-
Notifications
You must be signed in to change notification settings - Fork 767
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Futures order with TAKE_PROFIT_MARKET same time #614
Comments
I am working on the same thing, Check this. https://dev.binance.vision/t/how-to-implement-otoco-tp-sl-orders-using-api/1622 It seems we must do it by ourself. |
I applied a workaroung with creating a Trailing Stop Loss 2 second after creating market order. |
Hello guys, |
exactly, if you're placing market buy order then you can directly create a limit sell order with reduce only option as true right after market buy order. This is how i'm currently doing my auto trades |
Using the python-binance package I was able to achieve in putting the Stop Loss and Take Profit in 3 different actions: order = client.futures_create_order(
symbol='ETHUSDT', side=SIDE_BUY, type=ORDER_TYPE_MARKET, quantity=quantity, isolated=True, positionSide=positionSide)
client.futures_create_order(
symbol='ETHUSDT', side=SIDE_SELL, type=FUTURE_ORDER_TYPE_STOP_MARKET, quantity=quantity, positionSide=positionSide, stopPrice=stopLoss, timeInForce=TIME_IN_FORCE_GTC)
client.futures_create_order(
symbol='ETHUSDT', side=SIDE_SELL, type=FUTURE_ORDER_TYPE_TAKE_PROFIT_MARKET, quantity=quantity, positionSide=positionSide, stopPrice=takeProfit, timeInForce=TIME_IN_FORCE_GTC) 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 meet the same problems.How do I post in one order,just like APP submit. |
The app does not do this with a single order. if you trace the network requests of the app, it creates 3 orders just like @robyle's code sample. |
Hi, How do you get to know that either of the stop loss or take profits order has been triggered? Is there any callback or listener? |
You poll your orders, and/or you subscribe to Websocket updates. |
Yes, websockets is the way. Thank you. |
actually, I trance the binance desktop make order, it's indecated make a OTC order,but api was not surpported. |
Hello sir can you please explain how did you manage to cancel the sl and tp orders if one is triggered? |
Simply poll your orders or subscribe to websockets to see if one was filled, then cancel the other. |
I'm sorry sir, but I'm very new to programming, can you please explain to me how can I do that? |
Polling orders means, asking the Binance API every so-many seconds or minutes, for your list of orders and their status. Websockets means, subscribing to Binance's live feed of changes to orders relevant to you. To explain how to code this, would mean to write an entire blog post. The documentation for this particular API client, I would encourage you to learn a little bit more about programming before starting to work with automated trading. |
How did you implaement it? please explain how you did it in code |
connected to websocket which will push all the account actions |
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' SELL orderbuy_limit = client.futures_create_order( tp = round(45000,2) # TakeProfit = 45000 sl = round(50000,2) # StopLoss = 50000 TAKE_PROFIT_MARKET ordersell_gain_market = client.futures_create_order( STOP_MARKET ordersell_stop_market = client.futures_create_order( |
😎 😎 Thank you very much sir. This is highly appreciated
…On Tue, 28 Dec 2021, 16:14 Alessandro Mota, ***@***.***> wrote:
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
)
`
—
Reply to this email directly, view it on GitHub
<#614 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AL6XRBPL3HYLYD72NGDP3F3UTHA4VANCNFSM4ZIP3RNQ>
.
You are receiving this because you commented.Message ID:
***@***.***>
|
Sorry for the late reply, I guess it might have been already solved but I'd tell you my solution. |
hi, is this applicable in one way mode? i dont see gte_gtc in the ui |
Here'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:
Which will send the request with these parameters:
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?
The text was updated successfully, but these errors were encountered: