nautechsystems/nautilus_trader · error

Continuous future segment venue mismatch for {target_bar_typ

Error message

Continuous future segment venue mismatch for {target_bar_type}: target venue {target_venue}, segment venues pre={}, post={}

What it means

Every transition's pre/post instrument IDs must be listed on the same venue as the target continuous instrument. A segment whose pre or post contract is on another venue breaks the continuity assumption and is rejected.

Source

Thrown at crates/data/src/engine/requests.rs:554

            .with_context(|| {
                format!("Invalid continuous future transition_time_ns, was {row_value}")
            })?;

        if let Some(previous) = previous_transition_time_ns
            && transition_time_ns <= previous
        {
            anyhow::bail!(
                "Continuous future transition times must be strictly increasing, was {value}"
            );
        }
        previous_transition_time_ns = Some(transition_time_ns);

        let pre_instrument_id =
            parse_transition_instrument_id(row.get("pre_instrument_id"), target_bar_type)?;
        let post_instrument_id =
            parse_transition_instrument_id(row.get("post_instrument_id"), target_bar_type)?;
        if pre_instrument_id.venue != target_venue || post_instrument_id.venue != target_venue {
            anyhow::bail!(
                "Continuous future segment venue mismatch for {target_bar_type}: target venue {target_venue}, segment venues pre={}, post={}",
                pre_instrument_id.venue,
                post_instrument_id.venue,
            );
        }

        if let Some(previous) = previous_post_instrument_id
            && pre_instrument_id != previous
        {
            anyhow::bail!(
                "Continuous future chain discontinuity for {target_bar_type}: previous post {previous} != current pre {pre_instrument_id}",
            );
        }
        previous_post_instrument_id = Some(post_instrument_id);

        let pre_price = parse_transition_price(row.get("pre_price"), row_value, "pre_price")?;
        let post_price = parse_transition_price(row.get("post_price"), row_value, "post_price")?;
        if is_ratio && (pre_price <= Decimal::ZERO || post_price <= Decimal::ZERO) {

View on GitHub (pinned to 18893faf8b)

Solutions

  1. Correct the pre/post instrument IDs so both carry the target venue suffix.
  2. Remove transition rows belonging to other venues.
  3. Validate every transition's venue against the target bar type before building the request.

Example fix

// before
{"pre_instrument_id": "BRN-ICE", "post_instrument_id": "CL-NYMEX"} // target CL...NYMEX
// after
{"pre_instrument_id": "CLZ5-NYMEX", "post_instrument_id": "CLH6-NYMEX"}
Defensive patterns

Strategy: validation

Validate before calling

let target_venue = target_bar_type.instrument_id().venue;
for t in &transitions {
    assert_eq!(t.pre_instrument_id.venue, target_venue);
    assert_eq!(t.post_instrument_id.venue, target_venue);
}

Prevention

When it happens

Trigger: parse_transitions finds a row where pre_instrument_id.venue or post_instrument_id.venue differs from the target bar type's venue (e.g. a roll row referencing an ICE contract inside a CME continuous series).

Common situations: Merging roll tables from multiple exchanges; vendor data with inconsistent venue suffixes; hand-edited transition rows with a wrong venue code.

Understand the failure class

Background: "Must be a positive integer", "Invalid value", "Unsupported": the invalid-argument-value error family, when a library rejects the value you pass — this error's family across 35 libraries.

Related errors


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