From 6ae6b5724d21ea3aafb1d9c0871cb44431d058cf Mon Sep 17 00:00:00 2001 From: T <52665225+valamidev@users.noreply.github.com> Date: Mon, 14 Oct 2024 09:23:39 +0200 Subject: [PATCH] Fix a small bug --- __tests__/Tickdata.test.ts | 4 ++-- package.json | 2 +- src/index.ts | 4 +++- 3 files changed, 6 insertions(+), 4 deletions(-) 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 });