{"record":{"id":"bca71dbb5aa9f1f9","repo":"nautechsystems/nautilus_trader","slug":"unmapped-in-scope-message-position-instrument-i","errorCode":null,"errorMessage":"unmapped_in_scope_message(\"position\", instrument_id, None, collection_load_ids,)","messagePattern":"unmapped_in_scope_message\\(\"position\", instrument_id, None, collection_load_ids,\\)","errorType":"exception","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"crates/adapters/polymarket/src/execution/reconciliation.rs","lineNumber":1438,"sourceCode":"    let instrument_id = instrument_id_from_market_token(&position.condition_id, &position.asset);\n\n    if instrument_filter\n        .is_some_and(|filter_id| !polymarket_instrument_ids_equivalent(filter_id, instrument_id))\n    {\n        return Ok(None);\n    }\n\n    if !instrument_in_load_ids_scope(instrument_id, collection_load_ids) {\n        log::debug!(\"Dropping out-of-scope position instrument {instrument_id}\");\n        return Ok(None);\n    }\n\n    if position_is_dust(position) {\n        return Ok(None);\n    }\n\n    if !position_instrument_loaded(&position.asset, instrument_id, instruments) {\n        anyhow::bail!(unmapped_in_scope_message(\n            \"position\",\n            instrument_id,\n            None,\n            collection_load_ids,\n        ));\n    }\n\n    Ok(build_position_report_from_reportable_position(\n        position, account_id, ts,\n    ))\n}\n\n/// Full reconciliation mass status generation.\n#[expect(clippy::too_many_arguments)]\npub(crate) async fn generate_mass_status(\n    http_client: &PolymarketClobHttpClient,\n    data_api_client: &PolymarketDataApiHttpClient,\n    instruments: &AtomicMap<Ustr, InstrumentAny>,","sourceCodeStart":1420,"sourceCodeEnd":1456,"githubUrl":"https://github.com/nautechsystems/nautilus_trader/blob/d1527c24afdf475115785557f89a55c3e336c51f/crates/adapters/polymarket/src/execution/reconciliation.rs#L1420-L1456","documentation":"During Polymarket position reconciliation, a non-dust position's asset maps to an instrument_id that was not loaded by the instrument provider. Like the open-order variant, this uses unmapped_in_scope_message and aborts reconciliation because an in-scope position cannot be reported without its instrument definition.","triggerScenarios":"Position report generation where position_instrument_loaded returns false for a position's asset — the provider returned positions for markets whose definitions are missing from the local cache.","commonSituations":"Instrument load filters narrower than the account's actual positions; failed instrument fetches at startup; positions on newly created markets not present in the cached snapshot.","solutions":["Widen the instrument provider load scope (or remove filters) to cover every market with an open position","Verify instruments finished loading before position reconciliation runs","Close stray positions on markets intentionally outside scope, or add those markets to the load list"],"exampleFix":null,"handlingStrategy":"validation","validationCode":"let instruments: HashSet<InstrumentId> = cache.instrument_ids().into_iter().collect();\n// before position reconciliation: every market with a non-dust position must be loaded\nfor pos in provider_positions {\n    if !instruments.contains(&map_asset_to_instrument(&pos.asset)?) {\n        log::warn!(\"position on unloaded market {}\", pos.asset);\n    }\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Load instruments for all markets with open positions before starting the node","Delay reconciliation until the instrument provider reports complete startup","Keep the load scope a superset of the account's active markets"],"tags":["polymarket","reconciliation","position-report","instrument-loading"],"backgroundTag":"out-of-scope-instrument","analyzedSha":"d1527c24afdf475115785557f89a55c3e336c51f","analyzedAt":"2026-08-27T04:01:12.327Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}