market-data-tradingview-ws 2.1.3 → 2.1.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/lib/client.js CHANGED
@@ -186,8 +186,14 @@ module.exports = class Client {
186
186
  #intentionalClose = false;
187
187
  #watchdogTimer = null;
188
188
  #lastMessageAt = 0;
189
+ #chartInitialLimitMax = 1500;
189
190
 
190
191
  constructor(config = {}) {
192
+ const initialLimitMax = Number(process.env.chart_initial_limit_max ?? 1500);
193
+ if (!Number.isSafeInteger(initialLimitMax) || initialLimitMax <= 0 || initialLimitMax > 40000) {
194
+ throw new RangeError('chart_initial_limit_max must be a positive safe integer no greater than 40000');
195
+ }
196
+ this.#chartInitialLimitMax = initialLimitMax;
191
197
  const cfg = config && typeof config === 'object' ? config : {};
192
198
  this.#configuredMaxChartSessions = utils.positive(cfg.max, this.#configuredMaxChartSessions);
193
199
  this.#maxChartSessions = this.#configuredMaxChartSessions;
@@ -254,8 +260,9 @@ module.exports = class Client {
254
260
  const identity = this.#validateChartIdentity({ symbol, period });
255
261
  if (!identity.ok) return identity;
256
262
 
263
+ if (typeof limit !== 'number' && typeof limit !== 'string') return { ok: false, reason: 'invalid_limit' };
257
264
  const normalizedLimit = Number(limit);
258
- if (!Number.isInteger(normalizedLimit) || normalizedLimit <= 0 || normalizedLimit > 1500) return { ok: false, reason: 'invalid_limit' };
265
+ if (!Number.isSafeInteger(normalizedLimit) || normalizedLimit <= 0 || normalizedLimit > this.#chartInitialLimitMax) return { ok: false, reason: 'invalid_limit' };
259
266
 
260
267
  return { ...identity, limit: normalizedLimit };
261
268
  }
@@ -204,7 +204,6 @@ class TradingView {
204
204
  'lp_time',
205
205
  'rtc',
206
206
  'rtc_time',
207
- 'trade',
208
207
  'bid',
209
208
  'bid_size',
210
209
  'ask',
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "market-data-tradingview-ws",
3
- "version": "2.1.3",
3
+ "version": "2.1.4",
4
4
  "description": "marketData from Tradingview ws",
5
5
  "main": "index.js",
6
6
  "scripts": {