http91
March 23, 2021, 4:10pm
1
Similar to that question.
I want to go short by borrowing, then repay it (close it) when I’m done. How can I do it?
I understand how this all works in web GUI, but I couldn’t find the related API endpoints to achieve this functionality, most certainly my mistake.
Thanks!
Please check this API document section to get to know the endpoint for placing orders in futures: https://binance-docs.github.io/apidocs/futures/en/#new-order-trade
I would suggest use https://github.com/binance-exchange/binance-api-postman and futures testnet for the testing, because it’s not straightforward. The parameters depends your conditions, but in the simplest conditions (one-way mode, market order and no open positions):
POST https://testnet.binancefuture.com/fapi/v1/order?symbol=BNBUSDT&side=SELL&positionSide=BOTH&type=MARKET&quantity=0.03×tamp=1616535470671&signature=xxx
You can explore the API document further to see how to change the margin.
If you’re able to close the position with a loss, then you don’t have to repay, it’s already automatically deducted from your margin balance.
http91
March 24, 2021, 9:44am
4
I’m sorry, I forgot to add, I’m talking about isolated margin on altcoins and btc in general, not futures.
Thank you for your reply.
MJW
March 23, 2021, 10:27pm
3
You talking about margin trading or futures trading?
http91
March 24, 2021, 9:45am
5
Thank you for your reply!
My mistake, I’m sorry I forgot to mention it. Margin trading, specifically isolated margin.
MJW
March 24, 2021, 9:57am
6
sideEffectType=“MARGIN_BUY” to borrow
sideEffectType=“AUTO_REPAY” to pay back
Read the docs pls - https://binance-docs.github.io/apidocs/spot/en/#margin-account-new-order-trade
1 Like
http91
March 24, 2021, 10:45am
7
Thanks!
I missed the “side” parameter. Now it’s clear.