问答交流

回测、平台——IndexError: tuple index out of range

由a5130512创建,最终由small_q 被浏览 41 用户

  • \

    HDF5ExtError                              Traceback (most recent call last)
    File /var/app/enabled/bigdatasource/impl/dsimpl/hdf.py:21, in wrapped_func(*args, **kwargs)
    File /var/app/enabled/bigdatasource/impl/dsimpl/hdf.py:104, in read_hdf_from_bigma(fn, key)
    File /usr/local/python3/lib/python3.8/site-packages/pandas/io/pytables.py:561, in HDFStore.__init__(self, path, mode, complevel, complib, fletcher32, **kwargs)
        560 self._filters = None
    --> 561 self.open(mode=mode, **kwargs)
    File /usr/local/python3/lib/python3.8/site-packages/pandas/io/pytables.py:710, in HDFStore.open(self, mode, **kwargs)
        708     raise ValueError(msg)
    --> 710 self._handle = tables.open_file(self._path, self._mode, **kwargs)
    File /usr/local/python3/lib/python3.8/site-packages/tables/file.py:315, in open_file(filename, mode, title, root_uep, filters, **kwargs)
        314 # Finally, create the File instance, and return it
    --> 315 return File(filename, mode, title, root_uep, filters, **kwargs)
    File /usr/local/python3/lib/python3.8/site-packages/tables/file.py:778, in File.__init__(self, filename, mode, title, root_uep, filters, **kwargs)
        777 # Now, it is time to initialize the File extension
    --> 778 self._g_new(filename, mode, **params)
        780 # Check filters and set PyTables format version for new files.
    File tables/hdf5extension.pyx:492, in tables.hdf5extension.File._g_new()
    HDF5ExtError: HDF5 error back trace
      File "H5F.c", line 509, in H5Fopen
        unable to open file
      File "H5Fint.c", line 1400, in H5F__open
        unable to open file
      File "H5Fint.c", line 1700, in H5F_open
        unable to read superblock
      File "H5Fsuper.c", line 411, in H5F__super_read
        file signature not found
    End of HDF5 error back trace
    Unable to open/create file '/tmp/data.h5'
    During handling of the above exception, another exception occurred:
    IndexError                                Traceback (most recent call last)
    Cell In[5], line 201
        175 m9 = M.derived_feature_extractor.v3(
        176     input_data=m8.data,
        177     features=m1.data,
       (...)
        182     user_functions={}
        183 )
        185 m5 = M.stock_ranker.v2(
        186     training_ds=m4.data,
        187     features=m1.data,
       (...)
        198     slim_data=True
        199 )
    --> 201 m10 = M.trade.v4(
        202     instruments=m3.data,
        203     options_data=m5.model,
        204     start_date='2016-01-01',
        205     end_date='2018-01-01',
        206     initialize=m10_initialize_bigquant_run,
        207     handle_data=m10_handle_data_bigquant_run,
        208     prepare=m10_prepare_bigquant_run,
        209     before_trading_start=m10_before_trading_start_bigquant_run,
        210     volume_limit=0.025,
        211     order_price_field_buy='close',
        212     order_price_field_sell='close',
        213     capital_base=1000000,
        214     auto_cancel_non_tradable_orders=True,
        215     data_frequency='daily',
        216     price_type='后复权',
        217     product_type='股票',
        218     plot_charts=True,
        219     backtest_only=False,
        220     benchmark='000300.HIX'
        221 )
    File /var/app/enabled/biglearning/module2/common/modulemanagerv2.py:88, in __call__(self, **kwargs)
    File /var/app/enabled/biglearning/module2/common/moduleinvoker.py:331, in module_invoke(name, version, custom_module, kwargs)
    File /var/app/enabled/biglearning/module2/common/moduleinvoker.py:214, in _invoke_with_cache(module, kwargs, module_cache_key, name, version, remote_run)
    File /var/app/enabled/biglearning/module2/common/moduleinvoker.py:171, in _module_run(module, kwargs)
    File /var/app/enabled/biglearning/module2/modules/trade/v4/__init__.py:363, in bigquant_run(start_date, end_date, initialize, handle_data, instruments, prepare, before_trading_start, volume_limit, order_price_field_buy, order_price_field_sell, capital_base, auto_cancel_non_tradable_orders, data_frequency, price_type, product_type, plot_charts, backtest_only, options_data, options, history_ds, benchmark_ds, benchmark, trading_calendar, amount_integer, m_meta_kwargs)
    File /var/app/enabled/biglearning/module2/common/modulemanagerv2.py:88, in __call__(self, **kwargs)
    File /var/app/enabled/biglearning/module2/common/moduleinvoker.py:331, in module_invoke(name, version, custom_module, kwargs)
    File /var/app/enabled/biglearning/module2/common/moduleinvoker.py:214, in _invoke_with_cache(module, kwargs, module_cache_key, name, version, remote_run)
    File /var/app/enabled/biglearning/module2/common/moduleinvoker.py:173, in _module_run(module, kwargs)
    File /var/app/enabled/biglearning/module2/modules/backtest/v8/__init__.py:1055, in run(self)
    File /var/app/enabled/biglearning/module2/modules/backtest/v8/__init__.py:1029, in run_algo(self)
    File /var/app/enabled/bigline/zipline/algorithm.py:877, in TradingAlgorithm.run(self, data, overwrite_sim_params)
        875 try:
        876     perfs = []
    --> 877     for perf in self.get_generator():
        878         perfs.append(perf)
        880         if self.show_debug_info:
    File /var/app/enabled/bigline/zipline/algorithm.py:717, in TradingAlgorithm.get_generator(self)
        711 def get_generator(self):
        712     """
        713     Override this method to add new logic to the construction
        714     of the generator. Overrides can use the _create_generator
        715     method to get a standard construction generator.
        716     """
    --> 717     return self._create_generator(self.sim_params)...
    

    Cell In[5], line 28, in m10_initialize_bigquant_run(context) 26 def m10_initialize_bigquant_run(context): 27 # 加载预测数据 ---> 28 context.ranker_prediction = context.options['data'].read_df() 30 # 系统已经设置了默认的交易手续费和滑点,要修改手续费可使用如下函数 31 context.set_commission(PerOrder(buy_cost=0.0003, sell_cost=0.0013, min_cost=5)) File /var/app/enabled/bigdatasource/api/v6/init.py:58, in read_df(self, key) File /var/app/enabled/bigdatasource/impl/dsimpl/hdf.py:91, in read_df(id, version, key) File /var/app/enabled/bigdatasource/impl/dsimpl/hdf.py:25, in wrapped_func(*args, **kwargs) IndexError: tuple index out of range


\

标签

回测
评论
  • 可以把策略分享出来,我们复现一下哈
  • 你再运行一下呢
{link}