From add46ddb33d135adc6ae0f3f36f4efbcb19d669d Mon Sep 17 00:00:00 2001 From: Administrator <admin@example.com> Date: 星期一, 03 六月 2024 20:43:34 +0800 Subject: [PATCH] 可转债回撤 --- trade/backtest_trade.py | 29 +++++++++++++++++------------ 1 files changed, 17 insertions(+), 12 deletions(-) diff --git a/trade/backtest_trade.py b/trade/backtest_trade.py index bd112fb..34e1cde 100644 --- a/trade/backtest_trade.py +++ b/trade/backtest_trade.py @@ -3,21 +3,26 @@ """ # 鎸佷粨瀛楀吀 from log_module import log_export +from log_module.log import logger_debug from trade.buy_strategy import BuyStrategyDataManager position_dict = {} def start_backtest(date): - __BuyStrategyDataManager = BuyStrategyDataManager() - # 鍥炴挙 - markets_dict = log_export.load_latest_market_info(date) - for code in markets_dict: - __BuyStrategyDataManager.add_market_info(markets_dict[code]) - transactions = log_export.load_transactions(date) - for t in transactions: - code = t["SecurityID"] - need_buy = __BuyStrategyDataManager.add_transaction_info(t) - if need_buy and code not in position_dict: - # 鎸佷粨缁撴灉淇濆瓨 - position_dict[code] = t \ No newline at end of file + try: + __BuyStrategyDataManager = BuyStrategyDataManager() + # 鍥炴挙 + markets_dict = log_export.load_latest_market_info(date) + for code in markets_dict: + __BuyStrategyDataManager.add_market_info(markets_dict[code]) + transactions = log_export.load_transactions(date) + for t in transactions: + code = t["SecurityID"] + need_buy = __BuyStrategyDataManager.add_transaction_info(t) + if need_buy and code not in position_dict: + # 鎸佷粨缁撴灉淇濆瓨 + position_dict[code] = t + logger_debug.info(f"鍥炴祴涓嬪崟锛歿t}") + except Exception as e: + logger_debug.exception(e) \ No newline at end of file -- Gitblit v1.8.0