{"record":{"id":"a3bc83ca400cc4e2","repo":"nautechsystems/nautilus_trader","slug":"e-a3bc83","errorCode":null,"errorMessage":"{e}","messagePattern":"\\{e\\}","errorType":"exception","errorClass":"anyhow::Error","httpStatus":null,"severity":"warning","filePath":"crates/adapters/interactive_brokers/src/execution/account.rs","lineNumber":169,"sourceCode":"    );\n\n    Ok((\n        balances,\n        margins,\n        if info.is_empty() { None } else { Some(info) },\n    ))\n}\n\nfn merge_account_summary_margin(margins: &mut Vec<MarginBalance>, summary: &AccountSummary) {\n    let currency = match parse_currency(&summary.currency) {\n        Ok(currency) => currency,\n        Err(e) => {\n            tracing::warn!(\"Skipping margin summary with unknown currency: {}\", e);\n            return;\n        }\n    };\n    let value = match parse_balance_decimal(&summary.value)\n        .and_then(|d| Money::from_decimal(d, currency).map_err(|e| anyhow::anyhow!(e.to_string())))\n    {\n        Ok(money) => money,\n        Err(e) => {\n            tracing::warn!(\"Failed to parse margin value '{}': {}\", summary.value, e);\n            return;\n        }\n    };\n\n    let existing = margins\n        .iter_mut()\n        .find(|m| m.currency == currency && m.instrument_id.is_none());\n\n    match summary.tag.as_str() {\n        AccountSummaryTags::INIT_MARGIN_REQ => match existing {\n            Some(margin) => margin.initial = value,\n            None => margins.push(MarginBalance::new(value, Money::zero(currency), None)),\n        },\n        AccountSummaryTags::MAINT_MARGIN_REQ => match existing {","sourceCodeStart":151,"sourceCodeEnd":187,"githubUrl":"https://github.com/nautechsystems/nautilus_trader/blob/18893faf8b356be3320add8de2f861b0b647cf06/crates/adapters/interactive_brokers/src/execution/account.rs#L151-L187","documentation":"This error is raised when a parsed IB margin summary value cannot be converted into a Nautilus Money amount, typically because Money::from_decimal rejects the decimal (e.g. wrong precision for the currency) or a chained parse fails. merge_account_summary_margin logs it as a warning and skips that margin row instead of propagating it, so account margin data can be silently incomplete. It surfaces to developers through the 'Skipping margin summary' / 'Failed to parse margin value' warn logs.","triggerScenarios":"Calling subscribe_account_summary (or running the merge tests) when an IB AccountSummary row with tag InitMarginReq or MaintMarginReq has a value string that fails parse_balance_decimal or a decimal that Money::from_decimal cannot represent for the parsed currency.","commonSituations":"IB returns unexpected value strings like '1.7976931348623157E308' (infinite/placeholder margin values), scientific notation, or empty strings during account warm-up; currency-specific precision limits in Money::from_decimal reject high-precision values.","solutions":["Check logs for 'Failed to parse margin value' and inspect the raw value string IB returned for that tag/currency.","Filter out IB sentinel values (e.g. values in scientific notation or ~1.7e308) before calling Money::from_decimal.","Verify parse_balance_decimal handles IB's number formats and add a pre-check that the decimal is finite and within Money precision for the currency.","Ensure the currency string parsed by parse_currency is correct, since from_decimal precision depends on the currency."],"exampleFix":"// before\nlet value = match parse_balance_decimal(&summary.value)\n    .and_then(|d| Money::from_decimal(d, currency).map_err(|e| anyhow::anyhow!(e.to_string())))\n{\n    Ok(money) => money,\n    Err(e) => { tracing::warn!(\"Failed to parse margin value '{}': {}\", summary.value, e); return; }\n};\n// after\nlet value = match parse_balance_decimal(&summary.value) {\n    Ok(d) if d.is_finite() => Money::from_decimal(d, currency)\n        .map_err(|e| anyhow::anyhow!(e.to_string())),\n    Ok(_) => { tracing::warn!(\"Skipping non-finite margin value '{}'\", summary.value); return; }\n    Err(e) => { tracing::warn!(\"Failed to parse margin value '{}': {}\", summary.value, e); return; }\n};","handlingStrategy":"validation","validationCode":"fn is_representable_margin(value: &str, currency: Currency) -> bool {\n    match rust_decimal::Decimal::from_str_exact(value) {\n        Ok(d) => d.is_finite() && d.abs() < rust_decimal::Decimal::from(1_000_000_000),\n        Err(_) => false,\n    }\n}","typeGuard":null,"tryCatchPattern":"match result {\n    Ok(money) => apply_margin(money),\n    Err(e) => tracing::warn!(\"Skipping margin row: {}\", e),\n}","preventionTips":["Log the raw IB summary value and tag whenever a margin row is skipped so formats are diagnosable.","Sanitize IB sentinel/scientific-notation values before parsing.","Test merge_account_summary_margin against real IB payloads including placeholder values."],"tags":["parsing","interactive-brokers","decimal","account-margin"],"backgroundTag":"invalid-argument-format","analyzedSha":"18893faf8b356be3320add8de2f861b0b647cf06","analyzedAt":"2026-09-08T20:49:34.690Z","contentChangedAt":"2026-09-08T20:49:34.690Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}