From 94dd7664058545c2d80876422ea477078bd67e8b Mon Sep 17 00:00:00 2001 From: Tzion Date: Thu, 6 Jan 2022 12:49:23 +0200 Subject: [PATCH] Do not load bar with the same timestamp as the latest bar; This can happen when joining data from file and live data (backfilling). In this case, if the last bar of the file data is of the same time as the bar in the live data - both of them will be added. --- backtrader/feeds/ibdata.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/backtrader/feeds/ibdata.py b/backtrader/feeds/ibdata.py index 6301f2c5c..aa1ad2290 100644 --- a/backtrader/feeds/ibdata.py +++ b/backtrader/feeds/ibdata.py @@ -667,7 +667,7 @@ def _load_rtbar(self, rtbar, hist=False): # The historical data has the same data but with 'date' instead of # 'time' for datetime dt = date2num(rtbar.time if not hist else rtbar.date) - if dt < self.lines.datetime[-1] and not self.p.latethrough: + if dt <= self.lines.datetime[-1] and not self.p.latethrough: return False # cannot deliver earlier than already delivered self.lines.datetime[0] = dt @@ -687,7 +687,7 @@ def _load_rtvolume(self, rtvol): # contains open/high/low/close/volume prices # Datetime transformation dt = date2num(rtvol.datetime) - if dt < self.lines.datetime[-1] and not self.p.latethrough: + if dt <= self.lines.datetime[-1] and not self.p.latethrough: return False # cannot deliver earlier than already delivered self.lines.datetime[0] = dt