{"record":{"id":"191375d81e8a0b74","repo":"nautechsystems/nautilus_trader","slug":"ax-maintenance-margin-pct-must-be-positive-was-m","errorCode":null,"errorMessage":"AX maintenance_margin_pct must be positive, was {maintenance_margin_pct}","messagePattern":"AX maintenance_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":381,"sourceCode":"        .taker_fee(taker_fee)\n        .info(info)\n        .ts_event(ts_event)\n        .ts_init(ts_init)\n        .build()\n        .unwrap();\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\nfn margin_percent_to_rate(value: Decimal, field: &str) -> anyhow::Result<Decimal> {\n    let normalized = value.normalize();\n    let scale = normalized.scale();\n    anyhow::ensure!(","sourceCodeStart":363,"sourceCodeEnd":399,"githubUrl":"https://github.com/nautechsystems/nautilus_trader/blob/18893faf8b356be3320add8de2f861b0b647cf06/crates/adapters/architect_ax/src/http/parse.rs#L363-L399","documentation":"Validation in AX instrument parsing's parse_margin_rates: the parsed maintenance margin percentage is zero or negative, which cannot represent a valid margin requirement, so the instrument definition is rejected.","triggerScenarios":"parse_instrument (via request_instruments/request_instrument) on a definition where maintenance_margin_pct <= 0.","commonSituations":"Missing or zero-defaulted margin metadata from the venue, fixtures with placeholder zeros, negative values from a malformed feed.","solutions":["Inspect the venue's maintenance margin field for the instrument.","Correct the upstream value to a positive percentage.","Fix fixtures to carry realistic positive maintenance margins.","Handle/filter instruments with missing margin data before parsing if they are not tradable."],"exampleFix":"// before (payload)\n\"margin_maint_pct\": \"0\"\n// after\n\"margin_maint_pct\": \"0.05\"","handlingStrategy":"validation","validationCode":"fn valid_maintenance_margin(v: Decimal) -> bool { v > Decimal::ZERO }","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Validate both margin fields together before parsing","Watch for venue feeds defaulting margins to zero","Fix float-to-Decimal generation so nulls do not become zeros"],"tags":["rust","validation","margin","decimal"],"backgroundTag":"value-out-of-range","analyzedSha":"18893faf8b356be3320add8de2f861b0b647cf06","analyzedAt":"2026-09-08T20:49:34.690Z","contentChangedAt":"2026-09-08T20:49:34.690Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}