Metadata-Version: 2.5
Name: tickerall
Version: 0.14.0
Summary: Official Python SDK for TickerAll — the hosted MetaTrader (MT4 & MT5) REST + WebSocket API. Place trades, stream live ticks, read historical candles, copy-trade, and manage broker accounts from your code, with no VPS or MT4/MT5 terminal required.
Project-URL: Homepage, https://tickerall.com
Project-URL: Documentation, https://tickerall.com/docs
Project-URL: Repository, https://github.com/TickerAll/tickerall
Author: Miguel Santos
License: MIT
License-File: LICENSE
Keywords: algorithmic trading,backtesting,broker api,copy trading,forex,forex api,hosted,live ticks,market data,metatrader,metatrader 4,metatrader 5,metatrader api,mt4,mt4 api,mt5,mt5 api,no vps,rest api,sdk,tickerall,trading api,trading bot,websocket
Classifier: Development Status :: 4 - Beta
Classifier: Intended Audience :: Developers
Classifier: Intended Audience :: Financial and Insurance Industry
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Topic :: Office/Business :: Financial :: Investment
Classifier: Typing :: Typed
Requires-Python: >=3.9
Requires-Dist: httpx>=0.25
Requires-Dist: websocket-client>=1.6
Provides-Extra: dev
Requires-Dist: mypy>=1.8; extra == 'dev'
Requires-Dist: pytest>=7.4; extra == 'dev'
Requires-Dist: ruff>=0.4; extra == 'dev'
Requires-Dist: websockets>=13; extra == 'dev'
Description-Content-Type: text/markdown

# tickerall

