From 86b639c8c969c0f17e5b6269aa840b3708a8c596 Mon Sep 17 00:00:00 2001 From: Denis Tereshkin Date: Mon, 3 May 2021 09:53:29 +0700 Subject: [PATCH] Bar aggregation fix --- qhp-download.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/qhp-download.py b/qhp-download.py index 2071707..d4373b0 100644 --- a/qhp-download.py +++ b/qhp-download.py @@ -44,7 +44,8 @@ class BarAggregator: b_low = self.low b_close = self.close b_volume = self.volume - b_timestamp = self.timestamp + if self.current_bar_number is not None: + b_timestamp = datetime.datetime.fromtimestamp(self.current_bar_number * self.timeframe) self.open_ = open_ self.high = high @@ -70,7 +71,7 @@ class BarAggregator: b_low = self.low b_close = self.close b_volume = self.volume - b_timestamp = self.timestamp + b_timestamp = datetime.datetime.fromtimestamp(self.timeframe * ( self.timestamp.timestamp() // self.timeframe)) return (b_timestamp, b_open, b_high, b_low, b_close, b_volume) @@ -122,6 +123,7 @@ def main(): if resp != b'OK': errmsg = s.recv_string() print("Error:", errmsg) + sys.exit(1) line_count = 0