Exchange Coverage

Each exchange implements a standardized exchangeProtocol_s struct. Adding a new exchange means implementing one header โ€” the rest of the framework doesn't change.

Exchange Market Data Trading Account Fee Note
Binance Trades, BBO, Book Market, Limit โœ… Standard maker/taker
Bybit Trades, BBO, Book Market, Limit โœ… Standard maker/taker
OKX Trades, BBO, Book Market, Limit โœ… Standard maker/taker
Bitfinex Trades, BBO, Book Market, Limit โœ… Standard maker/taker
Poloniex Trades, BBO, Book Market, Limit โœ… Standard maker/taker
Kraken Trades, BBO, Book Market, Limit โœ… Standard maker/taker
Bitstamp Trades, BBO, Book Market, Limit โœ… Standard maker/taker
Bitget Trades, BBO, Book Market, Limit โœ… Standard maker/taker
Hyperliquid Trades, BBO, Book Market, Limit โœ… Standard maker/taker
Paradex Trades, BBO, Book Market, Limit โœ… Standard maker/taker
Aster Trades, BBO, Book Market, Limit โœ… Standard maker/taker
Lighter Trades, BBO, Book Market, Limit โœ… Standard maker/taker
Phemex Trades, BBO, Book Market, Limit โœ… Standard maker/taker
Interactive Brokers Trades, BBO, Book Market, Limit โœ… Standard maker/taker

1. Market Data Pipeline

Each exchange publishes market data via WebSocket streams. ttTrader normalizes every exchange's format into a unified structure before your algo ever sees it.

๐Ÿ”„

Trade Stream

Normalized fields: decPrice, decSize, decSizeCvd (cumulative volume delta), fTakerIsSell, dtTimestamp. Circular buffer stores the last 16,384 trades per instrument. CVD is computed automatically from taker direction โ€” no exchange-specific logic needed.

๐Ÿ“–

BBO Stream

Best bid/ask with integrated spread tracking. 16,384-entry circular buffer per instrument. Access the latest via marketdataInfo.bbo.back(). The getMid() and spread history methods are built in โ€” compute VWAP, micro-price, or spread percentiles on the fly.

๐Ÿ“š

Order Book Stream

Up to 20 levels per side with singlePriceSize_s (price + aggregated size). The book snapshot carries ui64UpdateId and ui64Sequence for ordering guarantees. Book pressure and imbalance calculations are first-class.

๐Ÿ“ก Exchange Protocol Interface
Each exchange implements exchangeProtocol_s โ€” a struct with static methods for identity, capabilities, and message building. The protocol declares what data formats it uses (ce_fUsesBinaryData), whether book updates include BBO (ce_fBookUpdatesBbo), and provides factory methods for subscription messages, order creation, and order cancellation. This design makes adding a new exchange a matter of implementing one well-defined interface.

2. Account & Trading

Beyond market data, ttTrader manages the full account and trading lifecycle for each exchange.

๐Ÿฆ

Account Management

The exchgManagerAccountT template manages per-exchange account state. It handles WebSocket authentication, balance subscriptions, and asset tracking. Each exchange protocol implements buildAccountSubscribe() / buildAccountUnsubscribe() and a graceful canExitAccount() check.

Asset balances flow through the event system as assetBalanceInfo_s structs. Your algo receives updates via onAssetUpdate() โ€” monitor equity, available margin, and unrealized P&L across all connected exchanges.

๐Ÿ’ฑ

Trading Operations

The exchgManagerTradingT template orchestrates order lifecycle per exchange. It translates framework order objects into exchange-specific wire formats via buildOrderCreate() and buildOrderCancel().

Orders flow through a state machine tracked in orderStateInfo_s: EOPS_ALGO_CREATE โ†’ EOPS_MANAGER_CREATE โ†’ EOPS_EXCHG_CREATE. Location tracking confirms exchange acknowledgment. Error states provide detailed failure reasons (invalid trigger, margin issues, max slippage exceeded).

๐Ÿ”—

WebSocket-Based Trading

Trading operations (order create, cancel, modify) are sent via the same WebSocket connection used for market data โ€” no separate REST round-trips. The protocol builds binary or JSON wire messages via netBuffer_s, sent through the network subsystem with automatic reconnection and rate-limit awareness.

๐Ÿ”„

Order Modification

Active orders can be modified: change the limit price, adjust the stop trigger, or update the size. The framework tracks each modification through the processing state machine and validates that modifications are only applied to orders in modifiable states.

3. API Keys & Security

๐Ÿ” Protected Credential Storage
Exchange API keys are never stored in the main configuration file. The exchange subsystem manages credentials in a separate, protected store. The main config references exchange profiles by identifier โ€” the actual keys, secrets, and passphrases are loaded securely at runtime and never exposed in logs, config dumps, or WebSocket messages.
๐Ÿ”‘

Per-Exchange Credentials

