When one uses the “create_order” functionality, it creates an order on the SPOT exchange with a STATUS of NEW. When it gets filled, the STATUS goes to FILLED.
Also, when it is FILLED, my understanding is that a POSITION is being created (Long or Short)
My question is as follows:
What endpoint can I use to get a list of the Open Positions.
Why do I want this?
If a Position is on the SELL side, I would like to execute a BUY to close it.
If a Position is on the BUY side, I would like to execute a SELL to close it.
Can this be done?
Any help, hints or advice would be ~greatly~ appreciated.
TIA
ETA: I have also logged the message on the Stackoverflow developer’s site.
Spot trading doesn’t have positions like other instruments do because you are settling the trade immediately. When you place an order to buy BNB using USDT and it becomes FILLED, that BNB is immediately credited to your account.
If you logically really want to put a position concept on it: if you sell USDT to buy BNB, you can think of it that you’re Long on BNB. You would sell your BNB to “close” the position.
The closet way to list a of “open spot positions” in the way you are thinking about it would be to get your balances via GET api/v3/account.
I believe the issue with the balances that are pulled using the Get api/v3/account request relates to the fact that the response iterates every single coin rather than just coins with a balance >0.
How do you:
limit the iteration of coin balances of amounts >0
how do you select the objects within, what appears to be a single element array: for example
balances [
{asset: BTC, free 0.12345678, locked 0.12345678},…]
There doesn’t appear to be a filter for it.
Is the best way to complete this task using the daily account Snapshot GET /sapi/v1/accountSnapshot (HMAC SHA256
Is Lodash the best resource for completing this task, if so, which helper. If not, what do you recommend?
Many Thanks