Release v17.016 (from 000a21d8)
Fixes tradingview/charting_library#4599 Fixes tradingview/charting_library#4613 Fixes tradingview/charting_library#4764 Fixes tradingview/charting_library#4801 Fixes tradingview/charting_library#5112
This commit is contained in:
@@ -47,6 +47,8 @@ interface ExchangeDataResponseSymbolData {
|
||||
'has-weekly-and-monthly'?: boolean;
|
||||
'has-empty-bars'?: boolean;
|
||||
'has-no-volume'?: boolean;
|
||||
'currency-code'?: string;
|
||||
'original-currency-code'?: string;
|
||||
|
||||
'volume-precision'?: number;
|
||||
}
|
||||
@@ -80,6 +82,11 @@ function extractField<Field extends keyof ExchangeDataResponseSymbolData>(data:
|
||||
return value as ExchangeDataResponseSymbolData[Field];
|
||||
}
|
||||
|
||||
function symbolWithCurrencyKey(symbol: string, currency?: string): string {
|
||||
// here we're using a separator that quite possible shouldn't be in a real symbol name
|
||||
return symbol + (currency !== undefined ? '_%|#|%_' + currency : '');
|
||||
}
|
||||
|
||||
export class SymbolsStorage {
|
||||
private readonly _exchangesList: string[] = ['NYSE', 'FOREX', 'AMEX'];
|
||||
private readonly _symbolsInfo: SymbolInfoMap = {};
|
||||
@@ -102,9 +109,9 @@ export class SymbolsStorage {
|
||||
}
|
||||
|
||||
// BEWARE: this function does not consider symbol's exchange
|
||||
public resolveSymbol(symbolName: string): Promise<LibrarySymbolInfo> {
|
||||
public resolveSymbol(symbolName: string, currencyCode?: string): Promise<LibrarySymbolInfo> {
|
||||
return this._readyPromise.then(() => {
|
||||
const symbolInfo = this._symbolsInfo[symbolName];
|
||||
const symbolInfo = this._symbolsInfo[symbolWithCurrencyKey(symbolName, currencyCode)];
|
||||
if (symbolInfo === undefined) {
|
||||
return Promise.reject('invalid symbol');
|
||||
}
|
||||
@@ -228,6 +235,7 @@ export class SymbolsStorage {
|
||||
const listedExchange = extractField(data, 'exchange-listed', symbolIndex);
|
||||
const tradedExchange = extractField(data, 'exchange-traded', symbolIndex);
|
||||
const fullName = tradedExchange + ':' + symbolName;
|
||||
const currencyCode = extractField(data, 'currency-code', symbolIndex);
|
||||
|
||||
const ticker = tickerPresent ? (extractField(data, 'ticker', symbolIndex) as string) : symbolName;
|
||||
|
||||
@@ -238,6 +246,8 @@ export class SymbolsStorage {
|
||||
full_name: fullName,
|
||||
listed_exchange: listedExchange,
|
||||
exchange: tradedExchange,
|
||||
currency_code: currencyCode,
|
||||
original_currency_code: extractField(data, 'original-currency-code', symbolIndex),
|
||||
description: extractField(data, 'description', symbolIndex),
|
||||
has_intraday: definedValueOrDefault(extractField(data, 'has-intraday', symbolIndex), false),
|
||||
has_no_volume: definedValueOrDefault(extractField(data, 'has-no-volume', symbolIndex), false),
|
||||
@@ -261,6 +271,11 @@ export class SymbolsStorage {
|
||||
this._symbolsInfo[ticker] = symbolInfo;
|
||||
this._symbolsInfo[symbolName] = symbolInfo;
|
||||
this._symbolsInfo[fullName] = symbolInfo;
|
||||
if (currencyCode !== undefined) {
|
||||
this._symbolsInfo[symbolWithCurrencyKey(ticker, currencyCode)] = symbolInfo;
|
||||
this._symbolsInfo[symbolWithCurrencyKey(symbolName, currencyCode)] = symbolInfo;
|
||||
this._symbolsInfo[symbolWithCurrencyKey(fullName, currencyCode)] = symbolInfo;
|
||||
}
|
||||
|
||||
this._symbolsList.push(symbolName);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user