复制链接
克隆策略

    {"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":"-106:instruments","from_node_id":"287d2cb0-f53c-4101-bdf8-104b137c8601-8:data"},{"to_node_id":"-773:input_1","from_node_id":"287d2cb0-f53c-4101-bdf8-104b137c8601-15:data"},{"to_node_id":"-4597:input_1","from_node_id":"287d2cb0-f53c-4101-bdf8-104b137c8601-24:data"},{"to_node_id":"-43892:features_ds","from_node_id":"287d2cb0-f53c-4101-bdf8-104b137c8601-24:data"},{"to_node_id":"-19798:input_data","from_node_id":"287d2cb0-f53c-4101-bdf8-104b137c8601-53:data"},{"to_node_id":"-553:input_data","from_node_id":"-113:data"},{"to_node_id":"287d2cb0-f53c-4101-bdf8-104b137c8601-53:data2","from_node_id":"-773:data"},{"to_node_id":"-43989:input_data","from_node_id":"-553:data"},{"to_node_id":"-4597:input_2","from_node_id":"-4592:data"},{"to_node_id":"-106:features","from_node_id":"-43892:data"},{"to_node_id":"-113:features","from_node_id":"-43892:data"},{"to_node_id":"-44099:input_1","from_node_id":"-4597:data_1"},{"to_node_id":"-113:input_data","from_node_id":"-106:data"},{"to_node_id":"287d2cb0-f53c-4101-bdf8-104b137c8601-53:data1","from_node_id":"-43989:data"},{"to_node_id":"-19798:features","from_node_id":"-44099:data_2"}],"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":"2021-01-20","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":"# #号开始的表示注释\n# 0. 每行一个,顺序执行,从第二个开始,可以使用label字段\n# 1. 可用数据字段见 https://bigquant.com/docs/data_history_data.html\n# 添加benchmark_前缀,可使用对应的benchmark数据\n# 2. 可用操作符和函数见 `表达式引擎 <https://bigquant.com/docs/big_expr.html>`_\n\n# 计算收益:5日收盘价(作为卖出价格)除以明日开盘价(作为买入价格)\nshift(close, -2) / shift(open, -1) - 1\n\n# 极值处理:用1%和99%分位的值做clip\nclip(label, all_quantile(label, 0.01), all_quantile(label, 0.99))\n\n# 过滤掉一字涨停的情况 (设置label为NaN,在后续处理和训练中会忽略NaN的label)\nwhere(shift(high, -1) == shift(low, -1), NaN, label)\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":"287d2cb0-f53c-4101-bdf8-104b137c8601-24","module_id":"BigQuantSpace.input_features.input_features-v1","parameters":[{"name":"features","value":"","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":"287d2cb0-f53c-4101-bdf8-104b137c8601-53","module_id":"BigQuantSpace.join.join-v3","parameters":[{"name":"on","value":"date,instrument","type":"Literal","bound_global_parameter":null},{"name":"how","value":"inner","type":"Literal","bound_global_parameter":null},{"name":"sort","value":"False","type":"Literal","bound_global_parameter":null}],"input_ports":[{"name":"data1","node_id":"287d2cb0-f53c-4101-bdf8-104b137c8601-53"},{"name":"data2","node_id":"287d2cb0-f53c-4101-bdf8-104b137c8601-53"}],"output_ports":[{"name":"data","node_id":"287d2cb0-f53c-4101-bdf8-104b137c8601-53"}],"cacheable":true,"seq_num":7,"comment":"","comment_collapsed":true},{"node_id":"-113","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":"-113"},{"name":"features","node_id":"-113"}],"output_ports":[{"name":"data","node_id":"-113"}],"cacheable":true,"seq_num":16,"comment":"","comment_collapsed":true},{"node_id":"-773","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":"-773"},{"name":"input_2","node_id":"-773"}],"output_ports":[{"name":"data","node_id":"-773"}],"cacheable":true,"seq_num":13,"comment":"","comment_collapsed":true},{"node_id":"-553","module_id":"BigQuantSpace.chinaa_stock_filter.chinaa_stock_filter-v1","parameters":[{"name":"index_constituent_cond","value":"%7B%22enumItems%22%3A%5B%7B%22value%22%3A%22%E5%85%A8%E9%83%A8%22%2C%22displayValue%22%3A%22%E5%85%A8%E9%83%A8%22%2C%22selected%22%3Atrue%7D%2C%7B%22value%22%3A%22%E4%B8%8A%E8%AF%8150%22%2C%22displayValue%22%3A%22%E4%B8%8A%E8%AF%8150%22%2C%22selected%22%3Afalse%7D%2C%7B%22value%22%3A%22%E6%B2%AA%E6%B7%B1300%22%2C%22displayValue%22%3A%22%E6%B2%AA%E6%B7%B1300%22%2C%22selected%22%3Afalse%7D%2C%7B%22value%22%3A%22%E4%B8%AD%E8%AF%81500%22%2C%22displayValue%22%3A%22%E4%B8%AD%E8%AF%81500%22%2C%22selected%22%3Afalse%7D%2C%7B%22value%22%3A%22%E4%B8%AD%E8%AF%81800%22%2C%22displayValue%22%3A%22%E4%B8%AD%E8%AF%81800%22%2C%22selected%22%3Afalse%7D%2C%7B%22value%22%3A%22%E4%B8%8A%E8%AF%81180%22%2C%22displayValue%22%3A%22%E4%B8%8A%E8%AF%81180%22%2C%22selected%22%3Afalse%7D%2C%7B%22value%22%3A%22%E4%B8%AD%E8%AF%81100%22%2C%22displayValue%22%3A%22%E4%B8%AD%E8%AF%81100%22%2C%22selected%22%3Afalse%7D%2C%7B%22value%22%3A%22%E6%B7%B1%E8%AF%81100%22%2C%22displayValue%22%3A%22%E6%B7%B1%E8%AF%81100%22%2C%22selected%22%3Afalse%7D%5D%7D","type":"Literal","bound_global_parameter":null},{"name":"board_cond","value":"%7B%22enumItems%22%3A%5B%7B%22value%22%3A%22%E5%85%A8%E9%83%A8%22%2C%22displayValue%22%3A%22%E5%85%A8%E9%83%A8%22%2C%22selected%22%3Afalse%7D%2C%7B%22value%22%3A%22%E4%B8%8A%E8%AF%81%E4%B8%BB%E6%9D%BF%22%2C%22displayValue%22%3A%22%E4%B8%8A%E8%AF%81%E4%B8%BB%E6%9D%BF%22%2C%22selected%22%3Atrue%7D%2C%7B%22value%22%3A%22%E6%B7%B1%E8%AF%81%E4%B8%BB%E6%9D%BF%22%2C%22displayValue%22%3A%22%E6%B7%B1%E8%AF%81%E4%B8%BB%E6%9D%BF%22%2C%22selected%22%3Atrue%7D%2C%7B%22value%22%3A%22%E5%88%9B%E4%B8%9A%E6%9D%BF%22%2C%22displayValue%22%3A%22%E5%88%9B%E4%B8%9A%E6%9D%BF%22%2C%22selected%22%3Atrue%7D%2C%7B%22value%22%3A%22%E7%A7%91%E5%88%9B%E6%9D%BF%22%2C%22displayValue%22%3A%22%E7%A7%91%E5%88%9B%E6%9D%BF%22%2C%22selected%22%3Afalse%7D%5D%7D","type":"Literal","bound_global_parameter":null},{"name":"industry_cond","value":"%7B%22enumItems%22%3A%5B%7B%22value%22%3A%22%E5%85%A8%E9%83%A8%22%2C%22displayValue%22%3A%22%E5%85%A8%E9%83%A8%22%2C%22selected%22%3Atrue%7D%2C%7B%22value%22%3A%22%E4%BA%A4%E9%80%9A%E8%BF%90%E8%BE%93%22%2C%22displayValue%22%3A%22%E4%BA%A4%E9%80%9A%E8%BF%90%E8%BE%93%22%2C%22selected%22%3Afalse%7D%2C%7B%22value%22%3A%22%E4%BC%91%E9%97%B2%E6%9C%8D%E5%8A%A1%22%2C%22displayValue%22%3A%22%E4%BC%91%E9%97%B2%E6%9C%8D%E5%8A%A1%22%2C%22selected%22%3Afalse%7D%2C%7B%22value%22%3A%22%E4%BC%A0%E5%AA%92%2F%E4%BF%A1%E6%81%AF%E6%9C%8D%E5%8A%A1%22%2C%22displayValue%22%3A%22%E4%BC%A0%E5%AA%92%2F%E4%BF%A1%E6%81%AF%E6%9C%8D%E5%8A%A1%22%2C%22selected%22%3Afalse%7D%2C%7B%22value%22%3A%22%E5%85%AC%E7%94%A8%E4%BA%8B%E4%B8%9A%22%2C%22displayValue%22%3A%22%E5%85%AC%E7%94%A8%E4%BA%8B%E4%B8%9A%22%2C%22selected%22%3Afalse%7D%2C%7B%22value%22%3A%22%E5%86%9C%E6%9E%97%E7%89%A7%E6%B8%94%22%2C%22displayValue%22%3A%22%E5%86%9C%E6%9E%97%E7%89%A7%E6%B8%94%22%2C%22selected%22%3Afalse%7D%2C%7B%22value%22%3A%22%E5%8C%96%E5%B7%A5%22%2C%22displayValue%22%3A%22%E5%8C%96%E5%B7%A5%22%2C%22selected%22%3Afalse%7D%2C%7B%22value%22%3A%22%E5%8C%BB%E8%8D%AF%E7%94%9F%E7%89%A9%22%2C%22displayValue%22%3A%22%E5%8C%BB%E8%8D%AF%E7%94%9F%E7%89%A9%22%2C%22selected%22%3Afalse%7D%2C%7B%22value%22%3A%22%E5%95%86%E4%B8%9A%E8%B4%B8%E6%98%93%22%2C%22displayValue%22%3A%22%E5%95%86%E4%B8%9A%E8%B4%B8%E6%98%93%22%2C%22selected%22%3Afalse%7D%2C%7B%22value%22%3A%22%E5%9B%BD%E9%98%B2%E5%86%9B%E5%B7%A5%22%2C%22displayValue%22%3A%22%E5%9B%BD%E9%98%B2%E5%86%9B%E5%B7%A5%22%2C%22selected%22%3Afalse%7D%2C%7B%22value%22%3A%22%E5%AE%B6%E7%94%A8%E7%94%B5%E5%99%A8%22%2C%22displayValue%22%3A%22%E5%AE%B6%E7%94%A8%E7%94%B5%E5%99%A8%22%2C%22selected%22%3Afalse%7D%2C%7B%22value%22%3A%22%E5%BB%BA%E7%AD%91%E6%9D%90%E6%96%99%2F%E5%BB%BA%E7%AD%91%E5%BB%BA%E6%9D%90%22%2C%22displayValue%22%3A%22%E5%BB%BA%E7%AD%91%E6%9D%90%E6%96%99%2F%E5%BB%BA%E7%AD%91%E5%BB%BA%E6%9D%90%22%2C%22selected%22%3Afalse%7D%2C%7B%22value%22%3A%22%E5%BB%BA%E7%AD%91%E8%A3%85%E9%A5%B0%22%2C%22displayValue%22%3A%22%E5%BB%BA%E7%AD%91%E8%A3%85%E9%A5%B0%22%2C%22selected%22%3Afalse%7D%2C%7B%22value%22%3A%22%E6%88%BF%E5%9C%B0%E4%BA%A7%22%2C%22displayValue%22%3A%22%E6%88%BF%E5%9C%B0%E4%BA%A7%22%2C%22selected%22%3Afalse%7D%2C%7B%22value%22%3A%22%E6%9C%89%E8%89%B2%E9%87%91%E5%B1%9E%22%2C%22displayValue%22%3A%22%E6%9C%89%E8%89%B2%E9%87%91%E5%B1%9E%22%2C%22selected%22%3Afalse%7D%2C%7B%22value%22%3A%22%E6%9C%BA%E6%A2%B0%E8%AE%BE%E5%A4%87%22%2C%22displayValue%22%3A%22%E6%9C%BA%E6%A2%B0%E8%AE%BE%E5%A4%87%22%2C%22selected%22%3Afalse%7D%2C%7B%22value%22%3A%22%E6%B1%BD%E8%BD%A6%2F%E4%BA%A4%E8%BF%90%E8%AE%BE%E5%A4%87%22%2C%22displayValue%22%3A%22%E6%B1%BD%E8%BD%A6%2F%E4%BA%A4%E8%BF%90%E8%AE%BE%E5%A4%87%22%2C%22selected%22%3Afalse%7D%2C%7B%22value%22%3A%22%E7%94%B5%E5%AD%90%22%2C%22displayValue%22%3A%22%E7%94%B5%E5%AD%90%22%2C%22selected%22%3Afalse%7D%2C%7B%22value%22%3A%22%E7%94%B5%E6%B0%94%E8%AE%BE%E5%A4%87%22%2C%22displayValue%22%3A%22%E7%94%B5%E6%B0%94%E8%AE%BE%E5%A4%87%22%2C%22selected%22%3Afalse%7D%2C%7B%22value%22%3A%22%E7%BA%BA%E7%BB%87%E6%9C%8D%E8%A3%85%22%2C%22displayValue%22%3A%22%E7%BA%BA%E7%BB%87%E6%9C%8D%E8%A3%85%22%2C%22selected%22%3Afalse%7D%2C%7B%22value%22%3A%22%E7%BB%BC%E5%90%88%22%2C%22displayValue%22%3A%22%E7%BB%BC%E5%90%88%22%2C%22selected%22%3Afalse%7D%2C%7B%22value%22%3A%22%E8%AE%A1%E7%AE%97%E6%9C%BA%22%2C%22displayValue%22%3A%22%E8%AE%A1%E7%AE%97%E6%9C%BA%22%2C%22selected%22%3Afalse%7D%2C%7B%22value%22%3A%22%E8%BD%BB%E5%B7%A5%E5%88%B6%E9%80%A0%22%2C%22displayValue%22%3A%22%E8%BD%BB%E5%B7%A5%E5%88%B6%E9%80%A0%22%2C%22selected%22%3Afalse%7D%2C%7B%22value%22%3A%22%E9%80%9A%E4%BF%A1%22%2C%22displayValue%22%3A%22%E9%80%9A%E4%BF%A1%22%2C%22selected%22%3Afalse%7D%2C%7B%22value%22%3A%22%E9%87%87%E6%8E%98%22%2C%22displayValue%22%3A%22%E9%87%87%E6%8E%98%22%2C%22selected%22%3Afalse%7D%2C%7B%22value%22%3A%22%E9%92%A2%E9%93%81%22%2C%22displayValue%22%3A%22%E9%92%A2%E9%93%81%22%2C%22selected%22%3Afalse%7D%2C%7B%22value%22%3A%22%E9%93%B6%E8%A1%8C%22%2C%22displayValue%22%3A%22%E9%93%B6%E8%A1%8C%22%2C%22selected%22%3Afalse%7D%2C%7B%22value%22%3A%22%E9%9D%9E%E9%93%B6%E9%87%91%E8%9E%8D%22%2C%22displayValue%22%3A%22%E9%9D%9E%E9%93%B6%E9%87%91%E8%9E%8D%22%2C%22selected%22%3Afalse%7D%2C%7B%22value%22%3A%22%E9%A3%9F%E5%93%81%E9%A5%AE%E6%96%99%22%2C%22displayValue%22%3A%22%E9%A3%9F%E5%93%81%E9%A5%AE%E6%96%99%22%2C%22selected%22%3Afalse%7D%5D%7D","type":"Literal","bound_global_parameter":null},{"name":"st_cond","value":"%7B%22enumItems%22%3A%5B%7B%22value%22%3A%22%E5%85%A8%E9%83%A8%22%2C%22displayValue%22%3A%22%E5%85%A8%E9%83%A8%22%2C%22selected%22%3Afalse%7D%2C%7B%22value%22%3A%22%E6%AD%A3%E5%B8%B8%22%2C%22displayValue%22%3A%22%E6%AD%A3%E5%B8%B8%22%2C%22selected%22%3Atrue%7D%2C%7B%22value%22%3A%22ST%22%2C%22displayValue%22%3A%22ST%22%2C%22selected%22%3Afalse%7D%2C%7B%22value%22%3A%22*ST%22%2C%22displayValue%22%3A%22*ST%22%2C%22selected%22%3Afalse%7D%2C%7B%22value%22%3A%22%E6%9A%82%E5%81%9C%E4%B8%8A%E5%B8%82%22%2C%22displayValue%22%3A%22%E6%9A%82%E5%81%9C%E4%B8%8A%E5%B8%82%22%2C%22selected%22%3Afalse%7D%5D%7D","type":"Literal","bound_global_parameter":null},{"name":"delist_cond","value":"%7B%22enumItems%22%3A%5B%7B%22value%22%3A%22%E5%85%A8%E9%83%A8%22%2C%22displayValue%22%3A%22%E5%85%A8%E9%83%A8%22%2C%22selected%22%3Afalse%7D%2C%7B%22value%22%3A%22%E9%80%80%E5%B8%82%22%2C%22displayValue%22%3A%22%E9%80%80%E5%B8%82%22%2C%22selected%22%3Afalse%7D%2C%7B%22value%22%3A%22%E9%9D%9E%E9%80%80%E5%B8%82%22%2C%22displayValue%22%3A%22%E9%9D%9E%E9%80%80%E5%B8%82%22%2C%22selected%22%3Atrue%7D%5D%7D","type":"Literal","bound_global_parameter":null},{"name":"output_left_data","value":"False","type":"Literal","bound_global_parameter":null}],"input_ports":[{"name":"input_data","node_id":"-553"}],"output_ports":[{"name":"data","node_id":"-553"},{"name":"left_data","node_id":"-553"}],"cacheable":true,"seq_num":5,"comment":"","comment_collapsed":true},{"node_id":"-4592","module_id":"BigQuantSpace.input_features.input_features-v1","parameters":[{"name":"features","value":"","type":"Literal","bound_global_parameter":null}],"input_ports":[{"name":"features_ds","node_id":"-4592"}],"output_ports":[{"name":"data","node_id":"-4592"}],"cacheable":true,"seq_num":14,"comment":"板块因子","comment_collapsed":true},{"node_id":"-43892","module_id":"BigQuantSpace.input_features.input_features-v1","parameters":[{"name":"features","value":"buy_cond_1 = 1#where(sum(price_limit_status_1==3, 5)>0, 1, 0)\nbuy_cond_2 = where(volume_0/volume_1>1, 1, 0)\nbuy_cond_3 = where(return_0>1.05, 1, 0)\nbuy_cond_4 = where(list_days_0>120, 1, 0)\n\ne1 = mf_net_amount_l_0\n\n#目标变量\ny = shift(close_0,-2)/shift(open_0,-1)\n\n#未来两日股票的收益\nreturn_2_day=(shift(close_0, -2)-shift(open_0, -1))/shift(open_0, -1)\n#未来三日股票的收益\nreturn_3_day=(shift(close_0, -3)-shift(open_0, -1))/shift(open_0, -1)\n","type":"Literal","bound_global_parameter":null}],"input_ports":[{"name":"features_ds","node_id":"-43892"}],"output_ports":[{"name":"data","node_id":"-43892"}],"cacheable":true,"seq_num":40,"comment":"测试银子","comment_collapsed":false},{"node_id":"-4597","module_id":"BigQuantSpace.features_append.features_append-v1","parameters":[],"input_ports":[{"name":"input_1","node_id":"-4597"},{"name":"input_2","node_id":"-4597"}],"output_ports":[{"name":"data_1","node_id":"-4597"}],"cacheable":true,"seq_num":41,"comment":"","comment_collapsed":true},{"node_id":"-106","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":"121","type":"Literal","bound_global_parameter":null}],"input_ports":[{"name":"instruments","node_id":"-106"},{"name":"features","node_id":"-106"}],"output_ports":[{"name":"data","node_id":"-106"}],"cacheable":true,"seq_num":15,"comment":"","comment_collapsed":true},{"node_id":"-43989","module_id":"BigQuantSpace.filter.filter-v3","parameters":[{"name":"expr","value":"buy_cond_1==1&buy_cond_2==1&buy_cond_3==1&buy_cond_4==1","type":"Literal","bound_global_parameter":null},{"name":"output_left_data","value":"False","type":"Literal","bound_global_parameter":null}],"input_ports":[{"name":"input_data","node_id":"-43989"}],"output_ports":[{"name":"data","node_id":"-43989"},{"name":"left_data","node_id":"-43989"}],"cacheable":true,"seq_num":52,"comment":"","comment_collapsed":true},{"node_id":"-44099","module_id":"BigQuantSpace.cached.cached-v3","parameters":[{"name":"run","value":"# Python 代码入口函数,input_1/2/3 对应三个输入端,data_1/2/3 对应三个输出端\ndef bigquant_run(input_1, input_2, input_3, SW_type):\n feature_list = input_1.read()\n new_feature_list = []\n feature_jc_list = []\n for feature in feature_list:\n splitStrindex = feature.find(\"=\")\n feature_key = feature[0:splitStrindex].strip()\n feature_value = feature[splitStrindex:-1].strip()\n feature_jc_list.append(feature_key)\n new_feature_list.append('n_'+feature_key+'=rank('+feature_key+')')\n print('因子个数:{}'.format(len(new_feature_list)))\n data_1 = DataSource.write_pickle(new_feature_list)\n data_2 = DataSource.write_pickle(feature_jc_list)\n return Outputs(data_1=data_1,data_2=data_2)\n","type":"Literal","bound_global_parameter":null},{"name":"post_run","value":"# 后处理函数,可选。输入是主函数的输出,可以在这里对数据做处理,或者返回更友好的outputs数据格式。此函数输出不会被缓存。\ndef bigquant_run(outputs):\n return outputs\n","type":"Literal","bound_global_parameter":null},{"name":"input_ports","value":"","type":"Literal","bound_global_parameter":null},{"name":"params","value":"{\n 'SW_type':'name_SW2'\n}","type":"Literal","bound_global_parameter":null},{"name":"output_ports","value":"data_1,data_2","type":"Literal","bound_global_parameter":null}],"input_ports":[{"name":"input_1","node_id":"-44099"},{"name":"input_2","node_id":"-44099"},{"name":"input_3","node_id":"-44099"}],"output_ports":[{"name":"data_1","node_id":"-44099"},{"name":"data_2","node_id":"-44099"},{"name":"data_3","node_id":"-44099"}],"cacheable":true,"seq_num":64,"comment":"申万二级收益","comment_collapsed":true},{"node_id":"-1389","module_id":"BigQuantSpace.hyper_run.hyper_run-v1","parameters":[{"name":"run","value":"\ndef bigquant_run(bq_graph, inputs):\n g = bq_graph\n parameters_list = []\n #原始因子\n features = [\n ]\n add_features = [\n 'd1 = turn_0',\n 'd2 = turn_5'\n ]\n i = 0\n for feature in add_features:\n parameters = {}\n temp = list(set(features)).copy()\n if isinstance(feature,list)==True:\n for x in feature:\n temp.append(x) \n else:\n temp.append(feature)\n temp = list(set(temp))\n parameters['m3.features'] = '\\n'.join(temp)\n parameters_list.append({'parameters': parameters})\n i+=1\n \n #每组因子进行回测\n def run(parameters):\n try:\n result = g.run(parameters)\n return result\n except Exception as e:\n print('ERROR --------', e)\n return None\n results = T.parallel_map(run, parameters_list, max_workers=2, remote_run=False, silent=True)\n \n return results","type":"Literal","bound_global_parameter":null},{"name":"run_now","value":"True","type":"Literal","bound_global_parameter":null},{"name":"bq_graph","value":"True","type":"Literal","bound_global_parameter":null}],"input_ports":[{"name":"bq_graph_port","node_id":"-1389"},{"name":"input_1","node_id":"-1389"},{"name":"input_2","node_id":"-1389"},{"name":"input_3","node_id":"-1389"}],"output_ports":[{"name":"result","node_id":"-1389"}],"cacheable":false,"seq_num":8,"comment":"","comment_collapsed":true},{"node_id":"-19798","module_id":"BigQuantSpace.fillnan.fillnan-v1","parameters":[{"name":"fill_value","value":"mean","type":"Literal","bound_global_parameter":null}],"input_ports":[{"name":"input_data","node_id":"-19798"},{"name":"features","node_id":"-19798"}],"output_ports":[{"name":"data","node_id":"-19798"}],"cacheable":true,"seq_num":21,"comment":"","comment_collapsed":true}],"node_layout":"<node_postions><node_position Node='287d2cb0-f53c-4101-bdf8-104b137c8601-8' Position='-17,-180,200,200'/><node_position Node='287d2cb0-f53c-4101-bdf8-104b137c8601-15' Position='311,-45,200,200'/><node_position Node='287d2cb0-f53c-4101-bdf8-104b137c8601-24' Position='407,-186,200,200'/><node_position Node='287d2cb0-f53c-4101-bdf8-104b137c8601-53' Position='155,176,200,200'/><node_position Node='-113' Position='26,5,200,200'/><node_position Node='-773' Position='310,10,200,200'/><node_position Node='-553' Position='27,61,200,200'/><node_position Node='-4592' Position='907.213623046875,-174.9419708251953,200,200'/><node_position Node='-43892' Position='585.3641967773438,-115.53826904296875,200,200'/><node_position Node='-4597' Position='629,73,200,200'/><node_position Node='-106' Position='24,-48,200,200'/><node_position Node='-43989' Position='26,115,200,200'/><node_position Node='-44099' Position='602.0765380859375,178,200,200'/><node_position Node='-1389' Position='586,-235,200,200'/><node_position Node='-19798' Position='182.69381713867188,289.6728210449219,200,200'/></node_postions>"},"nodes_readonly":false,"studio_version":"v2"}
    In [25]:
    # 本代码由可视化策略环境自动生成 2023年2月21日 11:01
    # 本代码单元只能在可视化模式下编辑。您也可以拷贝代码,粘贴到新建的代码单元或者策略,然后修改。
    
    
    # Python 代码入口函数,input_1/2/3 对应三个输入端,data_1/2/3 对应三个输出端
    def m64_run_bigquant_run(input_1, input_2, input_3, SW_type):
        feature_list = input_1.read()
        new_feature_list = []
        feature_jc_list = []
        for feature in feature_list:
            splitStrindex = feature.find("=")
            feature_key = feature[0:splitStrindex].strip()
            feature_value = feature[splitStrindex:-1].strip()
            feature_jc_list.append(feature_key)
            new_feature_list.append('n_'+feature_key+'=rank('+feature_key+')')
        print('因子个数:{}'.format(len(new_feature_list)))
        data_1 = DataSource.write_pickle(new_feature_list)
        data_2 = DataSource.write_pickle(feature_jc_list)
        return Outputs(data_1=data_1,data_2=data_2)
    
    # 后处理函数,可选。输入是主函数的输出,可以在这里对数据做处理,或者返回更友好的outputs数据格式。此函数输出不会被缓存。
    def m64_post_run_bigquant_run(outputs):
        return outputs
    
    
    g = T.Graph({
    
        'm1': 'M.instruments.v2',
        'm1.start_date': '2016-01-01',
        'm1.end_date': '2021-01-20',
        'm1.market': 'CN_STOCK_A',
        'm1.instrument_list': '',
        'm1.max_count': 0,
    
        'm2': 'M.advanced_auto_labeler.v2',
        'm2.instruments': T.Graph.OutputPort('m1.data'),
        'm2.label_expr': """# #号开始的表示注释
    # 0. 每行一个,顺序执行,从第二个开始,可以使用label字段
    # 1. 可用数据字段见 https://bigquant.com/docs/data_history_data.html
    #   添加benchmark_前缀,可使用对应的benchmark数据
    # 2. 可用操作符和函数见 `表达式引擎 <https://bigquant.com/docs/big_expr.html>`_
    
    # 计算收益:5日收盘价(作为卖出价格)除以明日开盘价(作为买入价格)
    shift(close, -2) / shift(open, -1) - 1
    
    # 极值处理:用1%和99%分位的值做clip
    clip(label, all_quantile(label, 0.01), all_quantile(label, 0.99))
    
    # 过滤掉一字涨停的情况 (设置label为NaN,在后续处理和训练中会忽略NaN的label)
    where(shift(high, -1) == shift(low, -1), NaN, label)
    """,
        'm2.start_date': '',
        'm2.end_date': '',
        'm2.benchmark': '000300.SHA',
        'm2.drop_na_label': True,
        'm2.cast_label_int': False,
    
        'm13': 'M.standardlize.v8',
        'm13.input_1': T.Graph.OutputPort('m2.data'),
        'm13.columns_input': 'label',
    
        'm3': 'M.input_features.v1',
        'm3.features': '',
    
        'm40': 'M.input_features.v1',
        'm40.features_ds': T.Graph.OutputPort('m3.data'),
        'm40.features': """buy_cond_1 = 1#where(sum(price_limit_status_1==3, 5)>0, 1, 0)
    buy_cond_2 = where(volume_0/volume_1>1, 1, 0)
    buy_cond_3 = where(return_0>1.05, 1, 0)
    buy_cond_4 = where(list_days_0>120, 1, 0)
    
    e1 = mf_net_amount_l_0
    
    #目标变量
    y = shift(close_0,-2)/shift(open_0,-1)
    
    #未来两日股票的收益
    return_2_day=(shift(close_0, -2)-shift(open_0, -1))/shift(open_0, -1)
    #未来三日股票的收益
    return_3_day=(shift(close_0, -3)-shift(open_0, -1))/shift(open_0, -1)
    """,
    
        'm15': 'M.general_feature_extractor.v7',
        'm15.instruments': T.Graph.OutputPort('m1.data'),
        'm15.features': T.Graph.OutputPort('m40.data'),
        'm15.start_date': '',
        'm15.end_date': '',
        'm15.before_start_days': 121,
    
        'm16': 'M.derived_feature_extractor.v3',
        'm16.input_data': T.Graph.OutputPort('m15.data'),
        'm16.features': T.Graph.OutputPort('m40.data'),
        'm16.date_col': 'date',
        'm16.instrument_col': 'instrument',
        'm16.drop_na': False,
        'm16.remove_extra_columns': False,
    
        'm5': 'M.chinaa_stock_filter.v1',
        'm5.input_data': T.Graph.OutputPort('m16.data'),
        'm5.index_constituent_cond': ['全部'],
        'm5.board_cond': ['上证主板', '深证主板', '创业板'],
        'm5.industry_cond': ['全部'],
        'm5.st_cond': ['正常'],
        'm5.delist_cond': ['非退市'],
        'm5.output_left_data': False,
    
        'm52': 'M.filter.v3',
        'm52.input_data': T.Graph.OutputPort('m5.data'),
        'm52.expr': 'buy_cond_1==1&buy_cond_2==1&buy_cond_3==1&buy_cond_4==1',
        'm52.output_left_data': False,
    
        'm7': 'M.join.v3',
        'm7.data1': T.Graph.OutputPort('m52.data'),
        'm7.data2': T.Graph.OutputPort('m13.data'),
        'm7.on': 'date,instrument',
        'm7.how': 'inner',
        'm7.sort': False,
    
        'm14': 'M.input_features.v1',
        'm14.features': '',
    
        'm41': 'M.features_append.v1',
        'm41.input_1': T.Graph.OutputPort('m3.data'),
        'm41.input_2': T.Graph.OutputPort('m14.data'),
    
        'm64': 'M.cached.v3',
        'm64.input_1': T.Graph.OutputPort('m41.data_1'),
        'm64.run': m64_run_bigquant_run,
        'm64.post_run': m64_post_run_bigquant_run,
        'm64.input_ports': '',
        'm64.params': """{
        'SW_type':'name_SW2'
    }""",
        'm64.output_ports': 'data_1,data_2',
    
        'm21': 'M.fillnan.v1',
        'm21.input_data': T.Graph.OutputPort('m7.data'),
        'm21.features': T.Graph.OutputPort('m64.data_2'),
        'm21.fill_value': 'mean',
    })
    
    # g.run({})
    
    
    
    def m8_run_bigquant_run(bq_graph, inputs):
        g = bq_graph
        parameters_list = []
        #原始因子
        features = [
        ]
        add_features = [
            'd1 = turn_0',
            'd2 = turn_5'
        ]
        i = 0
        for feature in add_features:
            parameters = {}
            temp = list(set(features)).copy()
            if isinstance(feature,list)==True:
                for x in feature:
                    temp.append(x) 
            else:
                temp.append(feature)
            temp = list(set(temp))
            parameters['m3.features'] = '\n'.join(temp)
            parameters_list.append({'parameters': parameters})
            i+=1
      
        #每组因子进行回测
        def run(parameters):
            try:
                result = g.run(parameters)
                return result
            except Exception as e:
                print('ERROR --------', e)
                return None
        results = T.parallel_map(run, parameters_list, max_workers=2, remote_run=False, silent=True)
           
        return results
    
    m8 = M.hyper_run.v1(
        run=m8_run_bigquant_run,
        run_now=True,
        bq_graph=g
    )
    
    In [26]:
    m8.result
    
    Out[26]:
    [None, None]