{"record":{"id":"4f86f3760b229b7e","repo":"nautechsystems/nautilus_trader","slug":"ax-initial-margin-pct-must-be-positive-was-initi","errorCode":null,"errorMessage":"AX initial_margin_pct must be positive, was {initial_margin_pct}","messagePattern":"AX initial_margin_pct must be positive, was (.+?)","errorType":"validation","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"crates/adapters/architect_ax/src/http/parse.rs","lineNumber":384,"sourceCode":"        None,\n        Some(margin_init),\n        Some(margin_maint),\n        Some(maker_fee),\n        Some(taker_fee),\n        None,\n        Some(info),\n        ts_event,\n        ts_init,\n    );\n\n    Ok(InstrumentAny::PerpetualContract(instrument))\n}\n\nfn parse_margin_rates(\n    initial_margin_pct: Decimal,\n    maintenance_margin_pct: Decimal,\n) -> anyhow::Result<(Decimal, Decimal)> {\n    anyhow::ensure!(\n        initial_margin_pct > Decimal::ZERO,\n        \"AX initial_margin_pct must be positive, was {initial_margin_pct}\"\n    );\n    anyhow::ensure!(\n        maintenance_margin_pct > Decimal::ZERO,\n        \"AX maintenance_margin_pct must be positive, was {maintenance_margin_pct}\"\n    );\n    anyhow::ensure!(\n        maintenance_margin_pct <= initial_margin_pct,\n        \"AX maintenance_margin_pct {maintenance_margin_pct} exceeds initial_margin_pct {initial_margin_pct}\"\n    );\n\n    Ok((\n        margin_percent_to_rate(initial_margin_pct, \"initial_margin_pct\")?,\n        margin_percent_to_rate(maintenance_margin_pct, \"maintenance_margin_pct\")?,\n    ))\n}\n","sourceCodeStart":366,"sourceCodeEnd":402,"githubUrl":"https://github.com/nautechsystems/nautilus_trader/blob/a4b06ed870971b5671d12754ea138a3ab99b1dec/crates/adapters/architect_ax/src/http/parse.rs#L366-L402","documentation":"parse_margin_rates requires initial_margin_pct to be strictly greater than zero before converting percent to a rate for the instrument's margin fields. A zero or negative value — typically an unset field defaulting to 0 — fails instrument parsing immediately.","triggerScenarios":"An instrument definition carries initial_margin_pct of 0 (field never configured for a new listing) or a negative value; any instrument load or /instrument fetch for that symbol then errors during parse_margin_rates.","commonSituations":"Newly listed symbols whose margin configuration has not been populated in AX yet; an API change renaming the field so deserialization falls back to a zero default; contract templates copied without margin values.","solutions":["Check the symbol's margin fields in AX venue config and set a positive initial margin percent","Verify the field name/type against the AX API docs for your version — a renamed field silently deserializes to 0","If a symbol genuinely has no margin yet (spot-like listing), configure a nominal positive value or exclude it from loading","Retry after config changes; no client-side workaround exists"],"exampleFix":"// before (AX contract metadata)\n\"initial_margin_pct\": \"0\"\n// after\n\"initial_margin_pct\": \"1.5\"","handlingStrategy":"try-catch","validationCode":"// Vet margin fields before definitions reach the parser\nfn initial_margin_ok(v: Decimal) -> bool { v > Decimal::ZERO }\n\nif !initial_margin_ok(definition.initial_margin_pct) {\n    anyhow::bail!(\"symbol {} has non-positive initial_margin_pct {}}\", definition.symbol, definition.initial_margin_pct);\n}","typeGuard":null,"tryCatchPattern":"match parse_instrument(&definition, ts_event, ts_init) {\n    Ok(instrument) => Ok(instrument),\n    Err(e) if e.to_string().contains(\"initial_margin_pct must be positive\") => {\n        log::error!(\"symbol {} margin config incomplete (initial_margin_pct <= 0)\", definition.symbol);\n        Err(e)\n    }\n    Err(e) => Err(e),\n}","preventionTips":["Make margin percent fields mandatory in your venue-config publish pipeline","Alert when a newly listed symbol parses with default-zero margin fields instead of failing silently at trade time","Verify API field names after AX upgrades — renamed fields deserialize to zero defaults"],"tags":["architect-ax","instrument","margin","validation","metadata"],"backgroundTag":"invalid-margin-parameters","analyzedSha":"a4b06ed870971b5671d12754ea138a3ab99b1dec","analyzedAt":"2026-08-16T22:54:50.089Z","schemaVersion":2},"datasetVersion":"2026-08-16T23:17:17.608Z"}