{"record":{"id":"ac2df5a1d55a60c1","repo":"nautechsystems/nautilus_trader","slug":"invalid-stop-loss-price-e","errorCode":null,"errorMessage":"invalid 'stop_loss' price: {e}","messagePattern":"invalid 'stop_loss' price: (.+?)","errorType":"validation","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"crates/adapters/bybit/src/common/parse.rs","lineNumber":1802,"sourceCode":"\n    let mut result = BybitTpSlParams {\n        is_leverage: params.get_bool(\"is_leverage\").unwrap_or(false),\n        ..Default::default()\n    };\n\n    if let Some(s) = get_price_str(params, \"take_profit\") {\n        let p =\n            Price::from_str(&s).map_err(|e| anyhow::anyhow!(\"invalid 'take_profit' price: {e}\"))?;\n\n        if p.as_f64() < 0.0 {\n            anyhow::bail!(\"invalid 'take_profit' price: '{s}', expected a non-negative value\");\n        }\n        result.take_profit = Some(p);\n    }\n\n    if let Some(s) = get_price_str(params, \"stop_loss\") {\n        let p =\n            Price::from_str(&s).map_err(|e| anyhow::anyhow!(\"invalid 'stop_loss' price: {e}\"))?;\n\n        if p.as_f64() < 0.0 {\n            anyhow::bail!(\"invalid 'stop_loss' price: '{s}', expected a non-negative value\");\n        }\n        result.stop_loss = Some(p);\n    }\n\n    for (key, setter) in [\n        (\n            \"tp_limit_price\",\n            &mut result.tp_limit_price as &mut Option<String>,\n        ),\n        (\"sl_limit_price\", &mut result.sl_limit_price),\n        (\"tp_trigger_price\", &mut result.tp_trigger_price),\n        (\"sl_trigger_price\", &mut result.sl_trigger_price),\n    ] {\n        if let Some(s) = get_price_str(params, key) {\n            let v: f64 = s","sourceCodeStart":1784,"sourceCodeEnd":1820,"githubUrl":"https://github.com/nautechsystems/nautilus_trader/blob/18893faf8b356be3320add8de2f861b0b647cf06/crates/adapters/bybit/src/common/parse.rs#L1784-L1820","documentation":"parse_bybit_tp_sl_params reads an optional 'stop_loss' param from the order params map and parses it into a Price via Price::from_str; unparseable values raise this error (negative values are rejected separately). It means the stop-loss value supplied is not a valid price string.","triggerScenarios":"Submitting/modifying an order with params['stop_loss'] set to an empty string, non-numeric text, NaN/inf, or a value violating Price parsing rules (e.g. too many decimals for precision).","commonSituations":"Hardcoded placeholder stop-losses in config; float formatting producing scientific notation for very small prices; strategy passing sentinel values like 0 or -1 meant to mean 'no stop'; locale-formatted numbers.","solutions":["Ensure stop_loss is a valid decimal price string with decimals fitting the instrument's price precision.","Omit the key entirely when no stop-loss is intended instead of passing empty/placeholder values.","Validate the price is finite and positive before adding to params.","Format floats explicitly (fixed-point, e.g. {:.8g} or precision-aware) rather than relying on default Display of f64."],"exampleFix":"// before\nparams.insert(\"stop_loss\".into(), sl.to_string()); // f64, may be 0.0 or NaN\n// after\nif let Some(sl) = sl.filter(|v| v.is_finite() && *v > 0.0) {\n    params.insert(\"stop_loss\".into(), format!(\"{:.2}\", sl));\n}","handlingStrategy":"validation","validationCode":"// Rust: validate stop_loss param before building order\nlet sl = sl.filter(|v| v.is_finite() && *v > 0.0)\n    .map(|v| format!(\"{v:.instrument_price_precision$}\"));","typeGuard":"fn valid_sl_string(s: &str) -> bool {\n    s.trim().parse::<f64>().map(|v| v.is_finite() && v > 0.0).unwrap_or(false)\n}","tryCatchPattern":"let p = parse_bybit_tp_sl_params(&params)\n    .map_err(|e| { log::error!(\"bad stop_loss/TP params: {e:#}\"); e })?;","preventionTips":["Don't send sentinel values (0, -1) as stop prices; omit the key instead","Format stop prices with fixed-point notation, never default f64 Display","Verify price fits instrument precision before submission"],"tags":["order-params","stop-loss","parsing","bybit"],"backgroundTag":"invalid-argument-value","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"}