{"record":{"id":"d4d3b90a348886b0","repo":"nautechsystems/nautilus_trader","slug":"invalid-imbalancemsg","errorCode":null,"errorMessage":"Invalid `ImbalanceMsg`","messagePattern":"Invalid `ImbalanceMsg`","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/adapters/databento/src/loader.rs","lineNumber":858,"sourceCode":"                        &record,\n                        instrument_id,\n                        &mut metadata_cache,\n                    ) {\n                        Ok(id) => id,\n                        Err(e) => return Some(Err(e)),\n                    };\n                    let resolved_precision = match self.resolve_stream_price_precision(\n                        &instrument_id,\n                        fixed_instrument_id,\n                        &mut fixed_price_precision,\n                    ) {\n                        Ok(p) => p,\n                        Err(e) => return Some(Err(e)),\n                    };\n\n                    let msg = match record.get::<dbn::ImbalanceMsg>() {\n                        Some(m) => m,\n                        None => return Some(Err(anyhow::anyhow!(\"Invalid `ImbalanceMsg`\"))),\n                    };\n                    let ts_init = msg.ts_recv.into();\n\n                    match decode_imbalance_msg(\n                        msg,\n                        instrument_id,\n                        resolved_precision,\n                        Some(ts_init),\n                    ) {\n                        Ok(data) => Some(Ok(data)),\n                        Err(e) => Some(Err(e)),\n                    }\n                }\n                None => None,\n            }\n        }))\n    }\n","sourceCodeStart":840,"sourceCodeEnd":876,"githubUrl":"https://github.com/nautechsystems/nautilus_trader/blob/18893faf8b356be3320add8de2f861b0b647cf06/crates/adapters/databento/src/loader.rs#L840-L876","documentation":"`read_imbalance_records` requires each record to decode as `dbn::ImbalanceMsg`; if `record.get::<ImbalanceMsg>()` yields None the loader returns this error. It signals the input stream does not actually contain imbalance records.","triggerScenarios":"Calling `read_imbalance_records` on a DBN stream whose rtype/schema is not imbalance (e.g. quotes or trades), typically because the download used the wrong `schema` parameter.","commonSituations":"Confusing Databento's `imbalance` schema with standard quote data, or feeding a mixed-schema stream to the imbalance reader.","solutions":["Re-download the data with `schema=\"imbalance\"`","Point `read_imbalance_records` at the correct file containing imbalance records","Split mixed-schema files per schema before loading","Verify rtype in the DBN header before loading"],"exampleFix":null,"handlingStrategy":"validation","validationCode":"assert_eq!(request.schema, \"imbalance\", \"read_imbalance_records requires the imbalance schema\");","typeGuard":"fn is_imbalance_record(rec: &dbn::RecordRef) -> bool {\n    rec.get::<dbn::ImbalanceMsg>().is_some()\n}","tryCatchPattern":"match loader.read_imbalance_records(file, instrument_id, price_precision).next() {\n    Some(Ok(_)) => { /* proceed */ }\n    Some(Err(e)) if e.to_string().contains(\"Invalid `ImbalanceMsg`\") => {\n        anyhow::bail!(\"not an imbalance stream; re-download with schema=imbalance\");\n    }\n    other => { /* handle normally */ }\n}","preventionTips":["Confirm Databento schema name is `imbalance` for the target dataset","Keep per-schema files separate","Validate the first record's type before running the full read"],"tags":["databento","record-type-mismatch"],"backgroundTag":"incompatible-source-type","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"}