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). Choosing WEB or CLIENT requires a Pro or Enterprise plan.
session = client.sessions.start(
broker="mt5",
server="Exness-MT5Trial14",
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-MT5Trial14",
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 + the base, profit (quote) and margin currency — validate an order size and denote each instrument in its real currency, not the account currency (MT5 only).
specs = client.accounts.symbol_specs(account_id)
# each: name, volume_min, volume_max, volume_step, spec_source, trade_mode, base_currency, profit_currency, margin_currencyRemove 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="BTCUSD", 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,
)Bulk operations
Execute one action across many accounts in a single call — place, close, modify, and cancel over a set of accounts, or read live state for your whole roster at once. Each method returns a per-account results array plus a summary tally, so a partial success is explicit. Bulk operations require a Pro or Enterprise plan.
Place an order on many accounts (1–50) in one request. Each entry mirrors an orders.place body plus its target accountId.
res = client.bulk.place([
{"accountId": "acc_8Kd3...", "symbol": "BTCUSD", "side": "BUY", "volume": 0.1},
{"accountId": "acc_9Lm4...", "type": "limit", "symbol": "BTCUSD", "side": "BUY", "volume": 0.1, "price": 60000},
])
# res.summary -> total / filled / failed
# res.results[] -> accountId, status, ticket, price, code, reasonClose positions across accounts — an explicit list of positions, or an intent that flattens whole accounts (optionally by symbol / side).
# explicit list (omit volume for a full close, pass a smaller volume to scale out)
client.bulk.close_positions(items=[
{"accountId": "acc_8Kd3...", "ticket": 4072808150},
{"accountId": "acc_9Lm4...", "ticket": 4072809002, "volume": 0.05},
])
# intent: flatten these accounts (optionally one symbol / side)
client.bulk.close_positions(targets=[{"accountId": "acc_8Kd3...", "symbol": "BTCUSD"}, {"accountId": "acc_9Lm4...", "symbol": "BTCUSD"}])Set or change the SL / TP on positions across accounts. Provide at least one of stopLoss / takeProfit per item.
client.bulk.modify_positions([
{"accountId": "acc_8Kd3...", "ticket": 4072808150, "stopLoss": 72000, "takeProfit": 85000},
{"accountId": "acc_9Lm4...", "ticket": 4072809002, "takeProfit": 84000},
])Cancel resting pending orders across accounts — an explicit list, or an intent that cancels every pending order on whole accounts (optionally one symbol).
# explicit list
client.bulk.cancel_pending(items=[
{"accountId": "acc_8Kd3...", "ticket": 4072809988},
{"accountId": "acc_9Lm4...", "ticket": 4072809991},
])
# intent: cancel every pending order on these accounts (optionally one symbol)
client.bulk.cancel_pending(targets=[{"accountId": "acc_8Kd3..."}, {"accountId": "acc_9Lm4..."}])Change the trigger price / SL / TP on pending orders across accounts. Provide at least one of price / stopLoss / takeProfit per item.
client.bulk.modify_pending([
{"accountId": "acc_8Kd3...", "ticket": 4072809988, "price": 60000, "stopLoss": 58000},
{"accountId": "acc_9Lm4...", "ticket": 4072809991, "takeProfit": 72000},
])Read live state (status, account financials, open positions) for many accounts in one call. Omit ids to read your whole roster; use include to trim the payload.
state = client.bulk.read_accounts(
ids=["acc_8Kd3...", "acc_9Lm4..."], # omit for every account on your key
include=["account", "positions"], # default both
)
for a in state.accounts:
print(a.id, a.status)
# state.summary -> total / online / offlineCopy Trading
Mirror one master account's trades to many followers — each scaled, symbol-mapped, and risk-clamped to its own size. Create a set, tune each follower, arm it, and the master's trades follow. Read a set's stats + log. A Pro or Enterprise feature.
Create a copy set — a master account plus optional followers, each with its own sizing + risk config. Arm it to start mirroring.
s = client.copy.create_set(
"My desk", "acc_master",
followers=[
{"follower_account_id": "acc_1", "sizing_method": "proportional"},
{"follower_account_id": "acc_2", "sizing_method": "multiplier", "sizing_value": 0.5},
],
)
client.copy.arm(s.id) # start mirroring (pause with client.copy.pause)Attach or tune a follower — sizing, lot clamps, symbol allow/block, reverse copy, slippage guard, and per-broker symbol overrides.
client.copy.add_follower(s.id, "acc_3", config={"reverse": True, "max_slippage_pips": 3})
client.copy.update_follower(s.id, "follower_id", {"max_lot": 1, "symbol_block": ["XAUUSD"]})
client.copy.remove_follower(s.id, "follower_id")Read a set’s dashboard stats (totals, replication rate, per-follower rollups) and the copy log (every mirrored action, paginated).
stats = client.copy.get_stats(s.id)
# stats.totals -> ok / skipped / failed / replication_rate
page = client.copy.get_log(s.id, limit=50)
# page.entries[] -> action, follower_account_id, result, reason, ...; page.next_beforeCandles
Historical OHLC candles from a connected account, across all nine timeframes. Bound the series by a look-back window (hours) or an exact date range (from + to, ISO-8601). 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 — by look-back window (hours) or by exact date range (from + to, ISO-8601). Returns the bars, oldest first.
# look-back window
bars = client.candles.get(
account_id, symbol="BTCUSD", hours=8760, timeframe="D1",
)
# exact date range — pass BOTH from_ and to (ISO-8601)
ranged = client.candles.get(
account_id, symbol="BTCUSD",
from_="2026-01-01T00:00:00Z", to="2026-03-01T00:00:00Z", timeframe="H1",
)
# each: timestamp, open, high, low, close, bid, tick_volume, spread
# tick_volume/spread on recent bars; deep-history bars are bid-onlyTrade 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="BTCUSD", 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, ["BTCUSD", "ETHUSD"])
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("BTCUSD") — 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, ["ETHUSD"])
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="BTCUSD", 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="BTCUSD", 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="BTCUSD", 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)