IDatafeedChartApi
Methods
getBars
This function is called when the chart needs a history fragment defined by dates range.
Signature
getBars(symbolInfo: LibrarySymbolInfo, resolution: ResolutionString, periodParams: PeriodParams, onResult: HistoryCallback, onError: DatafeedErrorCallback) => void
Parameters
Name | Type | Description |
---|---|---|
symbolInfo | LibrarySymbolInfo | A SymbolInfo object |
resolution | ResolutionString | Resolution of the symbol |
periodParams | PeriodParams | An object used to pass specific requirements for getting bars |
onResult | HistoryCallback | Callback function for historical data |
onError | DatafeedErrorCallback | Callback function whose only argument is a text error message |
Returns
void
getMarks
OptionalThe library calls this function to get marks for visible bars range.
The library assumes that you will call onDataCallback
only once per getMarks
call.
A few marks per bar are allowed (for now, the maximum is 10). The time of each mark must match the time of a bar. For example, if the bar times are 2023-01-01
, 2023-01-08
, and 2023-01-15
, then a mark cannot have the time 2023-01-05
.
Remark: This function will be called only if you confirmed that your back-end is supporting marks (DatafeedConfiguration.supports_marks).
Signature
getMarks(symbolInfo: LibrarySymbolInfo, from: number, to: number, onDataCallback: GetMarksCallback<Mark>, resolution: ResolutionString) => void
Parameters
Name | Type | Description |
---|---|---|
symbolInfo | LibrarySymbolInfo | A SymbolInfo object |
from | number | Unix timestamp (leftmost visible bar) |
to | number | Unix timestamp (rightmost visible bar) |
onDataCallback | GetMarksCallback<Mark> | Callback function containing an array of marks |
resolution | ResolutionString | Resolution of the symbol |
Returns
void
getServerTime
OptionalThis function is called if the supports_time
configuration flag is true
when the chart needs to know the server time.
The library expects a callback to be called once.
The time is provided without milliseconds. Example: 1445324591
.
getServerTime
is used to display countdown on the price scale.
Note that the countdown can be displayed only for intraday resolutions.
Signature
getServerTime(callback: ServerTimeCallback) => void
Parameters
Name | Type |
---|---|
callback | ServerTimeCallback |
Returns
void
getTimescaleMarks
OptionalThe library calls this function to get timescale marks for visible bars range.
The library assumes that you will call onDataCallback
only once per getTimescaleMarks
call.
Remark: This function will be called only if you confirmed that your back-end is supporting marks (DatafeedConfiguration.supports_timescale_marks).
Signature
getTimescaleMarks(symbolInfo: LibrarySymbolInfo, from: number, to: number, onDataCallback: GetMarksCallback<TimescaleMark>, resolution: ResolutionString) => void
Parameters
Name | Type | Description |
---|---|---|
symbolInfo | LibrarySymbolInfo | A SymbolInfo object |
from | number | Unix timestamp (leftmost visible bar) |
to | number | Unix timestamp (rightmost visible bar) |
onDataCallback | GetMarksCallback<TimescaleMark> | Callback function containing an array of marks |
resolution | ResolutionString | Resolution of the symbol |
Returns
void
getVolumeProfileResolutionForPeriod
OptionalThe library calls this function to get the resolution that will be used to calculate the Volume Profile Visible Range indicator.
Usually you might want to implement this method to calculate the indicator more accurately. The implementation really depends on how much data you can transfer to the library and the depth of data in your data feed. Remark: If this function is not provided the library uses currentResolution.
Signature
getVolumeProfileResolutionForPeriod(currentResolution: ResolutionString, from: number, to: number, symbolInfo: LibrarySymbolInfo) => ResolutionString
Parameters
Name | Type | Description |
---|---|---|
currentResolution | ResolutionString | Resolution of the symbol |
from | number | Unix timestamp (leftmost visible bar) |
to | number | Unix timestamp (rightmost visible bar) |
symbolInfo | LibrarySymbolInfo | A Symbol object |
Returns
A resolution
resolveSymbol
The library will call this function when it needs to get SymbolInfo by symbol name.
Signature
resolveSymbol(symbolName: string, onResolve: ResolveCallback, onError: DatafeedErrorCallback, extension?: SymbolResolveExtension) => void
Parameters
Name | Type | Description |
---|---|---|
symbolName | string | Symbol name or ticker |
onResolve | ResolveCallback | Callback function returning a SymbolInfo (LibrarySymbolInfo) |
onError | DatafeedErrorCallback | Callback function whose only argument is a text error message |
extension? | SymbolResolveExtension | An optional object with additional parameters |
Returns
void
searchSymbols
Provides a list of symbols that match the user's search query.
Signature
searchSymbols(userInput: string, exchange: string, symbolType: string, onResult: SearchSymbolsCallback) => void
Parameters
Name | Type | Description |
---|---|---|
userInput | string | Text entered by user in the symbol search field |
exchange | string | The requested exchange. Empty value means no filter was specified |
symbolType | string | Type of symbol. Empty value means no filter was specified |
onResult | SearchSymbolsCallback | Callback function that returns an array of results (SearchSymbolResultItem) or empty array if no symbols found |
Returns
void
subscribeBars
The library calls this function when it wants to receive real-time updates for a symbol.
The library assumes that you will call the callback provided by the onTick
parameter every time you want to update the most recent bar or to add a new one.
Signature
subscribeBars(symbolInfo: LibrarySymbolInfo, resolution: ResolutionString, onTick: SubscribeBarsCallback, listenerGuid: string, onResetCacheNeededCallback: Function) => void
Parameters
Name | Type | Description |
---|---|---|
symbolInfo | LibrarySymbolInfo | A SymbolInfo object |
resolution | ResolutionString | Resolution of the symbol |
onTick | SubscribeBarsCallback | Callback function returning a Bar object |
listenerGuid | string | |
onResetCacheNeededCallback | () => void | Function to be executed when bar data has changed |
Returns
void
subscribeDepth
OptionalThe library calls this function when it wants to receive real-time symbol data in the Depth of Market (DOM) widget.
Note that you should set the BrokerConfigFlags.supportLevel2Data configuration flag to true
.
Signature
subscribeDepth(symbol: string, callback: DOMCallback) => string
Parameters
Name | Type | Description |
---|---|---|
symbol | string | A SymbolInfo object |
callback | DOMCallback | A function returning an object to update DOM data |
Returns
A unique identifier that will be used to unsubscribe from the data
string
unsubscribeBars
The library calls this function when it doesn't want to receive updates anymore.
Signature
unsubscribeBars(listenerGuid: string) => void
Parameters
Name | Type | Description |
---|---|---|
listenerGuid | string | id to unsubscribe from |
Returns
void
unsubscribeDepth
OptionalThe library calls this function to stop receiving real-time updates for the Depth of Market listener.
Note that you should set the BrokerConfigFlags.supportLevel2Data configuration flag to true
.
Signature
unsubscribeDepth(subscriberUID: string) => void
Parameters
Name | Type | Description |
---|---|---|
subscriberUID | string | A string returned by subscribeDepth |
Returns
void