Are you an LLM? Read llms.txt for a summary of the docs, or llms-full.txt for the full context.
Skip to content

subscribe_perps_candles

Stream OHLCV candles for one pair at one interval.

Signature

def subscribe_perps_candles(
    self,
    pair_id: PairId,
    interval: CandleInterval,
    callback: Callable[[PerpsCandle], None],
) -> int

Example

import time
 
from dango.info import Info
from dango.utils.constants import MAINNET_API_URL
from dango.utils.types import CandleInterval, PairId
 
info = Info(MAINNET_API_URL)
 
sid = info.subscribe_perps_candles(
    PairId("perp/ethusd"),
    CandleInterval.ONE_MINUTE,
    print,
)
time.sleep(60)
info.unsubscribe(sid)
info.disconnect_websocket()

Parameters

pair_idPairId.

intervalCandleInterval.

callbackCallable[[PerpsCandle], None]. Invoked once per candle. The server may emit multiple candles on reconnect; the SDK fan-out delivers them one at a time.

Returns

int — the subscription id.

See also