{"record":{"id":"72bebb294d0a85b5","repo":"nautechsystems/nautilus_trader","slug":"incompatible-cached-position-side-position-ids","errorCode":null,"errorMessage":"incompatible cached {position_side:?} position IDs for {instrument_id}: {}; expected {venue_position_id}","messagePattern":"incompatible cached (.+?) position IDs for (.+?): (.+?); expected (.+?)","errorType":"validation","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"crates/adapters/binance/src/futures/execution.rs","lineNumber":1087,"sourceCode":"        position_side: PositionSide,\n        venue_position_id: PositionId,\n    ) -> anyhow::Result<()> {\n        let cache = self.core.cache();\n        let mut incompatible_ids: Vec<_> = cache\n            .positions_open(\n                Some(&BINANCE_VENUE),\n                Some(&instrument_id),\n                None,\n                Some(&self.core.account_id),\n                Some(position_side),\n            )\n            .into_iter()\n            .filter(|position| position.id != venue_position_id)\n            .map(|position| position.id.to_string())\n            .collect();\n        incompatible_ids.sort_unstable();\n\n        anyhow::ensure!(\n            incompatible_ids.is_empty(),\n            \"incompatible cached {position_side:?} position IDs for {instrument_id}: {}; expected {venue_position_id}\",\n            incompatible_ids.join(\", \"),\n        );\n        Ok(())\n    }\n\n    async fn generate_open_order_status_reports(\n        &self,\n        instrument_id: Option<InstrumentId>,\n        ts_init: UnixNanos,\n    ) -> anyhow::Result<Vec<OpenOrderStatusReport>> {\n        if let Some(instrument_id) = instrument_id\n            && self\n                .http_client\n                .instrument_reconciliation(&instrument_id)\n                .is_none()\n        {","sourceCodeStart":1069,"sourceCodeEnd":1105,"githubUrl":"https://github.com/nautechsystems/nautilus_trader/blob/18893faf8b356be3320add8de2f861b0b647cf06/crates/adapters/binance/src/futures/execution.rs#L1069-L1105","documentation":"When use_position_ids=true, the adapter canonically names each position ID after the venue position (instrument + hedge side). ensure_cached_position_id_compatible scans the Nautilus cache for open positions of the same instrument/side/account whose IDs differ from the canonical venue ID; any such legacy or synthetic IDs would break identity tracking, so the error lists them and aborts.","triggerScenarios":"Reconciliation (create_position_report / generate_position_status_reports) finds open cached positions for an instrument+side that were created before use_position_ids was enabled, or by a different run with virtual (non-venue) position IDs.","commonSituations":"Restarting a trader after flipping use_position_ids=true on a cache populated with virtual position IDs; mixing strategy-generated PositionIds with venue IDs for the same instrument; replay/backtest cache reused in live trading.","solutions":["Clear stale cached open positions for the affected instrument (purge/rebuild the cache database) so only venue position IDs remain.","Run one clean reconciliation with use_position_ids=true from an empty cache.","Keep use_position_ids setting stable across restarts; do not toggle between virtual and venue position IDs on the same cache.","Close the conflicting positions and let the adapter recreate them with canonical venue IDs."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"let stale: Vec<_> = cache.positions_open(Some(&BINANCE_VENUE), Some(&instrument_id), None, Some(&account_id), Some(side))\n    .into_iter().filter(|p| p.id != expected_venue_id).collect();\nif !stale.is_empty() { /* purge or re-create cached positions before reconciliation */ }","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Keep use_position_ids stable across restarts","Start live trading against a clean cache when toggling position-ID modes","Do not mix backtest/replay caches with live venue position IDs"],"tags":["cache","position-id","reconciliation","binance-futures"],"backgroundTag":"incompatible-cached-state","analyzedSha":"18893faf8b356be3320add8de2f861b0b647cf06","analyzedAt":"2026-09-08T20:49:34.690Z","contentChangedAt":"2026-09-08T20:49:34.690Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}