{"record":{"id":"644f60c62a75bae8","repo":"nautechsystems/nautilus_trader","slug":"could-not-resolve-price-precision-for-instrumen-644f60","errorCode":null,"errorMessage":"Could not resolve `price_precision` for {instrument_id}: pass `price_precision` explicitly, call `set_price_precision`, or load the instrument definitions first via `load_instruments`","messagePattern":"Could not resolve `price_precision` for (.+?): pass `price_precision` explicitly, call `set_price_precision`, or load the instrument definitions first via `load_instruments`","errorType":"exception","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"crates/adapters/databento/src/loader.rs","lineNumber":218,"sourceCode":"    /// 2. The cached precision for the instrument's symbol.\n    ///\n    /// # Errors\n    ///\n    /// Returns an error when no precision is available.\n    fn resolve_price_precision(\n        &self,\n        instrument_id: &InstrumentId,\n        price_precision: Option<u8>,\n    ) -> anyhow::Result<u8> {\n        if let Some(precision) = price_precision {\n            return Ok(precision);\n        }\n\n        self.price_precisions\n            .get(&instrument_id.symbol)\n            .copied()\n            .ok_or_else(|| {\n                anyhow::anyhow!(\n                    \"Could not resolve `price_precision` for {instrument_id}: \\\n                     pass `price_precision` explicitly, call `set_price_precision`, \\\n                     or load the instrument definitions first via `load_instruments`\"\n                )\n            })\n    }\n\n    /// Returns the schema for the given `filepath`.\n    ///\n    /// # Errors\n    ///\n    /// Returns an error if the file cannot be decoded or metadata retrieval fails.\n    pub fn schema_from_file(&self, filepath: &Path) -> anyhow::Result<Option<String>> {\n        let decoder = Decoder::from_zstd_file(filepath)?;\n        let metadata = decoder.metadata();\n        Ok(metadata.schema.map(|schema| schema.to_string()))\n    }\n","sourceCodeStart":200,"sourceCodeEnd":236,"githubUrl":"https://github.com/nautechsystems/nautilus_trader/blob/18893faf8b356be3320add8de2f861b0b647cf06/crates/adapters/databento/src/loader.rs#L200-L236","documentation":"The Databento loader must know each instrument's price precision to build Nautilus types from raw integer prices. When no explicit `price_precision` argument is given and the symbol has no cached precision (via set_price_precision or load_instruments), resolution fails with this instructive error.","triggerScenarios":"Calling a DatabentoDataLoader read/decode method for a symbol whose definitions were never loaded via load_instruments, without passing `price_precision` and without a prior `set_price_precision(symbol, ...)` call. Note the cache is keyed by Symbol, not full InstrumentId, so a symbol mismatch (e.g. different suffix) also misses.","commonSituations":"Decoding a subset schema file without its definition file, symbol key mismatch (raw symbol vs continuous/instrument symbol with suffix), fresh loader instance where a previous instance held the cache.","solutions":["Call `load_instruments` on the definition-schema file for your dataset before decoding data records","Pass `price_precision: Some(n)` explicitly to the decode call for the instrument","Call `loader.set_price_precision(symbol, precision)` for each symbol you will decode","Verify the cached symbol exactly matches the record's symbol (watch for suffixes/case differences)"],"exampleFix":"// before\nlet instrument = loader.decode(msg, None, instrument_id)?; // panics into error: no cache\n// after\nloader.set_price_precision(instrument_id.symbol, 2);\nlet instrument = loader.decode(msg, None, instrument_id)?;\n// or: loader.load_instruments(&definition_path, ...)?;","handlingStrategy":"validation","validationCode":"// before decoding records, ensure precision is resolvable\nif loader.get_price_precisions().get(&instrument_id.symbol).is_none() {\n    loader.set_price_precision(instrument_id.symbol, expected_precision);\n}","typeGuard":null,"tryCatchPattern":"match loader.decode(msg, None, instrument_id) {\n    Ok(i) => i,\n    Err(e) if e.to_string().contains(\"Could not resolve `price_precision`\") => {\n        anyhow::bail!(\"pass price_precision or call load_instruments first: {e}\")\n    }\n    other => other,\n}","preventionTips":["Always call load_instruments for your dataset before decoding data","Pass explicit price_precision when you already know it","Remember the cache is keyed by Symbol — check exact symbol match including suffixes"],"tags":["databento","price-precision","missing-cache","decoding"],"backgroundTag":"missing-required-config-field","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"}