Futures order with TAKE_PROFIT_MARKET same time
See original GitHub issueHere’s my achievement that’s what I’m trying to make on API:
Create an order for BTCUSDT from 53000 price with 0.005 quantity and set TP value as markprice=54000 when order executed. This is what I can do from app as like this:
I tried with this code block:
await binance.futuresOrder( 'BUY', 'BTCUSDT', 0.005, 53000, { type: 'TAKE_PROFIT', stopPrice: 54000 } )
Which will send the request with these parameters:
{
type: 'TAKE_PROFIT',
stopPrice: 54000,
symbol: 'BTCUSDT',
side: 'BUY',
quantity: 0.005,
price: 53000,
timeInForce: 'GTX'
}
But order opening as wrong way like this:
However when I place the order from app it shows like this:
When I click on View under TP/SL it shows a condition like this:
How can I achieve this via API?
Issue Analytics
- State:
- Created 3 years ago
- Reactions:6
- Comments:21 (3 by maintainers)
Top Results From Across the Web
Futures Order Types - Kraken Support
This article details the order types available when trading futures contracts. For spot and margin trading order types, see Summary of Order Options....
Read more >Futures PlaceOrder and - set up take profit #734 - GitHub
I try to find solution about place order. How can i set Take profit when i place order? var otwarte_pozycje = client.FuturesUsdt.Order.
Read more >12. Advanced Order Types: Conditional Orders - Kraken Futures
Key points: - Conditional orders allow you to set trigger prices and actions, and can be a valuable tool for certain strategies.
Read more >Take Profit Orders On Kraken: Use Market Or Limit Order?
Today we'll look at what a take profit order is and what the differences are between a take profit market order and take...
Read more >What is a market if touched order-FUTU Help Center
If you submit a sell take profit market order at a take profit trigger price of 15 when the market ... You can...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Using the python-binance package I was able to achieve in putting the Stop Loss and Take Profit in 3 different actions:
But still not able to execute the same order in the same line. Though for the time being it works as desired.
EDIT: Now after using it I’ve come across problems that if for example even if the Stop Loss is triggered then the Take Profit order is still there and it interferes with my later orders. For this then I had to write down another logic to get the order Id of my stop losses and take profits and cancel them every time either one is triggered. The need for a single command now is axiomatic.
I was able to solve this problem by adding these arguments timeInForce=‘GTE_GTC’, workingType=‘MARK_PRICE’, priceProtect=True. Remember that I’m using mode position = HEDGE, for this reason I have to inform the positionSide argument.
`coin = ‘BTCUSDT’ qtd = 0.001
SELL order
buy_limit = client.futures_create_order( symbol=coin, side=‘BUY’, positionSide=‘LONG’, type=‘MARKET’, quantity=0.001 )
tp = round(45000,2) # TakeProfit = 45000
sl = round(50000,2) # StopLoss = 50000
TAKE_PROFIT_MARKET order
sell_gain_market = client.futures_create_order( symbol=coin, side=‘SELL’, positionSide=‘LONG’, type=‘TAKE_PROFIT_MARKET’, stopPrice=tp, closePosition=True, timeInForce=‘GTE_GTC’, workingType=‘MARK_PRICE’, priceProtect=True )
STOP_MARKET order
sell_stop_market = client.futures_create_order( symbol=coin, side=‘SELL’, positionSide=‘LONG’, type=‘STOP_MARKET’, stopPrice=sl, closePosition=True, timeInForce=‘GTE_GTC’, workingType=‘MARK_PRICE’, priceProtect=True ) `