From 20a76486229141008778b0f8a160877fad538587 Mon Sep 17 00:00:00 2001 From: "vn.py" Date: Sun, 30 Jun 2019 17:17:46 +0800 Subject: [PATCH] [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)