This commit is contained in:
vn.py 2018-08-13 00:54:32 +08:00
parent 97bfabe191
commit cd1d939c58

View File

@ -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()