How to retrieve active positions using CCXT library on Kucoin exchange?

4.6k Views Asked by At

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.

1

There are 1 best solutions below

3
On BEST ANSWER

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)