nautechsystems/nautilus_trader · error

No continuous future subscription state for {target_bar_type

Error message

No continuous future subscription state for {target_bar_type}

What it means

Applying a continuous future roll adjustment for a given segment requires existing subscription state keyed by the target bar type's standard form. When apply_continuous_future_subscription_adjustment looks up continuous_future_subscriptions and finds no entry, the internal bookkeeping for that subscription is missing — usually because the subscription was never registered or was already unsubscribed.

Source

Thrown at crates/data/src/engine/mod.rs:5442

            )
        })?;
        let adjustment = request.adjustment_for_segment(segment_index);
        aggregator
            .borrow_mut()
            .set_adjustment(adjustment, request.adjustment_mode);
        Ok(())
    }

    fn apply_continuous_future_subscription_adjustment_for(
        &self,
        target_bar_type: BarType,
        segment_index: usize,
    ) -> anyhow::Result<()> {
        let Some(state) = self
            .continuous_future_subscriptions
            .get(&target_bar_type.standard())
        else {
            anyhow::bail!("No continuous future subscription state for {target_bar_type}");
        };
        self.apply_continuous_future_subscription_adjustment(&state.request, segment_index)
    }

    fn subscribe_continuous_future_source(
        &mut self,
        target_bar_type: BarType,
        source: ContinuousFutureSource,
        segment_instrument_id: InstrumentId,
    ) -> BarAggregatorSubscription {
        let key = bar_aggregator_key(target_bar_type, None);
        let aggregator = self
            .bar_aggregators
            .get(&key)
            .cloned()
            .expect("aggregator was created before subscribe_continuous_future_source");

        let subscription = match source {

View on GitHub (pinned to 18893faf8b)

Solutions

  1. Subscribe to the continuous future bar type first so the subscription state is created, then apply adjustments.
  2. Use the exact same BarType (standard form) as passed to the original subscription.
  3. Check engine.continuous_future_subscriptions for the key before requesting a segment adjustment.

Example fix

// before
engine.apply_continuous_future_segment_adjustment(&other_bar_type, segment_index)?; // no state
// after
assert!(engine.continuous_future_subscriptions.contains_key(&bar_type.standard()));
engine.apply_continuous_future_segment_adjustment(&bar_type, segment_index)?;
Defensive patterns

Strategy: type-guard

Validate before calling

if !engine.continuous_future_subscriptions.contains_key(&bar_type.standard()) {
    // subscribe first or skip the segment adjustment
}

Type guard

fn has_continuous_state(engine: &DataEngine, bt: &BarType) -> bool {
    engine.continuous_future_subscriptions.contains_key(&bt.standard())
}

Try / catch

match engine.apply_continuous_future_segment_adjustment(&bar_type, idx) {
    Err(e) if e.to_string().contains("No continuous future subscription state") => {
        engine.subscribe_continuous_future_bars(&sub_cmd)?;
        engine.apply_continuous_future_segment_adjustment(&bar_type, idx)?;
    }
    r => r?,
}

Prevention

When it happens

Trigger: Calling apply_continuous_future_subscription_adjustment (via roll/segment update paths) with a target_bar_type that has no entry in engine.continuous_future_subscriptions — e.g. after unsubscribe, before subscribe, or with a bar type string that differs in its standard form.

Common situations: Re-applying adjustments after an unsubscribe; passing a slightly different BarType spelling (price type, step, or aggregation mismatch) than the one subscribed; engine state reset between subscribe and segment processing.

Understand the failure class

Background: Record Not Found Errors: "not found", RecordNotFound, and "was not found" — what they mean and how to fix them — this error's family across 28 libraries.

Related errors


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