问答交流

为啥order_percent()有错误?(HFTrade (高频 回测/模拟/实盘) (v2) 中)

由bqm2wcrs创建,最终由small_q 被浏览 43 用户

  • your performance may suffer as PyTables will pickle object types that it cannot

  • map directly to c-types [inferred_type->mixed,key->block3_values] [items->Index(['instrument', 'name', 'suspend_type', 'suspend_reason', 'suspended'], dtype='object')]

  • pytables.to_hdf(

  • [2023-11-09 19:42:22.043052] INFO: moduleinvoker:2982861925.py:168:<module> cached.v2 运行完成[11.297357s].

  • [] [] ['603272.SHA', '301032.SZA', '003003.SZA', '301027.SZA', '600539.SHA', '301057.SZA', '600083.SHA']

  • buy 603272.SHA

  • 2023-11-09 19:42:50.190120 strategy strategy exception:Traceback (most recent call last):

  • File "bigtrader/strategy/engine.py", line 608, in bigtrader2.bigtrader.strategy.engine.StrategyEngine._call_strategy_func

  • File "bigtrader/strategy/strategy_base.py", line 2255, in bigtrader2.bigtrader.strategy.strategy_base.StrategyBase.call_handle_data

  • File "/tmp/ipykernel_1504/2982861925.py", line 105, in m7_handle_data_bigquant_run

  • context.order_percent(ins,0.14)

  • File "bigtrader/strategy/strategy_base.py", line 733, in bigtrader2.bigtrader.strategy.strategy_base.StrategyBase.order_percent

  • File "bigtrader/strategy/strategy_base.py", line 746, in bigtrader2.bigtrader.strategy.strategy_base.StrategyBase.order_value

  • File "bigtrader/strategy/strategy_base.py", line 1331, in bigtrader2.bigtrader.strategy.strategy_base.StrategyBase.current

  • File "/var/app/enabled/bigtrader2/bigtrader/protocol.py", line 278, in current

  • return self.__data_engine.get_current_value(asset, curr_dt, fields)

  • File "bigtrader/mdata/engine.py", line 677, in bigtrader2.bigtrader.mdata.engine.DataEngine._get_minute_value_from_df

  • AttributeError: 'NoneType' object has no attribute 'get_value'

  • \

  • event engine process events exception err='NoneType' object has no attribute 'get_value'

  • Traceback (most recent call last):

  • File "bigtrader/event/event_engine.py", line 83, in bigtrader2.bigtrader.event.event_engine.EventEngine.process_events

  • File "bigtrader/event/event_engine.py", line 131, in bigtrader2.bigtrader.event.event_engine.EventEngine._process_without_lock

  • File "bigtrader/strategy/engine.py", line 197, in bigtrader2.bigtrader.strategy.engine.StrategyEngine.process_bars_event

  • File "bigtrader/strategy/engine.py", line 617, in bigtrader2.bigtrader.strategy.engine.StrategyEngine._call_strategy_func

  • File "bigtrader/strategy/engine.py", line 608, in bigtrader2.bigtrader.strategy.engine.StrategyEngine._call_strategy_func

  • File "bigtrader/strategy/strategy_base.py", line 2255, in bigtrader2.bigtrader.strategy.strategy_base.StrategyBase.call_handle_data

  • File "/tmp/ipykernel_1504/2982861925.py", line 105, in m7_handle_data_bigquant_run

  • context.order_percent(ins,0.14)

  • File "bigtrader/strategy/strategy_base.py", line 733, in bigtrader2.bigtrader.strategy.strategy_base.StrategyBase.order_percent

  • File "bigtrader/strategy/strategy_base.py", line 746, in bigtrader2.bigtrader.strategy.strategy_base.StrategyBase.order_value

  • File "bigtrader/strategy/strategy_base.py", line 1331, in bigtrader2.bigtrader.strategy.strategy_base.StrategyBase.current

  • File "/var/app/enabled/bigtrader2/bigtrader/protocol.py", line 278, in current

  • return self.__data_engine.get_current_value(asset, curr_dt, fields)

  • File "bigtrader/mdata/engine.py", line 677, in bigtrader2.bigtrader.mdata.engine.DataEngine._get_minute_value_from_df

  • AttributeError: 'NoneType' object has no attribute 'get_value'

  • [2023-11-09 19:42:50.355410] ERROR: moduleinvoker:2982861925.py:168:<module> module name: hfbacktest, module version: v1, trackeback: AttributeError: 'NoneType' object has no attribute 'get_value'

  • [2023-11-09 19:42:50.455800] ERROR: moduleinvoker:2982861925.py:168:<module> module name: hftrade, module version: v2, trackeback: AttributeError: 'NoneType' object has no attribute 'get_value'

  • Output exceeds the size limit. Open the full output data in a text editor

    --------------------------------------------------------------------------- AttributeError Traceback (most recent call last) Cell In[2], line 168 148 m4 = M.derived_feature_extractor.v3( 149 input_data=m3.data, 150 features=m2.data, (...) 155 user_functions={} 156 ) 158 m5 = M.chinaa_stock_filter.v1( 159 input_data=m4.data, 160 index_constituent_cond=['全部'], (...) 165 output_left_data=False 166 ) --> 168 m7 = M.hftrade.v2( 169 instruments=m1.data, 170 options_data=m5.data, 171 start_date='', 172 end_date='', 173 initialize=m7_initialize_bigquant_run, 174 before_trading_start=m7_before_trading_start_bigquant_run, 175 handle_tick=m7_handle_tick_bigquant_run, 176 handle_data=m7_handle_data_bigquant_run, 177 handle_trade=m7_handle_trade_bigquant_run, 178 handle_order=m7_handle_order_bigquant_run, 179 after_trading=m7_after_trading_bigquant_run, 180 capital_base=1000000, 181 frequency='minute', 182 price_type='真实价格', 183 product_type='股票', 184 before_start_days='0', 185 volume_limit=1, 186 order_price_field_buy='open', 187 order_price_field_sell='close', 188 benchmark='000300.HIX', 189 plot_charts=True, 190 disable_cache=False, 191 replay_bdb=False, 192 show_debug_info=False, 193 backtest_only=False 194 ) 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 module2/modules/hftrade/v2/init.py:417, in biglearning.module2.modules.hftrade.v2.init.bigquant_run() File module2/modules/hftrade/v2/init.py:257, in biglearning.module2.modules.hftrade.v2.init.bigquant_run.do_backtest_run() 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:212, in biglearning.module2.common.moduleinvoker._module_run() File module2/modules/hfbacktest/v1/init.py:610, in biglearning.module2.modules.hfbacktest.v1.init.BigQuantModule.run() File module2/modules/hfbacktest/v1/init.py:547, in biglearning.module2.modules.hfbacktest.v1.init.BigQuantModule.run_algo() File /var/app/enabled/bigtrader2/bigtrader/run_trading.py:650, in run_backtest(start_date, end_date, strategy, strategy_setting, capital_base, product_type, frequency, instruments, options_data, **kwargs) 634 capital_base = kwargs.pop("capital") 636 rt = RunTrading(RunMode.BACKTEST, 637 acct_type=acct_type, 638 account_id=account_id, (...) 648 options_data=options_data, 649 **kwargs) --> 650 return rt.run(**kwargs) File /var/app/enabled/bigtrader2/bigtrader/run_trading.py:401, in RunTrading.run(self, **kwargs) 398 return 400 if self.trading_env.run_mode == RunMode.BACKTEST: --> 401 return self._run_backtest(**kwargs) 402 else: 403 if not self.trading_env.account_id: File /var/app/enabled/bigtrader2/bigtrader/run_trading.py:428, in RunTrading._run_backtest(self, **kwargs) 426 debug_print("run_backtest() running...") 427 t0 = time.time() --> 428 bkt_engine.run() 429 cost_time = round(time.time() - t0, 3) 430 if show_debug_info: File bigtrader/strategy/backtest_engine.py:319, in bigtrader2.bigtrader.strategy.backtest_engine.BacktestEngine.run() File bigtrader/strategy/backtest_engine.py:549, in bigtrader2.bigtrader.strategy.backtest_engine.BacktestEngine.transform() File bigtrader/strategy/backtest_engine.py:518, in bigtrader2.bigtrader.strategy.backtest_engine.BacktestEngine.transform.replay_bars_dt() File bigtrader/event/event_engine.py:88, in bigtrader2.bigtrader.event.event_engine.EventEngine.process_events() File bigtrader/event/event_engine.py:83, in bigtrader2.bigtrader.event.event_engine.EventEngine.process_events() File bigtrader/event/event_engine.py:131, in bigtrader2.bigtrader.event.event_engine.EventEngine._process_without_lock() File bigtrader/strategy/engine.py:197, in bigtrader2.bigtrader.strategy.engine.StrategyEngine.process_bars_event() File bigtrader/strategy/engine.py:617, in bigtrader2.bigtrader.strategy.engine.StrategyEngine._call_strategy_func() File bigtrader/strategy/engine.py:608, in bigtrader2.bigtrader.strategy.engine.StrategyEngine._call_strategy_func() File bigtrader/strategy/strategy_base.py:2255, in bigtrader2.bigtrader.strategy.strategy_base.StrategyBase.call_handle_data() Cell In[2], line 105, in m7_handle_data_bigquant_run(context, data) 103 for ins in buy_list: 104 print('buy',ins)

    ...

    File bigtrader/strategy/strategy_base.py:746, in bigtrader2.bigtrader.strategy.strategy_base.StrategyBase.order_value() File bigtrader/strategy/strategy_base.py:1331, in bigtrader2.bigtrader.strategy.strategy_base.StrategyBase.current() File /var/app/enabled/bigtrader2/bigtrader/protocol.py:278, in BarDatas.current(self, assets, fields) 276 asset = assets.symbol if not isinstance(assets, str) else assets 277 if not multiple_fields: --> 278 return self.__data_engine.get_current_value(asset, curr_dt, fields) 279 else: 280 data = {} File bigtrader/mdata/engine.py:677, in bigtrader2.bigtrader.mdata.engine.DataEngine._get_minute_value_from_df() AttributeError: 'NoneType' object has no attribute 'get_value'

\

标签

HFTrade高频交易回测实盘
评论
  • 你好,hftrade回测引擎已改版,兼容了新版数据,请检查证券代码后缀以SZ或SH结尾
  • ok 已经解决 谢谢
{link}