From cd1d939c583250e989dc575c0c246bfb162d1252 Mon Sep 17 00:00:00 2001 From: "vn.py" Date: Mon, 13 Aug 2018 00:54:32 +0800 Subject: [PATCH] [Fix]Close #1035 --- vnpy/trader/app/ctaStrategy/ctaBacktesting.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/vnpy/trader/app/ctaStrategy/ctaBacktesting.py b/vnpy/trader/app/ctaStrategy/ctaBacktesting.py index 78fc6528..2fde1617 100644 --- a/vnpy/trader/app/ctaStrategy/ctaBacktesting.py +++ b/vnpy/trader/app/ctaStrategy/ctaBacktesting.py @@ -615,6 +615,11 @@ class BacktestingEngine(object): """ self.output(u'计算回测结果') + # 检查成交记录 + if not self.tradeDict: + self.output(u'成交记录为空,无法计算回测结果') + return {} + # 首先基于回测后的成交记录,计算每笔交易的盈亏 resultList = [] # 交易结果列表 @@ -971,6 +976,11 @@ class BacktestingEngine(object): """计算按日统计的交易结果""" self.output(u'计算按日统计结果') + # 检查成交记录 + if not self.tradeDict: + self.output(u'成交记录为空,无法计算回测结果') + return {} + # 将成交添加到每日交易结果中 for trade in self.tradeDict.values(): date = trade.dt.date()