{"record":{"id":"7c7f1d50eebea7b5","repo":"nautechsystems/nautilus_trader","slug":"invalid-price-for-key-s-expected-a-finit","errorCode":null,"errorMessage":"invalid price for '{key}': '{s}', expected a finite non-negative number","messagePattern":"invalid price for '(.+?)': '(.+?)', expected a finite non-negative number","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/adapters/bybit/src/common/parse.rs","lineNumber":1825,"sourceCode":"        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\n    if let Some(s) = params.get_str(\"tp_order_type\") {\n        result.tp_order_type = Some(parse_tp_sl_order_type(s)?);\n    }","sourceCodeStart":1807,"sourceCodeEnd":1843,"githubUrl":"https://github.com/nautechsystems/nautilus_trader/blob/18893faf8b356be3320add8de2f861b0b647cf06/crates/adapters/bybit/src/common/parse.rs#L1807-L1843","documentation":"parse_bybit_tp_sl_params also accepts auxiliary override fields (trigger_by, order_type, limit_price, trigger_price for TP/SL) as numeric strings. Each is parsed as f64 and rejected with this error if the value is not finite (NaN/inf) or is negative.","triggerScenarios":"Passing params like tp_trigger_price='NaN', tp_limit_price='Infinity', or a negative value such as sl_trigger_price='-0.1' in the TP/SL params map.","commonSituations":"Division by zero or NaN propagating from indicator math into trigger prices, JSON configs containing Infinity, or sign bugs in delta-based trigger computation.","solutions":["Ensure the value is a finite non-negative number before putting it in params","Fix upstream math producing NaN/Infinity (e.g. division by zero) or use a fallback value","Validate/parse the numeric string in your strategy before order submission"],"exampleFix":"// before\nlet tp_trigger = indicator_value / zero_var; // may be NaN\nparams.insert(\"tp_trigger_price\", tp_trigger.to_string());\n// after\nlet tp_trigger = if indicator_value.is_finite() && indicator_value >= 0.0 { indicator_value } else { fallback };\nparams.insert(\"tp_trigger_price\", tp_trigger.to_string());","handlingStrategy":"validation","validationCode":"import math\nv = float(params[key])\nassert math.isfinite(v) and v >= 0, f\"{key} must be a finite non-negative number, got {v}\"","typeGuard":"fn is_finite_non_negative(s: &str) -> bool {\n    s.parse::<f64>().map(|v| v.is_finite() && v >= 0.0).unwrap_or(false)\n}","tryCatchPattern":"for key in [\"tp_trigger_price\", \"tp_limit_price\", \"sl_trigger_price\", \"sl_limit_price\"] {\n    if let Some(s) = params.get(key) {\n        assert!(is_finite_non_negative(s), \"bad {key}: {s}\");\n    }\n}","preventionTips":["Sanitize indicator-derived values for NaN/Infinity before use","Guard divisions that can produce NaN","Parse and validate all numeric params at config load time"],"tags":["bybit","tpsl","trigger-price","validation","nan"],"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"}