TICKERALL!
Official SDK · Python 3.9+

TickerAll Python SDK

A synchronous Python client for the TickerAll REST + WebSocket API — place trades, stream live market data (on a background thread), and manage broker sessions, with idempotency keys and automatic reconnects built in. Depends only on httpx + websocket-client.

Install & connect

One client object holds your API key and exposes every namespace. The same key can drive many broker accounts at once, each addressed by its accountId.

Install

Add the package. Requires Node 18+ / Python 3.9+; no native dependencies.

Python
pip install tickerall
new Tickerall(config)

Create a client. Only apiKey is required; baseUrl / streamUrl / timeout / userAgent / onRearm are optional.

Python
from tickerall import Tickerall

client = Tickerall(api_key="cf_live_...")
# base_url=..., stream_url=..., timeout=30.0, user_agent=... optional.
# Also usable as a context manager:
with Tickerall(api_key="cf_live_...") as client:
    ...

Sessions

Connect a broker account and get its accountId. keepAlive caches the credentials in this process’s memory (never persisted) so the client transparently re-arms an account that goes cold — e.g. after a service restart.

sessions.start(params)

Connect a broker account → returns its accountId, isDemo, status, expiresAt. Pass terminalType to pick the terminal type (MOBILE default, or WEB — WEB requires the broker’s webTerminalUrl).

Python
session = client.sessions.start(
    broker="mt5",
    server="Exness-MT5Trial7",
    account=12345678,
    password="...",
    # Optional terminal type: "MOBILE" (default) or "WEB".
    terminal_type="MOBILE",
)
# session.account_id, session.is_demo

# For WEB, the broker's web-terminal URL is required:
# web = client.sessions.start(
#     broker="mt5", server="YourBroker-Server", account=12345678,
#     password="...", terminal_type="WEB",
#     web_terminal_url="https://mt5.yourbroker.com",
# )
sessions.keep_alive(params)

Start a session AND keep it alive — credentials cached in RAM for transparent re-arm.

Python
session = client.sessions.keep_alive(
    broker="mt5", server="Exness-MT5Trial7",
    account=12345678, password="...",
)
sessions.stop_keep_alive(account_id)

Stop auto-re-arming an account and drop its cached credentials.

Python
client.sessions.stop_keep_alive(account_id)
sessions.rearm(account_id)

Manually re-arm a kept account now (normally unnecessary — the client does it on demand).

Python
client.sessions.rearm(account_id)
sessions.pending_rearm()

Always-hot accounts that currently have no live connection (need a credentials refresh).

Python
pending = client.sessions.pending_rearm()
sessions.rearm_pending()

Re-arm every pending account you hold kept credentials for. Returns the re-armed IDs.

Python
ids = client.sessions.rearm_pending()
sessions.end(account_id)

Disconnect a session (also stops keeping it alive).

Python
client.sessions.end(account_id)

Accounts

List and inspect the broker accounts linked to your key — balances, open positions, tradeable symbols and their volume specs.

accounts.list()

All broker accounts linked to your API key.

Python
accounts = client.accounts.list()
accounts.get(account_id)

Full snapshot — balance/leverage info and open positions when online.

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

The broker-native symbol names this account can trade.

Python
symbols = client.accounts.symbols(account_id)
accounts.symbol_specs(account_id)

Per-symbol volume specs (min / max / step) + trade mode — validate an order size before placing it (MT5 only).

Python
specs = client.accounts.symbol_specs(account_id)
# each: name, volume_min, volume_max, volume_step, spec_source, trade_mode
accounts.remove(account_id)

Remove a broker account from your roster — disconnects it and drops it from your list and billing. Does not touch the broker account or its open positions; reconnect with sessions.start to re-add it.

Python
client.accounts.remove(account_id)
accounts.migrate(account_id, to)

Switch the terminal type (MOBILE↔WEB) on a live account. Open positions/orders/balance are preserved (they live broker-side). The switch is zero-gap — the new transport is warmed before the old is dropped — and runs only when the account is idle. Returns status:"noop" if already on `to`.

Python
res = client.accounts.migrate(account_id, "WEB")
# res.terminal_type, res.status ("noop" | "migrated")

Orders

Place market and pending (limit / stop) orders, and manage resting pending orders. State-changing calls carry a stable idempotency key so a retry can’t double-execute.

orders.place(account_id, params)

Place a market / limit / stop order. price is required for limit & stop.

Python
order = client.orders.place(
    account_id,
    type="market", symbol="BTCUSDm", side="BUY", volume=0.1,
    stop_loss=58000, take_profit=72000,
)
# order.ticket, order.status
orders.list_pending(account_id)

List resting pending orders (LIMIT / STOP). MT5 only — MT4 returns an empty list.

Python
pending = client.orders.list_pending(account_id)
# each: ticket, symbol, type, side, order_type, volume, price, ...
orders.cancel_pending(account_id, ticket)

Cancel a resting pending order by its ticket.

