DigitalRuby / ExchangeSharp

ExchangeSharp is a powerful, fast and easy to use .NET/C# API for interfacing with many crypto currency exchanges. REST and web sockets are supported.
https://www.digitalruby.com
MIT License
741 stars 374 forks source link

how to set a stop loss in binance #780

Open paulc1983 opened 2 years ago

paulc1983 commented 2 years ago

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?

vslee commented 2 years ago

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.