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.
Add the package. Requires Node 18+ / Python 3.9+; no native dependencies.
pip install tickerallCreate a client. Only apiKey is required; baseUrl / streamUrl / timeout / userAgent / onRearm are optional.
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.
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).
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",
# )Start a session AND keep it alive — credentials cached in RAM for transparent re-arm.
session = client.sessions.keep_alive(
broker="mt5", server="Exness-MT5Trial7",
account=12345678, password="...",
)Stop auto-re-arming an account and drop its cached credentials.
client.sessions.stop_keep_alive(account_id)Manually re-arm a kept account now (normally unnecessary — the client does it on demand).
client.sessions.rearm(account_id)Always-hot accounts that currently have no live connection (need a credentials refresh).
pending = client.sessions.pending_rearm()Re-arm every pending account you hold kept credentials for. Returns the re-armed IDs.
ids = client.sessions.rearm_pending()Disconnect a session (also stops keeping it alive).
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.
All broker accounts linked to your API key.
accounts = client.accounts.list()Full snapshot — balance/leverage info and open positions when online.
detail = client.accounts.get(account_id)
for p in detail.positions:
print(p.ticket, p.symbol, p.side, p.volume, p.profit)The broker-native symbol names this account can trade.
symbols = client.accounts.symbols(account_id)Per-symbol volume specs (min / max / step) + trade mode — validate an order size before placing it (MT5 only).
specs = client.accounts.symbol_specs(account_id)
# each: name, volume_min, volume_max, volume_step, spec_source, trade_modeRemove 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.
client.accounts.remove(account_id)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`.
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.
Place a market / limit / stop order. price is required for limit & stop.
order = client.orders.place(
account_id,
type="market", symbol="BTCUSDm", side="BUY", volume=0.1,
stop_loss=58000, take_profit=72000,
)
# order.ticket, order.statusList resting pending orders (LIMIT / STOP). MT5 only — MT4 returns an empty list.
pending = client.orders.list_pending(account_id)
# each: ticket, symbol, type, side, order_type, volume, price, ...Cancel a resting pending order by its ticket.
client.orders.cancel_pending(account_id, 4521969907)Change a pending order’s trigger price / SL / TP. Omitted fields are preserved.
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.
Close a position fully, or partially when volume is given.
client.positions.close(account_id, 70001) # full
client.positions.close(account_id, 70001, volume=0.05) # partialSet or change the SL / TP on an open position. Provide at least one.
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.
Fetch OHLC bars for a symbol. Pass a large hours and take what comes back.
bars = client.candles.get(
account_id, symbol="BTCUSDm", hours=8760, timeframe="D1",
)
# each: timestamp, open, high, low, close, bidTrade history
Closed-trade history — executed deals paired into round-trips, from the broker’s recent deal window plus any closes seen live this session.
Closed round-trips, optionally filtered by symbol / from / to / limit.
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.
Open the stream, register callbacks, and subscribe to topics.
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)Let the WebSocket fill a dict/map so price reads are instant with no polling.
latest = {}
stream.on("tick", lambda e: latest.__setitem__(e.symbol, e))
# latest.get("BTCUSDm") — instant, no networkQuery connection state, wait for it, unsubscribe, and close.
stream.get_state() # connecting | open | reconnecting | closed
stream.is_connected()
stream.wait_until_connected(30.0)
stream.unsubscribe_ticks(account_id, ["ETHUSDm"])
stream.close()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.
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.
TickerallApiError (base) → Auth (401), Forbidden (403), Validation (400/422), NotFound (404), Broker (broker rejection), ServiceUnavailable (transient).
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.
Auto-generated per call; supply your own to make a retry safe across process restarts.
client.orders.place(
account_id,
type="market", symbol="BTCUSDm", side="BUY", volume=0.1,
idempotency_key="order-2026-06-02-001",
)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.
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,
)For an always-on connection, keepAlive caches credentials so the client transparently re-arms after a service restart — no manual reconnect.
client.sessions.keep_alive(broker="mt5", server=server, account=account, password=password)