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

Can't place trailing stop without price #1211

Open ydanila opened 1 year ago

ydanila commented 1 year ago

Binance API has such decription for trailing stops

Information on Trailing Stops

SPOT API

Trailing Stops have been enabled.
This is a type of algo order where the activation is based on a percentage of a price change in the market using the new parameter trailingDelta.
This can only used with any of the following order types: STOP_LOSS, STOP_LOSS_LIMIT, TAKE_PROFIT, TAKE_PROFIT_LIMIT.
The trailingDelta parameter will be done in Basis Points or BIPS.
For example: a STOP_LOSS SELL order with a trailingDelta of 100 will trigger after a price decrease of 1%. (100 / 10,000 => 0.01 => 1%)
When used in combination with OCO Orders, the trailingDelta will determine when the contingent leg of the OCO will trigger.
When trailingDelta is used in combination with stopPrice, once the stopPrice condition is met, the trailing stop starts tracking the price change from the stopPrice based on the trailingDelta provided.
When no stopPrice is sent, the trailing stop starts tracking the price changes from the last price based on the trailingDelta provided.

But when I am trying to place trailing stop without price like this

var orderResponse = await _restBinanceClient.SpotApi.Trading.PlaceOrderAsync(
            pair.Symbol,
            OrderSide.Sell,
            SpotOrderType.StopLossLimit,
            timeInForce: TimeInForce.GoodTillCanceled,
            orderResponseType:OrderResponseType.Full,
            quantity: stop.Quantity,
            trailingDelta: trailingDeltaBips,
            newClientOrderId: orderId);

It always returns same error. OriginalData: {"code":-1102,"msg":"Mandatory parameter 'price' was not sent, was empty/null, or malformed."}

Is this bug or I need to provide another arguments to get desired behaviour?

When no stopPrice is sent, the trailing stop starts tracking the price changes from the last price based on the trailingDelta provided.

JKorf commented 1 year ago

price isn't the same as stopPrice. The message is complaining about price missing, not stopPrice