From 85c72c51bdd490cfdc6db67f38fa7f45a5e57c23 Mon Sep 17 00:00:00 2001 From: Jokers Date: Sat, 29 Jun 2019 01:17:10 +0800 Subject: [PATCH 1/2] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E5=8A=A0=E8=BD=BD?= =?UTF-8?q?=E5=8E=86=E5=8F=B2=E6=95=B0=E6=8D=AE=E7=9A=84bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- vnpy/app/cta_strategy/backtesting.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/vnpy/app/cta_strategy/backtesting.py b/vnpy/app/cta_strategy/backtesting.py index fa7a725e..a8887e8c 100644 --- a/vnpy/app/cta_strategy/backtesting.py +++ b/vnpy/app/cta_strategy/backtesting.py @@ -235,14 +235,14 @@ class BacktestingEngine: self.exchange, self.interval, start, - end + min(end, self.end) ) else: data = load_tick_data( self.symbol, self.exchange, start, - end + min(end, self.end) ) self.history_data.extend(data) From 20a76486229141008778b0f8a160877fad538587 Mon Sep 17 00:00:00 2001 From: "vn.py" Date: Sun, 30 Jun 2019 17:17:46 +0800 Subject: [PATCH 2/2] [Mod] reduce duplicate code line --- vnpy/app/cta_strategy/backtesting.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/vnpy/app/cta_strategy/backtesting.py b/vnpy/app/cta_strategy/backtesting.py index a8887e8c..d5d8b0f6 100644 --- a/vnpy/app/cta_strategy/backtesting.py +++ b/vnpy/app/cta_strategy/backtesting.py @@ -229,20 +229,22 @@ class BacktestingEngine: progress = 0 while start < self.end: + end = min(end, self.end) # Make sure end time stays within set range + if self.mode == BacktestingMode.BAR: data = load_bar_data( self.symbol, self.exchange, self.interval, start, - min(end, self.end) + end ) else: data = load_tick_data( self.symbol, self.exchange, start, - min(end, self.end) + end ) self.history_data.extend(data)