{"record":{"id":"20d41809ec5168d6","repo":"nautechsystems/nautilus_trader","slug":"invalid-type-for-order-iv-value-expected-str","errorCode":null,"errorMessage":"invalid type for 'order_iv': {value}, expected string or number","messagePattern":"invalid type for 'order_iv': (.+?), expected string or number","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/adapters/bybit/src/common/parse.rs","lineNumber":1893,"sourceCode":"    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\") {\n        match value.as_bool() {\n            Some(b) => result.mmp = Some(b),\n            None => anyhow::bail!(\"invalid type for 'mmp': {value}, expected bool\"),\n        }\n    }\n\n    if let Some(value) = params.get(\"smp_type\") {\n        let smp_type = value.as_str().ok_or_else(|| {\n            anyhow::anyhow!(\"invalid type for 'smp_type': {value}, expected string\")\n        })?;\n        result.smp_type = Some(parse_smp_type(smp_type)?);\n    }\n","sourceCodeStart":1875,"sourceCodeEnd":1911,"githubUrl":"https://github.com/nautechsystems/nautilus_trader/blob/18893faf8b356be3320add8de2f861b0b647cf06/crates/adapters/bybit/src/common/parse.rs#L1875-L1911","documentation":"'order_iv' (implied volatility for Bybit options orders) must be convertible to a price string. The parser tries get_price_str which accepts strings or numbers; any other JSON value type causes this bail, embedding the offending value in the message.","triggerScenarios":"Passing 'order_iv' as a bool, null, array, or object in the params map.","commonSituations":"Programmatically built params where order_iv came from a loosely typed config or an untyped JSON blob (e.g. 0.42 parsed as bool-like or nested value).","solutions":["Pass 'order_iv' as a string (e.g. \"0.42\") or a JSON number","Sanitize the source value before inserting it into params"],"exampleFix":"// before\nparams.set(\"order_iv\", true);\n// after\nparams.set(\"order_iv\", \"0.42\");","handlingStrategy":"type-guard","validationCode":"fn validate_order_iv(params: &Params) -> Result<(), String> {\n    if let Some(v) = params.get(\"order_iv\") {\n        if !matches!(v, Value::String(_) | Value::Number(_)) {\n            return Err(format!(\"order_iv must be string or number, got {v}\"));\n        }\n    }\n    Ok(())\n}","typeGuard":"fn is_iv_like(v: &Value) -> bool {\n    matches!(v, Value::String(_) | Value::Number(_))\n}","tryCatchPattern":"match parse_bybit_tp_sl_params(&params) {\n    Ok(p) => submit(p),\n    Err(e) if e.to_string().contains(\"invalid type for 'order_iv'\") => {\n        log::warn(\"order_iv must be a string or number\");\n    }\n    Err(e) => return Err(e),\n}","preventionTips":["Serialize order_iv as string or number, never bool/null/nested","Coerce untyped config values to string before inserting into params","Restrict the options-order config schema for order_iv types"],"tags":["bybit","type-mismatch","options","params-validation"],"backgroundTag":"type-mismatch","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"}