【代码报错】AttributeError: 'int' object has no attribute 'to_pydatetime'
由franklili创建,最终由franklili 被浏览 8 用户
运行bigtrader出现'int' object has no attribute 'to_pydatetime' 错误
https://bigquant.com/codesharev3/f57ba9ba-5de8-4748-8459-7fa473319887
日志 24 条 ▼
- [2025-01-03 16:08:42] INFO: input_features_dai.v30 开始运行 ..
- [2025-01-03 16:08:45] INFO: input_features_dai.v30 命中缓存
- [2025-01-03 16:08:45] INFO: input_features_dai.v30 运行完成 [2.958s].
- [2025-01-03 16:08:45] INFO: extract_data_dai.v18 开始运行 ..
- [2025-01-03 16:08:45] INFO: extract_data_dai.v18 命中缓存
- [2025-01-03 16:08:45] INFO: extract_data_dai.v18 运行完成 [0.116s].
- [2025-01-03 16:08:45] INFO: input_features_dai.v30 开始运行 ..
- [2025-01-03 16:08:45] INFO: input_features_dai.v30 命中缓存
- [2025-01-03 16:08:45] INFO: input_features_dai.v30 运行完成 [0.106s].
- [2025-01-03 16:08:45] INFO: extract_data_dai.v18 开始运行 ..
- [2025-01-03 16:08:45] INFO: extract_data_dai.v18 命中缓存
- [2025-01-03 16:08:45] INFO: extract_data_dai.v18 运行完成 [0.099s].
- [2025-01-03 16:08:45] INFO: python.v2 开始运行 ..
- [2025-01-03 16:08:46] INFO: python.v2 命中缓存
- [2025-01-03 16:08:46] INFO: python.v2 运行完成 [0.103s].
- [2025-01-03 16:08:46] INFO: python.v2 开始运行 ..
- 0
- [2025-01-03 16:08:46] INFO: python.v2 运行完成 [0.160s].
- [2025-01-03 16:08:46] INFO: bigtrader.v35 开始运行 ..
- [2025-01-03 16:08:46] INFO: read input 'data' ..
- [2025-01-03 16:08:46] INFO: pybacktest run 2017-11-28 ~ 2024-12-17, , , instruments=1
- [2025-01-03 16:08:47] INFO: bigtrader module V2.2.0
- [2025-01-03 16:08:47] INFO: bigtrader engine v1.10.10 2024-12-25
- 您可以去社区论坛问答交流板块反馈咨询 去发帖>> --------------------------------------------------------------------------- AttributeError Traceback (most recent call last) Cell In[1], line 414
- 404 m1 = M.python.v2(
- 405 input_1=m2.data_1,
- 406 input_2=m4.data, (...)
- 410 m_name="""m1"""
- 411 )
- 413 # @module(position="-1,-398", comment="""交易,日线,设置初始化函数和K线处理函数,以及初始资金、基准等""") -->
- 414 m5 = M.bigtrader.v35(
- 415 data=m1.data_1,
- 416 history_ds=m1.data_1,
- 417 start_date="""2017-11-28""",
- 418 end_date="""2024-12-17""",
- 419 initialize=m5_initialize_bigquant_run,
- 420 before_trading_start=m5_before_trading_start_bigquant_run,
- 421 handle_tick=m5_handle_tick_bigquant_run,
- 422 handle_data=m5_handle_data_bigquant_run,
- 423 handle_trade=m5_handle_trade_bigquant_run,
- 424 handle_order=m5_handle_order_bigquant_run,
- 425 after_trading=m5_after_trading_bigquant_run,
- 426 capital_base=100000,
- 427 frequency="""daily""",
- 428 product_type="""自动""",
- 429 rebalance_period_type="""月度交易日""",
- 430 rebalance_period_days="""1""",
- 431 rebalance_period_roll_forward=True,
- 432 backtest_engine_mode="""自动""",
- 433 before_start_days=50,
- 434 volume_limit=1,
- 435 order_price_field_buy="""close""",
- 436 order_price_field_sell="""close""",
- 437 benchmark="""沪深300指数""",
- 438 plot_charts=True,
- 439 debug=False,
- 440 backtest_only=False,
- 441 m_cached=False,
- 442 m_name="""m5"""
- 443 )
- 445 # @module(position="-196,-214", comment="""""", comment_collapsed=True)
- 446 m8 = M.strategy_style_show.v1(
- 447 input_1=m5.raw_perf,
- 448 m_name="""m8"""
- 449 ) File /opt/pyenv/versions/3.11.8/lib/python3.11/site-packages/bigmodule/modules.py:28, in call(self, **kwargs)
- File /opt/pyenv/versions/3.11.8/lib/python3.11/site-packages/bigmodule/moduleinvoker.py:203, in module_invoke(name, version, kwargs)
- File /opt/pyenv/versions/3.11.8/lib/python3.11/site-packages/bigmodule/moduleinvoker.py:169, in _module_invoke(name, version, kwargs)
- File /opt/pyenv/versions/3.11.8/lib/python3.11/site-packages/bigmodule/moduleinvoker.py:41, in _module_run(module, kwargs)
- File dist/build/bigtrader/v35/init.py:400, in v35.run() File dist/build/bigtrader/v35/init.py:194, in v35._run()
- File dist/build/bigtrader/v35/init.py:181, in v35._run_backtest()
- File dist/build/bigtrader/v35/core/pybacktest/init.py:410, in v35.core.pybacktest.BigQuantModule.run()
- File dist/build/bigtrader/v35/core/pybacktest/init.py:342, in v35.core.pybacktest.BigQuantModule.run_algo()
- AttributeError: 'int' object has no attribute 'to_pydatetime'
2024年12月20日运行正常。
- [2024-12-20 15:15:04] WARNING: start_date='2017-11-28', end_date='2024-12-17', query_start_date='2017-08-30 00:00:00' (支持加速 升级资源) ..
- [2024-12-20 15:15:04] INFO: data extracted: (2536, 7)
- [2024-12-20 15:15:05] INFO: extract_data_dai.v17 运行完成 [0.503s].
- [2024-12-20 15:15:05] INFO: input_features_dai.v30 开始运行 ..
- [2024-12-20 15:15:05] INFO: input_features_dai.v30 命中缓存
- [2024-12-20 15:15:05] INFO: input_features_dai.v30 运行完成 [0.167s].
- [2024-12-20 15:15:05] INFO: extract_data_dai.v17 开始运行 ..
- [2024-12-20 15:15:05] WARNING: start_date='2017-11-28', end_date='2024-12-17', query_start_date='2017-08-30 00:00:00' (支持加速 升级资源) ..
- [2024-12-20 15:15:05] INFO: data extracted: (2483, 2)
- [2024-12-20 15:15:05] INFO: extract_data_dai.v17 运行完成 [0.337s].
- [2024-12-20 15:15:05] INFO: python.v2 开始运行 ..
- [2024-12-20 15:15:05] INFO: python.v2 运行完成 [0.380s].
- [2024-12-20 15:15:05] INFO: python.v2 开始运行 ..
- 0
- [2024-12-20 15:15:06] INFO: python.v2 运行完成 [0.123s].
- [2024-12-20 15:15:06] INFO: bigtrader.v34 开始运行 ..
- [2024-12-20 15:15:06] INFO: read input 'data' ..
- [2024-12-20 15:15:06] INFO: 2017-11-28, 2024-12-17, , , instruments=1
- [2024-12-20 15:15:06] INFO: bigtrader module V2.2.0
- [2024-12-20 15:15:06] INFO: bigtrader engine v1.10.10 2024-12-18
- INFO:MAIN:======== bigtrader pid:2892 version 1.10.10 2024-12-18 ========
- INFO:MAIN:bigtrader run_mode:BACKTEST, handle_bar_mode:0, frequency:1d, exchange_mode:BQ2
- INFO:MAIN:> process add account:BACKTEST,0,bkt000
- INFO:ACCT[bkt000]:AccountEngine: self_calc:1, validate_self_trading:0, validate_cash:0, validate_position:1, enable_auto_planed_order:1
- INFO:MAIN:login_account(bkt000)
- INFO:MAIN:> add_strategy setting:{'strategy_name': 'strategy', 'account_id': 'bkt000'}
- INFO:MAIN:init all strategy account_id:...
- INFO:MAIN:stop all strategy account_id:...
- [2024-12-20 15:15:17] INFO: backtest done, raw_perf_ds:dai.DataSource("_b3a14620eed84575aa16ec8f777b2aa1")
- [2024-12-20 15:15:20] INFO: bigtrader.v34 运行完成 [14.653s].
- [2024-12-20 15:15:20] INFO: strategy_style_show.v1 开始运行 ..
- [2024-12-20 15:15:21] INFO: strategy_style_show.v1 运行完成 [0.900s].
- [2024-12-20 15:15:21] INFO: strategy_evaluate_risk_overview.v1 开始运行 ..
- [2024-12-20 15:15:22] INFO: strategy_evaluate_risk_overview.v1 运行完成 [0.761s].
- [2024-12-20 15:15:22] INFO: strategy_interval_return.v3 开始运行 ..
- [2024-12-20 15:15:22] INFO: strategy_interval_return.v3 运行完成 [0.428s].
- [2024-12-20 15:15:22] INFO: strategy_return_distribution.v2 开始运行 ..
- [2024-12-20 15:15:24] INFO: strategy_return_distribution.v2 运行完成 [1.201s].
\