{"record":{"id":"0e27be6f79cfd078","repo":"nautechsystems/nautilus_trader","slug":"fill-is-not-in-order-history","errorCode":null,"errorMessage":"fill {} is not in order history","messagePattern":"fill (.+?) is not in order history","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/execution/src/engine/mod.rs","lineNumber":3870,"sourceCode":"\n        position_events\n    }\n\n    fn prepare_order_fill_void_positions(\n        &self,\n        order: &OrderAny,\n        event: &OrderFillVoided,\n    ) -> anyhow::Result<Vec<CorrectedPosition>> {\n        let source_event_id = order\n            .events()\n            .into_iter()\n            .find_map(|order_event| match order_event {\n                OrderEventAny::Filled(fill) if fill.trade_id == event.trade_id => {\n                    Some(fill.event_id)\n                }\n                _ => None,\n            })\n            .ok_or_else(|| anyhow::anyhow!(\"fill {} is not in order history\", event.trade_id))?;\n\n        let positions: Vec<Position> = {\n            let cache = self.cache.borrow();\n            cache\n                .positions(\n                    None,\n                    Some(&event.instrument_id),\n                    Some(&event.strategy_id),\n                    Some(&event.account_id),\n                    None,\n                )\n                .into_iter()\n                .map(|position| position.cloned())\n                .collect()\n        };\n        let mut fragments = Vec::new();\n\n        for position in &positions {","sourceCodeStart":3852,"sourceCodeEnd":3888,"githubUrl":"https://github.com/nautechsystems/nautilus_trader/blob/18893faf8b356be3320add8de2f861b0b647cf06/crates/execution/src/engine/mod.rs#L3852-L3888","documentation":"When processing an order event that references positions (e.g. position splits/opens derived from a fill), the engine searches the order's event history for an existing Filled event with the same trade_id to obtain the originating fill's event_id. If no prior fill in the order's history matches the incoming event's trade_id, it raises \"fill {trade_id} is not in order history\".","triggerScenarios":"Dispatching an order event whose trade_id does not correspond to any OrderEventAny::Filled already recorded on that order — e.g. a duplicate or replayed fill event, or an event arriving before the original fill was persisted.","commonSituations":"Reconciliation mass status replaying fills against orders whose history was not fully loaded from cache; duplicate broker fill reports with new trade ids; cache rebuilt without the original fill events; out-of-order event delivery from the venue.","solutions":["Verify the original Fill event for that trade_id was applied to the order before this dependent event (event ordering).","Rebuild/restore the cache so the order's full event history includes the referenced fill.","Deduplicate broker fill reports so repeated trade_ids are not re-processed as new events.","Check reconciliation logic to ensure fills from mass status are inserted into order history before fragment computation."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"// before dispatching a dependent event, confirm the fill exists in order history\nif !order.events().iter().any(|ev| matches!(ev,\n    OrderEventAny::Filled(f) if f.trade_id == event.trade_id))\n{\n    // apply or fetch the original fill first\n}","typeGuard":null,"tryCatchPattern":"match result {\n    Err(e) if e.to_string().contains(\"is not in order history\") => {\n        // reload cache/replay fills, then retry the event\n    }\n    other => other?,\n}","preventionTips":["Deduplicate broker fill reports by trade_id before applying them.","Ensure the cache is fully rebuilt (including fill events) before reconciliation.","Preserve event ordering so fills land before events that reference them."],"tags":["execution-engine","fills","order-history","rust"],"backgroundTag":"record-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"}