Connecting Data
This section explains how the chart connects to market data through IBasicDataFeed.
Purpose
The datafeed is the bridge between your application and the market data the chart displays.
It is used to:
- load the initial symbol
- fetch historical bars
- stream live data
- search for symbols
- support depth, watchlists, alerts, and exchange calendars when available
Where It Is Used
The datafeed is involved when the chart:
- starts up
- changes symbol
- changes timeframe or resolution
- requests history
- receives live updates
- opens symbol search
- works with watchlists or alerts
- shows depth data
Overview
The IBasicDataFeed interface contains the methods the chart uses to load data and power optional market features.
| Function | Purpose |
|---|---|
onReady(callback) | Tells the chart what the datafeed supports. |
resolveSymbol(symbolName, onResolve, onError) | Resolves a symbol into chart-ready metadata. |
searchSymbols?(userInput, exchange, symbolType, onResult) | Searches for matching symbols. |
getBars(symbolInfo, resolution, from, to, onResult, onError) | Loads historical bars. |
subscribeBars?(symbolInfo, resolution, onRealtimeCallback, subscriberUID, onResetCacheNeededCallback?) | Streams realtime bars. |
unsubscribeBars?(subscriberUID) | Stops realtime bar streaming. |
subscribeDepth?(symbolInfo, onDataCallback, subscriberUID) | Streams market depth data. |
unsubscribeDepth?(subscriberUID) | Stops depth streaming. |
onTrade?(action_type, price, quantity, symbol_info) | Sends trade events. |
createWatchlist?(name, symbols, callback) | Creates a watchlist. |
deleteWatchlist?(id, callback?) | Deletes a watchlist. |
addSymbolToWatchlist?(watchlistId, symbol, callback?) | Adds a symbol to a watchlist. |
deleteSymbolFromWatchlist?(watchlistId, symbolId, callback?) | Removes a symbol from a watchlist. |
getWatchlists?(callback) | Returns available watchlists. |
getSymbolDetails?(symbols, callback) | Returns detailed symbol information. |
subscribeSymbolDetails?(symbols, callback, subscriberUID) | Streams symbol detail updates. |
unsubscribeSymbolDetails?(subscriberUID) | Stops symbol detail streaming. |
createAlert?(alert, callback) | Creates an alert. |
getAlerts?(callback) | Returns alerts. |
updateAlert?(alertId, alert, callback?) | Updates an alert. |
deleteAlert?(alertId, callback?) | Deletes an alert. |
loadExchangeCalendars?() | Loads exchange holiday and session data. |
Capability Fields Returned By onReady
| Field | Purpose |
|---|---|
supported_resolutions | Lists the chart timeframes the feed supports. |
supports_search | Says whether symbol search is available. |
supports_group_request | Says whether grouped symbol requests are available. |
supports_marks | Says whether bar marks are available. |
supports_timescale_marks | Says whether timescale marks are available. |
supports_time | Says whether the feed can return server time. |
exchanges | Lists the exchanges shown in search. |
symbols_types | Lists the symbol categories shown in search. |
Chart Data Feed
These are the core methods the chart depends on for normal chart loading and updates.
| Method | Purpose |
|---|---|
onReady(callback) | Reports supported resolutions and capabilities. |
resolveSymbol(symbolName, onResolve, onError) | Resolves the currently selected symbol. |
searchSymbols?(userInput, exchange, symbolType, onResult) | Powers symbol search inside the chart UI. |
getBars(symbolInfo, resolution, from, to, onResult, onError) | Loads historical bars for the chart. |
subscribeBars?(symbolInfo, resolution, onRealtimeCallback, subscriberUID, onResetCacheNeededCallback?) | Streams live bar updates while the market is open or data is flowing. |
unsubscribeBars?(subscriberUID) | Stops the live bar stream when it is no longer needed. |
Depth Feed
Depth support is optional and is used when you want to show order book or market depth data.
| Method | Purpose |
|---|---|
subscribeDepth?(symbolInfo, onDataCallback, subscriberUID) | Starts depth updates for the active symbol. |
unsubscribeDepth?(subscriberUID) | Stops depth updates. |
Trade
onTrade is an optional callback for trade events.
| Method | Purpose |
|---|---|
onTrade?(action_type, price, quantity, symbol_info) | Notifies the chart when a trade happens for the subscribed symbol. |
Watchlist
Watchlist methods are optional and used when you want the chart to create or manage symbol lists through your own backend.
| Method | Purpose |
|---|---|
createWatchlist?(name, symbols, callback) | Creates a new watchlist. |
deleteWatchlist?(id, callback?) | Deletes a watchlist. |
addSymbolToWatchlist?(watchlistId, symbol, callback?) | Adds a symbol to a watchlist. |
deleteSymbolFromWatchlist?(watchlistId, symbolId, callback?) | Removes a symbol from a watchlist. |
getWatchlists?(callback) | Returns all watchlists. |
Alerts
Alert methods let the chart create and manage alerts through your data layer.
| Method | Purpose |
|---|---|
createAlert?(alert, callback) | Creates a new alert. |
getAlerts?(callback) | Returns the list of alerts. |
updateAlert?(alertId, alert, callback?) | Updates an existing alert. |
deleteAlert?(alertId, callback?) | Deletes an alert. |
Other Optional Data Methods
The interface also supports extra market metadata when you need it.
| Method | Purpose |
|---|---|
getSymbolDetails?(symbols, callback) | Returns detailed information for one or more symbols. |
subscribeSymbolDetails?(symbols, callback, subscriberUID) | Streams symbol detail updates. |
unsubscribeSymbolDetails?(subscriberUID) | Stops symbol detail updates. |
loadExchangeCalendars?() | Returns exchange holiday and session metadata. |
Typical Flow
- The chart calls
onReady. - The feed reports supported resolutions and optional capabilities.
- The chart resolves the initial symbol with
resolveSymbol. - The chart loads history with
getBars. - If realtime is available, the chart subscribes to live updates.
- Optional features such as watchlists, alerts, and depth are used when implemented.
Minimum Setup
At a minimum, the datafeed should be able to:
- tell the chart what it supports with
onReady - resolve symbols with
resolveSymbol - provide historical bars with
getBars
If you also want realtime updates, symbol search, watchlists, alerts, or depth data, implement the optional methods for those features.