{"record":{"id":"919122e133e8322c","repo":"nautechsystems/nautilus_trader","slug":"strategy-order-id-tag-conflict-for-order-id-tag","errorCode":null,"errorMessage":"Strategy order_id_tag conflict for '{order_id_tag}', explicitly define unique order_id_tag values","messagePattern":"Strategy order_id_tag conflict for '(.+?)', explicitly define unique order_id_tag values","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/system/src/registration.rs","lineNumber":60,"sourceCode":"                    .unwrap_or_else(|| type_name::<T>());\n                strategy_type.to_string()\n            },\n            |strategy_id| strategy_id.to_string(),\n        )\n}\n\npub(crate) fn base_strategy_id(strategy_id: &str) -> String {\n    strategy_id\n        .rsplit_once('-')\n        .map_or_else(|| strategy_id.to_string(), |(base, _)| base.to_string())\n}\n\npub(crate) fn ensure_unique_order_id_tag(\n    existing_order_id_tags: &[&str],\n    order_id_tag: &str,\n) -> anyhow::Result<()> {\n    if existing_order_id_tags.contains(&order_id_tag) {\n        anyhow::bail!(\n            \"Strategy order_id_tag conflict for '{order_id_tag}', explicitly define unique order_id_tag values\",\n        );\n    }\n\n    Ok(())\n}\n","sourceCodeStart":42,"sourceCodeEnd":67,"githubUrl":"https://github.com/nautechsystems/nautilus_trader/blob/18893faf8b356be3320add8de2f861b0b647cf06/crates/system/src/registration.rs#L42-L67","documentation":"ensure_unique_order_id_tag checks a candidate strategy order_id_tag against tags already used by registered actors/strategies in the trader. Order ID tags must be unique per trader so generated order IDs don't collide; a duplicate tag is rejected with this error.","triggerScenarios":"Adding a second strategy (via prepare_python_strategy_instance, add_strategy_id_with_subscriptions, or prepare_strategy_for_registration) whose config carries an order_id_tag already claimed by another strategy, or two strategies both relying on a colliding default tag.","commonSituations":"Copy-pasting strategy configs without changing order_id_tag, running multiple instances of the same strategy class with default tags, template configs deployed twice under different strategy ids.","solutions":["Assign a unique explicit order_id_tag to each strategy config (e.g. \"001\", \"002\").","If using defaults, instantiate each strategy with a distinct tag before registration.","Review registered strategies to see which tag is taken and choose a free one."],"exampleFix":"// before\nconfig_a = MyStrategyConfig(order_id_tag=\"001\")\nconfig_b = MyStrategyConfig(order_id_tag=\"001\")  # conflict\n// after\nconfig_b = MyStrategyConfig(order_id_tag=\"002\")","handlingStrategy":"validation","validationCode":"used = {s.config.order_id_tag for s in trader.strategies()}\nassert config.order_id_tag not in used, \\\n    f\"order_id_tag '{config.order_id_tag}' already in use: {sorted(used)}\"","typeGuard":"def tag_is_free(order_id_tag: str, existing_tags) -> bool:\n    return order_id_tag not in existing_tags","tryCatchPattern":"try:\n    trader.add_strategy(strategy)\nexcept Exception as e:\n    if \"order_id_tag conflict\" in str(e):\n        logger.error(\"Duplicate order_id_tag: %s\", e)\n        raise ValueError(\"Assign a unique order_id_tag per strategy\") from e\n    raise","preventionTips":["Assign explicit, unique order_id_tag values (001, 002, ...) to every strategy config","Never copy-paste strategy configs without changing the tag","Keep a registry of tags in use when deploying multiple strategy instances"],"tags":["strategy","duplicate","order-id","registration"],"backgroundTag":"invalid-argument-value","analyzedSha":"18893faf8b356be3320add8de2f861b0b647cf06","analyzedAt":"2026-09-08T20:49:34.690Z","contentChangedAt":"2026-09-08T20:49:34.690Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}