{"record":{"id":"4ad51356c5c19eb4","repo":"nautechsystems/nautilus_trader","slug":"bbo-side-type-and-bbo-level-must-be-provided-t","errorCode":null,"errorMessage":"'bbo_side_type' and 'bbo_level' must be provided together","messagePattern":"'bbo_side_type' and 'bbo_level' must be provided together","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/adapters/bybit/src/common/parse.rs","lineNumber":1928,"sourceCode":"    }\n\n    if let Some(value) = params.get(\"position_idx\") {\n        let idx = value.as_i64().ok_or_else(|| {\n            anyhow::anyhow!(\"invalid type for 'position_idx': {value}, expected integer\")\n        })?;\n        result.position_idx = Some(match idx {\n            0 => BybitPositionIdx::OneWay,\n            1 => BybitPositionIdx::BuyHedge,\n            2 => BybitPositionIdx::SellHedge,\n            _ => anyhow::bail!(\"invalid 'position_idx': {idx}, expected 0, 1, or 2\"),\n        });\n    }\n\n    let has_bbo_side_type = params.get(\"bbo_side_type\").is_some();\n    let has_bbo_level = params.get(\"bbo_level\").is_some();\n\n    if has_bbo_side_type != has_bbo_level {\n        anyhow::bail!(\"'bbo_side_type' and 'bbo_level' must be provided together\");\n    }\n\n    if let Some(value) = params.get(\"bbo_side_type\") {\n        let side_type = value.as_str().ok_or_else(|| {\n            anyhow::anyhow!(\"invalid type for 'bbo_side_type': {value}, expected string\")\n        })?;\n        result.bbo_side_type = Some(parse_bbo_side_type(side_type)?);\n    }\n\n    if let Some(value) = params.get(\"bbo_level\") {\n        let level = if let Some(s) = value.as_str() {\n            s.to_string()\n        } else if let Some(i) = value.as_i64() {\n            i.to_string()\n        } else if let Some(u) = value.as_u64() {\n            u.to_string()\n        } else {\n            anyhow::bail!(\"invalid type for 'bbo_level': {value}, expected string or integer\");","sourceCodeStart":1910,"sourceCodeEnd":1946,"githubUrl":"https://github.com/nautechsystems/nautilus_trader/blob/18893faf8b356be3320add8de2f861b0b647cf06/crates/adapters/bybit/src/common/parse.rs#L1910-L1946","documentation":"Best-bid/offer (BBO) TP/SL configuration is a pair: 'bbo_side_type' describes which side/type and 'bbo_level' the depth level. The parser requires both or neither, bailing when exactly one is present, since a partial BBO spec is meaningless to the exchange.","triggerScenarios":"Setting 'bbo_side_type' without 'bbo_level', or 'bbo_level' without 'bbo_side_type', in TP/SL params.","commonSituations":"Conditionally-built params where only one of the two keys survived a filter; partial config merge that dropped the sibling key.","solutions":["Provide both 'bbo_side_type' and 'bbo_level' together","Remove both keys if BBO-based TP/SL is not intended","Check the param-building code so both keys are set from the same config section"],"exampleFix":"// before\nparams.set(\"bbo_side_type\", \"Bid\");\n// after\nparams.set(\"bbo_side_type\", \"Bid\");\nparams.set(\"bbo_level\", \"1\");","handlingStrategy":"validation","validationCode":"fn validate_bbo_pair(params: &Params) -> Result<(), String> {\n    let has_type = params.get(\"bbo_side_type\").is_some();\n    let has_level = params.get(\"bbo_level\").is_some();\n    if has_type != has_level {\n        return Err(\"bbo_side_type and bbo_level must be provided together\".into());\n    }\n    Ok(())\n}","typeGuard":"fn has_partial_bbo(params: &Params) -> bool {\n    params.get(\"bbo_side_type\").is_some() != params.get(\"bbo_level\").is_some()\n}","tryCatchPattern":"match parse_bybit_tp_sl_params(&params) {\n    Ok(p) => submit(p),\n    Err(e) if e.to_string().contains(\"'bbo_side_type' and 'bbo_level' must be provided together\") => {\n        log::warn(\"Partial BBO config; supply both bbo_side_type and bbo_level or neither\");\n    }\n    Err(e) => return Err(e),\n}","preventionTips":["Set both BBO keys from a single config section or struct","Never filter params keys independently when they form a pair","Add a config-load assertion that bbo_side_type and bbo_level co-occur"],"tags":["bybit","params-validation","bbo","mutually-dependent-params"],"backgroundTag":"mutually-exclusive-options","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"}