复制链接
克隆策略

    {"description":"实验创建于2022/3/23","graph":{"edges":[{"to_node_id":"-505:features_ds","from_node_id":"-501:data"},{"to_node_id":"-571:features","from_node_id":"-501:data"},{"to_node_id":"-528:features","from_node_id":"-505:data"},{"to_node_id":"-535:features","from_node_id":"-505:data"},{"to_node_id":"-792:features","from_node_id":"-505:data"},{"to_node_id":"-799:features","from_node_id":"-505:data"},{"to_node_id":"-554:data1","from_node_id":"-509:data"},{"to_node_id":"-509:instruments","from_node_id":"-519:data"},{"to_node_id":"-528:instruments","from_node_id":"-519:data"},{"to_node_id":"-535:input_data","from_node_id":"-528:data"},{"to_node_id":"-554:data2","from_node_id":"-535:data"},{"to_node_id":"-561:input_data","from_node_id":"-544:data"},{"to_node_id":"-544:input_data","from_node_id":"-554:data"},{"to_node_id":"-587:model","from_node_id":"-571:model"},{"to_node_id":"-250:options_data","from_node_id":"-587:predictions"},{"to_node_id":"-792:instruments","from_node_id":"-783:data"},{"to_node_id":"-250:instruments","from_node_id":"-783:data"},{"to_node_id":"-799:input_data","from_node_id":"-792:data"},{"to_node_id":"-3997:input_data","from_node_id":"-799:data"},{"to_node_id":"287d2cb0-f53c-4101-bdf8-104b137c8601-84:input_data","from_node_id":"-561:data"},{"to_node_id":"-571:training_ds","from_node_id":"287d2cb0-f53c-4101-bdf8-104b137c8601-84:data"},{"to_node_id":"-571:test_ds","from_node_id":"287d2cb0-f53c-4101-bdf8-104b137c8601-84:data"},{"to_node_id":"-4002:input_data","from_node_id":"-3997:data"},{"to_node_id":"-587:data","from_node_id":"-4002:data"}],"nodes":[{"node_id":"-501","module_id":"BigQuantSpace.input_features.input_features-v1","parameters":[{"name":"features","value":"\n# #号开始的表示注释,注释需单独一行\n# 多个特征,每行一个,可以包含基础特征和衍生特征,特征须为本平台特征\nts_min(amount_0,20)/mean(amount_0,20)\n#20日内最低成交额/20日平均成交额\nrank_swing_volatility_5_0\n#5日的振幅波动率排名\nrank(mean(mf_net_amount_xl_0,5))/rank(mean(mf_net_amount_xl_0,20))\n#5日的平均超大单资金流入的排名/(20日的平均超大单资金流入的排名)\nrank(sum(high_0/close_0,20))/rank(sum(close_0/low_0,10))\n#最高价和最低价的关系\nmean(mf_net_amount_m_0,10)/mean(mf_net_amount_m_0,20)\n#10日内的资金流中单净值/20日内中单净值 排序\nrank(mean(amount_0/deal_number_0,5))/rank(mean(amount_0/deal_number_0,20))\n#成交额和成交笔数的关系\nrank(mean(mf_net_amount_s_0,5))/rank(mean(mf_net_amount_s_0,20))\n#5日内的资金流小单净值/20日内小单净值 排序\nrank(mean(mf_net_amount_m_0,5))/rank(mean(mf_net_amount_m_0,10))\n#5日内的资金流中单净值/10日内小单净值 排序\nrank(mean(mf_net_amount_l_0,5))/rank(mean(mf_net_amount_l_0,10))\n#5日内的资金流大单净值/10日内大单净值 排序\ncorrelation(sqrt(volume_0),return_0,5)\n#5日内收益率和成交量的平方的相关系数\ncorrelation(log(volume_0),abs(return_0-1),5)\n#5日内成交量的对数 和收益率的绝对值 的相关系数\n\n","type":"Literal","bound_global_parameter":null}],"input_ports":[{"name":"features_ds","node_id":"-501"}],"output_ports":[{"name":"data","node_id":"-501"}],"cacheable":true,"seq_num":1,"comment":"","comment_collapsed":true},{"node_id":"-505","module_id":"BigQuantSpace.input_features.input_features-v1","parameters":[{"name":"features","value":"\n# #号开始的表示注释,注释需单独一行\n# 多个特征,每行一个,可以包含基础特征和衍生特征,特征须为本平台特征\ncond1=rank(((close_0-open_0)/open_0)/((close_0-open_4)/open_4))\n\ncond3=rank(((high_0-low_0)/close_1)/ts_max(((high_0-low_0)/close_1), 20))\n","type":"Literal","bound_global_parameter":null}],"input_ports":[{"name":"features_ds","node_id":"-505"}],"output_ports":[{"name":"data","node_id":"-505"}],"cacheable":true,"seq_num":2,"comment":"","comment_collapsed":true},{"node_id":"-509","module_id":"BigQuantSpace.advanced_auto_labeler.advanced_auto_labeler-v2","parameters":[{"name":"label_expr","value":"# #号开始的表示注释\n# 0. 每行一个,顺序执行,从第二个开始,可以使用label字段\n# 1. 可用数据字段见 https://bigquant.com/docs/develop/datasource/deprecated/history_data.html\n# 添加benchmark_前缀,可使用对应的benchmark数据\n# 2. 可用操作符和函数见 `表达式引擎 <https://bigquant.com/docs/develop/bigexpr/usage.html>`_\n\n# 计算收益,2日收盘价(作为卖出价格)除以明日开盘价(作为买入价格)\n\nshift(close, -2) / shift(open, -1)-1\n\n# 极值处理:用1%和99%分位的值做clip\n\nclip(label, all_quantile(label, 0.01), all_quantile(label, 0.99))\n\n# 将分数映射到分类,这里使用30个分类\n\nall_wbins(label, 30)\n\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":"True","type":"Literal","bound_global_parameter":null},{"name":"user_functions","value":"{}","type":"Literal","bound_global_parameter":null}],"input_ports":[{"name":"instruments","node_id":"-509"}],"output_ports":[{"name":"data","node_id":"-509"}],"cacheable":true,"seq_num":3,"comment":"","comment_collapsed":true},{"node_id":"-519","module_id":"BigQuantSpace.instruments.instruments-v2","parameters":[{"name":"start_date","value":"2011-10-20","type":"Literal","bound_global_parameter":null},{"name":"end_date","value":"2021-03-15","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":"-519"}],"output_ports":[{"name":"data","node_id":"-519"}],"cacheable":true,"seq_num":4,"comment":"","comment_collapsed":true},{"node_id":"-528","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":"-528"},{"name":"features","node_id":"-528"}],"output_ports":[{"name":"data","node_id":"-528"}],"cacheable":true,"seq_num":5,"comment":"","comment_collapsed":true},{"node_id":"-535","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":"-535"},{"name":"features","node_id":"-535"}],"output_ports":[{"name":"data","node_id":"-535"}],"cacheable":true,"seq_num":6,"comment":"","comment_collapsed":true},{"node_id":"-544","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%3Afalse%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%2C%7B%22value%22%3A%22%E5%8C%97%E4%BA%A4%E6%89%80%22%2C%22displayValue%22%3A%22%E5%8C%97%E4%BA%A4%E6%89%80%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%3Atrue%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%3Afalse%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":"-544"}],"output_ports":[{"name":"data","node_id":"-544"},{"name":"left_data","node_id":"-544"}],"cacheable":true,"seq_num":7,"comment":"","comment_collapsed":true},{"node_id":"-554","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":"-554"},{"name":"data2","node_id":"-554"}],"output_ports":[{"name":"data","node_id":"-554"}],"cacheable":true,"seq_num":8,"comment":"","comment_collapsed":true},{"node_id":"-571","module_id":"BigQuantSpace.stock_ranker_train.stock_ranker_train-v6","parameters":[{"name":"learning_algorithm","value":"排序","type":"Literal","bound_global_parameter":null},{"name":"number_of_leaves","value":30,"type":"Literal","bound_global_parameter":null},{"name":"minimum_docs_per_leaf","value":"280","type":"Literal","bound_global_parameter":null},{"name":"number_of_trees","value":"21","type":"Literal","bound_global_parameter":null},{"name":"learning_rate","value":0.1,"type":"Literal","bound_global_parameter":null},{"name":"max_bins","value":1023,"type":"Literal","bound_global_parameter":null},{"name":"feature_fraction","value":1,"type":"Literal","bound_global_parameter":null},{"name":"data_row_fraction","value":1,"type":"Literal","bound_global_parameter":null},{"name":"plot_charts","value":"True","type":"Literal","bound_global_parameter":null},{"name":"ndcg_discount_base","value":1,"type":"Literal","bound_global_parameter":null},{"name":"m_lazy_run","value":"False","type":"Literal","bound_global_parameter":null}],"input_ports":[{"name":"training_ds","node_id":"-571"},{"name":"features","node_id":"-571"},{"name":"test_ds","node_id":"-571"},{"name":"base_model","node_id":"-571"}],"output_ports":[{"name":"model","node_id":"-571"},{"name":"feature_gains","node_id":"-571"},{"name":"m_lazy_run","node_id":"-571"}],"cacheable":true,"seq_num":10,"comment":"","comment_collapsed":true},{"node_id":"-587","module_id":"BigQuantSpace.stock_ranker_predict.stock_ranker_predict-v5","parameters":[{"name":"m_lazy_run","value":"False","type":"Literal","bound_global_parameter":null}],"input_ports":[{"name":"model","node_id":"-587"},{"name":"data","node_id":"-587"}],"output_ports":[{"name":"predictions","node_id":"-587"},{"name":"m_lazy_run","node_id":"-587"}],"cacheable":true,"seq_num":11,"comment":"","comment_collapsed":true},{"node_id":"-783","module_id":"BigQuantSpace.instruments.instruments-v2","parameters":[{"name":"start_date","value":"2021-03-16","type":"Literal","bound_global_parameter":null},{"name":"end_date","value":"2022-03-23","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":"-783"}],"output_ports":[{"name":"data","node_id":"-783"}],"cacheable":true,"seq_num":12,"comment":"","comment_collapsed":true},{"node_id":"-792","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":"-792"},{"name":"features","node_id":"-792"}],"output_ports":[{"name":"data","node_id":"-792"}],"cacheable":true,"seq_num":13,"comment":"","comment_collapsed":true},{"node_id":"-799","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":"-799"},{"name":"features","node_id":"-799"}],"output_ports":[{"name":"data","node_id":"-799"}],"cacheable":true,"seq_num":14,"comment":"","comment_collapsed":true},{"node_id":"-250","module_id":"BigQuantSpace.trade.trade-v4","parameters":[{"name":"start_date","value":"","type":"Literal","bound_global_parameter":null},{"name":"end_date","value":"","type":"Literal","bound_global_parameter":null},{"name":"initialize","value":"# 回测引擎:初始化函数,只执行一次\ndef bigquant_run(context):\n # 加载预测数据\n context.ranker_prediction = context.options['data'].read_df()\n\n # 系统已经设置了默认的交易手续费和滑点,要修改手续费可使用如下函数\n context.set_commission(PerOrder(buy_cost=0.0003, sell_cost=0.0013, min_cost=5))\n # 预测数据,通过options传入进来,使用 read_df 函数,加载到内存 (DataFrame)\n # 设置买入的股票数量,这里买入预测股票列表排名靠前的5只\n stock_count = 1\n # 每只的股票的权重,如下的权重分配会使得靠前的股票分配多一点的资金,[0.339160, 0.213986, 0.169580, ..]\n context.stock_weights = [1]\n # 设置每只股票占用的最大资金比例\n context.max_cash_per_instrument = 1\n context.options['hold_days'] = 1\n","type":"Literal","bound_global_parameter":null},{"name":"handle_data","value":"# 回测引擎:每日数据处理函数,每天执行一次\ndef bigquant_run(context, data):\n # 获取当前持仓\n positions = {e.symbol: p.amount * p.last_sale_price\n for e, p in context.portfolio.positions.items()}\n \n today = data.current_dt.strftime('%Y-%m-%d')\n # 按日期过滤得到今日的预测数据\n ranker_prediction = context.ranker_prediction[\n context.ranker_prediction.date == today]\n# try:\n# #大盘风控模块,读取风控数据 \n# benckmark_risk=ranker_prediction['bm_0'].values[0]\n# if benckmark_risk > 0:\n# for instrument in positions.keys():\n# context.order_target(context.symbol(instrument), 0)\n# print(today,'大盘风控止损触发,全仓卖出')\n# return\n# except:\n# print('--!')\n \n #当risk为1时,市场有风险,全部平仓,不再执行其它操作 \n # 按日期过滤得到今日的预测数据\n ranker_prediction = context.ranker_prediction[\n context.ranker_prediction.date == data.current_dt.strftime('%Y-%m-%d')]\n #cash_for_buy = min(context.portfolio.portfolio_value/2,context.portfolio.cash)\n #cash_for_buy = context.portfolio.portfolio_value\n #print(ranker_prediction)\n #cash_for_buy = context.portfolio.portfolio_value\n # 手上有的资金全拿来买股票\n cash_for_buy = context.portfolio.cash\n # stockranker给出的股票排序\n buy_instruments = list(ranker_prediction.instrument)\n # 需要卖出的股票(持仓的股票)\n sell_instruments = [instrument.symbol for instrument in context.portfolio.positions.keys()]\n # 买入的股票不能是需要卖出的股票\n to_buy = set(buy_instruments[:1]) - set(sell_instruments) \n # 需要卖出的股票不包含需要买入的股票\n to_sell = set(sell_instruments) - set(buy_instruments[:1])\n \n \n for instrument in to_sell:\n context.order_target(context.symbol(instrument), 0)\n for instrument in to_buy:\n context.order_value(context.symbol(instrument), cash_for_buy)\n","type":"Literal","bound_global_parameter":null},{"name":"prepare","value":"def bigquant_run(context):\n\n\n # 获取st状态和涨跌停状态\n \n context.status_df = D.features(instruments =context.instruments,start_date = context.start_date, end_date = context.end_date, \n fields=['st_status_0','price_limit_status_0','price_limit_status_1'])\n","type":"Literal","bound_global_parameter":null},{"name":"before_trading_start","value":"def bigquant_run(context, data):\n pass \n# # 获取涨跌停状态数据\n# df_price_limit_status=context.status_df.set_index('date')\n# today=data.current_dt.strftime('%Y-%m-%d')\n# # 得到当前未完成订单\n# for orders in get_open_orders().values():\n# # 循环,撤销订单\n# for _order in orders:\n# ins=str(_order.sid.symbol)\n# try:\n# #判断一下如果当日涨停,则取消卖单\n# if df_price_limit_status[df_price_limit_status.instrument==ins].price_limit_status_0.loc[today]>2 and _order.amount<0:\n# cancel_order(_order)\n# print(today,'尾盘涨停取消卖单',ins) \n# except:\n# continue\n \n \n ","type":"Literal","bound_global_parameter":null},{"name":"volume_limit","value":"0","type":"Literal","bound_global_parameter":null},{"name":"order_price_field_buy","value":"open","type":"Literal","bound_global_parameter":null},{"name":"order_price_field_sell","value":"close","type":"Literal","bound_global_parameter":null},{"name":"capital_base","value":"100000","type":"Literal","bound_global_parameter":null},{"name":"auto_cancel_non_tradable_orders","value":"True","type":"Literal","bound_global_parameter":null},{"name":"data_frequency","value":"daily","type":"Literal","bound_global_parameter":null},{"name":"price_type","value":"真实价格","type":"Literal","bound_global_parameter":null},{"name":"product_type","value":"股票","type":"Literal","bound_global_parameter":null},{"name":"plot_charts","value":"True","type":"Literal","bound_global_parameter":null},{"name":"backtest_only","value":"False","type":"Literal","bound_global_parameter":null},{"name":"benchmark","value":"000300.SHA","type":"Literal","bound_global_parameter":null}],"input_ports":[{"name":"instruments","node_id":"-250"},{"name":"options_data","node_id":"-250"},{"name":"history_ds","node_id":"-250"},{"name":"benchmark_ds","node_id":"-250"},{"name":"trading_calendar","node_id":"-250"}],"output_ports":[{"name":"raw_perf","node_id":"-250"}],"cacheable":false,"seq_num":15,"comment":"","comment_collapsed":true},{"node_id":"-561","module_id":"BigQuantSpace.filter.filter-v3","parameters":[{"name":"expr","value":"cond1<0.01 & cond3>0.85","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":"-561"}],"output_ports":[{"name":"data","node_id":"-561"},{"name":"left_data","node_id":"-561"}],"cacheable":true,"seq_num":9,"comment":"","comment_collapsed":true},{"node_id":"287d2cb0-f53c-4101-bdf8-104b137c8601-84","module_id":"BigQuantSpace.dropnan.dropnan-v1","parameters":[],"input_ports":[{"name":"input_data","node_id":"287d2cb0-f53c-4101-bdf8-104b137c8601-84"}],"output_ports":[{"name":"data","node_id":"287d2cb0-f53c-4101-bdf8-104b137c8601-84"}],"cacheable":true,"seq_num":16,"comment":"","comment_collapsed":true},{"node_id":"-3997","module_id":"BigQuantSpace.filter.filter-v3","parameters":[{"name":"expr","value":"cond1<0.01 & cond3>0.85","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":"-3997"}],"output_ports":[{"name":"data","node_id":"-3997"},{"name":"left_data","node_id":"-3997"}],"cacheable":true,"seq_num":17,"comment":"","comment_collapsed":true},{"node_id":"-4002","module_id":"BigQuantSpace.dropnan.dropnan-v1","parameters":[],"input_ports":[{"name":"input_data","node_id":"-4002"}],"output_ports":[{"name":"data","node_id":"-4002"}],"cacheable":true,"seq_num":18,"comment":"","comment_collapsed":true}],"node_layout":"<node_postions><node_position Node='-501' Position='323,-66,200,200'/><node_position Node='-505' Position='342,29,200,200'/><node_position Node='-509' Position='-24,120,200,200'/><node_position Node='-519' Position='-20,5,200,200'/><node_position Node='-528' Position='272.6561584472656,156,200,200'/><node_position Node='-535' Position='272.51104736328125,250.3817138671875,200,200'/><node_position Node='-544' Position='136.6940460205078,423.70977783203125,200,200'/><node_position Node='-554' Position='124,360,200,200'/><node_position Node='-571' Position='157.64041137695312,648.7633666992188,200,200'/><node_position Node='-587' Position='434.80126953125,719.80126953125,200,200'/><node_position Node='-783' Position='685,-24,200,200'/><node_position Node='-792' Position='688.9463500976562,219.26808166503906,200,200'/><node_position Node='-799' Position='648.9085083007812,339.7791748046875,200,200'/><node_position Node='-250' Position='410.47320556640625,802.6561889648438,200,200'/><node_position Node='-561' Position='140.3502197265625,498.9464111328125,200,200'/><node_position Node='287d2cb0-f53c-4101-bdf8-104b137c8601-84' Position='139.02212524414062,572.236572265625,200,200'/><node_position Node='-3997' Position='626.6719360351562,438.0536193847656,200,200'/><node_position Node='-4002' Position='604.4195556640625,531.5425415039062,200,200'/></node_postions>"},"nodes_readonly":false,"studio_version":"v2"}
    In [3]:
    # 本代码由可视化策略环境自动生成 2022年3月24日 11:23
    # 本代码单元只能在可视化模式下编辑。您也可以拷贝代码,粘贴到新建的代码单元或者策略,然后修改。
    
    
    # 回测引擎:初始化函数,只执行一次
    def m15_initialize_bigquant_run(context):
        # 加载预测数据
        context.ranker_prediction = context.options['data'].read_df()
    
        # 系统已经设置了默认的交易手续费和滑点,要修改手续费可使用如下函数
        context.set_commission(PerOrder(buy_cost=0.0003, sell_cost=0.0013, min_cost=5))
        # 预测数据,通过options传入进来,使用 read_df 函数,加载到内存 (DataFrame)
        # 设置买入的股票数量,这里买入预测股票列表排名靠前的5只
        stock_count = 1
        # 每只的股票的权重,如下的权重分配会使得靠前的股票分配多一点的资金,[0.339160, 0.213986, 0.169580, ..]
        context.stock_weights = [1]
        # 设置每只股票占用的最大资金比例
        context.max_cash_per_instrument = 1
        context.options['hold_days'] = 1
    
    # 回测引擎:每日数据处理函数,每天执行一次
    def m15_handle_data_bigquant_run(context, data):
        # 获取当前持仓
        positions = {e.symbol: p.amount * p.last_sale_price
                     for e, p in context.portfolio.positions.items()}
        
        today = data.current_dt.strftime('%Y-%m-%d')
        # 按日期过滤得到今日的预测数据
        ranker_prediction = context.ranker_prediction[
            context.ranker_prediction.date == today]
    #     try:
    #     #大盘风控模块,读取风控数据    
    #         benckmark_risk=ranker_prediction['bm_0'].values[0]
    #         if benckmark_risk > 0:
    #             for instrument in positions.keys():
    #                 context.order_target(context.symbol(instrument), 0)
    #                 print(today,'大盘风控止损触发,全仓卖出')
    #                 return
    #     except:
    #         print('--!')
            
        #当risk为1时,市场有风险,全部平仓,不再执行其它操作    
        # 按日期过滤得到今日的预测数据
        ranker_prediction = context.ranker_prediction[
            context.ranker_prediction.date == data.current_dt.strftime('%Y-%m-%d')]
        #cash_for_buy = min(context.portfolio.portfolio_value/2,context.portfolio.cash)
        #cash_for_buy = context.portfolio.portfolio_value
        #print(ranker_prediction)
        #cash_for_buy = context.portfolio.portfolio_value
        # 手上有的资金全拿来买股票
        cash_for_buy = context.portfolio.cash
        # stockranker给出的股票排序
        buy_instruments = list(ranker_prediction.instrument)
        # 需要卖出的股票(持仓的股票)
        sell_instruments = [instrument.symbol for instrument in context.portfolio.positions.keys()]
        # 买入的股票不能是需要卖出的股票
        to_buy = set(buy_instruments[:1]) - set(sell_instruments) 
        # 需要卖出的股票不包含需要买入的股票
        to_sell = set(sell_instruments) -  set(buy_instruments[:1])
       
        
        for instrument in to_sell:
            context.order_target(context.symbol(instrument), 0)
        for instrument in to_buy:
            context.order_value(context.symbol(instrument), cash_for_buy)
    
    def m15_prepare_bigquant_run(context):
    
    
         # 获取st状态和涨跌停状态
        
        context.status_df = D.features(instruments =context.instruments,start_date = context.start_date, end_date = context.end_date, 
                               fields=['st_status_0','price_limit_status_0','price_limit_status_1'])
    
    def m15_before_trading_start_bigquant_run(context, data):
        pass     
    #     # 获取涨跌停状态数据
    #     df_price_limit_status=context.status_df.set_index('date')
    #     today=data.current_dt.strftime('%Y-%m-%d')
    #     # 得到当前未完成订单
    #     for orders in get_open_orders().values():
    #         # 循环,撤销订单
    #         for _order in orders:
    #             ins=str(_order.sid.symbol)
    #             try:
    #                 #判断一下如果当日涨停,则取消卖单
    #                 if  df_price_limit_status[df_price_limit_status.instrument==ins].price_limit_status_0.loc[today]>2 and _order.amount<0:
    #                     cancel_order(_order)
    #                     print(today,'尾盘涨停取消卖单',ins) 
    #             except:
    #                 continue
      
        
        
    
    m1 = M.input_features.v1(
        features="""
    # #号开始的表示注释,注释需单独一行
    # 多个特征,每行一个,可以包含基础特征和衍生特征,特征须为本平台特征
    ts_min(amount_0,20)/mean(amount_0,20)
    #20日内最低成交额/20日平均成交额
    rank_swing_volatility_5_0
    #5日的振幅波动率排名
    rank(mean(mf_net_amount_xl_0,5))/rank(mean(mf_net_amount_xl_0,20))
    #5日的平均超大单资金流入的排名/(20日的平均超大单资金流入的排名)
    rank(sum(high_0/close_0,20))/rank(sum(close_0/low_0,10))
    #最高价和最低价的关系
    mean(mf_net_amount_m_0,10)/mean(mf_net_amount_m_0,20)
    #10日内的资金流中单净值/20日内中单净值 排序
    rank(mean(amount_0/deal_number_0,5))/rank(mean(amount_0/deal_number_0,20))
    #成交额和成交笔数的关系
    rank(mean(mf_net_amount_s_0,5))/rank(mean(mf_net_amount_s_0,20))
    #5日内的资金流小单净值/20日内小单净值 排序
    rank(mean(mf_net_amount_m_0,5))/rank(mean(mf_net_amount_m_0,10))
    #5日内的资金流中单净值/10日内小单净值 排序
    rank(mean(mf_net_amount_l_0,5))/rank(mean(mf_net_amount_l_0,10))
    #5日内的资金流大单净值/10日内大单净值 排序
    correlation(sqrt(volume_0),return_0,5)
    #5日内收益率和成交量的平方的相关系数
    correlation(log(volume_0),abs(return_0-1),5)
    #5日内成交量的对数 和收益率的绝对值 的相关系数
    
    """
    )
    
    m2 = M.input_features.v1(
        features_ds=m1.data,
        features="""
    # #号开始的表示注释,注释需单独一行
    # 多个特征,每行一个,可以包含基础特征和衍生特征,特征须为本平台特征
    cond1=rank(((close_0-open_0)/open_0)/((close_0-open_4)/open_4))
    
    cond3=rank(((high_0-low_0)/close_1)/ts_max(((high_0-low_0)/close_1), 20))
    """
    )
    
    m4 = M.instruments.v2(
        start_date='2011-10-20',
        end_date='2021-03-15',
        market='CN_STOCK_A',
        instrument_list='',
        max_count=0
    )
    
    m3 = M.advanced_auto_labeler.v2(
        instruments=m4.data,
        label_expr="""# #号开始的表示注释
    # 0. 每行一个,顺序执行,从第二个开始,可以使用label字段
    # 1. 可用数据字段见 https://bigquant.com/docs/develop/datasource/deprecated/history_data.html
    #   添加benchmark_前缀,可使用对应的benchmark数据
    # 2. 可用操作符和函数见 `表达式引擎 <https://bigquant.com/docs/develop/bigexpr/usage.html>`_
    
    # 计算收益,2日收盘价(作为卖出价格)除以明日开盘价(作为买入价格)
    
    shift(close, -2) / shift(open, -1)-1
    
    # 极值处理:用1%和99%分位的值做clip
    
    clip(label, all_quantile(label, 0.01), all_quantile(label, 0.99))
    
    # 将分数映射到分类,这里使用30个分类
    
    all_wbins(label, 30)
    
    """,
        start_date='',
        end_date='',
        benchmark='000300.SHA',
        drop_na_label=True,
        cast_label_int=True,
        user_functions={}
    )
    
    m5 = M.general_feature_extractor.v7(
        instruments=m4.data,
        features=m2.data,
        start_date='',
        end_date='',
        before_start_days=90
    )
    
    m6 = M.derived_feature_extractor.v3(
        input_data=m5.data,
        features=m2.data,
        date_col='date',
        instrument_col='instrument',
        drop_na=False,
        remove_extra_columns=False,
        user_functions={}
    )
    
    m8 = M.join.v3(
        data1=m3.data,
        data2=m6.data,
        on='date,instrument',
        how='inner',
        sort=False
    )
    
    m7 = M.chinaa_stock_filter.v1(
        input_data=m8.data,
        index_constituent_cond=['全部'],
        board_cond=['上证主板', '深证主板'],
        industry_cond=['全部'],
        st_cond=['正常'],
        delist_cond=['退市'],
        output_left_data=False
    )
    
    m9 = M.filter.v3(
        input_data=m7.data,
        expr='cond1<0.01 & cond3>0.85',
        output_left_data=False
    )
    
    m16 = M.dropnan.v1(
        input_data=m9.data
    )
    
    m10 = M.stock_ranker_train.v6(
        training_ds=m16.data,
        features=m1.data,
        test_ds=m16.data,
        learning_algorithm='排序',
        number_of_leaves=30,
        minimum_docs_per_leaf=280,
        number_of_trees=21,
        learning_rate=0.1,
        max_bins=1023,
        feature_fraction=1,
        data_row_fraction=1,
        plot_charts=True,
        ndcg_discount_base=1,
        m_lazy_run=False
    )
    
    m12 = M.instruments.v2(
        start_date='2021-03-16',
        end_date='2022-03-23',
        market='CN_STOCK_A',
        instrument_list='',
        max_count=0
    )
    
    m13 = M.general_feature_extractor.v7(
        instruments=m12.data,
        features=m2.data,
        start_date='',
        end_date='',
        before_start_days=90
    )
    
    m14 = M.derived_feature_extractor.v3(
        input_data=m13.data,
        features=m2.data,
        date_col='date',
        instrument_col='instrument',
        drop_na=False,
        remove_extra_columns=False,
        user_functions={}
    )
    
    m17 = M.filter.v3(
        input_data=m14.data,
        expr='cond1<0.01 & cond3>0.85',
        output_left_data=False
    )
    
    m18 = M.dropnan.v1(
        input_data=m17.data
    )
    
    m11 = M.stock_ranker_predict.v5(
        model=m10.model,
        data=m18.data,
        m_lazy_run=False
    )
    
    m15 = M.trade.v4(
        instruments=m12.data,
        options_data=m11.predictions,
        start_date='',
        end_date='',
        initialize=m15_initialize_bigquant_run,
        handle_data=m15_handle_data_bigquant_run,
        prepare=m15_prepare_bigquant_run,
        before_trading_start=m15_before_trading_start_bigquant_run,
        volume_limit=0,
        order_price_field_buy='open',
        order_price_field_sell='close',
        capital_base=100000,
        auto_cancel_non_tradable_orders=True,
        data_frequency='daily',
        price_type='真实价格',
        product_type='股票',
        plot_charts=True,
        backtest_only=False,
        benchmark='000300.SHA'
    )
    
    ---------------------------------------------------------------------------
    Exception                                 Traceback (most recent call last)
    <ipython-input-3-9abed9487e05> in <module>
        218 )
        219 
    --> 220 m10 = M.stock_ranker_train.v6(
        221     training_ds=m16.data,
        222     features=m1.data,
    
    Exception: 模型训练失败:可能导致错误的原因是训练数据问题,请检查训练数据, err_code=1 (5bef2462ab2111ec80d3c6e6238ccd28)