Each exchange connection gets its own set of API credentials. You can run the same exchange with multiple accounts simultaneously โ€” each with independent key pairs, rate limits, and connection state.

๐Ÿ“Š

Rate Limit Tracking

The exchange subsystem tracks rate limits per connection. Before sending an order, the framework verifies that the rate limit budget is available โ€” preventing 429 errors and potential account restrictions.

๐Ÿ”„

Auto-Reconnection

If a WebSocket connection drops, the exchange manager automatically reconnects with configurable backoff. Market data subscriptions and account authentication are re-established transparently โ€” your algo doesn't need to handle reconnection logic.

Instrument Support

ttTrader supports the full spectrum of crypto derivative instruments. Each instrument type carries type-specific metadata and constraints.

๐Ÿ“ˆ

Perpetual Futures

EIT_FUTURE_PERPETUAL โ€” the most liquid crypto derivative. Funding rate tracking, leverage up to exchange maximum (typically 50โ€“125ร—). Both linear (USDT-margined) and inverse (coin-margined) variants.

๐Ÿ“…

Dated Futures

EIT_FUTURE โ€” quarterly and monthly expiries. EIT_FUTURE_VANILLA and EIT_FUTURE_CROSS for exotic expiry types. Settlement date tracking built into instrument metadata.

๐Ÿ’ก

Spot

EIT_SPOT โ€” standard spot trading pairs. No leverage, no funding rates. Available on all exchanges. Used for basis trading and spot-futures arbitrage strategies.

๐ŸŽฏ

Options

EIT_OPTION_VANILLA โ€” call and put options. Strike price, expiry timestamp, and option right (EIOR_CALL / EIOR_PUT) embedded in instrument metadata. Greeks can be computed from book data.

๐Ÿ“

Min/Max/Step Constraints

Every instrument exposes instrumentMinMaxStepInfo_s for price (mmsPrice), size (mmsSize), and leverage (mmsLeverage). The makePrice(), makeSize(), and isValid() methods ensure every order is exchange-compliant.

๐Ÿ’ต

Fee Transparency

runtimeInfo.decFeeMaker and decFeeTaker are populated from exchange data. decContractSize for calculating notional value. isDerivate() helper to distinguish spot from derivatives at runtime.

Monitoring Frontend

ttTrader includes a built-in WebSocket server that streams real-time trading data to any connected frontend โ€” browser dashboard, mobile app, or external monitoring system.

๐Ÿ”Œ Built-in WebSocket Server โ€” ws://0.0.0.0:18181
The managerWebSocket_c module runs an internal WebSocket server. On connection, it sends a full state snapshot (exchanges, instruments, orders, positions, assets, algos, trades, BBO). Thereafter, it pushes incremental updates on a configurable timer interval โ€” trades, BBO changes, order state transitions, fills, exchange status, asset balance changes, and playback/recording progress.
๐Ÿ“ก

Real-Time Data Streams

Message Section Content
"snap" Full state snapshot (on connect)
"exchg" Exchange status updates
"instr" Instrument metadata & state
"order" Order lifecycle events (JSON)
"fills" Execution/fill notifications
"pb" Playback state & recording progress
๐ŸŽฎ

Frontend Control Commands

The WebSocket protocol is bidirectional. A dashboard can send JSON commands:

Command Action
{"t":"pb","action":"load","id":...} Load a playback file
{"t":"pb","action":"play"} Start/resume playback
{"t":"pb","action":"pause"} Pause playback
{"t":"pb","action":"seek","position":...} Jump to position
{"t":"pb","action":"setSpeed","speed":...} Adjust replay speed
{"t":"rec","action":"start"} Start market data recording
{"t":"rec","action":"stop"} Stop recording

Dashboard Possibilities

The WebSocket API enables a rich monitoring dashboard with zero additional server infrastructure:

๐Ÿ“Š
Live P&L Charts
Real-time equity curves from asset balance and fill streams
๐Ÿ“‹
Order Blotter
Active orders, fills, and position summaries with live updates
๐Ÿ“ˆ
Market Data Viewer
Real-time BBO, trades, and CVD streaming to charts
โ–ถ๏ธ
Playback Controls
Load, play, pause, seek, and speed-control replay sessions
๐Ÿ”ด
Recording Manager
Start/stop market data recording with file progress tracking
๐ŸŒ
Exchange Status
Connection health and rate-limit status across all exchanges
// Connect from any WebSocket client const ws = new WebSocket("ws://localhost:18181"); // On connect โ€” full snapshot delivered ws.onmessage = (msg) => { const data = JSON.parse(msg.data); // data.snap.orders โ†’ active orders // data.snap.positions โ†’ open positions // data.snap.acct โ†’ account balances // data.snap.quotes โ†’ latest BBOs }; // Send playback commands ws.send(JSON.stringify({ t: "pb", action: "play" }));