nautechsystems/nautilus_trader · error
Cannot reopen position {} (oms_type=NETTING): reopening is o
Error message
Cannot reopen position {} (oms_type=NETTING): reopening is only valid for closed positions in NETTING mode What it means
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.
Source
Thrown at crates/execution/src/engine/mod.rs:4279
let ts_init = self.clock.borrow().timestamp_ns();
let event = PositionOpened::create(&position, &fill, UUID4::new(), ts_init);
Ok(vec![PositionEvent::PositionOpened(event)])
}
fn is_duplicate_closed_fill(position: &Position, fill: &OrderFilled) -> bool {
position.replay_events.iter().any(|event| {
matches!(
event,
PositionReplayEvent::Filled(replayed) if replayed.trade_id == fill.trade_id
)
})
}
fn reopen_position(&self, position: &Position, oms_type: OmsType) -> anyhow::Result<()> {
if oms_type == OmsType::Netting {
if position.is_open() {
anyhow::bail!(
"Cannot reopen position {} (oms_type=NETTING): reopening is only valid for closed positions in NETTING mode",
position.id
);
}
} else {
// HEDGING mode
log::warn!(
"Received fill for closed position {} in HEDGING mode; archiving closed cycle and creating new position",
position.id
);
}
// Snapshot the closed cycle before its ID is reused: `add_position` replaces the
// cached position, and realized PnL totals read closed cycles from the snapshots
self.snapshot_position(position)?;
Ok(())
}View on GitHub (pinned to 18893faf8b)
Solutions
- Let the position close before resubmitting orders that would reopen it
- Review the fill sequence producing fills against a non-closed position
Defensive patterns
Strategy: validation
When it happens
Trigger: Thrown at crates/execution/src/engine/mod.rs:4279 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of nautechsystems/nautilus_trader@18893faf8b (2026-09-08).
Data as JSON: /api/errors/1006742cddd82def.
Report an issue: GitHub.