Market LabDocs

Candles

Normalized candle dictionaries available to Python V2.

latest = history.source("btc@candles@binancef:timeframe=60", 0)
KeyTypeMeaning
tintegerBucket start in Unix milliseconds.
onumberOpen price.
hnumberHigh price.
lnumberLow price.
cnumberClose price.
volumenumberTotal available volume.
tradesintegerTrade count.
close_timeinteger, optionalExclusive bucket end in Unix milliseconds.
vb, vsnumber, optionalBuy and sell volume.
tb, tsinteger, optionalBuy and sell trade counts.
def on_data(ctx, history):
    candles = history.source("btc@candles@binancef:timeframe=60")
    latest = history.source("btc@candles@binancef:timeframe=60", 0)
    if latest is None:
        return

    sma = ctx.study.sma(candles, {"field": "c", "window": 20})
    return {"metrics": {"close": latest["c"], "sma": sma["latest"]}}

Directional fields are present only when the provider supplies or derives them. See Candles Source.