复制链接
克隆策略
In [20]:
m2.data.read()
Out[20]:
instrument date m:end_date m:nav m:accum_nav m:adjust_nav m:publish_date m:nav_chg m:nav_chg_pct m:adj_nav_chg_pct label
0 159931.ZOF 2021-01-04 2021-01-04 1.8214 1.8214 1.8214 2021-01-04 -0.0228 -1.2363 -1.2363 12
1 512560.HOF 2021-01-04 2021-01-04 1.5434 1.5434 1.5434 2021-01-04 0.0937 6.4634 6.4634 8
2 159932.ZOF 2021-01-04 2021-01-04 1.8140 1.5370 1.5367 2021-01-04 0.0390 2.1972 2.2013 9
3 512570.HOF 2021-01-04 2021-01-04 1.2047 1.2047 1.2047 2021-01-04 0.0077 0.6433 0.6433 7
4 163114.ZOF 2021-01-04 2021-01-04 1.2693 2.2475 1.8519 2021-01-04 0.0731 6.1110 6.1078 7
... ... ... ... ... ... ... ... ... ... ... ...
23081 161129.ZOF 2021-02-23 2021-02-23 0.6999 0.6999 0.6999 2021-02-24 0.0056 0.8066 0.8066 7
23082 161815.ZOF 2021-02-23 2021-02-23 0.5030 0.5030 0.5030 2021-02-24 0.0030 0.6000 0.6000 7
23083 160216.ZOF 2021-02-23 2021-02-23 0.2650 0.2650 0.2650 2021-02-24 0.0030 1.1450 1.1450 5
23084 163208.ZOF 2021-02-23 2021-02-23 0.6080 0.6080 0.6080 2021-02-24 0.0090 1.5025 1.5025 8
23085 160416.ZOF 2021-02-23 2021-02-23 0.9270 0.9670 0.9634 2021-02-24 0.0110 1.2009 1.1974 9

23086 rows × 11 columns

    {"description":"实验创建于2017/8/26","graph":{"edges":[{"to_node_id":"-916:input_data","from_node_id":"-1218:data"},{"to_node_id":"-1218:instruments","from_node_id":"287d2cb0-f53c-4101-bdf8-104b137c8601-8:data"}],"nodes":[{"node_id":"-916","module_id":"BigQuantSpace.auto_labeler_on_datasource.auto_labeler_on_datasource-v1","parameters":[{"name":"label_expr","value":"# #号开始的表示注释\n# 0. 每行一个,顺序执行,从第二个开始,可以使用label字段\n# 1. 可用数据字段见 https://bigquant.com/docs/develop/datasource/deprecated/history_data.html\n# 2. 可用操作符和函数见 `表达式引擎 <https://bigquant.com/docs/develop/bigexpr/usage.html>`_\n\n# 计算收益:5日收盘价(作为卖出价格)除以明日开盘价(作为买入价格)\nshift(nav, -5) / shift(nav, -1)\n\n# 极值处理:用1%和99%分位的值做clip\nclip(label, all_quantile(label, 0.01), all_quantile(label, 0.99))\n\n# 将分数映射到分类,这里使用20个分类\nall_wbins(label, 20)\n\n\n","type":"Literal","bound_global_parameter":null},{"name":"drop_na_label","value":"True","type":"Literal","bound_global_parameter":null},{"name":"cast_label_int","value":"True","type":"Literal","bound_global_parameter":null},{"name":"date_col","value":"date","type":"Literal","bound_global_parameter":null},{"name":"instrument_col","value":"instrument","type":"Literal","bound_global_parameter":null},{"name":"user_functions","value":"{}","type":"Literal","bound_global_parameter":null}],"input_ports":[{"name":"input_data","node_id":"-916"}],"output_ports":[{"name":"data","node_id":"-916"}],"cacheable":true,"seq_num":2,"comment":"","comment_collapsed":true},{"node_id":"-1218","module_id":"BigQuantSpace.use_datasource.use_datasource-v2","parameters":[{"name":"datasource_id","value":"history_nav_CN_MUTFUND","type":"Literal","bound_global_parameter":null},{"name":"start_date","value":"2021-01-01","type":"Literal","bound_global_parameter":null},{"name":"end_date","value":"2021-03-01","type":"Literal","bound_global_parameter":null},{"name":"before_start_days","value":"0","type":"Literal","bound_global_parameter":null}],"input_ports":[{"name":"instruments","node_id":"-1218"},{"name":"features","node_id":"-1218"}],"output_ports":[{"name":"data","node_id":"-1218"}],"cacheable":true,"seq_num":1,"comment":"","comment_collapsed":true},{"node_id":"287d2cb0-f53c-4101-bdf8-104b137c8601-8","module_id":"BigQuantSpace.instruments.instruments-v2","parameters":[{"name":"start_date","value":"2021-01-01","type":"Literal","bound_global_parameter":null},{"name":"end_date","value":"2021-03-01","type":"Literal","bound_global_parameter":null},{"name":"market","value":"CN_FUND","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":3,"comment":"","comment_collapsed":true}],"node_layout":"<node_postions><node_position Node='-916' Position='841.0524291992188,99.78688049316406,200,200'/><node_position Node='-1218' Position='860,21,200,200'/><node_position Node='287d2cb0-f53c-4101-bdf8-104b137c8601-8' Position='886.43603515625,-59.96393585205078,200,200'/></node_postions>"},"nodes_readonly":false,"studio_version":"v2"}
    In [19]:
    # 本代码由可视化策略环境自动生成 2022年9月9日 18:16
    # 本代码单元只能在可视化模式下编辑。您也可以拷贝代码,粘贴到新建的代码单元或者策略,然后修改。
    
    
    m3 = M.instruments.v2(
        start_date='2021-01-01',
        end_date='2021-03-01',
        market='CN_FUND',
        instrument_list='',
        max_count=0
    )
    
    m1 = M.use_datasource.v2(
        instruments=m3.data,
        datasource_id='history_nav_CN_MUTFUND',
        start_date='2021-01-01',
        end_date='2021-03-01',
        before_start_days=0
    )
    
    m2 = M.auto_labeler_on_datasource.v1(
        input_data=m1.data,
        label_expr="""# #号开始的表示注释
    # 0. 每行一个,顺序执行,从第二个开始,可以使用label字段
    # 1. 可用数据字段见 https://bigquant.com/docs/develop/datasource/deprecated/history_data.html
    # 2. 可用操作符和函数见 `表达式引擎 <https://bigquant.com/docs/develop/bigexpr/usage.html>`_
    
    # 计算收益:5日收盘价(作为卖出价格)除以明日开盘价(作为买入价格)
    shift(nav, -5) / shift(nav, -1)
    
    # 极值处理:用1%和99%分位的值做clip
    clip(label, all_quantile(label, 0.01), all_quantile(label, 0.99))
    
    # 将分数映射到分类,这里使用20个分类
    all_wbins(label, 20)
    
    
    """,
        drop_na_label=True,
        cast_label_int=True,
        date_col='date',
        instrument_col='instrument',
        user_functions={}
    )