Closed pfpietro closed 1 year ago
Also setting 'reduceOnly': 'true' in the params I get insufficient margin.
@pfpietro I've opened a pull request that adds reduceOnly to createOrder. Once the PR is merged this request will work properly for closing your order:
params = {'marginMode': 'cross', 'reduceOnly': true}
order = await self.okx.create_order(
symbol='XRP/USDT', type='market', side='buy',
amount=35.2446, price=undefined, params=params
)
I'd recommend using 'marginMode' instead of 'tdMode' and you need to enter the amount in USDT which can be found from fetchPosition -> info -> availPos
Alternatively you could try using the implicit api https://docs.ccxt.com/en/latest/manual.html#implicit-api with this endpoint privatePostTradeClosePosition
https://www.okx.com/docs-v5/en/#rest-api-trade-close-positions
order = await self.okx.privatePostTradeClosePosition({
'instId': 'XRP-USDT',
'mgnMode': 'cross',
})
Thanks Dan.
Hi all, my issue is probably something really simple but I don't get where am I doing wrong. I open a position with a given amount and close the position with the same amount. But somehow when closing, the order opens a order 2.5 times bigger than the expected.
OPEN ORDER:
RESULT:
Now when I close the current order:
If get the following:
How come in the second one I get the COST completely different from the first one ?