模拟运行失败
由bqzte5v2创建,最终由small_q 被浏览 52 用户
https://bigquant.com/codeshare/ab8fdfa0-cd0e-47b7-a96d-a0391c480bb7
这是我一个简单的策略,可以正常回测,但是提交模拟交易出错,请问如何解决?
2024-01-15 00:44:40 任务运行开始调度 state=trigger event= ea0b9d62-d73c-405f-aabe-a5812a248e0d ..
2024-01-15 00:44:46 任务运行状态更新 state=scheduled event=20240112 ea0b9d62-d73c-405f-aabe-a5812a248e0d
2024-01-15 00:44:49 任务运行状态更新 state=running event=20240112 ea0b9d62-d73c-405f-aabe-a5812a248e0d
2024-01-15 08:44:49 [info ] run task_id='ea0b9d62-d73c-405f-aabe-a5812a248e0d' ..
2024-01-15 08:44:49 [info ] fetch task ea0b9d62-d73c-405f-aabe-a5812a248e0d ..
2024-01-15 08:44:49 [info ] start ea0b9d62-d73c-405f-aabe-a5812a248e0d.ipynb ..
[2024-01-15 08:44:57.702682] INFO: moduleinvoker:3148543991.py:95:<module> input_features_dai.v6 开始运行..
[2024-01-15 08:44:57.816189] INFO: moduleinvoker:3148543991.py:95:<module> 命中缓存
[2024-01-15 08:44:57.819319] INFO: moduleinvoker:3148543991.py:95:<module> input_features_dai.v6 运行完成[0.116682s].
2024-01-15 08:44:57 [info ] cache disabled for paper/live trading
[2024-01-15 08:44:57.865311] INFO: moduleinvoker:3148543991.py:138:<module> extract_data_dai.v7 开始运行..
2024-01-15 08:44:57 [info ] start_date='2024-01-12', end_date='2024-01-12', query_start_date='2023-10-14' ..
2024-01-15 08:45:00 [info ] data extracted: (0, 5)
[2024-01-15 08:45:00.180838] INFO: moduleinvoker:3148543991.py:138:<module> extract_data_dai.v7 运行完成[2.315489s].
[2024-01-15 08:45:00.206120] INFO: moduleinvoker:3148543991.py:149:<module> bigtrader.v9 开始运行..
[2024-01-15 08:45:00.245065] INFO: hfpapertrading:init.py:90:init got metadata extra from input datasource
[2024-01-15 08:45:00.247609] INFO: hfpapertrading:init.py:95:init read data ..
[2024-01-15 08:45:00.268906] ERROR: moduleinvoker:3148543991.py:149:<module> module name: bigtrader, module version: v9, trackeback: ValueError: NaTType does not support strftime
2024-01-15 08:45:02 [error ] run task failed:
---------------------------------------------------------------------------
Exception encountered at "In [1]":
---------------------------------------------------------------------------
ValueError Traceback (most recent call last)
Cell In[1], line 149
138 m2 = M.extract_data_dai.v7(
139 sql=m1.data,
140 start_date='2023-02-13',
(...)
145 debug=False
146 )
148 # @module(position="817,497", comment='', comment_collapsed=True)
--> 149 m3 = M.bigtrader.v9(
150 data=m2.data,
151 start_date='',
152 end_date='',
153 initialize=m3_initialize_bigquant_run,
154 before_trading_start=m3_before_trading_start_bigquant_run,
155 handle_tick=m3_handle_tick_bigquant_run,
156 handle_data=m3_handle_data_bigquant_run,
157 handle_trade=m3_handle_trade_bigquant_run,
158 handle_order=m3_handle_order_bigquant_run,
159 after_trading=m3_after_trading_bigquant_run,
160 capital_base=1000000,
161 frequency='daily',
162 product_type='股票',
163 before_start_days=0,
164 volume_limit=1,
165 order_price_field_buy='open',
166 order_price_field_sell='open',
167 benchmark='000300.SH',
168 plot_charts=True,
169 disable_cache=False,
170 debug=False,
171 backtest_only=False
172 )
173 # </aistudiograph>
File module2/common/modulemanagerv2.py:88, in biglearning.module2.common.modulemanagerv2.BigQuantModuleVersion.call()
File module2/common/moduleinvoker.py:370, in biglearning.module2.common.moduleinvoker.module_invoke()
File module2/common/moduleinvoker.py:292, in biglearning.module2.common.moduleinvoker._invoke_with_cache()
File module2/common/moduleinvoker.py:253, in biglearning.module2.common.moduleinvoker._invoke_with_cache()
File module2/common/moduleinvoker.py:210, in biglearning.module2.common.moduleinvoker._module_run()
File /var/app/data/custom_module/publicmodules/bigtrader/v9/init.py:321, in run(start_date, end_date, data, initialize, before_trading_start, handle_tick, handle_data, handle_trade, handle_order, after_trading, options_data, history_ds, benchmark_ds, capital_base, frequency, product_type, before_start_days, volume_limit, order_price_field_buy, order_price_field_sell, benchmark, plot_charts, disable_cache, debug, backtest_only, m_meta_kwargs)
317 # result = do_live_run(env)
319 from .core.pypapertrading import BigQuantModule
--> 321 outputs = BigQuantModule(
322 run_date=env.trading_date,
323 \*\*trading_params,
324 # \*\*m_meta_kwargs,
325 ).run()
326 else:
327 raise Exception("invalid trading mode")
File /var/app/data/custom_module/publicmodules/bigtrader/v9/core/pypapertrading/init.py:109, in BigQuantModule.init(self, run_date, initialize, handle_data, handle_tick, handle_trade, handle_order, before_trading_start, after_trading, data, order_price_field_buy, order_price_field_sell, before_start_days, replay_bdb, frequency, adjust_type, product_type, volume_limit, capital_base, options_data, email_to, wechat_to, daily_data_ds, minute_data_ds, tick_data_ds, benchmark_data_ds, basic_data_ds, dominant_data_ds, debug, benchmark)
103 instruments = json.loads(data)
104 elif isinstance(data, pd.DataFrame):
105 instruments = {
106 # "market": "CN_STOCK_A",
107 "instruments": list(set(data\["instrument"\])),
108 # TODO: to seconds?
--> 109 "start_date": data["date"].min().strftime("%Y-%m-%d"),
110 "end_date": data\["date"\].max().strftime("%Y-%m-%d"),
111 }
112 else:
113 raise Exception(f"not supported instruments type: {type(data)}")
File pandas/_libs/tslibs/nattype.pyx:72, in pandas._libs.tslibs.nattype._make_error_func.f()
ValueError: NaTType does not support strftime
2024-01-15 00:45:02 任务运行状态更新 state=failed event=20240112 ea0b9d62-d73c-405f-aabe-a5812a248e0d
Traceback (most recent call last):
File "/var/app/data/custom_module/aiflow_task_run.py", line 258, in <module>
run(run_id=sys.argv\[1\], task_id=sys.argv\[2\], event_name=sys.argv\[3\], dry_run=sys.argv\[4\])
File "/var/app/data/custom_module/aiflow_task_run.py", line 253, in run
raise ex from ex
File "/var/app/data/custom_module/aiflow_task_run.py", line 243, in run
do_run(task_id, event_name)
File "/var/app/data/custom_module/aiflow_task_run.py", line 211, in do_run
pm.execute_notebook(
File "/usr/local/python3/lib/python3.8/site-packages/papermill/execute.py", line 128, in execute_notebook
raise_for_execution_errors(nb, output_path)
File "/usr/local/python3/lib/python3.8/site-packages/papermill/execute.py", line 232, in raise_for_execution_errors
raise error
papermill.exceptions.PapermillExecutionError:
---------------------------------------------------------------------------
Exception encountered at "In [1]":
---------------------------------------------------------------------------
ValueError Traceback (most recent call last)
Cell In[1], line 149
138 m2 = M.extract_data_dai.v7(
139 sql=m1.data,
140 start_date='2023-02-13',
(...)
145 debug=False
146 )
148 # @module(position="817,497", comment='', comment_collapsed=True)
--> 149 m3 = M.bigtrader.v9(
150 data=m2.data,
151 start_date='',
152 end_date='',
153 initialize=m3_initialize_bigquant_run,
154 before_trading_start=m3_before_trading_start_bigquant_run,
155 handle_tick=m3_handle_tick_bigquant_run,
156 handle_data=m3_handle_data_bigquant_run,
157 handle_trade=m3_handle_trade_bigquant_run,
158 handle_order=m3_handle_order_bigquant_run,
159 after_trading=m3_after_trading_bigquant_run,
160 capital_base=1000000,
161 frequency='daily',
162 product_type='股票',
163 before_start_days=0,
164 volume_limit=1,
165 order_price_field_buy='open',
166 order_price_field_sell='open',
167 benchmark='000300.SH',
168 plot_charts=True,
169 disable_cache=False,
170 debug=False,
171 backtest_only=False
172 )
173 # </aistudiograph>
File module2/common/modulemanagerv2.py:88, in biglearning.module2.common.modulemanagerv2.BigQuantModuleVersion.call()
File module2/common/moduleinvoker.py:370, in biglearning.module2.common.moduleinvoker.module_invoke()
File module2/common/moduleinvoker.py:292, in biglearning.module2.common.moduleinvoker._invoke_with_cache()
File module2/common/moduleinvoker.py:253, in biglearning.module2.common.moduleinvoker._invoke_with_cache()
File module2/common/moduleinvoker.py:210, in biglearning.module2.common.moduleinvoker._module_run()
File /var/app/data/custom_module/publicmodules/bigtrader/v9/init.py:321, in run(start_date, end_date, data, initialize, before_trading_start, handle_tick, handle_data, handle_trade, handle_order, after_trading, options_data, history_ds, benchmark_ds, capital_base, frequency, product_type, before_start_days, volume_limit, order_price_field_buy, order_price_field_sell, benchmark, plot_charts, disable_cache, debug, backtest_only, m_meta_kwargs)
317 # result = do_live_run(env)
319 from .core.pypapertrading import BigQuantModule
--> 321 outputs = BigQuantModule(
322 run_date=env.trading_date,
323 \*\*trading_params,
324 # \*\*m_meta_kwargs,
325 ).run()
326 else:
327 raise Exception("invalid trading mode")
File /var/app/data/custom_module/publicmodules/bigtrader/v9/core/pypapertrading/init.py:109, in BigQuantModule.init(self, run_date, initialize, handle_data, handle_tick, handle_trade, handle_order, before_trading_start, after_trading, data, order_price_field_buy, order_price_field_sell, before_start_days, replay_bdb, frequency, adjust_type, product_type, volume_limit, capital_base, options_data, email_to, wechat_to, daily_data_ds, minute_data_ds, tick_data_ds, benchmark_data_ds, basic_data_ds, dominant_data_ds, debug, benchmark)
103 instruments = json.loads(data)
104 elif isinstance(data, pd.DataFrame):
105 instruments = {
106 # "market": "CN_STOCK_A",
107 "instruments": list(set(data\["instrument"\])),
108 # TODO: to seconds?
--> 109 "start_date": data["date"].min().strftime("%Y-%m-%d"),
110 "end_date": data\["date"\].max().strftime("%Y-%m-%d"),
111 }
112 else:
113 raise Exception(f"not supported instruments type: {type(data)}")
File pandas/_libs/tslibs/nattype.pyx:72, in pandas._libs.tslibs.nattype._make_error_func.f()
ValueError: NaTType does not support strftime
2024-01-15 00:45:08 任务运行状态更新 state=running event=20240112 ea0b9d62-d73c-405f-aabe-a5812a248e0d
2024-01-15 08:45:09 [info ] run task_id='ea0b9d62-d73c-405f-aabe-a5812a248e0d' ..
2024-01-15 08:45:09 [info ] fetch task ea0b9d62-d73c-405f-aabe-a5812a248e0d ..
2024-01-15 08:45:09 [info ] start ea0b9d62-d73c-405f-aabe-a5812a248e0d.ipynb ..
[2024-01-15 08:45:17.662570] INFO: moduleinvoker:3148543991.py:95:<module> input_features_dai.v6 开始运行..
[2024-01-15 08:45:17.767237] INFO: moduleinvoker:3148543991.py:95:<module> 命中缓存
[2024-01-15 08:45:17.769816] INFO: moduleinvoker:3148543991.py:95:<module> input_features_dai.v6 运行完成[0.107278s].
2024-01-15 08:45:17 [info ] cache disabled for paper/live trading
[2024-01-15 08:45:17.814191] INFO: moduleinvoker:3148543991.py:138:<module> extract_data_dai.v7 开始运行..
2024-01-15 08:45:17 [info ] start_date='2024-01-12', end_date='2024-01-12', query_start_date='2023-10-14' ..
2024-01-15 08:45:19 [info ] data extracted: (0, 5)
[2024-01-15 08:45:19.727538] INFO: moduleinvoker:3148543991.py:138:<module> extract_data_dai.v7 运行完成[1.913297s].
[2024-01-15 08:45:19.754194] INFO: moduleinvoker:3148543991.py:149:<module> bigtrader.v9 开始运行..
[2024-01-15 08:45:19.790873] INFO: hfpapertrading:init.py:90:init got metadata extra from input datasource
[2024-01-15 08:45:19.793463] INFO: hfpapertrading:init.py:95:init read data ..
[2024-01-15 08:45:19.814292] ERROR: moduleinvoker:3148543991.py:149:<module> module name: bigtrader, module version: v9, trackeback: ValueError: NaTType does not support strftime
2024-01-15 08:45:21 [error ] run task failed:
---------------------------------------------------------------------------
Exception encountered at "In [1]":
---------------------------------------------------------------------------
ValueError Traceback (most recent call last)
Cell In[1], line 149
138 m2 = M.extract_data_dai.v7(
139 sql=m1.data,
140 start_date='2023-02-13',
(...)
145 debug=False
146 )
148 # @module(position="817,497", comment='', comment_collapsed=True)
--> 149 m3 = M.bigtrader.v9(
150 data=m2.data,
151 start_date='',
152 end_date='',
153 initialize=m3_initialize_bigquant_run,
154 before_trading_start=m3_before_trading_start_bigquant_run,
155 handle_tick=m3_handle_tick_bigquant_run,
156 handle_data=m3_handle_data_bigquant_run,
157 handle_trade=m3_handle_trade_bigquant_run,
158 handle_order=m3_handle_order_bigquant_run,
159 after_trading=m3_after_trading_bigquant_run,
160 capital_base=1000000,
161 frequency='daily',
162 product_type='股票',
163 before_start_days=0,
164 volume_limit=1,
165 order_price_field_buy='open',
166 order_price_field_sell='open',
167 benchmark='000300.SH',
168 plot_charts=True,
169 disable_cache=False,
170 debug=False,
171 backtest_only=False
172 )
173 # </aistudiograph>
File module2/common/modulemanagerv2.py:88, in biglearning.module2.common.modulemanagerv2.BigQuantModuleVersion.call()
File module2/common/moduleinvoker.py:370, in biglearning.module2.common.moduleinvoker.module_invoke()
File module2/common/moduleinvoker.py:292, in biglearning.module2.common.moduleinvoker._invoke_with_cache()
File module2/common/moduleinvoker.py:253, in biglearning.module2.common.moduleinvoker._invoke_with_cache()
File module2/common/moduleinvoker.py:210, in biglearning.module2.common.moduleinvoker._module_run()
File /var/app/data/custom_module/publicmodules/bigtrader/v9/init.py:321, in run(start_date, end_date, data, initialize, before_trading_start, handle_tick, handle_data, handle_trade, handle_order, after_trading, options_data, history_ds, benchmark_ds, capital_base, frequency, product_type, before_start_days, volume_limit, order_price_field_buy, order_price_field_sell, benchmark, plot_charts, disable_cache, debug, backtest_only, m_meta_kwargs)
317 # result = do_live_run(env)
319 from .core.pypapertrading import BigQuantModule
--> 321 outputs = BigQuantModule(
322 run_date=env.trading_date,
323 \*\*trading_params,
324 # \*\*m_meta_kwargs,
325 ).run()
326 else:
327 raise Exception("invalid trading mode")
File /var/app/data/custom_module/publicmodules/bigtrader/v9/core/pypapertrading/init.py:109, in BigQuantModule.init(self, run_date, initialize, handle_data, handle_tick, handle_trade, handle_order, before_trading_start, after_trading, data, order_price_field_buy, order_price_field_sell, before_start_days, replay_bdb, frequency, adjust_type, product_type, volume_limit, capital_base, options_data, email_to, wechat_to, daily_data_ds, minute_data_ds, tick_data_ds, benchmark_data_ds, basic_data_ds, dominant_data_ds, debug, benchmark)
103 instruments = json.loads(data)
104 elif isinstance(data, pd.DataFrame):
105 instruments = {
106 # "market": "CN_STOCK_A",
107 "instruments": list(set(data\["instrument"\])),
108 # TODO: to seconds?
--> 109 "start_date": data["date"].min().strftime("%Y-%m-%d"),
110 "end_date": data\["date"\].max().strftime("%Y-%m-%d"),
111 }
112 else:
113 raise Exception(f"not supported instruments type: {type(data)}")
File pandas/_libs/tslibs/nattype.pyx:72, in pandas._libs.tslibs.nattype._make_error_func.f()
ValueError: NaTType does not support strftime
2024-01-15 00:45:21 任务运行状态更新 state=failed event=20240112 ea0b9d62-d73c-405f-aabe-a5812a248e0d
Traceback (most recent call last):
File "/var/app/data/custom_module/aiflow_task_run.py", line 258, in <module>
run(run_id=sys.argv\[1\], task_id=sys.argv\[2\], event_name=sys.argv\[3\], dry_run=sys.argv\[4\])
File "/var/app/data/custom_module/aiflow_task_run.py", line 253, in run
raise ex from ex
File "/var/app/data/custom_module/aiflow_task_run.py", line 243, in run
do_run(task_id, event_name)
File "/var/app/data/custom_module/aiflow_task_run.py", line 211, in do_run
pm.execute_notebook(
File "/usr/local/python3/lib/python3.8/site-packages/papermill/execute.py", line 128, in execute_notebook
raise_for_execution_errors(nb, output_path)
File "/usr/local/python3/lib/python3.8/site-packages/papermill/execute.py", line 232, in raise_for_execution_errors
raise error
papermill.exceptions.PapermillExecutionError:
---------------------------------------------------------------------------
Exception encountered at "In [1]":
---------------------------------------------------------------------------
ValueError Traceback (most recent call last)
Cell In[1], line 149
138 m2 = M.extract_data_dai.v7(
139 sql=m1.data,
140 start_date='2023-02-13',
(...)
145 debug=False
146 )
148 # @module(position="817,497", comment='', comment_collapsed=True)
--> 149 m3 = M.bigtrader.v9(
150 data=m2.data,
151 start_date='',
152 end_date='',
153 initialize=m3_initialize_bigquant_run,
154 before_trading_start=m3_before_trading_start_bigquant_run,
155 handle_tick=m3_handle_tick_bigquant_run,
156 handle_data=m3_handle_data_bigquant_run,
157 handle_trade=m3_handle_trade_bigquant_run,
158 handle_order=m3_handle_order_bigquant_run,
159 after_trading=m3_after_trading_bigquant_run,
160 capital_base=1000000,
161 frequency='daily',
162 product_type='股票',
163 before_start_days=0,
164 volume_limit=1,
165 order_price_field_buy='open',
166 order_price_field_sell='open',
167 benchmark='000300.SH',
168 plot_charts=True,
169 disable_cache=False,
170 debug=False,
171 backtest_only=False
172 )
173 # </aistudiograph>
File module2/common/modulemanagerv2.py:88, in biglearning.module2.common.modulemanagerv2.BigQuantModuleVersion.call()
File module2/common/moduleinvoker.py:370, in biglearning.module2.common.moduleinvoker.module_invoke()
File module2/common/moduleinvoker.py:292, in biglearning.module2.common.moduleinvoker._invoke_with_cache()
File module2/common/moduleinvoker.py:253, in biglearning.module2.common.moduleinvoker._invoke_with_cache()
File module2/common/moduleinvoker.py:210, in biglearning.module2.common.moduleinvoker._module_run()
File /var/app/data/custom_module/publicmodules/bigtrader/v9/init.py:321, in run(start_date, end_date, data, initialize, before_trading_start, handle_tick, handle_data, handle_trade, handle_order, after_trading, options_data, history_ds, benchmark_ds, capital_base, frequency, product_type, before_start_days, volume_limit, order_price_field_buy, order_price_field_sell, benchmark, plot_charts, disable_cache, debug, backtest_only, m_meta_kwargs)
317 # result = do_live_run(env)
319 from .core.pypapertrading import BigQuantModule
--> 321 outputs = BigQuantModule(
322 run_date=env.trading_date,
323 \*\*trading_params,
324 # \*\*m_meta_kwargs,
325 ).run()
326 else:
327 raise Exception("invalid trading mode")
File /var/app/data/custom_module/publicmodules/bigtrader/v9/core/pypapertrading/init.py:109, in BigQuantModule.init(self, run_date, initialize, handle_data, handle_tick, handle_trade, handle_order, before_trading_start, after_trading, data, order_price_field_buy, order_price_field_sell, before_start_days, replay_bdb, frequency, adjust_type, product_type, volume_limit, capital_base, options_data, email_to, wechat_to, daily_data_ds, minute_data_ds, tick_data_ds, benchmark_data_ds, basic_data_ds, dominant_data_ds, debug, benchmark)
103 instruments = json.loads(data)
104 elif isinstance(data, pd.DataFrame):
105 instruments = {
106 # "market": "CN_STOCK_A",
107 "instruments": list(set(data\["instrument"\])),
108 # TODO: to seconds?
--> 109 "start_date": data["date"].min().strftime("%Y-%m-%d"),
110 "end_date": data\["date"\].max().strftime("%Y-%m-%d"),
111 }
112 else:
113 raise Exception(f"not supported instruments type: {type(data)}")
File pandas/_libs/tslibs/nattype.pyx:72, in pandas._libs.tslibs.nattype._make_error_func.f()
ValueError: NaTType does not support strftime
\