克隆策略

练习

  • 获取000001.SZA 的历史 pe_ttm_0 和 5日移动均线 因子,
  • 时间段'2021-06-01' 到 '2021-10-01', 分别使用缺失数据处理模块和缺失值填充模块实现数据的缺失值删除和缺失值向下向上填充,
  • 观察并绘制数据因子曲线

    {"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":"-2119:input_2","from_node_id":"287d2cb0-f53c-4101-bdf8-104b137c8601-24:data"},{"to_node_id":"-43:features","from_node_id":"287d2cb0-f53c-4101-bdf8-104b137c8601-24:data"},{"to_node_id":"-43:input_data","from_node_id":"-215:data"},{"to_node_id":"-2144:input_data","from_node_id":"-2119:data"},{"to_node_id":"-2229:input_data","from_node_id":"-43:data"},{"to_node_id":"-2119:input_1","from_node_id":"-43:data"}],"nodes":[{"node_id":"287d2cb0-f53c-4101-bdf8-104b137c8601-8","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-10-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":"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":"# #号开始的表示注释\n# 多个特征,每行一个,可以包含基础特征和衍生特征\npe_ttm_0\nmean(close_0,5)","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":0,"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":"-2229","module_id":"BigQuantSpace.dropnan.dropnan-v1","parameters":[],"input_ports":[{"name":"input_data","node_id":"-2229"}],"output_ports":[{"name":"data","node_id":"-2229"}],"cacheable":true,"seq_num":2,"comment":"","comment_collapsed":true},{"node_id":"-2119","module_id":"BigQuantSpace.fill_nan.fill_nan-v8","parameters":[{"name":"columns_input","value":"","type":"Literal","bound_global_parameter":null},{"name":"group_key","value":"['instrument']","type":"Literal","bound_global_parameter":null},{"name":"method","value":"向下向上填充","type":"Literal","bound_global_parameter":null},{"name":"fillnum","value":"0.0","type":"Literal","bound_global_parameter":null}],"input_ports":[{"name":"input_1","node_id":"-2119"},{"name":"input_2","node_id":"-2119"}],"output_ports":[{"name":"data","node_id":"-2119"}],"cacheable":true,"seq_num":4,"comment":"","comment_collapsed":true},{"node_id":"-2144","module_id":"BigQuantSpace.plot_dataframe.plot_dataframe-v1","parameters":[{"name":"title","value":"填充数据序列","type":"Literal","bound_global_parameter":null},{"name":"chart_type","value":"line","type":"Literal","bound_global_parameter":null},{"name":"x","value":"date","type":"Literal","bound_global_parameter":null},{"name":"y","value":"pe_ttm_0,close_0","type":"Literal","bound_global_parameter":null},{"name":"options","value":"{\n 'chart': {\n 'height': 400\n }\n}","type":"Literal","bound_global_parameter":null},{"name":"candlestick","value":"False","type":"Literal","bound_global_parameter":null},{"name":"pane_1","value":"","type":"Literal","bound_global_parameter":null},{"name":"pane_2","value":"","type":"Literal","bound_global_parameter":null},{"name":"pane_3","value":"","type":"Literal","bound_global_parameter":null},{"name":"pane_4","value":"","type":"Literal","bound_global_parameter":null}],"input_ports":[{"name":"input_data","node_id":"-2144"}],"output_ports":[],"cacheable":false,"seq_num":5,"comment":"","comment_collapsed":true},{"node_id":"-43","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":"-43"},{"name":"features","node_id":"-43"}],"output_ports":[{"name":"data","node_id":"-43"}],"cacheable":true,"seq_num":6,"comment":"","comment_collapsed":true}],"node_layout":"<node_postions><node_position Node='287d2cb0-f53c-4101-bdf8-104b137c8601-8' Position='210,93,200,200'/><node_position Node='287d2cb0-f53c-4101-bdf8-104b137c8601-24' Position='544.9472045898438,90,200,200'/><node_position Node='-215' Position='375,188,200,200'/><node_position Node='-2229' Position='120.46795654296875,356.2132873535156,200,200'/><node_position Node='-2119' Position='503.5802001953125,377.479248046875,200,200'/><node_position Node='-2144' Position='542.3142700195312,489.3760681152344,200,200'/><node_position Node='-43' Position='380.9390869140625,268.9143981933594,200,200'/></node_postions>"},"nodes_readonly":false,"studio_version":"v2"}
    In [2]:
    # 本代码由可视化策略环境自动生成 2021年10月14日21:23
    # 本代码单元只能在可视化模式下编辑。您也可以拷贝代码,粘贴到新建的代码单元或者策略,然后修改。
    
    
    m1 = M.instruments.v2(
        start_date='2021-06-01',
        end_date='2021-10-01',
        market='CN_STOCK_A',
        instrument_list='000001.SZA',
        max_count=0
    )
    
    m3 = M.input_features.v1(
        features="""# #号开始的表示注释
    # 多个特征,每行一个,可以包含基础特征和衍生特征
    pe_ttm_0
    mean(close_0,5)"""
    )
    
    m15 = M.general_feature_extractor.v7(
        instruments=m1.data,
        features=m3.data,
        start_date='',
        end_date='',
        before_start_days=0
    )
    
    m6 = M.derived_feature_extractor.v3(
        input_data=m15.data,
        features=m3.data,
        date_col='date',
        instrument_col='instrument',
        drop_na=False,
        remove_extra_columns=False,
        user_functions={}
    )
    
    m2 = M.dropnan.v1(
        input_data=m6.data
    )
    
    m4 = M.fill_nan.v8(
        input_1=m6.data,
        input_2=m3.data,
        group_key=['instrument'],
        method='向下向上填充',
        fillnum=0.0
    )
    
    m5 = M.plot_dataframe.v1(
        input_data=m4.data,
        title='填充数据序列',
        chart_type='line',
        x='date',
        y='pe_ttm_0,close_0',
        options={
        'chart': {
            'height': 400
        }
    },
        candlestick=False,
        pane_1='',
        pane_2='',
        pane_3='',
        pane_4=''
    )