复制链接
克隆策略

    {"description":"实验创建于2022/3/24","graph":{"edges":[{"to_node_id":"-3201:instruments","from_node_id":"287d2cb0-f53c-4101-bdf8-104b137c8601-8:data"},{"to_node_id":"-106:instruments","from_node_id":"287d2cb0-f53c-4101-bdf8-104b137c8601-8:data"},{"to_node_id":"-7902:instruments","from_node_id":"287d2cb0-f53c-4101-bdf8-104b137c8601-8:data"},{"to_node_id":"-3194:data2","from_node_id":"-3201:data"},{"to_node_id":"-3194:data1","from_node_id":"-1150:data"},{"to_node_id":"-113:input_data","from_node_id":"-106:data"},{"to_node_id":"-106:features","from_node_id":"-2196:data"},{"to_node_id":"-113:features","from_node_id":"-2196:data"},{"to_node_id":"-1162:input_ds","from_node_id":"-3194:data"},{"to_node_id":"-1150:input_data","from_node_id":"-113:data"},{"to_node_id":"-7902:features","from_node_id":"-7897:data"},{"to_node_id":"-7909:features","from_node_id":"-7897:data"},{"to_node_id":"-7909:input_data","from_node_id":"-7902:data"},{"to_node_id":"-10646:data2","from_node_id":"-7909:data"},{"to_node_id":"-10646:data1","from_node_id":"-1162:data"},{"to_node_id":"-276:input_1","from_node_id":"-10646:data"}],"nodes":[{"node_id":"287d2cb0-f53c-4101-bdf8-104b137c8601-8","module_id":"BigQuantSpace.instruments.instruments-v2","parameters":[{"name":"start_date","value":"2018-02-01","type":"Literal","bound_global_parameter":null},{"name":"end_date","value":"2020-12-31","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":"287d2cb0-f53c-4101-bdf8-104b137c8601-8"}],"output_ports":[{"name":"data","node_id":"287d2cb0-f53c-4101-bdf8-104b137c8601-8"}],"cacheable":true,"seq_num":1,"comment":"","comment_collapsed":true},{"node_id":"-3201","module_id":"BigQuantSpace.use_datasource.use_datasource-v1","parameters":[{"name":"datasource_id","value":"bar1d_CN_STOCK_A","type":"Literal","bound_global_parameter":null},{"name":"start_date","value":"","type":"Literal","bound_global_parameter":null},{"name":"end_date","value":"","type":"Literal","bound_global_parameter":null}],"input_ports":[{"name":"instruments","node_id":"-3201"},{"name":"features","node_id":"-3201"}],"output_ports":[{"name":"data","node_id":"-3201"}],"cacheable":true,"seq_num":3,"comment":"","comment_collapsed":true},{"node_id":"-1150","module_id":"BigQuantSpace.filter.filter-v3","parameters":[{"name":"expr","value":"cond4 and cond6","type":"Literal","bound_global_parameter":null},{"name":"output_left_data","value":"False","type":"Literal","bound_global_parameter":null}],"input_ports":[{"name":"input_data","node_id":"-1150"}],"output_ports":[{"name":"data","node_id":"-1150"},{"name":"left_data","node_id":"-1150"}],"cacheable":true,"seq_num":4,"comment":"","comment_collapsed":true},{"node_id":"-106","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":"58","type":"Literal","bound_global_parameter":null}],"input_ports":[{"name":"instruments","node_id":"-106"},{"name":"features","node_id":"-106"}],"output_ports":[{"name":"data","node_id":"-106"}],"cacheable":true,"seq_num":5,"comment":"","comment_collapsed":true},{"node_id":"-2196","module_id":"BigQuantSpace.input_features.input_features-v1","parameters":[{"name":"features","value":"\ncond4= abs((close_0-close_1)/close_1) >0.03\n\ncond6=st_status_0==0\n","type":"Literal","bound_global_parameter":null}],"input_ports":[{"name":"features_ds","node_id":"-2196"}],"output_ports":[{"name":"data","node_id":"-2196"}],"cacheable":true,"seq_num":6,"comment":"","comment_collapsed":true},{"node_id":"-3194","module_id":"BigQuantSpace.join.join-v3","parameters":[{"name":"on","value":"date,instrument","type":"Literal","bound_global_parameter":null},{"name":"how","value":"inner","type":"Literal","bound_global_parameter":null},{"name":"sort","value":"False","type":"Literal","bound_global_parameter":null}],"input_ports":[{"name":"data1","node_id":"-3194"},{"name":"data2","node_id":"-3194"}],"output_ports":[{"name":"data","node_id":"-3194"}],"cacheable":true,"seq_num":8,"comment":"","comment_collapsed":true},{"node_id":"-113","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":"True","type":"Literal","bound_global_parameter":null},{"name":"remove_extra_columns","value":"False","type":"Literal","bound_global_parameter":null},{"name":"user_functions","value":"","type":"Literal","bound_global_parameter":null}],"input_ports":[{"name":"input_data","node_id":"-113"},{"name":"features","node_id":"-113"}],"output_ports":[{"name":"data","node_id":"-113"}],"cacheable":true,"seq_num":2,"comment":"","comment_collapsed":true},{"node_id":"-7897","module_id":"BigQuantSpace.input_features.input_features-v1","parameters":[{"name":"features","value":"turn_0\nts_max(amount_0,10)\nmean(close_0,5)","type":"Literal","bound_global_parameter":null}],"input_ports":[{"name":"features_ds","node_id":"-7897"}],"output_ports":[{"name":"data","node_id":"-7897"}],"cacheable":true,"seq_num":9,"comment":"","comment_collapsed":true},{"node_id":"-7902","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":"58","type":"Literal","bound_global_parameter":null}],"input_ports":[{"name":"instruments","node_id":"-7902"},{"name":"features","node_id":"-7902"}],"output_ports":[{"name":"data","node_id":"-7902"}],"cacheable":true,"seq_num":10,"comment":"","comment_collapsed":true},{"node_id":"-7909","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":"True","type":"Literal","bound_global_parameter":null},{"name":"remove_extra_columns","value":"False","type":"Literal","bound_global_parameter":null},{"name":"user_functions","value":"","type":"Literal","bound_global_parameter":null}],"input_ports":[{"name":"input_data","node_id":"-7909"},{"name":"features","node_id":"-7909"}],"output_ports":[{"name":"data","node_id":"-7909"}],"cacheable":true,"seq_num":11,"comment":"","comment_collapsed":true},{"node_id":"-1162","module_id":"BigQuantSpace.select_columns.select_columns-v3","parameters":[{"name":"columns","value":"date,instrument","type":"Literal","bound_global_parameter":null},{"name":"reverse_select","value":"False","type":"Literal","bound_global_parameter":null}],"input_ports":[{"name":"input_ds","node_id":"-1162"},{"name":"columns_ds","node_id":"-1162"}],"output_ports":[{"name":"data","node_id":"-1162"}],"cacheable":true,"seq_num":7,"comment":"","comment_collapsed":true},{"node_id":"-10646","module_id":"BigQuantSpace.join.join-v3","parameters":[{"name":"on","value":"date,instrument","type":"Literal","bound_global_parameter":null},{"name":"how","value":"inner","type":"Literal","bound_global_parameter":null},{"name":"sort","value":"False","type":"Literal","bound_global_parameter":null}],"input_ports":[{"name":"data1","node_id":"-10646"},{"name":"data2","node_id":"-10646"}],"output_ports":[{"name":"data","node_id":"-10646"}],"cacheable":true,"seq_num":12,"comment":"","comment_collapsed":true},{"node_id":"-276","module_id":"BigQuantSpace.standardlize.standardlize-v8","parameters":[{"name":"columns_input","value":"","type":"Literal","bound_global_parameter":null}],"input_ports":[{"name":"input_1","node_id":"-276"},{"name":"input_2","node_id":"-276"}],"output_ports":[{"name":"data","node_id":"-276"}],"cacheable":true,"seq_num":13,"comment":"","comment_collapsed":true}],"node_layout":"<node_postions><node_position Node='287d2cb0-f53c-4101-bdf8-104b137c8601-8' Position='220,-490,200,200'/><node_position Node='-3201' Position='231,-324,200,200'/><node_position Node='-1150' Position='-6,-77,200,200'/><node_position Node='-106' Position='-123,-322,200,200'/><node_position Node='-2196' Position='-120,-496,200,200'/><node_position Node='-3194' Position='0,42,200,200'/><node_position Node='-113' Position='-123,-218,200,200'/><node_position Node='-7897' Position='571,-140,200,200'/><node_position Node='-7902' Position='587,1,200,200'/><node_position Node='-7909' Position='584,121,200,200'/><node_position Node='-1162' Position='0,157,200,200'/><node_position Node='-10646' Position='217.55703735351562,268.6330871582031,200,200'/><node_position Node='-276' Position='304.3955993652344,397.8632507324219,200,200'/></node_postions>"},"nodes_readonly":false,"studio_version":"v2"}
    In [69]:
    # 本代码由可视化策略环境自动生成 2022年3月24日 12:44
    # 本代码单元只能在可视化模式下编辑。您也可以拷贝代码,粘贴到新建的代码单元或者策略,然后修改。
    
    
    m1 = M.instruments.v2(
        start_date='2018-02-01',
        end_date='2020-12-31',
        market='CN_STOCK_A',
        instrument_list=' ',
        max_count=0
    )
    
    m3 = M.use_datasource.v1(
        instruments=m1.data,
        datasource_id='bar1d_CN_STOCK_A',
        start_date='',
        end_date=''
    )
    
    m6 = M.input_features.v1(
        features="""
    cond4= abs((close_0-close_1)/close_1) >0.03
    
    cond6=st_status_0==0
    """
    )
    
    m5 = M.general_feature_extractor.v7(
        instruments=m1.data,
        features=m6.data,
        start_date='',
        end_date='',
        before_start_days=58
    )
    
    m2 = M.derived_feature_extractor.v3(
        input_data=m5.data,
        features=m6.data,
        date_col='date',
        instrument_col='instrument',
        drop_na=True,
        remove_extra_columns=False
    )
    
    m4 = M.filter.v3(
        input_data=m2.data,
        expr='cond4 and cond6',
        output_left_data=False
    )
    
    m8 = M.join.v3(
        data1=m4.data,
        data2=m3.data,
        on='date,instrument',
        how='inner',
        sort=False
    )
    
    m7 = M.select_columns.v3(
        input_ds=m8.data,
        columns='date,instrument',
        reverse_select=False
    )
    
    m9 = M.input_features.v1(
        features="""turn_0
    ts_max(amount_0,10)
    mean(close_0,5)"""
    )
    
    m10 = M.general_feature_extractor.v7(
        instruments=m1.data,
        features=m9.data,
        start_date='',
        end_date='',
        before_start_days=58
    )
    
    m11 = M.derived_feature_extractor.v3(
        input_data=m10.data,
        features=m9.data,
        date_col='date',
        instrument_col='instrument',
        drop_na=True,
        remove_extra_columns=False
    )
    
    m12 = M.join.v3(
        data1=m7.data,
        data2=m11.data,
        on='date,instrument',
        how='inner',
        sort=False
    )
    
    m13 = M.standardlize.v8(
        input_1=m12.data,
        columns_input=''
    )
    
    列: ['date', 'instrument']
    /y_2017: 0
    /y_2018: 154561
    /y_2019: 166854
    /y_2020: 215682
    
    In [72]:
    m12.data.read_df()
    
    Out[72]:
    amount_0 close_0 date instrument turn_0 ts_max(amount_0,10) mean(close_0,5)
    0 3.326355e+09 1546.792969 2018-02-05 000001.SZA 1.378413 3.838735e+09 1495.339478
    1 3.641295e+09 1488.323120 2018-02-06 000001.SZA 1.526702 3.838735e+09 1502.781104
    2 4.521587e+09 1373.509521 2018-02-07 000001.SZA 1.977609 4.521587e+09 1478.755298
    3 3.308554e+09 1242.749756 2018-02-09 000001.SZA 1.669791 4.521587e+09 1396.897510
    4 1.573563e+09 1324.607544 2018-02-22 000001.SZA 0.749738 4.521587e+09 1271.665747
    ... ... ... ... ... ... ... ...
    213394 5.636281e+08 73.099998 2020-12-24 689009.SHA 12.703243 7.293031e+08 74.874001
    213395 6.488905e+08 80.099998 2020-12-28 689009.SHA 14.095573 7.293031e+08 76.779999
    213396 4.975511e+08 77.459999 2020-12-29 689009.SHA 10.811251 7.293031e+08 77.171999
    213397 5.506528e+08 80.910004 2020-12-30 689009.SHA 11.944640 7.293031e+08 77.334000
    213398 5.421623e+08 85.820000 2020-12-31 689009.SHA 11.130113 7.293031e+08 79.878000

    532388 rows × 7 columns

    In [71]:
    m13.data.read_df()
    
    Out[71]:
    amount_0 close_0 date instrument turn_0 ts_max(amount_0,10) mean(close_0,5)
    0 3.326355e+09 1546.792969 2018-02-05 000001.SZA 1.378413 3.838735e+09 1495.339478
    1 3.641295e+09 1488.323120 2018-02-06 000001.SZA 1.526702 3.838735e+09 1502.781104
    2 4.521587e+09 1373.509521 2018-02-07 000001.SZA 1.977609 4.521587e+09 1478.755298
    3 3.308554e+09 1242.749756 2018-02-09 000001.SZA 1.669791 4.521587e+09 1396.897510
    4 1.573563e+09 1324.607544 2018-02-22 000001.SZA 0.749738 4.521587e+09 1271.665747
    ... ... ... ... ... ... ... ...
    213394 5.636281e+08 73.099998 2020-12-24 689009.SHA 12.703243 7.293031e+08 74.874001
    213395 6.488905e+08 80.099998 2020-12-28 689009.SHA 14.095573 7.293031e+08 76.779999
    213396 4.975511e+08 77.459999 2020-12-29 689009.SHA 10.811251 7.293031e+08 77.171999
    213397 5.506528e+08 80.910004 2020-12-30 689009.SHA 11.944640 7.293031e+08 77.334000
    213398 5.421623e+08 85.820000 2020-12-31 689009.SHA 11.130113 7.293031e+08 79.878000

    532388 rows × 7 columns