复制链接
克隆策略

    {"description":"实验创建于2022/3/30","graph":{"edges":[{"to_node_id":"-212:instruments","from_node_id":"-182:data"},{"to_node_id":"-195:instruments","from_node_id":"-182:data"},{"to_node_id":"-195:features","from_node_id":"-190:data"},{"to_node_id":"-202:features","from_node_id":"-190:data"},{"to_node_id":"-202:input_data","from_node_id":"-195:data"},{"to_node_id":"-212:feature_datas","from_node_id":"-202:data"}],"nodes":[{"node_id":"-182","module_id":"BigQuantSpace.instruments.instruments-v2","parameters":[{"name":"start_date","value":"2020-01-01","type":"Literal","bound_global_parameter":null},{"name":"end_date","value":"2022-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":"-182"}],"output_ports":[{"name":"data","node_id":"-182"}],"cacheable":true,"seq_num":1,"comment":"","comment_collapsed":true},{"node_id":"-190","module_id":"BigQuantSpace.input_features.input_features-v1","parameters":[{"name":"features","value":"\n# #号开始的表示注释,注释需单独一行\n# 多个特征,每行一个,可以包含基础特征和衍生特征,特征须为本平台特征\nreturn_5\nreturn_10\nreturn_20\navg_amount_0/avg_amount_5\navg_amount_5/avg_amount_20\nrank_avg_amount_0/rank_avg_amount_5\nrank_avg_amount_5/rank_avg_amount_10\nrank_return_0\nrank_return_5\nrank_return_10\nrank_return_0/rank_return_5\nrank_return_5/rank_return_10\npe_ttm_0\n","type":"Literal","bound_global_parameter":null}],"input_ports":[{"name":"features_ds","node_id":"-190"}],"output_ports":[{"name":"data","node_id":"-190"}],"cacheable":true,"seq_num":2,"comment":"","comment_collapsed":true},{"node_id":"-195","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":"-195"},{"name":"features","node_id":"-195"}],"output_ports":[{"name":"data","node_id":"-195"}],"cacheable":true,"seq_num":3,"comment":"","comment_collapsed":true},{"node_id":"-202","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":"-202"},{"name":"features","node_id":"-202"}],"output_ports":[{"name":"data","node_id":"-202"}],"cacheable":true,"seq_num":4,"comment":"","comment_collapsed":true},{"node_id":"-212","module_id":"BigQuantSpace.genetic_algorithm.genetic_algorithm-v1","parameters":[{"name":"market","value":"CN_STOCK_A","type":"Literal","bound_global_parameter":null},{"name":"freq","value":"daily","type":"Literal","bound_global_parameter":null},{"name":"all_start_date","value":"","type":"Literal","bound_global_parameter":null},{"name":"all_end_date","value":"","type":"Literal","bound_global_parameter":null},{"name":"short_date_range_ratio","value":0.7,"type":"Literal","bound_global_parameter":null},{"name":"return_field","value":"open","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":1,"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":"icir","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":"1","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":1,"type":"Literal","bound_global_parameter":null},{"name":"plot","value":"True","type":"Literal","bound_global_parameter":null},{"name":"logs","value":"True","type":"Literal","bound_global_parameter":null}],"input_ports":[{"name":"instruments","node_id":"-212"},{"name":"feature_datas","node_id":"-212"},{"name":"base_features","node_id":"-212"}],"output_ports":[{"name":"factors","node_id":"-212"}],"cacheable":true,"seq_num":5,"comment":"","comment_collapsed":true}],"node_layout":"<node_postions><node_position Node='-182' Position='114,147,200,200'/><node_position Node='-190' Position='413,148,200,200'/><node_position Node='-195' Position='413,275,200,200'/><node_position Node='-202' Position='449,408,200,200'/><node_position Node='-212' Position='326,535,200,200'/></node_postions>"},"nodes_readonly":false,"studio_version":"v2"}
    In [2]:
    # 本代码由可视化策略环境自动生成 2023年2月27日 11:39
    # 本代码单元只能在可视化模式下编辑。您也可以拷贝代码,粘贴到新建的代码单元或者策略,然后修改。
    
    
    m1 = M.instruments.v2(
        start_date='2020-01-01',
        end_date='2022-12-31',
        market='CN_STOCK_A',
        instrument_list='',
        max_count=0
    )
    
    m2 = M.input_features.v1(
        features="""
    # #号开始的表示注释,注释需单独一行
    # 多个特征,每行一个,可以包含基础特征和衍生特征,特征须为本平台特征
    return_5
    return_10
    return_20
    avg_amount_0/avg_amount_5
    avg_amount_5/avg_amount_20
    rank_avg_amount_0/rank_avg_amount_5
    rank_avg_amount_5/rank_avg_amount_10
    rank_return_0
    rank_return_5
    rank_return_10
    rank_return_0/rank_return_5
    rank_return_5/rank_return_10
    pe_ttm_0
    """
    )
    
    m3 = M.general_feature_extractor.v7(
        instruments=m1.data,
        features=m2.data,
        start_date='',
        end_date='',
        before_start_days=90
    )
    
    m4 = M.derived_feature_extractor.v3(
        input_data=m3.data,
        features=m2.data,
        date_col='date',
        instrument_col='instrument',
        drop_na=False,
        remove_extra_columns=False,
        user_functions={}
    )
    
    m5 = M.genetic_algorithm.v1(
        instruments=m1.data,
        feature_datas=m4.data,
        market='CN_STOCK_A',
        freq='daily',
        all_start_date='',
        all_end_date='',
        short_date_range_ratio=0.7,
        return_field='open',
        rebalance_period=1,
        train_test_ratio=0.75,
        train_validate_ratio=0.75,
        mtime=1,
        init_ind_num=10,
        ngen=3,
        fitness_func='icir',
        train_fitness=0.16,
        test_fitness=0.1,
        ir_type='ir',
        cxpb=1,
        mutpb=0.3,
        mutspb=0.3,
        mutnrpb=0.3,
        constant='1,11',
        pool_processes_limit=1,
        plot=True,
        logs=True
    )
    
    Traceback (most recent call last):
    
      File "/usr/local/python3/lib/python3.8/site-packages/IPython/core/interactiveshell.py", line 3427, in run_code
        exec(code_obj, self.user_global_ns, self.user_ns)
    
      File "<ipython-input-2-23f7cc2494c5>", line 51, in <module>
        m5 = M.genetic_algorithm.v1(
    
      File "module2/common/modulemanagerv2.py", line 88, in biglearning.module2.common.modulemanagerv2.BigQuantModuleVersion.__call__
    
      File "module2/common/moduleinvoker.py", line 331, in biglearning.module2.common.moduleinvoker.module_invoke
    
      File "module2/common/moduleinvoker.py", line 253, in biglearning.module2.common.moduleinvoker._invoke_with_cache
    
      File "module2/common/moduleinvoker.py", line 214, in biglearning.module2.common.moduleinvoker._invoke_with_cache
    
      File "module2/common/moduleinvoker.py", line 171, in biglearning.module2.common.moduleinvoker._module_run
    
      File "module2/modules/genetic_algorithm/v1/__init__.py", line 152, in biglearning.module2.modules.genetic_algorithm.v1.__init__.bigquant_run
    
      File "/usr/local/python3/lib/python3.8/site-packages/deap/gp.py", line 478, in compile
        return eval(code, pset.context, {})
    
      File "<string>", line 1
        lambda avg_amount_0,avg_amount_20,avg_amount_5,pe_ttm_0,rank_avg_amount_0,rank_avg_amount_10,rank_avg_amount_5,rank_return_0,rank_return_10,rank_return_5,return_10,return_20,return_5,avg_amount_0/avg_amount_5,avg_amount_5/avg_amount_20,rank_avg_amount_0/rank_avg_amount_5,rank_avg_amount_5/rank_avg_amount_10,rank_return_0/rank_return_5,rank_return_5/rank_return_10,open: max(normalize(return_20), product(rank_avg_amount_0/rank_avg_amount_5, 1))
                                                                                                                                                                                                           ^
    SyntaxError: invalid syntax