Official Python client for the [TickerAll](https://tickerall.com) REST + WebSocket API.

Place trades, stream live market data, and manage broker sessions programmatically — **without an MT4/MT5 terminal in the path**. No Windows VM, no Wine, no `MetaTrader5` terminal to babysit, no thread-safety workarounds.

```bash
pip install tickerall
```

Requires Python 3.9+. Depends only on [`httpx`](https://www.python-httpx.org/) and [`websocket-client`](https://github.com/websocket-client/websocket-client).

## Why

The official `MetaTrader5` Python package only runs on Windows, drives a local terminal over a single-threaded IPC channel, and falls over under concurrency. TickerAll hosts the broker connection for you and exposes it as a clean HTTP + WebSocket API, so your bot can run anywhere — Linux, macOS, a container, a Raspberry Pi — and stream ticks instead of polling.

| | `MetaTrader5` (local terminal) | `tickerall` |
|---|---|---|
| OS | Windows only | anywhere Python runs |
| Live ticks | poll `symbol_info_tick()` per symbol | push over WebSocket |
| Concurrency | single-threaded IPC, not thread-safe | stateless HTTP, thread-safe |
| Deploy | a terminal per account to babysit | `pip install` |

## Quickstart

```python
from tickerall import Tickerall

client = Tickerall(api_key="cf_api_...")

# Connect a broker account → get a TickerAll account_id
session = client.sessions.start(
    broker="mt5",
    server="YourBroker-Demo",
    account=12345678,
    password="...",
)

# Place a market order
order = client.orders.place(
    session.account_id,
    type="market",
    symbol="BTCUSDm",
    side="BUY",
    volume=0.10,
    stop_loss=58000.0,
    take_profit=72000.0,
)
print(order.ticket, order.status)

client.sessions.end(session.account_id)
```

You may leave `password` out of `sessions.start` (and `accounts.reconnect`) only
for an account that has a remembered password; the remembered one is then used,
and if the broker refuses it the call raises 401 `BROKER_AUTH_FAILED` with
`err.credential_rejected == True`.

`sessions.start` can refuse a login that is already linked. Both raise
`TickerallBrokerError` with status 409, and nothing is connected:

| `err.code` | Meaning | What to do |
|---|---|---|
| `BROKER_ACCOUNT_HELD_BY_ANOTHER_KEY` | You already have this broker account connected, under an API key this key cannot see (another key's isolated account, or the shared pool when this key is isolated). | Connect with the key that owns it, or move it first with `accounts.migrate_key(account_id, owner_api_key_id)`. |
| `BROKER_ACCOUNT_ALREADY_LINKED` | Another TickerAll customer has this broker account linked. | Nothing to retry. It stays linked to them until they remove it. |

The client is a context manager too:

```python
with Tickerall(api_key="cf_api_...") as client:
    ...
```

## Terminal type (MOBILE / WEB / CLIENT)

`terminal_type` picks which client the connection presents AS — `"MOBILE"` (the
default), `"WEB"`, or `"CLIENT"` (a desktop terminal). All expose the full surface
(account, quotes, positions, history). The type sets the broker-assigned order
origin (`ENUM_DEAL_REASON`): `"MOBILE"` → `DEAL_REASON_MOBILE`, `"WEB"` →
`DEAL_REASON_WEB`, `"CLIENT"` → `DEAL_REASON_CLIENT` — useful where a venue
distinguishes desktop-placed orders (e.g. some prop firms).

`"WEB"` **requires the broker's web-terminal URL** (`web_terminal_url`) — web
terminals are per-broker-domain, so the URL must be supplied. `"MOBILE"` and
`"CLIENT"` take neither web field:

```python
session = client.sessions.start(
    broker="mt5",
    server="YourBroker-Server",
    account=12345678,
    password="...",
    terminal_type="WEB",
    web_terminal_url="https://mt5.yourbroker.com",  # required for WEB
    # web_endpoint="wss://host/path",               # optional WS override (rare)
)
```

For a desktop-origin (`DEAL_REASON_CLIENT`) connection — no web URL needed:

```python
session = client.sessions.start(
    broker="mt5",
    server="YourBroker-Server",
    account=12345678,
    password="...",
    terminal_type="CLIENT",
)
```

## Streaming — push, not poll

The stream runs on its own background thread. Register callbacks and go; it
heartbeats, reconnects with backoff, and re-subscribes automatically.

```python
client = Tickerall(api_key="cf_api_...")
session = client.sessions.start(broker="mt5", server="YourBroker-Demo",
                                account=12345678, password="...")

stream = client.stream.connect()
stream.on("tick", lambda e: print(e.symbol, e.bid, e.ask, e.timestamp))
stream.on("position", lambda e: print(e.event, e.position.ticket, e.position.profit))
stream.subscribe_ticks(session.account_id, ["BTCUSDm", "ETHUSDm"])
stream.subscribe_positions(session.account_id)

# ... your app runs ...
stream.close()
```

### Keep an in-memory tick cache fresh (zero polling)

A common pattern: let the WebSocket fill a dict so price reads are O(1) with no
network call — strictly better than polling a terminal per symbol.

```python
latest: dict[str, "TickEvent"] = {}
stream = client.stream.connect()
stream.on("tick", lambda e: latest.__setitem__(e.symbol, e))
stream.subscribe_ticks(session.account_id, ["BTCUSDm", "ETHUSDm", "XAUUSDm"])

# Anywhere in your app — instant, no IPC, no thread-safety dance:
tick = latest.get("BTCUSDm")
```

## Market data & history

```python
# Historical OHLC candles (coarser timeframes reach further back)
bars = client.candles.get(session.account_id, symbol="BTCUSDm", hours=24, timeframe="M5")
for c in bars:
    print(c.timestamp, c.open, c.high, c.low, c.close)

# An exact window: pass both from_ and to. Each takes an ISO-8601 string (a bare
# date is 00:00:00 UTC), Unix seconds, Unix milliseconds (a number below 1e12 is
# read as seconds) or a datetime (a naive one is taken as UTC).
day = client.candles.get(session.account_id, symbol="EURUSD", timeframe="M5",
                         from_="2026-11-09", to="2026-11-10")
# An empty list means there are no bars in that range (e.g. the market was closed).

# Candle timestamps are UTC (bar OPEN time, Unix seconds). The broker stamps bars
# on its own server clock and the API has already converted them, using the
# account's current offset, so do not subtract server_time_offset_seconds yourself.
# Bars from before the broker's last daylight-saving change are one hour off. The
# one exception is an MT4 account whose offset is not known yet
# (server_time_offset_seconds is None): the timestamps are then on the broker's
# server clock (the API marks that response with timeBasis "broker").

# Closed-trade history (profit, swap, commission per row) — what the broker provides
trades = client.history.get(session.account_id, symbol="BTCUSDm", limit=100)

# Deposits, withdrawals, credits… kept separate from trades (newest-first, like
# every history call). Each row carries `time` (UTC) and `broker_time` (the same
# instant in the broker's server-local zone), so a shifted broker clock is visible.
ops = client.history.balance_operations(session.account_id, limit=100)
# each: ticket, type ("deposit" | "withdrawal" | ...), deal_type, amount, profit (the
# amount as the broker booked it; always equal to amount), time, account, comment (the
# broker's own text), symbol / position_id (filled only when the broker's entry carries
# them — brokers generally do not — None otherwise)
# The stream's "account" channel pushes an update on every balance change
# (trade settlement, deposit, withdrawal) — call this on that push to learn what moved it.

# Tradeable symbols and their volume specs
symbols = client.accounts.symbols(session.account_id)
specs = client.accounts.symbol_specs(session.account_id)  # volume min/max/step + base/quote/margin currency

# Remove an account from your roster (disconnects it + drops it from your list
# and billing; broker account and open positions are untouched). Reversible —
# reconnect the same login with sessions.start to re-add it.
client.accounts.remove(session.account_id)
```

```python
# Every order that reached a final state: filled, cancelled, rejected, expired
orders = client.history.orders(session.account_id, limit=100)
# each: order_ticket, position_id, symbol, side, volume, price, state, filling_type, deal_count, time, broker_time

# Individual fills, each with the stop-loss / take-profit on that deal
deals = client.history.deals(session.account_id, limit=100)
```

- **Orders.** `state` is `"FILLED"`, `"CANCELED"`, `"REJECTED"`, `"EXPIRED"` or
  `"PARTIAL"`, the broker's own verdict: a rejected order is never reported as
  cancelled. `"PARTIAL"` is an order that filled in part and whose record still
  says so; it always has `deal_count` above 0. `filling_type` is `"FOK"`,
  `"IOC"`, `"RETURN"` or `"BOC"`; it is set on cancelled, rejected and expired
  orders and `None` on orders that have fills. An order that never filled has
  `position_id == "0"` and `deal_count == 0`.
- **Is the list the whole history?** Every history page can carry
  `coverage == "partial"` with a `coverage_reason`; both are `None` when the list
  is the account's whole history. `"history_still_loading"` means the history had
  not finished loading (read again shortly: it is then whole or
  `"history_load_failed"`), `"history_load_failed"` means it could not be loaded,
  or the broker did not answer the request for it (reconnect the account), and
  `"broker_session_window"` marks a history loaded for a recent window only — an
  MT4 account limited to a window, or an MT5 account connected with terminal type
  "CLIENT" (the list covers that window).
  Read it from a page: `client.history.get_page(account_id).coverage` (also
  `orders_page`, `deals_page`, `balance_operations_page`), or page by page with
  `for page in client.history.pages(account_id, "deals")`; the plain list methods
  and `iterate` return rows only.
- **Deals.** `stop_loss` / `take_profit` are always numbers: the levels on that
  deal, `0` when no level was set. On an `"IN"` deal they are the levels the
  position was opened with; on an `"OUT"` deal, the levels it had when that deal
  closed it. `profit` / `swap` / `commission` are set on closing (`"OUT"`) deals
  only and are `None` on an `"IN"` deal: `None` means "not booked", never `0`.
- **Closed trades** (`history.get`). `stop_loss` / `take_profit` are the levels
  the position had when it closed; `0` means no level.
- **MT4 accounts.** `history.get` returns the account's closed trades and
  `history.balance_operations` its deposits, withdrawals and credit, for the
  whole account, on the first read after the account connects; an account with
  none returns an empty list. `coverage == "partial"` appears only when the
  history could not be read in or was loaded for a recent window only. While
  `server_time_offset_seconds` is `None` on an MT4 account (the first few seconds after connect on some brokers, or a connection made while the market is closed), the UTC time
  fields of history rows (`open_time`, `close_time`, `time`, `set_time`,
  `expiration_time`) are `None` and the `broker_*` twin (`broker_open_time`,
  `broker_close_time`, `broker_time`, `broker_set_time`,
  `broker_expiration_time`) carries the broker's wall-clock time with no offset
  suffix, e.g. `"2026-11-12T18:06:12"`. Rows are ordered and `from` / `to`
  filtered on that clock meanwhile, so read again once it is known (the raw API
  response marks this with `timeBasis: "broker"`); the UTC fields are then
  filled and the twins carry their numeric offset. On closed trades
  `close_ticket` is always `None`, `profit` is before swap and commission, and
  there are no partial rows; `take_profit`, `comment` and `magic` are `None`
  only when a row does not carry them. Balance rows are `deposit`, `withdrawal`
  or `credit`, with `deal_type` `None` and the broker's `comment`.
  `history.orders` lists each closed trade as one row (`state` `"FILLED"`,
  `price` the open price, with `close_price`, `close_time`, `profit`, `swap`,
  `commission` on the same row; `deal_count` is `None`) together with the
  pending orders that were cancelled or expired (`state` `"CANCELED"` for both,
  with `type`, `set_time`, `expiration_time`); `time` is the trade's close or
  the order's removal. On MT4 `state` is only ever `"FILLED"` or `"CANCELED"`:
  MT4 does not tell an expiry from a cancel. It is more complete than `history.get`, which lists closed trades
  only. An MT4 account whose connection cannot list its cancelled orders raises
  501 `MT4_ORDERS_HISTORY_UNAVAILABLE`. `history.deals` is MT5-only: 501
  `MT4_DEALS_HISTORY_UNAVAILABLE`.
  Closing a position on MT4 returns `deal_ticket` `None`, and a partial close
  also returns `remainder_ticket`: the new ticket the still-open part continues
  under (`None` if not known yet, and on a full close or MT5); `close_price`,
  `profit`, `swap` and `commission` come from the broker's record of the closed
  trade and are all `None` if it has not arrived within about 2.5 seconds.
  Pending orders and symbol specs work on MT4 and MT5 alike.

### Account fields

Every account from `accounts.list()` and `accounts.get()` carries
`credential_rejected_at`. `None` means nothing is wrong. A timestamp (ISO-8601
UTC) means the broker refused the account's remembered password at that time,
for example because it was changed at the broker, and TickerAll stopped
reconnecting it. The account is then offline and its data calls raise
`BROKER_ACCOUNT_NOT_HOT` with `err.credential_rejected == True`. Call
`sessions.start` once with the current password: the account reconnects and the
field is `None` again on the next read.

```python
broken = [a for a in client.accounts.list() if a.credential_rejected_at is not None]
```

`last_hot_at` is when the account last became connected.
`server_time_offset_seconds` is the broker's server offset from UTC in seconds on
MT4 and MT5 accounts; `None` until it is known, `0` for a UTC server.

**Read-only keys.** A read-only or investor-only key cannot trade, but it may
call `accounts.remove`, `sessions.end` and the always-hot setting
(`PATCH /v1/accounts/:id/always-hot`) for any account it can see: a shared key
for accounts in the shared pool, an isolated key for the accounts it owns.

## Positions

```python
detail = client.accounts.get(session.account_id)
for p in detail.positions:
    print(p.ticket, p.symbol, p.side, p.volume, p.profit)

client.positions.modify(session.account_id, ticket=p.ticket, stop_loss=60000.0)
client.positions.close(session.account_id, ticket=p.ticket)          # full close
client.positions.close(session.account_id, ticket=p.ticket, volume=0.05)  # partial
```

## Bulk operations

Execute one action across many of your accounts in a single request. Bulk requires an eligible plan — a request without it returns `403 BULK_REQUIRES_PRO`; see [pricing](https://tickerall.com/pricing) for what's included. A bulk call spans N broker sessions and is **not** atomic — partial success is the contract: each account's outcome is in `results`, and a mix of success/failure still returns (nothing is raised).

> Bulk **trading** (place/close/modify/cancel) currently runs on **demo** accounts; live trading is coming soon. The bulk **read** works on all your accounts, demo or live.

```python
# Place the same order across several accounts
placed = client.bulk.place([
    {"account_id": "acc_1", "type": "market", "symbol": "EURUSDm", "side": "BUY", "volume": 0.1},
    {"account_id": "acc_2", "type": "market", "symbol": "EURUSDm", "side": "BUY", "volume": 0.2},
])
# placed.results -> [BulkPlaceResult(account_id, status='filled'|'failed', ticket, price, ...)]
# placed.summary -> BulkPlaceSummary(total, filled, failed)

# Close positions — explicit tickets, or by intent (flatten all / by symbol+side)
client.bulk.close_positions(items=[{"account_id": "acc_1", "ticket": 4072808150}])
client.bulk.close_positions(targets=[{"account_id": "acc_a", "symbol": "EURUSDm"}, {"account_id": "acc_b", "symbol": "EURUSD"}])  # each account, its own broker-native symbol
client.bulk.close_positions(targets=[{"account_id": "acc_1"}, {"account_id": "acc_2"}])                                                # no symbol on a target → flatten that account

# Modify SL/TP, cancel + modify pending orders
client.bulk.modify_positions([{"account_id": "acc_1", "ticket": 4072808150, "stop_loss": 1.0850}])
client.bulk.cancel_pending(targets=[{"account_id": "acc_1", "symbol": "EURUSDm"}])
client.bulk.modify_pending([{"account_id": "acc_1", "ticket": 4072808151, "price": 1.0805}])

# Read live state for many accounts at once (balance/equity/margin + open positions)
roster = client.bulk.read_accounts()                                            # your whole roster
some = client.bulk.read_accounts(ids=["acc_1", "acc_2"], include=["account", "positions"])
# roster.accounts -> [BulkAccountState(id, status='online'|'offline', hot, read_only, margin_mode,
#                    credential_rejected_at, account, positions, ...)]  # same object as accounts.get
# roster.summary  -> BulkAccountsSummary(total, online, offline)
```

In close/cancel by intent, **each target carries its own broker-native `symbol`** — so a mixed-broker roster (one broker's `EURUSDm` + another's `EURUSD`) is handled in one call. Omit a target's `symbol` to flatten every position on that account; a target whose symbol matches nothing simply reports `no matching open positions`.

Every write method auto-generates an idempotency key (pass `idempotency_key=` to dedupe retries), like the single-account methods.

## Copy Trading

Mirror one **master** account's trades to many **follower** accounts — each scaled, symbol-mapped, and risk-clamped to its own size. Create a set, tune each follower, arm it, and the moment the master trades (through TickerAll) the followers follow. All accounts are your own. Copy Trading requires an eligible plan — a request without it returns `403 COPY_REQUIRES_PRO`; see [pricing](https://tickerall.com/pricing).

> Copy **trading** currently mirrors to **demo** followers; live is coming soon. Managing sets + reading stats works on all accounts.

```python
# Create a set: one master, followers each with their own sizing + risk
s = client.copy.create_set(
    "My desk", "acc_master",
    followers=[
        {"follower_account_id": "acc_1", "sizing_method": "proportional"},                     # scale by equity ratio
        {"follower_account_id": "acc_2", "sizing_method": "multiplier", "sizing_value": 0.5},   # half the master's size
        {"follower_account_id": "acc_3", "sizing_method": "fixed", "sizing_value": 0.01, "symbol_block": ["XAUUSD"]},
    ],
)

client.copy.arm(s.id)   # start mirroring  (pause with client.copy.pause(s.id))

# Manage followers
client.copy.add_follower(s.id, "acc_4", config={"reverse": True, "max_slippage_pips": 3})
client.copy.update_follower(s.id, "follower_id", {"max_lot": 1, "min_master_lot": 0.05})

# Stats + the copy log
stats = client.copy.get_stats(s.id)          # totals, replication rate, per-follower rollups
page = client.copy.get_log(s.id, limit=50)   # every mirrored action; page with before=
```

Config keys are accepted in snake_case or camelCase. **Sizing** per follower: `proportional` (by equity ratio — a small account gets proportionally small trades), `multiplier`, `fixed`, or `risk_percent`. **Per-follower controls** include lot clamps, exposure caps, symbol allow/block lists, a daily-loss stop, `reverse` (inverse) copy, a slippage guard, a min-master-lot filter, and per-broker `symbol_overrides`. A follower's symbol auto-resolves from the master's (suffix-normalized); set `symbol_overrides` for anything cross-broker that doesn't.

## Always-hot sessions & transparent re-arm

For connections that must stay up across restarts, use `keep_alive`. The
credentials the SDK caches live in this process's memory only; if the
account goes cold (e.g. TickerAll restarted), the next call transparently
re-supplies them and retries once.

**No re-arm after a rejected password.** When a call raises
`BROKER_ACCOUNT_NOT_HOT` with `err.credential_rejected == True`, the broker has
refused the account's remembered password. The SDK does not reconnect and does
not retry: the call raises that error at once, and the stream's automatic re-arm
skips the account. Call `sessions.keep_alive` again with the current password
(or `sessions.rearm(account_id)` to retry the cached one yourself).

```python
session = client.sessions.keep_alive(broker="mt5", server="YourBroker-Demo",
                                     account=12345678, password="...")
# ... later, after an outage, this just works — the client re-arms under the hood:
client.accounts.get(session.account_id)

# Stop keeping it alive (drops the cached credentials):
client.sessions.stop_keep_alive(session.account_id)
```

## Reliability — idempotency & queue-and-replay

State-changing calls (`sessions.start`, `orders.place`, `positions.close`,
`positions.modify`) carry an **Idempotency-Key**. The API stores a successful
response under the key for 24 hours: sending the same key again inside that
window replays that response instead of executing a second time. Only a success
is stored, so after an error the same key is sent to the broker again. By default a transient connectivity failure
(`TickerallServiceUnavailableError`, `.transient == True`) **fails fast** so you
can re-decide with fresh prices:

```python
from tickerall import TickerallServiceUnavailableError

try:
    client.orders.place(account_id, type="market", symbol="BTCUSDm", side="BUY", volume=0.1)
except TickerallServiceUnavailableError:
    ...  # momentary blip — safe to retry
```

For price-insensitive orders (pending orders, SL/TP edits) you can instead
**queue-and-replay** until connectivity returns:

```python
client.orders.place(
    account_id, type="limit", symbol="BTCUSDm", side="BUY", volume=0.1, price=60000.0,
    queue_if_reconnecting=True, queue_max_s=60.0,
)
```

**409 `TRADE_UNCONFIRMED` — the outcome is unknown.** The order, close, modify
or cancel was sent to the broker but its answer did not arrive in time, so it may
have executed: read `accounts.get(account_id).positions` or
`orders.list_pending(account_id)` before you decide to retry, because a retry
with the same key can execute a second time. It is raised as
`TickerallTradeUnconfirmedError` (`err.outcome_unknown == True`,
`err.transient == False`) and the SDK never retries it, with or without
`queue_if_reconnecting`; batch results (`positions.close_all`,
`orders.cancel_all`, the `bulk.*` writes) can carry `code == "TRADE_UNCONFIRMED"`
on an item, which means the same for that one item.

A trade call can answer 503 `EDGE_UNREACHABLE` with a `Retry-After` header while
the broker connection is being re-established. Nothing was sent to the broker, so
retrying with the same Idempotency-Key is safe. With `queue_if_reconnecting=True`
the SDK does that for you: every replay carries the same key. Without it the call
raises `TickerallServiceUnavailableError` once (`err.retry_after_seconds` says how
long to wait); a retry you make yourself gets a new key unless you pass the same
`idempotency_key` on both calls.

## Errors

All errors derive from `TickerallApiError` and carry `.status`, `.code`,
`.request_id`, `.details`, and `.transient`, plus:

- `.reason` — `details["reason"]` when the server sent one, else `None`.
- `.credential_rejected` / `.credential_rejected_at` — `True` and the time
  (ISO-8601 UTC) when the broker refused the account's remembered password. Sent
  on 409 `BROKER_ACCOUNT_NOT_HOT` from account data calls, and on 401
  `BROKER_AUTH_FAILED` from a connect that carried no password. Retrying cannot
  help; connect once with the current password. A 422 `BROKER_ACCOUNT_INVALID`
  (the broker refused the account itself) never sets it.
- `.retry_after_seconds` — the response's `Retry-After` in seconds, or `None`. It
  comes with retryable answers such as 503 `EDGE_UNREACHABLE` (the broker
  connection is being re-established). Reads are never retried by the SDK: wait
  that long and call again. A call made with `queue_if_reconnecting=True` waits
  at least that long between replays. It is also set on a connect that fails
  with 401 `BROKER_AUTH_FAILED` and `.reason == "ACCOUNT_NOT_READY"` (the broker
  accepted the login, the account was not ready in time, the password was not
  rejected): connect again after that many seconds.

```python
from tickerall import TickerallApiError

try:
    client.accounts.symbols(account_id)
except TickerallApiError as err:
    if err.credential_rejected:
        ...  # refused at err.credential_rejected_at: ask for the current password, then sessions.start(...)
```

| Class | When |
|---|---|
| `TickerallAuthError` | 401 — bad/missing API key |
| `TickerallForbiddenError` | 403 — plan limit / reserved resource |
| `TickerallValidationError` | 400 / 422 — malformed request |
| `TickerallNotFoundError` | 404 — account / position not found |
| `TickerallBrokerError` | broker rejected or could not satisfy the request; includes 409 `BROKER_ACCOUNT_HELD_BY_ANOTHER_KEY` and `BROKER_ACCOUNT_ALREADY_LINKED` |
| `TickerallTradeUnconfirmedError` | 409 `TRADE_UNCONFIRMED` — sent to the broker, outcome unknown (`.outcome_unknown`); never retried by the SDK — check positions / orders first |
| `TickerallServiceUnavailableError` | transient — TickerAll momentarily unreachable (safe to retry); includes 503 `EDGE_UNREACHABLE` (see `.retry_after_seconds`) |

## Using it from an async app

REST methods are synchronous and thread-safe, so call them from an event loop
via `asyncio.to_thread`:

```python
detail = await asyncio.to_thread(client.accounts.get, account_id)
```

The stream is already non-blocking (its own thread) — callbacks fire as events
arrive.

## License

MIT © Miguel Santos
