复制链接
克隆策略

    {"description":"实验创建于2021/12/10","graph":{"edges":[{"to_node_id":"-91:features","from_node_id":"-77:data"},{"to_node_id":"-106:features","from_node_id":"-77:data"},{"to_node_id":"-106:input_data","from_node_id":"-91:data"},{"to_node_id":"-91:instruments","from_node_id":"-97:data"},{"to_node_id":"-78:input_data","from_node_id":"-106:data"},{"to_node_id":"-84:input_data","from_node_id":"-93:data"},{"to_node_id":"-93:input_data","from_node_id":"-99:data"},{"to_node_id":"-84:features","from_node_id":"-105:data"},{"to_node_id":"-99:features","from_node_id":"-105:data"},{"to_node_id":"-99:instruments","from_node_id":"-109:data"}],"nodes":[{"node_id":"-77","module_id":"BigQuantSpace.input_features.input_features-v1","parameters":[{"name":"features","value":"\n# #号开始的表示注释,注释需单独一行\n# 多个特征,每行一个,可以包含基础特征和衍生特征,特征须为本平台特征\nreturn_5\nadjust_factor_0\ntimex = timex(close_0,open_0)\nMA5 = mean(close_0, 5)\nsma=sma(close_0/adjust_factor_0,20,1)\nclose_0/adjust_factor_0","type":"Literal","bound_global_parameter":null}],"input_ports":[{"name":"features_ds","node_id":"-77"}],"output_ports":[{"name":"data","node_id":"-77"}],"cacheable":true,"seq_num":1,"comment":"","comment_collapsed":true},{"node_id":"-91","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":"-91"},{"name":"features","node_id":"-91"}],"output_ports":[{"name":"data","node_id":"-91"}],"cacheable":true,"seq_num":3,"comment":"","comment_collapsed":true},{"node_id":"-97","module_id":"BigQuantSpace.instruments.instruments-v2","parameters":[{"name":"start_date","value":"2021-01-01","type":"Literal","bound_global_parameter":null},{"name":"end_date","value":"2022-05-06","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":"-97"}],"output_ports":[{"name":"data","node_id":"-97"}],"cacheable":true,"seq_num":4,"comment":"","comment_collapsed":true},{"node_id":"-106","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":"def timex(df,s,x):\n return s * x\ndef sma(df,S,N,M=1):#1)高效的方法\n #return pd.Series(S).ewm(alpha=M/N,adjust=True).mean().values\n return pd.Series(S).ewm(com=N-M,adjust=True).mean().values\nbigquant_run = {\n 'timex' : timex,\n 'sma' : sma\n}\n","type":"Literal","bound_global_parameter":null}],"input_ports":[{"name":"input_data","node_id":"-106"},{"name":"features","node_id":"-106"}],"output_ports":[{"name":"data","node_id":"-106"}],"cacheable":true,"seq_num":2,"comment":"","comment_collapsed":true},{"node_id":"-78","module_id":"BigQuantSpace.filter.filter-v3","parameters":[{"name":"expr","value":"instrument=='000001.SZA'","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":"-78"}],"output_ports":[{"name":"data","node_id":"-78"},{"name":"left_data","node_id":"-78"}],"cacheable":true,"seq_num":9,"comment":"","comment_collapsed":true},{"node_id":"-84","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":"def timex(df,s,x):\n return s * x\ndef sma(df,S,N,M=1):#1)高效的方法\n #return pd.Series(S).ewm(alpha=M/N,adjust=True).mean().values\n return pd.Series(S).ewm(com=N-M,adjust=True).mean().values\nbigquant_run = {\n 'timex' : timex,\n 'sma' : sma\n}\n","type":"Literal","bound_global_parameter":null}],"input_ports":[{"name":"input_data","node_id":"-84"},{"name":"features","node_id":"-84"}],"output_ports":[{"name":"data","node_id":"-84"}],"cacheable":true,"seq_num":5,"comment":"","comment_collapsed":true},{"node_id":"-93","module_id":"BigQuantSpace.filter.filter-v3","parameters":[{"name":"expr","value":"instrument=='000001.SZA'","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":"-93"}],"output_ports":[{"name":"data","node_id":"-93"},{"name":"left_data","node_id":"-93"}],"cacheable":true,"seq_num":6,"comment":"","comment_collapsed":true},{"node_id":"-99","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":"-99"},{"name":"features","node_id":"-99"}],"output_ports":[{"name":"data","node_id":"-99"}],"cacheable":true,"seq_num":7,"comment":"","comment_collapsed":true},{"node_id":"-105","module_id":"BigQuantSpace.input_features.input_features-v1","parameters":[{"name":"features","value":"\n# #号开始的表示注释,注释需单独一行\n# 多个特征,每行一个,可以包含基础特征和衍生特征,特征须为本平台特征\nreturn_5\nadjust_factor_0\ntimex = timex(close_0,open_0)\nMA5 = mean(close_0, 5)\nsma=sma(close_0/adjust_factor_0,20,1)\nclose_0/adjust_factor_0","type":"Literal","bound_global_parameter":null}],"input_ports":[{"name":"features_ds","node_id":"-105"}],"output_ports":[{"name":"data","node_id":"-105"}],"cacheable":true,"seq_num":8,"comment":"","comment_collapsed":true},{"node_id":"-109","module_id":"BigQuantSpace.instruments.instruments-v2","parameters":[{"name":"start_date","value":"2021-01-01","type":"Literal","bound_global_parameter":null},{"name":"end_date","value":"2022-05-06","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":"-109"}],"output_ports":[{"name":"data","node_id":"-109"}],"cacheable":true,"seq_num":10,"comment":"","comment_collapsed":true}],"node_layout":"<node_postions><node_position Node='-77' Position='503,67,200,200'/><node_position Node='-91' Position='389,173,200,200'/><node_position Node='-97' Position='202,67,200,200'/><node_position Node='-106' Position='434.83447265625,267.01971435546875,200,200'/><node_position Node='-78' Position='428.7870788574219,339.67018127441406,200,200'/><node_position Node='-84' Position='852.48486328125,727.2995986938477,200,200'/><node_position Node='-93' Position='823.6990051269531,647.2772750854492,200,200'/><node_position Node='-99' Position='805.567626953125,572.6438980102539,200,200'/><node_position Node='-105' Position='919.567626953125,466.6438980102539,200,200'/><node_position Node='-109' Position='618.567626953125,466.6438980102539,200,200'/></node_postions>"},"nodes_readonly":false,"studio_version":"v2"}
    In [26]:
    # 本代码由可视化策略环境自动生成 2022年5月7日 10:24
    # 本代码单元只能在可视化模式下编辑。您也可以拷贝代码,粘贴到新建的代码单元或者策略,然后修改。
    
    
    def timex(df,s,x):
        return s * x
    def sma(df,S,N,M=1):#1)高效的方法
        #return pd.Series(S).ewm(alpha=M/N,adjust=True).mean().values
        return pd.Series(S).ewm(com=N-M,adjust=True).mean().values
    m2_user_functions_bigquant_run = {
        'timex' : timex,
        'sma' : sma
    }
    
    def timex(df,s,x):
        return s * x
    def sma(df,S,N,M=1):#1)高效的方法
        #return pd.Series(S).ewm(alpha=M/N,adjust=True).mean().values
        return pd.Series(S).ewm(com=N-M,adjust=True).mean().values
    m5_user_functions_bigquant_run = {
        'timex' : timex,
        'sma' : sma
    }
    
    
    m1 = M.input_features.v1(
        features="""
    # #号开始的表示注释,注释需单独一行
    # 多个特征,每行一个,可以包含基础特征和衍生特征,特征须为本平台特征
    return_5
    adjust_factor_0
    timex = timex(close_0,open_0)
    MA5 = mean(close_0, 5)
    sma=sma(close_0/adjust_factor_0,20,1)
    close_0/adjust_factor_0"""
    )
    
    m4 = M.instruments.v2(
        start_date='2021-01-01',
        end_date='2022-05-06',
        market='CN_STOCK_A',
        instrument_list='',
        max_count=0
    )
    
    m3 = M.general_feature_extractor.v7(
        instruments=m4.data,
        features=m1.data,
        start_date='',
        end_date='',
        before_start_days=90
    )
    
    m2 = M.derived_feature_extractor.v3(
        input_data=m3.data,
        features=m1.data,
        date_col='date',
        instrument_col='instrument',
        drop_na=False,
        remove_extra_columns=False,
        user_functions=m2_user_functions_bigquant_run
    )
    
    m9 = M.filter.v3(
        input_data=m2.data,
        expr='instrument==\'000001.SZA\'',
        output_left_data=False
    )
    
    m8 = M.input_features.v1(
        features="""
    # #号开始的表示注释,注释需单独一行
    # 多个特征,每行一个,可以包含基础特征和衍生特征,特征须为本平台特征
    return_5
    adjust_factor_0
    timex = timex(close_0,open_0)
    MA5 = mean(close_0, 5)
    sma=sma(close_0/adjust_factor_0,20,1)
    close_0/adjust_factor_0"""
    )
    
    m10 = M.instruments.v2(
        start_date='2021-01-01',
        end_date='2022-05-06',
        market='CN_STOCK_A',
        instrument_list='',
        max_count=0
    )
    
    m7 = M.general_feature_extractor.v7(
        instruments=m10.data,
        features=m8.data,
        start_date='',
        end_date='',
        before_start_days=90
    )
    
    m6 = M.filter.v3(
        input_data=m7.data,
        expr='instrument==\'000001.SZA\'',
        output_left_data=False
    )
    
    m5 = M.derived_feature_extractor.v3(
        input_data=m6.data,
        features=m8.data,
        date_col='date',
        instrument_col='instrument',
        drop_na=False,
        remove_extra_columns=False,
        user_functions=m5_user_functions_bigquant_run
    )
    
    In [30]:
    m5.data.read()
    
    Out[30]:
    adjust_factor_0 close_0 date instrument open_0 return_5 timex MA5 sma close_0/adjust_factor_0
    0 111.048714 1685.719482 2020-10-09 000001.SZA 1699.045288 0.971209 2864113.75 NaN 15.180000 15.180000
    1 111.048714 1765.674561 2020-10-12 000001.SZA 1690.161377 1.051587 2984275.00 NaN 15.549231 15.900001
    2 111.048714 1783.442383 2020-10-13 000001.SZA 1765.674561 1.057275 3148978.75 NaN 15.728291 16.059999
    3 111.048714 1780.110840 2020-10-14 000001.SZA 1781.221313 1.047028 3170771.25 NaN 15.809617 16.029999
    4 111.048714 1838.966675 2020-10-15 000001.SZA 1798.989136 1.118919 3308281.00 1770.782788 15.975470 16.559999
    ... ... ... ... ... ... ... ... ... ... ...
    377 111.921967 1751.578735 2022-04-27 000001.SZA 1676.591064 0.989880 2936681.25 1725.836719 15.637896 15.650000
    378 111.921967 1751.578735 2022-04-28 000001.SZA 1742.625000 0.987382 3052345.00 1722.255200 15.638501 15.650000
    379 111.921967 1714.644531 2022-04-29 000001.SZA 1756.055664 0.969007 3011011.25 1705.690747 15.622576 15.320000
    380 111.921967 1714.644531 2022-05-05 000001.SZA 1701.213867 0.953923 2916977.00 1716.211426 15.607447 15.320000
    381 111.921967 1674.352661 2022-05-06 000001.SZA 1681.067871 1.007407 2814700.50 1721.359839 15.575075 14.960000

    382 rows × 10 columns

    In [31]:
    m9.data.read()
    
    Out[31]:
    adjust_factor_0 close_0 date instrument open_0 return_5 timex MA5 sma close_0/adjust_factor_0
    0 111.048714 1685.719482 2020-10-09 000001.SZA 1699.045288 0.971209 2864113.75 NaN 15.180000 15.180000
    1 111.048714 1765.674561 2020-10-12 000001.SZA 1690.161377 1.051587 2984275.00 NaN 15.549231 15.900001
    2 111.048714 1783.442383 2020-10-13 000001.SZA 1765.674561 1.057275 3148978.75 NaN 15.728291 16.059999
    3 111.048714 1780.110840 2020-10-14 000001.SZA 1781.221313 1.047028 3170771.25 NaN 15.809617 16.029999
    4 111.048714 1838.966675 2020-10-15 000001.SZA 1798.989136 1.118919 3308281.00 1770.782788 15.975470 16.559999
    ... ... ... ... ... ... ... ... ... ... ...
    1305346 111.921967 1751.578735 2022-04-27 000001.SZA 1676.591064 0.989880 2936681.25 1725.836719 15.807359 15.650000
    1305347 111.921967 1751.578735 2022-04-28 000001.SZA 1742.625000 0.987382 3052345.00 1722.255200 15.799491 15.650000
    1305348 111.921967 1714.644531 2022-04-29 000001.SZA 1756.055664 0.969007 3011011.25 1705.690747 15.775517 15.320000
    1305349 111.921967 1714.644531 2022-05-05 000001.SZA 1701.213867 0.953923 2916977.00 1716.211426 15.752741 15.320000
    1305350 111.921967 1674.352661 2022-05-06 000001.SZA 1681.067871 1.007407 2814700.50 1721.359839 15.713104 14.960000

    382 rows × 10 columns