克隆策略

    {"Description":"实验创建于2017/9/28","Summary":"","Graph":{"EdgesInternal":[{"DestinationInputPortId":"-2119:features","SourceOutputPortId":"-315:data"},{"DestinationInputPortId":"-2648:features","SourceOutputPortId":"-315:data"},{"DestinationInputPortId":"-26:features","SourceOutputPortId":"-315:data"},{"DestinationInputPortId":"-2663:features","SourceOutputPortId":"-315:data"},{"DestinationInputPortId":"287d2cb0-f53c-4101-bdf8-104b137c8601-43:features","SourceOutputPortId":"-315:data"},{"DestinationInputPortId":"287d2cb0-f53c-4101-bdf8-104b137c8601-53:data2","SourceOutputPortId":"-26:data"},{"DestinationInputPortId":"-26:input_data","SourceOutputPortId":"-2119:data"},{"DestinationInputPortId":"287d2cb0-f53c-4101-bdf8-104b137c8601-53:data1","SourceOutputPortId":"-2125:data"},{"DestinationInputPortId":"287d2cb0-f53c-4101-bdf8-104b137c8601-84:input_data","SourceOutputPortId":"287d2cb0-f53c-4101-bdf8-104b137c8601-53:data"},{"DestinationInputPortId":"287d2cb0-f53c-4101-bdf8-104b137c8601-43:training_ds","SourceOutputPortId":"287d2cb0-f53c-4101-bdf8-104b137c8601-84:data"},{"DestinationInputPortId":"287d2cb0-f53c-4101-bdf8-104b137c8601-60:model","SourceOutputPortId":"287d2cb0-f53c-4101-bdf8-104b137c8601-43:model"},{"DestinationInputPortId":"-2648:instruments","SourceOutputPortId":"-2639:data"},{"DestinationInputPortId":"287d2cb0-f53c-4101-bdf8-104b137c8601-81:instruments","SourceOutputPortId":"-2639:data"},{"DestinationInputPortId":"-2663:input_data","SourceOutputPortId":"-2648:data"},{"DestinationInputPortId":"-2669:input_data","SourceOutputPortId":"-2663:data"},{"DestinationInputPortId":"287d2cb0-f53c-4101-bdf8-104b137c8601-60:data","SourceOutputPortId":"-2669:data"},{"DestinationInputPortId":"287d2cb0-f53c-4101-bdf8-104b137c8601-81:options_data","SourceOutputPortId":"287d2cb0-f53c-4101-bdf8-104b137c8601-60:predictions"},{"DestinationInputPortId":"-2119:instruments","SourceOutputPortId":"-4129:data"},{"DestinationInputPortId":"-2125:instruments","SourceOutputPortId":"-4129:data"}],"ModuleNodes":[{"Id":"-315","ModuleId":"BigQuantSpace.input_features.input_features-v1","ModuleParameters":[{"Name":"features","Value":"return_5\nreturn_10\nreturn_20\nvolume_0/mean(close_0,3)\navg_amount_0/avg_amount_5 \navg_amount_5/avg_amount_10 \nsum(mf_net_amount_xl_0, 5) \nsum(mf_net_amount_l_0, 5)\nclose_0\nmarket_cap_float_0\ngroupby_calcu_relative_ret(close_0)\n\n \n","ValueType":"Literal","LinkedGlobalParameter":null}],"InputPortsInternal":[{"DataSourceId":null,"TrainedModelId":null,"TransformModuleId":null,"Name":"features_ds","NodeId":"-315"}],"OutputPortsInternal":[{"Name":"data","NodeId":"-315","OutputType":null}],"UsePreviousResults":true,"moduleIdForCode":1,"Comment":"","CommentCollapsed":true},{"Id":"-26","ModuleId":"BigQuantSpace.derived_feature_extractor.derived_feature_extractor-v2","ModuleParameters":[{"Name":"date_col","Value":"date","ValueType":"Literal","LinkedGlobalParameter":null},{"Name":"instrument_col","Value":"instrument","ValueType":"Literal","LinkedGlobalParameter":null},{"Name":"user_functions","Value":"def calcu_relative_ret(df):\n start_date = min(m4.data.read_df().date).strftime('%Y-%m-%d')\n end_date = max(m4.data.read_df().date).strftime('%Y-%m-%d')\n hs800_df = D.history_data(\n '000016.SHA',\n start_date=(pd.to_datetime(start_date) - datetime.timedelta(days=10)).strftime('%Y-%m-%d'), # 多取几天的数据\n end_date=end_date)[['date', 'close']].rename(columns={'close': 'hs800_close'})\n df = df[['date', 'close_0']].reset_index().merge(hs800_df, on='date', how='left').set_index('index')\n return df['close_0'].pct_change() - df['hs800_close'].pct_change()\n\ndef groupby_calcu_relative_ret(df, close_0):\n return df.groupby('instrument', group_keys=False).apply(calcu_relative_ret)\n\nbigquant_run = {\n 'groupby_calcu_relative_ret': groupby_calcu_relative_ret\n}\n\n","ValueType":"Literal","LinkedGlobalParameter":null}],"InputPortsInternal":[{"DataSourceId":null,"TrainedModelId":null,"TransformModuleId":null,"Name":"input_data","NodeId":"-26"},{"DataSourceId":null,"TrainedModelId":null,"TransformModuleId":null,"Name":"features","NodeId":"-26"}],"OutputPortsInternal":[{"Name":"data","NodeId":"-26","OutputType":null}],"UsePreviousResults":true,"moduleIdForCode":2,"Comment":"在衍生特征里配置自定义函数就可以了,也可以覆盖同名的预定义函数","CommentCollapsed":true},{"Id":"-2119","ModuleId":"BigQuantSpace.general_feature_extractor.general_feature_extractor-v6","ModuleParameters":[{"Name":"start_date","Value":"","ValueType":"Literal","LinkedGlobalParameter":null},{"Name":"end_date","Value":"","ValueType":"Literal","LinkedGlobalParameter":null},{"Name":"before_start_days","Value":"","ValueType":"Literal","LinkedGlobalParameter":null}],"InputPortsInternal":[{"DataSourceId":null,"TrainedModelId":null,"TransformModuleId":null,"Name":"instruments","NodeId":"-2119"},{"DataSourceId":null,"TrainedModelId":null,"TransformModuleId":null,"Name":"features","NodeId":"-2119"}],"OutputPortsInternal":[{"Name":"data","NodeId":"-2119","OutputType":null}],"UsePreviousResults":false,"moduleIdForCode":4,"Comment":"","CommentCollapsed":true},{"Id":"-2125","ModuleId":"BigQuantSpace.advanced_auto_labeler.advanced_auto_labeler-v2","ModuleParameters":[{"Name":"label_expr","Value":"# #号开始的表示注释\n# 0. 每行一个,顺序执行,从第二个开始,可以使用label字段\n# 1. 可用数据字段见 https://bigquant.com/docs/data_history_data.html\n# 添加benchmark_前缀,可使用对应的benchmark数据\n# 2. 可用操作符和函数见 `表达式引擎 <https://bigquant.com/docs/big_expr.html>`_\n\n# 计算收益:5日收盘价(作为卖出价格)除以明日开盘价(作为买入价格)\nshift(close, -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":"-2125"}],"OutputPortsInternal":[{"Name":"data","NodeId":"-2125","OutputType":null}],"UsePreviousResults":true,"moduleIdForCode":5,"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":6,"Comment":"","CommentCollapsed":true},{"Id":"287d2cb0-f53c-4101-bdf8-104b137c8601-84","ModuleId":"BigQuantSpace.dropnan.dropnan-v1","ModuleParameters":[],"InputPortsInternal":[{"DataSourceId":null,"TrainedModelId":null,"TransformModuleId":null,"Name":"input_data","NodeId":"287d2cb0-f53c-4101-bdf8-104b137c8601-84"}],"OutputPortsInternal":[{"Name":"data","NodeId":"287d2cb0-f53c-4101-bdf8-104b137c8601-84","OutputType":null}],"UsePreviousResults":true,"moduleIdForCode":7,"Comment":"","CommentCollapsed":true},{"Id":"287d2cb0-f53c-4101-bdf8-104b137c8601-43","ModuleId":"BigQuantSpace.stock_ranker_train.stock_ranker_train-v5","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":"m_lazy_run","Value":"False","ValueType":"Literal","LinkedGlobalParameter":null}],"InputPortsInternal":[{"DataSourceId":null,"TrainedModelId":null,"TransformModuleId":null,"Name":"training_ds","NodeId":"287d2cb0-f53c-4101-bdf8-104b137c8601-43"},{"DataSourceId":null,"TrainedModelId":null,"TransformModuleId":null,"Name":"features","NodeId":"287d2cb0-f53c-4101-bdf8-104b137c8601-43"},{"DataSourceId":null,"TrainedModelId":null,"TransformModuleId":null,"Name":"test_ds","NodeId":"287d2cb0-f53c-4101-bdf8-104b137c8601-43"},{"DataSourceId":null,"TrainedModelId":null,"TransformModuleId":null,"Name":"base_model","NodeId":"287d2cb0-f53c-4101-bdf8-104b137c8601-43"}],"OutputPortsInternal":[{"Name":"model","NodeId":"287d2cb0-f53c-4101-bdf8-104b137c8601-43","OutputType":null},{"Name":"feature_gains","NodeId":"287d2cb0-f53c-4101-bdf8-104b137c8601-43","OutputType":null},{"Name":"m_lazy_run","NodeId":"287d2cb0-f53c-4101-bdf8-104b137c8601-43","OutputType":null}],"UsePreviousResults":true,"moduleIdForCode":8,"Comment":"","CommentCollapsed":true},{"Id":"-2639","ModuleId":"BigQuantSpace.instruments.instruments-v2","ModuleParameters":[{"Name":"start_date","Value":"2016-01-01","ValueType":"Literal","LinkedGlobalParameter":null},{"Name":"end_date","Value":"2018-01-22","ValueType":"Literal","LinkedGlobalParameter":null},{"Name":"market","Value":"CN_STOCK_A","ValueType":"Literal","LinkedGlobalParameter":null},{"Name":"instrument_list","Value":"600000.SHA\n600010.SHA\n600015.SHA\n600016.SHA\n600018.SHA\n600028.SHA\n600029.SHA\n600030.SHA\n600036.SHA\n600048.SHA\n600050.SHA\n600089.SHA\n600100.SHA\n600104.SHA\n600109.SHA\n600111.SHA\n600150.SHA\n600196.SHA\n600256.SHA\n600332.SHA\n600340.SHA\n600372.SHA\n600406.SHA\n600485.SHA\n600518.SHA\n600519.SHA\n600547.SHA\n600583.SHA\n600585.SHA\n600606.SHA\n600637.SHA\n600690.SHA\n600703.SHA\n600795.SHA\n600832.SHA\n600837.SHA\n600887.SHA\n600893.SHA\n600919.SHA\n600958.SHA\n600999.SHA\n601006.SHA\n601088.SHA\n601118.SHA\n601166.SHA\n601169.SHA\n601186.SHA\n601198.SHA\n601211.SHA\n601229.SHA\n601288.SHA\n601299.SHA\n601318.SHA\n601328.SHA\n601336.SHA\n601377.SHA\n601390.SHA\n601398.SHA\n601601.SHA\n601628.SHA\n601668.SHA\n601669.SHA\n601688.SHA\n601727.SHA\n601766.SHA\n601788.SHA\n601800.SHA\n601818.SHA\n601857.SHA\n601881.SHA\n601901.SHA\n601919.SHA\n601985.SHA\n601988.SHA\n601989.SHA\n601998.SHA","ValueType":"Literal","LinkedGlobalParameter":null},{"Name":"max_count","Value":0,"ValueType":"Literal","LinkedGlobalParameter":null}],"InputPortsInternal":[{"DataSourceId":null,"TrainedModelId":null,"TransformModuleId":null,"Name":"rolling_conf","NodeId":"-2639"}],"OutputPortsInternal":[{"Name":"data","NodeId":"-2639","OutputType":null}],"UsePreviousResults":true,"moduleIdForCode":10,"Comment":"","CommentCollapsed":true},{"Id":"-2648","ModuleId":"BigQuantSpace.general_feature_extractor.general_feature_extractor-v6","ModuleParameters":[{"Name":"start_date","Value":"","ValueType":"Literal","LinkedGlobalParameter":null},{"Name":"end_date","Value":"","ValueType":"Literal","LinkedGlobalParameter":null},{"Name":"before_start_days","Value":0,"ValueType":"Literal","LinkedGlobalParameter":null}],"InputPortsInternal":[{"DataSourceId":null,"TrainedModelId":null,"TransformModuleId":null,"Name":"instruments","NodeId":"-2648"},{"DataSourceId":null,"TrainedModelId":null,"TransformModuleId":null,"Name":"features","NodeId":"-2648"}],"OutputPortsInternal":[{"Name":"data","NodeId":"-2648","OutputType":null}],"UsePreviousResults":true,"moduleIdForCode":11,"Comment":"","CommentCollapsed":true},{"Id":"-2663","ModuleId":"BigQuantSpace.derived_feature_extractor.derived_feature_extractor-v2","ModuleParameters":[{"Name":"date_col","Value":"date","ValueType":"Literal","LinkedGlobalParameter":null},{"Name":"instrument_col","Value":"instrument","ValueType":"Literal","LinkedGlobalParameter":null},{"Name":"user_functions","Value":"def calcu_relative_ret(df):\n start_date = min(m11.data.read_df().date).strftime('%Y-%m-%d')\n end_date = max(m11.data.read_df().date).strftime('%Y-%m-%d')\n \n sz50_df = D.history_data(\n '000016.SHA',\n start_date=(pd.to_datetime(start_date) - datetime.timedelta(days=10)).strftime('%Y-%m-%d'), # 多取几天的数据\n end_date=end_date)[['date', 'close']].rename(columns={'close': 'sz50_close'})\n df = df[['date', 'close_0']].reset_index().merge(sz50_df, on='date', how='left').set_index('index')\n return df['close_0'].pct_change() - df['sz50_close'].pct_change()\n\ndef groupby_calcu_relative_ret(df, close_0):\n return df.groupby('instrument', group_keys=False).apply(calcu_relative_ret)\n\nbigquant_run = {\n 'groupby_calcu_relative_ret': groupby_calcu_relative_ret\n}\n\n","ValueType":"Literal","LinkedGlobalParameter":null}],"InputPortsInternal":[{"DataSourceId":null,"TrainedModelId":null,"TransformModuleId":null,"Name":"input_data","NodeId":"-2663"},{"DataSourceId":null,"TrainedModelId":null,"TransformModuleId":null,"Name":"features","NodeId":"-2663"}],"OutputPortsInternal":[{"Name":"data","NodeId":"-2663","OutputType":null}],"UsePreviousResults":false,"moduleIdForCode":12,"Comment":"在衍生特征里配置自定义函数就可以了,也可以覆盖同名的预定义函数","CommentCollapsed":true},{"Id":"-2669","ModuleId":"BigQuantSpace.dropnan.dropnan-v1","ModuleParameters":[],"InputPortsInternal":[{"DataSourceId":null,"TrainedModelId":null,"TransformModuleId":null,"Name":"input_data","NodeId":"-2669"}],"OutputPortsInternal":[{"Name":"data","NodeId":"-2669","OutputType":null}],"UsePreviousResults":true,"moduleIdForCode":13,"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":14,"Comment":"","CommentCollapsed":true},{"Id":"287d2cb0-f53c-4101-bdf8-104b137c8601-81","ModuleId":"BigQuantSpace.trade.trade-v3","ModuleParameters":[{"Name":"start_date","Value":"","ValueType":"Literal","LinkedGlobalParameter":null},{"Name":"end_date","Value":"","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.perf_tracker.position_tracker.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.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. 生成买入订单:按机器学习算法预测的排序,买入前面的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":"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":"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":"benchmark","Value":"000300.SHA","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":"plot_charts","Value":"True","ValueType":"Literal","LinkedGlobalParameter":null},{"Name":"backtest_only","Value":"False","ValueType":"Literal","LinkedGlobalParameter":null},{"Name":"amount_integer","Value":"False","ValueType":"Literal","LinkedGlobalParameter":null}],"InputPortsInternal":[{"DataSourceId":null,"TrainedModelId":null,"TransformModuleId":null,"Name":"instruments","NodeId":"287d2cb0-f53c-4101-bdf8-104b137c8601-81"},{"DataSourceId":null,"TrainedModelId":null,"TransformModuleId":null,"Name":"options_data","NodeId":"287d2cb0-f53c-4101-bdf8-104b137c8601-81"}],"OutputPortsInternal":[{"Name":"raw_perf","NodeId":"287d2cb0-f53c-4101-bdf8-104b137c8601-81","OutputType":null}],"UsePreviousResults":false,"moduleIdForCode":15,"Comment":"","CommentCollapsed":true},{"Id":"-4129","ModuleId":"BigQuantSpace.instruments.instruments-v2","ModuleParameters":[{"Name":"start_date","Value":"2011-01-01","ValueType":"Literal","LinkedGlobalParameter":null},{"Name":"end_date","Value":"2016-01-01","ValueType":"Literal","LinkedGlobalParameter":null},{"Name":"market","Value":"CN_STOCK_A","ValueType":"Literal","LinkedGlobalParameter":null},{"Name":"instrument_list","Value":"600000.SHA\n600010.SHA\n600015.SHA\n600016.SHA\n600018.SHA\n600028.SHA\n600029.SHA\n600030.SHA\n600036.SHA\n600048.SHA\n600050.SHA\n600089.SHA\n600100.SHA\n600104.SHA\n600109.SHA\n600111.SHA\n600150.SHA\n600196.SHA\n600256.SHA\n600332.SHA\n600340.SHA\n600372.SHA\n600406.SHA\n600485.SHA\n600518.SHA\n600519.SHA\n600547.SHA\n600583.SHA\n600585.SHA\n600606.SHA\n600637.SHA\n600690.SHA\n600703.SHA\n600795.SHA\n600832.SHA\n600837.SHA\n600887.SHA\n600893.SHA\n600919.SHA\n600958.SHA\n600999.SHA\n601006.SHA\n601088.SHA\n601118.SHA\n601166.SHA\n601169.SHA\n601186.SHA\n601198.SHA\n601211.SHA\n601229.SHA\n601288.SHA\n601299.SHA\n601318.SHA\n601328.SHA\n601336.SHA\n601377.SHA\n601390.SHA\n601398.SHA\n601601.SHA\n601628.SHA\n601668.SHA\n601669.SHA\n601688.SHA\n601727.SHA\n601766.SHA\n601788.SHA\n601800.SHA\n601818.SHA\n601857.SHA\n601881.SHA\n601901.SHA\n601919.SHA\n601985.SHA\n601988.SHA\n601989.SHA\n601998.SHA","ValueType":"Literal","LinkedGlobalParameter":null},{"Name":"max_count","Value":0,"ValueType":"Literal","LinkedGlobalParameter":null}],"InputPortsInternal":[{"DataSourceId":null,"TrainedModelId":null,"TransformModuleId":null,"Name":"rolling_conf","NodeId":"-4129"}],"OutputPortsInternal":[{"Name":"data","NodeId":"-4129","OutputType":null}],"UsePreviousResults":true,"moduleIdForCode":18,"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='-315' Position='198,-141,200,200'/><NodePosition Node='-26' Position='-38.6088285446167,64.16470336914062,200,200'/><NodePosition Node='-2119' Position='-39.65784311294556,-26.556861877441406,200,200'/><NodePosition Node='-2125' Position='-399.6960754394531,59.39116668701172,200,200'/><NodePosition Node='287d2cb0-f53c-4101-bdf8-104b137c8601-53' Position='-278.3049125671387,196.02450561523438,200,200'/><NodePosition Node='287d2cb0-f53c-4101-bdf8-104b137c8601-84' Position='-88.45490264892578,284.8980407714844,200,200'/><NodePosition Node='287d2cb0-f53c-4101-bdf8-104b137c8601-43' Position='49.56959533691406,400.8097839355469,200,200'/><NodePosition Node='-2639' Position='765,-66,200,200'/><NodePosition Node='-2648' Position='765,48,200,200'/><NodePosition Node='-2663' Position='762,158,200,200'/><NodePosition Node='-2669' Position='739.1657104492188,300.73333740234375,200,200'/><NodePosition Node='287d2cb0-f53c-4101-bdf8-104b137c8601-60' Position='301,520,200,200'/><NodePosition Node='287d2cb0-f53c-4101-bdf8-104b137c8601-81' Position='551,583,200,200'/><NodePosition Node='-4129' Position='-270,-146,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 [1]:
    # 本代码由可视化策略环境自动生成 2018年3月30日 21:22
    # 本代码单元只能在可视化模式下编辑。您也可以拷贝代码,粘贴到新建的代码单元或者策略,然后修改。
    
    
    m1 = M.input_features.v1(
        features="""return_5
    return_10
    return_20
    volume_0/mean(close_0,3)
    avg_amount_0/avg_amount_5  
    avg_amount_5/avg_amount_10  
    sum(mf_net_amount_xl_0, 5) 
    sum(mf_net_amount_l_0, 5)
    close_0
    market_cap_float_0
    groupby_calcu_relative_ret(close_0)
    
     
    """
    )
    
    m10 = M.instruments.v2(
        start_date='2016-01-01',
        end_date='2018-01-22',
        market='CN_STOCK_A',
        instrument_list="""600000.SHA
    600010.SHA
    600015.SHA
    600016.SHA
    600018.SHA
    600028.SHA
    600029.SHA
    600030.SHA
    600036.SHA
    600048.SHA
    600050.SHA
    600089.SHA
    600100.SHA
    600104.SHA
    600109.SHA
    600111.SHA
    600150.SHA
    600196.SHA
    600256.SHA
    600332.SHA
    600340.SHA
    600372.SHA
    600406.SHA
    600485.SHA
    600518.SHA
    600519.SHA
    600547.SHA
    600583.SHA
    600585.SHA
    600606.SHA
    600637.SHA
    600690.SHA
    600703.SHA
    600795.SHA
    600832.SHA
    600837.SHA
    600887.SHA
    600893.SHA
    600919.SHA
    600958.SHA
    600999.SHA
    601006.SHA
    601088.SHA
    601118.SHA
    601166.SHA
    601169.SHA
    601186.SHA
    601198.SHA
    601211.SHA
    601229.SHA
    601288.SHA
    601299.SHA
    601318.SHA
    601328.SHA
    601336.SHA
    601377.SHA
    601390.SHA
    601398.SHA
    601601.SHA
    601628.SHA
    601668.SHA
    601669.SHA
    601688.SHA
    601727.SHA
    601766.SHA
    601788.SHA
    601800.SHA
    601818.SHA
    601857.SHA
    601881.SHA
    601901.SHA
    601919.SHA
    601985.SHA
    601988.SHA
    601989.SHA
    601998.SHA""",
        max_count=0
    )
    
    m11 = M.general_feature_extractor.v6(
        instruments=m10.data,
        features=m1.data,
        start_date='',
        end_date='',
        before_start_days=0
    )
    
    def calcu_relative_ret(df):
        start_date = min(m11.data.read_df().date).strftime('%Y-%m-%d')
        end_date = max(m11.data.read_df().date).strftime('%Y-%m-%d')
       
        sz50_df = D.history_data(
        '000016.SHA',
        start_date=(pd.to_datetime(start_date) - datetime.timedelta(days=10)).strftime('%Y-%m-%d'),  # 多取几天的数据
        end_date=end_date)[['date', 'close']].rename(columns={'close': 'sz50_close'})
        df = df[['date', 'close_0']].reset_index().merge(sz50_df, on='date', how='left').set_index('index')
        return df['close_0'].pct_change() - df['sz50_close'].pct_change()
    
    def groupby_calcu_relative_ret(df, close_0):
        return df.groupby('instrument', group_keys=False).apply(calcu_relative_ret)
    
    m12_user_functions_bigquant_run = {
        'groupby_calcu_relative_ret':  groupby_calcu_relative_ret
    }
    
    
    m12 = M.derived_feature_extractor.v2(
        input_data=m11.data,
        features=m1.data,
        date_col='date',
        instrument_col='instrument',
        user_functions=m12_user_functions_bigquant_run,
        m_cached=False
    )
    
    m13 = M.dropnan.v1(
        input_data=m12.data
    )
    
    m18 = M.instruments.v2(
        start_date='2011-01-01',
        end_date='2016-01-01',
        market='CN_STOCK_A',
        instrument_list="""600000.SHA
    600010.SHA
    600015.SHA
    600016.SHA
    600018.SHA
    600028.SHA
    600029.SHA
    600030.SHA
    600036.SHA
    600048.SHA
    600050.SHA
    600089.SHA
    600100.SHA
    600104.SHA
    600109.SHA
    600111.SHA
    600150.SHA
    600196.SHA
    600256.SHA
    600332.SHA
    600340.SHA
    600372.SHA
    600406.SHA
    600485.SHA
    600518.SHA
    600519.SHA
    600547.SHA
    600583.SHA
    600585.SHA
    600606.SHA
    600637.SHA
    600690.SHA
    600703.SHA
    600795.SHA
    600832.SHA
    600837.SHA
    600887.SHA
    600893.SHA
    600919.SHA
    600958.SHA
    600999.SHA
    601006.SHA
    601088.SHA
    601118.SHA
    601166.SHA
    601169.SHA
    601186.SHA
    601198.SHA
    601211.SHA
    601229.SHA
    601288.SHA
    601299.SHA
    601318.SHA
    601328.SHA
    601336.SHA
    601377.SHA
    601390.SHA
    601398.SHA
    601601.SHA
    601628.SHA
    601668.SHA
    601669.SHA
    601688.SHA
    601727.SHA
    601766.SHA
    601788.SHA
    601800.SHA
    601818.SHA
    601857.SHA
    601881.SHA
    601901.SHA
    601919.SHA
    601985.SHA
    601988.SHA
    601989.SHA
    601998.SHA""",
        max_count=0
    )
    
    m4 = M.general_feature_extractor.v6(
        instruments=m18.data,
        features=m1.data,
        start_date='',
        end_date='',
        m_cached=False
    )
    
    def calcu_relative_ret(df):
        start_date = min(m4.data.read_df().date).strftime('%Y-%m-%d')
        end_date = max(m4.data.read_df().date).strftime('%Y-%m-%d')
        hs800_df = D.history_data(
        '000016.SHA',
        start_date=(pd.to_datetime(start_date) - datetime.timedelta(days=10)).strftime('%Y-%m-%d'),  # 多取几天的数据
        end_date=end_date)[['date', 'close']].rename(columns={'close': 'hs800_close'})
        df = df[['date', 'close_0']].reset_index().merge(hs800_df, on='date', how='left').set_index('index')
        return df['close_0'].pct_change() - df['hs800_close'].pct_change()
    
    def groupby_calcu_relative_ret(df, close_0):
        return df.groupby('instrument', group_keys=False).apply(calcu_relative_ret)
    
    m2_user_functions_bigquant_run = {
        'groupby_calcu_relative_ret':  groupby_calcu_relative_ret
    }
    
    
    m2 = M.derived_feature_extractor.v2(
        input_data=m4.data,
        features=m1.data,
        date_col='date',
        instrument_col='instrument',
        user_functions=m2_user_functions_bigquant_run
    )
    
    m5 = M.advanced_auto_labeler.v2(
        instruments=m18.data,
        label_expr="""# #号开始的表示注释
    # 0. 每行一个,顺序执行,从第二个开始,可以使用label字段
    # 1. 可用数据字段见 https://bigquant.com/docs/data_history_data.html
    #   添加benchmark_前缀,可使用对应的benchmark数据
    # 2. 可用操作符和函数见 `表达式引擎 <https://bigquant.com/docs/big_expr.html>`_
    
    # 计算收益:5日收盘价(作为卖出价格)除以明日开盘价(作为买入价格)
    shift(close, -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,
        user_functions={}
    )
    
    m6 = M.join.v3(
        data1=m5.data,
        data2=m2.data,
        on='date,instrument',
        how='inner',
        sort=False
    )
    
    m7 = M.dropnan.v1(
        input_data=m6.data
    )
    
    m8 = M.stock_ranker_train.v5(
        training_ds=m7.data,
        features=m1.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,
        m_lazy_run=False
    )
    
    m14 = M.stock_ranker_predict.v5(
        model=m8.model,
        data=m13.data,
        m_lazy_run=False
    )
    
    # 回测引擎:每日数据处理函数,每天执行一次
    def m15_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.perf_tracker.position_tracker.positions.items()}
    
        # 2. 生成卖出订单:hold_days天之后才开始卖出;对持仓的股票,按机器学习算法预测的排序末位淘汰
        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. 生成买入订单:按机器学习算法预测的排序,买入前面的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 m15_prepare_bigquant_run(context):
        pass
    
    # 回测引擎:初始化函数,只执行一次
    def m15_initialize_bigquant_run(context):
        # 加载预测数据
        context.ranker_prediction = context.options['data'].read_df()
    
        # 系统已经设置了默认的交易手续费和滑点,要修改手续费可使用如下函数
        context.set_commission(PerOrder(buy_cost=0.0003, sell_cost=0.0013, min_cost=5))
        # 预测数据,通过options传入进来,使用 read_df 函数,加载到内存 (DataFrame)
        # 设置买入的股票数量,这里买入预测股票列表排名靠前的5只
        stock_count = 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
    
    m15 = M.trade.v3(
        instruments=m10.data,
        options_data=m14.predictions,
        start_date='',
        end_date='',
        handle_data=m15_handle_data_bigquant_run,
        prepare=m15_prepare_bigquant_run,
        initialize=m15_initialize_bigquant_run,
        volume_limit=0.025,
        order_price_field_buy='open',
        order_price_field_sell='close',
        capital_base=1000000,
        benchmark='000300.SHA',
        auto_cancel_non_tradable_orders=True,
        data_frequency='daily',
        price_type='后复权',
        plot_charts=True,
        backtest_only=False,
        amount_integer=False
    )
    
    [2018-03-30 21:08:45.163243] INFO: bigquant: input_features.v1 开始运行..
    [2018-03-30 21:08:45.174400] INFO: bigquant: 命中缓存
    [2018-03-30 21:08:45.178868] INFO: bigquant: input_features.v1 运行完成[0.015629s].
    [2018-03-30 21:08:45.206212] INFO: bigquant: instruments.v2 开始运行..
    [2018-03-30 21:08:45.214191] INFO: bigquant: 命中缓存
    [2018-03-30 21:08:45.221861] INFO: bigquant: instruments.v2 运行完成[0.015638s].
    [2018-03-30 21:08:45.268631] INFO: bigquant: general_feature_extractor.v6 开始运行..
    [2018-03-30 21:08:45.291510] INFO: bigquant: 命中缓存
    [2018-03-30 21:08:45.298167] INFO: bigquant: general_feature_extractor.v6 运行完成[0.029525s].
    [2018-03-30 21:08:45.443384] INFO: bigquant: derived_feature_extractor.v2 开始运行..
    [2018-03-30 21:08:45.623471] INFO: derived_feature_extractor: 提取完成 avg_amount_0/avg_amount_5, 0.003s
    [2018-03-30 21:08:45.649524] INFO: derived_feature_extractor: 提取完成 avg_amount_5/avg_amount_10, 0.020s
    [2018-03-30 21:09:57.022507] INFO: derived_feature_extractor: 提取完成 groupby_calcu_relative_ret(close_0), 71.368s
    [2018-03-30 21:09:57.134961] INFO: derived_feature_extractor: 提取完成 sum(mf_net_amount_l_0, 5), 0.108s
    [2018-03-30 21:09:57.229090] INFO: derived_feature_extractor: 提取完成 sum(mf_net_amount_xl_0, 5), 0.089s
    [2018-03-30 21:09:57.345239] INFO: derived_feature_extractor: 提取完成 volume_0/mean(close_0,3), 0.111s
    [2018-03-30 21:09:57.402170] INFO: derived_feature_extractor: /y_2016, 17155
    [2018-03-30 21:09:57.482627] INFO: derived_feature_extractor: /y_2017, 16909
    [2018-03-30 21:09:57.542675] INFO: derived_feature_extractor: /y_2018, 1076
    [2018-03-30 21:09:57.608338] INFO: bigquant: derived_feature_extractor.v2 运行完成[72.164912s].
    [2018-03-30 21:09:57.632427] INFO: bigquant: dropnan.v1 开始运行..
    [2018-03-30 21:09:57.764975] INFO: dropnan: /y_2016, 16829/17155
    [2018-03-30 21:09:57.854584] INFO: dropnan: /y_2017, 16888/16909
    [2018-03-30 21:09:57.895756] INFO: dropnan: /y_2018, 1076/1076
    [2018-03-30 21:09:57.913873] INFO: dropnan: 行数: 34793/35140
    [2018-03-30 21:09:57.920975] INFO: bigquant: dropnan.v1 运行完成[0.288558s].
    [2018-03-30 21:09:57.939770] INFO: bigquant: instruments.v2 开始运行..
    [2018-03-30 21:09:57.948634] INFO: bigquant: 命中缓存
    [2018-03-30 21:09:57.951015] INFO: bigquant: instruments.v2 运行完成[0.011288s].
    [2018-03-30 21:09:57.987980] INFO: bigquant: general_feature_extractor.v6 开始运行..
    [2018-03-30 21:10:07.883372] INFO: 基础特征抽取: 年份 2011, 特征行数=15656
    [2018-03-30 21:10:18.130522] INFO: 基础特征抽取: 年份 2012, 特征行数=16459
    [2018-03-30 21:10:29.598167] INFO: 基础特征抽取: 年份 2013, 特征行数=15819
    [2018-03-30 21:10:37.633337] INFO: 基础特征抽取: 年份 2014, 特征行数=16152
    [2018-03-30 21:10:39.224122] INFO: 基础特征抽取: 年份 2015, 特征行数=16623
    [2018-03-30 21:10:40.817968] INFO: 基础特征抽取: 年份 2016, 特征行数=0
    [2018-03-30 21:10:40.849430] INFO: 基础特征抽取: 总行数: 80709
    [2018-03-30 21:10:40.861046] INFO: bigquant: general_feature_extractor.v6 运行完成[42.873078s].
    [2018-03-30 21:10:40.884315] INFO: bigquant: derived_feature_extractor.v2 开始运行..
    [2018-03-30 21:10:41.234714] INFO: derived_feature_extractor: 提取完成 avg_amount_0/avg_amount_5, 0.003s
    [2018-03-30 21:10:41.249679] INFO: derived_feature_extractor: 提取完成 avg_amount_5/avg_amount_10, 0.004s
    [2018-03-30 21:13:04.375923] INFO: derived_feature_extractor: 提取完成 groupby_calcu_relative_ret(close_0), 143.119s
    [2018-03-30 21:13:04.617037] INFO: derived_feature_extractor: 提取完成 sum(mf_net_amount_l_0, 5), 0.236s
    [2018-03-30 21:13:04.881607] INFO: derived_feature_extractor: 提取完成 sum(mf_net_amount_xl_0, 5), 0.262s
    [2018-03-30 21:13:05.086697] INFO: derived_feature_extractor: 提取完成 volume_0/mean(close_0,3), 0.199s
    [2018-03-30 21:13:05.175794] INFO: derived_feature_extractor: /y_2011, 15656
    [2018-03-30 21:13:05.291658] INFO: derived_feature_extractor: /y_2012, 16459
    [2018-03-30 21:13:05.440102] INFO: derived_feature_extractor: /y_2013, 15819
    [2018-03-30 21:13:05.551309] INFO: derived_feature_extractor: /y_2014, 16152
    [2018-03-30 21:13:05.643774] INFO: derived_feature_extractor: /y_2015, 16623
    [2018-03-30 21:13:05.715938] INFO: bigquant: derived_feature_extractor.v2 运行完成[144.831565s].
    [2018-03-30 21:13:05.777937] INFO: bigquant: advanced_auto_labeler.v2 开始运行..
    [2018-03-30 21:13:05.788388] INFO: bigquant: 命中缓存
    [2018-03-30 21:13:05.793398] INFO: bigquant: advanced_auto_labeler.v2 运行完成[0.015488s].
    [2018-03-30 21:13:05.830759] INFO: bigquant: join.v3 开始运行..
    [2018-03-30 21:13:06.539925] INFO: join: /y_2011, 行数=15649/15656, 耗时=0.290966s
    [2018-03-30 21:13:06.848387] INFO: join: /y_2012, 行数=16455/16459, 耗时=0.297689s
    [2018-03-30 21:13:07.171129] INFO: join: /y_2013, 行数=15792/15819, 耗时=0.31267s
    [2018-03-30 21:13:07.475021] INFO: join: /y_2014, 行数=16124/16152, 耗时=0.288851s
    [2018-03-30 21:13:07.664640] INFO: join: /y_2015, 行数=16175/16623, 耗时=0.184999s
    [2018-03-30 21:13:07.707003] INFO: join: 最终行数: 80195
    [2018-03-30 21:13:07.716680] INFO: bigquant: join.v3 运行完成[1.885905s].
    [2018-03-30 21:13:07.758758] INFO: bigquant: dropnan.v1 开始运行..
    [2018-03-30 21:13:08.274079] INFO: dropnan: /y_2011, 15321/15649
    [2018-03-30 21:13:08.557115] INFO: dropnan: /y_2012, 16424/16455
    [2018-03-30 21:13:08.770794] INFO: dropnan: /y_2013, 15792/15792
    [2018-03-30 21:13:08.958480] INFO: dropnan: /y_2014, 16124/16124
    [2018-03-30 21:13:09.072641] INFO: dropnan: /y_2015, 16113/16175
    [2018-03-30 21:13:09.094029] INFO: dropnan: 行数: 79774/80195
    [2018-03-30 21:13:09.101934] INFO: bigquant: dropnan.v1 运行完成[1.343171s].
    [2018-03-30 21:13:09.158647] INFO: bigquant: stock_ranker_train.v5 开始运行..
    [2018-03-30 21:13:10.219299] INFO: df2bin: prepare bins ..
    [2018-03-30 21:13:10.422291] INFO: df2bin: prepare data: training ..
    [2018-03-30 21:13:10.715362] INFO: df2bin: sort ..
    [2018-03-30 21:13:12.930695] INFO: stock_ranker_train: 176f341a 准备训练: 79774 行数
    [2018-03-30 21:13:17.554934] INFO: bigquant: stock_ranker_train.v5 运行完成[8.396265s].
    [2018-03-30 21:13:17.621703] INFO: bigquant: stock_ranker_predict.v5 开始运行..
    [2018-03-30 21:13:18.071319] INFO: df2bin: prepare data: prediction ..
    [2018-03-30 21:13:19.356035] INFO: stock_ranker_predict: 准备预测: 34793 行
    [2018-03-30 21:13:22.210223] INFO: bigquant: stock_ranker_predict.v5 运行完成[4.588495s].
    [2018-03-30 21:13:22.359734] INFO: bigquant: backtest.v7 开始运行..
    [2018-03-30 21:13:22.627019] INFO: algo: set price type:backward_adjusted
    [2018-03-30 21:13:42.756797] INFO: Performance: Simulated 503 trading days out of 503.
    [2018-03-30 21:13:42.761346] INFO: Performance: first open: 2016-01-04 01:30:00+00:00
    [2018-03-30 21:13:42.763123] INFO: Performance: last close: 2018-01-22 07:00:00+00:00
    
    • 收益率52.07%
    • 年化收益率23.37%
    • 基准收益率16.23%
    • 阿尔法0.16
    • 贝塔0.87
    • 夏普比率0.95
    • 胜率0.572
    • 盈亏比1.242
    • 收益波动率19.88%
    • 信息比率1.16
    • 最大回撤16.04%
    [2018-03-30 21:13:50.964857] INFO: bigquant: backtest.v7 运行完成[28.605077s].
    
    In [ ]: