{"record":{"id":"2d220b5e616410ea","repo":"nautechsystems/nautilus_trader","slug":"order-denied-invalid-status-for-expected-init","errorCode":null,"errorMessage":"Order denied: invalid status for {}, expected INITIALIZED","messagePattern":"Order denied: invalid status for (.+?), expected INITIALIZED","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/trading/src/strategy/mod.rs","lineNumber":2335,"sourceCode":"\npub(super) fn submit_order_native<T>(\n    strategy: &mut T,\n    order: &OrderAny,\n    position_id: Option<PositionId>,\n    client_id: Option<ClientId>,\n    params: Option<Params>,\n) -> anyhow::Result<()>\nwhere\n    T: Strategy + StrategyNative + ?Sized,\n{\n    let core = StrategyNative::strategy_core_mut(strategy);\n\n    let trader_id = registered_trader_id(core)?;\n    let strategy_id = registered_strategy_id(core)?;\n    let ts_init = core.clock_mut().timestamp_ns();\n\n    if order.status() != OrderStatus::Initialized {\n        anyhow::bail!(\n            \"Order denied: invalid status for {}, expected INITIALIZED\",\n            order.client_order_id()\n        );\n    }\n\n    let market_exit_tag = core.market_exit_tag;\n    let is_market_exit_order = order\n        .tags()\n        .is_some_and(|tags| tags.contains(&market_exit_tag));\n    let should_deny_for_market_exit =\n        core.is_exiting && !order.is_reduce_only() && !is_market_exit_order;\n\n    if should_deny_for_market_exit {\n        strategy.deny_order(order, Ustr::from(\"MARKET_EXIT_IN_PROGRESS\"));\n        return Ok(());\n    }\n\n    let core = StrategyNative::strategy_core_mut(strategy);","sourceCodeStart":2317,"sourceCodeEnd":2353,"githubUrl":"https://github.com/nautechsystems/nautilus_trader/blob/18893faf8b356be3320add8de2f861b0b647cf06/crates/trading/src/strategy/mod.rs#L2317-L2353","documentation":"submit_order_native only accepts orders whose status is INITIALIZED. If an order with any other lifecycle status (e.g. SUBMITTED, DENIED, FILLED) is passed again, the submission is denied with this error to prevent duplicate or stale submissions. Orders are meant to flow through this path exactly once.","triggerScenarios":"Calling submit_order_native (via binding_submit_order) with an order object that was already submitted, denied, or otherwise transitioned away from OrderStatus::Initialized.","commonSituations":"Retrying a submission after a failure without creating a fresh order; submitting the same order instance from multiple code paths; reusing a cached order after a strategy restart.","solutions":["Only call submit_order_native once per order, immediately after construction while status is INITIALIZED","Check order.status() before submitting and create a new order for retries","Trace why the order's status already changed (e.g. an earlier submit, deny, or event application)"],"exampleFix":"// before\nstrategy.submit_order_native(&order)?;\n// after\nif order.status() == OrderStatus::Initialized {\n    strategy.submit_order_native(&order)?;\n} else {\n    // create a new order for resubmission\n}","handlingStrategy":"validation","validationCode":"// Rust\nif order.status() != OrderStatus::Initialized {\n    // create a new order instead of resubmitting\n}","typeGuard":null,"tryCatchPattern":"// Rust\nmatch res {\n    Err(e) if e.to_string().contains(\"expected INITIALIZED\") => {\n        log::warn!(\"order already submitted; build a new order for retry\");\n    }\n    other => other?,\n}","preventionTips":["Submit each order exactly once, immediately after construction","Never reuse order objects across retries; construct a fresh order with a new client_order_id","Track submission state in your strategy so a failure path cannot resubmit the same instance"],"tags":["order-lifecycle","invalid-state","trading"],"backgroundTag":"invalid-state-transition","analyzedSha":"18893faf8b356be3320add8de2f861b0b647cf06","analyzedAt":"2026-09-08T20:49:34.690Z","contentChangedAt":"2026-09-08T20:49:34.690Z","schemaVersion":2},"datasetVersion":"2026-09-14T11:17:12.474Z"}