复制链接
克隆策略
In [8]:
m2.data.read()
Out[8]:
date close_0 instrument
0 2009-12-31 875.017822 000001.SZA
1 2010-03-31 833.008362 000001.SZA
2 2010-06-30 628.705872 000001.SZA
3 2010-09-30 582.387756 000001.SZA
4 2010-12-31 566.948364 000001.SZA
... ... ... ...
165923 2022-09-30 3.840000 873223.BJA
165924 2022-12-31 3.210000 873223.BJA
165925 2022-12-31 10.593433 873305.BJA
165926 2022-12-31 36.129807 873339.BJA
165927 2022-12-31 8.473687 873527.BJA

165928 rows × 3 columns

In [10]:
m16.data.read().dropna()
Out[10]:
date close_0 instrument ta_macd(close_0, 'golden_cross') ta_macd_dif(close_0) ta_macd_dea(close_0) ta_macd_hist(close_0)
33 2018-03-31 1158.765869 000001.SZA False 151.772919 128.454056 46.637733
34 2018-06-30 966.347046 000001.SZA False 134.004623 129.564163 8.880904
35 2018-09-30 1193.746948 000001.SZA False 136.696625 130.990662 11.411942
36 2018-12-31 1013.334534 000001.SZA False 122.856087 129.363739 -13.015318
37 2019-03-31 1384.962524 000001.SZA True 140.257828 131.542557 17.430525
... ... ... ... ... ... ... ...
160565 2021-12-31 19.055874 603993.SHA False 2.172895 2.297252 -0.248714
160566 2022-03-31 17.792311 603993.SHA False 2.064687 2.250739 -0.372104
160567 2022-06-30 19.568127 603993.SHA False 2.098041 2.220200 -0.244318
160568 2022-09-30 16.335934 603993.SHA False 1.842424 2.144644 -0.604441
160569 2022-12-31 15.747563 603993.SHA False 1.574223 2.030560 -0.912674

44234 rows × 7 columns

    {"description":"实验创建于2017/8/26","graph":{"edges":[{"to_node_id":"-215:instruments","from_node_id":"287d2cb0-f53c-4101-bdf8-104b137c8601-8:data"},{"to_node_id":"-215:features","from_node_id":"287d2cb0-f53c-4101-bdf8-104b137c8601-24:data"},{"to_node_id":"-222:features","from_node_id":"287d2cb0-f53c-4101-bdf8-104b137c8601-24:data"},{"to_node_id":"-554:data1","from_node_id":"-215:data"},{"to_node_id":"-222:input_data","from_node_id":"-554:data"}],"nodes":[{"node_id":"287d2cb0-f53c-4101-bdf8-104b137c8601-8","module_id":"BigQuantSpace.instruments.instruments-v2","parameters":[{"name":"start_date","value":"2010-01-01","type":"Literal","bound_global_parameter":null},{"name":"end_date","value":"2022-12-31","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":"287d2cb0-f53c-4101-bdf8-104b137c8601-8"}],"output_ports":[{"name":"data","node_id":"287d2cb0-f53c-4101-bdf8-104b137c8601-8"}],"cacheable":true,"seq_num":1,"comment":"","comment_collapsed":true},{"node_id":"287d2cb0-f53c-4101-bdf8-104b137c8601-24","module_id":"BigQuantSpace.input_features.input_features-v1","parameters":[{"name":"features","value":"ta_macd(close_0, 'golden_cross')\nta_macd_dif(close_0)\nta_macd_dea(close_0)\nta_macd_hist(close_0)","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":3,"comment":"","comment_collapsed":true},{"node_id":"-215","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":"-215"},{"name":"features","node_id":"-215"}],"output_ports":[{"name":"data","node_id":"-215"}],"cacheable":true,"seq_num":15,"comment":"","comment_collapsed":true},{"node_id":"-222","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":"-222"},{"name":"features","node_id":"-222"}],"output_ports":[{"name":"data","node_id":"-222"}],"cacheable":true,"seq_num":16,"comment":"","comment_collapsed":true},{"node_id":"-554","module_id":"BigQuantSpace.resample.resample-v1","parameters":[{"name":"group","value":"instrument","type":"Literal","bound_global_parameter":null},{"name":"sessions","value":"Q","type":"Literal","bound_global_parameter":null}],"input_ports":[{"name":"data1","node_id":"-554"}],"output_ports":[{"name":"data","node_id":"-554"}],"cacheable":true,"seq_num":2,"comment":"","comment_collapsed":true}],"node_layout":"<node_postions><node_position Node='287d2cb0-f53c-4101-bdf8-104b137c8601-8' Position='198.51284790039062,24.97765350341797,200,200'/><node_position Node='287d2cb0-f53c-4101-bdf8-104b137c8601-24' Position='551.1575927734375,22.560893058776855,200,200'/><node_position Node='-215' Position='391.92620849609375,247.31396484375,200,200'/><node_position Node='-222' Position='391.24346923828125,450.13751220703125,200,200'/><node_position Node='-554' Position='390.82127380371094,347.7580871582031,200,200'/></node_postions>"},"nodes_readonly":false,"studio_version":"v2"}
    In [7]:
    # 本代码由可视化策略环境自动生成 2023年4月7日 15:00
    # 本代码单元只能在可视化模式下编辑。您也可以拷贝代码,粘贴到新建的代码单元或者策略,然后修改。
    
    
    m1 = M.instruments.v2(
        start_date='2010-01-01',
        end_date='2022-12-31',
        market='CN_STOCK_A',
        instrument_list='',
        max_count=0
    )
    
    m3 = M.input_features.v1(
        features="""ta_macd(close_0, 'golden_cross')
    ta_macd_dif(close_0)
    ta_macd_dea(close_0)
    ta_macd_hist(close_0)"""
    )
    
    m15 = M.general_feature_extractor.v7(
        instruments=m1.data,
        features=m3.data,
        start_date='',
        end_date='',
        before_start_days=90
    )
    
    m2 = M.resample.v1(
        data1=m15.data,
        group='instrument',
        sessions='Q'
    )
    
    m16 = M.derived_feature_extractor.v3(
        input_data=m2.data,
        features=m3.data,
        date_col='date',
        instrument_col='instrument',
        drop_na=False,
        remove_extra_columns=False
    )