Reputation: 88
I am using ccxt to connect to ByBit and create orders.
symbol = 'SOLUSDT'
trade_res = exchange.create_order(symbol, amount=1, type='Market', side='Buy')
The above snippet buys 1 SOL against USDT. When I try to close the position by placing a sell order, I see that ByBit placed another Short position on SOL without closing the Long one (2 positions appear in the console):
How do I close a current position on ByBit using ccxt?
Upvotes: 4
Views: 4427
Reputation: 2341
Add reduceOnly
to params
to exit out of a futures order
symbol = 'SOLUSDT'
trade_res = exchange.create_order(symbol, amount=1, type='Market', side='sell', params={'reduceOnly': true})
Upvotes: 6