From 932e5e2773714229ed5b8903a3ebbc2c60619e2d Mon Sep 17 00:00:00 2001 From: "vn.py" Date: Tue, 2 Oct 2018 13:55:47 +0800 Subject: [PATCH] =?UTF-8?q?[Fix]=E4=BF=AE=E5=A4=8D=E5=8F=82=E6=95=B0?= =?UTF-8?q?=E4=BC=98=E5=8C=96=E7=9A=84bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- vnpy/trader/app/ctaStrategy/ctaBacktesting.py | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/vnpy/trader/app/ctaStrategy/ctaBacktesting.py b/vnpy/trader/app/ctaStrategy/ctaBacktesting.py index 570e8be5..19267ef9 100644 --- a/vnpy/trader/app/ctaStrategy/ctaBacktesting.py +++ b/vnpy/trader/app/ctaStrategy/ctaBacktesting.py @@ -913,13 +913,13 @@ class BacktestingEngine(object): self.output('setting: %s' %str(setting)) self.initStrategy(strategyClass, setting) self.runBacktesting() - df = self.calculateDailyResult() - df, d = self.calculateDailyStatistics(df) + self.calculateDailyResult() + d, result = self.calculateDailyStatistics() try: - targetValue = d[targetName] + targetValue = result[targetName] except KeyError: targetValue = 0 - resultList.append(([str(setting)], targetValue, d)) + resultList.append(([str(setting)], targetValue, result)) # 显示结果 resultList.sort(reverse=True, key=lambda result:result[1]) @@ -1387,11 +1387,11 @@ def optimize(strategyClass, setting, targetName, engine.initStrategy(strategyClass, setting) engine.runBacktesting() - df = engine.calculateDailyResult() - df, d = engine.calculateDailyStatistics(df) + self.calculateDailyResult() + d, result = self.calculateDailyStatistics() try: - targetValue = d[targetName] + targetValue = result[targetName] except KeyError: - targetValue = 0 - return (str(setting), targetValue, d) + targetValue = 0 + return (str(setting), targetValue, result)