{"record":{"id":"4568ab3abd25bd73","repo":"nautechsystems/nautilus_trader","slug":"architect-ax-adapter-cannot-encode-quote-quantity","errorCode":null,"errorMessage":"Architect AX adapter cannot encode quote_quantity; submit a base quantity instead","messagePattern":"Architect AX adapter cannot encode quote_quantity; submit a base quantity instead","errorType":"validation","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"crates/adapters/architect_ax/src/execution.rs","lineNumber":1923,"sourceCode":"fn validate_order_init_instructions(order_init: &OrderInitialized) -> anyhow::Result<()> {\n    validate_order_instructions(\n        order_init.reduce_only,\n        order_init.quote_quantity,\n        order_init.display_qty.is_some(),\n    )\n}\n\nfn validate_order_instructions(\n    reduce_only: bool,\n    quote_quantity: bool,\n    has_display_qty: bool,\n) -> anyhow::Result<()> {\n    if reduce_only {\n        anyhow::bail!(\"AX does not support reduce-only orders\");\n    }\n\n    if quote_quantity {\n        anyhow::bail!(\n            \"Architect AX adapter cannot encode quote_quantity; submit a base quantity instead\"\n        );\n    }\n\n    if has_display_qty {\n        anyhow::bail!(\"Architect AX adapter cannot encode display_qty iceberg instructions\");\n    }\n\n    Ok(())\n}\n\n// The AX HTTP API documents only a bare 400 with no error schema, so no venue\n// failure can be allowlisted as an unambiguous rejection; those arrive via the\n// orders WS `Rejected` and `CancelRejected` events instead. AX therefore never\n// classifies a send failure as `CommandFailure::VenueRejected`.\nfn classify_ax_http_failure(error: &AxHttpError) -> CommandFailure {\n    let message = error.to_string();\n    match error {","sourceCodeStart":1905,"sourceCodeEnd":1941,"githubUrl":"https://github.com/nautechsystems/nautilus_trader/blob/a4b06ed870971b5671d12754ea138a3ab99b1dec/crates/adapters/architect_ax/src/execution.rs#L1905-L1941","documentation":"validate_order_instructions rejects orders with quote_quantity=true: the AX order encoding accepts only a base-size (integer contract count, see quantity_to_contracts), so an order denominated in quote currency (e.g. 'buy $5,000 of BTC-PERP') cannot be encoded. The message tells you the unit mismatch directly - the adapter needs a base quantity instead. Checked at both submit validation and OrderInitialized validation.","triggerScenarios":"factory.market(...).quote_quantity(true) (or an OrderInitialized with quote_quantity set) submitted to the AX execution client; strategies that size entries in USD notional, common when porting from spot adapters.","commonSituations":"Notional-based position sizing code shared across venues; default templates from adapters where quote-quantity market buys are idiomatic.","solutions":["Compute base size = notional / reference_price and submit that base quantity instead","Round to a whole number of contracts (AX quantities are integers; fractional contracts also fail later in quantity_to_contracts)","Keep the reference-price logic in the strategy so the order you submit is already base-denominated"],"exampleFix":"// before\nlet order = factory.market(id, side, Quantity::from(5_000))\n    .quote_quantity(true); // $5000 notional -> error\n// after\nlet base = (5_000.0 / mid_price).floor(); // whole contracts\nlet order = factory.market(id, side, Quantity::from(base));","handlingStrategy":"validation","validationCode":"// Convert notional to base contracts before building the order\nlet contracts = (notional / ref_price).floor();\nensure!(contracts >= 1.0, \"notional too small for one contract\");\nlet qty = Quantity::from(contracts as u64); // integer contracts only\nassert!(!order.is_quote_quantity());","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Do notional-to-base conversion in the sizing layer so orders are always base-denominated","Remember AX takes integer contract counts - fractional sizes fail even without quote_quantity","Unit-test sizing helpers against the minimum contract size of each AX instrument"],"tags":["architect-ax","order-validation","quote-quantity","notional-sizing","rust"],"backgroundTag":"quote-quantity-not-supported","analyzedSha":"a4b06ed870971b5671d12754ea138a3ab99b1dec","analyzedAt":"2026-08-16T22:54:50.089Z","schemaVersion":2},"datasetVersion":"2026-08-16T23:17:17.608Z"}