setTradingStop method
Set trading-stop. https://bybit-exchange.github.io/docs/inverse/#t-tradingstop
Implementation
Future<Map<String, dynamic>?> setTradingStop({
required String symbol,
double? takeProfit,
double? stopLoss,
double? trailingStop,
String? tpTriggerBy,
String? slTriggerBy,
double? newTrailingTriggerPrice,
double? tpSize,
double? slSize,
}) async {
log.d('ByBitRest.setTradingStop');
var parameters = <String, dynamic>{};
parameters['symbol'] = symbol;
if (takeProfit != null) parameters['take_profit'] = takeProfit;
if (stopLoss != null) parameters['stop_loss'] = stopLoss;
if (trailingStop != null) parameters['trailing_stop'] = trailingStop;
if (tpTriggerBy != null) parameters['tp_trigger_by'] = tpTriggerBy;
if (slTriggerBy != null) parameters['sl_trigger_by'] = slTriggerBy;
if (tpSize != null) parameters['tp_size'] = tpSize;
if (slSize != null) parameters['sl_size'] = slSize;
if (newTrailingTriggerPrice != null) {
parameters['new_trailing_active'] = newTrailingTriggerPrice;
}
return await request(
path: '/v2/private/position/trading-stop',
type: 'POST',
parameters: parameters,
withAuthentication: true,
);
}