{"record":{"id":"cb74841a5fb15da6","repo":"nautechsystems/nautilus_trader","slug":"order-in-list-denied-duplicate","errorCode":null,"errorMessage":"Order in list denied: duplicate {}","messagePattern":"Order in list denied: duplicate (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/trading/src/strategy/mod.rs","lineNumber":277,"sourceCode":"            anyhow::bail!(\"OrderList denied: {e}\");\n        }\n\n        {\n            let cache_rc = core.cache_rc();\n            let mut cache = cache_rc.try_borrow_mut().map_err(|_| {\n                anyhow::anyhow!(\n                    \"Cannot submit order list {}: cache is currently borrowed\",\n                    order_list.id\n                )\n            })?;\n\n            if cache.order_list_exists(&order_list.id) {\n                anyhow::bail!(\"OrderList denied: duplicate {}\", order_list.id);\n            }\n\n            for order in &orders {\n                if cache.order_exists(&order.client_order_id()) {\n                    anyhow::bail!(\n                        \"Order in list denied: duplicate {}\",\n                        order.client_order_id()\n                    );\n                }\n            }\n\n            cache.add_order_list(order_list.clone())?;\n            for order in &orders {\n                cache.add_order(order.clone(), position_id, client_id, true)?;\n            }\n        }\n\n        for order in &orders {\n            publish_order_initialized(order);\n        }\n\n        let params = params.filter(|params| !params.is_empty());\n","sourceCodeStart":259,"sourceCodeEnd":295,"githubUrl":"https://github.com/nautechsystems/nautilus_trader/blob/18893faf8b356be3320add8de2f861b0b647cf06/crates/trading/src/strategy/mod.rs#L259-L295","documentation":"While registering the list's orders, submit_order_list checks each client_order_id against the cache; if an order with that ID already exists it bails with 'Order in list denied: duplicate {id}'. Client order IDs must be unique within the cache.","triggerScenarios":"Any order in the list has a client_order_id already present in the cache — resubmitting submitted orders, or hand-built orders with fixed/colliding client order IDs.","commonSituations":"Custom client order ID generation that collides across restarts; replaying a session with persisted orders; reusing order factory state so IDs repeat.","solutions":["Rely on the order factory to generate unique client order IDs; avoid hand-assigning them.","Check cache.order_exists(client_order_id) before submitting each order.","On restart/replay, seed the factory so IDs continue after the last used value rather than restarting."],"exampleFix":"// before\norder = self.order_factory.limit(..., client_order_id=ClientId(\"fixed-1\"))\n\n// after\nif not self.cache.order_exists(client_order_id):\n    order = self.order_factory.limit(...)  # factory-generated unique ID","handlingStrategy":"validation","validationCode":"dupes = [o.client_order_id for o in orders if self.cache.order_exists(o.client_order_id)]\nif dupes:\n    raise ValueError(f\"client order IDs already in cache: {dupes}\")","typeGuard":"def all_new_orders(cache, orders) -> bool:\n    return not any(cache.order_exists(o.client_order_id) for o in orders)","tryCatchPattern":"try:\n    self.submit_order_list(order_list)\nexcept RuntimeError as e:\n    if \"Order in list denied: duplicate\" in str(e):\n        self.log.error(f\"client order ID collision: {e}\")\n    else:\n        raise","preventionTips":["Let the order factory generate client order IDs; avoid hand-assigned fixed IDs","Persist/seed factory state across restarts so IDs never repeat","Check cache.order_exists per order before resubmitting after an error"],"tags":["rust","strategy","duplicate","client-order-id","cache"],"backgroundTag":"duplicate-identifier","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"}