{"record":{"id":"ba11a14d4d798d9f","repo":"nautechsystems/nautilus_trader","slug":"tp-limit-price-requires-tp-order-type-to-be-l","errorCode":null,"errorMessage":"'tp_limit_price' requires 'tp_order_type' to be 'Limit'","messagePattern":"'tp_limit_price' requires 'tp_order_type' to be 'Limit'","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/adapters/bybit/src/common/parse.rs","lineNumber":1880,"sourceCode":"\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            }\n        }\n    }\n\n    if let Some(value) = params.get(\"mmp\") {","sourceCodeStart":1862,"sourceCodeEnd":1898,"githubUrl":"https://github.com/nautechsystems/nautilus_trader/blob/18893faf8b356be3320add8de2f861b0b647cf06/crates/adapters/bybit/src/common/parse.rs#L1862-L1898","documentation":"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.","triggerScenarios":"Setting 'tp_limit_price' while 'tp_order_type' is missing, \"Market\", or anything other than \"Limit\".","commonSituations":"Adding a limit price to existing Market TP/SL params; forgetting that the price requires explicitly opting into a Limit TP order type.","solutions":["Set 'tp_order_type' to \"Limit\" alongside 'tp_limit_price'","Remove 'tp_limit_price' if the TP order should remain Market"],"exampleFix":"// before\nparams.set(\"tp_limit_price\", \"45000\");\n// after\nparams.set(\"tp_order_type\", \"Limit\");\nparams.set(\"tp_limit_price\", \"45000\");","handlingStrategy":"validation","validationCode":"fn validate_tp_price(params: &Params) -> Result<(), String> {\n    if params.get(\"tp_limit_price\").is_some()\n        && params.get_str(\"tp_order_type\") != Some(\"Limit\") {\n        return Err(\"tp_limit_price requires tp_order_type = Limit\".into());\n    }\n    Ok(())\n}","typeGuard":"fn is_tp_price_without_limit(params: &Params) -> bool {\n    params.get(\"tp_limit_price\").is_some()\n        && params.get_str(\"tp_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(\"'tp_limit_price' requires 'tp_order_type'\") => {\n        log::warn(\"TP price given without Limit type; set tp_order_type=Limit or drop the price\");\n    }\n    Err(e) => return Err(e),\n}","preventionTips":["Never emit tp_limit_price unless the TP order type is Limit","Keep order type and price in one struct field pair (enum Limit(Price) / Market)","Reject contradictory TP config at config-load time"],"tags":["bybit","params-validation","take-profit","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-14T05:17:10.506Z"}