{"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":377,"sourceCode":"        .maybe_min_quantity(min_quantity)\n        .margin_init(margin_init)\n        .margin_maint(margin_maint)\n        .maker_fee(maker_fee)\n        .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","sourceCodeStart":359,"sourceCodeEnd":395,"githubUrl":"https://github.com/nautechsystems/nautilus_trader/blob/18893faf8b356be3320add8de2f861b0b647cf06/crates/adapters/architect_ax/src/http/parse.rs#L359-L395","documentation":"Validation in AX instrument parsing's parse_margin_rates: the parsed initial 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) passing an instrument definition whose margin data yields initial_margin_pct <= 0 (zero, negative, or a Decimal parsed from '0'/'-0.1').","commonSituations":"Venue margin metadata missing/defaulted to zero, fixtures with 0 placeholders, negative values from a bad feed, or a field rename causing the parser to read the wrong column.","solutions":["Check the raw margin fields on the AX instrument definition.","Correct the source data so initial_margin_pct is > 0.","Fix test fixtures to use realistic positive margins.","If the venue legitimately sends 0 for some instruments, filter them out or update the adapter to handle the special case explicitly."],"exampleFix":"// before (payload)\n\"margin_init_pct\": \"0\"\n// after\n\"margin_init_pct\": \"0.10\"","handlingStrategy":"validation","validationCode":"fn valid_initial_margin(v: Decimal) -> bool { v > Decimal::ZERO }","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Check margin fields when onboarding new instruments","Reject/flag zero-value margin metadata at ingestion","Keep fixtures with realistic positive margins"],"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"}