setTradingStop method

Future<Map<String, dynamic>?> setTradingStop({
  1. required String symbol,
  2. double? takeProfit,
  3. double? stopLoss,
  4. double? trailingStop,
  5. String? tpTriggerBy,
  6. String? slTriggerBy,
  7. double? newTrailingTriggerPrice,
  8. double? tpSize,
  9. double? slSize,
})

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,
  );
}