{"record":{"id":"08c1a0a3d6184aa5","repo":"nautechsystems/nautilus_trader","slug":"no-currency-code-in-account-details","errorCode":null,"errorMessage":"No currency_code in account details","messagePattern":"No currency_code in account details","errorType":"exception","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"crates/adapters/betfair/src/provider.rs","lineNumber":405,"sourceCode":"    pub fn min_notional(&self) -> Option<Money> {\n        self.min_notional\n    }\n\n    /// Fetches the account currency from the Betfair Account API.\n    ///\n    /// # Errors\n    ///\n    /// Returns an error if the API call fails or the currency code is missing/unknown.\n    pub async fn get_account_currency(&self) -> anyhow::Result<Currency> {\n        let details: AccountDetailsResponse = self\n            .http_client\n            .send_accounts(METHOD_GET_ACCOUNT_DETAILS, &serde_json::json!({}))\n            .await\n            .map_err(|e| anyhow::anyhow!(\"{e}\"))?;\n\n        let code = details\n            .currency_code\n            .ok_or_else(|| anyhow::anyhow!(\"No currency_code in account details\"))?;\n        Ok(code.parse::<Currency>()?)\n    }\n\n    /// Builds an effective filter by merging runtime overrides with the base filter.\n    fn build_effective_filter(\n        &self,\n        overrides: Option<&HashMap<String, String>>,\n    ) -> NavigationFilter {\n        let Some(overrides) = overrides else {\n            return self.nav_filter.clone();\n        };\n\n        let parse_csv = |key: &str| -> Option<Vec<String>> {\n            overrides\n                .get(key)\n                .map(|v| v.split(',').map(|s| s.trim().to_string()).collect())\n        };\n","sourceCodeStart":387,"sourceCodeEnd":423,"githubUrl":"https://github.com/nautechsystems/nautilus_trader/blob/18893faf8b356be3320add8de2f861b0b647cf06/crates/adapters/betfair/src/provider.rs#L387-L423","documentation":"get_account_currency received a successful AccountDetailsResponse whose currency_code field was None. Betfair did not report the account's currency, so the method cannot return a Currency and raises an explicit error.","triggerScenarios":"Calling get_account_currency when Betfair's getAccountDetails returns without a currency_code, typically for accounts with undetermined currency, certain demo/promotional accounts, or unusual account types.","commonSituations":"New Betfair accounts before first deposit; accounts in jurisdictions where currency is hidden; API responses during account migration; test/integration accounts.","solutions":["Configure the currency explicitly in the adapter/factory config instead of auto-detecting from the account.","Log in to the Betfair site and complete account setup so the API returns a currency_code.","Verify with a raw getAccountDetails call that Betfair really omits currency_code for this account.","Fall back to a default currency constant if the deployment permits."],"exampleFix":"// before\nlet currency = client.get_account_currency().await?;\n// after\nlet currency = match client.get_account_currency().await {\n    Ok(c) => c,\n    Err(e) => {\n        log::warn!(\"currency auto-detect failed ({e}); using configured default\");\n        Currency::GBP()\n    }\n};","handlingStrategy":"fallback","validationCode":"// prefer an explicitly configured currency when available\nlet currency: Option<Currency> = cfg.currency.clone();","typeGuard":null,"tryCatchPattern":"let currency = match client.get_account_currency().await {\n    Ok(c) => c,\n    Err(e) if e.to_string().contains(\"No currency_code\") => {\n        log::warn!(\"account currency missing; using configured default\");\n        cfg.default_currency.clone().ok_or(e)?\n    }\n    Err(e) => return Err(e.into()),\n};","preventionTips":["Configure currency explicitly for accounts known to omit currency_code (new/demo accounts).","Complete account setup on Betfair so the API reports currency.","Add a startup check that account currency detection succeeds before trading."],"tags":["betfair","account","currency","missing-field"],"backgroundTag":"empty-required-field","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"}