tradingview-ws
Advanced tools
Comparing version 0.0.2 to 0.0.3
@@ -122,4 +122,5 @@ "use strict"; | ||
// loaded all requested candles | ||
if (event.name === 'series_completed') { | ||
if (currentSymCandles.length % batchSize === 0 && (!amount || currentSymCandles.length < amount)) { | ||
if (['series_completed', 'symbol_error'].includes(event.name)) { | ||
const loadedCount = currentSymCandles.length; | ||
if (loadedCount > 0 && loadedCount % batchSize === 0 && (!amount || loadedCount < amount)) { | ||
connection.send('request_more_data', [chartSession, 'sds_1', batchSize]); | ||
@@ -126,0 +127,0 @@ return; |
{ | ||
"name": "tradingview-ws", | ||
"version": "0.0.2", | ||
"version": "0.0.3", | ||
"description": "Tradingview websocket API", | ||
@@ -5,0 +5,0 @@ "repository": "https://github.com/endenwer/tradingview-ws.git", |
@@ -54,4 +54,4 @@ ## Tradingview websockets integration | ||
* `subscribe: (handler: Subscriber) => Unsubscriber` - subscribe to wesockets events | ||
* `send: (name: string, params: any[]) => void` - send command to websocket | ||
* `subscribe: (handler: Subscriber) => Unsubscriber` - subscribe to websockets events | ||
* `send: (name: string, params: any[]) => void` - send command to websockets | ||
* `close: () => Promise<void>` - close the connection |
@@ -34,2 +34,14 @@ import { expect } from 'chai' | ||
}) | ||
it('returns empty candles for incorrect symbol', async function() { | ||
const connection = await connect() | ||
const candles = await getCandles({ | ||
connection, | ||
symbols: ['FX:AUDCAD', 'UNKNOWN'], | ||
}) | ||
await connection.close() | ||
expect(candles[0].length).to.gt(10_000) | ||
expect(candles[1].length).to.eq(0) | ||
}) | ||
}) |
@@ -169,4 +169,5 @@ import axios from 'axios' | ||
// loaded all requested candles | ||
if (event.name === 'series_completed') { | ||
if (currentSymCandles.length % batchSize === 0 && (!amount || currentSymCandles.length < amount)) { | ||
if (['series_completed', 'symbol_error'].includes(event.name)) { | ||
const loadedCount = currentSymCandles.length | ||
if (loadedCount > 0 && loadedCount % batchSize === 0 && (!amount || loadedCount < amount)) { | ||
connection.send('request_more_data', [chartSession, 'sds_1', batchSize]) | ||
@@ -173,0 +174,0 @@ return |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
27442
10
437