nautechsystems/nautilus_trader · error

Missing required price for `{field_name}`

Error message

Missing required price for `{field_name}`

What it means

`decode_price` in the Databento adapter decodes an i64 price into a domain `Price`. Databento uses `i64::MAX` as the UNDEF sentinel for null/absent price fields, so when a required price field is undefined the function refuses to return a zero/garbage price and errors instead. It is thrown for required price fields (e.g. in instrument definition decoding) where a missing value cannot be tolerated.

Source

Thrown at crates/adapters/databento/src/decode/primitives.rs:233

        4 => "Implied matching off",
        _ => anyhow::bail!("Invalid `StatusMsg` trading_event, was '{value}'"),
    };

    Ok(Some(Ustr::from(value_str)))
}

/// Decodes a price, returning an error if undefined.
///
/// Databento uses `i64::MAX` as a sentinel value for unset/null prices (see
/// [`UNDEF_PRICE`](https://docs.rs/dbn/latest/dbn/constant.UNDEF_PRICE.html)).
///
/// # Errors
///
/// Returns an error if `value` is `i64::MAX` (undefined).
#[inline(always)]
pub fn decode_price(value: i64, precision: u8, field_name: &str) -> anyhow::Result<Price> {
    if value == i64::MAX {
        anyhow::bail!("Missing required price for `{field_name}`")
    } else {
        Ok(Price::from_raw(decode_raw_price_i64(value), precision))
    }
}

/// Decodes a price from the given optional value, expressed in units of 1e-9.
///
/// Databento uses `i64::MAX` as a sentinel value for unset/null prices (see
/// [`UNDEF_PRICE`](https://docs.rs/dbn/latest/dbn/constant.UNDEF_PRICE.html)).
#[inline(always)]
#[must_use]
pub fn decode_optional_price(value: i64, precision: u8) -> Option<Price> {
    if value == i64::MAX {
        None
    } else {
        Some(Price::from_raw(decode_raw_price_i64(value), precision))
    }
}

View on GitHub (pinned to 18893faf8b)

Solutions

  1. Check the instrument/record on the Databento side for the missing field and exclude such symbols before requesting definitions.
  2. If the field can legitimately be absent, switch the caller to `decode_optional_price` and handle `None` instead of erroring.
  3. Inspect the raw dbn record for the offending `field_name` to confirm whether the upstream data is genuinely undefined.
  4. Catch the anyhow error around `seed_price_precision_if_needed`/definition decoding and skip or log that instrument.

Example fix

// before
let strike = decode_price(msg.strike_px as i64, precision, "strike_px")?;
// after
let strike = if msg.strike_px == f64::NAN { None } else { Some(decode_price(msg.strike_px as i64, precision, "strike_px")?) };
Defensive patterns

Strategy: validation

Validate before calling

fn price_defined(raw: i64) -> bool { raw != i64::MAX }

Type guard

fn is_undefined_price(v: i64) -> bool { v == i64::MAX }

Try / catch

match decode_price(raw, precision, "strike_px") {
    Ok(p) => use(p),
    Err(e) if e.to_string().contains("Missing required price") => skip_instrument(),
    Err(e) => return Err(e),
}

Prevention

When it happens

Trigger: Calling `decode_price(value, precision, field_name)` with `value == i64::MAX`, e.g. an instrument definition record (option/futures contract) whose strike, activation, or other required price field was unset in the Databento response; also invoked directly in tests.

Common situations: Fetching definitions for instruments that legitimately lack a field (e.g. undefined strike for some derivatives), partial/malformed Databento records, or querying a schema where the price field is optional but the decode path treats it as required.

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/590796b4a14d17f4. Report an issue: GitHub.