克隆策略
In [3]:
df = m4.data.read()
print(df.shape)
df
(18, 7)
Out[3]:
close_0 date instrument open_0 close_0/mean(close_0,5) close_0/open_0 open_0/mean(close_0,5)
4 2719.703857 2021-06-07 000001.SZA 2739.849609 1.008969 0.992647 1.016442
5 2745.445801 2021-06-08 000001.SZA 2702.915527 1.013385 1.015735 0.997687
6 2758.876465 2021-06-09 000001.SZA 2734.253662 1.011988 1.009005 1.002956
7 2708.511475 2021-06-10 000001.SZA 2759.995605 0.990018 0.981346 1.008837
8 2615.616455 2021-06-11 000001.SZA 2720.822998 0.965304 0.961333 1.004131
9 2598.828125 2021-06-15 000001.SZA 2613.377930 0.967742 0.994433 0.973160
10 2603.304932 2021-06-16 000001.SZA 2598.828125 0.979781 1.001723 0.978096
11 2585.397461 2021-06-17 000001.SZA 2576.443604 0.985916 1.003475 0.982501
12 2535.032471 2021-06-18 000001.SZA 2588.755127 0.979671 0.979248 1.000433
13 2480.190674 2021-06-21 000001.SZA 2529.436523 0.968616 0.980531 0.987849
14 2570.847656 2021-06-22 000001.SZA 2504.813721 1.006220 1.026363 0.980375
15 2589.874268 2021-06-23 000001.SZA 2557.416992 1.014734 1.012691 1.002017
16 2583.158936 2021-06-24 000001.SZA 2577.562988 1.012281 1.002171 1.010088
17 2614.497070 2021-06-25 000001.SZA 2583.158936 1.018220 1.012132 1.006015
18 2549.582275 2021-06-28 000001.SZA 2614.497070 0.987601 0.975171 1.012746
19 2500.336670 2021-06-29 000001.SZA 2527.197998 0.973845 0.989371 0.984307
20 2531.674805 2021-06-30 000001.SZA 2502.575195 0.990541 1.011628 0.979156
21 2596.589600 2021-07-01 000001.SZA 2552.939941 1.014873 1.017098 0.997813
In [36]:
df = m5.data.read()
x = df["x"]
print(x.shape)

df1 = pd.DataFrame(x)
df1.to_csv("滚动序列窗口_2.csv")

df = m7.data.read()
x = df["x"]

df1 = pd.DataFrame(x)
df1.to_csv("滚动序列窗口_3.csv")

