1

I can get all open orders (take profit or stop loss ), but I dont know if some position is "open".

Positions = exchange.fetchPositions(symbols = 'SOL/USDT:USDT', params = {})

I get the following error:

AttributeError: 'kucoinfutures' object has no attribute 'fetchAccountPositions'

Sometimes, there is an active trade and if I want to put another position and a tp/sl, two things happen: If the position is contrary to the previous one and if they have the same amount, simply the previous position is cancelled, and the new position enters.

But when the amount of the new position is different from the previous position and if the amount of the TP/SL is calculated to the amount of the new position, there would be an open position after a TP or SL occurs, with the remaining amount, there is an open position.

Alex B
  • 1,092
  • 1
  • 14
  • 39
maxixmo
  • 45
  • 1
  • 6
  • 1
    Looks like you forgot to post the Python code that's causing you a problem – DarkKnight May 22 '22 at 07:08
  • I don't know what code I could put, I try with this code "exchange.fetchMyTrades(simbol)" but I don't get what I really need, if someone knows how to put an example code – maxixmo May 22 '22 at 08:08
  • 1
    You need to add the code that's causing you problems to the question - a minimal reproducible example – DarkKnight May 22 '22 at 08:10
  • Please edit your question to include a code block and/or error message in the body of question. [How do I format my posts using Markdown or HTML?](https://stackoverflow.com/help/formatting). – Alex B May 22 '22 at 08:31
  • Have you tried to get information about positions currently held as describred in this section of ccxt docs? https://docs.ccxt.com/en/latest/manual.html#positions – Alex B May 22 '22 at 08:37
  • Positions = exchange.fetchPositions(symbols = 'SOL/USDT:USDT', params = {}) it returns me error: AttributeError: 'kucoinfutures' object has no attribute 'fetchAccountPositions' – maxixmo May 22 '22 at 09:56
  • have you tried `positions = exchange.fetchPositions()` ? – Alex B May 22 '22 at 14:03
  • yes and the same error comes out – maxixmo May 22 '22 at 14:43
  • ok it works for me on binance. i'll setup an account on kucoin later and try it there later on. – Alex B May 22 '22 at 15:18
  • Ok, very good Alex B, thanks – maxixmo May 22 '22 at 18:10

1 Answers1

2

Does this work for you or do you still get an error message?

import ccxt

exchange = ccxt.kucoinfutures({
    'apiKey': [...],
    'secret': [...],
    'password': [...],
    'enableRateLimit': True,
})

markets = exchange.load_markets()
positions = exchange.fetchPositions(symbols = 'SOL/USDT:USDT', params = {})
print(positions)
Alex B
  • 1,092
  • 1
  • 14
  • 39
  • if it works now, incredible, I don't know why it didn't work yesterday. Thanks to all for the help :) – maxixmo May 23 '22 at 17:26
  • @maxixmo you're welcome. Please accept the answer as correct and upvote if you can. I have the feeling you were using `fetchAccountPositions` instead of `fetchPositions` maybe. – Alex B May 23 '22 at 17:29
  • could you fetch all positions without specifying symbols – Rado Mar 29 '23 at 16:16