{"record":{"id":"96ceb3dd038e3433","repo":"nautechsystems/nautilus_trader","slug":"fill-maps-to-position-position-id-which-is-n","errorCode":null,"errorMessage":"fill {} maps to position {position_id}, which is not cached","messagePattern":"fill (.+?) maps to position (.+?), which is not cached","errorType":"exception","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"crates/live/src/execution/manager.rs","lineNumber":2886,"sourceCode":"        if let Some(order) = order\n            && Self::has_active_inferred_fill(&order)?\n        {\n            return Ok(PositionFillReportPreparation::InferredOverlap);\n        }\n\n        if !hedge_context {\n            return Ok(PositionFillReportPreparation::Ready);\n        }\n\n        if report.venue_position_id.is_some() {\n            return Ok(PositionFillReportPreparation::Ready);\n        }\n\n        let Some(position_id) = mapped_position_id else {\n            return Ok(PositionFillReportPreparation::Unattributed);\n        };\n        let position = cache.position(&position_id).ok_or_else(|| {\n            anyhow::anyhow!(\n                \"fill {} maps to position {position_id}, which is not cached\",\n                report.trade_id,\n            )\n        })?;\n\n        anyhow::ensure!(\n            position.account_id == report.account_id\n                && position.instrument_id == report.instrument_id,\n            \"fill {} maps to position {position_id} with a different account or instrument\",\n            report.trade_id,\n        );\n        anyhow::ensure!(\n            position.is_open(),\n            \"fill {} maps to non-open position {position_id}\",\n            report.trade_id,\n        );\n        anyhow::ensure!(\n            !position.is_opposite_side(report.order_side) || report.last_qty <= position.quantity,","sourceCodeStart":2868,"sourceCodeEnd":2904,"githubUrl":"https://github.com/nautechsystems/nautilus_trader/blob/18893faf8b356be3320add8de2f861b0b647cf06/crates/live/src/execution/manager.rs#L2868-L2904","documentation":"The fill's position was resolved via the order/venue mapping to position_id, but that position is absent from the cache. Since fills must be applied to the cached Position to update it, the manager returns an error instead of silently dropping or fabricating position state.","triggerScenarios":"mapped_position_id is Some(position_id) but cache.position(&position_id) returns None - e.g. the position was cleared from cache (position closed and purged, cache reset, or a fresh process that received fills before reconciling existing positions).","commonSituations":"Restarting a live node with a non-persistent cache while the venue still has open positions; cache backends (Redis/Postgres) dropping entries; reconciliation not run before processing fills; positions flushed after close while late fills still arrive.","solutions":["Run reconciliation on startup so existing venue positions are loaded into the cache before fills are processed","Enable a persistent cache backend and ensure it retains open positions across restarts","Delay/queue fill processing until position reconciliation completes","Check cache flush/eviction settings so open positions are not purged"],"exampleFix":"// before (node starts trading immediately)\nlet node = TradingNode::build(config)?;\nnode.run()?;\n// after (reconcile first)\nlet node = TradingNode::build(config)?;\nnode.reconcile_execution_state().await?;\nnode.run()?;","handlingStrategy":"validation","validationCode":"if let Some(pid) = mapped_position_id {\n    if cache.position(&pid).is_none() {\n        // reconcile or skip before processing the fill\n    }\n}","typeGuard":null,"tryCatchPattern":"match result {\n    Err(e) if e.to_string().contains(\"which is not cached\") => {\n        // trigger execution reconciliation, then requeue the report\n    }\n    other => other?,\n}","preventionTips":["Run reconciliation at node startup before consuming reports","Use a persistent cache backend that survives restarts","Avoid manual cache flushes while positions are open"],"tags":["rust","live-execution","cache-miss","position"],"backgroundTag":"entity-not-found","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"}