{"record":{"id":"6d4558c979188ac6","repo":"nautechsystems/nautilus_trader","slug":"invalid-price-for-key-s","errorCode":null,"errorMessage":"invalid price for '{key}': '{s}'","messagePattern":"invalid price for '(.+?)': '(.+?)'","errorType":"validation","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"crates/adapters/bybit/src/common/parse.rs","lineNumber":1822,"sourceCode":"        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\n                .parse()\n                .map_err(|_| anyhow::anyhow!(\"invalid price for '{key}': '{s}'\"))?;\n\n            if !v.is_finite() || v < 0.0 {\n                anyhow::bail!(\n                    \"invalid price for '{key}': '{s}', expected a finite non-negative number\"\n                );\n            }\n            *setter = Some(s);\n        }\n    }\n\n    if let Some(s) = params.get_str(\"tp_trigger_by\") {\n        result.tp_trigger_by = Some(parse_trigger_type(s)?);\n    }\n\n    if let Some(s) = params.get_str(\"sl_trigger_by\") {\n        result.sl_trigger_by = Some(parse_trigger_type(s)?);\n    }\n","sourceCodeStart":1804,"sourceCodeEnd":1840,"githubUrl":"https://github.com/nautechsystems/nautilus_trader/blob/18893faf8b356be3320add8de2f861b0b647cf06/crates/adapters/bybit/src/common/parse.rs#L1804-L1840","documentation":"For trigger-price parameters ('tp_trigger_price' and 'sl_trigger_price'), parse_bybit_tp_sl_params parses the string as f64 and rejects values that fail to parse or (in the follow-up check) are non-finite/negative. This specific error fires when the string cannot be parsed as a number at all.","triggerScenarios":"Order params contain 'tp_trigger_price' or 'sl_trigger_price' with a value that f64::from_str rejects — empty string, descriptive text, numbers with units ('65000 USD'), or comma-formatted numbers.","commonSituations":"Config-driven strategies with placeholder trigger values; strings carrying thousands separators ('65,000.5'); accidentally passing the key with an empty value from a partially-filled UI/config; prior step producing 'NaN'.","solutions":["Ensure trigger price params are clean numeric strings, e.g. \"65000.5\" (trim whitespace, no separators/units).","Validate with a parse check before submitting: value.parse::<f64>() and confirm finite and >= 0.","Omit the trigger-price keys when the feature is not used instead of sending empty values.","Sanitize upstream numeric formatting so no commas or unit suffixes leak into the string."],"exampleFix":"// before\nparams.insert(\"sl_trigger_price\".into(), trigger_price_input.to_string());\n// after\nlet v: f64 = trigger_price_input.trim().parse()?;\nanyhow::ensure!(v.is_finite() && v >= 0.0, \"sl_trigger_price must be finite non-negative\");\nparams.insert(\"sl_trigger_price\".into(), format!(\"{v}\"));","handlingStrategy":"validation","validationCode":"// Rust: validate trigger prices before building order params\nfn valid_trigger(s: &str) -> bool {\n    s.trim().parse::<f64>().map(|v| v.is_finite() && v >= 0.0).unwrap_or(false)\n}\nif !valid_trigger(&sl_trigger) { anyhow::bail!(\"bad sl_trigger_price: {sl_trigger}\"); }","typeGuard":"fn parse_trigger(s: &str) -> Option<f64> {\n    s.trim().parse::<f64>().ok().filter(|v| v.is_finite() && *v >= 0.0)\n}","tryCatchPattern":"let p = parse_bybit_tp_sl_params(&params)\n    .inspect_err(|e| log::error!(\"invalid TP/SL trigger params: {e:#}\"))?;","preventionTips":["Send plain numeric strings with no units, commas, or whitespace","Only include trigger keys when trigger orders are actually configured","Unit-test param building with boundary values (0, very small, very large)"],"tags":["order-params","trigger-price","parsing","bybit"],"backgroundTag":"invalid-argument-format","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"}