nautechsystems/nautilus_trader · error

'tp_limit_price' requires 'tp_order_type' to be 'Limit'

Error message

'tp_limit_price' requires 'tp_order_type' to be 'Limit'

What it means

The inverse constraint: providing 'tp_limit_price' only makes sense when the TP order type is Limit. If tp_order_type is absent or Market, the parser bails because the limit price would be ignored or invalid on Bybit.

Source

Thrown at crates/adapters/bybit/src/common/parse.rs:1880

    if result.take_profit.is_none() && has_tp_fields {
        anyhow::bail!("TP override fields require 'take_profit' to be set");
    }

    if result.stop_loss.is_none() && has_sl_fields {
        anyhow::bail!("SL override fields require 'stop_loss' to be set");
    }

    if result.tp_order_type == Some(BybitOrderType::Limit) && result.tp_limit_price.is_none() {
        anyhow::bail!("'tp_order_type' is 'Limit' but 'tp_limit_price' was not provided");
    }

    if result.sl_order_type == Some(BybitOrderType::Limit) && result.sl_limit_price.is_none() {
        anyhow::bail!("'sl_order_type' is 'Limit' but 'sl_limit_price' was not provided");
    }

    if result.tp_limit_price.is_some() && result.tp_order_type != Some(BybitOrderType::Limit) {
        anyhow::bail!("'tp_limit_price' requires 'tp_order_type' to be 'Limit'");
    }

    if result.sl_limit_price.is_some() && result.sl_order_type != Some(BybitOrderType::Limit) {
        anyhow::bail!("'sl_limit_price' requires 'sl_order_type' to be 'Limit'");
    }

    result.close_on_trigger = params.get_bool("close_on_trigger");

    if let Some(value) = params.get("order_iv") {
        match get_price_str(params, "order_iv") {
            Some(s) => result.order_iv = Some(s),
            None => {
                anyhow::bail!("invalid type for 'order_iv': {value}, expected string or number")
            }
        }
    }

    if let Some(value) = params.get("mmp") {

View on GitHub (pinned to 18893faf8b)

Solutions

  1. Set 'tp_order_type' to "Limit" alongside 'tp_limit_price'
  2. Remove 'tp_limit_price' if the TP order should remain Market

Example fix

// before
params.set("tp_limit_price", "45000");
// after
params.set("tp_order_type", "Limit");
params.set("tp_limit_price", "45000");
Defensive patterns

Strategy: validation

Validate before calling

fn validate_tp_price(params: &Params) -> Result<(), String> {
    if params.get("tp_limit_price").is_some()
        && params.get_str("tp_order_type") != Some("Limit") {
        return Err("tp_limit_price requires tp_order_type = Limit".into());
    }
    Ok(())
}

Type guard

fn is_tp_price_without_limit(params: &Params) -> bool {
    params.get("tp_limit_price").is_some()
        && params.get_str("tp_order_type") != Some("Limit")
}

Try / catch

match parse_bybit_tp_sl_params(&params) {
    Ok(p) => submit(p),
    Err(e) if e.to_string().contains("'tp_limit_price' requires 'tp_order_type'") => {
        log::warn("TP price given without Limit type; set tp_order_type=Limit or drop the price");
    }
    Err(e) => return Err(e),
}

Prevention

When it happens

Trigger: Setting 'tp_limit_price' while 'tp_order_type' is missing, "Market", or anything other than "Limit".

Common situations: Adding a limit price to existing Market TP/SL params; forgetting that the price requires explicitly opting into a Limit TP order type.

Related errors


AI-assisted analysis of nautechsystems/nautilus_trader@18893faf8b (2026-09-08). Data as JSON: /api/errors/ba11a14d4d798d9f. Report an issue: GitHub.