From 6c24d46d6a9e7b13eae4aa1c48a6f5da7ed23b9a Mon Sep 17 00:00:00 2001 From: "vn.py" Date: Thu, 30 May 2019 12:30:22 +0800 Subject: [PATCH] [Add] function for get backtesting trade/order data --- vnpy/app/cta_backtester/engine.py | 10 +++++++++- vnpy/app/cta_strategy/backtesting.py | 12 ++++++++++++ 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/vnpy/app/cta_backtester/engine.py b/vnpy/app/cta_backtester/engine.py index dec4492b..5281d0fc 100644 --- a/vnpy/app/cta_backtester/engine.py +++ b/vnpy/app/cta_backtester/engine.py @@ -339,7 +339,7 @@ class BacktesterEngine(BaseEngine): self.write_log(f"{vt_symbol}-{interval}开始下载历史数据") symbol, exchange = extract_vt_symbol(vt_symbol) - + req = HistoryRequest( symbol=symbol, exchange=exchange, @@ -390,3 +390,11 @@ class BacktesterEngine(BaseEngine): self.thread.start() return True + + def get_all_trades(self): + """""" + return self.backtesting_engine.get_all_trades() + + def get_all_orders(self): + """""" + return self.backtesting_engine.get_all_orders() diff --git a/vnpy/app/cta_strategy/backtesting.py b/vnpy/app/cta_strategy/backtesting.py index 3431a409..852217db 100644 --- a/vnpy/app/cta_strategy/backtesting.py +++ b/vnpy/app/cta_strategy/backtesting.py @@ -1019,6 +1019,18 @@ class BacktestingEngine: """ print(f"{datetime.now()}\t{msg}") + def get_all_trades(self): + """ + Return all trade data of current backtesting result. + """ + return self.trades.values() + + def get_all_orders(self): + """ + Return all limit order data of current backtesting result. + """ + return self.limit_orders.values() + class DailyResult: """"""