diff --git a/__tests__/Tickdata.test.ts b/__tests__/Tickdata.test.ts index e9d66f6..e0b5ca2 100644 --- a/__tests__/Tickdata.test.ts +++ b/__tests__/Tickdata.test.ts @@ -390,7 +390,7 @@ test("Trades convert to Candlestick", () => { high: 0.00224, low: 0.00224, close: 0.00224, - volume: 8916, + volume: 4458, }); // 27 candles, without open (unfinished) candle @@ -415,7 +415,7 @@ test("Trades convert to Candlestick, with filter", () => { high: 0.00224, low: 0.00224, close: 0.00224, - volume: 8916, + volume: 4458, }); // 24 candles, without open (unfinished) candle diff --git a/package.json b/package.json index ef1a79e..f64b09e 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "candlestick-convert", - "version": "6.0.0", + "version": "6.0.1", "description": "OHLCV Candlestick converter and batcher with Typescript support", "main": "build/index.js", "scripts": { diff --git a/src/index.ts b/src/index.ts index 6492243..78313f7 100644 --- a/src/index.ts +++ b/src/index.ts @@ -292,7 +292,9 @@ export const batchTicksToCandle = ( if (timeOpen == trade.time) { low = Math.min(trade.price, low); high = Math.max(trade.price, high); - volume += trade.quantity; + if (i > 0) { + volume += trade.quantity; + } close = trade.price; } else { result.push({ time: timeOpen, open, high, low, close, volume });