{"record":{"id":"1006742cddd82def","repo":"nautechsystems/nautilus_trader","slug":"cannot-reopen-position-oms-type-netting-reop","errorCode":null,"errorMessage":"Cannot reopen position {} (oms_type=NETTING): reopening is only valid for closed positions in NETTING mode","messagePattern":"Cannot reopen position (.+?) \\(oms_type=NETTING\\): reopening is only valid for closed positions in NETTING mode","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/execution/src/engine/mod.rs","lineNumber":4279,"sourceCode":"        let ts_init = self.clock.borrow().timestamp_ns();\n        let event = PositionOpened::create(&position, &fill, UUID4::new(), ts_init);\n\n        Ok(vec![PositionEvent::PositionOpened(event)])\n    }\n\n    fn is_duplicate_closed_fill(position: &Position, fill: &OrderFilled) -> bool {\n        position.replay_events.iter().any(|event| {\n            matches!(\n                event,\n                PositionReplayEvent::Filled(replayed) if replayed.trade_id == fill.trade_id\n            )\n        })\n    }\n\n    fn reopen_position(&self, position: &Position, oms_type: OmsType) -> anyhow::Result<()> {\n        if oms_type == OmsType::Netting {\n            if position.is_open() {\n                anyhow::bail!(\n                    \"Cannot reopen position {} (oms_type=NETTING): reopening is only valid for closed positions in NETTING mode\",\n                    position.id\n                );\n            }\n        } else {\n            // HEDGING mode\n            log::warn!(\n                \"Received fill for closed position {} in HEDGING mode; archiving closed cycle and creating new position\",\n                position.id\n            );\n        }\n\n        // Snapshot the closed cycle before its ID is reused: `add_position` replaces the\n        // cached position, and realized PnL totals read closed cycles from the snapshots\n        self.snapshot_position(position)?;\n\n        Ok(())\n    }","sourceCodeStart":4261,"sourceCodeEnd":4297,"githubUrl":"https://github.com/nautechsystems/nautilus_trader/blob/18893faf8b356be3320add8de2f861b0b647cf06/crates/execution/src/engine/mod.rs#L4261-L4297","documentation":"OmsType guard in reopen_position: under NETTING a position may only be reopened after it was closed; attempting to reopen a position that is not closed would corrupt netting net-position accounting and is rejected.","triggerScenarios":"Thrown at crates/execution/src/engine/mod.rs:4279 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Let the position close before resubmitting orders that would reopen it","Review the fill sequence producing fills against a non-closed position"],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"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"}