{"record":{"id":"4d388bf71c11e2ec","repo":"nautechsystems/nautilus_trader","slug":"invalid-take-profit-price-e","errorCode":null,"errorMessage":"invalid 'take_profit' price: {e}","messagePattern":"invalid 'take_profit' price: (.+?)","errorType":"validation","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"crates/adapters/bybit/src/common/parse.rs","lineNumber":1792,"sourceCode":"        \"1\" | \"2\" | \"3\" | \"4\" | \"5\" => Ok(s),\n        _ => anyhow::bail!(\"invalid 'bbo_level': '{s}', expected 1, 2, 3, 4, or 5\"),\n    }\n}\n\n/// Parses Bybit TP/SL parameters from an optional params map.\npub fn parse_bybit_tp_sl_params(params: Option<&Params>) -> anyhow::Result<BybitTpSlParams> {\n    let Some(params) = params else {\n        return Ok(BybitTpSlParams::default());\n    };\n\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 [","sourceCodeStart":1774,"sourceCodeEnd":1810,"githubUrl":"https://github.com/nautechsystems/nautilus_trader/blob/18893faf8b356be3320add8de2f861b0b647cf06/crates/adapters/bybit/src/common/parse.rs#L1774-L1810","documentation":"parse_bybit_tp_sl_params extracts TP/SL-related parameters from an order's params map. When a 'take_profit' key is present, its string value must parse into a Price via Price::from_str; failure produces this error (a separate check rejects negative values). It indicates the take-profit value supplied by the strategy is not a parseable price string.","triggerScenarios":"Submitting/modifying an order with params['take_profit'] set to a value Price::from_str rejects — empty string, non-numeric text, or a number exceeding price precision limits.","commonSituations":"Strategies passing floats/doubles instead of strings with sufficient decimal places; config files with placeholder or empty take-profit values; prices with more decimals than the instrument's precision; mixing NaN/inf from upstream calculations.","solutions":["Ensure the take_profit param is a valid decimal string (e.g. \"65000.5\"), not empty or descriptive text.","Validate/round the price to the instrument's price precision before attaching it to the order.","Only include the take_profit key when a real TP is intended (omit rather than pass empty string).","Sanitize upstream floats (reject NaN/inf, format with fixed decimals) before building params."],"exampleFix":"// before\nparams.insert(\"take_profit\".into(), format!(\"{}\", maybe_tp)); // maybe_tp: Option<f64>\n// after\nif let Some(tp) = maybe_tp.filter(|v| v.is_finite() && *v > 0.0) {\n    params.insert(\"take_profit\".into(), format!(\"{:.2}\", tp));\n}","handlingStrategy":"validation","validationCode":"// Rust: validate take_profit param before building order\nlet tp = tp.filter(|v| v.is_finite() && *v > 0.0)\n    .map(|v| format!(\"{v:.instrument_price_precision$}\"));","typeGuard":"fn valid_tp_string(s: &str) -> bool {\n    s.trim().parse::<f64>().map(|v| v.is_finite() && v > 0.0).unwrap_or(false)\n}","tryCatchPattern":"match parse_bybit_tp_sl_params(&params) {\n    Ok(p) => p,\n    Err(e) => { log::error!(\"rejecting order, bad TP/SL params: {e:#}\"); return Err(e); }\n};","preventionTips":["Omit take_profit key entirely when no TP is intended","Round TP to the instrument's price precision before submission","Reject NaN/inf upstream before formatting to string"],"tags":["order-params","take-profit","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"}