nautechsystems/nautilus_trader · error

Cannot unsubscribe from synthetic instrument `InstrumentStat

Error message

Cannot unsubscribe from synthetic instrument `InstrumentStatus` data

What it means

InstrumentStatus subscriptions never exist for synthetic instruments, so the corresponding unsubscribe is likewise impossible. UnsubscribeCommand::InstrumentStatus with a synthetic instrument ID is rejected with this error.

Source

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

            UnsubscribeCommand::Quotes(cmd) if cmd.instrument_id.is_synthetic() => {
                self.unsubscribe_synthetic_quotes(cmd.instrument_id);
                return Ok(());
            }
            UnsubscribeCommand::Quotes(cmd)
                if self.is_spread_quote_command(cmd.instrument_id, cmd.params.as_ref()) =>
            {
                self.unsubscribe_spread_quotes(cmd);
                return Ok(());
            }
            UnsubscribeCommand::Trades(cmd) if cmd.instrument_id.is_synthetic() => {
                self.unsubscribe_synthetic_trades(cmd.instrument_id);
                return Ok(());
            }
            UnsubscribeCommand::Instrument(cmd) if cmd.instrument_id.is_synthetic() => {
                anyhow::bail!("Cannot unsubscribe from synthetic instrument `Instrument` data");
            }
            UnsubscribeCommand::InstrumentStatus(cmd) if cmd.instrument_id.is_synthetic() => {
                anyhow::bail!(
                    "Cannot unsubscribe from synthetic instrument `InstrumentStatus` data"
                );
            }
            UnsubscribeCommand::InstrumentClose(cmd) if cmd.instrument_id.is_synthetic() => {
                anyhow::bail!(
                    "Cannot unsubscribe from synthetic instrument `InstrumentClose` data"
                );
            }
            UnsubscribeCommand::OptionGreeks(cmd) if cmd.instrument_id.is_synthetic() => {
                anyhow::bail!("Cannot unsubscribe from synthetic instrument `OptionGreeks` data");
            }
            _ => {}
        }

        if let Some(client) = self.get_command_client(cmd.client_id(), cmd.venue()) {
            client.execute_unsubscribe(cmd);
        } else {
            log::error!(

View on GitHub (pinned to 18893faf8b)

Solutions

  1. Guard InstrumentStatus unsubscribes with an is_synthetic() check and skip synthetic IDs.
  2. Maintain a record of live subscriptions and only issue matching unsubscribes.
  3. Resolve the mismatch if synthetic IDs unexpectedly appear in your real-instrument teardown list.

Example fix

// before
for id in &instrument_ids {
    engine.unsubscribe_instrument_status(*id)?;
}
// after
for id in instrument_ids.iter().filter(|id| !id.is_synthetic()) {
    engine.unsubscribe_instrument_status(*id)?;
}
Defensive patterns

Strategy: type-guard

Validate before calling

// Rust
if !instrument_id.is_synthetic() {
    engine.unsubscribe_instrument_status(instrument_id)?;
}

Type guard

// Rust
fn was_ever_subscribed(id: &InstrumentId, cmd: &UnsubscribeCommand) -> bool {
    !id.is_synthetic() // InstrumentStatus is never subscribed for synthetics
}

Try / catch

// Rust
if let Err(e) = engine.unsubscribe_instrument_status(id) {
    if e.to_string().contains("unsubscribe from synthetic instrument `InstrumentStatus`") {
        log::debug!("no InstrumentStatus subscription existed for synthetic {id}");
    } else {
        return Err(e.into());
    }
}

Prevention

When it happens

Trigger: Calling unsubscribe for InstrumentStatus where the InstrumentId is synthetic (is_synthetic() == true), e.g. blanket teardown loops unsubscribing all data types for all instruments.

Common situations: Strategy shutdown routines that unsubscribe every stream type unconditionally; refactors that changed an instrument ID to a synthetic one without updating subscription bookkeeping.

Understand the failure class

Background: UnsupportedOperationException and "is not supported" errors: when a library deliberately refuses a call — this error's family across 30 libraries.

Related errors


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