Release v30.0.0 (from a7798f5b2167d88489048eb7e1527e9bf896690e)
This commit is contained in:
2
datafeeds/udf/dist/bundle.js
vendored
2
datafeeds/udf/dist/bundle.js
vendored
File diff suppressed because one or more lines are too long
@@ -5,7 +5,7 @@ const isLoggingEnabled = false;
|
||||
export function logMessage(message) {
|
||||
if (isLoggingEnabled) {
|
||||
const now = new Date();
|
||||
// tslint:disable-next-line:no-console
|
||||
// eslint-disable-next-line no-console
|
||||
console.log(`${now.toLocaleTimeString()}.${now.getMilliseconds()}> ${message}`);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -33,7 +33,7 @@ export class HistoryProvider {
|
||||
catch (e) {
|
||||
if (e instanceof Error || typeof e === 'string') {
|
||||
const reasonString = getErrorMessage(e);
|
||||
// tslint:disable-next-line:no-console
|
||||
// eslint-disable-next-line no-console
|
||||
console.warn(`HistoryProvider: getBars() failed, error=${reasonString}`);
|
||||
reject(reasonString);
|
||||
}
|
||||
@@ -86,7 +86,7 @@ export class HistoryProvider {
|
||||
*/
|
||||
if (e instanceof Error || typeof e === 'string') {
|
||||
const reasonString = getErrorMessage(e);
|
||||
// tslint:disable-next-line:no-console
|
||||
// eslint-disable-next-line no-console
|
||||
console.warn(`HistoryProvider: getBars() warning during followup request, error=${reasonString}`);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,10 @@
|
||||
import { getErrorMessage, logMessage, } from './helpers';
|
||||
function extractField(data, field, arrayIndex, valueIsArray) {
|
||||
if (!(field in data)) {
|
||||
// eslint-disable-next-line no-console
|
||||
console.warn(`Field "${String(field)}" not present in response`);
|
||||
return undefined;
|
||||
}
|
||||
const value = data[field];
|
||||
if (Array.isArray(value) && (!valueIsArray || Array.isArray(value[0]))) {
|
||||
return value[arrayIndex];
|
||||
@@ -21,7 +26,7 @@ export class SymbolsStorage {
|
||||
this._readyPromise = this._init();
|
||||
this._readyPromise.catch((error) => {
|
||||
// seems it is impossible
|
||||
// tslint:disable-next-line:no-console
|
||||
// eslint-disable-next-line no-console
|
||||
console.error(`SymbolsStorage: Cannot init, error=${error.toString()}`);
|
||||
});
|
||||
}
|
||||
@@ -116,6 +121,7 @@ export class SymbolsStorage {
|
||||
}
|
||||
_onExchangeDataReceived(exchange, data) {
|
||||
let symbolIndex = 0;
|
||||
let fullName;
|
||||
try {
|
||||
const symbolsCount = data.symbol.length;
|
||||
const tickerPresent = data.ticker !== undefined;
|
||||
@@ -123,7 +129,19 @@ export class SymbolsStorage {
|
||||
const symbolName = data.symbol[symbolIndex];
|
||||
const listedExchange = extractField(data, 'exchange-listed', symbolIndex);
|
||||
const tradedExchange = extractField(data, 'exchange-traded', symbolIndex);
|
||||
const fullName = tradedExchange + ':' + symbolName;
|
||||
if (listedExchange !== undefined || tradedExchange !== undefined) {
|
||||
// eslint-disable-next-line no-console
|
||||
console.warn('Starting from v30, both "exchange-listed" and "exchange-traded" fields are deprecated. Please use "exchange_listed_name" instead.');
|
||||
fullName = tradedExchange + ':' + symbolName;
|
||||
}
|
||||
const exchangeListedName = extractField(data, 'exchange_listed_name', symbolIndex);
|
||||
if (exchangeListedName === undefined) {
|
||||
// eslint-disable-next-line no-console
|
||||
console.warn('Starting from v30, both "exchange-listed" and "exchange-traded" fields are deprecated. Please use "exchange_listed_name" instead.');
|
||||
}
|
||||
else {
|
||||
fullName = exchangeListedName + ':' + symbolName;
|
||||
}
|
||||
const currencyCode = extractField(data, 'currency-code', symbolIndex);
|
||||
const unitId = extractField(data, 'unit-id', symbolIndex);
|
||||
const ticker = tickerPresent ? extractField(data, 'ticker', symbolIndex) : symbolName;
|
||||
@@ -132,7 +150,7 @@ export class SymbolsStorage {
|
||||
name: symbolName,
|
||||
base_name: [listedExchange + ':' + symbolName],
|
||||
listed_exchange: listedExchange,
|
||||
exchange: tradedExchange,
|
||||
exchange: exchangeListedName || listedExchange,
|
||||
currency_code: currencyCode,
|
||||
original_currency_code: extractField(data, 'original-currency-code', symbolIndex),
|
||||
unit_id: unitId,
|
||||
@@ -160,11 +178,15 @@ export class SymbolsStorage {
|
||||
};
|
||||
this._symbolsInfo[ticker] = symbolInfo;
|
||||
this._symbolsInfo[symbolName] = symbolInfo;
|
||||
this._symbolsInfo[fullName] = symbolInfo;
|
||||
if (fullName !== undefined) {
|
||||
this._symbolsInfo[fullName] = symbolInfo;
|
||||
}
|
||||
if (currencyCode !== undefined || unitId !== undefined) {
|
||||
this._symbolsInfo[symbolKey(ticker, currencyCode, unitId)] = symbolInfo;
|
||||
this._symbolsInfo[symbolKey(symbolName, currencyCode, unitId)] = symbolInfo;
|
||||
this._symbolsInfo[symbolKey(fullName, currencyCode, unitId)] = symbolInfo;
|
||||
if (fullName !== undefined) {
|
||||
this._symbolsInfo[symbolKey(fullName, currencyCode, unitId)] = symbolInfo;
|
||||
}
|
||||
}
|
||||
this._symbolsList.push(symbolName);
|
||||
}
|
||||
|
||||
@@ -22,7 +22,7 @@ const isLoggingEnabled = false;
|
||||
export function logMessage(message: string): void {
|
||||
if (isLoggingEnabled) {
|
||||
const now = new Date();
|
||||
// tslint:disable-next-line:no-console
|
||||
// eslint-disable-next-line no-console
|
||||
console.log(`${now.toLocaleTimeString()}.${now.getMilliseconds()}> ${message}`);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -14,7 +14,7 @@ import {
|
||||
} from './helpers';
|
||||
|
||||
import { IRequester } from './irequester';
|
||||
// tslint:disable: no-any
|
||||
/* eslint-disable @typescript-eslint/no-explicit-any */
|
||||
interface HistoryPartialDataResponse extends UdfOkResponse {
|
||||
t: any;
|
||||
c: any;
|
||||
@@ -32,7 +32,7 @@ interface HistoryFullDataResponse extends UdfOkResponse {
|
||||
l: any;
|
||||
v: any;
|
||||
}
|
||||
// tslint:enable: no-any
|
||||
/* eslint-enable @typescript-eslint/no-explicit-any */
|
||||
interface HistoryNoDataResponse extends UdfResponse {
|
||||
s: 'no_data';
|
||||
nextTime?: number;
|
||||
@@ -122,7 +122,7 @@ export class HistoryProvider {
|
||||
} catch (e: unknown) {
|
||||
if (e instanceof Error || typeof e === 'string') {
|
||||
const reasonString = getErrorMessage(e);
|
||||
// tslint:disable-next-line:no-console
|
||||
// eslint-disable-next-line no-console
|
||||
console.warn(
|
||||
`HistoryProvider: getBars() failed, error=${reasonString}`
|
||||
);
|
||||
@@ -183,7 +183,7 @@ export class HistoryProvider {
|
||||
*/
|
||||
if (e instanceof Error || typeof e === 'string') {
|
||||
const reasonString = getErrorMessage(e);
|
||||
// tslint:disable-next-line:no-console
|
||||
// eslint-disable-next-line no-console
|
||||
console.warn(
|
||||
`HistoryProvider: getBars() warning during followup request, error=${reasonString}`
|
||||
);
|
||||
|
||||
@@ -21,9 +21,17 @@ interface ExchangeDataResponseSymbolData {
|
||||
'timezone': LibrarySymbolInfo['timezone'];
|
||||
'description': string;
|
||||
|
||||
/**
|
||||
* @deprecated Use 'exchange_listed_name' instead
|
||||
*/
|
||||
'exchange-listed': string;
|
||||
/**
|
||||
* @deprecated Use 'exchange_listed_name' instead
|
||||
*/
|
||||
'exchange-traded': string;
|
||||
|
||||
'exchange_listed_name': string;
|
||||
|
||||
'session-regular': string;
|
||||
'corrections'?: string;
|
||||
'session-holidays'?: string;
|
||||
@@ -59,7 +67,7 @@ interface ExchangeDataResponseSymbolData {
|
||||
|
||||
// Here is some black magic with types to get compile-time checks of names and types
|
||||
type PickArrayedObjectFields<T> = Pick<T, {
|
||||
// tslint:disable-next-line:no-any
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
[K in keyof T]-?: NonNullable<T[K]> extends any[] ? K : never;
|
||||
}[keyof T]>;
|
||||
|
||||
@@ -76,7 +84,13 @@ type ExchangeDataResponse =
|
||||
|
||||
function extractField<Field extends keyof ExchangeDataResponseNonArrayedSymbolData>(data: ExchangeDataResponse, field: Field, arrayIndex: number): ExchangeDataResponseNonArrayedSymbolData[Field];
|
||||
function extractField<Field extends keyof ExchangeDataResponseArrayedSymbolData>(data: ExchangeDataResponse, field: Field, arrayIndex: number, valueIsArray: true): ExchangeDataResponseArrayedSymbolData[Field];
|
||||
function extractField<Field extends keyof ExchangeDataResponseSymbolData>(data: ExchangeDataResponse, field: Field, arrayIndex: number, valueIsArray?: boolean): ExchangeDataResponseSymbolData[Field] {
|
||||
function extractField<Field extends keyof ExchangeDataResponseSymbolData>(data: ExchangeDataResponse, field: Field, arrayIndex: number, valueIsArray?: boolean): ExchangeDataResponseSymbolData[Field] | undefined {
|
||||
if (!(field in data)) {
|
||||
// eslint-disable-next-line no-console
|
||||
console.warn(`Field "${String(field)}" not present in response`);
|
||||
return undefined;
|
||||
}
|
||||
|
||||
const value: ExchangeDataResponse[keyof ExchangeDataResponseSymbolData] = data[field];
|
||||
|
||||
if (Array.isArray(value) && (!valueIsArray || Array.isArray(value[0]))) {
|
||||
@@ -107,7 +121,7 @@ export class SymbolsStorage {
|
||||
this._readyPromise = this._init();
|
||||
this._readyPromise.catch((error: Error) => {
|
||||
// seems it is impossible
|
||||
// tslint:disable-next-line:no-console
|
||||
// eslint-disable-next-line no-console
|
||||
console.error(`SymbolsStorage: Cannot init, error=${error.toString()}`);
|
||||
});
|
||||
}
|
||||
@@ -229,6 +243,7 @@ export class SymbolsStorage {
|
||||
|
||||
private _onExchangeDataReceived(exchange: string, data: ExchangeDataResponse): void {
|
||||
let symbolIndex = 0;
|
||||
let fullName;
|
||||
|
||||
try {
|
||||
const symbolsCount = data.symbol.length;
|
||||
@@ -236,9 +251,23 @@ export class SymbolsStorage {
|
||||
|
||||
for (; symbolIndex < symbolsCount; ++symbolIndex) {
|
||||
const symbolName = data.symbol[symbolIndex];
|
||||
|
||||
const listedExchange = extractField(data, 'exchange-listed', symbolIndex);
|
||||
const tradedExchange = extractField(data, 'exchange-traded', symbolIndex);
|
||||
const fullName = tradedExchange + ':' + symbolName;
|
||||
if (listedExchange !== undefined || tradedExchange !== undefined) {
|
||||
// eslint-disable-next-line no-console
|
||||
console.warn('Starting from v30, both "exchange-listed" and "exchange-traded" fields are deprecated. Please use "exchange_listed_name" instead.');
|
||||
fullName = tradedExchange + ':' + symbolName;
|
||||
}
|
||||
|
||||
const exchangeListedName = extractField(data, 'exchange_listed_name', symbolIndex);
|
||||
if (exchangeListedName === undefined) {
|
||||
// eslint-disable-next-line no-console
|
||||
console.warn('Starting from v30, both "exchange-listed" and "exchange-traded" fields are deprecated. Please use "exchange_listed_name" instead.');
|
||||
} else {
|
||||
fullName = exchangeListedName + ':' + symbolName;
|
||||
}
|
||||
|
||||
const currencyCode = extractField(data, 'currency-code', symbolIndex);
|
||||
const unitId = extractField(data, 'unit-id', symbolIndex);
|
||||
|
||||
@@ -249,7 +278,7 @@ export class SymbolsStorage {
|
||||
name: symbolName,
|
||||
base_name: [listedExchange + ':' + symbolName],
|
||||
listed_exchange: listedExchange,
|
||||
exchange: tradedExchange,
|
||||
exchange: exchangeListedName || listedExchange,
|
||||
currency_code: currencyCode,
|
||||
original_currency_code: extractField(data, 'original-currency-code', symbolIndex),
|
||||
unit_id: unitId,
|
||||
@@ -278,11 +307,15 @@ export class SymbolsStorage {
|
||||
|
||||
this._symbolsInfo[ticker] = symbolInfo;
|
||||
this._symbolsInfo[symbolName] = symbolInfo;
|
||||
this._symbolsInfo[fullName] = symbolInfo;
|
||||
if (fullName !== undefined) {
|
||||
this._symbolsInfo[fullName] = symbolInfo;
|
||||
}
|
||||
if (currencyCode !== undefined || unitId !== undefined) {
|
||||
this._symbolsInfo[symbolKey(ticker, currencyCode, unitId)] = symbolInfo;
|
||||
this._symbolsInfo[symbolKey(symbolName, currencyCode, unitId)] = symbolInfo;
|
||||
this._symbolsInfo[symbolKey(fullName, currencyCode, unitId)] = symbolInfo;
|
||||
if (fullName !== undefined) {
|
||||
this._symbolsInfo[symbolKey(fullName, currencyCode, unitId)] = symbolInfo;
|
||||
}
|
||||
}
|
||||
|
||||
this._symbolsList.push(symbolName);
|
||||
|
||||
Reference in New Issue
Block a user