# `CCXT.Balance`
[🔗](https://github.com/ZenHive/ccxt_client/blob/main/lib/ccxt/balance.ex#L1)

Unified account balance across currencies.

Balances are stored as maps of `currency => amount` for each category
(free, used, total).

## Fields

  * `free` - Available balance per currency
  * `used` - Balance locked in orders per currency
  * `total` - Total balance per currency (free + used)
  * `timestamp` - Exchange timestamp in milliseconds
  * `datetime` - ISO 8601 datetime string
  * `info` - Raw exchange response

## Examples

    balance = %CCXT.Balance{
      free: %{"BTC" => 1.5, "USDT" => 10000.0},
      used: %{"BTC" => 0.5},
      total: %{"BTC" => 2.0, "USDT" => 10000.0}
    }

    CCXT.Balance.get(balance, "BTC")
    #=> %{free: 1.5, used: 0.5, total: 2.0}

# `t`

```elixir
@type t() :: %CCXT.Balance{
  datetime: String.t() | nil,
  free: %{required(String.t()) =&gt; number()},
  info: map() | nil,
  timestamp: integer() | nil,
  total: %{required(String.t()) =&gt; number()},
  used: %{required(String.t()) =&gt; number()}
}
```

# `currencies`

```elixir
@spec currencies(t()) :: [String.t()]
```

Returns a sorted list of all currencies in the balance.

## Examples

    CCXT.Balance.currencies(balance)
    #=> ["BTC", "ETH", "USDT"]

# `get`

```elixir
@spec get(t(), String.t()) :: %{free: number(), used: number(), total: number()} | nil
```

Returns the balance for a specific currency.

Returns a map with `:free`, `:used`, and `:total` keys, defaulting
missing values to `0.0`. Returns `nil` if the currency has no entries.

## Examples

    CCXT.Balance.get(balance, "BTC")
    #=> %{free: 1.5, used: 0.5, total: 2.0}

    CCXT.Balance.get(balance, "UNKNOWN")
    #=> nil

# `schema`

```elixir
@spec schema() :: map()
```

JSON Schema for the Balance unified type.

---

*Consult [api-reference.md](api-reference.md) for complete listing*
