nautechsystems/nautilus_trader · error · anyhow::Error

unmapped_in_scope_message("open order", instrument_id…

Error message

unmapped_in_scope_message("open order", instrument_id, Some(&format!("token {}", order.asset_id)), collection_load_ids,)

What it means

During Polymarket reconciliation, an open order's token (asset_id) resolves to an instrument_id that is within the configured collection load scope, but that instrument was not actually loaded/mapped by the provider. Reconciliation bails (via unmapped_in_scope_message) because an in-scope instrument must be present for correct reporting.

Solutions

  1. Ensure all instruments in the configured load scope successfully loaded before reconciliation (check startup logs for fetch errors)
  2. Remove stale/delisted token IDs from load_ids
  3. Retry the connection so the instrument provider can repopulate missing definitions
Defensive patterns

Strategy: validation

Validate before calling

for id in collection_load_ids {
    if cache.instrument(id).is_none() {
        anyhow::bail!("configured instrument {id} not loaded; cannot reconcile in-scope orders");
    }
}

Prevention

When it happens

Trigger: build_order_report_from_order with collection_load_ids containing the resolved instrument_id, yet the instrument is absent from the cache — e.g. load_ids lists a token that failed to load, or the token-to-instrument mapping drifted.

Common situations: Instrument load failures during startup (network errors fetching definitions); load_ids referencing delisted or renamed markets; partial cache population before reconciliation began.

Related errors


AI-assisted analysis of nautechsystems/nautilus_trader@d1527c24af (2026-08-27). Data as JSON: /api/errors/baa2179abb3c73aa. Report an issue: GitHub.

Appendix: source

Thrown at crates/adapters/polymarket/src/execution/reconciliation.rs:597

        OrderEvidenceScope::Collection { instrument_filter } => match instruments
            .get_cloned(&order.asset_id)
        {
            Some(instrument) => instrument,
            None => {
                let instrument_id =
                    instrument_id_from_market_token(order.market.as_str(), order.asset_id.as_str());

                if instrument_filter.is_some_and(|filter_id| {
                    !polymarket_instrument_ids_equivalent(filter_id, instrument_id)
                }) {
                    return Ok(OrderRowResult {
                        report: None,
                        counted_filtered: false,
                    });
                }

                if instrument_in_load_ids_scope(instrument_id, collection_load_ids) {
                    anyhow::bail!(unmapped_in_scope_message(
                        "open order",
                        instrument_id,
                        Some(&format!("token {}", order.asset_id)),
                        collection_load_ids,
                    ));
                }
                log::debug!("Dropping out-of-scope unmapped open order instrument {instrument_id}");
                return Ok(OrderRowResult {
                    report: None,
                    counted_filtered: true,
                });
            }
        },
    };
    let instrument_id = instrument.id();

    if let OrderEvidenceScope::Collection {
        instrument_filter: Some(filter_id),

View on GitHub (pinned to d1527c24af)