{"record":{"id":"7db90ff6ec65b7aa","repo":"nautechsystems/nautilus_trader","slug":"ax-final-settlement-fill-must-also-be-classified-a","errorCode":null,"errorMessage":"AX final-settlement fill must also be classified as a block trade","messagePattern":"AX final-settlement fill must also be classified as a block trade","errorType":"validation","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"crates/adapters/architect_ax/src/http/parse.rs","lineNumber":652,"sourceCode":"/// # Errors\n///\n/// Returns an error if:\n/// - Price or quantity fields cannot be parsed.\n/// - Fee parsing fails.\n/// - Fill classification is inconsistent.\n/// - A fill is neither explicitly special nor linked to a valid order ID.\npub fn parse_fill_report(\n    fill: &AxFill,\n    account_id: AccountId,\n    instrument: &InstrumentAny,\n    ts_init: UnixNanos,\n) -> anyhow::Result<FillReport> {\n    let instrument_id = instrument.id();\n\n    let trade_id = TradeId::new_checked(&fill.trade_id).context(\"Invalid trade_id in Ax fill\")?;\n    let is_block_trade = fill.is_block_trade;\n    let is_final_settlement = fill.is_final_settlement;\n    anyhow::ensure!(\n        !(is_final_settlement == Some(true) && is_block_trade == Some(false)),\n        \"AX final-settlement fill must also be classified as a block trade\"\n    );\n\n    let is_special_fill = is_block_trade == Some(true) || is_final_settlement == Some(true);\n    let venue_order_id = if is_special_fill {\n        VenueOrderId::new_checked(format!(\"AX-FILL-{}\", fill.trade_id))\n            .context(\"Invalid synthetic venue order ID for AX fill\")?\n    } else {\n        let order_id = fill\n            .order_id\n            .as_deref()\n            .context(\"AX fill is missing order_id and explicit special-fill classification\")?;\n        anyhow::ensure!(\n            !order_id.is_empty(),\n            \"AX regular fill has an empty order_id\"\n        );\n        VenueOrderId::new_checked(order_id).context(\"Invalid order_id in AX fill\")?","sourceCodeStart":634,"sourceCodeEnd":670,"githubUrl":"https://github.com/nautechsystems/nautilus_trader/blob/18893faf8b356be3320add8de2f861b0b647cf06/crates/adapters/architect_ax/src/http/parse.rs#L634-L670","documentation":"In the AX adapter, a fill flagged as final settlement must also be flagged as a block trade. The two classifications drive venue_order_id synthesis for special fills, and a final-settlement fill without block classification is treated as inconsistent venue data, so parsing is rejected.","triggerScenarios":"parse_fill_report (via request_fill_reports) encountering a fill where is_final_settlement == Some(true) but is_block_trade == Some(false).","commonSituations":"AX venue sends inconsistent flags on expiry-day settlement fills; a venue API version change altering flag semantics; adapter consuming fills from a venue misconfiguring final settlement events.","solutions":["Check the raw fill payload flags (is_block_trade, is_final_settlement) from the AX API.","If the venue data is inconsistent, obtain corrected fill records or re-fetch the affected fills.","Filter the inconsistent fill and reconcile it manually with the venue.","If a newer AX API decoupled these flags, update the adapter's parsing rules."],"exampleFix":"// before (payload)\n{ \"trade_id\": \"T1\", \"is_block_trade\": false, \"is_final_settlement\": true }\n// after\n{ \"trade_id\": \"T1\", \"is_block_trade\": true, \"is_final_settlement\": true }","handlingStrategy":"validation","validationCode":"fn fill_flags_consistent(f: &AxFill) -> bool {\n    !(f.is_final_settlement == Some(true) && f.is_block_trade == Some(false))\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Validate flag pairs when fetching fills around expiry dates","Reconcile inconsistent venue fill data before feeding the adapter","Track AX API changes to fill classification flags"],"tags":["rust","validation","fills","invariant"],"backgroundTag":"unexpected-api-response-shape","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"}