复制链接
克隆策略

    {"description":"实验创建于2021/12/10","graph":{"edges":[{"to_node_id":"-91:features","from_node_id":"-77:data"},{"to_node_id":"-106:features","from_node_id":"-77:data"},{"to_node_id":"-106:input_data","from_node_id":"-91:data"},{"to_node_id":"-91:instruments","from_node_id":"-97:data"}],"nodes":[{"node_id":"-77","module_id":"BigQuantSpace.input_features.input_features-v1","parameters":[{"name":"features","value":"\n# #号开始的表示注释,注释需单独一行\n# 多个特征,每行一个,可以包含基础特征和衍生特征,特征须为本平台特征\nreturn_5\ntimex = timex(close_0,open_0)\nMA5 = mean(close_0, 5)\n","type":"Literal","bound_global_parameter":null}],"input_ports":[{"name":"features_ds","node_id":"-77"}],"output_ports":[{"name":"data","node_id":"-77"}],"cacheable":true,"seq_num":1,"comment":"","comment_collapsed":true},{"node_id":"-91","module_id":"BigQuantSpace.general_feature_extractor.general_feature_extractor-v7","parameters":[{"name":"start_date","value":"","type":"Literal","bound_global_parameter":null},{"name":"end_date","value":"","type":"Literal","bound_global_parameter":null},{"name":"before_start_days","value":90,"type":"Literal","bound_global_parameter":null}],"input_ports":[{"name":"instruments","node_id":"-91"},{"name":"features","node_id":"-91"}],"output_ports":[{"name":"data","node_id":"-91"}],"cacheable":true,"seq_num":3,"comment":"","comment_collapsed":true},{"node_id":"-97","module_id":"BigQuantSpace.instruments.instruments-v2","parameters":[{"name":"start_date","value":"2021-01-01","type":"Literal","bound_global_parameter":null},{"name":"end_date","value":"2021-12-01","type":"Literal","bound_global_parameter":null},{"name":"market","value":"CN_STOCK_A","type":"Literal","bound_global_parameter":null},{"name":"instrument_list","value":"","type":"Literal","bound_global_parameter":null},{"name":"max_count","value":0,"type":"Literal","bound_global_parameter":null}],"input_ports":[{"name":"rolling_conf","node_id":"-97"}],"output_ports":[{"name":"data","node_id":"-97"}],"cacheable":true,"seq_num":4,"comment":"","comment_collapsed":true},{"node_id":"-106","module_id":"BigQuantSpace.derived_feature_extractor.derived_feature_extractor-v3","parameters":[{"name":"date_col","value":"date","type":"Literal","bound_global_parameter":null},{"name":"instrument_col","value":"instrument","type":"Literal","bound_global_parameter":null},{"name":"drop_na","value":"False","type":"Literal","bound_global_parameter":null},{"name":"remove_extra_columns","value":"False","type":"Literal","bound_global_parameter":null},{"name":"user_functions","value":"def timex(df,s,x):\n return s * x\n\n\nbigquant_run = {\n 'timex' : timex\n}","type":"Literal","bound_global_parameter":null}],"input_ports":[{"name":"input_data","node_id":"-106"},{"name":"features","node_id":"-106"}],"output_ports":[{"name":"data","node_id":"-106"}],"cacheable":true,"seq_num":2,"comment":"","comment_collapsed":true}],"node_layout":"<node_postions><node_position Node='-77' Position='503,67,200,200'/><node_position Node='-91' Position='389,173,200,200'/><node_position Node='-97' Position='202,67,200,200'/><node_position Node='-106' Position='437,306,200,200'/></node_postions>"},"nodes_readonly":false,"studio_version":"v2"}
    In [25]:
    # 本代码由可视化策略环境自动生成 2021年12月14日 10:20
    # 本代码单元只能在可视化模式下编辑。您也可以拷贝代码,粘贴到新建的代码单元或者策略,然后修改。
    
    
    def timex(df,s,x):
        return s * x
    
    
    m2_user_functions_bigquant_run = {
        'timex' : timex
    }
    
    m1 = M.input_features.v1(
        features="""
    # #号开始的表示注释,注释需单独一行
    # 多个特征,每行一个,可以包含基础特征和衍生特征,特征须为本平台特征
    return_5
    timex = timex(close_0,open_0)
    MA5 = mean(close_0, 5)
    """
    )
    
    m4 = M.instruments.v2(
        start_date='2021-01-01',
        end_date='2021-12-01',
        market='CN_STOCK_A',
        instrument_list='',
        max_count=0
    )
    
    m3 = M.general_feature_extractor.v7(
        instruments=m4.data,
        features=m1.data,
        start_date='',
        end_date='',
        before_start_days=90
    )
    
    m2 = M.derived_feature_extractor.v3(
        input_data=m3.data,
        features=m1.data,
        date_col='date',
        instrument_col='instrument',
        drop_na=False,
        remove_extra_columns=False,
        user_functions=m2_user_functions_bigquant_run
    )
    
    In [26]:
    m2.data.read()
    
    Out[26]:
    close_0 date instrument open_0 return_5 timex MA5
    0 1685.719482 2020-10-09 000001.SZA 1699.045288 0.971209 2.864114e+06 NaN
    1 1765.674561 2020-10-12 000001.SZA 1690.161377 1.051587 2.984275e+06 NaN
    2 1783.442383 2020-10-13 000001.SZA 1765.674561 1.057275 3.148979e+06 NaN
    3 1780.110840 2020-10-14 000001.SZA 1781.221313 1.047028 3.170771e+06 NaN
    4 1838.966675 2020-10-15 000001.SZA 1798.989136 1.118919 3.308281e+06 1770.782788
    ... ... ... ... ... ... ... ...
    1202960 24.104408 2021-11-25 872925.BJA 24.469166 0.947809 5.898148e+02 23.958506
    1202961 24.823792 2021-11-26 872925.BJA 24.114540 1.007401 5.986143e+02 24.197625
    1202962 23.658594 2021-11-29 872925.BJA 24.570488 1.001287 5.813032e+02 24.240180
    1202963 23.810575 2021-11-30 872925.BJA 23.739651 1.015557 5.652548e+02 24.094276
    1202964 23.628197 2021-12-01 872925.BJA 23.658594 0.962841 5.590099e+02 24.005113

    1202965 rows × 7 columns