{"record":{"id":"32e0b8348d414ed6","repo":"nautechsystems/nautilus_trader","slug":"sl-order-type-is-limit-but-sl-limit-price-wa","errorCode":null,"errorMessage":"'sl_order_type' is 'Limit' but 'sl_limit_price' was not provided","messagePattern":"'sl_order_type' is 'Limit' but 'sl_limit_price' was not provided","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/adapters/bybit/src/common/parse.rs","lineNumber":1876,"sourceCode":"    let has_sl_fields = result.sl_trigger_by.is_some()\n        || result.sl_order_type.is_some()\n        || result.sl_limit_price.is_some()\n        || result.sl_trigger_price.is_some();\n\n    if result.take_profit.is_none() && has_tp_fields {\n        anyhow::bail!(\"TP override fields require 'take_profit' to be set\");\n    }\n\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            }","sourceCodeStart":1858,"sourceCodeEnd":1894,"githubUrl":"https://github.com/nautechsystems/nautilus_trader/blob/18893faf8b356be3320add8de2f861b0b647cf06/crates/adapters/bybit/src/common/parse.rs#L1858-L1894","documentation":"Cross-field validation in parse_bybit_tp_sl_params: sl_order_type was set to Limit but no sl_limit_price accompanies it, so a stop-loss limit order would lack its limit price. The params are rejected as inconsistent.","triggerScenarios":"Setting params 'sl_order_type' = \"Limit\" without 'sl_limit_price'.","commonSituations":"Configuring a limit stop-loss after switching from market; deserialized params where sl_limit_price was lost.","solutions":["Provide 'sl_limit_price' in params","Set 'sl_order_type' to \"Market\" if no limit price is intended"],"exampleFix":"// before\nparams.set(\"sl_order_type\", \"Limit\");\n// after\nparams.set(\"sl_order_type\", \"Limit\");\nparams.set(\"sl_limit_price\", \"39500\");","handlingStrategy":"validation","validationCode":"fn validate_sl_limit(params: &Params) -> Result<(), String> {\n    if params.get_str(\"sl_order_type\") == Some(\"Limit\") && params.get(\"sl_limit_price\").is_none() {\n        return Err(\"sl_order_type Limit requires sl_limit_price\".into());\n    }\n    Ok(())\n}","typeGuard":"fn is_limit_sl_missing_price(params: &Params) -> bool {\n    params.get_str(\"sl_order_type\") == Some(\"Limit\")\n        && params.get(\"sl_limit_price\").is_none()\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' was not provided\") => {\n        log::warn(\"Limit SL without price; add sl_limit_price or switch to Market\");\n    }\n    Err(e) => return Err(e),\n}","preventionTips":["Pair sl_order_type with sl_limit_price at construction time","Default SL order type to Market when no limit price is configured","Validate SL params in tests for every order-type variant"],"tags":["bybit","params-validation","stop-loss","limit-order"],"backgroundTag":"missing-required-argument","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"}