回测正常,模拟交易始终不出信号是什么原因
由nature023创建,最终由small_q 被浏览 84 用户
https://bigquant.com/wiki/doc/shizhi-celve-v-10-Jhc4IN7nXK
直接克隆的知识库-平台使用文档中的样例策略(https://bigquant.com/wiki/doc/shizhi-celve-v-10-Jhc4IN7nXK),回测完全正常。但是模拟交易时,始终不出交易信号。不知道模拟交易时运行各个模块的原理和回测的原理有什么不同?
注:并不是因为22天才调仓的原因,第一天运行都不出信号。感觉在模拟交易时回测模块之前连接的模块运行结果不对,输入给回测模块的数据有误。只是个人猜测。不知道真实原因,请高手指点,谢谢!
模拟交易的id:
?notebook_id=69d83e10-9202-11ed-88b2-72d507417d56&execution_id=4233714
以下是模拟交易时的部分日志:
[2023-01-13 18:00:47.713796] INFO moduleinvoker: instruments.v2 开始运行.. [2023-01-13 18:00:47.740386] INFO moduleinvoker: 命中缓存 [2023-01-13 18:00:47.741547] INFO moduleinvoker: instruments.v2 运行完成[0.027848s]. [2023-01-13 18:00:47.745953] INFO moduleinvoker: input_features.v1 开始运行.. [2023-01-13 18:00:47.757501] INFO moduleinvoker: 命中缓存 [2023-01-13 18:00:47.758620] INFO moduleinvoker: input_features.v1 运行完成[0.012656s]. [2023-01-13 18:00:47.782897] INFO moduleinvoker: general_feature_extractor.v7 开始运行.. [2023-01-13 18:00:47.797985] INFO moduleinvoker: 命中缓存 [2023-01-13 18:00:47.799189] INFO moduleinvoker: general_feature_extractor.v7 运行完成[0.016353s]. [2023-01-13 18:00:47.805645] INFO moduleinvoker: sort.v4 开始运行.. [2023-01-13 18:00:47.827037] INFO moduleinvoker: 命中缓存 [2023-01-13 18:00:47.828241] INFO moduleinvoker: sort.v4 运行完成[0.022618s]. [2023-01-13 18:00:47.837712] INFO moduleinvoker: filter.v3 开始运行.. [2023-01-13 18:00:47.850714] INFO moduleinvoker: 命中缓存 [2023-01-13 18:00:47.851876] INFO moduleinvoker: filter.v3 运行完成[0.014201s]. [2023-01-13 18:00:51.851918] INFO moduleinvoker: forward_register.v2 运行完成[0.952487s]. [2023-01-13 18:00:52.274728] INFO forward_test: init options data:DataSource(0e7738a5eb6b4342895ab7e63c74ea7dT) [2023-01-13 18:00:52.275897] INFO forward_test: init username:nature023, algo_id:108078, first_date:2023-01-11, frequency:daily, price_type:post_right, instruments:['000001.SZA', '000002.SZA', '000004.SZA', '000005.SZA', '000006.SZA', '000007.SZA', '000008.SZA', '000009.SZA', '000010.SZA', '000011.SZA', '000012.SZA', '000014.SZA', '000016.SZA', '000017.SZA', '000019.SZA', '000020.SZA', '000021.SZA', '000023.SZA', '000025.SZA', '000026.SZA', '000027.SZA', '000028.SZA', '000029.SZA', '000030.SZA', '000031.SZA', '000032.SZA', '000034.SZA', '000035.SZA', '000036.SZA', '000037.SZA', '000038.SZA', '000039.SZA'] [2023-01-13 18:00:52.276755] INFO forward_test: init benchmark_symbol= [2023-01-13 18:00:52.401836] INFO forward_test: got run_date_str=2023-01-13, de_list_instruments=['600385.SHA', '002770.SZA', '000780.SZA', '833994.BJA', '430057.BJA', '600870.SHA', '603996.SHA', '000687.SZA', '300064.SZA', '651002.SHA', '002684.SZA', '603157.SHA', '002618.SZA', '000585.SZA', '600209.SHA', '000835.SZA', '000502.SZA', '002147.SZA', '000673.SZA', '300312.SZA', '600291.SHA', '600695.SHA', '600145.SHA', '002447.SZA', '300367.SZA', '832317.BJA', '600093.SHA', '002619.SZA', '000611.SZA', '833874.BJA', '600555.SHA', '002464.SZA', '600652.SHA', '600890.SHA', '002473.SZA', '600090.SHA', '300325.SZA', '300202.SZA', '600896.SHA', '600146.SHA', '600275.SHA', '000613.SZA', '300178.SZA', '600856.SHA', '002260.SZA', '600091.SHA', '300023.SZA', '300038.SZA'] [2023-01-13 18:00:52.403342] INFO forward_test: biglearning forward test:V5.5.2 [2023-01-13 18:00:52.583105] INFO forward_test: forward test invoke_micro_service done True [2023-01-13 18:00:52.970139] INFO forward_test: run_date: 2023-01-13, notebook_id:nature023_69d83e10-9202-11ed-88b2-72d507417d56, algo_name:可视化策略-小市值选股-Clone2, is_third_match:0 [2023-01-13 18:00:53.185438] INFO forward_test: last_record is_sync cash:1000000.0, last_portfolio:{'cum_return': 0.0, 'annual_return': 0.0, 'today_return': 0.0, 'pv': 0.0, 'max_pv': 1000000.0, 'drawdown': 0.0, 'first_date': '2023-01-11'} [2023-01-13 18:00:53.186362] INFO forward_test: last_record is_sync extension:{'index': 2, 'order_price_field_buy': 'open', 'order_price_field_sell': 'open', 'is_stock': 'True', 'need_settle': 'False'} [2023-01-13 18:00:53.187077] INFO forward_test: forward test trading_calendar done! [2023-01-13 18:00:53.222963] INFO forward_test: forward test read benchmark_df True from DataSource done! [2023-01-13 18:00:53.231387] INFO forward_test: benchmark_df: open high instrument close date 238 3998.527832 4023.089844 000300.HIX 4013.119629 2023-01-09239 4014.712402 4030.457520 000300.HIX 4017.473633 2023-01-10240 4019.884521 4043.399170 000300.HIX 4010.031006 2023-01-11241 4021.754639 4030.287598 000300.HIX 4017.869141 2023-01-12242 4032.290527 4074.377197 000300.HIX 4074.377197 2023-01-13
low volume
238 3990.707275 11705442500239 4002.229736 10175114100240 4008.015381 9999788900241 4003.507812 9055262700242 4027.886475 9587189600[2023-01-13 18:00:53.289519] INFO algo: init() show_debug_info:True, standard_mode:True, instant_fill:False, third_match_model:False, max_pos_ratio:1.0, papertrading:True, perf_raw_object:0
[2023-01-13 18:00:53.291100] INFO algo: init() daily start:2023-01-13 00:00:00+00:00 ~ end:2023-01-13 00:00:00+00:00
[2023-01-13 18:00:53.292170] INFO factory: create simulation parameters [start:2023-01-13 00:00:00+00:00, end:2023-01-13 00:00:00+00:00]
[2023-01-13 18:00:53.293193] INFO Trading: SimulationParameters start_session:2023-01-13 00:00:00+00:00, end_session:2023-01-13 00:00:00+00:00, emission_rate:daily, arena:backtest
[2023-01-13 18:00:53.294372] INFO Trading: SimulationParameters _first_open:2023-01-13 09:30:00+00:00, _last_close:2023-01-13 15:00:00+00:00
[2023-01-13 18:00:53.298867] INFO forward_test: instruments type <class 'list'>, <class 'list'>, <class 'list'>
[2023-01-13 18:00:53.300945] INFO forward_test: start create history data
[2023-01-13 18:00:56.369831] INFO backtest: 读取股票行情完成:1313359
[2023-01-13 18:00:57.299963] INFO forward_test: create history data ENABLE_CACHE is False, directly reading ohlc_data_ds:DataSource(815dd550469740e698818f9c0748ccf0T)
[2023-01-13 18:01:01.586162] INFO forward_test: end create history data type=<class 'pandas.core.frame.DataFrame'>.
[2023-01-13 18:01:01.595552] INFO forward_test: ohlc_data=
adjust_factor amount close instrument deal_number 1181451 1.069075 1862146.0 12.337126 873122.BJA 0.01181452 1.017831 210551.0 6.106986 873169.BJA 0.01181453 1.000000 684001.0 3.210000 873223.BJA 0.01181454 7.211538 499469.0 36.274036 873339.BJA 0.01181455 1.052632 350342.0 8.452635 873527.BJA 0.0
date high low open turn volume \
1181451 2023-01-13 12.604394 12.240909 12.347816 1.839136 161706.01181452 2023-01-13 6.106986 6.056095 6.106986 0.128754 35200.01181453 2023-01-13 3.210000 3.180000 3.190000 0.442290 214002.01181454 2023-01-13 36.418266 36.201920 36.274036 0.174696 99215.01181455 2023-01-13 8.494740 8.442109 8.494740 0.186204 43627.0
price_limit_status st_status suspended delist_date list_date name
1181451 2.0 0.0 False NaT 2022-09-27 中纺标1181452 2.0 0.0 False NaT 2022-04-15 七丰精工1181453 2.0 0.0 False NaT 2022-06-09 荣亿精密1181454 2.0 0.0 False NaT 2022-11-17 恒太照明1181455 2.0 0.0 False NaT 2022-10-27 夜光明[2023-01-13 18:01:01.596709] INFO forward_test: forward test get_adjust_factor_map...
[2023-01-13 18:01:01.865012] INFO forward_test: forward test init_equity_name_map...
[2023-01-13 18:01:02.851165] INFO algo: TradingAlgorithm V1.8.9
[2023-01-13 18:01:15.367234] INFO forward_test: c_initialize() first_trading_date:2023-01-11, trading_day_index:2
[2023-01-13 18:01:17.353836] INFO forward_test: c_initialize() positions len:0, value:0.0
[2023-01-13 18:01:17.355049] INFO forward_test: c_initialize() orders len:0
[2023-01-13 18:01:17.355931] INFO algo: init() setting[data_frequency:daily, product_type:stock,price_type:backward_adjusted,amount_integer:False,leverage_type:fill_amap,max_leverage:1.0,need_settle:False]
[2023-01-13 18:01:17.357617] INFO algo: trading transform...
[2023-01-13 18:01:17.359626] INFO forward_test: c_handle_data() dt=2023-01-13 15:00:00+00:00 portfolio value=1000000.0, cash=1000000.0
[2023-01-13 18:01:17.361499] INFO Performance: Simulated 1 trading days out of 1.
[2023-01-13 18:01:17.362304] INFO Performance: first open: 2023-01-13 09:30:00+00:00
[2023-01-13 18:01:17.362965] INFO Performance: last close: 2023-01-13 15:00:00+00:00
[2023-01-13 18:01:17.384736] INFO forward_test: get last row of algo result_1:
algorithm_period_return alpha 2023-01-13 15:00:00+00:00 0.0 0
benchmark_period_return beta capital_used \
2023-01-13 15:00:00+00:00 0.014064 0 0.0
ending_cash ending_value long_value longs_count \
2023-01-13 15:00:00+00:00 1000000.0 0.0 0.0 0
max_drawdown
2023-01-13 15:00:00+00:00 0.0[2023-01-13 18:01:17.392520] INFO forward_test: get last row of algo result_2:
period_close period_label 2023-01-13 15:00:00+00:00 2023-01-13 15:00:00+00:00 2023-01
period_open pnl portfolio_value \
2023-01-13 15:00:00+00:00 2023-01-13 09:30:00+00:00 0.0 1000000.0
returns short_value shorts_count sortino \
2023-01-13 15:00:00+00:00 0.0 0.0 0 0
starting_cash starting_value trading_days
2023-01-13 15:00:00+00:00 1000000.0 0.0 1[2023-01-13 18:01:17.394448] INFO forward_test: get_orders new_orders 0:
json_orders:
[2023-01-13 18:01:17.397221] INFO forward_test: get_last_sale_date_dict: {} [2023-01-13 18:01:17.398125] INFO forward_test: get_positions_stocks position_value:0.0 new_positions:
json_positions:
[2023-01-13 18:01:17.399446] INFO forward_test: get_portfolio last_pv:1000000.0, current_pv:1000000.0, json_portfolio:{'cum_return': 0.0, 'annual_return': 0.0, 'today_return': 0.0, 'pv': 0.0, 'max_pv': 1000000.0, 'drawdown': 0.0, 'first_date': '2023-01-11'} [2023-01-13 18:01:17.400732] INFO forward_test: get_transactions transaction num 0 [2023-01-13 18:01:17.401427] INFO forward_test: get_transactions total_buy:0.0, total_sell:0.0, json_transaction:
reading benchmark data... 000300.HIX 2023-01-11 2023-01-13 00:00:00+00:00
open high instrument close date low 0 4019.884521 4043.399170 000300.HIX 4010.031006 2023-01-11 4008.0153811 4021.754639 4030.287598 000300.HIX 4017.869141 2023-01-12 4003.5078122 4032.290527 4074.377197 000300.HIX 4074.377197 2023-01-13 4027.886475