df = m6.data.read()
x = df["x"]
print(x)
(18, 6)
[[[0.         0.         0.        ]
  [0.         0.         0.        ]
  [1.0089687  0.9926471  1.0164424 ]]

 [[0.         0.         0.        ]
  [1.0089687  0.9926471  1.0164424 ]
  [1.0133852  1.0157349  0.99768656]]

 [[1.0089687  0.9926471  1.0164424 ]
  [1.0133852  1.0157349  0.99768656]
  [1.0119878  1.0090053  1.0029559 ]]

 [[1.0133852  1.0157349  0.99768656]
  [1.0119878  1.0090053  1.0029559 ]
  [0.99001795 0.9813463  1.0088365 ]]

 [[1.0119878  1.0090053  1.0029559 ]
  [0.99001795 0.9813463  1.0088365 ]
  [0.9653036  0.9613328  1.0041305 ]]

 [[0.99001795 0.9813463  1.0088365 ]
  [0.9653036  0.9613328  1.0041305 ]
  [0.96774197 0.99443257 0.97315997]]

 [[0.9653036  0.9613328  1.0041305 ]
  [0.96774197 0.99443257 0.97315997]
  [0.979781   1.0017226  0.97809607]]

 [[0.96774197 0.99443257 0.97315997]
  [0.979781   1.0017226  0.97809607]
  [0.9859155  1.0034753  0.98250103]]

 [[0.979781   1.0017226  0.97809607]
  [0.9859155  1.0034753  0.98250103]
  [0.97967124 0.9792477  1.0004325 ]]

 [[0.9859155  1.0034753  0.98250103]
  [0.97967124 0.9792477  1.0004325 ]
  [0.9686161  0.9805309  0.98784864]]

 [[0.97967124 0.9792477  1.0004325 ]
  [0.9686161  0.9805309  0.98784864]
  [1.0062205  1.0263628  0.98037505]]

 [[0.9686161  0.9805309  0.98784864]
  [1.0062205  1.0263628  0.98037505]
  [1.0147343  1.0126914  1.0020173 ]]

 [[1.0062205  1.0263628  0.98037505]
  [1.0147343  1.0126914  1.0020173 ]
  [1.0122807  1.002171   1.0100877 ]]

 [[1.0147343  1.0126914  1.0020173 ]
  [1.0122807  1.002171   1.0100877 ]
  [1.0182198  1.0121317  1.0060152 ]]

 [[1.0122807  1.002171   1.0100877 ]
  [1.0182198  1.0121317  1.0060152 ]
  [0.98760074 0.9751712  1.012746  ]]

 [[1.0182198  1.0121317  1.0060152 ]
  [0.98760074 0.9751712  1.012746  ]
  [0.9738448  0.9893711  0.98430693]]

 [[0.98760074 0.9751712  1.012746  ]
  [0.9738448  0.9893711  0.98430693]
  [0.9905413  1.0116279  0.9791558 ]]

 [[0.9738448  0.9893711  0.98430693]
  [0.9905413  1.0116279  0.9791558 ]
  [1.0148731  1.0170978  0.99781275]]]

    {"description":"实验创建于7/6/2021","graph":{"edges":[{"to_node_id":"-873:instruments","from_node_id":"-864:data"},{"to_node_id":"-1179:input_data","from_node_id":"-873:data"},{"to_node_id":"-873:features","from_node_id":"-1174:data"},{"to_node_id":"-1179:features","from_node_id":"-1174:data"},{"to_node_id":"-1188:features","from_node_id":"-1174:data"},{"to_node_id":"-2771:features","from_node_id":"-1174:data"},{"to_node_id":"-2885:features","from_node_id":"-1174:data"},{"to_node_id":"-1188:input_data","from_node_id":"-1179:data"},{"to_node_id":"-2771:input_data","from_node_id":"-1179:data"},{"to_node_id":"-2885:input_data","from_node_id":"-1179:data"}],"nodes":[{"node_id":"-864","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-07-01","type":"Literal","bound_global_parameter":null},{"name":"market","value":"CN_STOCK_A","type":"Literal","bound_global_parameter":null},{"name":"instrument_list","value":"000001.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":"-864"}],"output_ports":[{"name":"data","node_id":"-864"}],"cacheable":true,"seq_num":1,"comment":"","comment_collapsed":true},{"node_id":"-873","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":"-873"},{"name":"features","node_id":"-873"}],"output_ports":[{"name":"data","node_id":"-873"}],"cacheable":true,"seq_num":2,"comment":"","comment_collapsed":true},{"node_id":"-1174","module_id":"BigQuantSpace.input_features.input_features-v1","parameters":[{"name":"features","value":"close_0/mean(close_0,5)\nclose_0/open_0\nopen_0/mean(close_0,5)\n","type":"Literal","bound_global_parameter":null}],"input_ports":[{"name":"features_ds","node_id":"-1174"}],"output_ports":[{"name":"data","node_id":"-1174"}],"cacheable":true,"seq_num":3,"comment":"","comment_collapsed":true},{"node_id":"-1179","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":"True","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":"-1179"},{"name":"features","node_id":"-1179"}],"output_ports":[{"name":"data","node_id":"-1179"}],"cacheable":true,"seq_num":4,"comment":"","comment_collapsed":true},{"node_id":"-1188","module_id":"BigQuantSpace.dl_convert_to_bin.dl_convert_to_bin-v2","parameters":[{"name":"window_size","value":"2","type":"Literal","bound_global_parameter":null},{"name":"feature_clip","value":5,"type":"Literal","bound_global_parameter":null},{"name":"flatten","value":"True","type":"Literal","bound_global_parameter":null},{"name":"window_along_col","value":"instrument","type":"Literal","bound_global_parameter":null}],"input_ports":[{"name":"input_data","node_id":"-1188"},{"name":"features","node_id":"-1188"}],"output_ports":[{"name":"data","node_id":"-1188"}],"cacheable":true,"seq_num":5,"comment":"","comment_collapsed":true},{"node_id":"-2771","module_id":"BigQuantSpace.dl_convert_to_bin.dl_convert_to_bin-v2","parameters":[{"name":"window_size","value":"3","type":"Literal","bound_global_parameter":null},{"name":"feature_clip","value":"5","type":"Literal","bound_global_parameter":null},{"name":"flatten","value":"True","type":"Literal","bound_global_parameter":null},{"name":"window_along_col","value":"instrument","type":"Literal","bound_global_parameter":null}],"input_ports":[{"name":"input_data","node_id":"-2771"},{"name":"features","node_id":"-2771"}],"output_ports":[{"name":"data","node_id":"-2771"}],"cacheable":true,"seq_num":7,"comment":"","comment_collapsed":true},{"node_id":"-2885","module_id":"BigQuantSpace.dl_convert_to_bin.dl_convert_to_bin-v2","parameters":[{"name":"window_size","value":"3","type":"Literal","bound_global_parameter":null},{"name":"feature_clip","value":"5","type":"Literal","bound_global_parameter":null},{"name":"flatten","value":"False","type":"Literal","bound_global_parameter":null},{"name":"window_along_col","value":"instrument","type":"Literal","bound_global_parameter":null}],"input_ports":[{"name":"input_data","node_id":"-2885"},{"name":"features","node_id":"-2885"}],"output_ports":[{"name":"data","node_id":"-2885"}],"cacheable":true,"seq_num":6,"comment":"","comment_collapsed":true}],"node_layout":"<node_postions><node_position Node='-864' Position='-194,-47,200,200'/><node_position Node='-873' Position='-215,81.87921142578125,200,200'/><node_position Node='-1174' Position='327,-52,200,200'/><node_position Node='-1179' Position='-243,214,200,200'/><node_position Node='-1188' Position='-332,453,200,200'/><node_position Node='-2771' Position='34,454,200,200'/><node_position Node='-2885' Position='353,441,200,200'/></node_postions>"},"nodes_readonly":false,"studio_version":"v2"}
    In [1]:
    # 本代码由可视化策略环境自动生成 2021年7月9日11:09
    # 本代码单元只能在可视化模式下编辑。您也可以拷贝代码,粘贴到新建的代码单元或者策略,然后修改。
    
    
    m1 = M.instruments.v2(
        start_date='2021-06-01',
        end_date='2021-07-01',
        market='CN_STOCK_A',
        instrument_list='000001.SZA',
        max_count=0
    )
    
    m3 = M.input_features.v1(
        features="""close_0/mean(close_0,5)
    close_0/open_0
    open_0/mean(close_0,5)
    """
    )
    
    m2 = M.general_feature_extractor.v7(
        instruments=m1.data,
        features=m3.data,
        start_date='',
        end_date='',
        before_start_days=0
    )
    
    m4 = M.derived_feature_extractor.v3(
        input_data=m2.data,
        features=m3.data,
        date_col='date',
        instrument_col='instrument',
        drop_na=True,
        remove_extra_columns=False,
        user_functions={}
    )
    
    m5 = M.dl_convert_to_bin.v2(
        input_data=m4.data,
        features=m3.data,
        window_size=2,
        feature_clip=5,
        flatten=True,
        window_along_col='instrument'
    )
    
    m7 = M.dl_convert_to_bin.v2(
        input_data=m4.data,
        features=m3.data,
        window_size=3,
        feature_clip=5,
        flatten=True,
        window_along_col='instrument'
    )
    
    m6 = M.dl_convert_to_bin.v2(
        input_data=m4.data,
        features=m3.data,
        window_size=3,
        feature_clip=5,
        flatten=False,
        window_along_col='instrument'
    )
    

    时序模型,CNN LSTM RNN 之前时间的因子对后面预测有更多信息