复制链接
克隆策略

    {"description":"实验创建于2021/10/23","graph":{"edges":[{"to_node_id":"-313:features","from_node_id":"-301:data"},{"to_node_id":"-270:feature_datas","from_node_id":"-313:data"},{"to_node_id":"-209:input_1","from_node_id":"287d2cb0-f53c-4101-bdf8-104b137c8601-8:data"},{"to_node_id":"-270:instruments","from_node_id":"-209:data_1"},{"to_node_id":"-313:input_data","from_node_id":"-209:data_1"}],"nodes":[{"node_id":"-270","module_id":"BigQuantSpace.genetic_algorithm.genetic_algorithm-v1","parameters":[{"name":"all_start_date","value":"2021-01-01","type":"Literal","bound_global_parameter":null},{"name":"all_end_date","value":"2021-08-30","type":"Literal","bound_global_parameter":null},{"name":"short_date_range_ratio","value":"0.7","type":"Literal","bound_global_parameter":null},{"name":"return_field","value":"wap_3_vwap_buy","type":"Literal","bound_global_parameter":null},{"name":"rebalance_period","value":1,"type":"Literal","bound_global_parameter":null},{"name":"train_test_ratio","value":0.75,"type":"Literal","bound_global_parameter":null},{"name":"train_validate_ratio","value":0.75,"type":"Literal","bound_global_parameter":null},{"name":"mtime","value":"2","type":"Literal","bound_global_parameter":null},{"name":"init_ind_num","value":"10","type":"Literal","bound_global_parameter":null},{"name":"ngen","value":"3","type":"Literal","bound_global_parameter":null},{"name":"fitness_func","value":"long_return","type":"Literal","bound_global_parameter":null},{"name":"train_fitness","value":"0.16","type":"Literal","bound_global_parameter":null},{"name":"test_fitness","value":"0.1","type":"Literal","bound_global_parameter":null},{"name":"ir_type","value":"ir","type":"Literal","bound_global_parameter":null},{"name":"cxpb","value":0.5,"type":"Literal","bound_global_parameter":null},{"name":"mutpb","value":0.3,"type":"Literal","bound_global_parameter":null},{"name":"mutspb","value":0.3,"type":"Literal","bound_global_parameter":null},{"name":"mutnrpb","value":0.3,"type":"Literal","bound_global_parameter":null},{"name":"constant","value":"1,11","type":"Literal","bound_global_parameter":null},{"name":"pool_processes_limit","value":"5","type":"Literal","bound_global_parameter":null}],"input_ports":[{"name":"instruments","node_id":"-270"},{"name":"feature_datas","node_id":"-270"},{"name":"base_features","node_id":"-270"}],"output_ports":[{"name":"factors","node_id":"-270"}],"cacheable":false,"seq_num":1,"comment":"","comment_collapsed":true},{"node_id":"-301","module_id":"BigQuantSpace.input_features.input_features-v1","parameters":[{"name":"features","value":"#close_0\nopen_0\n#high_0\nlow_0\n#amount_0\n#turn_0\n#return_0","type":"Literal","bound_global_parameter":null}],"input_ports":[{"name":"features_ds","node_id":"-301"}],"output_ports":[{"name":"data","node_id":"-301"}],"cacheable":true,"seq_num":3,"comment":"","comment_collapsed":true},{"node_id":"-313","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":"-313"},{"name":"features","node_id":"-313"}],"output_ports":[{"name":"data","node_id":"-313"}],"cacheable":true,"seq_num":5,"comment":"","comment_collapsed":true},{"node_id":"287d2cb0-f53c-4101-bdf8-104b137c8601-8","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-08-30","type":"Literal","bound_global_parameter":null},{"name":"market","value":"CN_FUTURE","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":6,"comment":"","comment_collapsed":true},{"node_id":"-209","module_id":"BigQuantSpace.cached.cached-v3","parameters":[{"name":"run","value":"# Python 代码入口函数,input_1/2/3 对应三个输入端,data_1/2/3 对应三个输出端\ndef bigquant_run(input_1, input_2, input_3):\n # 示例代码如下。在这里编写您的代码\n instruments = input_1.read()['instruments']\n start_date = input_1.read()['start_date']\n end_date = input_1.read()['end_date']\n df = DataSource('bar1m_CN_FUTURE').read(instruments=instruments,start_date=start_date,end_date=end_date)\n df5 = BarGenerator.aggregate_df(df, \"5m\"),\n df5 = df5[0]\n\n data_1 = DataSource.write_df(df5)\n return Outputs(data_1=data_1)\n","type":"Literal","bound_global_parameter":null},{"name":"post_run","value":"# 后处理函数,可选。输入是主函数的输出,可以在这里对数据做处理,或者返回更友好的outputs数据格式。此函数输出不会被缓存。\ndef bigquant_run(outputs):\n return outputs\n","type":"Literal","bound_global_parameter":null},{"name":"input_ports","value":"","type":"Literal","bound_global_parameter":null},{"name":"params","value":"{}","type":"Literal","bound_global_parameter":null},{"name":"output_ports","value":"","type":"Literal","bound_global_parameter":null}],"input_ports":[{"name":"input_1","node_id":"-209"},{"name":"input_2","node_id":"-209"},{"name":"input_3","node_id":"-209"}],"output_ports":[{"name":"data_1","node_id":"-209"},{"name":"data_2","node_id":"-209"},{"name":"data_3","node_id":"-209"}],"cacheable":true,"seq_num":7,"comment":"","comment_collapsed":true}],"node_layout":"<node_postions><node_position Node='-270' Position='-113.7995834350586,132.55625915527344,200,200'/><node_position Node='-301' Position='122.49897766113281,-138.48668670654297,200,200'/><node_position Node='-313' Position='81.4866943359375,29.32720947265625,200,200'/><node_position Node='287d2cb0-f53c-4101-bdf8-104b137c8601-8' Position='-162.45808267593384,-221.3414764404297,200,200'/><node_position Node='-209' Position='-183.89772701263428,-78.07360458374023,200,200'/></node_postions>"},"nodes_readonly":false,"studio_version":"v2"}
    In [ ]:
    # 本代码由可视化策略环境自动生成 2022年2月7日 18:40
    # 本代码单元只能在可视化模式下编辑。您也可以拷贝代码,粘贴到新建的代码单元或者策略,然后修改。
    
    
    # Python 代码入口函数,input_1/2/3 对应三个输入端,data_1/2/3 对应三个输出端
    def m7_run_bigquant_run(input_1, input_2, input_3):
        # 示例代码如下。在这里编写您的代码
        instruments = input_1.read()['instruments']
        start_date = input_1.read()['start_date']
        end_date = input_1.read()['end_date']
        df = DataSource('bar1m_CN_FUTURE').read(instruments=instruments,start_date=start_date,end_date=end_date)
        df5 = BarGenerator.aggregate_df(df, "5m"),
        df5 = df5[0]
    
        data_1 = DataSource.write_df(df5)
        return Outputs(data_1=data_1)
    
    # 后处理函数,可选。输入是主函数的输出,可以在这里对数据做处理,或者返回更友好的outputs数据格式。此函数输出不会被缓存。
    def m7_post_run_bigquant_run(outputs):
        return outputs
    
    
    m3 = M.input_features.v1(
        features="""#close_0
    open_0
    #high_0
    low_0
    #amount_0
    #turn_0
    #return_0"""
    )
    
    m6 = M.instruments.v2(
        start_date='2021-01-01',
        end_date='2021-08-30',
        market='CN_FUTURE',
        instrument_list='',
        max_count=0
    )
    
    m7 = M.cached.v3(
        input_1=m6.data,
        run=m7_run_bigquant_run,
        post_run=m7_post_run_bigquant_run,
        input_ports='',
        params='{}',
        output_ports=''
    )
    
    m5 = M.derived_feature_extractor.v3(
        input_data=m7.data_1,
        features=m3.data,
        date_col='date',
        instrument_col='instrument',
        drop_na=False,
        remove_extra_columns=False,
        user_functions={}
    )
    
    m1 = M.genetic_algorithm.v1(
        instruments=m7.data_1,
        feature_datas=m5.data,
        all_start_date='2021-01-01',
        all_end_date='2021-08-30',
        short_date_range_ratio=0.7,
        return_field='wap_3_vwap_buy',
        rebalance_period=1,
        train_test_ratio=0.75,
        train_validate_ratio=0.75,
        mtime=2,
        init_ind_num=10,
        ngen=3,
        fitness_func='long_return',
        train_fitness=0.16,
        test_fitness=0.1,
        ir_type='ir',
        cxpb=0.5,
        mutpb=0.3,
        mutspb=0.3,
        mutnrpb=0.3,
        constant='1,11',
        pool_processes_limit=5,
        m_cached=False
    )
    
    In [ ]:
    m1.factors.read()