复制链接
克隆策略

    {"description":"实验创建于2022/8/12","graph":{"edges":[{"to_node_id":"-2091:instruments","from_node_id":"-2078:data"},{"to_node_id":"-2091:features","from_node_id":"-2086:data"},{"to_node_id":"-2362:features","from_node_id":"-2086:data"},{"to_node_id":"-2362:input_data","from_node_id":"-2091:data"},{"to_node_id":"-2329:instruments","from_node_id":"-2316:data"},{"to_node_id":"-2329:features","from_node_id":"-2324:data"},{"to_node_id":"-2349:features","from_node_id":"-2324:data"},{"to_node_id":"-2349:input_data","from_node_id":"-2329:data"},{"to_node_id":"-2098:input_data","from_node_id":"-2336:data"},{"to_node_id":"-2336:data1","from_node_id":"-2343:data"},{"to_node_id":"-2343:input_ds","from_node_id":"-2349:data"},{"to_node_id":"-2098:features","from_node_id":"-2357:data"},{"to_node_id":"-2336:data2","from_node_id":"-2362:data"}],"nodes":[{"node_id":"-2078","module_id":"BigQuantSpace.instruments.instruments-v2","parameters":[{"name":"start_date","value":"2022-01-01","type":"Literal","bound_global_parameter":null},{"name":"end_date","value":"2022-08-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":"-2078"}],"output_ports":[{"name":"data","node_id":"-2078"}],"cacheable":true,"seq_num":1,"comment":"","comment_collapsed":true},{"node_id":"-2086","module_id":"BigQuantSpace.input_features.input_features-v1","parameters":[{"name":"features","value":"returns = close_0 / shift(close_0, 22)\n\n# return_Nm1 = close_0 / shift(close_0, 120)\n\n# wgt_return_Nm = mean(turn_0 * return_0, 22)\n\n# exp_wgt_return_Nm = ' + '.join(['shift(turn_0,{})*exp(-{}/1/4)'.format(k, k) for k in range(22)])","type":"Literal","bound_global_parameter":null}],"input_ports":[{"name":"features_ds","node_id":"-2086"}],"output_ports":[{"name":"data","node_id":"-2086"}],"cacheable":true,"seq_num":2,"comment":"","comment_collapsed":true},{"node_id":"-2091","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":"0","type":"Literal","bound_global_parameter":null}],"input_ports":[{"name":"instruments","node_id":"-2091"},{"name":"features","node_id":"-2091"}],"output_ports":[{"name":"data","node_id":"-2091"}],"cacheable":true,"seq_num":3,"comment":"","comment_collapsed":true},{"node_id":"-2098","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":"{}","type":"Literal","bound_global_parameter":null}],"input_ports":[{"name":"input_data","node_id":"-2098"},{"name":"features","node_id":"-2098"}],"output_ports":[{"name":"data","node_id":"-2098"}],"cacheable":false,"seq_num":4,"comment":"","comment_collapsed":true},{"node_id":"-2316","module_id":"BigQuantSpace.instruments.instruments-v2","parameters":[{"name":"start_date","value":"2022-01-01","type":"Literal","bound_global_parameter":null},{"name":"end_date","value":"2022-08-01","type":"Literal","bound_global_parameter":null},{"name":"market","value":"CN_STOCK_A","type":"Literal","bound_global_parameter":null},{"name":"instrument_list","value":"000001.HIX","type":"Literal","bound_global_parameter":null},{"name":"max_count","value":0,"type":"Literal","bound_global_parameter":null}],"input_ports":[{"name":"rolling_conf","node_id":"-2316"}],"output_ports":[{"name":"data","node_id":"-2316"}],"cacheable":true,"seq_num":9,"comment":"","comment_collapsed":true},{"node_id":"-2324","module_id":"BigQuantSpace.input_features.input_features-v1","parameters":[{"name":"features","value":"bm_close = bar1d_index_CN_STOCK_A__close\nbm_return = bm_close / shift(bm_close, 22)","type":"Literal","bound_global_parameter":null}],"input_ports":[{"name":"features_ds","node_id":"-2324"}],"output_ports":[{"name":"data","node_id":"-2324"}],"cacheable":true,"seq_num":10,"comment":"","comment_collapsed":true},{"node_id":"-2329","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":"0","type":"Literal","bound_global_parameter":null}],"input_ports":[{"name":"instruments","node_id":"-2329"},{"name":"features","node_id":"-2329"}],"output_ports":[{"name":"data","node_id":"-2329"}],"cacheable":true,"seq_num":11,"comment":"","comment_collapsed":true},{"node_id":"-2336","module_id":"BigQuantSpace.join.join-v3","parameters":[{"name":"on","value":"date","type":"Literal","bound_global_parameter":null},{"name":"how","value":"inner","type":"Literal","bound_global_parameter":null},{"name":"sort","value":"True","type":"Literal","bound_global_parameter":null}],"input_ports":[{"name":"data1","node_id":"-2336"},{"name":"data2","node_id":"-2336"}],"output_ports":[{"name":"data","node_id":"-2336"}],"cacheable":true,"seq_num":12,"comment":"","comment_collapsed":true},{"node_id":"-2343","module_id":"BigQuantSpace.select_columns.select_columns-v3","parameters":[{"name":"columns","value":"date,bm_return","type":"Literal","bound_global_parameter":null},{"name":"reverse_select","value":"False","type":"Literal","bound_global_parameter":null}],"input_ports":[{"name":"input_ds","node_id":"-2343"},{"name":"columns_ds","node_id":"-2343"}],"output_ports":[{"name":"data","node_id":"-2343"}],"cacheable":true,"seq_num":13,"comment":"","comment_collapsed":true},{"node_id":"-2349","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":"True","type":"Literal","bound_global_parameter":null},{"name":"user_functions","value":"{}","type":"Literal","bound_global_parameter":null}],"input_ports":[{"name":"input_data","node_id":"-2349"},{"name":"features","node_id":"-2349"}],"output_ports":[{"name":"data","node_id":"-2349"}],"cacheable":true,"seq_num":14,"comment":"","comment_collapsed":true},{"node_id":"-2357","module_id":"BigQuantSpace.input_features.input_features-v1","parameters":[{"name":"features","value":"intercept = ols(\"intercept\", returns, bm_return, 22)","type":"Literal","bound_global_parameter":null}],"input_ports":[{"name":"features_ds","node_id":"-2357"}],"output_ports":[{"name":"data","node_id":"-2357"}],"cacheable":true,"seq_num":15,"comment":"","comment_collapsed":true},{"node_id":"-2362","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":"True","type":"Literal","bound_global_parameter":null},{"name":"user_functions","value":"{}","type":"Literal","bound_global_parameter":null}],"input_ports":[{"name":"input_data","node_id":"-2362"},{"name":"features","node_id":"-2362"}],"output_ports":[{"name":"data","node_id":"-2362"}],"cacheable":true,"seq_num":16,"comment":"","comment_collapsed":true}],"node_layout":"<node_postions><node_position Node='-2078' Position='332.70562744140625,380.25836181640625,200,200'/><node_position Node='-2086' Position='662.0886840820312,379.06683349609375,200,200'/><node_position Node='-2091' Position='506.70562744140625,476.06683349609375,200,200'/><node_position Node='-2098' Position='468.385498046875,973.1824645996094,200,200'/><node_position Node='-2316' Position='-316.6722412109375,385.00254821777344,200,200'/><node_position Node='-2324' Position='15.093841552734375,382.61949157714844,200,200'/><node_position Node='-2329' Position='-139.0977020263672,480.81101989746094,200,200'/><node_position Node='-2336' Position='183.29153442382812,800.5349731445312,200,200'/><node_position Node='-2343' Position='-141.9924921989441,649.8082275390625,200,200'/><node_position Node='-2349' Position='-141.67230987548828,551.3637390136719,200,200'/><node_position Node='-2357' Position='618.001220703125,796.0757446289062,200,200'/><node_position Node='-2362' Position='504.12969970703125,562.0874328613281,200,200'/></node_postions>"},"nodes_readonly":false,"studio_version":"v2"}
    In [89]:
    # 本代码由可视化策略环境自动生成 2022年8月12日 17:27
    # 本代码单元只能在可视化模式下编辑。您也可以拷贝代码,粘贴到新建的代码单元或者策略,然后修改。
    
    
    m1 = M.instruments.v2(
        start_date='2022-01-01',
        end_date='2022-08-01',
        market='CN_STOCK_A',
        instrument_list='',
        max_count=0
    )
    
    m2 = M.input_features.v1(
        features="""returns = close_0 / shift(close_0, 22)
    
    # return_Nm1 = close_0 / shift(close_0, 120)
    
    # wgt_return_Nm = mean(turn_0 * return_0, 22)
    
    # exp_wgt_return_Nm = ' + '.join(['shift(turn_0,{})*exp(-{}/1/4)'.format(k, k) for k in range(22)])"""
    )
    
    m3 = M.general_feature_extractor.v7(
        instruments=m1.data,
        features=m2.data,
        start_date='',
        end_date='',
        before_start_days=0
    )
    
    m16 = M.derived_feature_extractor.v3(
        input_data=m3.data,
        features=m2.data,
        date_col='date',
        instrument_col='instrument',
        drop_na=True,
        remove_extra_columns=True,
        user_functions={}
    )
    
    m9 = M.instruments.v2(
        start_date='2022-01-01',
        end_date='2022-08-01',
        market='CN_STOCK_A',
        instrument_list='000001.HIX',
        max_count=0
    )
    
    m10 = M.input_features.v1(
        features="""bm_close = bar1d_index_CN_STOCK_A__close
    bm_return = bm_close / shift(bm_close, 22)"""
    )
    
    m11 = M.general_feature_extractor.v7(
        instruments=m9.data,
        features=m10.data,
        start_date='',
        end_date='',
        before_start_days=0
    )
    
    m14 = M.derived_feature_extractor.v3(
        input_data=m11.data,
        features=m10.data,
        date_col='date',
        instrument_col='instrument',
        drop_na=True,
        remove_extra_columns=True,
        user_functions={}
    )
    
    m13 = M.select_columns.v3(
        input_ds=m14.data,
        columns='date,bm_return',
        reverse_select=False
    )
    
    m12 = M.join.v3(
        data1=m13.data,
        data2=m16.data,
        on='date',
        how='inner',
        sort=True
    )
    
    m15 = M.input_features.v1(
        features='intercept = ols("intercept", returns, bm_return, 22)'
    )
    
    m4 = M.derived_feature_extractor.v3(
        input_data=m12.data,
        features=m15.data,
        date_col='date',
        instrument_col='instrument',
        drop_na=False,
        remove_extra_columns=False,
        user_functions={},
        m_cached=False
    )
    
    列: ['date', 'bm_return']
    /y_2022: 117
    
    In [ ]: