nautechsystems/nautilus_trader · error

Invalid account currency code

Error message

Invalid account currency code: {code}

What it means

Betfair adapter config validation: the configured account currency string is parsed into the nautilus Currency type, and any parse failure is converted into this anyhow error. It means the currency code string is not a recognized currency in the codebase.

Solutions

  1. Use a valid ISO 4217 code supported by nautilus (e.g. GBP, USD, EUR, AUD) with exact casing
  2. Check nautilus' Currency registry for supported codes or register a custom Currency before use
  3. Fix the config file or environment variable supplying the code

Example fix

// before
account_currency = "gbp"
// after
account_currency = "GBP"
Defensive patterns

Strategy: validation

Validate before calling

// Rust
let code = "GBP";
assert!(
    code.parse::<nautilus_model::enums::Currency>().is_ok(),
    "unsupported currency: {code}"
);

Type guard

fn is_supported_currency(code: &str) -> bool {
    code.parse::<nautilus_model::enums::Currency>().is_ok()
}

Prevention

When it happens

Trigger: Setting an account_currency (or similar) config value to a code that Currency::from_str does not recognize — misspelled codes, lowercase codes, or non-ISO codes.

Common situations: Typos in TOML/env config; using lowercase or free-text currency names; using an exotic venue-specific code nautilus has no Currency registered for.

Understand the failure class

Background: "Must be a positive integer", "Invalid value", "Unsupported": the invalid-argument-value error family, when a library rejects the value you pass — this error's family across 35 libraries.

Related errors


AI-assisted analysis of nautechsystems/nautilus_trader@18893faf8b (2026-09-08). Data as JSON: /api/errors/4e7450d1f017c12b. Report an issue: GitHub.

Appendix: source

Thrown at crates/adapters/betfair/src/config.rs:42

use nautilus_model::{
    identifiers::AccountId,
    types::{Currency, Money},
};
use rust_decimal::Decimal;
use serde::{Deserialize, Serialize};

use crate::{
    common::{
        credential::{BetfairCredential, CredentialError},
        parse::parse_betfair_timestamp,
    },
    provider::NavigationFilter,
    stream::config::BetfairStreamConfig,
};

fn parse_currency(code: &str) -> anyhow::Result<Currency> {
    code.parse::<Currency>()
        .map_err(|_| anyhow::anyhow!("Invalid account currency code: {code}"))
}

fn make_min_notional(value: Option<Decimal>, currency: Currency) -> anyhow::Result<Option<Money>> {
    value
        .map(|amount| Money::from_decimal(amount, currency))
        .transpose()
        .map_err(Into::into)
}

fn validate_market_start_time(label: &str, value: &Option<String>) -> anyhow::Result<()> {
    if let Some(value) = value {
        parse_betfair_timestamp(value)
            .map(|_| ())
            .map_err(|e| anyhow::anyhow!("Invalid {label} '{value}': {e}"))?;
    }

    Ok(())
}

View on GitHub (pinned to 18893faf8b)