CandleSource
The SDK’s charting boundary. Every chart library needs the same three things — symbol metadata, bars for a time range, and a live subscription — so that is exactly what a source provides. Chart-library adapters (toTradingViewDatafeed) and framework hooks (useCandles) are written against this interface, never against a specific venue.
interface CandleSource {
readonly id: string; // stable identifier, scopes query keys (e.g. "binance:usd-m-futures")
readonly priceBasis: CandlePriceBasis;
readonly supportedResolutions: readonly CandleResolution[];
readonly maxCandlesPerRequest: number;
getSymbol(marketName: string): Promise<CandleSymbol | undefined>;
getCandles(parameters: GetCandlesParameters): Promise<GetCandlesReturnType>;
watchCandles?(parameters: WatchCandlesParameters): Unwatch;
}Unlike most SDK actions, a source is not derived from Config: a reference exchange is not a SYMMIO chain
deployment, and which venue to chart is the consumer’s choice. Construct one and pass it in explicitly.
getSymbolresolves toundefinedwhen the source does not carry the market — the check to run before rendering.getCandlespages internally pastmaxCandlesPerRequest; the field is exposed so a caller can size its own requests sensibly.watchCandlesis absent when the source has no realtime feed, in which case a consumer must pollgetCandles.
GetCandlesParameters
marketNamestringMarket name as SYMMIO names it.
resolutionCandleResolutionBar size to fetch. Must be listed in supportedResolutions.
fromnumberRange start, unix ms, inclusive.
tonumberRange end, unix ms, exclusive.
limitnumberoptionalMaximum bars to return. A source pages internally to satisfy this.
signalAbortSignaloptionalAborts in-flight requests. Wired to TanStack Query cancellation by the hooks.
GetCandlesReturnType
candlesCandle[]Bars in ascending time order, de-duplicated and clipped to the requested range.
noMoreDatabooleantrue when the source has nothing at or before from — typically because the request predates the instrument’s
listing. A chart paging backwards should stop when it sees this.
WatchCandlesParameters
marketNamestringMarket name as SYMMIO names it.
resolutionCandleResolutionBar size to stream.
onCandle(candle: Candle, meta: CandleUpdateMeta) => voidCalled on every update to the in-progress bar, and once more with closed: true when that bar finalizes.
onReset() => voidoptionalCalled after a reconnect, when bars may have been missed while the socket was down. Drop cached bars and refetch history rather than splicing a live bar onto a stale series.
onStatusChange(status: SocketStatus) => voidoptionalCalled whenever the underlying connection status changes.
onError(error: SymmError) => voidoptionalCalled on a transport or parse error; does not stop the subscription.
CandleUpdateMeta is { closed: boolean } — true when the bar has finalized and the next update starts a new one.
Implementing your own source
Anything that can answer the three questions plugs in: a solver mark-price stream folded into bars (priceBasis: "solver-mark"), a DEX pool OHLCV API ("dex-pool"), another exchange. Declare honest supportedResolutions, keep time in unix milliseconds aligned to the resolution boundary, report volume: 0 when the venue cannot supply it, and give the source a stable id — it scopes the query cache.
Related
createBinanceCandleSource— the reference implementation.Candle— the bar and symbol shapes.getCandlesQueryOptions— TanStack Query overgetCandles.