nautechsystems/nautilus_trader · error · anyhow::Error

Could not resolve `price_precision` for {instrument_id}: pas

Error message

Could not resolve `price_precision` for {instrument_id}: pass `price_precision` explicitly, call `set_price_precision`, or fetch the instrument definitions first via `get_range_instruments`

What it means

The Databento historical adapter needs `price_precision` to decode instrument definitions, and it resolves it from an explicit argument, a previously cached value, or data seeded via `get_range_instruments`. If none is available for the given InstrumentId it raises this error rather than guessing. It is an API-misuse / ordering error, not a network failure.

Source

Thrown at crates/adapters/databento/src/historical.rs:221

    ///
    /// # Errors
    ///
    /// Returns an error when no precision is available.
    fn resolve_price_precision(
        &self,
        instrument_id: &InstrumentId,
        price_precision: Option<u8>,
    ) -> anyhow::Result<u8> {
        if let Some(precision) = price_precision {
            return Ok(precision);
        }

        let precisions = self.price_precisions.load();
        precisions
            .get(&instrument_id.symbol)
            .copied()
            .ok_or_else(|| {
                anyhow::anyhow!(
                    "Could not resolve `price_precision` for {instrument_id}: \
                     pass `price_precision` explicitly, call `set_price_precision`, \
                     or fetch the instrument definitions first via `get_range_instruments`"
                )
            })
    }

    fn resolve_cached_price_precision(
        &self,
        instrument_id: &InstrumentId,
        price_precision: Option<u8>,
        precision_cache: &mut AHashMap<InstrumentId, u8>,
    ) -> anyhow::Result<u8> {
        if let Some(precision) = price_precision {
            return Ok(precision);
        }

        if let Some(precision) = precision_cache.get(instrument_id) {

View on GitHub (pinned to 18893faf8b)

Solutions

  1. Pass `price_precision` explicitly to the call
  2. Call `set_price_precision(instrument_id, precision)` before decoding
  3. Call `get_range_instruments` once first to seed the precision cache from instrument definitions
  4. Verify the symbol spelling matches what was cached (symbol key match is exact)

Example fix

// before
let records = client.get_range_raw(params).await?;
// after
client.set_price_precision(instrument_id, 2);
let records = client.get_range_raw(params).await?;
Defensive patterns

Strategy: validation

Validate before calling

if client.resolve_price_precision(instrument_id, None).is_err() {
    client.seed_price_precision_if_needed(&params).await?; // fetch instrument definitions first
}

Type guard

fn precision_available(cache: &DashMap<String, u8>, symbol: &str) -> bool { cache.contains_key(symbol) }

Try / catch

let precision = args.price_precision
    .or_else(|| client.get_cached_price_precision(&instrument_id))
    .ok_or_else(|| anyhow!("price_precision required for {instrument_id}; fetch instruments first"))?;

Prevention

When it happens

Trigger: Calling an adapter method (e.g. one that decodes definitions) that internally calls `resolve_price_precision` when: no `price_precision` argument was passed, `set_price_precision` was never called for the symbol, and `get_range_instruments` was not run first to seed the cache.

Common situations: Querying raw historical records for a symbol never seen before; calling decode paths before instrument definitions were fetched; cache cleared or a new client instance constructed.

Understand the failure class

Background: "missing required argument" and "the following required arguments were not provided": what required-argument errors mean and how to fix them — this error's family across 20 libraries.

Related errors


AI-assisted analysis of nautechsystems/nautilus_trader@18893faf8b (2026-09-08). Data as JSON: /api/errors/5557ed58c3025755. Report an issue: GitHub.