克隆策略

    {"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":"-2771:features","from_node_id":"-1174:data"},{"to_node_id":"-2885:features","from_node_id":"-1174: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":"-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='-168.45593357086182,-19.412408113479614,200,200'/><node_position Node='-873' Position='-171.06420707702637,91.1740951538086,200,200'/><node_position Node='-1174' Position='327,-52,200,200'/><node_position Node='-1179' Position='-107.10556268692017,209.91294860839844,200,200'/><node_position Node='-2771' Position='-39,439,200,200'/><node_position Node='-2885' Position='327,443,200,200'/></node_postions>"},"nodes_readonly":false,"studio_version":"v2"}
    In [1]:
    # 本代码由可视化策略环境自动生成 2021年12月3日 19:43
    # 本代码单元只能在可视化模式下编辑。您也可以拷贝代码,粘贴到新建的代码单元或者策略,然后修改。
    
    
    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={}
    )
    
    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'
    )
    
    In [3]:
    m7.data.read()
    
    Out[3]:
    {'x': array([[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]], dtype=float32)}
    In [5]:
    m6.data.read()
    
    Out[5]:
    {'x': array([[[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]]], dtype=float32)}