{"record":{"id":"a0d3ddddd3b7c7f4","repo":"nautechsystems/nautilus_trader","slug":"sl-limit-price-requires-sl-order-type-to-be-l","errorCode":null,"errorMessage":"'sl_limit_price' requires 'sl_order_type' to be 'Limit'","messagePattern":"'sl_limit_price' requires 'sl_order_type' to be 'Limit'","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/adapters/bybit/src/common/parse.rs","lineNumber":1884,"sourceCode":"\n    if result.stop_loss.is_none() && has_sl_fields {\n        anyhow::bail!(\"SL override fields require 'stop_loss' to be set\");\n    }\n\n    if result.tp_order_type == Some(BybitOrderType::Limit) && result.tp_limit_price.is_none() {\n        anyhow::bail!(\"'tp_order_type' is 'Limit' but 'tp_limit_price' was not provided\");\n    }\n\n    if result.sl_order_type == Some(BybitOrderType::Limit) && result.sl_limit_price.is_none() {\n        anyhow::bail!(\"'sl_order_type' is 'Limit' but 'sl_limit_price' was not provided\");\n    }\n\n    if result.tp_limit_price.is_some() && result.tp_order_type != Some(BybitOrderType::Limit) {\n        anyhow::bail!(\"'tp_limit_price' requires 'tp_order_type' to be 'Limit'\");\n    }\n\n    if result.sl_limit_price.is_some() && result.sl_order_type != Some(BybitOrderType::Limit) {\n        anyhow::bail!(\"'sl_limit_price' requires 'sl_order_type' to be 'Limit'\");\n    }\n\n    result.close_on_trigger = params.get_bool(\"close_on_trigger\");\n\n    if let Some(value) = params.get(\"order_iv\") {\n        match get_price_str(params, \"order_iv\") {\n            Some(s) => result.order_iv = Some(s),\n            None => {\n                anyhow::bail!(\"invalid type for 'order_iv': {value}, expected string or number\")\n            }\n        }\n    }\n\n    if let Some(value) = params.get(\"mmp\") {\n        match value.as_bool() {\n            Some(b) => result.mmp = Some(b),\n            None => anyhow::bail!(\"invalid type for 'mmp': {value}, expected bool\"),\n        }","sourceCodeStart":1866,"sourceCodeEnd":1902,"githubUrl":"https://github.com/nautechsystems/nautilus_trader/blob/18893faf8b356be3320add8de2f861b0b647cf06/crates/adapters/bybit/src/common/parse.rs#L1866-L1902","documentation":"Cross-field validation in parse_bybit_tp_sl_params: sl_limit_price is only meaningful when sl_order_type is Limit; supplying the limit price together with a different (market) SL order type is rejected.","triggerScenarios":"Setting 'sl_limit_price' while 'sl_order_type' is missing or not \"Limit\".","commonSituations":"Configuring SL limit prices for market stop-losses; params built conditionally where sl_order_type is set later or under a different key.","solutions":["Set 'sl_order_type' to \"Limit\" together with 'sl_limit_price'","Remove 'sl_limit_price' when using a Market stop-loss"],"exampleFix":"// before\nparams.set(\"sl_limit_price\", \"39500\");\n// after\nparams.set(\"sl_order_type\", \"Limit\");\nparams.set(\"sl_limit_price\", \"39500\");","handlingStrategy":"validation","validationCode":"fn validate_sl_price(params: &Params) -> Result<(), String> {\n    if params.get(\"sl_limit_price\").is_some()\n        && params.get_str(\"sl_order_type\") != Some(\"Limit\") {\n        return Err(\"sl_limit_price requires sl_order_type = Limit\".into());\n    }\n    Ok(())\n}","typeGuard":"fn is_sl_price_without_limit(params: &Params) -> bool {\n    params.get(\"sl_limit_price\").is_some()\n        && params.get_str(\"sl_order_type\") != Some(\"Limit\")\n}","tryCatchPattern":"match parse_bybit_tp_sl_params(&params) {\n    Ok(p) => submit(p),\n    Err(e) if e.to_string().contains(\"'sl_limit_price' requires 'sl_order_type'\") => {\n        log::warn(\"SL price given without Limit type; set sl_order_type=Limit or drop the price\");\n    }\n    Err(e) => return Err(e),\n}","preventionTips":["Never emit sl_limit_price unless the SL order type is Limit","Model SL as enum { Market, Limit(Price) } so the pair is type-enforced","Validate merged configs for stray sl_limit_price values"],"tags":["bybit","params-validation","stop-loss","conflicting-params"],"backgroundTag":"conflicting-config-options","analyzedSha":"18893faf8b356be3320add8de2f861b0b647cf06","analyzedAt":"2026-09-08T20:49:34.690Z","contentChangedAt":"2026-09-08T20:49:34.690Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}