nautechsystems/nautilus_trader · error

No wallet balance found in response

Error message

No wallet balance found in response

What it means

The adapter expects Bybit's GET /v5/account/wallet-balance response to contain at least one wallet balance entry in `result.list`. When the list is empty, it cannot build an account state and throws this error.

Source

Thrown at crates/adapters/bybit/src/http/client.rs:4207

    pub async fn request_account_state(
        &self,
        account_type: BybitAccountType,
        account_id: AccountId,
    ) -> anyhow::Result<AccountState> {
        let params = BybitWalletBalanceParams {
            account_type,
            coin: None,
        };

        let response = self.inner.get_wallet_balance(&params).await?;
        let ts_init = self.generate_ts_init();

        // Take the first wallet balance from the list
        let wallet_balance = response
            .result
            .list
            .first()
            .ok_or_else(|| anyhow::anyhow!("No wallet balance found in response"))?;

        parse_account_state(wallet_balance, account_id, ts_init)
    }

    /// Request multiple order status reports.
    ///
    /// Orders for instruments not currently loaded in cache will be skipped.
    ///
    /// When `open_only` is true the realtime endpoint is queried for currently
    /// open orders and again for recently closed orders, so terminal reports
    /// are included. The closed pass fetches the most recent page only and is
    /// not constrained by `start` or `end`.
    ///
    /// # Errors
    ///
    /// Returns an error if:
    /// - Credentials are missing.
    /// - The request fails.

View on GitHub (pinned to 18893faf8b)

Solutions

  1. Verify the account_type requested matches where funds actually live (UNIFIED, CONTRACT, FUND, SPOT)
  2. Check the account has balance/deposit and the API key has Account read permission
  3. Inspect the raw response `retCode`/`retMsg` for upstream errors masked as an empty list
  4. Fund the account or switch to the correct account type in the adapter config

Example fix

// before
let wallet_balance = response.result.list.first()
    .ok_or_else(|| anyhow::anyhow!("No wallet balance found in response"))?;
// after: validate the account type choice up front
if response.result.list.is_empty() {
    anyhow::bail!("No wallet balance for account_type={account_type}; check config and account funding");
}
Defensive patterns

Strategy: try-catch

Validate before calling

if not response.get('result', {}).get('list'):
    raise ValueError('wallet-balance returned empty list; check account_type')

Try / catch

match client.request_account_state(...) { Err(e) if e.to_string().contains("No wallet balance") => fallback_to_next_account_type(), other => other }

Prevention

When it happens

Trigger: Calling request_account_state (wallet balance endpoint) when Bybit returns `result.list: []` — e.g. the account has no balance data for the queried account type (UNIFIED vs CONTRACT vs FUND mismatch).

Common situations: Querying a subaccount with no funds; passing the wrong accountType parameter; API key scoped to an account type with no balances; brand-new account before any deposit.

Understand the failure class

Background: EmptyResultError / "no results found": when an API or scraper succeeds but returns zero rows — this error's family across 9 libraries.

Related errors


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