MarketDataClient is the read-only client for the T+ market-data-service. It requires no user authentication — you only need the base URL of a running market-data instance. Use it to fetch order book snapshots, candlestick (kline) data, 24-hour tickers, and the public trade history, or to subscribe to live WebSocket streams for any of those feeds.
Initialization
BecauseMarketDataClient is unauthenticated, you only need to supply the service URL. The default base URL is http://localhost:8011.
MarketDataClient does not require a User object or any signing — all endpoints are publicly accessible. If you need to place orders or query user-specific data, use OrderBookClient instead.REST Methods
Get Order Book Snapshot
Fetch the current state of the order book for an asset. Returns the sequence number, the list of ask price levels, and the list of bid price levels.Get Klines (Candlestick Data)
Retrieve candlestick data for charting and analysis.Get 24-Hour Ticker
Fetch a 24-hour rolling price and volume summary for an asset.Get Public Trades
Retrieve the public trade history — all finalized trades visible on the exchange, not filtered by user.WebSocket Streaming
MarketDataClient exposes three real-time streams as async generators. Use async for to consume each stream. For guidance on running multiple streams concurrently, see the WebSocket Streaming page.
Stream Finalized Trades
Subscribe to all finalized (matched and settled) trades in real time.Stream Order Book Depth Diffs
Subscribe to incremental updates to the order book. Each message is anOrderBookDiff containing the sequence number and the changed price levels on the ask and bid sides. Apply diffs sequentially to a local snapshot to maintain a live view of the book.
Stream Klines
Subscribe to live candlestick updates as trades are matched.Complete Streaming Example
The following example runs all threeMarketDataClient streams concurrently using asyncio.gather:
Each coroutine passed to
asyncio.gather runs indefinitely. Press Ctrl-C to interrupt the program in interactive use. In production, wrap your gather in a try/except to handle asyncio.CancelledError cleanly.