问答交流

数据源报错——nonetype

由bqlf38ns创建,最终由small_q 被浏览 40 用户

# 本代码由可视化策略环境自动生成 2023年9月2日 18:54
# 本代码单元只能在可视化模式下编辑。您也可以拷贝代码,粘贴到新建的代码单元或者策略,然后修改。
 
# 显式导入 BigQuant 相关 SDK 模块
from bigdatasource.api import DataSource
from bigdata.api.datareader import D
from biglearning.api import M
from biglearning.api import tools as T
from biglearning.module2.common.data import Outputs
 
import pandas as pd
import numpy as np
import math
import warnings
import datetime
 
from zipline.finance.commission import PerOrder
from zipline.api import get_open_orders
from zipline.api import symbol
 
from bigtrader.sdk import *
from bigtrader.utils.my_collections import NumPyDeque
from bigtrader.constant import OrderType
from bigtrader.constant import Direction

m1 = M.instruments.v2(
    start_date='20200101',
    end_date='20230901',
    market='CN_STOCK_A',
    instrument_list='',
    max_count=0
)

m5 = M.input_features.v1(
    features="""
# #号开始的表示注释,注释需单独一行
# 多个特征,每行一个,可以包含基础特征和衍生特征,特征须为本平台特征
close_0
high_0
low_0
ta_macd_macd_12_26_9_0
ta_macd_macdsignal_12_26_9_0
"""
)

m2 = M.general_feature_extractor.v7(
    instruments=m1.data,
    features=m5.data,
    start_date='20200101',
    end_date='20230901',
    before_start_days=90
)

m3 = M.derived_feature_extractor.v3(
    input_data=m2.data,
    features=m5.data,
    date_col='date',
    instrument_col='instrument',
    drop_na=True,
    remove_extra_columns=False,
    user_functions={}
)

m7 = M.use_datasource.v2(
    datasource_id='cn_stock_factors_ta',
    start_date='2020-01-01',
    end_date='2023-09-01',
    before_start_days=90
)

m8 = M.input_features.v1(
    features="""
# #号开始的表示注释,注释需单独一行
# 多个特征,每行一个,可以包含基础特征和衍生特征,特征须为本平台特征
macd_dif
macd_dea
macd_hist
macd_golden
macd_death"""
)

m9 = M.derived_feature_extractor.v3(
    input_data=m7.data,
    features=m8.data,
    date_col='date',
    instrument_col='instrument',
    drop_na=True,
    remove_extra_columns=False,
    user_functions={}
)

m11 = M.join.v3(
    data1=m3.data,
    data2=m9.data,
    on='date,instrument',
    how='inner',
    sort=False
)

m4 = M.chinaa_stock_filter.v1(
    input_data=m11.data,
    index_constituent_cond=['全部'],
    board_cond=['上证主板', '深证主板', '创业板', '科创板'],
    industry_cond=['全部'],
    st_cond=['正常'],
    delist_cond=['非退市'],
    output_left_data=False
)

m13 = M.filter.v3(
    input_data=m4.data,
    expr='list_days_0>250 and market_cap_0>10000000000',
    output_left_data=False
)

m6 = M.dropnan.v2(
    input_data=m13.data
)

运行时报错,日志如下,不知道为什么,求教,谢谢

  • \
    ---------------------------------------------------------------------------
    AttributeError                            Traceback (most recent call last)
    File /var/app/enabled/bigdatasource/impl/dsimpl/hdf.py:40, in write_df_helper(df, path, key)
    AttributeError: 'NoneType' object has no attribute 'to_hdf'
    During handling of the above exception, another exception occurred:
    AttributeError                            Traceback (most recent call last)
    Cell In[7], line 26
         23 from bigtrader.constant import OrderType
         24 from bigtrader.constant import Direction
    ---> 26 m7 = M.use_datasource.v2(
         27     datasource_id='cn_stock_factors_ta',
         28     start_date='2020-01-01',
         29     end_date='2023-09-01',
         30     before_start_days=90
         31 )
    File module2/common/modulemanagerv2.py:88, in biglearning.module2.common.modulemanagerv2.BigQuantModuleVersion.__call__()
    File module2/common/moduleinvoker.py:331, in biglearning.module2.common.moduleinvoker.module_invoke()
    File module2/common/moduleinvoker.py:253, in biglearning.module2.common.moduleinvoker._invoke_with_cache()
    File module2/common/moduleinvoker.py:214, in biglearning.module2.common.moduleinvoker._invoke_with_cache()
    File module2/common/moduleinvoker.py:173, in biglearning.module2.common.moduleinvoker._module_run()
    File module2/modules/use_datasource/v2/__init__.py:60, in biglearning.module2.modules.use_datasource.v2.__init__.BigQuantModule.run()
    File /var/app/enabled/bigdatasource/api/v6/__init__.py:48, in write_df(cls, df, key, use_cache, **kwargs)
    File /var/app/enabled/bigdatasource/impl/dsimpl/hdf.py:79, in write_df(df, key, use_cache, **kwargs)
    File /var/app/enabled/bigdatasource/impl/dsimpl/hdf.py:65, in _write(df, key, **kwargs)
    File /var/app/enabled/bigdatasource/impl/dsimpl/hdf.py:42, in write_df_helper(df, path, key)
    AttributeError: 'NoneType' object has no attribute 'to_hdf'
    

\

评论
  • 重启下开发环境就好。
  • undefined
{link}