1222 lines
63 KiB
TypeScript
1222 lines
63 KiB
TypeScript
/**
|
||
* Datafeed JS API for TradingView Advanced Charts
|
||
* @packageDocumentation
|
||
* @module Datafeed
|
||
*/
|
||
// Generated by dts-bundle-generator v9.5.1
|
||
|
||
declare const enum SearchInitiationPoint {
|
||
SymbolSearch = "symbolSearch",
|
||
Watchlist = "watchlist",
|
||
Compare = "compare",
|
||
IndicatorInputs = "indicatorInputs",
|
||
}
|
||
/**
|
||
* This is the generic type useful for declaring a nominal type,
|
||
* which does not structurally matches with the base type and
|
||
* the other types declared over the same base type
|
||
*
|
||
* Usage:
|
||
* @example
|
||
* type Index = Nominal<number, 'Index'>;
|
||
* // let i: Index = 42; // this fails to compile
|
||
* let i: Index = 42 as Index; // OK
|
||
* @example
|
||
* type TagName = Nominal<string, 'TagName'>;
|
||
*/
|
||
declare type Nominal<T, Name extends string> = T & {
|
||
[Symbol.species]: Name;
|
||
};
|
||
/**
|
||
* Bar data point
|
||
*/
|
||
interface Bar {
|
||
/**
|
||
* Bar time.
|
||
* Amount of **milliseconds** since Unix epoch start in **UTC** timezone.
|
||
* `time` for daily, weekly, and monthly bars is expected to be a trading day (not session start day) at 00:00 UTC.
|
||
* The library adjusts time according to `session` from {@link LibrarySymbolInfo}.
|
||
*/
|
||
time: number;
|
||
/** Opening price */
|
||
open: number;
|
||
/** High price */
|
||
high: number;
|
||
/** Low price */
|
||
low: number;
|
||
/** Closing price */
|
||
close: number;
|
||
/** Trading Volume */
|
||
volume?: number;
|
||
}
|
||
interface CurrencyItem {
|
||
/** Unique ID */
|
||
id: string;
|
||
/** Currency code. @example `USD` */
|
||
code: string;
|
||
/** URL to an image of the currency. SVG logos are preferable, but please make sure that the provided image fits nicely in the currency select control (for raster images the expected size is 24x24px). */
|
||
logoUrl?: string;
|
||
/** Description for the currency */
|
||
description?: string;
|
||
}
|
||
/**
|
||
* Depth of Market (Order Book) Data
|
||
*/
|
||
interface DOMData {
|
||
/**
|
||
* Whether the Depth of Market data is a snapshot (has the full set of depth data).
|
||
* - If `true` then the data contains the full set of depth data.
|
||
* - If `false` then data only contains updated levels.
|
||
*/
|
||
snapshot: boolean;
|
||
/** Ask order levels (must be sorted by `price` in ascending order) */
|
||
asks: DOMLevel[];
|
||
/** Bid order levels (must be sorted by `price` in ascending order) */
|
||
bids: DOMLevel[];
|
||
}
|
||
/**
|
||
* Depth of Market Level
|
||
*/
|
||
interface DOMLevel {
|
||
/** Price for DOM level */
|
||
price: number;
|
||
/** Volume for DOM level */
|
||
volume: number;
|
||
}
|
||
/**
|
||
* Datafeed configuration data.
|
||
* Pass the resulting array of properties as a parameter to {@link OnReadyCallback} of the [`onReady`](https://www.tradingview.com/charting-library-docs/latest/connecting_data/datafeed-api/required-methods#onready) method.
|
||
*/
|
||
interface DatafeedConfiguration {
|
||
/**
|
||
* List of exchange descriptors.
|
||
* An empty array leads to an absence of the exchanges filter in the Symbol Search list.
|
||
* Use `value=''` if you wish to include all exchanges.
|
||
*/
|
||
exchanges?: Exchange[];
|
||
/**
|
||
* List of [resolutions](https://www.tradingview.com/charting-library-docs/latest/core_concepts/Resolution) that the chart should support.
|
||
* Each item of the array is expected to be a string that has a specific [format](https://www.tradingview.com/charting-library-docs/latest/core_concepts/Resolution#resolution-format).
|
||
* If you set this property to `undefined` or an empty array, the _Resolution_ drop-down menu displays the list of resolutions available for
|
||
* the current symbol ({@link LibrarySymbolInfo.supported_resolutions}).
|
||
*
|
||
* @example
|
||
* `["1", "15", "240", "D", "6M"]` will give you "1 minute, 15 minutes, 4 hours, 1 day, 6 months" in the _Resolution_ drop-down menu.
|
||
*/
|
||
supported_resolutions?: ResolutionString[];
|
||
/**
|
||
* Supported unit groups. Each group can have several unit objects.
|
||
*
|
||
* @example
|
||
* ```javascript
|
||
* {
|
||
* weight: [
|
||
* { id: 'kg', name: 'kg', description: 'Kilograms' },
|
||
* { id: 'lb', name: 'lb', description: 'Pounds'},
|
||
* ]
|
||
* }
|
||
* ```
|
||
*/
|
||
units?: Record<string, Unit[]>;
|
||
/**
|
||
* Supported currencies for currency conversion.
|
||
*
|
||
* When a currency code is supplied as a string then the library will automatically convert it to `{ id: value, code: value }` object.
|
||
*
|
||
* @example `["USD", "EUR", "GBP"]`
|
||
* @example `[{ id: "USD", code: "USD", description: "$" }, { id: "EUR", code: "EUR", description: "€" }]`
|
||
*/
|
||
currency_codes?: (string | CurrencyItem)[];
|
||
/** Does the datafeed supports marks on bars (`true`), or not (`false | undefined`). */
|
||
supports_marks?: boolean;
|
||
/** Set this one to `true` if your datafeed provides server time (unix time). It is used to adjust Countdown on the Price scale. */
|
||
supports_time?: boolean;
|
||
/** Does the datafeed supports marks on the timescale (`true`), or not (`false | undefined`). */
|
||
supports_timescale_marks?: boolean;
|
||
/**
|
||
* List of filter descriptors.
|
||
*
|
||
* Setting this property to `undefined` or an empty array leads to the absence of filter types in Symbol Search list. Use `value = ''` if you wish to include all filter types.
|
||
* `value` within the descriptor will be passed as `symbolType` argument to {@link IDatafeedChartApi.searchSymbols}
|
||
*/
|
||
symbols_types?: DatafeedSymbolType[];
|
||
/**
|
||
* Set it if you want to group symbols in the [Symbol Search](https://www.tradingview.com/charting-library-docs/latest/ui_elements/Symbol-Search).
|
||
* Represents an object where keys are symbol types {@link SymbolType} and values are regular expressions (each regular expression should divide an instrument name into 2 parts: a root and an expiration).
|
||
*
|
||
* Sample:
|
||
* ```
|
||
* {
|
||
* "futures": `/^(.+)([12]!|[FGHJKMNQUVXZ]\d{1,2})$/`,
|
||
* "stock": `/^(.+)([12]!|[FGHJKMNQUVXZ]\d{1,2})$/`,
|
||
* }
|
||
* ```
|
||
* It will be applied to the instruments with futures and stock as a type.
|
||
* Refer to [Symbol grouping](https://www.tradingview.com/charting-library-docs/latest/ui_elements/Symbol-Search#symbol-grouping) for more information.
|
||
*/
|
||
symbols_grouping?: Record<string, string>;
|
||
}
|
||
/**
|
||
* This object contains symbol quote values, where a [quote](https://www.tradingview.com/charting-library-docs/latest/trading_terminal/trading-concepts/quotes) represents a set of data describing the current price.
|
||
* The library uses quote data for various trading functionalities, including the [Order Ticket](https://www.tradingview.com/charting-library-docs/latest/trading_terminal/order-ticket), [Legend](https://www.tradingview.com/charting-library-docs/latest/ui_elements/Legend),
|
||
* and widgets, such as [Watchlist](https://www.tradingview.com/charting-library-docs/latest/trading_terminal/Watch-List), [Details](https://www.tradingview.com/charting-library-docs/latest/trading_terminal/#details),
|
||
* [News](https://www.tradingview.com/charting-library-docs/latest/trading_terminal/news), and [Depth of Market](https://www.tradingview.com/charting-library-docs/latest/trading_terminal/#depth-of-market).
|
||
*
|
||
* While all properties in this object are marked as optional, populating most of them is required for supporting trading functionalities.
|
||
* Providing values that do not match the expected data types can cause issues such as UI [loading delays](https://www.tradingview.com/charting-library-docs/latest/connecting_data/Datafeed-Issues#delays-in-trading-platform-ui-elements) or [missing data](https://www.tradingview.com/charting-library-docs/latest/connecting_data/Datafeed-Issues#quotes-are-not-displayed-or-refreshed).
|
||
* See property descriptions for more information.
|
||
*/
|
||
interface DatafeedQuoteValues {
|
||
/**
|
||
* Price change. It is usually calculated as a difference between the current price and close price of the previous day (regular session).
|
||
* In the UI, `ch` and {@link chp} are represented as the last day change parameter in *Data Window*.
|
||
* You can also display these values in the [legend](https://www.tradingview.com/charting-library-docs/latest/ui_elements/Legend#last-day-change-values).
|
||
* If `ch` and `chp` are not provided, `0.00 (0.00%)` is displayed instead.
|
||
*
|
||
* Note that `ch` and `chp` are **required** for mobile apps. Otherwise, [`NaN` values](https://www.tradingview.com/charting-library-docs/latest/ui_elements/Legend#nan-values-in-legend) will appear in the legend.
|
||
*/
|
||
ch?: number;
|
||
/**
|
||
* Price change percentage. In the UI, `chp` and {@link ch} are represented as the last day change parameter in *Data Window*.
|
||
* You can also display these values in the [Legend](https://www.tradingview.com/charting-library-docs/latest/ui_elements/Legend#last-day-change-values).
|
||
* If `ch` and `chp` are not provided, `0.00 (0.00%)` is displayed instead.
|
||
*
|
||
* Note that `ch` and `chp` are **required** for mobile apps. Otherwise, [`NaN` values](https://www.tradingview.com/charting-library-docs/latest/ui_elements/Legend#nan-values-in-legend) will appear in the Legend.
|
||
*/
|
||
chp?: number;
|
||
/** Short name for a symbol. Short name is used in the title for the [News](https://www.tradingview.com/charting-library-docs/latest/trading_terminal/news), [Watchlist](https://www.tradingview.com/charting-library-docs/latest/trading_terminal/Watch-List) and [Details](https://www.tradingview.com/charting-library-docs/latest/trading_terminal/#details) widgets. You can disable the [`prefer_quote_short_name`](https://www.tradingview.com/charting-library-docs/latest/customization/Featuresets#prefer_quote_short_name) to use the {@link LibrarySymbolInfo.ticker} value instead. */
|
||
short_name?: string;
|
||
/** The name of the exchange. The exchange name is displayed in the [Details](https://www.tradingview.com/charting-library-docs/latest/trading_terminal/#details) widget. */
|
||
exchange?: string;
|
||
/** A short description of the symbol. This description is displayed in the [Details](https://www.tradingview.com/charting-library-docs/latest/trading_terminal/#details) widget and the tooltip of the [Watchlist](https://www.tradingview.com/charting-library-docs/latest/trading_terminal/Watch-List) widget. */
|
||
description?: string;
|
||
/**
|
||
* The price at which the most recent trade of a security occurred, regardless of whether it was a buy or sell.
|
||
* Required for the [Order Ticket](https://www.tradingview.com/charting-library-docs/latest/trading_terminal/order-ticket), [Depth of Market](https://www.tradingview.com/charting-library-docs/latest/trading_terminal/#depth-of-market), [Buy/Sell buttons](https://www.tradingview.com/charting-library-docs/latest/trading_terminal/#buysell-buttons-and-lines), and [Details](https://www.tradingview.com/charting-library-docs/latest/trading_terminal/#details) and [Watchlist](https://www.tradingview.com/charting-library-docs/latest/trading_terminal/Watch-List) widgets.
|
||
*/
|
||
lp?: number;
|
||
/** Ask price – the lowest price a seller is willing to accept for a security. The value is displayed in the [Order Ticket](https://www.tradingview.com/charting-library-docs/latest/trading_terminal/order-ticket) and [Buy/Sell buttons](https://www.tradingview.com/charting-library-docs/latest/trading_terminal/#buysell-buttons-and-lines). */
|
||
ask?: number;
|
||
/** Bid price – the highest price a buyer is willing to pay for a security. The value is displayed in the [Order Ticket](https://www.tradingview.com/charting-library-docs/latest/trading_terminal/order-ticket) and [Buy/Sell buttons](https://www.tradingview.com/charting-library-docs/latest/trading_terminal/#buysell-buttons-and-lines). */
|
||
bid?: number;
|
||
/** Spread – the difference between the ask and bid prices. The value is displayed between [Buy/Sell buttons](https://www.tradingview.com/charting-library-docs/latest/trading_terminal/#buysell-buttons-and-lines). */
|
||
spread?: number;
|
||
/** Today's opening price */
|
||
open_price?: number;
|
||
/** Today's high price. The value is displayed in the [Details](https://www.tradingview.com/charting-library-docs/latest/trading_terminal/#details) widget. */
|
||
high_price?: number;
|
||
/** Today's low price. The value is displayed in the [Details](https://www.tradingview.com/charting-library-docs/latest/trading_terminal/#details) widget. */
|
||
low_price?: number;
|
||
/**
|
||
* Closing price of the symbol from the previous regular market session.
|
||
*
|
||
* Required for mobile apps. Otherwise, `NaN` values will appear in the [Legend](https://www.tradingview.com/charting-library-docs/latest/ui_elements/Legend).
|
||
*/
|
||
prev_close_price?: number;
|
||
/** Today's trading volume. This value is displayed in the [Watchlist](https://www.tradingview.com/charting-library-docs/latest/trading_terminal/Watch-List) widget. */
|
||
volume?: number;
|
||
/** Original name */
|
||
original_name?: string;
|
||
/** Pre-/post-market price. This value is required to display the [pre-/post-market price line](https://www.tradingview.com/charting-library-docs/latest/connecting_data/Extended-Sessions#enable-the-price-line) on the chart and information on the extended session in the [Details](https://www.tradingview.com/charting-library-docs/latest/trading_terminal/#details) widget. */
|
||
rtc?: number;
|
||
/** Pre-/post-market price update time. This value is required to display information on the [extended session](https://www.tradingview.com/charting-library-docs/latest/connecting_data/Extended-Sessions) in the [Details](https://www.tradingview.com/charting-library-docs/latest/trading_terminal/#details) widget. */
|
||
rtc_time?: number;
|
||
/** Pre-/post-market price change. This value is required to display information on the [extended session](https://www.tradingview.com/charting-library-docs/latest/connecting_data/Extended-Sessions) in the [Details](https://www.tradingview.com/charting-library-docs/latest/trading_terminal/#details) widget. */
|
||
rch?: number;
|
||
/** Pre-/post-market price change percentage. This value is required to display information on the [extended session](https://www.tradingview.com/charting-library-docs/latest/connecting_data/Extended-Sessions) the [Details](https://www.tradingview.com/charting-library-docs/latest/trading_terminal/#details) widget. */
|
||
rchp?: number;
|
||
[valueName: string]: string | number | string[] | number[] | undefined;
|
||
}
|
||
interface DatafeedSymbolType {
|
||
/** Name of the symbol type */
|
||
name: string;
|
||
/** Value to be passed as the `symbolType` argument to `searchSymbols` */
|
||
value: string;
|
||
}
|
||
/** Exchange Description */
|
||
interface Exchange {
|
||
/** Value to be passed as the `exchange` argument to `searchSymbols` */
|
||
value: string;
|
||
/** Name of the exchange */
|
||
name: string;
|
||
/** Description of the exchange */
|
||
desc: string;
|
||
}
|
||
/**
|
||
* Information passed to `onHistoryCallback` for getBars.
|
||
*/
|
||
interface HistoryMetadata {
|
||
/**
|
||
* Optional value indicating to the library that there is no more data on the server.
|
||
*/
|
||
noData?: boolean;
|
||
/**
|
||
* The time of the next available bar in history. The time value should be represented with a Unix timestamp in milliseconds.
|
||
*
|
||
* You can pass the `nextTime` value to the library if there is no data in the time range that the library requests.
|
||
* Therefore, you notify the library about available data before the requested range and ensure that the next data request is for the right range.
|
||
* For more information, refer to the [How nextTime works](https://www.tradingview.com/charting-library-docs/latest/connecting_data/UDF#how-nexttime-works) section.
|
||
*/
|
||
nextTime?: number | null;
|
||
}
|
||
interface IDatafeedChartApi {
|
||
/**
|
||
* The 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 ({@link DatafeedConfiguration.supports_marks}).
|
||
*
|
||
* @param symbolInfo A SymbolInfo object
|
||
* @param from Unix timestamp (leftmost visible bar)
|
||
* @param to Unix timestamp (rightmost visible bar)
|
||
* @param onDataCallback Callback function containing an array of marks
|
||
* @param resolution Resolution of the symbol
|
||
*/
|
||
getMarks?: (symbolInfo: LibrarySymbolInfo, from: number, to: number, onDataCallback: GetMarksCallback<Mark>, resolution: ResolutionString) => void;
|
||
/**
|
||
* The 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 ({@link DatafeedConfiguration.supports_timescale_marks}).
|
||
*
|
||
* @param symbolInfo A SymbolInfo object
|
||
* @param from Unix timestamp (leftmost visible bar)
|
||
* @param to Unix timestamp (rightmost visible bar)
|
||
* @param onDataCallback Callback function containing an array of marks
|
||
* @param resolution Resolution of the symbol
|
||
*/
|
||
getTimescaleMarks?: (symbolInfo: LibrarySymbolInfo, from: number, to: number, onDataCallback: GetMarksCallback<TimescaleMark>, resolution: ResolutionString) => void;
|
||
/**
|
||
* This 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](https://www.tradingview.com/charting-library-docs/latest/core_concepts/Resolution#resolution-in-minutes-intraday) resolutions.
|
||
*/
|
||
getServerTime?: (callback: ServerTimeCallback) => void;
|
||
/**
|
||
* Provides a list of symbols that match the user's search query.
|
||
*
|
||
* @param userInput Text entered by user in the symbol search field
|
||
* @param exchange The requested exchange. Empty value means no filter was specified
|
||
* @param symbolType Type of symbol. Empty value means no filter was specified
|
||
* @param onResult Callback function that returns an array of results ({@link SearchSymbolResultItem}) or empty array if no symbols found
|
||
* @param searchSource The source of the search ({@link SearchInitiationPoint}).
|
||
*/
|
||
searchSymbols: (userInput: string, exchange: string, symbolType: string, onResult: SearchSymbolsCallback, searchSource?: SearchInitiationPoint) => void;
|
||
/**
|
||
* The library will call this function when it needs to get SymbolInfo by symbol name.
|
||
*
|
||
* @param symbolName Symbol name or `ticker`
|
||
* @param onResolve Callback function returning a SymbolInfo ({@link LibrarySymbolInfo})
|
||
* @param onError Callback function whose only argument is a text error message
|
||
* @param extension An optional object with additional parameters
|
||
*/
|
||
resolveSymbol: (symbolName: string, onResolve: ResolveCallback, onError: DatafeedErrorCallback, extension?: SymbolResolveExtension) => void;
|
||
/**
|
||
* This function is called when the chart needs a history fragment defined by dates range.
|
||
*
|
||
* @param symbolInfo A SymbolInfo object
|
||
* @param resolution Resolution of the symbol
|
||
* @param periodParams An object used to pass specific requirements for getting bars
|
||
* @param onResult Callback function for historical data
|
||
* @param onError Callback function whose only argument is a text error message. If using special characters, please consider `encodeURIComponent`.
|
||
*/
|
||
getBars: (symbolInfo: LibrarySymbolInfo, resolution: ResolutionString, periodParams: PeriodParams, onResult: HistoryCallback, onError: DatafeedErrorCallback) => void;
|
||
/**
|
||
* 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.
|
||
*
|
||
* @param symbolInfo A SymbolInfo object
|
||
* @param resolution Resolution of the symbol
|
||
* @param onTick Callback function returning a Bar object
|
||
* @param listenerGuid
|
||
* @param onResetCacheNeededCallback Function to be executed when bar data has changed
|
||
*/
|
||
subscribeBars: (symbolInfo: LibrarySymbolInfo, resolution: ResolutionString, onTick: SubscribeBarsCallback, listenerGuid: string, onResetCacheNeededCallback: () => void) => void;
|
||
/**
|
||
* The library calls this function when it doesn't want to receive updates anymore.
|
||
*
|
||
* @param listenerGuid id to unsubscribe from
|
||
*/
|
||
unsubscribeBars: (listenerGuid: string) => void;
|
||
/**
|
||
* The library calls this function when it wants to receive real-time symbol data in the [Depth of Market](https://www.tradingview.com/charting-library-docs/latest/trading_terminal/depth-of-market) (DOM) widget.
|
||
* Note that you should set the {@link BrokerConfigFlags.supportLevel2Data} configuration flag to `true`.
|
||
*
|
||
* @param symbol A SymbolInfo object
|
||
* @param callback A function returning an object to update DOM data
|
||
* @returns A unique identifier that will be used to unsubscribe from the data
|
||
*/
|
||
subscribeDepth?: (symbol: string, callback: DOMCallback) => string;
|
||
/**
|
||
* The library calls this function to stop receiving real-time updates for the [Depth of Market](https://www.tradingview.com/charting-library-docs/latest/trading_terminal/depth-of-market) listener.
|
||
* Note that you should set the {@link BrokerConfigFlags.supportLevel2Data} configuration flag to `true`.
|
||
*
|
||
* @param subscriberUID A string returned by `subscribeDepth`
|
||
*/
|
||
unsubscribeDepth?: (subscriberUID: string) => void;
|
||
/**
|
||
* The 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.
|
||
*
|
||
* @param currentResolution Resolution of the symbol
|
||
* @param from Unix timestamp (leftmost visible bar)
|
||
* @param to Unix timestamp (rightmost visible bar)
|
||
* @param symbolInfo A Symbol object
|
||
* @returns A resolution
|
||
*/
|
||
getVolumeProfileResolutionForPeriod?: (currentResolution: ResolutionString, from: number, to: number, symbolInfo: LibrarySymbolInfo) => ResolutionString;
|
||
}
|
||
/** Quotes datafeed API */
|
||
interface IDatafeedQuotesApi {
|
||
/**
|
||
* This function is called when the library needs quote data.
|
||
* The library assumes that `onDataCallback` is called once when all the requested data is received.
|
||
* @param {string[]} symbols - symbol names.
|
||
* @param {QuotesCallback} onDataCallback - callback to return the requested data.
|
||
* @param {QuotesErrorCallback} onErrorCallback - callback for responding with an error.
|
||
*/
|
||
getQuotes: (symbols: string[], onDataCallback: QuotesCallback, onErrorCallback: QuotesErrorCallback) => void;
|
||
/**
|
||
* Trading Platform calls this function when it wants to receive real-time quotes for a symbol.
|
||
* The library assumes that you will call `onRealtimeCallback` every time you want to update the quotes.
|
||
* @param {string[]} symbols - list of symbols that should be updated rarely (once per minute). These symbols are included in the watchlist but they are not visible at the moment.
|
||
* @param {string[]} fastSymbols - list of symbols that should be updated frequently (at least once every 10 seconds)
|
||
* @param {QuotesCallback} onRealtimeCallback - callback to send realtime quote data updates
|
||
* @param {string} listenerGUID - unique identifier of the listener
|
||
*/
|
||
subscribeQuotes: (symbols: string[], fastSymbols: string[], onRealtimeCallback: QuotesCallback, listenerGUID: string) => void;
|
||
/**
|
||
* Trading Platform calls this function when it doesn't want to receive updates for this listener anymore.
|
||
* `listenerGUID` will be the same object that the Library passed to `subscribeQuotes` before.
|
||
* @param {string} listenerGUID - unique identifier of the listener
|
||
*/
|
||
unsubscribeQuotes: (listenerGUID: string) => void;
|
||
}
|
||
interface IExternalDatafeed {
|
||
/**
|
||
* This call is intended to provide the object filled with the configuration data.
|
||
* The lib assumes that you will call the callback function and pass your datafeed {@link DatafeedConfiguration} as an argument.
|
||
*
|
||
* @param {OnReadyCallback} callback - callback to return your datafeed configuration ({@link DatafeedConfiguration}) to the library.
|
||
*/
|
||
onReady: (callback: OnReadyCallback) => void;
|
||
}
|
||
interface LibrarySubsessionInfo {
|
||
/**
|
||
* Description of the subsession.
|
||
*
|
||
* @example "Regular Trading Hours"
|
||
*/
|
||
"description": string;
|
||
/**
|
||
* Subsession ID.
|
||
*/
|
||
"id": LibrarySessionId;
|
||
/**
|
||
* Session string. See {@link LibrarySymbolInfo.session}.
|
||
*/
|
||
"session": string;
|
||
/**
|
||
* Session corrections string. See {@link LibrarySymbolInfo.corrections}.
|
||
*/
|
||
"session-correction"?: string;
|
||
/**
|
||
* Session to display. See {@link LibrarySymbolInfo.session_display}.
|
||
*/
|
||
"session-display"?: string;
|
||
}
|
||
interface LibrarySymbolInfo {
|
||
/**
|
||
* It is a symbol name within an exchange, such as `AAPL` or `9988` (Hong Kong).
|
||
* Note that it should not contain the exchange name.
|
||
* This symbol name is visible to users and can be repeated.
|
||
*
|
||
* By default, `name` is used to resolve symbols in the [Datafeed API](https://www.tradingview.com/charting-library-docs/latest/connecting_data/datafeed-api/).
|
||
* If you use {@link LibrarySymbolInfo.ticker}, the library will use the ticker for Datafeed API requests.
|
||
*/
|
||
name: string;
|
||
/**
|
||
* Array of base symbols
|
||
* Example: for `AAPL*MSFT` it is `['NASDAQ:AAPL', 'NASDAQ:MSFT']`
|
||
*/
|
||
base_name?: string[];
|
||
/**
|
||
* It is an unique identifier for a particular symbol in your [symbology](https://www.tradingview.com/charting-library-docs/latest/connecting_data/Symbology).
|
||
* If you specify this property, its value will be used for all data requests for this symbol.
|
||
* `ticker` will be treated the same as {@link LibrarySymbolInfo.name} if not specified explicitly.
|
||
*
|
||
* You should avoid using colons (":") in ticker values unless you are following the TradingView format: "NYSE:IBM". Using colons may cause unexpected behaviour and display bugs.
|
||
*/
|
||
ticker?: string;
|
||
/**
|
||
* The description of the symbol.
|
||
* Will be displayed in the chart legend for this symbol.
|
||
*/
|
||
description: string;
|
||
/**
|
||
* Symbol Long description
|
||
*
|
||
* Optional long(er) description for the symbol.
|
||
*/
|
||
long_description?: string;
|
||
/**
|
||
* Type of the instrument.
|
||
* Possible values: {@link SymbolType}
|
||
*/
|
||
type: string;
|
||
/**
|
||
* Trading hours for the symbol. The time should be in the **exchange** time zone specified in the {@link LibrarySymbolInfo.timezone} property. Refer to the [Trading sessions](https://www.tradingview.com/charting-library-docs/latest/connecting_data/Trading-Sessions) article for more information.
|
||
* @example "1700-0200"
|
||
*/
|
||
session: string;
|
||
/**
|
||
* The session value to display in the UI. If not specified, then `session` is used.
|
||
*/
|
||
session_display?: string;
|
||
/**
|
||
* A string that contains a list of non-trading holidays for the symbol.
|
||
* Holiday dates should be in the `YYYYMMDD` format.
|
||
* These dates are not displayed on the chart.
|
||
*
|
||
* You can specify a correction for a holiday using {@link LibrarySymbolInfo.corrections}.
|
||
* @example "20181105,20181107,20181112"
|
||
*/
|
||
session_holidays?: string;
|
||
/**
|
||
* List of corrections for a symbol. The corrections are days when the trading session differs from the default one set in {@link LibrarySymbolInfo.session}.
|
||
* The `corrections` value is a string in the following format: `SESSION:YYYYMMDD`.
|
||
* For more information, refer to [corrections](https://www.tradingview.com/charting-library-docs/latest/connecting_data/Symbology#corrections).
|
||
*
|
||
* The string below specifies corrections for two trading days:
|
||
*
|
||
* - November 13, 2018. This trading day is split into two sessions. The first session starts at 19:00 four days before (November 9, 2018) and ends at 23:50 four days before. The second session starts at 10:00 and ends at 18:45.
|
||
* - November 14, 2018. The session starts at 10:00 and ends at 14:00.
|
||
*
|
||
* @example "1900F4-2350F4,1000-1845:20181113;1000-1400:20181114"
|
||
*/
|
||
corrections?: string;
|
||
/**
|
||
* Traded exchange (current (proxy) exchange).
|
||
* The name will be displayed in the chart legend for this symbol.
|
||
*
|
||
* @example "NYSE"
|
||
*/
|
||
exchange: string;
|
||
/**
|
||
* short name of the exchange where this symbol is traded (real listed exchange).
|
||
* The name will be displayed in the chart legend for this symbol.
|
||
*
|
||
* @example "NYSE"
|
||
*/
|
||
listed_exchange: string;
|
||
/**
|
||
* The time zone of the **exchange** where the symbol is listed. The time zone value should be in the OlsonDB format.
|
||
* Refer to [Time zones](https://www.tradingview.com/charting-library-docs/latest/ui_elements/timezones) for a full list of supported time zones.
|
||
*/
|
||
timezone: Timezone;
|
||
/**
|
||
* Format of displaying labels on the price scale:
|
||
*
|
||
* `price` - formats decimal or fractional numbers based on `minmov`, `pricescale`, `minmove2`, `fractional` and `variableMinTick` values. See [Price format](https://www.tradingview.com/charting-library-docs/latest/connecting_data/Symbology#price-format) for more details.
|
||
* `volume` - formats decimal numbers in thousands, millions, billions or trillions
|
||
*/
|
||
format: SeriesFormat;
|
||
/**
|
||
* A number of decimal places or fractions that the price has.
|
||
*
|
||
* The `pricescale` value depends on the [price format](https://www.tradingview.com/charting-library-docs/latest/connecting_data/Symbology#price-format).
|
||
* If you want to display the price in the decimal format, `pricescale` should be `10^n`, where `n` is the number of decimal places.
|
||
* **Examples:** `1`, `10`, `10000000`.
|
||
*
|
||
* If you want to display the price in the fractional format, `pricescale` should be `2^n`.
|
||
* This value represents the number of fractions.
|
||
* **Examples:** `8`, `16`, `256`.
|
||
*/
|
||
pricescale: number;
|
||
/**
|
||
* The number of units that make up one tick.
|
||
* For example, U.S. equities are quotes in decimals, and tick in decimals, and can go up +/- `.01`.
|
||
* Therefore, the tick increment is 1 and `minmov = 1`. But the e-mini S&P futures contract, though quoted in decimals, goes up in `.25` increments, so the tick increment is 25 and `minmov = 25`.
|
||
* Refer to [Price format](https://www.tradingview.com/charting-library-docs/latest/connecting_data/Symbology#price-format) for more information.
|
||
*/
|
||
minmov: number;
|
||
/**
|
||
* For common prices this can be skipped.
|
||
*
|
||
* Fractional prices are displayed 2 different forms: 1) `xx'yy` (for example, `133'21`) 2) `xx'yy'zz` (for example, `133'21'5`).
|
||
*
|
||
* - `xx` is an integer part.
|
||
* - `minmov/pricescale` is a Fraction.
|
||
* - `minmove2` is used in form 2.
|
||
* - `fractional` is `true`.
|
||
* - `variableMinTick` is skipped.
|
||
*
|
||
* Example:
|
||
*
|
||
* If `minmov = 1`, `pricescale = 128` and `minmove2 = 4`:
|
||
*
|
||
* - `119'16'0` represents `119 + 16/32`
|
||
* - `119'16'2` represents `119 + 16.25/32`
|
||
* - `119'16'5` represents `119 + 16.5/32`
|
||
* - `119'16'7` represents `119 + 16.75/32`
|
||
*
|
||
* More examples:
|
||
*
|
||
* - `ZBM2014 (T-Bond)` with `1/32`: `minmov = 1`, `pricescale = 32`, `minmove2 = 0`
|
||
* - `ZCM2014 (Corn)` with `2/8`: `minmov = 2`, `pricescale = 8`, `minmove2 = 0`
|
||
* - `ZFM2014 (5 year t-note)` with `1/4 of 1/32`: `minmov = 1`, `pricescale = 128`, `minmove2 = 4`
|
||
*/
|
||
fractional?: boolean;
|
||
/**
|
||
* This property is used to display prices in the [fraction of a fraction](https://www.tradingview.com/charting-library-docs/latest/connecting_data/Symbology#fraction-of-a-fraction-format) format.
|
||
* For example, the ZBM2023 tick size is 1/4 of a 32nd. To display this security, set `minmov = 1`, `pricescale = 128`, `minmove2 = 4`.
|
||
*
|
||
* For common prices, `minmove2` can be skipped or set to `0`.
|
||
*/
|
||
minmove2?: number;
|
||
/**
|
||
* Dynamic minimum price movement. It is used if the instrument's minimum price movement changes depending on the price range.
|
||
*
|
||
* For example, '0.01 10 0.02 25 0.05', where the tick size is 0.01 for a price less than 10, the tick size is 0.02 for a price less than 25, the tick size is 0.05 for a price greater than or equal to 25.
|
||
*/
|
||
variable_tick_size?: string;
|
||
/**
|
||
* A flag indicating whether your datafeed contains intraday (minutes) data for this symbol.
|
||
* If `true`, the library requests this data when an intraday resolution is selected. If `false`, _No data here_ is displayed on the chart.
|
||
*
|
||
* This property is required to enable intraday resolutions. Refer to the [Resolution](https://www.tradingview.com/charting-library-docs/latest/core_concepts/Resolution#resolution-in-minutes-intraday) article for more information.
|
||
* @default false
|
||
*/
|
||
has_intraday?: boolean;
|
||
/**
|
||
* An array of [resolutions](https://www.tradingview.com/charting-library-docs/latest/core_concepts/Resolution) which should be enabled in the _Resolution_ drop-down menu for this symbol.
|
||
* Each item of the array is expected to be a string that has a specific [format](https://www.tradingview.com/charting-library-docs/latest/core_concepts/Resolution#resolution-format).
|
||
*
|
||
* If one changes the symbol and the new symbol does not support the selected resolution, an error message will be shown on the chart.
|
||
*
|
||
* **Resolution availability logic (pseudocode):**
|
||
* ```
|
||
* resolutionAvailable =
|
||
* resolution.isIntraday
|
||
* ? symbol.has_intraday && symbol.supported_resolutions(resolution)
|
||
* : symbol.supported_resolutions(resolution);
|
||
* ```
|
||
*
|
||
* If `supported_resolutions` is `[]` (empty array), all resolutions are disabled in the _Resolution_ drop-down menu.
|
||
*
|
||
* If `supported_resolutions` is `undefined`, all resolutions that the chart support ({@link DatafeedConfiguration.supported_resolutions}) and custom resolutions are enabled.
|
||
*
|
||
* Note that the list of available time frames depends on supported resolutions.
|
||
* Time frames that require resolutions that are unavailable for a particular symbol will be hidden.
|
||
* Refer to [Time frame toolbar](https://www.tradingview.com/charting-library-docs/latest/ui_elements/Time-Scale#time-frame-toolbar) for more information.
|
||
*/
|
||
supported_resolutions?: ResolutionString[];
|
||
/**
|
||
* An array of intraday (minutes) resolutions that your datafeed supports. Items in the array should be listed in ascending order, for example: `["1", "2"]`.
|
||
*
|
||
* This property is required to enable intraday resolutions. Refer to the [Resolution](https://www.tradingview.com/charting-library-docs/latest/core_concepts/Resolution#resolution-in-minutes-intraday) article for more information.
|
||
* Note that each resolution in `intraday_multipliers` should be handled in the {@link IDatafeedChartApi.getBars} implementation.
|
||
* Consider the [example](https://www.tradingview.com/charting-library-docs/latest/core_concepts/Resolution#example).
|
||
*
|
||
* The library also uses resolutions listed in `intraday_multipliers` to display higher resolution that your datafeed does not explicitly support. If `intraday_multipliers` is not specified, the library cannot build additional resolutions.
|
||
*
|
||
* Note that the library **cannot** build daily, weekly, or monthly resolutions using intraday data.
|
||
* @default [] — specifies that the datafeed can provide data for any requested resolution.
|
||
*/
|
||
intraday_multipliers?: string[];
|
||
/**
|
||
* A flag indicating whether your datafeed contains seconds data for this symbol.
|
||
* If `true`, the library requests this data when a seconds resolution is selected. If `false`, _No data here_ is displayed on the chart.
|
||
*
|
||
* You should set `has_seconds` to `true` to enable seconds resolutions. Refer to the [Resolution](https://www.tradingview.com/charting-library-docs/latest/core_concepts/Resolution#resolution-in-seconds) article for more information.
|
||
* @default false
|
||
*/
|
||
has_seconds?: boolean;
|
||
/**
|
||
* A flag indicating whether your datafeed contains ticks data for this symbol.
|
||
* If `true`, the library requests this data when a resolution in ticks is selected. If `false`, _No data here_ is displayed on the chart.
|
||
*
|
||
* You should set `has_ticks` to `true` to enable ticks resolutions. Refer to the [Resolution](https://www.tradingview.com/charting-library-docs/latest/core_concepts/Resolution#resolution-in-ticks) article for more information.
|
||
* @default false
|
||
*/
|
||
has_ticks?: boolean;
|
||
/**
|
||
* An array of seconds resolutions that your datafeed supports. Items in the array should be listed in ascending order and **should not** include letters, for example: `["1", "2"]`.
|
||
* This property is required to enable seconds resolutions. Refer to the [Resolution](https://www.tradingview.com/charting-library-docs/latest/core_concepts/Resolution#resolution-in-seconds) article for more information.
|
||
*
|
||
* The library also uses resolutions listed in `seconds_multipliers` to display higher resolution that your datafeed does not explicitly support. If `seconds_multipliers` is not specified, the library cannot build additional resolutions.
|
||
* Consider the example. You need to enable one-second and five-second resolutions but your datafeed contains only one-second data. In this case, you should set `seconds_multipliers` to `["1"]`.
|
||
* The library will build the five-second resolution from one-second data.
|
||
*/
|
||
seconds_multipliers?: string[];
|
||
/**
|
||
* The boolean value showing whether or not seconds bars for this symbol can be built from ticks. Only available in Trading Platform.
|
||
*
|
||
* {@link LibrarySymbolInfo.has_seconds} must also be `true`
|
||
* {@link LibrarySymbolInfo.has_ticks} must also be `true`
|
||
* {@link LibrarySymbolInfo.seconds_multipliers} must be an empty array or only contain multipliers that the datafeed provides itself
|
||
*
|
||
* The library builds resolutions from ticks only if there are no seconds resolutions from the datafeed or the provided resolutions are larger then the required one. For example, the datafeed provides `3S` resolution. In this case, the library can build only `1S` or `2S` resolutions from ticks. Resolutions such as `15S` will be build with seconds bars.
|
||
* @default false
|
||
*/
|
||
build_seconds_from_ticks?: boolean;
|
||
/**
|
||
* A flag indicating whether your datafeed contains daily data for this symbol.
|
||
* If `true`, the library requests this data when a daily resolution is selected. If `false`, _No data here_ is displayed on the chart.
|
||
*
|
||
* `has_daily` is set to `true` by default. However, you should also specify {@link daily_multipliers} to enable daily resolutions. Refer to the [Resolution](https://www.tradingview.com/charting-library-docs/latest/core_concepts/Resolution#resolution-in-days) article for more information.
|
||
* @default true
|
||
*/
|
||
has_daily?: boolean;
|
||
/**
|
||
* An array of daily resolutions that your datafeed supports. Items in the array should be listed in ascending order and **should not** include letters, for example: `["1", "2"]`.
|
||
* This property is required to enable daily resolutions. Refer to the [Resolution](https://www.tradingview.com/charting-library-docs/latest/core_concepts/Resolution#resolution-in-days) article for more information.
|
||
*
|
||
* The library also uses resolutions listed in `daily_multipliers` to display higher resolution that your datafeed does not explicitly support. If `daily_multipliers` is not specified, the library cannot build additional resolutions.
|
||
* @default ["1"]
|
||
*/
|
||
daily_multipliers?: string[];
|
||
/**
|
||
* A flag indicating whether your datafeed contains weekly or monthly data for this symbol. If `true`, the library requests this data when the corresponding resolution is selected.
|
||
* To enable weekly or monthly resolutions, you should also specify the {@link weekly_multipliers} or {@link monthly_multipliers} properties.
|
||
* Refer to the [Resolution](https://www.tradingview.com/charting-library-docs/latest/core_concepts/Resolution#resolution-in-weeks--months) article for more information.
|
||
*
|
||
* If `has_weekly_and_monthly` is set to `false`, the library attempts to build the resolutions using daily bars. Note that building bars requires a large number of requests to your datafeed.
|
||
* If the library fails to build bars, _No data here_ is displayed on the chart.
|
||
* @default false
|
||
*/
|
||
has_weekly_and_monthly?: boolean;
|
||
/**
|
||
* An array of weekly resolutions that your datafeed supports. Items in the array should be listed in ascending order and **should not** include letters, for example: `["1", "3"]`.
|
||
* This property is required to enable weekly resolutions. Refer to the [Resolution](https://www.tradingview.com/charting-library-docs/latest/core_concepts/Resolution#resolution-in-weeks--months) article for more information.
|
||
*
|
||
* The library also uses resolutions listed in `weekly_multipliers` to display higher resolution that your datafeed does not explicitly support. If `weekly_multipliers` is not specified, the library cannot build additional resolutions.
|
||
* @default ['1']
|
||
*/
|
||
weekly_multipliers?: string[];
|
||
/**
|
||
* An array of monthly resolutions that your datafeed supports. Items in the array should be listed in ascending order and **should not** include letters, for example: `["1", "3", "6", "12"]`.
|
||
* This property is required to enable monthly resolutions. Refer to the [Resolution](https://www.tradingview.com/charting-library-docs/latest/core_concepts/Resolution#resolution-in-weeks--months) article for more information.
|
||
*
|
||
* The library also uses resolutions listed in `monthly_multipliers` to display higher resolution that your datafeed does not explicitly support. If `monthly_multipliers` is not specified, the library cannot build additional resolutions.
|
||
* @default ['1']
|
||
*/
|
||
monthly_multipliers?: string[];
|
||
/**
|
||
* The boolean value showing whether the library should generate empty bars in the session when there is no data from the data feed for this particular time.
|
||
*
|
||
* I.e., if your session is `0900-1600` and your data has gaps between `11:00` and `12:00` and your `has_empty_bars` is `true`, then the Library will fill the gaps with bars for this time.
|
||
*
|
||
* Flag `has_empty_bars` = `true` cannot be used if featureset `disable_resolution_rebuild` is enabled.
|
||
* @default false
|
||
*/
|
||
has_empty_bars?: boolean;
|
||
/**
|
||
* Represents what values are supported by the symbol. Possible values:
|
||
*
|
||
* - `ohlcv` — the symbol supports open, high, low, close prices and has volume.
|
||
* - `ohlc` — the symbol supports open, high, low, close, prices but doesn't have volume.
|
||
* - `c` — the symbol supports only close price. This makes the chart show the symbol data using only line-based styles.
|
||
* @default 'ohlcv'
|
||
*/
|
||
visible_plots_set?: VisiblePlotsSet;
|
||
/**
|
||
* Integer showing typical volume value decimal places for a particular symbol.
|
||
* 0 means volume is always an integer.
|
||
* 1 means that there might be 1 numeric character after the comma.
|
||
* @default '0'
|
||
*/
|
||
volume_precision?: number;
|
||
/**
|
||
* The status code of a series with this symbol.
|
||
* For `delayed_streaming` and `endofday` type of data, the status is displayed as an icon and the *Data is delayed* section in the [_Legend_](https://www.tradingview.com/charting-library-docs/latest/ui_elements/Legend#display-delayed-data-information), next to the market status icon.
|
||
* Note that you should also enable the [`display_data_mode`](https://www.tradingview.com/charting-library-docs/latest/customization/Featuresets#display_data_mode) featureset.
|
||
*
|
||
* When declaring `delayed_streaming` you also have to specify its {@link LibrarySymbolInfo.delay} in seconds.
|
||
*/
|
||
data_status?: "streaming" | "endofday" | "delayed_streaming";
|
||
/**
|
||
* Type of delay that is associated to the data or real delay for real time data.
|
||
* - `0` for realtime
|
||
* - `-1` for endofday
|
||
* - or delay in seconds (for delayed realtime)
|
||
*/
|
||
delay?: number;
|
||
/**
|
||
* Boolean showing whether this symbol is expired futures contract or not.
|
||
* @default false
|
||
*/
|
||
expired?: boolean;
|
||
/**
|
||
* Unix timestamp of the expiration date. One must set this value when `expired` = `true`.
|
||
* The library will request data for this symbol starting from that time point.
|
||
*/
|
||
expiration_date?: number;
|
||
/** Sector for stocks to be displayed in the Security Info. */
|
||
sector?: string;
|
||
/** Industry for stocks to be displayed in the Security Info. */
|
||
industry?: string;
|
||
/**
|
||
* The currency in which the instrument is traded or some other currency if currency conversion is enabled.
|
||
* It is displayed in the Security Info dialog and on the price axes.
|
||
*/
|
||
currency_code?: string;
|
||
/** The currency in which the instrument is traded. */
|
||
original_currency_code?: string;
|
||
/**
|
||
* A unique identifier of a unit in which the instrument is traded or some other identifier if unit conversion is enabled.
|
||
* It is displayed on the price axes.
|
||
*/
|
||
unit_id?: string;
|
||
/**
|
||
* A unique identifier of a unit in which the instrument is traded.
|
||
*/
|
||
original_unit_id?: string;
|
||
/**
|
||
* Allowed unit conversion group names.
|
||
*/
|
||
unit_conversion_types?: string[];
|
||
/**
|
||
* An ID of a subsession specified in {@link subsessions}. The value must match the subsession that is currently displayed on the chart.
|
||
* For more information, refer to the [Extended sessions](https://www.tradingview.com/charting-library-docs/latest/connecting_data/Symbology#extended-sessions) section.
|
||
*/
|
||
subsession_id?: string;
|
||
/**
|
||
* An array of objects that contain information about certain subsessions within the extended session.
|
||
* For more information, refer to the [Extended sessions](https://www.tradingview.com/charting-library-docs/latest/connecting_data/Symbology#extended-sessions) section.
|
||
*/
|
||
subsessions?: LibrarySubsessionInfo[];
|
||
/**
|
||
* Optional ID of a price source for a symbol. Should match one of the price sources from the {@link price_sources} array.
|
||
*
|
||
* Note that you should set the [`symbol_info_price_source`](https://www.tradingview.com/charting-library-docs/latest/customization/Featuresets#symbol_info_price_source) featureset to `true` to display the symbol price source in the main series legend.
|
||
*/
|
||
price_source_id?: string;
|
||
/**
|
||
* Supported price sources for the symbol.
|
||
* Price sources appear in the series legend and indicate the origin of values represented by symbol bars.
|
||
* Example price sources: "Spot Price", "Ask", "Bid", etc.
|
||
* The price source information is valuable when viewing non-OHLC series types.
|
||
*
|
||
* Note that you should set the [`symbol_info_price_source`](https://www.tradingview.com/charting-library-docs/latest/customization/Featuresets#symbol_info_price_source) featureset to `true` to display the symbol price source in the main series legend.
|
||
* @example [{ id: '1', name: 'Spot Price' }, { id: '321', name: 'Bid' }]
|
||
*/
|
||
price_sources?: SymbolInfoPriceSource[];
|
||
/**
|
||
* URL of image/s to be displayed as the logo/s for the symbol. The `show_symbol_logos` featureset needs to be enabled for this to be visible in the UI.
|
||
*
|
||
* - If a single url is returned then that url will solely be used to display the symbol logo.
|
||
* - If two urls are provided then the images will be displayed as two partially overlapping
|
||
* circles with the first url appearing on top. This is typically used for FOREX where you would
|
||
* like to display two country flags are the symbol logo.
|
||
*
|
||
* The image/s should ideally be square in dimension. You can use any image type which
|
||
* the browser supports natively.
|
||
*
|
||
* Examples:
|
||
* - `https://yourserver.com/apple.svg`
|
||
* - `/images/myImage.png`
|
||
* - `data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3...`
|
||
* - `data:image/jpeg;base64,/9j/4AAQSkZJRgABAQAASABIAAD/4...`
|
||
*/
|
||
logo_urls?: [
|
||
string,
|
||
] | [
|
||
string,
|
||
string,
|
||
];
|
||
/**
|
||
* URL of image to be displayed as the logo for the exchange. The `show_exchange_logos` featureset needs to be enabled for this to be visible in the UI.
|
||
*
|
||
* The image should ideally be square in dimension. You can use any image type which
|
||
* the browser supports natively. Simple SVG images are recommended.
|
||
*
|
||
* Examples:
|
||
* - `https://yourserver.com/exchangeLogo.svg`
|
||
* - `/images/myImage.png`
|
||
* - `data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3...`
|
||
* - `data:image/jpeg;base64,/9j/4AAQSkZJRgABAQAASABIAAD/4...`
|
||
*/
|
||
exchange_logo?: string;
|
||
/**
|
||
* Additional metadata to include with the symbol information.
|
||
* These parameters will not affect existing properties such as 'ticker' or 'name'
|
||
* and will not be processed by the library. However, they can be accessed later
|
||
* through the {@link IChartWidgetApi.symbolExt} method, impacting existing
|
||
* properties such as 'ticker' or 'name'.
|
||
*/
|
||
library_custom_fields?: Record<string, unknown>;
|
||
}
|
||
interface Mark {
|
||
/** ID of the mark */
|
||
id: string | number;
|
||
/**
|
||
* Time for the mark.
|
||
* Unix timestamp in seconds.
|
||
*/
|
||
time: number;
|
||
/** Color for the mark */
|
||
color: MarkConstColors | MarkCustomColor;
|
||
/** Text content for the mark */
|
||
text: string;
|
||
/** Label for the mark */
|
||
label: string;
|
||
/** Text color for the mark */
|
||
labelFontColor: string;
|
||
/** Minimum size for the mark */
|
||
minSize: number;
|
||
/** Border Width */
|
||
borderWidth?: number;
|
||
/** Border Width when hovering over bar mark */
|
||
hoveredBorderWidth?: number;
|
||
/**
|
||
* Optional URL for an image to be displayed within the timescale mark.
|
||
*
|
||
* The image should ideally be square in dimension. You can use any image type which
|
||
* the browser supports natively.
|
||
*
|
||
* Examples:
|
||
* - `https://yourserver.com/adobe.svg`
|
||
* - `/images/myImage.png`
|
||
* - `data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3...`
|
||
* - `data:image/jpeg;base64,/9j/4AAQSkZJRgABAQAASABIAAD/4...`
|
||
*/
|
||
imageUrl?: string;
|
||
/**
|
||
* Continue to show text label even when an image has
|
||
* been loaded for the timescale mark.
|
||
*
|
||
* Defaults to `false` if undefined.
|
||
*/
|
||
showLabelWhenImageLoaded?: boolean;
|
||
}
|
||
interface MarkCustomColor {
|
||
/** Border color */
|
||
border: string;
|
||
/** Background color */
|
||
background: string;
|
||
}
|
||
/**
|
||
* Parameters passed to getBars
|
||
*/
|
||
interface PeriodParams {
|
||
/**
|
||
* Unix timestamp (leftmost requested bar)
|
||
*/
|
||
from: number;
|
||
/**
|
||
* Unix timestamp (rightmost requested bar - not inclusive)
|
||
*/
|
||
to: number;
|
||
/**
|
||
* The exact amount of bars to load, should be considered a higher priority than `from` if your datafeed supports it
|
||
*/
|
||
countBack: number;
|
||
/**
|
||
* Used to identify if it's the first call of getBars
|
||
*/
|
||
firstDataRequest: boolean;
|
||
}
|
||
interface QuoteDataResponse {
|
||
/** Status code for symbol. Expected values: `ok` | `error` */
|
||
s: "ok" | "error";
|
||
/** Symbol name. This value must be **exactly the same** as in the request */
|
||
n: string;
|
||
/** Quote Values */
|
||
v: unknown;
|
||
}
|
||
/** Quote Data Error Response */
|
||
interface QuoteErrorData extends QuoteDataResponse {
|
||
/** @inheritDoc */
|
||
s: "error";
|
||
/** @inheritDoc */
|
||
v: object;
|
||
}
|
||
/** Quote Data Ok Response */
|
||
interface QuoteOkData extends QuoteDataResponse {
|
||
/** @inheritDoc */
|
||
s: "ok";
|
||
/** @inheritDoc */
|
||
v: DatafeedQuoteValues;
|
||
}
|
||
/**
|
||
* [Symbol Search](https://www.tradingview.com/charting-library-docs/latest/ui_elements/Symbol-Search) result item.
|
||
* Pass the resulting array of symbols as a parameter to {@link SearchSymbolsCallback} of the [`searchSymbols`](https://www.tradingview.com/charting-library-docs/latest/connecting_data/datafeed-api/required-methods#searchsymbols) method.
|
||
*
|
||
* @example
|
||
* ```
|
||
* {
|
||
* description: 'Apple Inc.',
|
||
* exchange: 'NasdaqNM',
|
||
* symbol: 'AAPL',
|
||
* ticker: 'AAPL',
|
||
* type: 'stock',
|
||
* }
|
||
* ```
|
||
*/
|
||
interface SearchSymbolResultItem {
|
||
/** Short symbol name */
|
||
symbol: string;
|
||
/** Description */
|
||
description: string;
|
||
/** Exchange name */
|
||
exchange: string;
|
||
/**
|
||
* It is a unique identifier for a particular symbol in your [symbology](https://www.tradingview.com/charting-library-docs/latest/connecting_data/Symbology).
|
||
*
|
||
* You should avoid using colons (":") in ticker values unless you are following the TradingView format: "NYSE:IBM". Using colons may cause unexpected behaviour and display bugs.
|
||
*
|
||
* Corresponds with {@link LibrarySymbolInfo.ticker}.
|
||
*/
|
||
ticker?: string;
|
||
/**
|
||
* Type of symbol
|
||
*
|
||
* 'stock' | 'futures' | 'forex' | 'index'
|
||
*/
|
||
type: string;
|
||
/**
|
||
* URL of image/s to be displayed as the logo/s for the symbol. The `show_symbol_logos` featureset needs to be enabled for this to be visible in the UI.
|
||
*
|
||
* - If a single url is returned then that url will solely be used to display the symbol logo.
|
||
* - If two urls are provided then the images will be displayed as two partially overlapping
|
||
* circles with the first url appearing on top. This is typically used for FOREX where you would
|
||
* like to display two country flags as the symbol logo.
|
||
*
|
||
* The image/s should ideally be square in dimension. You can use any image type which
|
||
* the browser supports natively. Simple SVG images are recommended.
|
||
*
|
||
* Examples:
|
||
* - `https://yourserver.com/symbolName.svg`
|
||
* - `/images/myImage.png`
|
||
* - `data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3...`
|
||
* - `data:image/jpeg;base64,/9j/4AAQSkZJRgABAQAASABIAAD/4...`
|
||
*/
|
||
logo_urls?: [
|
||
string,
|
||
] | [
|
||
string,
|
||
string,
|
||
];
|
||
/**
|
||
* URL of image to be displayed as the logo for the exchange. The `show_exchange_logos` featureset needs to be enabled for this to be visible in the UI.
|
||
*
|
||
* The image should ideally be square in dimension. You can use any image type which
|
||
* the browser supports natively. Simple SVG images are recommended.
|
||
*
|
||
* Examples:
|
||
* - `https://yourserver.com/exchangeLogo.svg`
|
||
* - `/images/myImage.png`
|
||
* - `data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3...`
|
||
* - `data:image/jpeg;base64,/9j/4AAQSkZJRgABAQAASABIAAD/4...`
|
||
*/
|
||
exchange_logo?: string;
|
||
}
|
||
interface SymbolInfoPriceSource {
|
||
/** Unique ID */
|
||
id: string;
|
||
/** Short name */
|
||
name: string;
|
||
}
|
||
/** Additional information about the Symbol's currency or unit */
|
||
interface SymbolResolveExtension {
|
||
/**
|
||
* Indicates the currency for conversions if `currency_codes` configuration field is set,
|
||
* and `currency_code` is provided in the original symbol information ({@link LibrarySymbolInfo}).
|
||
* Read more about [currency conversion](https://www.tradingview.com/charting-library-docs/latest/ui_elements/Price-Scale#enable-currency-conversion).
|
||
*/
|
||
currencyCode?: string;
|
||
/**
|
||
* Indicates the unit for conversion if `units` configuration
|
||
* field is set and `unit_id` is provided in the original symbol information ({@link LibrarySymbolInfo}).
|
||
*/
|
||
unitId?: string;
|
||
/**
|
||
* Trading session type, such as `"regular"` or `"extended"`, that the chart should currently display.
|
||
*/
|
||
session?: string;
|
||
}
|
||
interface TimescaleMark {
|
||
/** ID of the timescale mark */
|
||
id: string | number;
|
||
/**
|
||
* Time for the mark.
|
||
* Unix timestamp in seconds.
|
||
*/
|
||
time: number;
|
||
/** Color for the timescale mark */
|
||
color: MarkConstColors | string;
|
||
/**
|
||
* Color for the timescale mark text label.
|
||
* If undefined then the value provided for `color` will be used.
|
||
*/
|
||
labelFontColor?: MarkConstColors | string;
|
||
/** Label for the timescale mark */
|
||
label: string;
|
||
/** Tooltip content */
|
||
tooltip: string[];
|
||
/** Shape of the timescale mark */
|
||
shape?: TimeScaleMarkShape;
|
||
/**
|
||
* Optional URL for an image to be displayed within the timescale mark.
|
||
*
|
||
* The image should ideally be square in dimension. You can use any image type which
|
||
* the browser supports natively.
|
||
*
|
||
* Examples:
|
||
* - `https://s3-symbol-logo.tradingview.com/crypto/XTVCBTC.svg`
|
||
* - `/images/myImage.png`
|
||
* - `data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3...`
|
||
* - `data:image/jpeg;base64,/9j/4AAQSkZJRgABAQAASABIAAD/4...`
|
||
*/
|
||
imageUrl?: string;
|
||
/**
|
||
* Continue to show text label even when an image has
|
||
* been loaded for the timescale mark.
|
||
*
|
||
* Defaults to `false` if undefined.
|
||
*/
|
||
showLabelWhenImageLoaded?: boolean;
|
||
}
|
||
interface Unit {
|
||
/** Unique ID */
|
||
id: string;
|
||
/** Short name */
|
||
name: string;
|
||
/** Description */
|
||
description: string;
|
||
}
|
||
type CustomTimezones = "Africa/Cairo" | "Africa/Casablanca" | "Africa/Johannesburg" | "Africa/Lagos" | "Africa/Nairobi" | "Africa/Tunis" | "America/Anchorage" | "America/Argentina/Buenos_Aires" | "America/Bogota" | "America/Caracas" | "America/Chicago" | "America/El_Salvador" | "America/Juneau" | "America/Lima" | "America/Los_Angeles" | "America/Mexico_City" | "America/New_York" | "America/Phoenix" | "America/Santiago" | "America/Sao_Paulo" | "America/Toronto" | "America/Vancouver" | "Asia/Almaty" | "Asia/Ashkhabad" | "Asia/Bahrain" | "Asia/Bangkok" | "Asia/Chongqing" | "Asia/Colombo" | "Asia/Dhaka" | "Asia/Dubai" | "Asia/Ho_Chi_Minh" | "Asia/Hong_Kong" | "Asia/Jakarta" | "Asia/Jerusalem" | "Asia/Karachi" | "Asia/Kathmandu" | "Asia/Kolkata" | "Asia/Kuala_Lumpur" | "Asia/Kuwait" | "Asia/Manila" | "Asia/Muscat" | "Asia/Nicosia" | "Asia/Qatar" | "Asia/Riyadh" | "Asia/Seoul" | "Asia/Shanghai" | "Asia/Singapore" | "Asia/Taipei" | "Asia/Tehran" | "Asia/Tokyo" | "Asia/Yangon" | "Atlantic/Azores" | "Atlantic/Reykjavik" | "Australia/Adelaide" | "Australia/Brisbane" | "Australia/Perth" | "Australia/Sydney" | "Europe/Amsterdam" | "Europe/Athens" | "Europe/Belgrade" | "Europe/Berlin" | "Europe/Bratislava" | "Europe/Brussels" | "Europe/Bucharest" | "Europe/Budapest" | "Europe/Copenhagen" | "Europe/Dublin" | "Europe/Helsinki" | "Europe/Istanbul" | "Europe/Lisbon" | "Europe/London" | "Europe/Luxembourg" | "Europe/Madrid" | "Europe/Malta" | "Europe/Moscow" | "Europe/Oslo" | "Europe/Paris" | "Europe/Prague" | "Europe/Riga" | "Europe/Rome" | "Europe/Stockholm" | "Europe/Tallinn" | "Europe/Vienna" | "Europe/Vilnius" | "Europe/Warsaw" | "Europe/Zurich" | "Pacific/Auckland" | "Pacific/Chatham" | "Pacific/Fakaofo" | "Pacific/Honolulu" | "Pacific/Norfolk" | "US/Mountain";
|
||
type DOMCallback = (data: DOMData) => void;
|
||
type DatafeedErrorCallback = (reason: string) => void;
|
||
type GetMarksCallback<T> = (marks: T[]) => void;
|
||
type HistoryCallback = (bars: Bar[], meta?: HistoryMetadata) => void;
|
||
type LibrarySessionId = "regular" | "extended" | "premarket" | "postmarket";
|
||
type MarkConstColors = "red" | "green" | "blue" | "yellow";
|
||
type OnReadyCallback = (configuration: DatafeedConfiguration) => void;
|
||
type QuoteData = QuoteOkData | QuoteErrorData;
|
||
/**
|
||
* Callback to provide Quote data.
|
||
* @param {QuoteData[]} data - Quote Data
|
||
*/
|
||
type QuotesCallback = (data: QuoteData[]) => void;
|
||
/**
|
||
* Error callback for quote data request.
|
||
* @param {QuoteData[]} reason - message describing the reason for the error
|
||
*/
|
||
type QuotesErrorCallback = (reason: string) => void;
|
||
/**
|
||
* Resolution or time interval is a time period of one bar. Advanced Charts supports tick, intraday (seconds, minutes, hours), and DWM (daily, weekly, monthly) resolutions. The table below describes how to specify different types of resolutions:
|
||
*
|
||
* Resolution | Format | Example
|
||
* ---------|----------|---------
|
||
* Ticks | `xT` | `1T` — one tick, `5T` — five ticks, `100T` — one hundred ticks
|
||
* Seconds | `xS` | `1S` — one second
|
||
* Minutes | `x` | `1` — one minute
|
||
* Hours | `x` minutes | `60` — one hour
|
||
* Days | `xD` | `1D` — one day
|
||
* Weeks | `xW` | `1W` — one week
|
||
* Months | `xM` | `1M` — one month
|
||
* Years | `xM` months | `12M` — one year
|
||
*
|
||
* Refer to [Resolution](https://www.tradingview.com/charting-library-docs/latest/core_concepts/Resolution) for more information.
|
||
*/
|
||
type ResolutionString = Nominal<string, "ResolutionString">;
|
||
type ResolveCallback = (symbolInfo: LibrarySymbolInfo) => void;
|
||
type SearchSymbolsCallback = (items: SearchSymbolResultItem[]) => void;
|
||
type SeriesFormat = "price" | "volume";
|
||
type ServerTimeCallback = (serverTime: number) => void;
|
||
type SubscribeBarsCallback = (bar: Bar) => void;
|
||
type TimeScaleMarkShape = "circle" | "earningUp" | "earningDown" | "earning";
|
||
type Timezone = "Etc/UTC" | CustomTimezones;
|
||
type VisiblePlotsSet = "ohlcv" | "ohlc" | "c" | "hlc";
|
||
|
||
interface RequestParams {
|
||
[paramName: string]: string | string[] | number;
|
||
}
|
||
interface UdfResponse {
|
||
s: string;
|
||
}
|
||
interface UdfErrorResponse {
|
||
s: "error";
|
||
errmsg: string;
|
||
}
|
||
|
||
interface IRequester {
|
||
sendRequest: (<T extends UdfResponse>(datafeedUrl: string, urlPath: string, params?: RequestParams) => Promise<T | UdfErrorResponse>) & (<T>(datafeedUrl: string, urlPath: string, params?: RequestParams) => Promise<T>) & (<T>(datafeedUrl: string, urlPath: string, params?: RequestParams) => Promise<T>);
|
||
}
|
||
|
||
type PeriodParamsWithOptionalCountback = Omit<PeriodParams, "countBack"> & {
|
||
countBack?: number;
|
||
};
|
||
interface LimitedResponseConfiguration {
|
||
/**
|
||
* Set this value to the maximum number of bars which
|
||
* the data backend server can supply in a single response.
|
||
* This doesn't affect or change the library behavior regarding
|
||
* how many bars it will request. It just allows this Datafeed
|
||
* implementation to correctly handle this situation.
|
||
*/
|
||
maxResponseLength: number;
|
||
/**
|
||
* If the server can't return all the required bars in a single
|
||
* response then `expectedOrder` specifies whether the server
|
||
* will send the latest (newest) or earliest (older) data first.
|
||
*/
|
||
expectedOrder: "latestFirst" | "earliestFirst";
|
||
}
|
||
|
||
interface IQuotesProvider {
|
||
getQuotes: (symbols: string[]) => Promise<QuoteData[]>;
|
||
}
|
||
|
||
interface UdfCompatibleConfiguration extends DatafeedConfiguration {
|
||
supports_search?: boolean;
|
||
supports_group_request?: boolean;
|
||
}
|
||
/**
|
||
* This class implements interaction with UDF-compatible datafeed.
|
||
* See [UDF protocol reference](@docs/connecting_data/UDF.md)
|
||
*/
|
||
declare class UDFCompatibleDatafeedBase implements IExternalDatafeed, IDatafeedQuotesApi, IDatafeedChartApi {
|
||
protected _configuration: UdfCompatibleConfiguration;
|
||
private readonly _datafeedURL;
|
||
private readonly _configurationReadyPromise;
|
||
private _symbolsStorage;
|
||
private readonly _historyProvider;
|
||
private readonly _dataPulseProvider;
|
||
private readonly _quotesProvider;
|
||
private readonly _quotesPulseProvider;
|
||
private readonly _requester;
|
||
protected constructor(datafeedURL: string, quotesProvider: IQuotesProvider, requester: IRequester, updateFrequency?: number, limitedServerResponse?: LimitedResponseConfiguration);
|
||
onReady(callback: OnReadyCallback): void;
|
||
getQuotes(symbols: string[], onDataCallback: QuotesCallback, onErrorCallback: (msg: string) => void): void;
|
||
subscribeQuotes(symbols: string[], fastSymbols: string[], onRealtimeCallback: QuotesCallback, listenerGuid: string): void;
|
||
unsubscribeQuotes(listenerGuid: string): void;
|
||
getMarks(symbolInfo: LibrarySymbolInfo, from: number, to: number, onDataCallback: GetMarksCallback<Mark>, resolution: ResolutionString): void;
|
||
getTimescaleMarks(symbolInfo: LibrarySymbolInfo, from: number, to: number, onDataCallback: GetMarksCallback<TimescaleMark>, resolution: ResolutionString): void;
|
||
getServerTime(callback: ServerTimeCallback): void;
|
||
searchSymbols(userInput: string, exchange: string, symbolType: string, onResult: SearchSymbolsCallback): void;
|
||
resolveSymbol(symbolName: string, onResolve: ResolveCallback, onError: DatafeedErrorCallback, extension?: SymbolResolveExtension): void;
|
||
getBars(symbolInfo: LibrarySymbolInfo, resolution: ResolutionString, periodParams: PeriodParamsWithOptionalCountback, onResult: HistoryCallback, onError: DatafeedErrorCallback): void;
|
||
subscribeBars(symbolInfo: LibrarySymbolInfo, resolution: ResolutionString, onTick: SubscribeBarsCallback, listenerGuid: string, _onResetCacheNeededCallback: () => void): void;
|
||
unsubscribeBars(listenerGuid: string): void;
|
||
protected _requestConfiguration(): Promise<UdfCompatibleConfiguration | null>;
|
||
private _send;
|
||
private _setupWithConfiguration;
|
||
}
|
||
|
||
declare class UDFCompatibleDatafeed extends UDFCompatibleDatafeedBase {
|
||
constructor(datafeedURL: string, updateFrequency?: number, limitedServerResponse?: LimitedResponseConfiguration);
|
||
}
|
||
|
||
export { UDFCompatibleDatafeed };
|