JKorf / Binance.Net

A C# .netstandard client library for the Binance REST and Websocket Spot and Futures API focusing on clear usage and models
https://jkorf.github.io/Binance.Net/
MIT License
1.04k stars 425 forks source link

get limit order sl tp order data #1005

Open sinaptech opened 2 years ago

sinaptech commented 2 years ago

Hi. for futures api USDT please help me how to get SL and TP limit order when the main order is limit too?

sinaptech commented 2 years ago

@HypsyNZ You do not have to worry about the rest. If you know this, help me, if not, you do not need to answer

eros1453 commented 2 years ago

This is for TP : var startTP = await bfc.UsdFuturesApi.Trading.PlaceOrderAsync(ASSET, side: OrderSide.Sell, positionSide: PositionSide.Long, type: FuturesOrderType.TakeProfit, quantity: long_quantity, price: long_price, stopPrice: actpr, timeInForce: TimeInForce.GoodTillCanceled); You can make await order than => if(PositionLongOpenOrder.Success) { .... } For TP/SL you have to use STOP/TAKE_PROFIT | quantity, price, stopPrice

sinaptech commented 2 years ago

@eros1453 Thank you. Is it works on Both Cross and Isolated?

eros1453 commented 2 years ago

yes for me But try it on both way, sometimes when you miss the order on one side it will close the other side positionb on 'Hedge mode`

sinaptech commented 2 years ago

@eros1453 Hi. I place an order with the following parameter values first for the limit order: Order Side: Sell, Order Type: Limit, Quantity: 5 ADA, PositionSide: Short, TimeInForce: TimeInForce.GoodTillCancel, Price: 1.25

after success result I place another order for SL Limit as follows: Order Side: Buy, Order Type: Stop, Quantity: 5 ADA, PositionSide: Short, TimeInForce: TimeInForce.GoodTillCancel, Price: 1.25, StopPrice: 1.45

But at binance the result is not as expected. see screen shot please b1

sinaptech commented 2 years ago

@HypsyNZ I have set order type to stoplosslimit. binance futures api return error Invalid orderType. Shouldn't I set closeposition=true??

sinaptech commented 2 years ago

@JKorf @HypsyNZ I want to place a limit order with limit stoploss order too like the attached files in binance. I could not add stoploss order limit by this package. b3 b2

eros1453 commented 2 years ago

@eros1453 Hi. I place an order with the following parameter values first for the limit order: Order Side: Sell, Order Type: Limit, Quantity: 5 ADA, PositionSide: Short, TimeInForce: TimeInForce.GoodTillCancel, Price: 1.25

after success result I place another order for SL Limit as follows: Order Side: Buy, Order Type: Stop, Quantity: 5 ADA, PositionSide: Short, TimeInForce: TimeInForce.GoodTillCancel, Price: 1.25, StopPrice: 1.45

But at binance the result is not as expected. see screen shot please b1

Its cause from limit price. the order is not executed immediately. I use orderbook and use the bestAsk or bestBuy price. On fast moving market it gets stuck sometimes. Its better to use market order for position opening for fast trades

sinaptech commented 2 years ago

@eros1453 @JKorf I have still confused in creating limit order with SL and TP limit order like https://github.com/JKorf/Binance.Net/issues/1005#issuecomment-1061823508 I want to know If I can place order with this package like the above screenshots.

eros1453 commented 2 years ago

Best way is to send Limit order with custom Order ID and when you receive the result trough userdatastream Event: Order Update execute the SL/TP orders. That must be the logic

urbanchaman commented 5 months ago

Best way is to send Limit order with custom Order ID and when you receive the result trough userdatastream Event: Order Update execute the SL/TP orders. That must be the logic

thank you my lord of humanity. you just cured my depression.