Python
client.orders.cancel_pending(account_id, 4521969907)
orders.modify_pending(account_id, ticket, params)

Change a pending order’s trigger price / SL / TP. Omitted fields are preserved.

Python
client.orders.modify_pending(
    account_id, 4521969907,
    price=60000, stop_loss=58000, take_profit=72000,
)

Positions

Close (fully or partially) and modify the stop-loss / take-profit on open positions.

positions.close(account_id, ticket, params?)

Close a position fully, or partially when volume is given.

Python
client.positions.close(account_id, 70001)              # full
client.positions.close(account_id, 70001, volume=0.05) # partial
positions.modify(account_id, ticket, params)

Set or change the SL / TP on an open position. Provide at least one.

Python
client.positions.modify(
    account_id, 70001, stop_loss=60000, take_profit=72000,
)

Candles

Historical OHLC candles from a connected account, across all nine timeframes. Coarser timeframes reach further back; deep look-backs ride an isolated history connection so they don’t disturb your live tick stream.

candles.get(account_id, params)

Fetch OHLC bars for a symbol. Pass a large hours and take what comes back.

Python
bars = client.candles.get(
    account_id, symbol="BTCUSDm", hours=8760, timeframe="D1",
)
# each: timestamp, open, high, low, close, bid

Trade history

Closed-trade history — executed deals paired into round-trips, from the broker’s recent deal window plus any closes seen live this session.

history.get(account_id, params?)

Closed round-trips, optionally filtered by symbol / from / to / limit.

Python
trades = client.history.get(account_id, symbol="BTCUSDm", limit=100)
# each: ticket, side, volume, open_price, close_price, profit, ...

Realtime stream

A single self-healing WebSocket pushes live ticks, position events, and account snapshots. It heartbeats, reconnects with backoff, and re-subscribes automatically — you register callbacks and go.

stream.connect()

Open the stream, register callbacks, and subscribe to topics.

Python
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.on("account", lambda e: print(e.snapshot.balance))
stream.on("reconnect", lambda e: print("reconnecting", e["attempt"]))

stream.subscribe_ticks(account_id, ["BTCUSDm", "ETHUSDm"])
stream.subscribe_positions(account_id)
stream.subscribe_account(account_id)
O(1) tick cache pattern

Let the WebSocket fill a dict/map so price reads are instant with no polling.

Python
latest = {}
stream.on("tick", lambda e: latest.__setitem__(e.symbol, e))
# latest.get("BTCUSDm") — instant, no network
state & teardown

Query connection state, wait for it, unsubscribe, and close.

Python
stream.get_state()         # connecting | open | reconnecting | closed
stream.is_connected()
stream.wait_until_connected(30.0)
stream.unsubscribe_ticks(account_id, ["ETHUSDm"])
stream.close()
set_before_resubscribe(cb)

Advanced hook — runs after a reconnect, just before subscriptions are re-sent. Use it to re-arm kept sessions so the stream transparently survives a backend restart.

Python
def _rearm():
    client.sessions.rearm_pending()

stream.set_before_resubscribe(_rearm)

Errors

Every failure is a typed error carrying status / code / requestId / details / transient. Catch the base class, or a narrow subclass. transient marks a momentary connectivity issue that is safe to retry.

Error hierarchy

TickerallApiError (base) → Auth (401), Forbidden (403), Validation (400/422), NotFound (404), Broker (broker rejection), ServiceUnavailable (transient).

Python
from tickerall import (
    TickerallApiError,
    TickerallServiceUnavailableError,
    TickerallBrokerError,
)

try:
    client.orders.place(account_id, type="market", symbol="BTCUSDm", side="BUY", volume=0.1)
except TickerallServiceUnavailableError:
    ...  # transient — safe to retry
except TickerallBrokerError as e:
    ...  # broker rejected — e.code, e.message
except TickerallApiError as e:
    print(e.status, e.code, e.request_id, e.transient)

Reliability

State-changing calls (sessions.start, orders.place, positions.close / modify, pending cancel / modify) carry a stable Idempotency-Key, so a retried call can’t double-execute. By default a transient failure fails fast so you can re-decide with fresh prices.

Idempotency keys

Auto-generated per call; supply your own to make a retry safe across process restarts.

Python
client.orders.place(
    account_id,
    type="market", symbol="BTCUSDm", side="BUY", volume=0.1,
    idempotency_key="order-2026-06-02-001",
)
Queue-and-replay

For price-insensitive orders (pending, SL/TP edits), opt into queue-and-replay: held in order and retried with the stable key until connectivity returns.

Python
client.orders.place(
    account_id,
    type="limit", symbol="BTCUSDm", side="BUY", volume=0.1, price=60000,
    queue_if_reconnecting=True, queue_max_s=60.0,
)
Kept sessions across restarts

For an always-on connection, keepAlive caches credentials so the client transparently re-arms after a service restart — no manual reconnect.

Python
client.sessions.keep_alive(broker="mt5", server=server, account=account, password=password)
Python SDK — TickerAll Docs · Ticker All!