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:
@@ -12,6 +12,9 @@ var HistoryProvider = /** @class */ (function () {
|
||||
from: rangeStartDate,
|
||||
to: rangeEndDate,
|
||||
};
|
||||
if (symbolInfo.currency_code !== undefined) {
|
||||
requestParams.currencyCode = symbolInfo.currency_code;
|
||||
}
|
||||
return new Promise(function (resolve, reject) {
|
||||
_this._requester.sendRequest(_this._datafeedUrl, 'history', requestParams)
|
||||
.then(function (response) {
|
||||
@@ -33,18 +36,18 @@ var HistoryProvider = /** @class */ (function () {
|
||||
for (var i = 0; i < response.t.length; ++i) {
|
||||
var barValue = {
|
||||
time: response.t[i] * 1000,
|
||||
close: Number(response.c[i]),
|
||||
open: Number(response.c[i]),
|
||||
high: Number(response.c[i]),
|
||||
low: Number(response.c[i]),
|
||||
close: parseFloat(response.c[i]),
|
||||
open: parseFloat(response.c[i]),
|
||||
high: parseFloat(response.c[i]),
|
||||
low: parseFloat(response.c[i]),
|
||||
};
|
||||
if (ohlPresent) {
|
||||
barValue.open = Number(response.o[i]);
|
||||
barValue.high = Number(response.h[i]);
|
||||
barValue.low = Number(response.l[i]);
|
||||
barValue.open = parseFloat(response.o[i]);
|
||||
barValue.high = parseFloat(response.h[i]);
|
||||
barValue.low = parseFloat(response.l[i]);
|
||||
}
|
||||
if (volumePresent) {
|
||||
barValue.volume = Number(response.v[i]);
|
||||
barValue.volume = parseFloat(response.v[i]);
|
||||
}
|
||||
bars.push(barValue);
|
||||
}
|
||||
|
||||
@@ -6,6 +6,10 @@ function extractField(data, field, arrayIndex, valueIsArray) {
|
||||
}
|
||||
return value;
|
||||
}
|
||||
function symbolWithCurrencyKey(symbol, currency) {
|
||||
// here we're using a separator that quite possible shouldn't be in a real symbol name
|
||||
return symbol + (currency !== undefined ? '_%|#|%_' + currency : '');
|
||||
}
|
||||
var SymbolsStorage = /** @class */ (function () {
|
||||
function SymbolsStorage(datafeedUrl, datafeedSupportedResolutions, requester) {
|
||||
this._exchangesList = ['NYSE', 'FOREX', 'AMEX'];
|
||||
@@ -22,10 +26,10 @@ var SymbolsStorage = /** @class */ (function () {
|
||||
});
|
||||
}
|
||||
// BEWARE: this function does not consider symbol's exchange
|
||||
SymbolsStorage.prototype.resolveSymbol = function (symbolName) {
|
||||
SymbolsStorage.prototype.resolveSymbol = function (symbolName, currencyCode) {
|
||||
var _this = this;
|
||||
return this._readyPromise.then(function () {
|
||||
var symbolInfo = _this._symbolsInfo[symbolName];
|
||||
var symbolInfo = _this._symbolsInfo[symbolWithCurrencyKey(symbolName, currencyCode)];
|
||||
if (symbolInfo === undefined) {
|
||||
return Promise.reject('invalid symbol');
|
||||
}
|
||||
@@ -129,6 +133,7 @@ var SymbolsStorage = /** @class */ (function () {
|
||||
var listedExchange = extractField(data, 'exchange-listed', symbolIndex);
|
||||
var tradedExchange = extractField(data, 'exchange-traded', symbolIndex);
|
||||
var fullName = tradedExchange + ':' + symbolName;
|
||||
var currencyCode = extractField(data, 'currency-code', symbolIndex);
|
||||
var ticker = tickerPresent ? extractField(data, 'ticker', symbolIndex) : symbolName;
|
||||
var symbolInfo = {
|
||||
ticker: ticker,
|
||||
@@ -137,6 +142,8 @@ var SymbolsStorage = /** @class */ (function () {
|
||||
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),
|
||||
@@ -159,6 +166,11 @@ var SymbolsStorage = /** @class */ (function () {
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -161,8 +161,9 @@ var UDFCompatibleDatafeedBase = /** @class */ (function () {
|
||||
.catch(onResult.bind(null, []));
|
||||
}
|
||||
};
|
||||
UDFCompatibleDatafeedBase.prototype.resolveSymbol = function (symbolName, onResolve, onError) {
|
||||
UDFCompatibleDatafeedBase.prototype.resolveSymbol = function (symbolName, onResolve, onError, extension) {
|
||||
logMessage('Resolve requested');
|
||||
var currencyCode = extension && extension.currencyCode;
|
||||
var resolveRequestStartTime = Date.now();
|
||||
function onResultReady(symbolInfo) {
|
||||
logMessage("Symbol resolved: " + (Date.now() - resolveRequestStartTime) + "ms");
|
||||
@@ -172,6 +173,9 @@ var UDFCompatibleDatafeedBase = /** @class */ (function () {
|
||||
var params = {
|
||||
symbol: symbolName,
|
||||
};
|
||||
if (currencyCode !== undefined) {
|
||||
params.currencyCode = currencyCode;
|
||||
}
|
||||
this._send('symbols', params)
|
||||
.then(function (response) {
|
||||
if (response.s !== undefined) {
|
||||
@@ -190,7 +194,7 @@ var UDFCompatibleDatafeedBase = /** @class */ (function () {
|
||||
if (this._symbolsStorage === null) {
|
||||
throw new Error('UdfCompatibleDatafeed: inconsistent configuration (symbols storage)');
|
||||
}
|
||||
this._symbolsStorage.resolveSymbol(symbolName).then(onResultReady).catch(onError);
|
||||
this._symbolsStorage.resolveSymbol(symbolName, currencyCode).then(onResultReady).catch(onError);
|
||||
}
|
||||
};
|
||||
UDFCompatibleDatafeedBase.prototype.getBars = function (symbolInfo, resolution, rangeStartDate, rangeEndDate, onResult, onError) {
|
||||
|
||||
Reference in New Issue
Block a user