Candles
Configure live and historical candle sources for Python V2.
The candles source provides normalized OHLCV records. timeframe is an integer number of seconds.
history.source("btc@candles@binancef:timeframe=60")
history.source("btc@candles@binancef@mmt:timeframe=60")
history.source("btc@candles@bulkf:timeframe=5")
history.source("btc@candles@hyperliquidf:timeframe=5")Live Candles
MMT, BULK, and Hyperliquid live candles are built locally from raw trades. Any positive whole-second timeframe is valid.
Only completed, epoch-aligned candles reach the script. If the job begins inside a bucket, Market Lab discards that partial bucket. Periods without trades do not produce invented candles.
SOURCE = "btc@candles@hyperliquidf:timeframe=5"
def on_data(ctx, history):
candle = history.source(SOURCE, 0)
if candle is None:
returnBacktest Candles
Backtests read stored provider candles. They use provider-supported intervals and cannot request arbitrary seconds.
- MMT starts at 60 seconds.
- BULK starts at 10 seconds.
- Hyperliquid starts at 60 seconds.
- Standalone Binance supports its historical exchange intervals.
A historical candle enters the simulation at its closing boundary, after its OHLC values would have been known.
Standalone Binance candles are backtest-only. Use MMT, BULK, or Hyperliquid for live candle streams.
mlab script backtest strategy.py \
--from 2026-05-31 \
--to 2026-06-03See Candle Data.