克隆策略
In [68]:
df=m4.data.read_df()
f2=m1.data.read_pickle()

for fac in f2:
    median=df[fac].mean()
    std=df[fac].std()
    df[fac]=df.groupby('date')[fac].apply(lambda x:(x-median)/std)
    
df  
  
Out[68]:
close_0 close_1 date high_0 high_1 instrument low_0 low_1 open_0 open_1 volume_0 volume_1 (close_0/close_1-1)*10 (high_0/high_1-1)*10 (low_0/low_1-1)*10 (open_0/open_1-1)*10 (volume_0/volume_1-1)*10
0 64.433884 64.040993 2019-01-02 65.023216 65.612556 300170.SZA 63.910030 63.648106 64.302925 64.892258 5924093 10926565 0.200946 -0.312196 0.157671 -0.299358 -0.456588
1 63.255215 64.433884 2019-01-03 65.743515 65.023216 300170.SZA 62.665882 63.910030 64.826775 64.302925 13016873 5924093 -0.603252 0.386184 -0.730709 0.266709 0.764148
2 65.939964 63.255215 2019-01-04 66.332848 65.743515 300170.SZA 62.403954 62.665882 62.796844 64.826775 14681376 13016873 1.396270 0.312604 -0.154812 -1.029809 -0.024600
3 67.707962 65.939964 2019-01-07 68.493744 66.332848 300170.SZA 65.939964 62.403954 66.136406 62.796844 17402335 14681376 0.881673 1.134677 2.137226 1.746372 0.017781
4 68.952118 67.707962 2019-01-08 69.672409 68.493744 300170.SZA 66.791222 65.939964 67.642479 66.136406 20340086 17402336 0.603916 0.599630 0.488964 0.747257 0.005596
... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ...
660 48.446667 51.478703 2021-09-16 51.478703 51.874184 300170.SZA 48.314838 49.699028 51.215046 50.292252 24000147 16794643 -1.940074 -0.264907 -1.046556 0.601915 0.197525
661 47.787525 48.446667 2021-09-17 48.776234 51.478703 300170.SZA 46.864735 48.314838 48.710320 51.215046 13906113 24000147 -0.448944 -1.827168 -1.128008 -1.607856 -0.429118
662 47.326130 47.787525 2021-09-22 47.655701 48.776234 300170.SZA 46.798820 46.864735 47.326130 48.710320 7917200 13906113 -0.318890 -0.799288 -0.050339 -0.934644 -0.436557
663 48.512577 47.326130 2021-09-23 48.776234 47.655701 300170.SZA 47.457958 46.798820 47.589787 47.326130 10725855 7917200 0.824304 0.819130 0.533226 0.182082 0.142738
664 48.248924 48.512577 2021-09-24 49.501286 48.776234 300170.SZA 48.117096 47.457958 48.644405 47.589787 10618592 10725855 -0.179948 0.518039 0.525856 0.727163 -0.126290

