ExchangeSharp icon indicating copy to clipboard operation
ExchangeSharp copied to clipboard

how to set a stop loss in binance

Open paulc1983 opened this issue 3 years ago • 1 comments
trafficstars

hi

i get this error submitting a stop order or binance.: Parameter 'timeInForce' sent when not required.

that is submitting it as stop with isBuy = false.

I have looked at the code and set ispostonly = true , or modified the code to prevent the time in force param being added and get: Binance stop order : ExchangeSharp.APIException: {"code":-1106,"msg":"Parameter 'price' sent when not required."}

whats the correct way to set a stop loss in binance?

I modified the code to change the type of order to 'STOP_LOSS_LIMIT' and added : if (order.OrderType == OrderType.Stop) payload["stopPrice"] = order.StopPrice;

this works. should i create a branch with these changes and raise a pr or is there a better way to do this using the existing 'STOP_LOSS' type?

paulc1983 avatar May 12 '22 08:05 paulc1983

You could probably incorporate fixes for both STOP_LOSS and STOP_LOSS_LIMIT. First, do a refactor rename to the enum OrderType.Stop to StopMarket. Then, add another enum member OrderType.StopLimit. And then you can make the fixes you proposed above, as well as likely editing the line where timeInForce is set. Go ahead send a PR and we'll get it merged.

vslee avatar May 12 '22 19:05 vslee