Skip to content

collect_market_updates


function backtide.live.collect_market_updates(provider, symbols, interval="1m", max_events=1, timeout_seconds=30.0, include_partial=True)

Collect a finite batch from an exchange WebSocket.

A timeout returns the updates collected so far.

Warning

Yahoo Finance is intentionally rejected because it does not provide an official live market-data WebSocket. Choose Binance, Coinbase, or Kraken.

Parameters

provider : str | Provider

Public WebSocket source. Use "binance", "coinbase", or "kraken". "yahoo" is accepted by historical-data APIs but rejected here.

symbols : list[str]
One or more canonical market symbols to subscribe to, such as "BTC-USDT" for Binance or "BTC-USD" for Coinbase and Kraken.

interval : str | Interval, default="1m"
Duration represented by each candle. Accepted strings are "1m", "5m", "15m", "30m", "1h", "4h", "1d", and "1w" where supported by the provider. Coinbase live collection supports "5m" only.

max_events : int, default=1
Maximum number of updates to return across all subscribed symbols.

timeout_seconds : float, default=30
Maximum number of seconds to wait for the batch. When it expires, the function returns any updates already received, including an empty list.

include_partial : bool, default=True
Whether to include in-progress candle revisions. Set to False to receive only candles the provider has marked as final.

Returns

list[MarketUpdate]

Updates received before the event limit or timeout.


See Also

LiveMarketFeed

Reusable, cancellable exchange market-data collector.

Session

A stateful simulated account with optional strategy evaluation.


Example

>>> from backtide.live import collect_market_updates

>>> updates = collect_market_updates(  
...     "binance",
...     ["BTC-USDT"],
...     interval="1m",
...     max_events=10,
...     timeout_seconds=5,
... )