{"record":{"id":"eb1df7897674103c","repo":"nautechsystems/nautilus_trader","slug":"single-currency-account-has-multiple-starting-curr","errorCode":null,"errorMessage":"single-currency account has multiple starting currencies","messagePattern":"single-currency account has multiple starting currencies","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/backtest/src/exchange.rs","lineNumber":223,"sourceCode":"impl SimulatedExchange {\n    /// Creates a new [`SimulatedExchange`] instance from a venue configuration.\n    ///\n    /// # Errors\n    ///\n    /// Returns an error if:\n    /// - `starting_balances` is empty.\n    /// - `base_currency` is `Some` but `starting_balances` contains multiple currencies.\n    pub fn new(\n        config: SimulatedVenueConfig,\n        cache: Rc<RefCell<Cache>>,\n        clock: Rc<RefCell<dyn Clock>>,\n    ) -> anyhow::Result<Self> {\n        if config.starting_balances.is_empty() {\n            anyhow::bail!(\"Starting balances must be provided\")\n        }\n\n        if config.base_currency.is_some() && config.starting_balances.len() > 1 {\n            anyhow::bail!(\"single-currency account has multiple starting currencies\")\n        }\n\n        let default_leverage = config.default_leverage.unwrap_or_else(|| {\n            if config.account_type == AccountType::Margin {\n                Decimal::from(10)\n            } else {\n                Decimal::from(1)\n            }\n        });\n\n        Ok(Self {\n            id: config.venue,\n            oms_type: config.oms_type,\n            account_type: config.account_type,\n            base_currency: config.base_currency,\n            starting_balances: config.starting_balances,\n            book_type: config.book_type,\n            default_leverage,","sourceCodeStart":205,"sourceCodeEnd":241,"githubUrl":"https://github.com/nautechsystems/nautilus_trader/blob/18893faf8b356be3320add8de2f861b0b647cf06/crates/backtest/src/exchange.rs#L205-L241","documentation":"When a base_currency is configured the account is single-currency, so supplying more than one starting balance is contradictory; the constructor bails to prevent an invalid multi-currency account state.","triggerScenarios":"SimulatedVenueConfig with base_currency set (Some) and starting_balances.len() > 1; copying a multi-currency margin config and adding a base_currency.","commonSituations":"Config mistake when switching between cash single-currency and margin multi-currency setups; leftover balances from a template config.","solutions":["Remove base_currency (set None) to allow multi-currency starting balances, or","Reduce starting_balances to a single balance in the configured base_currency","Align account_type with balances: use Margin accounts for multi-currency setups"],"exampleFix":"// before\nSimulatedVenueConfig { base_currency: Some(Currency::USD()), starting_balances: vec![usd, eur], .. }\n// after\nSimulatedVenueConfig { base_currency: None, starting_balances: vec![usd, eur], .. } // multi-currency margin","handlingStrategy":"validation","validationCode":"anyhow::ensure!(\n    config.base_currency.is_none() || config.starting_balances.len() <= 1,\n    \"single-currency account accepts at most one starting balance\"\n);","typeGuard":null,"tryCatchPattern":"match SimulatedExchange::new(config, cache, clock) {\n    Err(e) if e.to_string().contains(\"single-currency account\") => {\n        eprintln!(\"drop base_currency for multi-currency, or trim to one balance\");\n    }\n    other => other?,\n}","preventionTips":["Use base_currency only for single-currency cash accounts","Review template configs when switching cash/margin account types","Pair multi-currency balances with account_type Margin and no base_currency"],"tags":["backtest","exchange","account-currency"],"backgroundTag":"conflicting-config-options","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"}