Release v23.038 (from e012cb8f)
Fixes tradingview/charting_library#4522 Fixes tradingview/charting_library#5348 Fixes tradingview/charting_library#5573 Fixes tradingview/charting_library#5726 Fixes tradingview/charting_library#6039 Fixes tradingview/charting_library#6215 Fixes tradingview/charting_library#6500 Fixes tradingview/charting_library#6550 Fixes tradingview/charting_library#6559 Fixes tradingview/charting_library#6572 Fixes tradingview/charting_library#6617 Fixes tradingview/charting_library#6659 Fixes tradingview/charting_library#6678 Fixes tradingview/charting_library#6695 Fixes tradingview/charting_library#6713 Fixes tradingview/charting_library#6714 Fixes tradingview/charting_library#6737 Fixes tradingview/charting_library#6767 Fixes tradingview/charting_library#6783 Fixes tradingview/charting_library#6800 Fixes tradingview/charting_library#6825
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
@@ -3,9 +3,8 @@ export class QuotesPulseProvider {
|
||||
constructor(quotesProvider) {
|
||||
this._subscribers = {};
|
||||
this._requestsPending = 0;
|
||||
this._timers = null;
|
||||
this._quotesProvider = quotesProvider;
|
||||
setInterval(this._updateQuotes.bind(this, 1 /* Fast */), 10000 /* Fast */);
|
||||
setInterval(this._updateQuotes.bind(this, 0 /* General */), 60000 /* General */);
|
||||
}
|
||||
subscribeQuotes(symbols, fastSymbols, onRealtimeCallback, listenerGuid) {
|
||||
this._subscribers[listenerGuid] = {
|
||||
@@ -13,12 +12,30 @@ export class QuotesPulseProvider {
|
||||
fastSymbols: fastSymbols,
|
||||
listener: onRealtimeCallback,
|
||||
};
|
||||
this._createTimersIfRequired();
|
||||
logMessage(`QuotesPulseProvider: subscribed quotes with #${listenerGuid}`);
|
||||
}
|
||||
unsubscribeQuotes(listenerGuid) {
|
||||
delete this._subscribers[listenerGuid];
|
||||
if (Object.keys(this._subscribers).length === 0) {
|
||||
this._destroyTimers();
|
||||
}
|
||||
logMessage(`QuotesPulseProvider: unsubscribed quotes with #${listenerGuid}`);
|
||||
}
|
||||
_createTimersIfRequired() {
|
||||
if (this._timers === null) {
|
||||
const fastTimer = setInterval(this._updateQuotes.bind(this, 1 /* SymbolsType.Fast */), 10000 /* UpdateTimeouts.Fast */);
|
||||
const generalTimer = setInterval(this._updateQuotes.bind(this, 0 /* SymbolsType.General */), 60000 /* UpdateTimeouts.General */);
|
||||
this._timers = { fastTimer, generalTimer };
|
||||
}
|
||||
}
|
||||
_destroyTimers() {
|
||||
if (this._timers !== null) {
|
||||
clearInterval(this._timers.fastTimer);
|
||||
clearInterval(this._timers.generalTimer);
|
||||
this._timers = null;
|
||||
}
|
||||
}
|
||||
_updateQuotes(updateType) {
|
||||
if (this._requestsPending > 0) {
|
||||
return;
|
||||
@@ -26,7 +43,7 @@ export class QuotesPulseProvider {
|
||||
for (const listenerGuid in this._subscribers) { // tslint:disable-line:forin
|
||||
this._requestsPending++;
|
||||
const subscriptionRecord = this._subscribers[listenerGuid];
|
||||
this._quotesProvider.getQuotes(updateType === 1 /* Fast */ ? subscriptionRecord.fastSymbols : subscriptionRecord.symbols)
|
||||
this._quotesProvider.getQuotes(updateType === 1 /* SymbolsType.Fast */ ? subscriptionRecord.fastSymbols : subscriptionRecord.symbols)
|
||||
.then((data) => {
|
||||
this._requestsPending--;
|
||||
if (!this._subscribers.hasOwnProperty(listenerGuid)) {
|
||||
|
||||
@@ -127,7 +127,7 @@ export class UDFCompatibleDatafeedBase {
|
||||
searchSymbols(userInput, exchange, symbolType, onResult) {
|
||||
if (this._configuration.supports_search) {
|
||||
const params = {
|
||||
limit: 30 /* SearchItemsLimit */,
|
||||
limit: 30 /* Constants.SearchItemsLimit */,
|
||||
query: userInput.toUpperCase(),
|
||||
type: symbolType,
|
||||
exchange: exchange,
|
||||
@@ -150,7 +150,7 @@ export class UDFCompatibleDatafeedBase {
|
||||
if (this._symbolsStorage === null) {
|
||||
throw new Error('UdfCompatibleDatafeed: inconsistent configuration (symbols storage)');
|
||||
}
|
||||
this._symbolsStorage.searchSymbols(userInput, exchange, symbolType, 30 /* SearchItemsLimit */)
|
||||
this._symbolsStorage.searchSymbols(userInput, exchange, symbolType, 30 /* Constants.SearchItemsLimit */)
|
||||
.then(onResult)
|
||||
.catch(onResult.bind(null, []));
|
||||
}
|
||||
@@ -176,11 +176,44 @@ export class UDFCompatibleDatafeedBase {
|
||||
}
|
||||
this._send('symbols', params)
|
||||
.then((response) => {
|
||||
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _0, _1, _2, _3, _4;
|
||||
if (response.s !== undefined) {
|
||||
onError('unknown_symbol');
|
||||
}
|
||||
else {
|
||||
onResultReady(response);
|
||||
const symbol = response.name;
|
||||
const listedExchange = (_a = response.listed_exchange) !== null && _a !== void 0 ? _a : response['exchange-listed'];
|
||||
const tradedExchange = (_b = response.exchange) !== null && _b !== void 0 ? _b : response['exchange-traded'];
|
||||
const fullName = (_c = response.full_name) !== null && _c !== void 0 ? _c : `${tradedExchange}:${symbol}`;
|
||||
const result = {
|
||||
...response,
|
||||
name: symbol,
|
||||
base_name: [listedExchange + ':' + symbol],
|
||||
full_name: fullName,
|
||||
listed_exchange: listedExchange,
|
||||
exchange: tradedExchange,
|
||||
currency_code: (_d = response.currency_code) !== null && _d !== void 0 ? _d : response['currency-code'],
|
||||
original_currency_code: (_e = response.original_currency_code) !== null && _e !== void 0 ? _e : response['original-currency-code'],
|
||||
unit_id: (_f = response.unit_id) !== null && _f !== void 0 ? _f : response['unit-id'],
|
||||
original_unit_id: (_g = response.original_unit_id) !== null && _g !== void 0 ? _g : response['original-unit-id'],
|
||||
unit_conversion_types: (_h = response.unit_conversion_types) !== null && _h !== void 0 ? _h : response['unit-conversion-types'],
|
||||
has_intraday: (_k = (_j = response.has_intraday) !== null && _j !== void 0 ? _j : response['has-intraday']) !== null && _k !== void 0 ? _k : false,
|
||||
// tslint:disable-next-line: no-deprecation
|
||||
has_no_volume: (_l = response.has_no_volume) !== null && _l !== void 0 ? _l : response['has-no-volume'],
|
||||
visible_plots_set: (_m = response.visible_plots_set) !== null && _m !== void 0 ? _m : response['visible-plots-set'],
|
||||
minmov: (_p = (_o = response.minmovement) !== null && _o !== void 0 ? _o : response.minmov) !== null && _p !== void 0 ? _p : 0,
|
||||
minmove2: (_r = (_q = response.minmovement2) !== null && _q !== void 0 ? _q : response.minmove2) !== null && _r !== void 0 ? _r : response.minmov2,
|
||||
session: (_s = response.session) !== null && _s !== void 0 ? _s : response['session-regular'],
|
||||
session_holidays: (_t = response.session_holidays) !== null && _t !== void 0 ? _t : response['session-holidays'],
|
||||
supported_resolutions: (_w = (_v = (_u = response.supported_resolutions) !== null && _u !== void 0 ? _u : response['supported-resolutions']) !== null && _v !== void 0 ? _v : this._configuration.supported_resolutions) !== null && _w !== void 0 ? _w : [],
|
||||
has_daily: (_y = (_x = response.has_daily) !== null && _x !== void 0 ? _x : response['has-daily']) !== null && _y !== void 0 ? _y : true,
|
||||
intraday_multipliers: (_0 = (_z = response.intraday_multipliers) !== null && _z !== void 0 ? _z : response['intraday-multipliers']) !== null && _0 !== void 0 ? _0 : ['1', '5', '15', '30', '60'],
|
||||
has_weekly_and_monthly: (_1 = response.has_weekly_and_monthly) !== null && _1 !== void 0 ? _1 : response['has-weekly-and-monthly'],
|
||||
has_empty_bars: (_2 = response.has_empty_bars) !== null && _2 !== void 0 ? _2 : response['has-empty-bars'],
|
||||
volume_precision: (_3 = response.volume_precision) !== null && _3 !== void 0 ? _3 : response['volume-precision'],
|
||||
format: (_4 = response.format) !== null && _4 !== void 0 ? _4 : 'price',
|
||||
};
|
||||
onResultReady(result);
|
||||
}
|
||||
})
|
||||
.catch((reason) => {
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
"@rollup/plugin-node-resolve": "~9.0.0",
|
||||
"rollup": "~2.28.2",
|
||||
"rollup-plugin-terser": "~7.0.2",
|
||||
"typescript": "4.5.4"
|
||||
"typescript": "4.7.3"
|
||||
},
|
||||
"scripts": {
|
||||
"compile": "tsc",
|
||||
|
||||
@@ -30,16 +30,20 @@ const enum UpdateTimeouts {
|
||||
General = 60 * 1000,
|
||||
}
|
||||
|
||||
interface Timers {
|
||||
fastTimer: number;
|
||||
generalTimer: number;
|
||||
}
|
||||
|
||||
export class QuotesPulseProvider {
|
||||
private readonly _quotesProvider: IQuotesProvider;
|
||||
private readonly _subscribers: QuoteSubscribers = {};
|
||||
private _requestsPending: number = 0;
|
||||
|
||||
private _timers: Timers | null = null;
|
||||
|
||||
public constructor(quotesProvider: IQuotesProvider) {
|
||||
this._quotesProvider = quotesProvider;
|
||||
|
||||
setInterval(this._updateQuotes.bind(this, SymbolsType.Fast), UpdateTimeouts.Fast);
|
||||
setInterval(this._updateQuotes.bind(this, SymbolsType.General), UpdateTimeouts.General);
|
||||
}
|
||||
|
||||
public subscribeQuotes(symbols: string[], fastSymbols: string[], onRealtimeCallback: QuotesCallback, listenerGuid: string): void {
|
||||
@@ -48,15 +52,34 @@ export class QuotesPulseProvider {
|
||||
fastSymbols: fastSymbols,
|
||||
listener: onRealtimeCallback,
|
||||
};
|
||||
|
||||
this._createTimersIfRequired();
|
||||
logMessage(`QuotesPulseProvider: subscribed quotes with #${listenerGuid}`);
|
||||
}
|
||||
|
||||
public unsubscribeQuotes(listenerGuid: string): void {
|
||||
delete this._subscribers[listenerGuid];
|
||||
if (Object.keys(this._subscribers).length === 0) {
|
||||
this._destroyTimers();
|
||||
}
|
||||
logMessage(`QuotesPulseProvider: unsubscribed quotes with #${listenerGuid}`);
|
||||
}
|
||||
|
||||
private _createTimersIfRequired(): void {
|
||||
if (this._timers === null) {
|
||||
const fastTimer = setInterval(this._updateQuotes.bind(this, SymbolsType.Fast), UpdateTimeouts.Fast);
|
||||
const generalTimer = setInterval(this._updateQuotes.bind(this, SymbolsType.General), UpdateTimeouts.General);
|
||||
this._timers = { fastTimer, generalTimer };
|
||||
}
|
||||
}
|
||||
|
||||
private _destroyTimers(): void {
|
||||
if (this._timers !== null) {
|
||||
clearInterval(this._timers.fastTimer);
|
||||
clearInterval(this._timers.generalTimer);
|
||||
this._timers = null;
|
||||
}
|
||||
}
|
||||
|
||||
private _updateQuotes(updateType: SymbolsType): void {
|
||||
if (this._requestsPending > 0) {
|
||||
return;
|
||||
|
||||
@@ -18,6 +18,7 @@ import {
|
||||
SubscribeBarsCallback,
|
||||
TimescaleMark,
|
||||
SymbolResolveExtension,
|
||||
VisiblePlotsSet,
|
||||
} from '../../../charting_library/datafeed-api';
|
||||
|
||||
import {
|
||||
@@ -48,6 +49,32 @@ export interface UdfCompatibleConfiguration extends DatafeedConfiguration {
|
||||
|
||||
export interface ResolveSymbolResponse extends LibrarySymbolInfo {
|
||||
s: undefined;
|
||||
|
||||
'exchange-listed': string;
|
||||
'exchange-traded': string;
|
||||
|
||||
'currency-code': string;
|
||||
'unit-id': string;
|
||||
|
||||
'original-currency-code': string;
|
||||
|
||||
'original-unit-id': string;
|
||||
|
||||
'unit-conversion-types': string[];
|
||||
'has-intraday': boolean;
|
||||
'has-no-volume': boolean;
|
||||
'visible-plots-set'?: VisiblePlotsSet;
|
||||
minmovement: number;
|
||||
minmovement2?: number;
|
||||
minmov2?: number;
|
||||
'session-regular': string;
|
||||
'session-holidays': string;
|
||||
'supported-resolutions': ResolutionString[];
|
||||
'has-daily': boolean;
|
||||
'intraday-multipliers': string[];
|
||||
'has-weekly-and-monthly'?: boolean;
|
||||
'has-empty-bars'?: boolean;
|
||||
'volume-precision'?: number;
|
||||
}
|
||||
|
||||
// it is hack to let's TypeScript make code flow analysis
|
||||
@@ -286,7 +313,40 @@ export class UDFCompatibleDatafeedBase implements IExternalDatafeed, IDatafeedQu
|
||||
if (response.s !== undefined) {
|
||||
onError('unknown_symbol');
|
||||
} else {
|
||||
onResultReady(response);
|
||||
const symbol = response.name;
|
||||
const listedExchange = response.listed_exchange ?? response['exchange-listed'];
|
||||
const tradedExchange = response.exchange ?? response['exchange-traded'];
|
||||
const fullName = response.full_name ?? `${tradedExchange}:${symbol}`;
|
||||
|
||||
const result: LibrarySymbolInfo = {
|
||||
...response,
|
||||
name: symbol,
|
||||
base_name: [listedExchange + ':' + symbol],
|
||||
full_name: fullName,
|
||||
listed_exchange: listedExchange,
|
||||
exchange: tradedExchange,
|
||||
currency_code: response.currency_code ?? response['currency-code'],
|
||||
original_currency_code: response.original_currency_code ?? response['original-currency-code'],
|
||||
unit_id: response.unit_id ?? response['unit-id'],
|
||||
original_unit_id: response.original_unit_id ?? response['original-unit-id'],
|
||||
unit_conversion_types: response.unit_conversion_types ?? response['unit-conversion-types'],
|
||||
has_intraday: response.has_intraday ?? response['has-intraday'] ?? false,
|
||||
// tslint:disable-next-line: no-deprecation
|
||||
has_no_volume: response.has_no_volume ?? response['has-no-volume'],
|
||||
visible_plots_set: response.visible_plots_set ?? response['visible-plots-set'],
|
||||
minmov: response.minmovement ?? response.minmov ?? 0,
|
||||
minmove2: response.minmovement2 ?? response.minmove2 ?? response.minmov2,
|
||||
session: response.session ?? response['session-regular'],
|
||||
session_holidays: response.session_holidays ?? response['session-holidays'],
|
||||
supported_resolutions: response.supported_resolutions ?? response['supported-resolutions'] ?? this._configuration.supported_resolutions ?? [],
|
||||
has_daily: response.has_daily ?? response['has-daily'] ?? true,
|
||||
intraday_multipliers: response.intraday_multipliers ?? response['intraday-multipliers'] ?? ['1', '5', '15', '30', '60'],
|
||||
has_weekly_and_monthly: response.has_weekly_and_monthly ?? response['has-weekly-and-monthly'],
|
||||
has_empty_bars: response.has_empty_bars ?? response['has-empty-bars'],
|
||||
volume_precision: response.volume_precision ?? response['volume-precision'],
|
||||
format: response.format ?? 'price',
|
||||
};
|
||||
onResultReady(result);
|
||||
}
|
||||
})
|
||||
.catch((reason?: string | Error) => {
|
||||
|
||||
Reference in New Issue
Block a user