复制链接
克隆策略
In [ ]:
 

    {"description":"实验创建于2021/10/29","graph":{"edges":[{"to_node_id":"-6:instruments","from_node_id":"-16:data"},{"to_node_id":"-6:features","from_node_id":"-24:data"},{"to_node_id":"-6:user_functions","from_node_id":"-28:functions"}],"nodes":[{"node_id":"-6","module_id":"BigQuantSpace.feature_extractor_1m.feature_extractor_1m-v2","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},{"name":"workers","value":"2","type":"Literal","bound_global_parameter":null},{"name":"parallel_mode","value":"测试","type":"Literal","bound_global_parameter":null},{"name":"table_1m","value":"level2_bar1m_CN_STOCK_A","type":"Literal","bound_global_parameter":null}],"input_ports":[{"name":"instruments","node_id":"-6"},{"name":"features","node_id":"-6"},{"name":"user_functions","node_id":"-6"}],"output_ports":[{"name":"data","node_id":"-6"}],"cacheable":true,"seq_num":1,"comment":"","comment_collapsed":true},{"node_id":"-16","module_id":"BigQuantSpace.instruments.instruments-v2","parameters":[{"name":"start_date","value":"2020-01-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":"-16"}],"output_ports":[{"name":"data","node_id":"-16"}],"cacheable":true,"seq_num":2,"comment":"","comment_collapsed":true},{"node_id":"-24","module_id":"BigQuantSpace.input_features.input_features-v1","parameters":[{"name":"features","value":"_rij = ret_sim(close, open)\nRVar = (_rij**2).sum()","type":"Literal","bound_global_parameter":null}],"input_ports":[{"name":"features_ds","node_id":"-24"}],"output_ports":[{"name":"data","node_id":"-24"}],"cacheable":true,"seq_num":3,"comment":"","comment_collapsed":true},{"node_id":"-28","module_id":"BigQuantSpace.feature_extractor_user_function.feature_extractor_user_function-v1","parameters":[{"name":"name","value":"ret_sim","type":"Literal","bound_global_parameter":null},{"name":"func","value":"def bigquant_run(df, x, y):\n ret = x.pct_change()\n ret.iloc[0] = x.iloc[0] / y.iloc[0] - 1\n\n return ret\n","type":"Literal","bound_global_parameter":null}],"input_ports":[{"name":"input_functions","node_id":"-28"}],"output_ports":[{"name":"functions","node_id":"-28"}],"cacheable":false,"seq_num":4,"comment":"","comment_collapsed":true}],"node_layout":"<node_postions><node_position Node='-6' Position='301.134033203125,492.5030517578125,200,200'/><node_position Node='-16' Position='139.5670166015625,321.32373046875,200,200'/><node_position Node='-24' Position='404.41650390625,236.02886962890625,200,200'/><node_position Node='-28' Position='650,349,200,200'/></node_postions>"},"nodes_readonly":false,"studio_version":"v2"}
    In [2]:
    # 本代码由可视化策略环境自动生成 2022年5月22日 10:35
    # 本代码单元只能在可视化模式下编辑。您也可以拷贝代码,粘贴到新建的代码单元或者策略,然后修改。
    
    
    def m4_func_bigquant_run(df, x, y):
        ret = x.pct_change()
        ret.iloc[0] = x.iloc[0] / y.iloc[0] - 1
    
        return ret
    
    
    m2 = M.instruments.v2(
        start_date='2020-01-01',
        end_date='2020-12-31',
        market='CN_STOCK_A',
        instrument_list='',
        max_count=0
    )
    
    m3 = M.input_features.v1(
        features="""_rij = ret_sim(close, open)
    RVar = (_rij**2).sum()"""
    )
    
    m4 = M.feature_extractor_user_function.v1(
        name='ret_sim',
        func=m4_func_bigquant_run
    )
    
    m1 = M.feature_extractor_1m.v2(
        instruments=m2.data,
        features=m3.data,
        user_functions=m4.functions,
        start_date='',
        end_date='',
        before_start_days=0,
        workers=2,
        parallel_mode='测试',
        table_1m='level2_bar1m_CN_STOCK_A'
    )