From 15559a626dfe6bac321618dd43218623f147ce53 Mon Sep 17 00:00:00 2001 From: "vn.py" Date: Thu, 30 May 2019 13:58:23 +0800 Subject: [PATCH] [Add] function for querying daily results in backtesting --- vnpy/app/cta_backtester/engine.py | 4 ++++ vnpy/app/cta_strategy/backtesting.py | 11 +++++++++-- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/vnpy/app/cta_backtester/engine.py b/vnpy/app/cta_backtester/engine.py index 5281d0fc..bfb7b91d 100644 --- a/vnpy/app/cta_backtester/engine.py +++ b/vnpy/app/cta_backtester/engine.py @@ -398,3 +398,7 @@ class BacktesterEngine(BaseEngine): def get_all_orders(self): """""" return self.backtesting_engine.get_all_orders() + + def get_all_daily_results(self): + """""" + return self.backtesting_engine.get_all_daily_results() diff --git a/vnpy/app/cta_strategy/backtesting.py b/vnpy/app/cta_strategy/backtesting.py index 852217db..bdeb6295 100644 --- a/vnpy/app/cta_strategy/backtesting.py +++ b/vnpy/app/cta_strategy/backtesting.py @@ -825,6 +825,7 @@ class BacktestingEngine: status=Status.ALLTRADED, gateway_name=self.gateway_name, ) + order.datetime = self.datetime self.limit_orders[order.vt_orderid] = order @@ -943,6 +944,7 @@ class BacktestingEngine: status=Status.NOTTRADED, gateway_name=self.gateway_name, ) + order.datetime = self.datetime self.active_limit_orders[order.vt_orderid] = order self.limit_orders[order.vt_orderid] = order @@ -1023,14 +1025,19 @@ class BacktestingEngine: """ Return all trade data of current backtesting result. """ - return self.trades.values() + return list(self.trades.values()) def get_all_orders(self): """ Return all limit order data of current backtesting result. """ - return self.limit_orders.values() + return list(self.limit_orders.values()) + def get_all_daily_results(self): + """ + Return all daily result data. + """ + return list(self.daily_results.values()) class DailyResult: """"""