I am using the Binance Python API (Python 3.x)
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
@michaeldel ETA: I am using this here: https://python-binance.readthedocs.io/en/latest/
For the Orders, I have been following: https://python-binance.readthedocs.io/en/latest/account.html?highlight=orders#orders
Can you note what the equivalent would be the equivalent under this (Python) API?
I have been using: "get_all_orders" with a focus of the "STATUS" being "FILLED". https://python-binance.readthedocs.io/en/latest/binance.html#binance.client.Client.get_all_orders
I was looking for Open Positions (not Orders)
If a BTCUSDT SELL Position that has status=FILLED with a origQty =.20, I want to be able to reverse it with a BUY and a Quantity of .20
If a BTCUSDT BUY Position has status=FILLED and a origQty=.30, I want to be able to reverse it with a SELL and a Quantity of .30
Does this make sense?
Is there a better way to do it? Am I missing something?
Thanks for the input!
Log in to your Binance account and go to [Wallet] - [Margin]. For Cross Margin positions, simply click [Close All Positions] to close all your positions in the Cross Margin account. For Isolated Margin positions, click [Close All Positions] next to the pairs you wish to close.
The Close All Positions function allows traders to efficiently exit all positions simultaneously in the event of extreme market conditions. With this feature, you can cancel all open orders and exit all positions immediately.
Log in to your Binance account and go to [Wallet] - [Margin]. Simply click [Close All Positions] to close all your positions in the Cross Margin account. Alternatively, you may use the [Close All Position] function on the trading page.
Closing a long position in a security would entail selling it, while closing a short position in a security would involve buying it back. Taking offsetting positions in swaps is also very common to eliminate exposure prior to maturity. Closing a position is also known as "position squaring."
For binance futures this feature was added at 2020-05-18!
With the STOP_MARKET
or TAKE_PROFIT_MARKET
you can use closePosition
param!
closePosition=true
As per the change long from the api doc here:
2020-05-18
New parameter closePosition for endpoint POST /fapi/v1/order: If a STOP_MARKET or TAKE_PROFIT_MARKET order with closePosition=true is triggered,all of the current long position( if SELL order) or current short position( if BUY order) will be closed.
New field closePosition in response to endpoints:
- POST /fapi/v1/order
- POST /fapi/v1/batchOrders
- GET /fapi/v1/order
- DELETE /fapi/v1/order
- DELETE /fapi/v1/batchOrders
- GET /fapi/v1/openOrder
- GET /fapi/v1/openOrders
- GET /fapi/v1/allOrders
Check the new order doc description
Also, when it is FILLED, my understanding is that a POSITION is being created (Long or Short)
As far as I know, Binance does not provide semantics for position (in terms of trading). Such abstractions are usually implemented for derivatives (e.g. futures) when it comes to currency markets, since currencies buying-and-selling-to-make-profit is not their only use.
On Binance, and most other cryptocurrency exchanges, you are making spot transactions, i.e. giving some amount of a currency to receive some amount of another currency. Plain and simple.
You may abstract positions yourself though, but that may involve much more work especially considering heterogeneous chains of transaction (e.g. BTC -> ETH -> USDT -> BTC
), partial fills, etc.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With