复制链接
克隆策略

    {"description":"实验创建于2020/4/10","graph":{"edges":[{"to_node_id":"-526:instruments","from_node_id":"-513:data"},{"to_node_id":"-565:instruments","from_node_id":"-513:data"},{"to_node_id":"-526:features","from_node_id":"-521:data"},{"to_node_id":"-541:features","from_node_id":"-521:data"},{"to_node_id":"-548:features","from_node_id":"-521:data"},{"to_node_id":"-557:features","from_node_id":"-521:data"},{"to_node_id":"-548:input_data","from_node_id":"-526:data"},{"to_node_id":"-541:instruments","from_node_id":"-532:data"},{"to_node_id":"-614:instruments","from_node_id":"-532:data"},{"to_node_id":"-557:input_data","from_node_id":"-541:data"},{"to_node_id":"-576:data2","from_node_id":"-548:data"},{"to_node_id":"-2650:input_data","from_node_id":"-557:data"},{"to_node_id":"-576:data1","from_node_id":"-565:data"},{"to_node_id":"-2640:input_data","from_node_id":"-576:data"},{"to_node_id":"-600:predict_ds","from_node_id":"-593:data"},{"to_node_id":"-635:input_ds","from_node_id":"-600:predictions"},{"to_node_id":"-614:options_data","from_node_id":"-635:sorted_data"},{"to_node_id":"-590:input_data","from_node_id":"-2640:data"},{"to_node_id":"-593:input_data","from_node_id":"-2650:data"},{"to_node_id":"-600:training_ds","from_node_id":"-1451:data_1"}],"nodes":[{"node_id":"-513","module_id":"BigQuantSpace.instruments.instruments-v2","parameters":[{"name":"start_date","value":"2020-01-01","type":"Literal","bound_global_parameter":null},{"name":"end_date","value":"2020-12-31","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":"-513"}],"output_ports":[{"name":"data","node_id":"-513"}],"cacheable":true,"seq_num":1,"comment":"","comment_collapsed":true},{"node_id":"-521","module_id":"BigQuantSpace.input_features.input_features-v1","parameters":[{"name":"features","value":"# #号开始的表示注释\n# 多个特征,每行一个,可以包含基础特征和衍生特征\nreturn_5\nreturn_10\nreturn_20\navg_amount_0/avg_amount_5\navg_amount_5/avg_amount_20\nrank_avg_amount_0/rank_avg_amount_5\nrank_avg_amount_5/rank_avg_amount_10\nrank_return_0\nrank_return_5\nrank_return_10\nrank_return_0/rank_return_5\nrank_return_5/rank_return_10\npe_ttm_0","type":"Literal","bound_global_parameter":null}],"input_ports":[{"name":"features_ds","node_id":"-521"}],"output_ports":[{"name":"data","node_id":"-521"}],"cacheable":true,"seq_num":2,"comment":"","comment_collapsed":true},{"node_id":"-526","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":"-526"},{"name":"features","node_id":"-526"}],"output_ports":[{"name":"data","node_id":"-526"}],"cacheable":true,"seq_num":3,"comment":"","comment_collapsed":true},{"node_id":"-532","module_id":"BigQuantSpace.instruments.instruments-v2","parameters":[{"name":"start_date","value":"2022-01-01","type":"Literal","bound_global_parameter":null},{"name":"end_date","value":"2022-02-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":"-532"}],"output_ports":[{"name":"data","node_id":"-532"}],"cacheable":true,"seq_num":4,"comment":"","comment_collapsed":true},{"node_id":"-541","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":"-541"},{"name":"features","node_id":"-541"}],"output_ports":[{"name":"data","node_id":"-541"}],"cacheable":true,"seq_num":5,"comment":"","comment_collapsed":true},{"node_id":"-548","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":"-548"},{"name":"features","node_id":"-548"}],"output_ports":[{"name":"data","node_id":"-548"}],"cacheable":true,"seq_num":6,"comment":"","comment_collapsed":true},{"node_id":"-557","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":"-557"},{"name":"features","node_id":"-557"}],"output_ports":[{"name":"data","node_id":"-557"}],"cacheable":true,"seq_num":7,"comment":"","comment_collapsed":true},{"node_id":"-565","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日收盘价(作为卖出价格)除以明日开盘价(作为买入价格)\nshift(close, -2) / shift(open, -1)\n\n\n# 极值处理:用1%和99%分位的值做clip\nclip(label, all_quantile(label, 0.01), all_quantile(label, 0.99))\n\n# 将分数映射到分类,这里使用20个分类\nall_wbins(label, 2)\n# 过滤掉一字涨停的情况 (设置label为NaN,在后续处理和训练中会忽略NaN的label)\n#where(shift(high, -1) == shift(low, -1), NaN, label)\n\nshift(price_limit_status,-1)>2","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":"-565"}],"output_ports":[{"name":"data","node_id":"-565"}],"cacheable":false,"seq_num":8,"comment":"","comment_collapsed":true},{"node_id":"-576","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":"-576"},{"name":"data2","node_id":"-576"}],"output_ports":[{"name":"data","node_id":"-576"}],"cacheable":true,"seq_num":9,"comment":"","comment_collapsed":true},{"node_id":"-590","module_id":"BigQuantSpace.dropnan.dropnan-v1","parameters":[],"input_ports":[{"name":"input_data","node_id":"-590"}],"output_ports":[{"name":"data","node_id":"-590"}],"cacheable":true,"seq_num":11,"comment":"","comment_collapsed":true},{"node_id":"-593","module_id":"BigQuantSpace.dropnan.dropnan-v1","parameters":[],"input_ports":[{"name":"input_data","node_id":"-593"}],"output_ports":[{"name":"data","node_id":"-593"}],"cacheable":true,"seq_num":10,"comment":"","comment_collapsed":true},{"node_id":"-600","module_id":"BigQuantSpace.random_forest_regressor.random_forest_regressor-v1","parameters":[{"name":"iterations","value":10,"type":"Literal","bound_global_parameter":null},{"name":"feature_fraction","value":1,"type":"Literal","bound_global_parameter":null},{"name":"max_depth","value":30,"type":"Literal","bound_global_parameter":null},{"name":"min_samples_per_leaf","value":200,"type":"Literal","bound_global_parameter":null},{"name":"key_cols","value":"date,instrument","type":"Literal","bound_global_parameter":null},{"name":"workers","value":1,"type":"Literal","bound_global_parameter":null},{"name":"random_state","value":0,"type":"Literal","bound_global_parameter":null},{"name":"other_train_parameters","value":"{\"random_state\":0}","type":"Literal","bound_global_parameter":null}],"input_ports":[{"name":"training_ds","node_id":"-600"},{"name":"features","node_id":"-600"},{"name":"model","node_id":"-600"},{"name":"predict_ds","node_id":"-600"}],"output_ports":[{"name":"output_model","node_id":"-600"},{"name":"predictions","node_id":"-600"}],"cacheable":true,"seq_num":12,"comment":"","comment_collapsed":true},{"node_id":"-614","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 = 3\n # 每只的股票的权重,如下的权重分配会使得靠前的股票分配多一点的资金,[0.339160, 0.213986, 0.169580, ..]\n context.stock_weights = T.norm([1 / math.log(i + 2) for i in range(0, stock_count)])\n # 设置每只股票占用的最大资金比例\n context.max_cash_per_instrument = 0.2\n context.hold_days = 1\n \n from zipline.finance.slippage import SlippageModel\n class FixedPriceSlippage(SlippageModel):\n def process_order(self, data, order, bar_volume=0, trigger_check_price=0):\n if order.limit is None:\n price_field = self._price_field_buy if order.amount > 0 else self._price_field_sell\n price = data.current(order.asset, price_field)\n else:\n price = data.current(order.asset, self._price_field_buy)\n # 返回希望成交的价格和数量\n return (price, order.amount)\n # 设置price_field,默认是开盘买入,收盘卖出\n context.fix_slippage = FixedPriceSlippage(price_field_buy='open', price_field_sell='close')\n context.set_slippage(us_equities=context.fix_slippage)\n \n #大盘数据获取\n bm_df = DataSource('bar1d_index_CN_STOCK_A').read(instruments=['000001.HIX'])\n bm_df[\"bm_ret\"] = bm_df[\"close\"]/bm_df[\"close\"].shift(10)-1\n bm_df[\"bm_ret\"] = bm_df[\"bm_ret\"].shift(1) #取昨日的收益情况\n context.bm_df = bm_df[['date','bm_ret']]\n \n #个股风控计算\n import pandas as pd\n start_date = context.ranker_prediction.date.iloc[0]\n start_date = pd.to_datetime(start_date)-pd.Timedelta(days=30)\n end_date = context.ranker_prediction.date.iloc[-1]\n stocks = context.ranker_prediction.instrument.to_list()\n data = DataSource(\"bar1d_CN_STOCK_A\").read(instruments=stocks,start_date=start_date.strftime(\"%Y-%m-%d\"),end_date=end_date)\n #计算个股风控,小于20日均线\n def cal_risk(df):\n df = df.sort_values(\"date\")\n df[\"ma\"] = df.close.rolling(20).mean()\n df[\"risk\"] = np.where(df.close.shift(1)<df.ma.shift(1),1,0)\n return df\n context.stock_risk_data = data.groupby(\"instrument\").apply(cal_risk).reset_index(drop=True)\n\n","type":"Literal","bound_global_parameter":null},{"name":"handle_data","value":"# 回测引擎:每日数据处理函数,每天执行一次\ndef bigquant_run(context, data):\n # 按日期过滤得到今日的预测数据\n ranker_prediction = context.ranker_prediction[\n context.ranker_prediction.date == data.current_dt.strftime('%Y-%m-%d')]\n today = data.current_dt.strftime('%Y-%m-%d')\n \n # 1. 资金分配\n # 平均持仓时间是hold_days,每日都将买入股票,每日预期使用 1/hold_days 的资金\n # 实际操作中,会存在一定的买入误差,所以在前hold_days天,等量使用资金;之后,尽量使用剩余资金(这里设置最多用等量的1.5倍)\n is_staging = context.trading_day_index < context.hold_days # 是否在建仓期间(前 hold_days 天)\n cash_avg = context.portfolio.portfolio_value / context.hold_days\n cash_for_buy = min(context.portfolio.cash, (1 if is_staging else 1.5) * cash_avg)\n cash_for_sell = cash_avg - (context.portfolio.cash - cash_for_buy)\n positions = {e.symbol: p.amount * p.last_sale_price\n for e, p in context.perf_tracker.position_tracker.positions.items()}\n equities = {e.symbol: e for e, p in context.portfolio.positions.items()}\n '''\n # 2. 生成卖出订单:hold_days天之后才开始卖出;对持仓的股票,按StockRanker预测的排序末位淘汰\n if not is_staging and cash_for_sell > 0:\n equities = {e.symbol: e for e, p in context.perf_tracker.position_tracker.positions.items()}\n instruments = list(reversed(list(ranker_prediction.instrument[ranker_prediction.instrument.apply(\n lambda x: x in equities and not context.has_unfinished_sell_order(equities[x]))])))\n # print('rank order for sell %s' % instruments)\n for instrument in instruments:\n context.order_target(context.symbol(instrument), 0)\n cash_for_sell -= positions[instrument]\n if cash_for_sell <= 0:\n break\n\n # 3. 生成买入订单:按StockRanker预测的排序,买入前面的stock_count只股票\n buy_cash_weights = context.stock_weights\n buy_instruments = list(ranker_prediction.instrument[:len(buy_cash_weights)])\n max_cash_per_instrument = context.portfolio.portfolio_value * context.max_cash_per_instrument\n for i, instrument in enumerate(buy_instruments):\n cash = cash_for_buy * buy_cash_weights[i]\n if cash > max_cash_per_instrument - positions.get(instrument, 0):\n # 确保股票持仓量不会超过每次股票最大的占用资金量\n cash = max_cash_per_instrument - positions.get(instrument, 0)\n if cash > 0:\n context.order_value(context.symbol(instrument), cash)\n '''\n \n # 记录持仓中st的股票\n st_stock_list = []\n name_df = context.name_df\n name_today = name_df[name_df.date==today]\n #print(name_today)\n for instrument in equities:\n name_instrument = name_today[name_today.instrument==instrument]['name'].values[0]\n # 如果股票状态变为了st 则卖出\n if 'ST' in name_instrument or '退' in name_instrument:\n # 指定一个limit_price,此时会以开盘价成交,这是由于初始化函数中改写了下单价格\n context.order_target(context.symbol(instrument), 0, limit_price=1.0)\n st_stock_list.append(instrument)\n cash_for_sell -= positions[instrument]\n if st_stock_list!=[]:\n print(today,'持仓出现st股/退市股',st_stock_list,'进行卖出处理')\n \n # 2. 生成卖出订单:hold_days天之后才开始卖出;对持仓的股票,按机器学习算法预测的排序末位淘汰\n if not is_staging and cash_for_sell > 0:\n instruments = list(reversed(list(ranker_prediction.instrument[ranker_prediction.instrument.apply(\n lambda x: x in equities)])))\n price_limit_status = context.price_limit_status\n status_today = price_limit_status[price_limit_status.date==today]\n for instrument in instruments:\n # 如果是st股票已经卖过了,就跳过\n if instrument in st_stock_list:\n continue\n # 如果涨停就跳过股票\n #status_instrument = status_today[status_today.instrument==instrument]['price_limit_status'].values[0]\n #if status_instrument>2:\n # continue\n context.order_target(context.symbol(instrument),0)\n cash_for_sell -= positions[instrument]\n if cash_for_sell <= 0:\n break\n\n # 3. 生成买入订单:按机器学习算法预测的排序,买入前面的stock_count只股票\n buy_cash_weights = context.stock_weights\n buy_instruments = list(ranker_prediction.instrument[:len(buy_cash_weights)])\n pred_label = list(ranker_prediction.pred_label[:len(buy_cash_weights)])\n print(today,'今日选中标的为:') \n print(pred_label)\n print(buy_instruments)\n print(pred_label)\n max_cash_per_instrument = context.portfolio.portfolio_value * context.max_cash_per_instrument\n for i, instrument in enumerate(buy_instruments):\n cash = cash_for_buy * buy_cash_weights[i]\n if cash > max_cash_per_instrument - positions.get(instrument, 0):\n # 确保股票持仓量不会超过每次股票最大的占用资金量\n cash = max_cash_per_instrument - positions.get(instrument, 0)\n if cash > 0:\n context.order_value(context.symbol(instrument), cash)\n\n\n","type":"Literal","bound_global_parameter":null},{"name":"prepare","value":"# 回测引擎:准备数据,只执行一次\ndef bigquant_run(context):\n # 获取股票名称 用于过滤st和退市股\n context.name_df = DataSource('instruments_CN_STOCK_A').read()\n # 获取涨跌停状态\n context.price_limit_status = DataSource('stock_status_CN_STOCK_A').read(fields=['price_limit_status'])\n","type":"Literal","bound_global_parameter":null},{"name":"before_trading_start","value":"from zipline.finance.order import Order\n\n#插入定单\ndef insert_order(context,date,instr,amount):\n order = Order(\n dt = pd.to_datetime(date+\" 09:30:00\"),\n asset=context.symbol(instr),\n amount=-amount,\n stop=None,\n limit=None,\n price_field='open')\n\n try:\n context.blotter.open_orders[order.asset].append(order)\n except Exception:\n context.blotter.open_orders[order.asset] = [order]\n\n context.blotter.orders[order.id] = order\n context.blotter.new_orders.append(order) \n\n#个股风控判断\ndef stock_risk(context, data):\n today=data.current_dt.strftime('%Y-%m-%d')\n #====卖出股票\n stock_hold_now = {e.symbol:p.amount for e, p in context.perf_tracker.position_tracker.positions.items()}\n stocks = stock_hold_now.keys()\n\n for instr,amount in stock_hold_now.items():\n nowdata = context.stock_risk_data[(context.stock_risk_data.instrument==instr)&(context.stock_risk_data.date==today)]\n #触发个股风控,早盘卖出\n if nowdata.risk.iloc[0] == 1 and amount>0:\n print(today,'个股风控卖出:',instr) \n insert_order(context,today,instr,amount)\n\n\ndef bigquant_run(context, data):\n df_price_limit_status=context.price_limit_status.set_index('date')\n today=data.current_dt.strftime('%Y-%m-%d')\n \n now_bm = context.bm_df[context.bm_df.date==today]\n #个股风控\n #stock_risk(context,data)\n context.bm_risk = 0\n #大盘风控判断\n '''\n if(now_bm.bm_ret.iloc[0]<-0.01):\n context.bm_risk = 1\n # 得到当前未完成订单\n for orders in get_open_orders().values():\n # 循环,撤销订单\n for _order in orders:\n ins=str(_order.sid.symbol)\n if data.can_trade(_order.sid) and _order.amount>0:\n #大盘风控取消买单\n cancel_order(_order)\n print(today,'大盘风控取消买单',ins) \n if data.can_trade(_order.sid) and _order.amount<0:#卖单由后续统一处理,先取消\n #大盘风控取消卖单\n cancel_order(_order)\n print(today,'大盘风控取消卖单',ins) \n \n #====卖出股票\n stock_hold_now = {e.symbol:p.amount for e, p in context.perf_tracker.position_tracker.positions.items()}\n print(today,\"=======风控卖出所有的股票:\",stock_hold_now)\n for instr,amount in stock_hold_now.items():\n #插入定单\n insert_order(context,today,instr,amount)\n '''\n \n \n # 得到当前未完成订单\n for orders in get_open_orders().values():\n # 循环,撤销订单\n for _order in orders:\n ins=str(_order.sid.symbol)\n if data.can_trade(_order.sid):\n #判断一下如果当日涨停,则取消卖单\n if df_price_limit_status[df_price_limit_status.instrument==ins].price_limit_status.loc[today]>2 and _order.amount<0:\n cancel_order(_order)\n print(today,'取消昨日尾盘涨停的卖单',ins) \n \n ","type":"Literal","bound_global_parameter":null},{"name":"volume_limit","value":0.025,"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":1000000,"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":"","type":"Literal","bound_global_parameter":null}],"input_ports":[{"name":"instruments","node_id":"-614"},{"name":"options_data","node_id":"-614"},{"name":"history_ds","node_id":"-614"},{"name":"benchmark_ds","node_id":"-614"},{"name":"trading_calendar","node_id":"-614"}],"output_ports":[{"name":"raw_perf","node_id":"-614"}],"cacheable":false,"seq_num":13,"comment":"","comment_collapsed":true},{"node_id":"-635","module_id":"BigQuantSpace.sort.sort-v4","parameters":[{"name":"sort_by","value":"pred_label","type":"Literal","bound_global_parameter":null},{"name":"group_by","value":"date","type":"Literal","bound_global_parameter":null},{"name":"keep_columns","value":"--","type":"Literal","bound_global_parameter":null},{"name":"ascending","value":"False","type":"Literal","bound_global_parameter":null}],"input_ports":[{"name":"input_ds","node_id":"-635"},{"name":"sort_by_ds","node_id":"-635"}],"output_ports":[{"name":"sorted_data","node_id":"-635"}],"cacheable":true,"seq_num":14,"comment":"","comment_collapsed":true},{"node_id":"-2640","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%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":"-2640"}],"output_ports":[{"name":"data","node_id":"-2640"},{"name":"left_data","node_id":"-2640"}],"cacheable":true,"seq_num":15,"comment":"","comment_collapsed":true},{"node_id":"-2650","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%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":"-2650"}],"output_ports":[{"name":"data","node_id":"-2650"},{"name":"left_data","node_id":"-2650"}],"cacheable":true,"seq_num":16,"comment":"","comment_collapsed":true},{"node_id":"-1451","module_id":"BigQuantSpace.cached.cached-v3","parameters":[{"name":"run","value":"def bigquant_run(input_1, input_2, input_3):\n # 示例代码如下。在这里编写您的代码\n data = pd.read_pickle('/home/bigquant/work/userlib/model_rdr.csv')\n model_ds = DataSource.write_pickle(data.iloc[0].values[0])\n print(model_ds)\n return Outputs(data_1=model_ds, data_2=None, data_3=None, data_4=None)","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":"{}","type":"Literal","bound_global_parameter":null},{"name":"output_ports","value":"","type":"Literal","bound_global_parameter":null}],"input_ports":[{"name":"input_1","node_id":"-1451"},{"name":"input_2","node_id":"-1451"},{"name":"input_3","node_id":"-1451"}],"output_ports":[{"name":"data_1","node_id":"-1451"},{"name":"data_2","node_id":"-1451"},{"name":"data_3","node_id":"-1451"}],"cacheable":true,"seq_num":17,"comment":"","comment_collapsed":true}],"node_layout":"<node_postions><node_position Node='-513' Position='10,23,200,200'/><node_position Node='-521' Position='337,26,200,200'/><node_position Node='-526' Position='129,157,200,200'/><node_position Node='-532' Position='642,27,200,200'/><node_position Node='-541' Position='579,153,200,200'/><node_position Node='-548' Position='134,243,200,200'/><node_position Node='-557' Position='581,264,200,200'/><node_position Node='-565' Position='-161,159,200,200'/><node_position Node='-576' Position='-5,330,200,200'/><node_position Node='-590' Position='40,518,200,200'/><node_position Node='-593' Position='500,524,200,200'/><node_position Node='-600' Position='124,709,200,200'/><node_position Node='-614' Position='545,923,200,200'/><node_position Node='-635' Position='480,777,200,200'/><node_position Node='-2640' Position='12,446,200,200'/><node_position Node='-2650' Position='530,411,200,200'/><node_position Node='-1451' Position='-19,593,200,200'/></node_postions>"},"nodes_readonly":false,"studio_version":"v2"}
    In [8]:
    # 本代码由可视化策略环境自动生成 2022年6月2日 15:51
    # 本代码单元只能在可视化模式下编辑。您也可以拷贝代码,粘贴到新建的代码单元或者策略,然后修改。
    
    
    def m17_run_bigquant_run(input_1, input_2, input_3):
        # 示例代码如下。在这里编写您的代码
        data = pd.read_pickle('/home/bigquant/work/userlib/model_rdr.csv')
        model_ds = DataSource.write_pickle(data.iloc[0].values[0])
        print(model_ds)
        return Outputs(data_1=model_ds, data_2=None, data_3=None, data_4=None)
    # 后处理函数,可选。输入是主函数的输出,可以在这里对数据做处理,或者返回更友好的outputs数据格式。此函数输出不会被缓存。
    def m17_post_run_bigquant_run(outputs):
        return outputs
    
    # 回测引擎:初始化函数,只执行一次
    def m13_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 = 3
        # 每只的股票的权重,如下的权重分配会使得靠前的股票分配多一点的资金,[0.339160, 0.213986, 0.169580, ..]
        context.stock_weights = T.norm([1 / math.log(i + 2) for i in range(0, stock_count)])
        # 设置每只股票占用的最大资金比例
        context.max_cash_per_instrument = 0.2
        context.hold_days = 1
        
        from zipline.finance.slippage import SlippageModel
        class FixedPriceSlippage(SlippageModel):
            def process_order(self, data, order, bar_volume=0, trigger_check_price=0):
                if order.limit is None:
                    price_field = self._price_field_buy if order.amount > 0 else self._price_field_sell
                    price = data.current(order.asset, price_field)
                else:
                    price = data.current(order.asset, self._price_field_buy)
                # 返回希望成交的价格和数量
                return (price, order.amount)
        # 设置price_field,默认是开盘买入,收盘卖出
        context.fix_slippage = FixedPriceSlippage(price_field_buy='open', price_field_sell='close')
        context.set_slippage(us_equities=context.fix_slippage)
        
        #大盘数据获取
        bm_df = DataSource('bar1d_index_CN_STOCK_A').read(instruments=['000001.HIX'])
        bm_df["bm_ret"] = bm_df["close"]/bm_df["close"].shift(10)-1
        bm_df["bm_ret"] = bm_df["bm_ret"].shift(1) #取昨日的收益情况
        context.bm_df = bm_df[['date','bm_ret']]
        
        #个股风控计算
        import pandas as pd
        start_date = context.ranker_prediction.date.iloc[0]
        start_date = pd.to_datetime(start_date)-pd.Timedelta(days=30)
        end_date = context.ranker_prediction.date.iloc[-1]
        stocks = context.ranker_prediction.instrument.to_list()
        data = DataSource("bar1d_CN_STOCK_A").read(instruments=stocks,start_date=start_date.strftime("%Y-%m-%d"),end_date=end_date)
        #计算个股风控,小于20日均线
        def cal_risk(df):
            df = df.sort_values("date")
            df["ma"] = df.close.rolling(20).mean()
            df["risk"] = np.where(df.close.shift(1)<df.ma.shift(1),1,0)
            return df
        context.stock_risk_data = data.groupby("instrument").apply(cal_risk).reset_index(drop=True)
    
    
    # 回测引擎:每日数据处理函数,每天执行一次
    def m13_handle_data_bigquant_run(context, data):
        # 按日期过滤得到今日的预测数据
        ranker_prediction = context.ranker_prediction[
            context.ranker_prediction.date == data.current_dt.strftime('%Y-%m-%d')]
        today = data.current_dt.strftime('%Y-%m-%d')
        
        # 1. 资金分配
        # 平均持仓时间是hold_days,每日都将买入股票,每日预期使用 1/hold_days 的资金
        # 实际操作中,会存在一定的买入误差,所以在前hold_days天,等量使用资金;之后,尽量使用剩余资金(这里设置最多用等量的1.5倍)
        is_staging = context.trading_day_index < context.hold_days # 是否在建仓期间(前 hold_days 天)
        cash_avg = context.portfolio.portfolio_value / context.hold_days
        cash_for_buy = min(context.portfolio.cash, (1 if is_staging else 1.5) * cash_avg)
        cash_for_sell = cash_avg - (context.portfolio.cash - cash_for_buy)
        positions = {e.symbol: p.amount * p.last_sale_price
                     for e, p in context.perf_tracker.position_tracker.positions.items()}
        equities = {e.symbol: e for e, p in context.portfolio.positions.items()}
        '''
        # 2. 生成卖出订单:hold_days天之后才开始卖出;对持仓的股票,按StockRanker预测的排序末位淘汰
        if not is_staging and cash_for_sell > 0:
            equities = {e.symbol: e for e, p in context.perf_tracker.position_tracker.positions.items()}
            instruments = list(reversed(list(ranker_prediction.instrument[ranker_prediction.instrument.apply(
                    lambda x: x in equities and not context.has_unfinished_sell_order(equities[x]))])))
            # print('rank order for sell %s' % instruments)
            for instrument in instruments:
                context.order_target(context.symbol(instrument), 0)
                cash_for_sell -= positions[instrument]
                if cash_for_sell <= 0:
                    break
    
        # 3. 生成买入订单:按StockRanker预测的排序,买入前面的stock_count只股票
        buy_cash_weights = context.stock_weights
        buy_instruments = list(ranker_prediction.instrument[:len(buy_cash_weights)])
        max_cash_per_instrument = context.portfolio.portfolio_value * context.max_cash_per_instrument
        for i, instrument in enumerate(buy_instruments):
            cash = cash_for_buy * buy_cash_weights[i]
            if cash > max_cash_per_instrument - positions.get(instrument, 0):
                # 确保股票持仓量不会超过每次股票最大的占用资金量
                cash = max_cash_per_instrument - positions.get(instrument, 0)
            if cash > 0:
                context.order_value(context.symbol(instrument), cash)
        '''
        
        # 记录持仓中st的股票
        st_stock_list = []
        name_df = context.name_df
        name_today = name_df[name_df.date==today]
        #print(name_today)
        for instrument in equities:
            name_instrument = name_today[name_today.instrument==instrument]['name'].values[0]
            # 如果股票状态变为了st 则卖出
            if 'ST' in name_instrument or '退' in name_instrument:
                # 指定一个limit_price,此时会以开盘价成交,这是由于初始化函数中改写了下单价格
                context.order_target(context.symbol(instrument), 0, limit_price=1.0)
                st_stock_list.append(instrument)
                cash_for_sell -= positions[instrument]
        if st_stock_list!=[]:
            print(today,'持仓出现st股/退市股',st_stock_list,'进行卖出处理')
     
        # 2. 生成卖出订单:hold_days天之后才开始卖出;对持仓的股票,按机器学习算法预测的排序末位淘汰
        if not is_staging and cash_for_sell > 0:
            instruments = list(reversed(list(ranker_prediction.instrument[ranker_prediction.instrument.apply(
                lambda x: x in equities)])))
            price_limit_status = context.price_limit_status
            status_today = price_limit_status[price_limit_status.date==today]
            for instrument in instruments:
                # 如果是st股票已经卖过了,就跳过
                if instrument in st_stock_list:
                    continue
                # 如果涨停就跳过股票
                #status_instrument = status_today[status_today.instrument==instrument]['price_limit_status'].values[0]
                #if status_instrument>2:
                #    continue
                context.order_target(context.symbol(instrument),0)
                cash_for_sell -= positions[instrument]
                if cash_for_sell <= 0:
                    break
    
        # 3. 生成买入订单:按机器学习算法预测的排序,买入前面的stock_count只股票
        buy_cash_weights = context.stock_weights
        buy_instruments = list(ranker_prediction.instrument[:len(buy_cash_weights)])
        pred_label = list(ranker_prediction.pred_label[:len(buy_cash_weights)])
        print(today,'今日选中标的为:')   
        print(pred_label)
        print(buy_instruments)
        print(pred_label)
        max_cash_per_instrument = context.portfolio.portfolio_value * context.max_cash_per_instrument
        for i, instrument in enumerate(buy_instruments):
            cash = cash_for_buy * buy_cash_weights[i]
            if cash > max_cash_per_instrument - positions.get(instrument, 0):
                # 确保股票持仓量不会超过每次股票最大的占用资金量
                cash = max_cash_per_instrument - positions.get(instrument, 0)
            if cash > 0:
                context.order_value(context.symbol(instrument), cash)
    
    
    
    # 回测引擎:准备数据,只执行一次
    def m13_prepare_bigquant_run(context):
        # 获取股票名称 用于过滤st和退市股
        context.name_df = DataSource('instruments_CN_STOCK_A').read()
        # 获取涨跌停状态
        context.price_limit_status = DataSource('stock_status_CN_STOCK_A').read(fields=['price_limit_status'])
    
    from zipline.finance.order import Order
    
    #插入定单
    def insert_order(context,date,instr,amount):
        order = Order(
            dt = pd.to_datetime(date+" 09:30:00"),
            asset=context.symbol(instr),
            amount=-amount,
            stop=None,
            limit=None,
            price_field='open')
    
        try:
            context.blotter.open_orders[order.asset].append(order)
        except Exception:
            context.blotter.open_orders[order.asset] = [order]
    
        context.blotter.orders[order.id] = order
        context.blotter.new_orders.append(order) 
    
    #个股风控判断
    def stock_risk(context, data):
        today=data.current_dt.strftime('%Y-%m-%d')
        #====卖出股票
        stock_hold_now = {e.symbol:p.amount for e, p in context.perf_tracker.position_tracker.positions.items()}
        stocks = stock_hold_now.keys()
    
        for instr,amount in stock_hold_now.items():
            nowdata = context.stock_risk_data[(context.stock_risk_data.instrument==instr)&(context.stock_risk_data.date==today)]
            #触发个股风控,早盘卖出
            if nowdata.risk.iloc[0] == 1 and amount>0:
                print(today,'个股风控卖出:',instr) 
                insert_order(context,today,instr,amount)
    
    
    def m13_before_trading_start_bigquant_run(context, data):
        df_price_limit_status=context.price_limit_status.set_index('date')
        today=data.current_dt.strftime('%Y-%m-%d')
        
        now_bm = context.bm_df[context.bm_df.date==today]
        #个股风控
        #stock_risk(context,data)
        context.bm_risk = 0
        #大盘风控判断
        '''
        if(now_bm.bm_ret.iloc[0]<-0.01):
            context.bm_risk = 1
            # 得到当前未完成订单
            for orders in get_open_orders().values():
                # 循环,撤销订单
                for _order in orders:
                    ins=str(_order.sid.symbol)
                    if data.can_trade(_order.sid) and _order.amount>0:
                        #大盘风控取消买单
                        cancel_order(_order)
                        print(today,'大盘风控取消买单',ins) 
                    if data.can_trade(_order.sid) and _order.amount<0:#卖单由后续统一处理,先取消
                        #大盘风控取消卖单
                        cancel_order(_order)
                        print(today,'大盘风控取消卖单',ins) 
                        
            #====卖出股票
            stock_hold_now = {e.symbol:p.amount for e, p in context.perf_tracker.position_tracker.positions.items()}
            print(today,"=======风控卖出所有的股票:",stock_hold_now)
            for instr,amount in stock_hold_now.items():
                #插入定单
                insert_order(context,today,instr,amount)
        '''
        
        
        # 得到当前未完成订单
        for orders in get_open_orders().values():
            # 循环,撤销订单
            for _order in orders:
                ins=str(_order.sid.symbol)
                if data.can_trade(_order.sid):
                    #判断一下如果当日涨停,则取消卖单
                    if  df_price_limit_status[df_price_limit_status.instrument==ins].price_limit_status.loc[today]>2 and _order.amount<0:
                        cancel_order(_order)
                        print(today,'取消昨日尾盘涨停的卖单',ins)    
                        
         
    
    m1 = M.instruments.v2(
        start_date='2020-01-01',
        end_date='2020-12-31',
        market='CN_STOCK_A',
        instrument_list='',
        max_count=0
    )
    
    m8 = M.advanced_auto_labeler.v2(
        instruments=m1.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%和99%分位的值做clip
    clip(label, all_quantile(label, 0.01), all_quantile(label, 0.99))
    
    # 将分数映射到分类,这里使用20个分类
    all_wbins(label, 2)
    # 过滤掉一字涨停的情况 (设置label为NaN,在后续处理和训练中会忽略NaN的label)
    #where(shift(high, -1) == shift(low, -1), NaN, label)
    
    shift(price_limit_status,-1)>2""",
        start_date='',
        end_date='',
        benchmark='000300.SHA',
        drop_na_label=True,
        cast_label_int=False,
        user_functions={},
        m_cached=False
    )
    
    m2 = M.input_features.v1(
        features="""# #号开始的表示注释
    # 多个特征,每行一个,可以包含基础特征和衍生特征
    return_5
    return_10
    return_20
    avg_amount_0/avg_amount_5
    avg_amount_5/avg_amount_20
    rank_avg_amount_0/rank_avg_amount_5
    rank_avg_amount_5/rank_avg_amount_10
    rank_return_0
    rank_return_5
    rank_return_10
    rank_return_0/rank_return_5
    rank_return_5/rank_return_10
    pe_ttm_0"""
    )
    
    m3 = M.general_feature_extractor.v7(
        instruments=m1.data,
        features=m2.data,
        start_date='',
        end_date='',
        before_start_days=90
    )
    
    m6 = M.derived_feature_extractor.v3(
        input_data=m3.data,
        features=m2.data,
        date_col='date',
        instrument_col='instrument',
        drop_na=False,
        remove_extra_columns=False,
        user_functions={}
    )
    
    m9 = M.join.v3(
        data1=m8.data,
        data2=m6.data,
        on='date,instrument',
        how='inner',
        sort=False
    )
    
    m15 = M.chinaa_stock_filter.v1(
        input_data=m9.data,
        index_constituent_cond=['全部'],
        board_cond=['上证主板', '深证主板'],
        industry_cond=['全部'],
        st_cond=['正常'],
        delist_cond=['非退市'],
        output_left_data=False
    )
    
    m11 = M.dropnan.v1(
        input_data=m15.data
    )
    
    m4 = M.instruments.v2(
        start_date='2022-01-01',
        end_date='2022-02-01',
        market='CN_STOCK_A',
        instrument_list='',
        max_count=0
    )
    
    m5 = M.general_feature_extractor.v7(
        instruments=m4.data,
        features=m2.data,
        start_date='',
        end_date='',
        before_start_days=90
    )
    
    m7 = 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={}
    )
    
    m16 = M.chinaa_stock_filter.v1(
        input_data=m7.data,
        index_constituent_cond=['全部'],
        board_cond=['上证主板', '深证主板'],
        industry_cond=['全部'],
        st_cond=['正常'],
        delist_cond=['非退市'],
        output_left_data=False
    )
    
    m10 = M.dropnan.v1(
        input_data=m16.data
    )
    
    m17 = M.cached.v3(
        run=m17_run_bigquant_run,
        post_run=m17_post_run_bigquant_run,
        input_ports='',
        params='{}',
        output_ports=''
    )
    
    m12 = M.random_forest_regressor.v1(
        training_ds=m17.data_1,
        predict_ds=m10.data,
        iterations=10,
        feature_fraction=1,
        max_depth=30,
        min_samples_per_leaf=200,
        key_cols='date,instrument',
        workers=1,
        random_state=0,
        other_train_parameters={"random_state":0}
    )
    
    m14 = M.sort.v4(
        input_ds=m12.predictions,
        sort_by='pred_label',
        group_by='date',
        keep_columns='--',
        ascending=False
    )
    
    m13 = M.trade.v4(
        instruments=m4.data,
        options_data=m14.sorted_data,
        start_date='',
        end_date='',
        initialize=m13_initialize_bigquant_run,
        handle_data=m13_handle_data_bigquant_run,
        prepare=m13_prepare_bigquant_run,
        before_trading_start=m13_before_trading_start_bigquant_run,
        volume_limit=0.025,
        order_price_field_buy='open',
        order_price_field_sell='close',
        capital_base=1000000,
        auto_cancel_non_tradable_orders=True,
        data_frequency='daily',
        price_type='真实价格',
        product_type='股票',
        plot_charts=True,
        backtest_only=False,
        benchmark=''
    )
    
    DataSource(9ca1aed308fd4d0fa56037ca5c6fbf21T)
    
    ---------------------------------------------------------------------------
    Exception                                 Traceback (most recent call last)
    <ipython-input-8-30361800f093> in <module>
         78 )
         79 
    ---> 80 m12 = M.random_forest_regressor.v1(
         81     training_ds=m17.data_1,
         82     predict_ds=m10.data,
    
    Exception: 请输入参数features
    In [2]:
    # import pandas as pd
    # print(m12)
    # pd.DataFrame([m12.output_model]).to_pickle('/home/bigquant/work/userlib/model_tree.csv')
    # m12.feature_gains
    print(1)
    
    1
    
    In [3]:
    m12.predictions.read()
    
    Out[3]:
    pred_label date instrument
    0 0.015236 2021-10-08 000001.SZA
    1 0.023202 2021-10-11 000001.SZA
    2 0.016433 2021-10-12 000001.SZA
    3 0.015236 2021-10-13 000001.SZA
    4 0.010896 2021-10-14 000001.SZA
    ... ... ... ...
    359892 0.010896 2022-01-24 605599.SHA
    359893 0.028886 2022-01-25 605599.SHA
    359894 0.015415 2022-01-26 605599.SHA
    359895 0.010896 2022-01-27 605599.SHA
    359896 0.015236 2022-01-28 605599.SHA

    237012 rows × 3 columns