nautechsystems/nautilus_trader · error

Continuous future bar subscriptions must not include `bar_ty

Error message

Continuous future bar subscriptions must not include `bar_types`; pass the chain in continuous_future_transitions instead

What it means

When subscribing to continuous future bars via the continuous_future_transitions param, the chain of contracts must be passed only in that param. Including a separate bar_types param is ambiguous (two sources of the chain), so the engine rejects the subscription to prevent conflicting definitions.

Source

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

    }

    let bar_types = continuous_future_bar_types(request, params)?;
    parse_continuous_future(bar_types, params).map(Some)
}

pub(super) fn continuous_future_subscription_from_bars(
    cmd: &SubscribeBars,
) -> anyhow::Result<Option<ContinuousFutureRequest>> {
    let Some(params) = cmd.params.as_ref() else {
        return Ok(None);
    };

    if !params.contains_key(CONTINUOUS_FUTURE_TRANSITIONS) {
        return Ok(None);
    }

    if params.contains_key(BAR_TYPES) {
        anyhow::bail!(
            "Continuous future bar subscriptions must not include `bar_types`; pass the chain in continuous_future_transitions instead"
        );
    }

    parse_continuous_future(vec![cmd.bar_type], params).map(Some)
}

fn parse_continuous_future(
    bar_types: Vec<BarType>,
    params: &Params,
) -> anyhow::Result<ContinuousFutureRequest> {
    let primary_bar_type = bar_types[0];
    if !primary_bar_type.is_internally_aggregated() {
        anyhow::bail!("Continuous future target {primary_bar_type} must be internally aggregated");
    }

    let transitions_value = params
        .get(CONTINUOUS_FUTURE_TRANSITIONS)

View on GitHub (pinned to 18893faf8b)

Solutions

  1. Remove the bar_types key from params when continuous_future_transitions is supplied; the primary bar type comes from cmd.bar_type.
  2. Pass the full contract chain exclusively via continuous_future_transitions.
  3. Ensure your param builder only sets one of the two for continuous future subscriptions.

Example fix

// before
let params = params_with(BAR_TYPES, chain).with(CONTINUOUS_FUTURE_TRANSITIONS, transitions);
// after
let params = params_with(CONTINUOUS_FUTURE_TRANSITIONS, transitions); // no BAR_TYPES
Defensive patterns

Strategy: validation

Validate before calling

if params.contains_key(CONTINUOUS_FUTURE_TRANSITIONS) && params.contains_key(BAR_TYPES) {
    anyhow::bail!("remove BAR_TYPES when CONTINUOUS_FUTURE_TRANSITIONS is set");
}

Try / catch

match engine.subscribe_continuous_future_bars(&cmd) {
    Err(e) if e.to_string().contains("must not include `bar_types`") => {
        let mut p = params.clone();
        p.remove(BAR_TYPES);
        let cmd = SubscribeBars { params: p, ..cmd };
        engine.subscribe_continuous_future_bars(&cmd)?;
    }
    r => r?,
}

Prevention

When it happens

Trigger: Calling subscribe_continuous_future_bars (with continuous_future_transitions present in params) while the params also contain the BAR_TYPES key — e.g. merging generic bar subscription params with continuous-future params.

Common situations: Copy-pasting a normal bars subscription call (which sets bar_types) and adding continuous_future_transitions; a generic param builder that always injects bar_types.

Related errors


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