665 rows × 17 columns

    {"description":"实验创建于9/26/2021","graph":{"edges":[{"to_node_id":"-288:features","from_node_id":"287d2cb0-f53c-4101-bdf8-104b137c8601-24:data"},{"to_node_id":"-295:features","from_node_id":"287d2cb0-f53c-4101-bdf8-104b137c8601-24:data"},{"to_node_id":"-748:input_2","from_node_id":"287d2cb0-f53c-4101-bdf8-104b137c8601-24:data"},{"to_node_id":"-288:instruments","from_node_id":"287d2cb0-f53c-4101-bdf8-104b137c8601-62:data"},{"to_node_id":"-295:input_data","from_node_id":"-288:data"},{"to_node_id":"-748:input_1","from_node_id":"-295:data"}],"nodes":[{"node_id":"287d2cb0-f53c-4101-bdf8-104b137c8601-24","module_id":"BigQuantSpace.input_features.input_features-v1","parameters":[{"name":"features","value":"# #号开始的表示注释\n# 多个特征,每行一个,可以包含基础特征和衍生特征\n\n(close_0/close_1-1)*10\n(high_0/high_1-1)*10\n(low_0/low_1-1)*10\n(open_0/open_1-1)*10\n(volume_0/volume_1-1)*10\n","type":"Literal","bound_global_parameter":null}],"input_ports":[{"name":"features_ds","node_id":"287d2cb0-f53c-4101-bdf8-104b137c8601-24"}],"output_ports":[{"name":"data","node_id":"287d2cb0-f53c-4101-bdf8-104b137c8601-24"}],"cacheable":true,"seq_num":1,"comment":"","comment_collapsed":true},{"node_id":"287d2cb0-f53c-4101-bdf8-104b137c8601-62","module_id":"BigQuantSpace.instruments.instruments-v2","parameters":[{"name":"start_date","value":"2020-01-01","type":"Literal","bound_global_parameter":null},{"name":"end_date","value":"2021-09-24","type":"Literal","bound_global_parameter":null},{"name":"market","value":"CN_STOCK_A","type":"Literal","bound_global_parameter":null},{"name":"instrument_list","value":"300170.SZA","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-62"}],"output_ports":[{"name":"data","node_id":"287d2cb0-f53c-4101-bdf8-104b137c8601-62"}],"cacheable":true,"seq_num":2,"comment":"预测数据,用于回测和模拟","comment_collapsed":true},{"node_id":"-288","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":"365","type":"Literal","bound_global_parameter":null}],"input_ports":[{"name":"instruments","node_id":"-288"},{"name":"features","node_id":"-288"}],"output_ports":[{"name":"data","node_id":"-288"}],"cacheable":true,"seq_num":3,"comment":"","comment_collapsed":true},{"node_id":"-295","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":"-295"},{"name":"features","node_id":"-295"}],"output_ports":[{"name":"data","node_id":"-295"}],"cacheable":true,"seq_num":4,"comment":"","comment_collapsed":true},{"node_id":"-748","module_id":"BigQuantSpace.standardlize.standardlize-v8","parameters":[{"name":"columns_input","value":"","type":"Literal","bound_global_parameter":null}],"input_ports":[{"name":"input_1","node_id":"-748"},{"name":"input_2","node_id":"-748"}],"output_ports":[{"name":"data","node_id":"-748"}],"cacheable":true,"seq_num":6,"comment":"","comment_collapsed":true}],"node_layout":"<node_postions><node_position Node='287d2cb0-f53c-4101-bdf8-104b137c8601-24' Position='1709.0341796875,399.60711669921875,200,200'/><node_position Node='287d2cb0-f53c-4101-bdf8-104b137c8601-62' Position='1320.1104736328125,394.7915344238281,200,200'/><node_position Node='-288' Position='1411.873779296875,618.4907836914062,200,200'/><node_position Node='-295' Position='1415.7574462890625,731.4141845703125,200,200'/><node_position Node='-748' Position='1568.1202392578125,884.7709350585938,200,200'/></node_postions>"},"nodes_readonly":false,"studio_version":"v2"}
    In [79]:
    # 本代码由可视化策略环境自动生成 2021年10月2日 21:35
    # 本代码单元只能在可视化模式下编辑。您也可以拷贝代码,粘贴到新建的代码单元或者策略,然后修改。
    
    
    m1 = M.input_features.v1(
        features="""# #号开始的表示注释
    # 多个特征,每行一个,可以包含基础特征和衍生特征
    
    (close_0/close_1-1)*10
    (high_0/high_1-1)*10
    (low_0/low_1-1)*10
    (open_0/open_1-1)*10
    (volume_0/volume_1-1)*10
    """
    )
    
    m2 = M.instruments.v2(
        start_date='2020-01-01',
        end_date='2021-09-24',
        market='CN_STOCK_A',
        instrument_list='300170.SZA',
        max_count=0
    )
    
    m3 = M.general_feature_extractor.v7(
        instruments=m2.data,
        features=m1.data,
        start_date='',
        end_date='',
        before_start_days=365
    )
    
    m4 = 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
    )
    
    m6 = M.standardlize.v8(
        input_1=m4.data,
        input_2=m1.data,
        columns_input=''
    )