复制链接
克隆策略

    {"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 [18]:
    # 本代码由可视化策略环境自动生成 2022年5月7日 10:14
    # 本代码单元只能在可视化模式下编辑。您也可以拷贝代码,粘贴到新建的代码单元或者策略,然后修改。
    
    
    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 [9]:
    a=m6.data.read()
    a[a.instrument=='123034.ZCB']
    
    Out[9]:
    instrument date pre_close name open high low close deal_number volume amount accrued_interest yield_to_maturity vwap gross_close net_close sma20 con
    0 123034.ZCB 2019-11-28 100.000000 通光转债 103.099998 103.900002 101.000000 101.037003 69943 1961470 1.994131e+08 0.034247 NaN 101.665001 101.037003 101.002754 5.051850 False
    1 123034.ZCB 2019-11-29 101.037003 通光转债 101.044998 101.101997 100.632004 100.806000 10426 198862 2.007110e+07 0.035616 NaN 100.930000 100.806000 100.770386 9.839558 False
    2 123034.ZCB 2019-12-02 100.806000 通光转债 102.002998 102.489998 101.209999 101.281998 9862 288367 2.930455e+07 0.039726 NaN 101.622002 101.281998 101.242271 14.411680 False
    3 123034.ZCB 2019-12-03 101.281998 通光转债 101.259003 101.259003 100.800003 100.934998 3046 82506 8.323023e+06 0.041096 NaN 100.877998 100.934998 100.893906 18.737846 False
    4 123034.ZCB 2019-12-04 100.934998 通光转债 100.692001 100.989998 100.690002 100.917999 2770 66232 6.680410e+06 0.042466 NaN 100.863998 100.917999 100.875534 22.846853 False
    ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ...
    584 123034.ZCB 2022-04-27 159.800003 通光转债 159.009995 166.628006 155.233002 165.000000 28113 1905701 3.074227e+08 0.479452 NaN 161.317001 165.000000 164.520554 185.219474 True
    585 123034.ZCB 2022-04-28 165.000000 通光转债 163.138000 172.350006 161.699997 165.800003 28723 1966090 3.284323e+08 0.482192 NaN 167.048004 165.800003 165.317810 184.248500 True
    586 123034.ZCB 2022-04-29 165.800003 通光转债 166.552994 170.664001 166.552994 167.934998 16747 1243780 2.096547e+08 0.484932 NaN NaN 167.934998 167.450073 183.432825 True
    587 123034.ZCB 2022-05-05 167.934998 通光转债 168.604996 170.449997 165.000000 169.899994 8576 630750 1.064093e+08 0.501370 NaN 168.703003 169.899994 169.398636 182.756183 True
    588 123034.ZCB 2022-05-06 169.899994 通光转债 174.000000 199.990005 169.000000 178.000000 156466 12291580 2.282259e+09 0.504110 NaN NaN 178.000000 177.495895 182.518374 True

    589 rows × 18 columns