克隆策略
In [33]:
df=m4.data.read()
df=df[df["con"]==1]
df
Out[33]:
close_0 close_1 close_2 date instrument open_0 open_1 open_2 con
22 80.545746 73.230797 72.702492 2021-06-09 000004.SZA 73.149513 73.108879 66.200310 1
23 88.592194 80.545746 73.230797 2021-06-10 000004.SZA 84.081306 73.149513 73.108879 1
50 51.314991 51.090908 51.090908 2021-06-03 000008.SZA 51.090908 50.866825 50.642742 1
60 99.561119 90.502037 88.814560 2021-06-07 000009.SZA 92.189514 88.281670 88.104042 1
61 108.264946 99.561119 90.502037 2021-06-08 000009.SZA 103.913033 92.189514 88.281670 1
... ... ... ... ... ... ... ... ... ...
34495 767.539124 710.630188 688.469971 2021-06-07 688696.SHA 707.102173 689.732849 683.659058 1
34499 18.127512 17.704536 17.241278 2021-06-01 688698.SHA 17.704536 16.838444 17.120428 1
34507 195.839462 197.506958 191.720963 2021-06-01 688699.SHA 195.819382 190.857086 187.592422 1
34531 43.684040 43.298443 42.212685 2021-06-01 688819.SHA 43.156384 42.161949 41.908268 1
34548 80.169998 77.500000 73.300003 2021-06-02 689009.SHA 78.199997 72.860001 70.699997 1

3310 rows × 9 columns

In [34]:
df=m4.data.read()
df=df[df["instrument"]=="000004.SZA"]
df
Out[34]:
close_0 close_1 close_2 date instrument open_0 open_1 open_2 con
16 64.940514 65.184349 64.127739 2021-06-01 000004.SZA 65.306259 64.981155 64.290298 0
17 67.338196 64.940514 65.184349 2021-06-02 000004.SZA 65.875206 65.306259 64.981155 0
18 68.679268 67.338196 64.940514 2021-06-03 000004.SZA 67.907135 65.875206 65.306259 0
19 66.078400 68.679268 67.338196 2021-06-04 000004.SZA 67.541389 67.907135 65.875206 0
20 72.702492 66.078400 68.679268 2021-06-07 000004.SZA 66.200310 67.541389 67.907135 0
21 73.230797 72.702492 66.078400 2021-06-08 000004.SZA 73.108879 66.200310 67.541389 0
22 80.545746 73.230797 72.702492 2021-06-09 000004.SZA 73.149513 73.108879 66.200310 1
23 88.592194 80.545746 73.230797 2021-06-10 000004.SZA 84.081306 73.149513 73.108879 1

    {"description":"实验创建于7/12/2021","graph":{"edges":[{"to_node_id":"-1219:instruments","from_node_id":"-1206:data"},{"to_node_id":"-1219:features","from_node_id":"-1214:data"},{"to_node_id":"-1226:features","from_node_id":"-1214:data"},{"to_node_id":"-1226:input_data","from_node_id":"-1219:data"}],"nodes":[{"node_id":"-1206","module_id":"BigQuantSpace.instruments.instruments-v2","parameters":[{"name":"start_date","value":"2021-06-01","type":"Literal","bound_global_parameter":null},{"name":"end_date","value":"2021-06-10","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":"-1206"}],"output_ports":[{"name":"data","node_id":"-1206"}],"cacheable":true,"seq_num":1,"comment":"","comment_collapsed":true},{"node_id":"-1214","module_id":"BigQuantSpace.input_features.input_features-v1","parameters":[{"name":"features","value":"\n# #号开始的表示注释,注释需单独一行\n# 多个特征,每行一个,可以包含基础特征和衍生特征,特征须为本平台特征\ncon = where((close_0>open_0) & (close_1>open_1) & (close_2>open_2),1,0)","type":"Literal","bound_global_parameter":null}],"input_ports":[{"name":"features_ds","node_id":"-1214"}],"output_ports":[{"name":"data","node_id":"-1214"}],"cacheable":true,"seq_num":2,"comment":"","comment_collapsed":true},{"node_id":"-1219","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":"0","type":"Literal","bound_global_parameter":null}],"input_ports":[{"name":"instruments","node_id":"-1219"},{"name":"features","node_id":"-1219"}],"output_ports":[{"name":"data","node_id":"-1219"}],"cacheable":true,"seq_num":3,"comment":"","comment_collapsed":true},{"node_id":"-1226","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":"-1226"},{"name":"features","node_id":"-1226"}],"output_ports":[{"name":"data","node_id":"-1226"}],"cacheable":true,"seq_num":4,"comment":"","comment_collapsed":true}],"node_layout":"<node_postions><node_position Node='-1206' Position='205,74,200,200'/><node_position Node='-1214' Position='563.542724609375,72,200,200'/><node_position Node='-1219' Position='342,187,200,200'/><node_position Node='-1226' Position='354,323,200,200'/></node_postions>"},"nodes_readonly":false,"studio_version":"v2"}
    In [32]:
    # 本代码由可视化策略环境自动生成 2021年7月12日10:11
    # 本代码单元只能在可视化模式下编辑。您也可以拷贝代码,粘贴到新建的代码单元或者策略,然后修改。
    
    
    m1 = M.instruments.v2(
        start_date='2021-06-01',
        end_date='2021-06-10',
        market='CN_STOCK_A',
        instrument_list='',
        max_count=0
    )
    
    m2 = M.input_features.v1(
        features="""
    # #号开始的表示注释,注释需单独一行
    # 多个特征,每行一个,可以包含基础特征和衍生特征,特征须为本平台特征
    con = where((close_0>open_0) & (close_1>open_1) & (close_2>open_2),1,0)"""
    )
    
    m3 = M.general_feature_extractor.v7(
        instruments=m1.data,
        features=m2.data,
        start_date='',
        end_date='',
        before_start_days=0
    )
    
    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={}
    )