克隆策略

练习

  • 获取全市场历史'2016-01-01'至'2016-03-01'的股票历史数据的未来五日收益率标注,自动删除无标注数据并保留标注为浮点数
  • 将获取的label列按日期进行横截面标准化处理并查看模块运行结果

    {"description":"实验创建于2017/8/26","graph":{"edges":[{"to_node_id":"287d2cb0-f53c-4101-bdf8-104b137c8601-15:instruments","from_node_id":"287d2cb0-f53c-4101-bdf8-104b137c8601-8:data"},{"to_node_id":"-2538:input_1","from_node_id":"287d2cb0-f53c-4101-bdf8-104b137c8601-15:data"}],"nodes":[{"node_id":"287d2cb0-f53c-4101-bdf8-104b137c8601-8","module_id":"BigQuantSpace.instruments.instruments-v2","parameters":[{"name":"start_date","value":"2016-01-01","type":"Literal","bound_global_parameter":null},{"name":"end_date","value":"2016-03-01","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-15","module_id":"BigQuantSpace.advanced_auto_labeler.advanced_auto_labeler-v2","parameters":[{"name":"label_expr","value":"# 计算收益:5日收盘价(作为卖出价格)除以明日开盘价(作为买入价格)\nshift(close, -5) / shift(open, -1)\n","type":"Literal","bound_global_parameter":null},{"name":"start_date","value":"","type":"Literal","bound_global_parameter":null},{"name":"end_date","value":"","type":"Literal","bound_global_parameter":null},{"name":"benchmark","value":"000300.SHA","type":"Literal","bound_global_parameter":null},{"name":"drop_na_label","value":"True","type":"Literal","bound_global_parameter":null},{"name":"cast_label_int","value":"False","type":"Literal","bound_global_parameter":null},{"name":"user_functions","value":"","type":"Literal","bound_global_parameter":null}],"input_ports":[{"name":"instruments","node_id":"287d2cb0-f53c-4101-bdf8-104b137c8601-15"}],"output_ports":[{"name":"data","node_id":"287d2cb0-f53c-4101-bdf8-104b137c8601-15"}],"cacheable":true,"seq_num":2,"comment":"","comment_collapsed":true},{"node_id":"-2538","module_id":"BigQuantSpace.standardlize.standardlize-v8","parameters":[{"name":"columns_input","value":"label","type":"Literal","bound_global_parameter":null}],"input_ports":[{"name":"input_1","node_id":"-2538"},{"name":"input_2","node_id":"-2538"}],"output_ports":[{"name":"data","node_id":"-2538"}],"cacheable":true,"seq_num":3,"comment":"","comment_collapsed":true}],"node_layout":"<node_postions><node_position Node='287d2cb0-f53c-4101-bdf8-104b137c8601-8' Position='292.0617980957031,99.79351806640625,200,200'/><node_position Node='287d2cb0-f53c-4101-bdf8-104b137c8601-15' Position='266.2705383300781,218.1582489013672,200,200'/><node_position Node='-2538' Position='223.79354858398438,329.36700439453125,200,200'/></node_postions>"},"nodes_readonly":false,"studio_version":"v2"}
    In [3]:
    # 本代码由可视化策略环境自动生成 2021年10月14日21:27
    # 本代码单元只能在可视化模式下编辑。您也可以拷贝代码,粘贴到新建的代码单元或者策略,然后修改。
    
    
    m1 = M.instruments.v2(
        start_date='2016-01-01',
        end_date='2016-03-01',
        market='CN_STOCK_A',
        instrument_list='',
        max_count=0
    )
    
    m2 = M.advanced_auto_labeler.v2(
        instruments=m1.data,
        label_expr="""# 计算收益:5日收盘价(作为卖出价格)除以明日开盘价(作为买入价格)
    shift(close, -5) / shift(open, -1)
    """,
        start_date='',
        end_date='',
        benchmark='000300.SHA',
        drop_na_label=True,
        cast_label_int=False
    )
    
    m3 = M.standardlize.v8(
        input_1=m2.data,
        columns_input='label'
    )
    
    In [4]:
    m3.data.read()
    
    Out[4]:
    m:amount instrument m:close date m:open label
    0 660376153.1 000001.SZA 974.312988 2016-01-04 1031.928955 0.492865
    1 97674865.8 000004.SZA 167.878143 2016-01-04 186.531265 -0.613812
    2 302240974.4 000005.SZA 83.779106 2016-01-04 92.676003 0.071692
    3 254639754.8 000006.SZA 332.181213 2016-01-04 366.743439 -0.365810
    4 157014603.3 000008.SZA 233.642014 2016-01-04 261.608582 1.033053
    ... ... ... ... ... ... ...
    81027 236081584.0 603993.SHA 11.556387 2016-02-23 11.460615 0.479822
    81028 557833862.0 603996.SHA 42.240002 2016-02-23 40.799999 -1.725510
    81029 93839460.0 603997.SHA 21.200857 2016-02-23 21.190815 -0.629810
    81030 37720055.0 603998.SHA 50.650059 2016-02-23 50.454597 -0.312322
    81031 444028818.0 603999.SHA 45.169998 2016-02-23 44.759998 -1.917191

    81032 rows × 6 columns