使用沪深300数据进行可视化策略

策略分享
标签: #<Tag:0x00007ff195ee9970>

(zxm) #1
克隆策略
In [30]:
DataSource("index_constituent_CN_STOCK_A").read().head()
Out[30]:
date in_csi100 in_csi300 in_csi500 in_csi800 in_sse180 in_sse50 in_szse100 instrument
0 2005-01-04 0 0 0 0 1 1 0 600000.SHA
1 2005-01-04 0 0 0 0 1 0 0 600333.SHA
2 2005-01-04 0 0 0 0 1 1 0 600002.SHA
3 2005-01-04 0 0 0 0 1 1 0 600004.SHA
4 2005-01-04 0 0 0 0 1 1 0 600005.SHA

    {"Description":"实验创建于2017/8/26","Summary":"","Graph":{"EdgesInternal":[{"DestinationInputPortId":"287d2cb0-f53c-4101-bdf8-104b137c8601-53:data1","SourceOutputPortId":"287d2cb0-f53c-4101-bdf8-104b137c8601-15:data"},{"DestinationInputPortId":"-215:features","SourceOutputPortId":"287d2cb0-f53c-4101-bdf8-104b137c8601-24:data"},{"DestinationInputPortId":"-222:features","SourceOutputPortId":"287d2cb0-f53c-4101-bdf8-104b137c8601-24:data"},{"DestinationInputPortId":"-231:features","SourceOutputPortId":"287d2cb0-f53c-4101-bdf8-104b137c8601-24:data"},{"DestinationInputPortId":"-238:features","SourceOutputPortId":"287d2cb0-f53c-4101-bdf8-104b137c8601-24:data"},{"DestinationInputPortId":"-654:features","SourceOutputPortId":"287d2cb0-f53c-4101-bdf8-104b137c8601-24:data"},{"DestinationInputPortId":"-668:input_data","SourceOutputPortId":"287d2cb0-f53c-4101-bdf8-104b137c8601-53:data"},{"DestinationInputPortId":"-250:options_data","SourceOutputPortId":"287d2cb0-f53c-4101-bdf8-104b137c8601-60:predictions"},{"DestinationInputPortId":"-231:instruments","SourceOutputPortId":"287d2cb0-f53c-4101-bdf8-104b137c8601-62:data"},{"DestinationInputPortId":"-250:instruments","SourceOutputPortId":"287d2cb0-f53c-4101-bdf8-104b137c8601-62:data"},{"DestinationInputPortId":"-222:input_data","SourceOutputPortId":"-215:data"},{"DestinationInputPortId":"287d2cb0-f53c-4101-bdf8-104b137c8601-53:data2","SourceOutputPortId":"-222:data"},{"DestinationInputPortId":"-238:input_data","SourceOutputPortId":"-231:data"},{"DestinationInputPortId":"-672:input_data","SourceOutputPortId":"-238:data"},{"DestinationInputPortId":"287d2cb0-f53c-4101-bdf8-104b137c8601-60:model","SourceOutputPortId":"-654:model"},{"DestinationInputPortId":"-654:training_ds","SourceOutputPortId":"-668:data"},{"DestinationInputPortId":"287d2cb0-f53c-4101-bdf8-104b137c8601-60:data","SourceOutputPortId":"-672:data"},{"DestinationInputPortId":"287d2cb0-f53c-4101-bdf8-104b137c8601-15:instruments","SourceOutputPortId":"-130:data_1"},{"DestinationInputPortId":"-215:instruments","SourceOutputPortId":"-130:data_1"}],"ModuleNodes":[{"Id":"287d2cb0-f53c-4101-bdf8-104b137c8601-15","ModuleId":"BigQuantSpace.advanced_auto_labeler.advanced_auto_labeler-v2","ModuleParameters":[{"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# 计算收益:5日收盘价(作为卖出价格)除以明日开盘价(作为买入价格)\nshift(close, -5) / shift(open, -1)\n\n# 极值处理:用1%和99%分位的值做clip\nclip(label, all_quantile(label, 0.01), all_quantile(label, 0.99))\n\n# 将分数映射到分类,这里使用20个分类\nall_wbins(label, 20)\n\n# 过滤掉一字涨停的情况 (设置label为NaN,在后续处理和训练中会忽略NaN的label)\nwhere(shift(high, -1) == shift(low, -1), NaN, label)\n","ValueType":"Literal","LinkedGlobalParameter":null},{"Name":"start_date","Value":"","ValueType":"Literal","LinkedGlobalParameter":null},{"Name":"end_date","Value":"","ValueType":"Literal","LinkedGlobalParameter":null},{"Name":"benchmark","Value":"000300.SHA","ValueType":"Literal","LinkedGlobalParameter":null},{"Name":"drop_na_label","Value":"True","ValueType":"Literal","LinkedGlobalParameter":null},{"Name":"cast_label_int","Value":"True","ValueType":"Literal","LinkedGlobalParameter":null},{"Name":"user_functions","Value":"","ValueType":"Literal","LinkedGlobalParameter":null}],"InputPortsInternal":[{"DataSourceId":null,"TrainedModelId":null,"TransformModuleId":null,"Name":"instruments","NodeId":"287d2cb0-f53c-4101-bdf8-104b137c8601-15"}],"OutputPortsInternal":[{"Name":"data","NodeId":"287d2cb0-f53c-4101-bdf8-104b137c8601-15","OutputType":null}],"UsePreviousResults":true,"moduleIdForCode":2,"Comment":"","CommentCollapsed":true},{"Id":"287d2cb0-f53c-4101-bdf8-104b137c8601-24","ModuleId":"BigQuantSpace.input_features.input_features-v1","ModuleParameters":[{"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\n","ValueType":"Literal","LinkedGlobalParameter":null}],"InputPortsInternal":[{"DataSourceId":null,"TrainedModelId":null,"TransformModuleId":null,"Name":"features_ds","NodeId":"287d2cb0-f53c-4101-bdf8-104b137c8601-24"}],"OutputPortsInternal":[{"Name":"data","NodeId":"287d2cb0-f53c-4101-bdf8-104b137c8601-24","OutputType":null}],"UsePreviousResults":true,"moduleIdForCode":3,"Comment":"","CommentCollapsed":true},{"Id":"287d2cb0-f53c-4101-bdf8-104b137c8601-53","ModuleId":"BigQuantSpace.join.join-v3","ModuleParameters":[{"Name":"on","Value":"date,instrument","ValueType":"Literal","LinkedGlobalParameter":null},{"Name":"how","Value":"inner","ValueType":"Literal","LinkedGlobalParameter":null},{"Name":"sort","Value":"False","ValueType":"Literal","LinkedGlobalParameter":null}],"InputPortsInternal":[{"DataSourceId":null,"TrainedModelId":null,"TransformModuleId":null,"Name":"data1","NodeId":"287d2cb0-f53c-4101-bdf8-104b137c8601-53"},{"DataSourceId":null,"TrainedModelId":null,"TransformModuleId":null,"Name":"data2","NodeId":"287d2cb0-f53c-4101-bdf8-104b137c8601-53"}],"OutputPortsInternal":[{"Name":"data","NodeId":"287d2cb0-f53c-4101-bdf8-104b137c8601-53","OutputType":null}],"UsePreviousResults":true,"moduleIdForCode":7,"Comment":"","CommentCollapsed":true},{"Id":"287d2cb0-f53c-4101-bdf8-104b137c8601-60","ModuleId":"BigQuantSpace.stock_ranker_predict.stock_ranker_predict-v5","ModuleParameters":[{"Name":"m_lazy_run","Value":"False","ValueType":"Literal","LinkedGlobalParameter":null}],"InputPortsInternal":[{"DataSourceId":null,"TrainedModelId":null,"TransformModuleId":null,"Name":"model","NodeId":"287d2cb0-f53c-4101-bdf8-104b137c8601-60"},{"DataSourceId":null,"TrainedModelId":null,"TransformModuleId":null,"Name":"data","NodeId":"287d2cb0-f53c-4101-bdf8-104b137c8601-60"}],"OutputPortsInternal":[{"Name":"predictions","NodeId":"287d2cb0-f53c-4101-bdf8-104b137c8601-60","OutputType":null},{"Name":"m_lazy_run","NodeId":"287d2cb0-f53c-4101-bdf8-104b137c8601-60","OutputType":null}],"UsePreviousResults":true,"moduleIdForCode":8,"Comment":"","CommentCollapsed":true},{"Id":"287d2cb0-f53c-4101-bdf8-104b137c8601-62","ModuleId":"BigQuantSpace.instruments.instruments-v2","ModuleParameters":[{"Name":"start_date","Value":"2015-01-01","ValueType":"Literal","LinkedGlobalParameter":"交易日期"},{"Name":"end_date","Value":"2017-01-01","ValueType":"Literal","LinkedGlobalParameter":"交易日期"},{"Name":"market","Value":"CN_STOCK_A","ValueType":"Literal","LinkedGlobalParameter":null},{"Name":"instrument_list","Value":"","ValueType":"Literal","LinkedGlobalParameter":null},{"Name":"max_count","Value":"0","ValueType":"Literal","LinkedGlobalParameter":null}],"InputPortsInternal":[{"DataSourceId":null,"TrainedModelId":null,"TransformModuleId":null,"Name":"rolling_conf","NodeId":"287d2cb0-f53c-4101-bdf8-104b137c8601-62"}],"OutputPortsInternal":[{"Name":"data","NodeId":"287d2cb0-f53c-4101-bdf8-104b137c8601-62","OutputType":null}],"UsePreviousResults":true,"moduleIdForCode":9,"Comment":"预测数据,用于回测和模拟","CommentCollapsed":false},{"Id":"-215","ModuleId":"BigQuantSpace.general_feature_extractor.general_feature_extractor-v7","ModuleParameters":[{"Name":"start_date","Value":"","ValueType":"Literal","LinkedGlobalParameter":null},{"Name":"end_date","Value":"","ValueType":"Literal","LinkedGlobalParameter":null},{"Name":"before_start_days","Value":90,"ValueType":"Literal","LinkedGlobalParameter":null}],"InputPortsInternal":[{"DataSourceId":null,"TrainedModelId":null,"TransformModuleId":null,"Name":"instruments","NodeId":"-215"},{"DataSourceId":null,"TrainedModelId":null,"TransformModuleId":null,"Name":"features","NodeId":"-215"}],"OutputPortsInternal":[{"Name":"data","NodeId":"-215","OutputType":null}],"UsePreviousResults":true,"moduleIdForCode":15,"Comment":"","CommentCollapsed":true},{"Id":"-222","ModuleId":"BigQuantSpace.derived_feature_extractor.derived_feature_extractor-v3","ModuleParameters":[{"Name":"date_col","Value":"date","ValueType":"Literal","LinkedGlobalParameter":null},{"Name":"instrument_col","Value":"instrument","ValueType":"Literal","LinkedGlobalParameter":null},{"Name":"drop_na","Value":"False","ValueType":"Literal","LinkedGlobalParameter":null},{"Name":"remove_extra_columns","Value":"False","ValueType":"Literal","LinkedGlobalParameter":null},{"Name":"user_functions","Value":"","ValueType":"Literal","LinkedGlobalParameter":null}],"InputPortsInternal":[{"DataSourceId":null,"TrainedModelId":null,"TransformModuleId":null,"Name":"input_data","NodeId":"-222"},{"DataSourceId":null,"TrainedModelId":null,"TransformModuleId":null,"Name":"features","NodeId":"-222"}],"OutputPortsInternal":[{"Name":"data","NodeId":"-222","OutputType":null}],"UsePreviousResults":true,"moduleIdForCode":16,"Comment":"","CommentCollapsed":true},{"Id":"-231","ModuleId":"BigQuantSpace.general_feature_extractor.general_feature_extractor-v7","ModuleParameters":[{"Name":"start_date","Value":"","ValueType":"Literal","LinkedGlobalParameter":null},{"Name":"end_date","Value":"","ValueType":"Literal","LinkedGlobalParameter":null},{"Name":"before_start_days","Value":90,"ValueType":"Literal","LinkedGlobalParameter":null}],"InputPortsInternal":[{"DataSourceId":null,"TrainedModelId":null,"TransformModuleId":null,"Name":"instruments","NodeId":"-231"},{"DataSourceId":null,"TrainedModelId":null,"TransformModuleId":null,"Name":"features","NodeId":"-231"}],"OutputPortsInternal":[{"Name":"data","NodeId":"-231","OutputType":null}],"UsePreviousResults":true,"moduleIdForCode":17,"Comment":"","CommentCollapsed":true},{"Id":"-238","ModuleId":"BigQuantSpace.derived_feature_extractor.derived_feature_extractor-v3","ModuleParameters":[{"Name":"date_col","Value":"date","ValueType":"Literal","LinkedGlobalParameter":null},{"Name":"instrument_col","Value":"instrument","ValueType":"Literal","LinkedGlobalParameter":null},{"Name":"drop_na","Value":"False","ValueType":"Literal","LinkedGlobalParameter":null},{"Name":"remove_extra_columns","Value":"False","ValueType":"Literal","LinkedGlobalParameter":null},{"Name":"user_functions","Value":"","ValueType":"Literal","LinkedGlobalParameter":null}],"InputPortsInternal":[{"DataSourceId":null,"TrainedModelId":null,"TransformModuleId":null,"Name":"input_data","NodeId":"-238"},{"DataSourceId":null,"TrainedModelId":null,"TransformModuleId":null,"Name":"features","NodeId":"-238"}],"OutputPortsInternal":[{"Name":"data","NodeId":"-238","OutputType":null}],"UsePreviousResults":true,"moduleIdForCode":18,"Comment":"","CommentCollapsed":true},{"Id":"-250","ModuleId":"BigQuantSpace.trade.trade-v4","ModuleParameters":[{"Name":"start_date","Value":"","ValueType":"Literal","LinkedGlobalParameter":null},{"Name":"end_date","Value":"","ValueType":"Literal","LinkedGlobalParameter":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 = 5\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.options['hold_days'] = 5\n","ValueType":"Literal","LinkedGlobalParameter":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\n # 1. 资金分配\n # 平均持仓时间是hold_days,每日都将买入股票,每日预期使用 1/hold_days 的资金\n # 实际操作中,会存在一定的买入误差,所以在前hold_days天,等量使用资金;之后,尽量使用剩余资金(这里设置最多用等量的1.5倍)\n is_staging = context.trading_day_index < context.options['hold_days'] # 是否在建仓期间(前 hold_days 天)\n cash_avg = context.portfolio.portfolio_value / context.options['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.portfolio.positions.items()}\n\n # 2. 生成卖出订单:hold_days天之后才开始卖出;对持仓的股票,按机器学习算法预测的排序末位淘汰\n if not is_staging and cash_for_sell > 0:\n equities = {e.symbol: e for e, p in context.portfolio.positions.items()}\n instruments = list(reversed(list(ranker_prediction.instrument[ranker_prediction.instrument.apply(\n lambda x: x in equities)])))\n\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. 生成买入订单:按机器学习算法预测的排序,买入前面的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","ValueType":"Literal","LinkedGlobalParameter":null},{"Name":"prepare","Value":"# 回测引擎:准备数据,只执行一次\ndef bigquant_run(context):\n pass\n","ValueType":"Literal","LinkedGlobalParameter":null},{"Name":"before_trading_start","Value":"","ValueType":"Literal","LinkedGlobalParameter":null},{"Name":"volume_limit","Value":0.025,"ValueType":"Literal","LinkedGlobalParameter":null},{"Name":"order_price_field_buy","Value":"open","ValueType":"Literal","LinkedGlobalParameter":null},{"Name":"order_price_field_sell","Value":"close","ValueType":"Literal","LinkedGlobalParameter":null},{"Name":"capital_base","Value":1000000,"ValueType":"Literal","LinkedGlobalParameter":null},{"Name":"auto_cancel_non_tradable_orders","Value":"True","ValueType":"Literal","LinkedGlobalParameter":null},{"Name":"data_frequency","Value":"daily","ValueType":"Literal","LinkedGlobalParameter":null},{"Name":"price_type","Value":"真实价格","ValueType":"Literal","LinkedGlobalParameter":null},{"Name":"product_type","Value":"股票","ValueType":"Literal","LinkedGlobalParameter":null},{"Name":"plot_charts","Value":"True","ValueType":"Literal","LinkedGlobalParameter":null},{"Name":"backtest_only","Value":"False","ValueType":"Literal","LinkedGlobalParameter":null},{"Name":"benchmark","Value":"000300.SHA","ValueType":"Literal","LinkedGlobalParameter":null}],"InputPortsInternal":[{"DataSourceId":null,"TrainedModelId":null,"TransformModuleId":null,"Name":"instruments","NodeId":"-250"},{"DataSourceId":null,"TrainedModelId":null,"TransformModuleId":null,"Name":"options_data","NodeId":"-250"},{"DataSourceId":null,"TrainedModelId":null,"TransformModuleId":null,"Name":"history_ds","NodeId":"-250"},{"DataSourceId":null,"TrainedModelId":null,"TransformModuleId":null,"Name":"benchmark_ds","NodeId":"-250"},{"DataSourceId":null,"TrainedModelId":null,"TransformModuleId":null,"Name":"trading_calendar","NodeId":"-250"}],"OutputPortsInternal":[{"Name":"raw_perf","NodeId":"-250","OutputType":null}],"UsePreviousResults":false,"moduleIdForCode":19,"Comment":"","CommentCollapsed":true},{"Id":"-654","ModuleId":"BigQuantSpace.stock_ranker_train.stock_ranker_train-v6","ModuleParameters":[{"Name":"learning_algorithm","Value":"排序","ValueType":"Literal","LinkedGlobalParameter":null},{"Name":"number_of_leaves","Value":30,"ValueType":"Literal","LinkedGlobalParameter":null},{"Name":"minimum_docs_per_leaf","Value":1000,"ValueType":"Literal","LinkedGlobalParameter":null},{"Name":"number_of_trees","Value":20,"ValueType":"Literal","LinkedGlobalParameter":null},{"Name":"learning_rate","Value":0.1,"ValueType":"Literal","LinkedGlobalParameter":null},{"Name":"max_bins","Value":1023,"ValueType":"Literal","LinkedGlobalParameter":null},{"Name":"feature_fraction","Value":1,"ValueType":"Literal","LinkedGlobalParameter":null},{"Name":"data_row_fraction","Value":1,"ValueType":"Literal","LinkedGlobalParameter":null},{"Name":"ndcg_discount_base","Value":1,"ValueType":"Literal","LinkedGlobalParameter":null},{"Name":"m_lazy_run","Value":"False","ValueType":"Literal","LinkedGlobalParameter":null}],"InputPortsInternal":[{"DataSourceId":null,"TrainedModelId":null,"TransformModuleId":null,"Name":"training_ds","NodeId":"-654"},{"DataSourceId":null,"TrainedModelId":null,"TransformModuleId":null,"Name":"features","NodeId":"-654"},{"DataSourceId":null,"TrainedModelId":null,"TransformModuleId":null,"Name":"test_ds","NodeId":"-654"},{"DataSourceId":null,"TrainedModelId":null,"TransformModuleId":null,"Name":"base_model","NodeId":"-654"}],"OutputPortsInternal":[{"Name":"model","NodeId":"-654","OutputType":null},{"Name":"feature_gains","NodeId":"-654","OutputType":null},{"Name":"m_lazy_run","NodeId":"-654","OutputType":null}],"UsePreviousResults":true,"moduleIdForCode":4,"Comment":"","CommentCollapsed":true},{"Id":"-668","ModuleId":"BigQuantSpace.dropnan.dropnan-v2","ModuleParameters":[],"InputPortsInternal":[{"DataSourceId":null,"TrainedModelId":null,"TransformModuleId":null,"Name":"input_data","NodeId":"-668"},{"DataSourceId":null,"TrainedModelId":null,"TransformModuleId":null,"Name":"features","NodeId":"-668"}],"OutputPortsInternal":[{"Name":"data","NodeId":"-668","OutputType":null}],"UsePreviousResults":true,"moduleIdForCode":5,"Comment":"","CommentCollapsed":true},{"Id":"-672","ModuleId":"BigQuantSpace.dropnan.dropnan-v2","ModuleParameters":[],"InputPortsInternal":[{"DataSourceId":null,"TrainedModelId":null,"TransformModuleId":null,"Name":"input_data","NodeId":"-672"},{"DataSourceId":null,"TrainedModelId":null,"TransformModuleId":null,"Name":"features","NodeId":"-672"}],"OutputPortsInternal":[{"Name":"data","NodeId":"-672","OutputType":null}],"UsePreviousResults":true,"moduleIdForCode":10,"Comment":"","CommentCollapsed":true},{"Id":"-130","ModuleId":"BigQuantSpace.cached.cached-v3","ModuleParameters":[{"Name":"run","Value":"# Python 代码入口函数,input_1/2/3 对应三个输入端,data_1/2/3 对应三个输出端\ndef bigquant_run(input_1, input_2, input_3):\n # 示例代码如下。在这里编写您的代码\n df = DataSource(\"index_constituent_CN_STOCK_A\").read() # 读取A股指数成分表,具体信息见 数据文档-A股-其他常规数据-A股指数成分\n df_csi300 = df[df.in_csi300==1] #选取 沪深300 的记录\n ins_list = df_csi300.instrument.tolist() # 获取对应的 instruments列表\n data_1 = {'end_date': '2015-01-01','instruments':ins_list,'start_date':'2010-01-01'} #输出格式和原代码列表模块输出格式保持一致,代码列表输出格式可通过 m1.data.read()看到\n return Outputs(data_1=data_1, data_2=None, data_3=None) #只需要用到一个输出端,可以把另外两个设为 None。 最后在可视化模块里用输出端口1分别连接 自动标注模块(m2), 基础特征抽取模块(m15),即可。\n","ValueType":"Literal","LinkedGlobalParameter":null},{"Name":"post_run","Value":"# 后处理函数,可选。输入是主函数的输出,可以在这里对数据做处理,或者返回更友好的outputs数据格式。此函数输出不会被缓存。\ndef bigquant_run(outputs):\n return outputs\n","ValueType":"Literal","LinkedGlobalParameter":null},{"Name":"input_ports","Value":"","ValueType":"Literal","LinkedGlobalParameter":null},{"Name":"params","Value":"{}","ValueType":"Literal","LinkedGlobalParameter":null},{"Name":"output_ports","Value":"","ValueType":"Literal","LinkedGlobalParameter":null}],"InputPortsInternal":[{"DataSourceId":null,"TrainedModelId":null,"TransformModuleId":null,"Name":"input_1","NodeId":"-130"},{"DataSourceId":null,"TrainedModelId":null,"TransformModuleId":null,"Name":"input_2","NodeId":"-130"},{"DataSourceId":null,"TrainedModelId":null,"TransformModuleId":null,"Name":"input_3","NodeId":"-130"}],"OutputPortsInternal":[{"Name":"data_1","NodeId":"-130","OutputType":null},{"Name":"data_2","NodeId":"-130","OutputType":null},{"Name":"data_3","NodeId":"-130","OutputType":null}],"UsePreviousResults":true,"moduleIdForCode":11,"Comment":"","CommentCollapsed":true}],"SerializedClientData":"<?xml version='1.0' encoding='utf-16'?><DataV1 xmlns:xsd='http://www.w3.org/2001/XMLSchema' xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'><Meta /><NodePositions><NodePosition Node='287d2cb0-f53c-4101-bdf8-104b137c8601-15' Position='59.23162841796875,261.968017578125,200,200'/><NodePosition Node='287d2cb0-f53c-4101-bdf8-104b137c8601-24' Position='765,21,200,200'/><NodePosition Node='287d2cb0-f53c-4101-bdf8-104b137c8601-53' Position='249,375,200,200'/><NodePosition Node='287d2cb0-f53c-4101-bdf8-104b137c8601-60' Position='906,647,200,200'/><NodePosition Node='287d2cb0-f53c-4101-bdf8-104b137c8601-62' Position='1074,127,200,200'/><NodePosition Node='-215' Position='372.0263366699219,213.12615966796875,200,200'/><NodePosition Node='-222' Position='424.4840087890625,294.3578186035156,200,200'/><NodePosition Node='-231' Position='1078,236,200,200'/><NodePosition Node='-238' Position='1081,327,200,200'/><NodePosition Node='-250' Position='1037,751,200,200'/><NodePosition Node='-654' Position='638,561,200,200'/><NodePosition Node='-668' Position='376,467,200,200'/><NodePosition Node='-672' Position='1078,418,200,200'/><NodePosition Node='-130' Position='176.74017333984375,136.44004821777344,200,200'/></NodePositions><NodeGroups /></DataV1>"},"IsDraft":true,"ParentExperimentId":null,"WebService":{"IsWebServiceExperiment":false,"Inputs":[],"Outputs":[],"Parameters":[{"Name":"交易日期","Value":"","ParameterDefinition":{"Name":"交易日期","FriendlyName":"交易日期","DefaultValue":"","ParameterType":"String","HasDefaultValue":true,"IsOptional":true,"ParameterRules":[],"HasRules":false,"MarkupType":0,"CredentialDescriptor":null}}],"WebServiceGroupId":null,"SerializedClientData":"<?xml version='1.0' encoding='utf-16'?><DataV1 xmlns:xsd='http://www.w3.org/2001/XMLSchema' xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'><Meta /><NodePositions></NodePositions><NodeGroups /></DataV1>"},"DisableNodesUpdate":false,"Category":"user","Tags":[],"IsPartialRun":true}
    In [31]:
    # 本代码由可视化策略环境自动生成 2020年12月29日 15:15
    # 本代码单元只能在可视化模式下编辑。您也可以拷贝代码,粘贴到新建的代码单元或者策略,然后修改。
    
    
    # Python 代码入口函数,input_1/2/3 对应三个输入端,data_1/2/3 对应三个输出端
    def m11_run_bigquant_run(input_1, input_2, input_3):
        # 示例代码如下。在这里编写您的代码
        df = DataSource("index_constituent_CN_STOCK_A").read() # 读取A股指数成分表,具体信息见 数据文档-A股-其他常规数据-A股指数成分
        df_csi300 = df[df.in_csi300==1] #选取 沪深300 的记录
        ins_list = df_csi300.instrument.tolist() # 获取对应的 instruments列表
        data_1 = {'end_date': '2015-01-01','instruments':ins_list,'start_date':'2010-01-01'} #输出格式和原代码列表模块输出格式保持一致,代码列表输出格式可通过 m1.data.read()看到
        return Outputs(data_1=data_1, data_2=None, data_3=None) #只需要用到一个输出端,可以把另外两个设为 None。 最后在可视化模块里用输出端口1分别连接 自动标注模块(m2), 基础特征抽取模块(m15),即可。
    
    # 后处理函数,可选。输入是主函数的输出,可以在这里对数据做处理,或者返回更友好的outputs数据格式。此函数输出不会被缓存。
    def m11_post_run_bigquant_run(outputs):
        return outputs
    
    # 回测引擎:初始化函数,只执行一次
    def m19_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 = 5
        # 每只的股票的权重,如下的权重分配会使得靠前的股票分配多一点的资金,[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.options['hold_days'] = 5
    
    # 回测引擎:每日数据处理函数,每天执行一次
    def m19_handle_data_bigquant_run(context, data):
        # 按日期过滤得到今日的预测数据
        ranker_prediction = context.ranker_prediction[
            context.ranker_prediction.date == data.current_dt.strftime('%Y-%m-%d')]
    
        # 1. 资金分配
        # 平均持仓时间是hold_days,每日都将买入股票,每日预期使用 1/hold_days 的资金
        # 实际操作中,会存在一定的买入误差,所以在前hold_days天,等量使用资金;之后,尽量使用剩余资金(这里设置最多用等量的1.5倍)
        is_staging = context.trading_day_index < context.options['hold_days'] # 是否在建仓期间(前 hold_days 天)
        cash_avg = context.portfolio.portfolio_value / context.options['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.portfolio.positions.items()}
    
        # 2. 生成卖出订单:hold_days天之后才开始卖出;对持仓的股票,按机器学习算法预测的排序末位淘汰
        if not is_staging and cash_for_sell > 0:
            equities = {e.symbol: e for e, p in context.portfolio.positions.items()}
            instruments = list(reversed(list(ranker_prediction.instrument[ranker_prediction.instrument.apply(
                    lambda x: x in equities)])))
    
            for instrument in instruments:
                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)])
        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 m19_prepare_bigquant_run(context):
        pass
    
    
    m3 = 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
    """
    )
    
    m9 = M.instruments.v2(
        start_date=T.live_run_param('trading_date', '2015-01-01'),
        end_date=T.live_run_param('trading_date', '2017-01-01'),
        market='CN_STOCK_A',
        instrument_list='',
        max_count=0
    )
    
    m17 = M.general_feature_extractor.v7(
        instruments=m9.data,
        features=m3.data,
        start_date='',
        end_date='',
        before_start_days=90
    )
    
    m18 = M.derived_feature_extractor.v3(
        input_data=m17.data,
        features=m3.data,
        date_col='date',
        instrument_col='instrument',
        drop_na=False,
        remove_extra_columns=False
    )
    
    m10 = M.dropnan.v2(
        input_data=m18.data
    )
    
    m11 = M.cached.v3(
        run=m11_run_bigquant_run,
        post_run=m11_post_run_bigquant_run,
        input_ports='',
        params='{}',
        output_ports=''
    )
    
    m2 = M.advanced_auto_labeler.v2(
        instruments=m11.data_1,
        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>`_
    
    # 计算收益:5日收盘价(作为卖出价格)除以明日开盘价(作为买入价格)
    shift(close, -5) / shift(open, -1)
    
    # 极值处理:用1%和99%分位的值做clip
    clip(label, all_quantile(label, 0.01), all_quantile(label, 0.99))
    
    # 将分数映射到分类,这里使用20个分类
    all_wbins(label, 20)
    
    # 过滤掉一字涨停的情况 (设置label为NaN,在后续处理和训练中会忽略NaN的label)
    where(shift(high, -1) == shift(low, -1), NaN, label)
    """,
        start_date='',
        end_date='',
        benchmark='000300.SHA',
        drop_na_label=True,
        cast_label_int=True
    )
    
    m15 = M.general_feature_extractor.v7(
        instruments=m11.data_1,
        features=m3.data,
        start_date='',
        end_date='',
        before_start_days=90
    )
    
    m16 = M.derived_feature_extractor.v3(
        input_data=m15.data,
        features=m3.data,
        date_col='date',
        instrument_col='instrument',
        drop_na=False,
        remove_extra_columns=False
    )
    
    m7 = M.join.v3(
        data1=m2.data,
        data2=m16.data,
        on='date,instrument',
        how='inner',
        sort=False
    )
    
    m5 = M.dropnan.v2(
        input_data=m7.data
    )
    
    m4 = M.stock_ranker_train.v6(
        training_ds=m5.data,
        features=m3.data,
        learning_algorithm='排序',
        number_of_leaves=30,
        minimum_docs_per_leaf=1000,
        number_of_trees=20,
        learning_rate=0.1,
        max_bins=1023,
        feature_fraction=1,
        data_row_fraction=1,
        ndcg_discount_base=1,
        m_lazy_run=False
    )
    
    m8 = M.stock_ranker_predict.v5(
        model=m4.model,
        data=m10.data,
        m_lazy_run=False
    )
    
    m19 = M.trade.v4(
        instruments=m9.data,
        options_data=m8.predictions,
        start_date='',
        end_date='',
        initialize=m19_initialize_bigquant_run,
        handle_data=m19_handle_data_bigquant_run,
        prepare=m19_prepare_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='000300.SHA'
    )
    
    设置评估测试数据集,查看训练曲线
    [视频教程]StockRanker训练曲线
    bigcharts-data-start/{"__type":"tabs","__id":"bigchart-ec87cce110c8459e82e1f59f290e26b2"}/bigcharts-data-end
    • 收益率133.22%
    • 年化收益率54.85%
    • 基准收益率-6.33%
    • 阿尔法0.51
    • 贝塔1.02
    • 夏普比率1.17
    • 胜率0.59
    • 盈亏比0.84
    • 收益波动率42.55%
    • 信息比率0.12
    • 最大回撤57.93%
    bigcharts-data-start/{"__type":"tabs","__id":"bigchart-a3623e638190412c84bf04582f5bc52d"}/bigcharts-data-end
    In [32]:
    m1.data.read()
    
    Out[32]:
    {'end_date': '2015-01-01',
     'instruments': ['000001.SZA',
      '000002.SZA',
      '000004.SZA',
      '000005.SZA',
      '000006.SZA',
      '000007.SZA',
      '000008.SZA',
      '000009.SZA',
      '000010.SZA',
      '000011.SZA',
      '000012.SZA',
      '000014.SZA',
      '000016.SZA',
      '000017.SZA',
      '000018.SZA',
      '000019.SZA',
      '000020.SZA',
      '000021.SZA',
      '000022.SZA',
      '000023.SZA',
      '000024.SZA',
      '000025.SZA',
      '000026.SZA',
      '000027.SZA',
      '000028.SZA',
      '000029.SZA',
      '000030.SZA',
      '000031.SZA',
      '000032.SZA',
      '000033.SZA',
      '000034.SZA',
      '000035.SZA',
      '000036.SZA',
      '000037.SZA',
      '000038.SZA',
      '000039.SZA',
      '000040.SZA',
      '000042.SZA',
      '000043.SZA',
      '000045.SZA',
      '000046.SZA',
      '000048.SZA',
      '000049.SZA',
      '000050.SZA',
      '000055.SZA',
      '000056.SZA',
      '000058.SZA',
      '000059.SZA',
      '000060.SZA',
      '000061.SZA',
      '000062.SZA',
      '000063.SZA',
      '000065.SZA',
      '000066.SZA',
      '000068.SZA',
      '000069.SZA',
      '000070.SZA',
      '000078.SZA',
      '000088.SZA',
      '000089.SZA',
      '000090.SZA',
      '000096.SZA',
      '000099.SZA',
      '000100.SZA',
      '000150.SZA',
      '000151.SZA',
      '000153.SZA',
      '000155.SZA',
      '000156.SZA',
      '000157.SZA',
      '000158.SZA',
      '000159.SZA',
      '000301.SZA',
      '000333.SZA',
      '000338.SZA',
      '000400.SZA',
      '000401.SZA',
      '000402.SZA',
      '000403.SZA',
      '000404.SZA',
      '000407.SZA',
      '000408.SZA',
      '000409.SZA',
      '000410.SZA',
      '000411.SZA',
      '000413.SZA',
      '000415.SZA',
      '000416.SZA',
      '000417.SZA',
      '000418.SZA',
      '000419.SZA',
      '000420.SZA',
      '000421.SZA',
      '000422.SZA',
      '000423.SZA',
      '000425.SZA',
      '000426.SZA',
      '000428.SZA',
      '000429.SZA',
      '000430.SZA',
      '000488.SZA',
      '000498.SZA',
      '000501.SZA',
      '000502.SZA',
      '000503.SZA',
      '000504.SZA',
      '000505.SZA',
      '000506.SZA',
      '000507.SZA',
      '000509.SZA',
      '000510.SZA',
      '000511.SZA',
      '000513.SZA',
      '000514.SZA',
      '000516.SZA',
      '000517.SZA',
      '000518.SZA',
      '000519.SZA',
      '000520.SZA',
      '000521.SZA',
      '000522.SZA',
      '000523.SZA',
      '000524.SZA',
      '000525.SZA',
      '000526.SZA',
      '000527.SZA',
      '000528.SZA',
      '000529.SZA',
      '000530.SZA',
      '000531.SZA',
      '000532.SZA',
      '000533.SZA',
      '000534.SZA',
      '000536.SZA',
      '000537.SZA',
      '000538.SZA',
      '000539.SZA',
      '000540.SZA',
      '000541.SZA',
      '000543.SZA',
      '000544.SZA',
      '000545.SZA',
      '000546.SZA',
      '000547.SZA',
      '000548.SZA',
      '000550.SZA',
      '000551.SZA',
      '000552.SZA',
      '000553.SZA',
      '000554.SZA',
      '000555.SZA',
      '000557.SZA',
      '000558.SZA',
      '000559.SZA',
      '000560.SZA',
      '000561.SZA',
      '000562.SZA',
      '000563.SZA',
      '000564.SZA',
      '000565.SZA',
      '000566.SZA',
      '000567.SZA',
      '000568.SZA',
      '000570.SZA',
      '000571.SZA',
      '000572.SZA',
      '000573.SZA',
      '000576.SZA',
      '000578.SZA',
      '000581.SZA',
      '000582.SZA',
      '000584.SZA',
      '000585.SZA',
      '000586.SZA',
      '000587.SZA',
      '000589.SZA',
      '000590.SZA',
      '000591.SZA',
      '000592.SZA',
      '000593.SZA',
      '000594.SZA',
      '000595.SZA',
      '000596.SZA',
      '000597.SZA',
      '000598.SZA',
      '000599.SZA',
      '000600.SZA',
      '000601.SZA',
      '000602.SZA',
      '000603.SZA',
      '000605.SZA',
      '000606.SZA',
      '000607.SZA',
      '000608.SZA',
      '000609.SZA',
      '000610.SZA',
      '000611.SZA',
      '000612.SZA',
      '000613.SZA',
      '000615.SZA',
      '000616.SZA',
      '000617.SZA',
      '000619.SZA',
      '000620.SZA',
      '000622.SZA',
      '000623.SZA',
      '000625.SZA',
      '000626.SZA',
      '000627.SZA',
      '000628.SZA',
      '000629.SZA',
      '000630.SZA',
      '000631.SZA',
      '000632.SZA',
      '000633.SZA',
      '000635.SZA',
      '000636.SZA',
      '000637.SZA',
      '000638.SZA',
      '000639.SZA',
      '000650.SZA',
      '000651.SZA',
      '000652.SZA',
      '000655.SZA',
      '000656.SZA',
      '000657.SZA',
      '000659.SZA',
      '000661.SZA',
      '000662.SZA',
      '000663.SZA',
      '000665.SZA',
      '000666.SZA',
      '000667.SZA',
      '000668.SZA',
      '000669.SZA',
      '000670.SZA',
      '000671.SZA',
      '000672.SZA',
      '000673.SZA',
      '000676.SZA',
      '000677.SZA',
      '000678.SZA',
      '000679.SZA',
      '000680.SZA',
      '000681.SZA',
      '000682.SZA',
      '000683.SZA',
      '000685.SZA',
      '000686.SZA',
      '000687.SZA',
      '000688.SZA',
      '000690.SZA',
      '000691.SZA',
      '000692.SZA',
      '000693.SZA',
      '000695.SZA',
      '000697.SZA',
      '000698.SZA',
      '000700.SZA',
      '000701.SZA',
      '000702.SZA',
      '000703.SZA',
      '000705.SZA',
      '000707.SZA',
      '000708.SZA',
      '000709.SZA',
      '000710.SZA',
      '000711.SZA',
      '000712.SZA',
      '000713.SZA',
      '000715.SZA',
      '000716.SZA',
      '000717.SZA',
      '000718.SZA',
      '000719.SZA',
      '000720.SZA',
      '000721.SZA',
      '000722.SZA',
      '000723.SZA',
      '000725.SZA',
      '000726.SZA',
      '000727.SZA',
      '000728.SZA',
      '000729.SZA',
      '000731.SZA',
      '000732.SZA',
      '000733.SZA',
      '000735.SZA',
      '000736.SZA',
      '000737.SZA',
      '000738.SZA',
      '000739.SZA',
      '000748.SZA',
      '000750.SZA',
      '000751.SZA',
      '000752.SZA',
      '000753.SZA',
      '000755.SZA',
      '000756.SZA',
      '000757.SZA',
      '000758.SZA',
      '000759.SZA',
      '000760.SZA',
      '000761.SZA',
      '000762.SZA',
      '000766.SZA',
      '000767.SZA',
      '000768.SZA',
      '000776.SZA',
      '000777.SZA',
      '000778.SZA',
      '000779.SZA',
      '000780.SZA',
      '000782.SZA',
      '000783.SZA',
      '000785.SZA',
      '000786.SZA',
      '000787.SZA',
      '000788.SZA',
      '000789.SZA',
      '000790.SZA',
      '000791.SZA',
      '000792.SZA',
      '000793.SZA',
      '000795.SZA',
      '000796.SZA',
      '000797.SZA',
      '000798.SZA',
      '000799.SZA',
      '000800.SZA',
      '000801.SZA',
      '000802.SZA',
      '000803.SZA',
      '000805.SZA',
      '000806.SZA',
      '000807.SZA',
      '000809.SZA',
      '000810.SZA',
      '000811.SZA',
      '000812.SZA',
      '000813.SZA',
      '000815.SZA',
      '000816.SZA',
      '000818.SZA',
      '000819.SZA',
      '000820.SZA',
      '000821.SZA',
      '000822.SZA',
      '000823.SZA',
      '000825.SZA',
      '000826.SZA',
      '000828.SZA',
      '000829.SZA',
      '000830.SZA',
      '000831.SZA',
      '000833.SZA',
      '000835.SZA',
      '000836.SZA',
      '000837.SZA',
      '000838.SZA',
      '000839.SZA',
      '000848.SZA',
      '000850.SZA',
      '000851.SZA',
      '000852.SZA',
      '000856.SZA',
      '000858.SZA',
      '000859.SZA',
      '000860.SZA',
      '000861.SZA',
      '000862.SZA',
      '000863.SZA',
      '000868.SZA',
      '000869.SZA',
      '000875.SZA',
      '000876.SZA',
      '000877.SZA',
      '000878.SZA',
      '000880.SZA',
      '000881.SZA',
      '000882.SZA',
      '000883.SZA',
      '000885.SZA',
      '000886.SZA',
      '000887.SZA',
      '000888.SZA',
      '000889.SZA',
      '000890.SZA',
      '000892.SZA',
      '000893.SZA',
      '000895.SZA',
      '000897.SZA',
      '000898.SZA',
      '000899.SZA',
      '000900.SZA',
      '000901.SZA',
      '000902.SZA',
      '000903.SZA',
      '000905.SZA',
      '000906.SZA',
      '000908.SZA',
      '000909.SZA',
      '000910.SZA',
      '000911.SZA',
      '000912.SZA',
      '000913.SZA',
      '000915.SZA',
      '000916.SZA',
      '000917.SZA',
      '000918.SZA',
      '000919.SZA',
      '000920.SZA',
      '000921.SZA',
      '000922.SZA',
      '000923.SZA',
      '000925.SZA',
      '000926.SZA',
      '000927.SZA',
      '000928.SZA',
      '000929.SZA',
      '000930.SZA',
      '000931.SZA',
      '000932.SZA',
      '000933.SZA',
      '000935.SZA',
      '000936.SZA',
      '000937.SZA',
      '000938.SZA',
      '000939.SZA',
      '000948.SZA',
      '000949.SZA',
      '000950.SZA',
      '000951.SZA',
      '000952.SZA',
      '000953.SZA',
      '000955.SZA',
      '000957.SZA',
      '000958.SZA',
      '000959.SZA',
      '000960.SZA',
      '000961.SZA',
      '000962.SZA',
      '000963.SZA',
      '000965.SZA',
      '000966.SZA',
      '000967.SZA',
      '000968.SZA',
      '000969.SZA',
      '000970.SZA',
      '000971.SZA',
      '000972.SZA',
      '000973.SZA',
      '000975.SZA',
      '000976.SZA',
      '000977.SZA',
      '000978.SZA',
      '000979.SZA',
      '000980.SZA',
      '000981.SZA',
      '000982.SZA',
      '000983.SZA',
      '000985.SZA',
      '000987.SZA',
      '000988.SZA',
      '000989.SZA',
      '000990.SZA',
      '000993.SZA',
      '000995.SZA',
      '000996.SZA',
      '000997.SZA',
      '000998.SZA',
      '000999.SZA',
      '001696.SZA',
      '001872.SZA',
      '001896.SZA',
      '001914.SZA',
      '002001.SZA',
      '002002.SZA',
      '002003.SZA',
      '002004.SZA',
      '002005.SZA',
      '002006.SZA',
      '002007.SZA',
      '002008.SZA',
      '002009.SZA',
      '002010.SZA',
      '002011.SZA',
      '002012.SZA',
      '002013.SZA',
      '002014.SZA',
      '002015.SZA',
      '002016.SZA',
      '002017.SZA',
      '002018.SZA',
      '002019.SZA',
      '002020.SZA',
      '002021.SZA',
      '002022.SZA',
      '002023.SZA',
      '002024.SZA',
      '002025.SZA',
      '002026.SZA',
      '002027.SZA',
      '002028.SZA',
      '002029.SZA',
      '002030.SZA',
      '002031.SZA',
      '002032.SZA',
      '002033.SZA',
      '002034.SZA',
      '002035.SZA',
      '002036.SZA',
      '002037.SZA',
      '002038.SZA',
      '002039.SZA',
      '002040.SZA',
      '002041.SZA',
      '002042.SZA',
      '002043.SZA',
      '002044.SZA',
      '002045.SZA',
      '002046.SZA',
      '002047.SZA',
      '002048.SZA',
      '002049.SZA',
      '002050.SZA',
      '002051.SZA',
      '002052.SZA',
      '002053.SZA',
      '002054.SZA',
      '002055.SZA',
      '002056.SZA',
      '002057.SZA',
      '002058.SZA',
      '002059.SZA',
      '002060.SZA',
      '002061.SZA',
      '002062.SZA',
      '002063.SZA',
      '002064.SZA',
      '002065.SZA',
      '002066.SZA',
      '002067.SZA',
      '002068.SZA',
      '002069.SZA',
      '002070.SZA',
      '002071.SZA',
      '002072.SZA',
      '002073.SZA',
      '002074.SZA',
      '002075.SZA',
      '002076.SZA',
      '002077.SZA',
      '002078.SZA',
      '002079.SZA',
      '002080.SZA',
      '002081.SZA',
      '002082.SZA',
      '002083.SZA',
      '002084.SZA',
      '002085.SZA',
      '002086.SZA',
      '002087.SZA',
      '002088.SZA',
      '002089.SZA',
      '002090.SZA',
      '002091.SZA',
      '002092.SZA',
      '002093.SZA',
      '002094.SZA',
      '002095.SZA',
      '002096.SZA',
      '002097.SZA',
      '002098.SZA',
      '002099.SZA',
      '002100.SZA',
      '002101.SZA',
      '002102.SZA',
      '002103.SZA',
      '002104.SZA',
      '002105.SZA',
      '002106.SZA',
      '002107.SZA',
      '002108.SZA',
      '002109.SZA',
      '002110.SZA',
      '002111.SZA',
      '002112.SZA',
      '002113.SZA',
      '002114.SZA',
      '002115.SZA',
      '002116.SZA',
      '002117.SZA',
      '002118.SZA',
      '002119.SZA',
      '002120.SZA',
      '002121.SZA',
      '002122.SZA',
      '002123.SZA',
      '002124.SZA',
      '002125.SZA',
      '002126.SZA',
      '002127.SZA',
      '002128.SZA',
      '002129.SZA',
      '002130.SZA',
      '002131.SZA',
      '002132.SZA',
      '002133.SZA',
      '002134.SZA',
      '002135.SZA',
      '002136.SZA',
      '002137.SZA',
      '002138.SZA',
      '002139.SZA',
      '002140.SZA',
      '002141.SZA',
      '002142.SZA',
      '002143.SZA',
      '002144.SZA',
      '002145.SZA',
      '002146.SZA',
      '002147.SZA',
      '002148.SZA',
      '002149.SZA',
      '002150.SZA',
      '002151.SZA',
      '002152.SZA',
      '002153.SZA',
      '002154.SZA',
      '002155.SZA',
      '002156.SZA',
      '002157.SZA',
      '002158.SZA',
      '002159.SZA',
      '002160.SZA',
      '002161.SZA',
      '002162.SZA',
      '002163.SZA',
      '002164.SZA',
      '002165.SZA',
      '002166.SZA',
      '002167.SZA',
      '002168.SZA',
      '002169.SZA',
      '002170.SZA',
      '002171.SZA',
      '002172.SZA',
      '002173.SZA',
      '002174.SZA',
      '002175.SZA',
      '002176.SZA',
      '002177.SZA',
      '002178.SZA',
      '002179.SZA',
      '002180.SZA',
      '002181.SZA',
      '002182.SZA',
      '002183.SZA',
      '002184.SZA',
      '002185.SZA',
      '002186.SZA',
      '002187.SZA',
      '002188.SZA',
      '002189.SZA',
      '002190.SZA',
      '002191.SZA',
      '002192.SZA',
      '002193.SZA',
      '002194.SZA',
      '002195.SZA',
      '002196.SZA',
      '002197.SZA',
      '002198.SZA',
      '002199.SZA',
      '002200.SZA',
      '002201.SZA',
      '002202.SZA',
      '002203.SZA',
      '002204.SZA',
      '002205.SZA',
      '002206.SZA',
      '002207.SZA',
      '002208.SZA',
      '002209.SZA',
      '002210.SZA',
      '002211.SZA',
      '002212.SZA',
      '002213.SZA',
      '002214.SZA',
      '002215.SZA',
      '002216.SZA',
      '002217.SZA',
      '002218.SZA',
      '002219.SZA',
      '002220.SZA',
      '002221.SZA',
      '002222.SZA',
      '002223.SZA',
      '002224.SZA',
      '002225.SZA',
      '002226.SZA',
      '002227.SZA',
      '002228.SZA',
      '002229.SZA',
      '002230.SZA',
      '002231.SZA',
      '002232.SZA',
      '002233.SZA',
      '002234.SZA',
      '002235.SZA',
      '002236.SZA',
      '002237.SZA',
      '002238.SZA',
      '002239.SZA',
      '002240.SZA',
      '002241.SZA',
      '002242.SZA',
      '002243.SZA',
      '002244.SZA',
      '002245.SZA',
      '002246.SZA',
      '002247.SZA',
      '002248.SZA',
      '002249.SZA',
      '002250.SZA',
      '002251.SZA',
      '002252.SZA',
      '002253.SZA',
      '002254.SZA',
      '002255.SZA',
      '002256.SZA',
      '002258.SZA',
      '002259.SZA',
      '002260.SZA',
      '002261.SZA',
      '002262.SZA',
      '002263.SZA',
      '002264.SZA',
      '002265.SZA',
      '002266.SZA',
      '002267.SZA',
      '002268.SZA',
      '002269.SZA',
      '002270.SZA',
      '002271.SZA',
      '002272.SZA',
      '002273.SZA',
      '002274.SZA',
      '002275.SZA',
      '002276.SZA',
      '002277.SZA',
      '002278.SZA',
      '002279.SZA',
      '002280.SZA',
      '002281.SZA',
      '002282.SZA',
      '002283.SZA',
      '002284.SZA',
      '002285.SZA',
      '002286.SZA',
      '002287.SZA',
      '002288.SZA',
      '002289.SZA',
      '002290.SZA',
      '002291.SZA',
      '002292.SZA',
      '002293.SZA',
      '002294.SZA',
      '002295.SZA',
      '002296.SZA',
      '002297.SZA',
      '002298.SZA',
      '002299.SZA',
      '002300.SZA',
      '002301.SZA',
      '002302.SZA',
      '002303.SZA',
      '002304.SZA',
      '002305.SZA',
      '002306.SZA',
      '002307.SZA',
      '002308.SZA',
      '002309.SZA',
      '002310.SZA',
      '002311.SZA',
      '002312.SZA',
      '002313.SZA',
      '002314.SZA',
      '002315.SZA',
      '002316.SZA',
      '002317.SZA',
      '002318.SZA',
      '002319.SZA',
      '002320.SZA',
      '002321.SZA',
      '002322.SZA',
      '002323.SZA',
      '002324.SZA',
      '002325.SZA',
      '002326.SZA',
      '002327.SZA',
      '002328.SZA',
      '002329.SZA',
      '002330.SZA',
      '002331.SZA',
      '002332.SZA',
      '002333.SZA',
      '002334.SZA',
      '002335.SZA',
      '002336.SZA',
      '002337.SZA',
      '002338.SZA',
      '002339.SZA',
      '002340.SZA',
      '002341.SZA',
      '002342.SZA',
      '002343.SZA',
      '002344.SZA',
      '002345.SZA',
      '002346.SZA',
      '002347.SZA',
      '002348.SZA',
      '002349.SZA',
      '002350.SZA',
      '002351.SZA',
      '002352.SZA',
      '002353.SZA',
      '002354.SZA',
      '002355.SZA',
      '002356.SZA',
      '002357.SZA',
      '002358.SZA',
      '002359.SZA',
      '002360.SZA',
      '002361.SZA',
      '002362.SZA',
      '002363.SZA',
      '002364.SZA',
      '002365.SZA',
      '002366.SZA',
      '002367.SZA',
      '002368.SZA',
      '002369.SZA',
      '002370.SZA',
      '002371.SZA',
      '002372.SZA',
      '002373.SZA',
      '002374.SZA',
      '002375.SZA',
      '002376.SZA',
      '002377.SZA',
      '002378.SZA',
      '002379.SZA',
      '002380.SZA',
      '002381.SZA',
      '002382.SZA',
      '002383.SZA',
      '002384.SZA',
      '002385.SZA',
      '002386.SZA',
      '002387.SZA',
      '002388.SZA',
      '002389.SZA',
      '002390.SZA',
      '002391.SZA',
      '002392.SZA',
      '002393.SZA',
      '002394.SZA',
      '002395.SZA',
      '002396.SZA',
      '002397.SZA',
      '002398.SZA',
      '002399.SZA',
      '002400.SZA',
      '002401.SZA',
      '002402.SZA',
      '002403.SZA',
      '002404.SZA',
      '002405.SZA',
      '002406.SZA',
      '002407.SZA',
      '002408.SZA',
      '002409.SZA',
      '002410.SZA',
      '002411.SZA',
      '002412.SZA',
      '002413.SZA',
      '002414.SZA',
      '002415.SZA',
      '002416.SZA',
      '002417.SZA',
      '002418.SZA',
      '002419.SZA',
      '002420.SZA',
      '002421.SZA',
      '002422.SZA',
      '002423.SZA',
      '002424.SZA',
      '002425.SZA',
      '002426.SZA',
      '002427.SZA',
      '002428.SZA',
      '002429.SZA',
      '002430.SZA',
      '002431.SZA',
      '002432.SZA',
      '002433.SZA',
      '002434.SZA',
      '002435.SZA',
      '002436.SZA',
      '002437.SZA',
      '002438.SZA',
      '002439.SZA',
      '002440.SZA',
      '002441.SZA',
      '002442.SZA',
      '002443.SZA',
      '002444.SZA',
      '002445.SZA',
      '002446.SZA',
      '002447.SZA',
      '002448.SZA',
      '002449.SZA',
      '002450.SZA',
      '002451.SZA',
      '002452.SZA',
      '002453.SZA',
      '002454.SZA',
      '002455.SZA',
      '002456.SZA',
      '002457.SZA',
      '002458.SZA',
      '002459.SZA',
      '002460.SZA',
      '002461.SZA',
      '002462.SZA',
      '002463.SZA',
      '002464.SZA',
      '002465.SZA',
      '002466.SZA',
      '002467.SZA',
      '002468.SZA',
      '002469.SZA',
      '002470.SZA',
      '002471.SZA',
      '002472.SZA',
      '002473.SZA',
      '002474.SZA',
      '002475.SZA',
      '002476.SZA',
      '002477.SZA',
      '002478.SZA',
      '002479.SZA',
      '002480.SZA',
      '002481.SZA',
      '002482.SZA',
      '002483.SZA',
      '002484.SZA',
      '002485.SZA',
      '002486.SZA',
      '002487.SZA',
      '002488.SZA',
      '002489.SZA',
      '002490.SZA',
      '002491.SZA',
      '002492.SZA',
      '002493.SZA',
      '002494.SZA',
      '002495.SZA',
      '002496.SZA',
      '002497.SZA',
      '002498.SZA',
      '002499.SZA',
      '002500.SZA',
      '002501.SZA',
      '002502.SZA',
      '002503.SZA',
      '002504.SZA',
      '002505.SZA',
      '002506.SZA',
      '002507.SZA',
      '002508.SZA',
      '002509.SZA',
      '002510.SZA',
      '002511.SZA',
      '002512.SZA',
      '002513.SZA',
      '002514.SZA',
      '002515.SZA',
      '002516.SZA',
      '002517.SZA',
      '002518.SZA',
      '002519.SZA',
      '002520.SZA',
      '002521.SZA',
      '002522.SZA',
      '002523.SZA',
      '002524.SZA',
      '002526.SZA',
      ...],
     'start_date': '2010-01-01'}