策略报错,求助,如何在AI可视策略里用跟踪止损代码

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

(yilong10) #1
克隆策略

    {"Description":"实验创建于2017/8/26","Summary":"","Graph":{"EdgesInternal":[{"DestinationInputPortId":"287d2cb0-f53c-4101-bdf8-104b137c8601-15:instruments","SourceOutputPortId":"287d2cb0-f53c-4101-bdf8-104b137c8601-8:data"},{"DestinationInputPortId":"287d2cb0-f53c-4101-bdf8-104b137c8601-29:instruments","SourceOutputPortId":"287d2cb0-f53c-4101-bdf8-104b137c8601-8:data"},{"DestinationInputPortId":"287d2cb0-f53c-4101-bdf8-104b137c8601-53:data1","SourceOutputPortId":"287d2cb0-f53c-4101-bdf8-104b137c8601-15:data"},{"DestinationInputPortId":"287d2cb0-f53c-4101-bdf8-104b137c8601-29:features","SourceOutputPortId":"287d2cb0-f53c-4101-bdf8-104b137c8601-24:data"},{"DestinationInputPortId":"287d2cb0-f53c-4101-bdf8-104b137c8601-35:features","SourceOutputPortId":"287d2cb0-f53c-4101-bdf8-104b137c8601-24:data"},{"DestinationInputPortId":"287d2cb0-f53c-4101-bdf8-104b137c8601-76:features","SourceOutputPortId":"287d2cb0-f53c-4101-bdf8-104b137c8601-24:data"},{"DestinationInputPortId":"287d2cb0-f53c-4101-bdf8-104b137c8601-43:features","SourceOutputPortId":"287d2cb0-f53c-4101-bdf8-104b137c8601-24:data"},{"DestinationInputPortId":"287d2cb0-f53c-4101-bdf8-104b137c8601-70:features","SourceOutputPortId":"287d2cb0-f53c-4101-bdf8-104b137c8601-24:data"},{"DestinationInputPortId":"287d2cb0-f53c-4101-bdf8-104b137c8601-35:input_data","SourceOutputPortId":"287d2cb0-f53c-4101-bdf8-104b137c8601-29:data"},{"DestinationInputPortId":"287d2cb0-f53c-4101-bdf8-104b137c8601-53:data2","SourceOutputPortId":"287d2cb0-f53c-4101-bdf8-104b137c8601-35:data"},{"DestinationInputPortId":"287d2cb0-f53c-4101-bdf8-104b137c8601-60:model","SourceOutputPortId":"287d2cb0-f53c-4101-bdf8-104b137c8601-43:model"},{"DestinationInputPortId":"287d2cb0-f53c-4101-bdf8-104b137c8601-84:input_data","SourceOutputPortId":"287d2cb0-f53c-4101-bdf8-104b137c8601-53:data"},{"DestinationInputPortId":"287d2cb0-f53c-4101-bdf8-104b137c8601-81:options_data","SourceOutputPortId":"287d2cb0-f53c-4101-bdf8-104b137c8601-60:predictions"},{"DestinationInputPortId":"287d2cb0-f53c-4101-bdf8-104b137c8601-70:instruments","SourceOutputPortId":"287d2cb0-f53c-4101-bdf8-104b137c8601-62:data"},{"DestinationInputPortId":"287d2cb0-f53c-4101-bdf8-104b137c8601-81:instruments","SourceOutputPortId":"287d2cb0-f53c-4101-bdf8-104b137c8601-62:data"},{"DestinationInputPortId":"287d2cb0-f53c-4101-bdf8-104b137c8601-76:input_data","SourceOutputPortId":"287d2cb0-f53c-4101-bdf8-104b137c8601-70:data"},{"DestinationInputPortId":"-86:input_data","SourceOutputPortId":"287d2cb0-f53c-4101-bdf8-104b137c8601-76: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:data","SourceOutputPortId":"-86:data"}],"ModuleNodes":[{"Id":"287d2cb0-f53c-4101-bdf8-104b137c8601-8","ModuleId":"BigQuantSpace.instruments.instruments-v2","ModuleParameters":[{"Name":"start_date","Value":"2010-01-01","ValueType":"Literal","LinkedGlobalParameter":null},{"Name":"end_date","Value":"2015-01-01","ValueType":"Literal","LinkedGlobalParameter":null},{"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-8"}],"OutputPortsInternal":[{"Name":"data","NodeId":"287d2cb0-f53c-4101-bdf8-104b137c8601-8","OutputType":null}],"UsePreviousResults":true,"moduleIdForCode":1,"IsPartOfPartialRun":null,"Comment":"","CommentCollapsed":true},{"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/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":"287d2cb0-f53c-4101-bdf8-104b137c8601-15"}],"OutputPortsInternal":[{"Name":"data","NodeId":"287d2cb0-f53c-4101-bdf8-104b137c8601-15","OutputType":null}],"UsePreviousResults":true,"moduleIdForCode":2,"IsPartOfPartialRun":null,"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,"IsPartOfPartialRun":null,"Comment":"","CommentCollapsed":true},{"Id":"287d2cb0-f53c-4101-bdf8-104b137c8601-29","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":"287d2cb0-f53c-4101-bdf8-104b137c8601-29"},{"DataSourceId":null,"TrainedModelId":null,"TransformModuleId":null,"Name":"features","NodeId":"287d2cb0-f53c-4101-bdf8-104b137c8601-29"}],"OutputPortsInternal":[{"Name":"data","NodeId":"287d2cb0-f53c-4101-bdf8-104b137c8601-29","OutputType":null}],"UsePreviousResults":true,"moduleIdForCode":4,"IsPartOfPartialRun":null,"Comment":"","CommentCollapsed":true},{"Id":"287d2cb0-f53c-4101-bdf8-104b137c8601-35","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":"","ValueType":"Literal","LinkedGlobalParameter":null}],"InputPortsInternal":[{"DataSourceId":null,"TrainedModelId":null,"TransformModuleId":null,"Name":"input_data","NodeId":"287d2cb0-f53c-4101-bdf8-104b137c8601-35"},{"DataSourceId":null,"TrainedModelId":null,"TransformModuleId":null,"Name":"features","NodeId":"287d2cb0-f53c-4101-bdf8-104b137c8601-35"}],"OutputPortsInternal":[{"Name":"data","NodeId":"287d2cb0-f53c-4101-bdf8-104b137c8601-35","OutputType":null}],"UsePreviousResults":true,"moduleIdForCode":5,"IsPartOfPartialRun":null,"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":6,"IsPartOfPartialRun":null,"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,"IsPartOfPartialRun":null,"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,"IsPartOfPartialRun":null,"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,"IsPartOfPartialRun":null,"Comment":"预测数据,用于回测和模拟","CommentCollapsed":false},{"Id":"287d2cb0-f53c-4101-bdf8-104b137c8601-70","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":"287d2cb0-f53c-4101-bdf8-104b137c8601-70"},{"DataSourceId":null,"TrainedModelId":null,"TransformModuleId":null,"Name":"features","NodeId":"287d2cb0-f53c-4101-bdf8-104b137c8601-70"}],"OutputPortsInternal":[{"Name":"data","NodeId":"287d2cb0-f53c-4101-bdf8-104b137c8601-70","OutputType":null}],"UsePreviousResults":true,"moduleIdForCode":10,"IsPartOfPartialRun":null,"Comment":"","CommentCollapsed":true},{"Id":"287d2cb0-f53c-4101-bdf8-104b137c8601-76","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":"","ValueType":"Literal","LinkedGlobalParameter":null}],"InputPortsInternal":[{"DataSourceId":null,"TrainedModelId":null,"TransformModuleId":null,"Name":"input_data","NodeId":"287d2cb0-f53c-4101-bdf8-104b137c8601-76"},{"DataSourceId":null,"TrainedModelId":null,"TransformModuleId":null,"Name":"features","NodeId":"287d2cb0-f53c-4101-bdf8-104b137c8601-76"}],"OutputPortsInternal":[{"Name":"data","NodeId":"287d2cb0-f53c-4101-bdf8-104b137c8601-76","OutputType":null}],"UsePreviousResults":true,"moduleIdForCode":11,"IsPartOfPartialRun":null,"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#------------------------------------------止损模块START--------------------------------------------\n today = data.current_dt \n equities = {e.symbol: p for e, p in context.portfolio.positions.items() if p.amount>0}\n hold_days_record = context.options['hold_days']\n \n # 新建当日止损股票列表是为了handle_data 策略逻辑部分不再对该股票进行判断\n current_stoploss_stock = [] \n if len(equities) > 0:\n for i in equities.keys():\n stock_market_price = data.current(context.symbol(i), 'price') # 最新市场价格\n hold_days = context.trading_day_index - hold_days_record[i] # 通过记录的建仓时间点来计算持仓时间\n # 建仓以来的最高价\n highest_price_since_buy = data.history(context.symbol(i), 'high', int(hold_days), '1d').max()\n # 确定止损位置\n stoploss_line = highest_price_since_buy - highest_price_since_buy * 0.1\n record('止损位置', stoploss_line)\n # 如果价格下穿止损位置\n if stock_market_price < stoploss_line:\n context.order_target_percent(context.symbol(i), 0) \n current_stoploss_stock.append(i)\n print('日期:', today, '股票:', i, '出现止损状况') \n #-------------------------------------------止损模块END---------------------------------------------\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":12,"IsPartOfPartialRun":null,"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":13,"IsPartOfPartialRun":null,"Comment":"","CommentCollapsed":true},{"Id":"-86","ModuleId":"BigQuantSpace.dropnan.dropnan-v1","ModuleParameters":[],"InputPortsInternal":[{"DataSourceId":null,"TrainedModelId":null,"TransformModuleId":null,"Name":"input_data","NodeId":"-86"}],"OutputPortsInternal":[{"Name":"data","NodeId":"-86","OutputType":null}],"UsePreviousResults":true,"moduleIdForCode":14,"IsPartOfPartialRun":null,"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-8' Position='211,64,200,200'/><NodePosition Node='287d2cb0-f53c-4101-bdf8-104b137c8601-15' Position='70,183,200,200'/><NodePosition Node='287d2cb0-f53c-4101-bdf8-104b137c8601-24' Position='765,21,200,200'/><NodePosition Node='287d2cb0-f53c-4101-bdf8-104b137c8601-29' Position='381,188,200,200'/><NodePosition Node='287d2cb0-f53c-4101-bdf8-104b137c8601-35' Position='385,280,200,200'/><NodePosition Node='287d2cb0-f53c-4101-bdf8-104b137c8601-43' Position='638,561,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='287d2cb0-f53c-4101-bdf8-104b137c8601-70' Position='1078,236,200,200'/><NodePosition Node='287d2cb0-f53c-4101-bdf8-104b137c8601-76' Position='1081,327,200,200'/><NodePosition Node='287d2cb0-f53c-4101-bdf8-104b137c8601-81' Position='1037,751,200,200'/><NodePosition Node='287d2cb0-f53c-4101-bdf8-104b137c8601-84' Position='376,467,200,200'/><NodePosition Node='-86' Position='1078,418,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":false}
    In [1]:
    # 本代码由可视化策略环境自动生成 2018年4月25日 01:39
    # 本代码单元只能在可视化模式下编辑。您也可以拷贝代码,粘贴到新建的代码单元或者策略,然后修改。
    
    
    m1 = M.instruments.v2(
        start_date='2010-01-01',
        end_date='2015-01-01',
        market='CN_STOCK_A',
        instrument_list='',
        max_count=0
    )
    
    m2 = M.advanced_auto_labeler.v2(
        instruments=m1.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
    )
    
    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
    """
    )
    
    m4 = M.general_feature_extractor.v6(
        instruments=m1.data,
        features=m3.data,
        start_date='',
        end_date='',
        before_start_days=0
    )
    
    m5 = M.derived_feature_extractor.v2(
        input_data=m4.data,
        features=m3.data,
        date_col='date',
        instrument_col='instrument'
    )
    
    m7 = M.join.v3(
        data1=m2.data,
        data2=m5.data,
        on='date,instrument',
        how='inner',
        sort=False
    )
    
    m13 = M.dropnan.v1(
        input_data=m7.data
    )
    
    m6 = M.stock_ranker_train.v5(
        training_ds=m13.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,
        m_lazy_run=False
    )
    
    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
    )
    
    m10 = M.general_feature_extractor.v6(
        instruments=m9.data,
        features=m3.data,
        start_date='',
        end_date='',
        before_start_days=0
    )
    
    m11 = M.derived_feature_extractor.v2(
        input_data=m10.data,
        features=m3.data,
        date_col='date',
        instrument_col='instrument'
    )
    
    m14 = M.dropnan.v1(
        input_data=m11.data
    )
    
    m8 = M.stock_ranker_predict.v5(
        model=m6.model,
        data=m14.data,
        m_lazy_run=False
    )
    
    # 回测引擎:每日数据处理函数,每天执行一次
    def m12_handle_data_bigquant_run(context, data):
        # 按日期过滤得到今日的预测数据
        ranker_prediction = context.ranker_prediction[
            context.ranker_prediction.date == data.current_dt.strftime('%Y-%m-%d')]
    #------------------------------------------止损模块START--------------------------------------------
        today = data.current_dt  
        equities = {e.symbol: p for e, p in context.portfolio.positions.items() if p.amount>0}
        hold_days_record = context.options['hold_days']
        
        # 新建当日止损股票列表是为了handle_data 策略逻辑部分不再对该股票进行判断
        current_stoploss_stock = [] 
        if len(equities) > 0:
            for i in equities.keys():
                stock_market_price = data.current(context.symbol(i), 'price')  # 最新市场价格
                hold_days = context.trading_day_index - hold_days_record[i] # 通过记录的建仓时间点来计算持仓时间
                # 建仓以来的最高价
                highest_price_since_buy = data.history(context.symbol(i), 'high', int(hold_days), '1d').max()
                # 确定止损位置
                stoploss_line = highest_price_since_buy - highest_price_since_buy * 0.1
                record('止损位置', stoploss_line)
                # 如果价格下穿止损位置
                if stock_market_price < stoploss_line:
                    context.order_target_percent(context.symbol(i), 0)     
                    current_stoploss_stock.append(i)
                    print('日期:', today, '股票:', i, '出现止损状况')  
        #-------------------------------------------止损模块END---------------------------------------------
        
        # 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 m12_prepare_bigquant_run(context):
        pass
    
    # 回测引擎:初始化函数,只执行一次
    def m12_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
    
    m12 = M.trade.v3(
        instruments=m9.data,
        options_data=m8.predictions,
        start_date='',
        end_date='',
        handle_data=m12_handle_data_bigquant_run,
        prepare=m12_prepare_bigquant_run,
        initialize=m12_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-04-25 01:31:48.750688] INFO: bigquant: instruments.v2 开始运行..
    [2018-04-25 01:31:48.778765] INFO: bigquant: 命中缓存
    [2018-04-25 01:31:48.780030] INFO: bigquant: instruments.v2 运行完成[0.029342s].
    [2018-04-25 01:31:48.846647] INFO: bigquant: advanced_auto_labeler.v2 开始运行..
    [2018-04-25 01:31:48.872515] INFO: bigquant: 命中缓存
    [2018-04-25 01:31:48.874328] INFO: bigquant: advanced_auto_labeler.v2 运行完成[0.0277s].
    [2018-04-25 01:31:48.885912] INFO: bigquant: input_features.v1 开始运行..
    [2018-04-25 01:31:48.964216] INFO: bigquant: 命中缓存
    [2018-04-25 01:31:48.966096] INFO: bigquant: input_features.v1 运行完成[0.080152s].
    [2018-04-25 01:31:49.134131] INFO: bigquant: general_feature_extractor.v6 开始运行..
    [2018-04-25 01:31:49.157359] INFO: bigquant: 命中缓存
    [2018-04-25 01:31:49.158982] INFO: bigquant: general_feature_extractor.v6 运行完成[0.024887s].
    [2018-04-25 01:31:49.180425] INFO: bigquant: derived_feature_extractor.v2 开始运行..
    [2018-04-25 01:31:49.203298] INFO: bigquant: 命中缓存
    [2018-04-25 01:31:49.204867] INFO: bigquant: derived_feature_extractor.v2 运行完成[0.024467s].
    [2018-04-25 01:31:49.226956] INFO: bigquant: join.v3 开始运行..
    [2018-04-25 01:31:49.247198] INFO: bigquant: 命中缓存
    [2018-04-25 01:31:49.248653] INFO: bigquant: join.v3 运行完成[0.021746s].
    [2018-04-25 01:31:49.262966] INFO: bigquant: dropnan.v1 开始运行..
    [2018-04-25 01:31:49.285864] INFO: bigquant: 命中缓存
    [2018-04-25 01:31:49.287113] INFO: bigquant: dropnan.v1 运行完成[0.024179s].
    [2018-04-25 01:31:49.303369] INFO: bigquant: stock_ranker_train.v5 开始运行..
    [2018-04-25 01:31:49.338310] INFO: bigquant: 命中缓存
    [2018-04-25 01:31:49.339540] INFO: bigquant: stock_ranker_train.v5 运行完成[0.036192s].
    [2018-04-25 01:31:49.345485] INFO: bigquant: instruments.v2 开始运行..
    [2018-04-25 01:31:49.350792] INFO: bigquant: 命中缓存
    [2018-04-25 01:31:49.351829] INFO: bigquant: instruments.v2 运行完成[0.006361s].
    [2018-04-25 01:31:49.445027] INFO: bigquant: general_feature_extractor.v6 开始运行..
    [2018-04-25 01:31:49.449893] INFO: bigquant: 命中缓存
    [2018-04-25 01:31:49.451166] INFO: bigquant: general_feature_extractor.v6 运行完成[0.006185s].
    [2018-04-25 01:31:49.461134] INFO: bigquant: derived_feature_extractor.v2 开始运行..
    [2018-04-25 01:31:49.466310] INFO: bigquant: 命中缓存
    [2018-04-25 01:31:49.467570] INFO: bigquant: derived_feature_extractor.v2 运行完成[0.006436s].
    [2018-04-25 01:31:49.477031] INFO: bigquant: dropnan.v1 开始运行..
    [2018-04-25 01:31:49.481122] INFO: bigquant: 命中缓存
    [2018-04-25 01:31:49.482280] INFO: bigquant: dropnan.v1 运行完成[0.005262s].
    [2018-04-25 01:31:49.497424] INFO: bigquant: stock_ranker_predict.v5 开始运行..
    [2018-04-25 01:31:49.505693] INFO: bigquant: 命中缓存
    [2018-04-25 01:31:49.507033] INFO: bigquant: stock_ranker_predict.v5 运行完成[0.009614s].
    [2018-04-25 01:31:49.581982] INFO: bigquant: backtest.v7 开始运行..
    [2018-04-25 01:31:49.713072] INFO: algo: set price type:backward_adjusted
    
    ---------------------------------------------------------------------------
    TypeError                                 Traceback (most recent call last)
    <ipython-input-1-a0a71ffd2156> in <module>()
        230     plot_charts=True,
        231     backtest_only=False,
    --> 232     amount_integer=False
        233 )
    
    <ipython-input-1-a0a71ffd2156> in m12_handle_data_bigquant_run(context, data)
        145         for i in equities.keys():
        146             stock_market_price = data.current(context.symbol(i), 'price')  # 最新市场价格
    --> 147             hold_days = context.trading_day_index - hold_days_record[i] # 通过记录的建仓时间点来计算持仓时间
        148             # 建仓以来的最高价
        149             highest_price_since_buy = data.history(context.symbol(i), 'high', int(hold_days), '1d').max()
    
    TypeError: 'int' object is not subscriptable

    策略报错,求助,如何在AI可视策略里用跟踪止损代码


    我把止损代码放入但没有效果 可能是放的地方不对,或者哪里没有一起改动,
    希望能得到一个AI可视策略里用跟踪止损代码样例


    【宽客学院】策略止盈止损
    (iQuant) #2

    之所以报错是因为 hold_days_record 在你的代码中是数字5,不能取元素,因此报错。
    造成的原因应该是代码没有及时更新,你参考下面的代码即可。

    克隆策略

      {"Description":"实验创建于2017/8/26","Summary":"","Graph":{"EdgesInternal":[{"DestinationInputPortId":"287d2cb0-f53c-4101-bdf8-104b137c8601-15:instruments","SourceOutputPortId":"287d2cb0-f53c-4101-bdf8-104b137c8601-8:data"},{"DestinationInputPortId":"287d2cb0-f53c-4101-bdf8-104b137c8601-29:instruments","SourceOutputPortId":"287d2cb0-f53c-4101-bdf8-104b137c8601-8:data"},{"DestinationInputPortId":"287d2cb0-f53c-4101-bdf8-104b137c8601-53:data1","SourceOutputPortId":"287d2cb0-f53c-4101-bdf8-104b137c8601-15:data"},{"DestinationInputPortId":"287d2cb0-f53c-4101-bdf8-104b137c8601-29:features","SourceOutputPortId":"287d2cb0-f53c-4101-bdf8-104b137c8601-24:data"},{"DestinationInputPortId":"287d2cb0-f53c-4101-bdf8-104b137c8601-35:features","SourceOutputPortId":"287d2cb0-f53c-4101-bdf8-104b137c8601-24:data"},{"DestinationInputPortId":"287d2cb0-f53c-4101-bdf8-104b137c8601-76:features","SourceOutputPortId":"287d2cb0-f53c-4101-bdf8-104b137c8601-24:data"},{"DestinationInputPortId":"287d2cb0-f53c-4101-bdf8-104b137c8601-43:features","SourceOutputPortId":"287d2cb0-f53c-4101-bdf8-104b137c8601-24:data"},{"DestinationInputPortId":"287d2cb0-f53c-4101-bdf8-104b137c8601-70:features","SourceOutputPortId":"287d2cb0-f53c-4101-bdf8-104b137c8601-24:data"},{"DestinationInputPortId":"287d2cb0-f53c-4101-bdf8-104b137c8601-35:input_data","SourceOutputPortId":"287d2cb0-f53c-4101-bdf8-104b137c8601-29:data"},{"DestinationInputPortId":"287d2cb0-f53c-4101-bdf8-104b137c8601-53:data2","SourceOutputPortId":"287d2cb0-f53c-4101-bdf8-104b137c8601-35:data"},{"DestinationInputPortId":"287d2cb0-f53c-4101-bdf8-104b137c8601-60:model","SourceOutputPortId":"287d2cb0-f53c-4101-bdf8-104b137c8601-43:model"},{"DestinationInputPortId":"287d2cb0-f53c-4101-bdf8-104b137c8601-84:input_data","SourceOutputPortId":"287d2cb0-f53c-4101-bdf8-104b137c8601-53:data"},{"DestinationInputPortId":"287d2cb0-f53c-4101-bdf8-104b137c8601-81:options_data","SourceOutputPortId":"287d2cb0-f53c-4101-bdf8-104b137c8601-60:predictions"},{"DestinationInputPortId":"287d2cb0-f53c-4101-bdf8-104b137c8601-70:instruments","SourceOutputPortId":"287d2cb0-f53c-4101-bdf8-104b137c8601-62:data"},{"DestinationInputPortId":"287d2cb0-f53c-4101-bdf8-104b137c8601-81:instruments","SourceOutputPortId":"287d2cb0-f53c-4101-bdf8-104b137c8601-62:data"},{"DestinationInputPortId":"287d2cb0-f53c-4101-bdf8-104b137c8601-76:input_data","SourceOutputPortId":"287d2cb0-f53c-4101-bdf8-104b137c8601-70:data"},{"DestinationInputPortId":"-86:input_data","SourceOutputPortId":"287d2cb0-f53c-4101-bdf8-104b137c8601-76: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:data","SourceOutputPortId":"-86:data"}],"ModuleNodes":[{"Id":"287d2cb0-f53c-4101-bdf8-104b137c8601-8","ModuleId":"BigQuantSpace.instruments.instruments-v2","ModuleParameters":[{"Name":"start_date","Value":"2010-01-01","ValueType":"Literal","LinkedGlobalParameter":null},{"Name":"end_date","Value":"2015-01-01","ValueType":"Literal","LinkedGlobalParameter":null},{"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-8"}],"OutputPortsInternal":[{"Name":"data","NodeId":"287d2cb0-f53c-4101-bdf8-104b137c8601-8","OutputType":null}],"UsePreviousResults":true,"moduleIdForCode":1,"Comment":"","CommentCollapsed":true},{"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/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":"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-29","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":"287d2cb0-f53c-4101-bdf8-104b137c8601-29"},{"DataSourceId":null,"TrainedModelId":null,"TransformModuleId":null,"Name":"features","NodeId":"287d2cb0-f53c-4101-bdf8-104b137c8601-29"}],"OutputPortsInternal":[{"Name":"data","NodeId":"287d2cb0-f53c-4101-bdf8-104b137c8601-29","OutputType":null}],"UsePreviousResults":true,"moduleIdForCode":4,"Comment":"","CommentCollapsed":true},{"Id":"287d2cb0-f53c-4101-bdf8-104b137c8601-35","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":"","ValueType":"Literal","LinkedGlobalParameter":null}],"InputPortsInternal":[{"DataSourceId":null,"TrainedModelId":null,"TransformModuleId":null,"Name":"input_data","NodeId":"287d2cb0-f53c-4101-bdf8-104b137c8601-35"},{"DataSourceId":null,"TrainedModelId":null,"TransformModuleId":null,"Name":"features","NodeId":"287d2cb0-f53c-4101-bdf8-104b137c8601-35"}],"OutputPortsInternal":[{"Name":"data","NodeId":"287d2cb0-f53c-4101-bdf8-104b137c8601-35","OutputType":null}],"UsePreviousResults":true,"moduleIdForCode":5,"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":6,"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":"287d2cb0-f53c-4101-bdf8-104b137c8601-70","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":"287d2cb0-f53c-4101-bdf8-104b137c8601-70"},{"DataSourceId":null,"TrainedModelId":null,"TransformModuleId":null,"Name":"features","NodeId":"287d2cb0-f53c-4101-bdf8-104b137c8601-70"}],"OutputPortsInternal":[{"Name":"data","NodeId":"287d2cb0-f53c-4101-bdf8-104b137c8601-70","OutputType":null}],"UsePreviousResults":true,"moduleIdForCode":10,"Comment":"","CommentCollapsed":true},{"Id":"287d2cb0-f53c-4101-bdf8-104b137c8601-76","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":"","ValueType":"Literal","LinkedGlobalParameter":null}],"InputPortsInternal":[{"DataSourceId":null,"TrainedModelId":null,"TransformModuleId":null,"Name":"input_data","NodeId":"287d2cb0-f53c-4101-bdf8-104b137c8601-76"},{"DataSourceId":null,"TrainedModelId":null,"TransformModuleId":null,"Name":"features","NodeId":"287d2cb0-f53c-4101-bdf8-104b137c8601-76"}],"OutputPortsInternal":[{"Name":"data","NodeId":"287d2cb0-f53c-4101-bdf8-104b137c8601-76","OutputType":null}],"UsePreviousResults":true,"moduleIdForCode":11,"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#------------------------------------------止损模块START--------------------------------------------\n today = data.current_dt \n equities = {e.symbol: p for e, p in context.portfolio.positions.items() if p.amount>0}\n \n # 新建当日止损股票列表是为了handle_data 策略逻辑部分不再对该股票进行判断\n current_stoploss_stock = [] \n if len(equities) > 0:\n for i in equities.keys():\n stock_market_price = data.current(context.symbol(i), 'price') # 最新市场价格\n hold_days = context.trading_day_index - context.hold_days[i] # 通过记录的建仓时间点来计算持仓时间\n # 建仓以来的最高价\n highest_price_since_buy = data.history(context.symbol(i), 'high', int(hold_days), '1d').max()\n # 确定止损位置\n stoploss_line = highest_price_since_buy - highest_price_since_buy * 0.1\n record('止损位置', stoploss_line)\n # 如果价格下穿止损位置\n if stock_market_price < stoploss_line:\n context.order_target_percent(context.symbol(i), 0) \n current_stoploss_stock.append(i)\n print('日期:', today, '股票:', i, '出现止损状况') \n #-------------------------------------------止损模块END---------------------------------------------\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 context.hold_days[instrument] = context.trading_day_index\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 context.hold_days = {}\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":12,"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":13,"Comment":"","CommentCollapsed":true},{"Id":"-86","ModuleId":"BigQuantSpace.dropnan.dropnan-v1","ModuleParameters":[],"InputPortsInternal":[{"DataSourceId":null,"TrainedModelId":null,"TransformModuleId":null,"Name":"input_data","NodeId":"-86"}],"OutputPortsInternal":[{"Name":"data","NodeId":"-86","OutputType":null}],"UsePreviousResults":true,"moduleIdForCode":14,"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-8' Position='211,64,200,200'/><NodePosition Node='287d2cb0-f53c-4101-bdf8-104b137c8601-15' Position='70,183,200,200'/><NodePosition Node='287d2cb0-f53c-4101-bdf8-104b137c8601-24' Position='765,21,200,200'/><NodePosition Node='287d2cb0-f53c-4101-bdf8-104b137c8601-29' Position='381,188,200,200'/><NodePosition Node='287d2cb0-f53c-4101-bdf8-104b137c8601-35' Position='385,280,200,200'/><NodePosition Node='287d2cb0-f53c-4101-bdf8-104b137c8601-43' Position='638,561,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='287d2cb0-f53c-4101-bdf8-104b137c8601-70' Position='1078,236,200,200'/><NodePosition Node='287d2cb0-f53c-4101-bdf8-104b137c8601-76' Position='1081,327,200,200'/><NodePosition Node='287d2cb0-f53c-4101-bdf8-104b137c8601-81' Position='1037,751,200,200'/><NodePosition Node='287d2cb0-f53c-4101-bdf8-104b137c8601-84' Position='376,467,200,200'/><NodePosition Node='-86' Position='1078,418,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年4月26日 00:23
      # 本代码单元只能在可视化模式下编辑。您也可以拷贝代码,粘贴到新建的代码单元或者策略,然后修改。
      
      
      m1 = M.instruments.v2(
          start_date='2010-01-01',
          end_date='2015-01-01',
          market='CN_STOCK_A',
          instrument_list='',
          max_count=0
      )
      
      m2 = M.advanced_auto_labeler.v2(
          instruments=m1.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
      )
      
      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
      """
      )
      
      m4 = M.general_feature_extractor.v6(
          instruments=m1.data,
          features=m3.data,
          start_date='',
          end_date='',
          before_start_days=0
      )
      
      m5 = M.derived_feature_extractor.v2(
          input_data=m4.data,
          features=m3.data,
          date_col='date',
          instrument_col='instrument'
      )
      
      m7 = M.join.v3(
          data1=m2.data,
          data2=m5.data,
          on='date,instrument',
          how='inner',
          sort=False
      )
      
      m13 = M.dropnan.v1(
          input_data=m7.data
      )
      
      m6 = M.stock_ranker_train.v5(
          training_ds=m13.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,
          m_lazy_run=False
      )
      
      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
      )
      
      m10 = M.general_feature_extractor.v6(
          instruments=m9.data,
          features=m3.data,
          start_date='',
          end_date='',
          before_start_days=0
      )
      
      m11 = M.derived_feature_extractor.v2(
          input_data=m10.data,
          features=m3.data,
          date_col='date',
          instrument_col='instrument'
      )
      
      m14 = M.dropnan.v1(
          input_data=m11.data
      )
      
      m8 = M.stock_ranker_predict.v5(
          model=m6.model,
          data=m14.data,
          m_lazy_run=False
      )
      
      # 回测引擎:每日数据处理函数,每天执行一次
      def m12_handle_data_bigquant_run(context, data):
          # 按日期过滤得到今日的预测数据
          ranker_prediction = context.ranker_prediction[
              context.ranker_prediction.date == data.current_dt.strftime('%Y-%m-%d')]
      #------------------------------------------止损模块START--------------------------------------------
          today = data.current_dt  
          equities = {e.symbol: p for e, p in context.portfolio.positions.items() if p.amount>0}
          
          # 新建当日止损股票列表是为了handle_data 策略逻辑部分不再对该股票进行判断
          current_stoploss_stock = [] 
          if len(equities) > 0:
              for i in equities.keys():
                  stock_market_price = data.current(context.symbol(i), 'price')  # 最新市场价格
                  hold_days = context.trading_day_index - context.hold_days[i] # 通过记录的建仓时间点来计算持仓时间
                  # 建仓以来的最高价
                  highest_price_since_buy = data.history(context.symbol(i), 'high', int(hold_days), '1d').max()
                  # 确定止损位置
                  stoploss_line = highest_price_since_buy - highest_price_since_buy * 0.1
                  record('止损位置', stoploss_line)
                  # 如果价格下穿止损位置
                  if stock_market_price < stoploss_line:
                      context.order_target_percent(context.symbol(i), 0)     
                      current_stoploss_stock.append(i)
                      print('日期:', today, '股票:', i, '出现止损状况')  
          #-------------------------------------------止损模块END---------------------------------------------
          
          # 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)
                  context.hold_days[instrument] = context.trading_day_index
      
      # 回测引擎:准备数据,只执行一次
      def m12_prepare_bigquant_run(context):
          pass
      
      # 回测引擎:初始化函数,只执行一次
      def m12_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
          context.hold_days = {}
      
      m12 = M.trade.v3(
          instruments=m9.data,
          options_data=m8.predictions,
          start_date='',
          end_date='',
          handle_data=m12_handle_data_bigquant_run,
          prepare=m12_prepare_bigquant_run,
          initialize=m12_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-04-26 00:12:24.621589] INFO: bigquant: instruments.v2 开始运行..
      [2018-04-26 00:12:24.718064] INFO: bigquant: 命中缓存
      [2018-04-26 00:12:24.759832] INFO: bigquant: instruments.v2 运行完成[0.138258s].
      [2018-04-26 00:12:25.676154] INFO: bigquant: advanced_auto_labeler.v2 开始运行..
      [2018-04-26 00:12:25.772523] INFO: bigquant: 命中缓存
      [2018-04-26 00:12:25.774519] INFO: bigquant: advanced_auto_labeler.v2 运行完成[0.098411s].
      [2018-04-26 00:12:25.841325] INFO: bigquant: input_features.v1 开始运行..
      [2018-04-26 00:12:25.998680] INFO: bigquant: 命中缓存
      [2018-04-26 00:12:26.058034] INFO: bigquant: input_features.v1 运行完成[0.216686s].
      [2018-04-26 00:12:26.544095] INFO: bigquant: general_feature_extractor.v6 开始运行..
      [2018-04-26 00:12:26.609174] INFO: bigquant: 命中缓存
      [2018-04-26 00:12:26.612988] INFO: bigquant: general_feature_extractor.v6 运行完成[0.068887s].
      [2018-04-26 00:12:26.761678] INFO: bigquant: derived_feature_extractor.v2 开始运行..
      [2018-04-26 00:12:26.792355] INFO: bigquant: 命中缓存
      [2018-04-26 00:12:26.858508] INFO: bigquant: derived_feature_extractor.v2 运行完成[0.0968s].
      [2018-04-26 00:12:27.106897] INFO: bigquant: join.v3 开始运行..
      [2018-04-26 00:12:27.145693] INFO: bigquant: 命中缓存
      [2018-04-26 00:12:27.164354] INFO: bigquant: join.v3 运行完成[0.057469s].
      [2018-04-26 00:12:27.214910] INFO: bigquant: dropnan.v1 开始运行..
      [2018-04-26 00:12:27.272331] INFO: bigquant: 命中缓存
      [2018-04-26 00:12:27.311511] INFO: bigquant: dropnan.v1 运行完成[0.096613s].
      [2018-04-26 00:12:27.414816] INFO: bigquant: stock_ranker_train.v5 开始运行..
      [2018-04-26 00:12:27.517142] INFO: bigquant: 命中缓存
      [2018-04-26 00:12:27.519238] INFO: bigquant: stock_ranker_train.v5 运行完成[0.104459s].
      [2018-04-26 00:12:27.535351] INFO: bigquant: instruments.v2 开始运行..
      [2018-04-26 00:12:27.621391] INFO: bigquant: 命中缓存
      [2018-04-26 00:12:27.672744] INFO: bigquant: instruments.v2 运行完成[0.133844s].
      [2018-04-26 00:12:28.014401] INFO: bigquant: general_feature_extractor.v6 开始运行..
      [2018-04-26 00:12:28.019561] INFO: bigquant: 命中缓存
      [2018-04-26 00:12:28.021043] INFO: bigquant: general_feature_extractor.v6 运行完成[0.007152s].
      [2018-04-26 00:12:28.069609] INFO: bigquant: derived_feature_extractor.v2 开始运行..
      [2018-04-26 00:12:28.079255] INFO: bigquant: 命中缓存
      [2018-04-26 00:12:28.081048] INFO: bigquant: derived_feature_extractor.v2 运行完成[0.011458s].
      [2018-04-26 00:12:28.133128] INFO: bigquant: dropnan.v1 开始运行..
      [2018-04-26 00:12:28.171197] INFO: bigquant: 命中缓存
      [2018-04-26 00:12:28.212219] INFO: bigquant: dropnan.v1 运行完成[0.079123s].
      [2018-04-26 00:12:28.319257] INFO: bigquant: stock_ranker_predict.v5 开始运行..
      [2018-04-26 00:12:28.420159] INFO: bigquant: 命中缓存
      [2018-04-26 00:12:28.436422] INFO: bigquant: stock_ranker_predict.v5 运行完成[0.117173s].
      [2018-04-26 00:12:28.813812] INFO: bigquant: backtest.v7 开始运行..
      [2018-04-26 00:12:29.025721] INFO: algo: set price type:backward_adjusted
      日期: 2015-02-09 07:00:00+00:00 股票: 002240.SZA 出现止损状况
      日期: 2015-03-09 07:00:00+00:00 股票: 600212.SHA 出现止损状况
      日期: 2015-04-15 07:00:00+00:00 股票: 300236.SZA 出现止损状况
      日期: 2015-05-04 07:00:00+00:00 股票: 002539.SZA 出现止损状况
      日期: 2015-05-07 07:00:00+00:00 股票: 002671.SZA 出现止损状况
      日期: 2015-05-07 07:00:00+00:00 股票: 002082.SZA 出现止损状况
      日期: 2015-05-28 07:00:00+00:00 股票: 002619.SZA 出现止损状况
      日期: 2015-05-28 07:00:00+00:00 股票: 600746.SHA 出现止损状况
      日期: 2015-05-28 07:00:00+00:00 股票: 600671.SHA 出现止损状况
      日期: 2015-05-28 07:00:00+00:00 股票: 002141.SZA 出现止损状况
      日期: 2015-05-28 07:00:00+00:00 股票: 300120.SZA 出现止损状况
      日期: 2015-05-28 07:00:00+00:00 股票: 600679.SHA 出现止损状况
      日期: 2015-05-28 07:00:00+00:00 股票: 000678.SZA 出现止损状况
      日期: 2015-05-28 07:00:00+00:00 股票: 002534.SZA 出现止损状况
      日期: 2015-05-28 07:00:00+00:00 股票: 002393.SZA 出现止损状况
      日期: 2015-05-28 07:00:00+00:00 股票: 002563.SZA 出现止损状况
      日期: 2015-05-28 07:00:00+00:00 股票: 600721.SHA 出现止损状况
      日期: 2015-05-29 07:00:00+00:00 股票: 600163.SHA 出现止损状况
      日期: 2015-06-08 07:00:00+00:00 股票: 300174.SZA 出现止损状况
      日期: 2015-06-15 07:00:00+00:00 股票: 300302.SZA 出现止损状况
      日期: 2015-06-16 07:00:00+00:00 股票: 300380.SZA 出现止损状况
      日期: 2015-06-16 07:00:00+00:00 股票: 300385.SZA 出现止损状况
      日期: 2015-06-16 07:00:00+00:00 股票: 002124.SZA 出现止损状况
      日期: 2015-06-16 07:00:00+00:00 股票: 002279.SZA 出现止损状况
      日期: 2015-06-16 07:00:00+00:00 股票: 300376.SZA 出现止损状况
      日期: 2015-06-18 07:00:00+00:00 股票: 600446.SHA 出现止损状况
      日期: 2015-06-18 07:00:00+00:00 股票: 300248.SZA 出现止损状况
      日期: 2015-06-18 07:00:00+00:00 股票: 300378.SZA 出现止损状况
      日期: 2015-06-19 07:00:00+00:00 股票: 002034.SZA 出现止损状况
      日期: 2015-06-19 07:00:00+00:00 股票: 300359.SZA 出现止损状况
      日期: 2015-06-19 07:00:00+00:00 股票: 002059.SZA 出现止损状况
      日期: 2015-06-25 07:00:00+00:00 股票: 000555.SZA 出现止损状况
      日期: 2015-06-25 07:00:00+00:00 股票: 300343.SZA 出现止损状况
      日期: 2015-06-25 07:00:00+00:00 股票: 600446.SHA 出现止损状况
      日期: 2015-06-25 07:00:00+00:00 股票: 300440.SZA 出现止损状况
      日期: 2015-06-25 07:00:00+00:00 股票: 300350.SZA 出现止损状况
      日期: 2015-06-26 07:00:00+00:00 股票: 300216.SZA 出现止损状况
      日期: 2015-06-26 07:00:00+00:00 股票: 300343.SZA 出现止损状况
      日期: 2015-06-26 07:00:00+00:00 股票: 300445.SZA 出现止损状况
      日期: 2015-06-26 07:00:00+00:00 股票: 600446.SHA 出现止损状况
      日期: 2015-06-26 07:00:00+00:00 股票: 000555.SZA 出现止损状况
      日期: 2015-06-26 07:00:00+00:00 股票: 300440.SZA 出现止损状况
      日期: 2015-06-26 07:00:00+00:00 股票: 300077.SZA 出现止损状况
      日期: 2015-06-26 07:00:00+00:00 股票: 300350.SZA 出现止损状况
      日期: 2015-06-26 07:00:00+00:00 股票: 300151.SZA 出现止损状况
      日期: 2015-06-29 07:00:00+00:00 股票: 600446.SHA 出现止损状况
      日期: 2015-06-29 07:00:00+00:00 股票: 002572.SZA 出现止损状况
      日期: 2015-06-29 07:00:00+00:00 股票: 002229.SZA 出现止损状况
      日期: 2015-06-29 07:00:00+00:00 股票: 603818.SHA 出现止损状况
      日期: 2015-06-29 07:00:00+00:00 股票: 300343.SZA 出现止损状况
      日期: 2015-06-29 07:00:00+00:00 股票: 000829.SZA 出现止损状况
      日期: 2015-06-29 07:00:00+00:00 股票: 300445.SZA 出现止损状况
      日期: 2015-06-29 07:00:00+00:00 股票: 300440.SZA 出现止损状况
      日期: 2015-06-29 07:00:00+00:00 股票: 603869.SHA 出现止损状况
      日期: 2015-06-29 07:00:00+00:00 股票: 300077.SZA 出现止损状况
      日期: 2015-06-29 07:00:00+00:00 股票: 300075.SZA 出现止损状况
      日期: 2015-06-29 07:00:00+00:00 股票: 300348.SZA 出现止损状况
      日期: 2015-06-29 07:00:00+00:00 股票: 002436.SZA 出现止损状况
      日期: 2015-06-29 07:00:00+00:00 股票: 000516.SZA 出现止损状况
      日期: 2015-06-29 07:00:00+00:00 股票: 300350.SZA 出现止损状况
      日期: 2015-06-29 07:00:00+00:00 股票: 603703.SHA 出现止损状况
      日期: 2015-06-29 07:00:00+00:00 股票: 300151.SZA 出现止损状况
      日期: 2015-06-30 07:00:00+00:00 股票: 002572.SZA 出现止损状况
      日期: 2015-07-01 07:00:00+00:00 股票: 002341.SZA 出现止损状况
      日期: 2015-07-01 07:00:00+00:00 股票: 002229.SZA 出现止损状况
      日期: 2015-07-01 07:00:00+00:00 股票: 002407.SZA 出现止损状况
      日期: 2015-07-01 07:00:00+00:00 股票: 300348.SZA 出现止损状况
      日期: 2015-07-01 07:00:00+00:00 股票: 002515.SZA 出现止损状况
      日期: 2015-07-01 07:00:00+00:00 股票: 300006.SZA 出现止损状况
      日期: 2015-07-01 07:00:00+00:00 股票: 600446.SHA 出现止损状况
      日期: 2015-07-02 07:00:00+00:00 股票: 002229.SZA 出现止损状况
      日期: 2015-07-02 07:00:00+00:00 股票: 002341.SZA 出现止损状况
      日期: 2015-07-02 07:00:00+00:00 股票: 600556.SHA 出现止损状况
      日期: 2015-07-02 07:00:00+00:00 股票: 002515.SZA 出现止损状况
      日期: 2015-07-02 07:00:00+00:00 股票: 600446.SHA 出现止损状况
      日期: 2015-07-02 07:00:00+00:00 股票: 002407.SZA 出现止损状况
      日期: 2015-07-02 07:00:00+00:00 股票: 300006.SZA 出现止损状况
      日期: 2015-07-02 07:00:00+00:00 股票: 300348.SZA 出现止损状况
      日期: 2015-07-03 07:00:00+00:00 股票: 002451.SZA 出现止损状况
      日期: 2015-07-03 07:00:00+00:00 股票: 002341.SZA 出现止损状况
      日期: 2015-07-03 07:00:00+00:00 股票: 002112.SZA 出现止损状况
      日期: 2015-07-03 07:00:00+00:00 股票: 600556.SHA 出现止损状况
      日期: 2015-07-03 07:00:00+00:00 股票: 002515.SZA 出现止损状况
      日期: 2015-07-03 07:00:00+00:00 股票: 000662.SZA 出现止损状况
      日期: 2015-07-03 07:00:00+00:00 股票: 300309.SZA 出现止损状况
      日期: 2015-07-03 07:00:00+00:00 股票: 300304.SZA 出现止损状况
      日期: 2015-07-03 07:00:00+00:00 股票: 002407.SZA 出现止损状况
      日期: 2015-07-03 07:00:00+00:00 股票: 002229.SZA 出现止损状况
      日期: 2015-07-03 07:00:00+00:00 股票: 300006.SZA 出现止损状况
      日期: 2015-07-03 07:00:00+00:00 股票: 300348.SZA 出现止损状况
      日期: 2015-07-06 07:00:00+00:00 股票: 002335.SZA 出现止损状况
      日期: 2015-07-06 07:00:00+00:00 股票: 002341.SZA 出现止损状况
      日期: 2015-07-06 07:00:00+00:00 股票: 002112.SZA 出现止损状况
      日期: 2015-07-06 07:00:00+00:00 股票: 600556.SHA 出现止损状况
      日期: 2015-07-06 07:00:00+00:00 股票: 002515.SZA 出现止损状况
      日期: 2015-07-06 07:00:00+00:00 股票: 000662.SZA 出现止损状况
      日期: 2015-07-06 07:00:00+00:00 股票: 600821.SHA 出现止损状况
      日期: 2015-07-06 07:00:00+00:00 股票: 002322.SZA 出现止损状况
      日期: 2015-07-06 07:00:00+00:00 股票: 300309.SZA 出现止损状况
      日期: 2015-07-06 07:00:00+00:00 股票: 300304.SZA 出现止损状况
      日期: 2015-07-06 07:00:00+00:00 股票: 600385.SHA 出现止损状况
      日期: 2015-07-06 07:00:00+00:00 股票: 600148.SHA 出现止损状况
      日期: 2015-07-06 07:00:00+00:00 股票: 600783.SHA 出现止损状况
      日期: 2015-07-06 07:00:00+00:00 股票: 002451.SZA 出现止损状况
      日期: 2015-07-06 07:00:00+00:00 股票: 300006.SZA 出现止损状况
      日期: 2015-07-06 07:00:00+00:00 股票: 300348.SZA 出现止损状况
      日期: 2015-07-07 07:00:00+00:00 股票: 002112.SZA 出现止损状况
      日期: 2015-07-07 07:00:00+00:00 股票: 000662.SZA 出现止损状况
      日期: 2015-07-07 07:00:00+00:00 股票: 600385.SHA 出现止损状况
      日期: 2015-07-07 07:00:00+00:00 股票: 300309.SZA 出现止损状况
      日期: 2015-07-07 07:00:00+00:00 股票: 002515.SZA 出现止损状况
      日期: 2015-07-07 07:00:00+00:00 股票: 002335.SZA 出现止损状况
      日期: 2015-07-07 07:00:00+00:00 股票: 002341.SZA 出现止损状况
      日期: 2015-07-07 07:00:00+00:00 股票: 600556.SHA 出现止损状况
      日期: 2015-07-07 07:00:00+00:00 股票: 600821.SHA 出现止损状况
      日期: 2015-07-07 07:00:00+00:00 股票: 300348.SZA 出现止损状况
      日期: 2015-07-07 07:00:00+00:00 股票: 300304.SZA 出现止损状况
      日期: 2015-07-07 07:00:00+00:00 股票: 002322.SZA 出现止损状况
      日期: 2015-07-07 07:00:00+00:00 股票: 600148.SHA 出现止损状况
      日期: 2015-07-07 07:00:00+00:00 股票: 002451.SZA 出现止损状况
      日期: 2015-07-07 07:00:00+00:00 股票: 300006.SZA 出现止损状况
      日期: 2015-07-08 07:00:00+00:00 股票: 000819.SZA 出现止损状况
      日期: 2015-07-08 07:00:00+00:00 股票: 000662.SZA 出现止损状况
      日期: 2015-07-08 07:00:00+00:00 股票: 600385.SHA 出现止损状况
      日期: 2015-07-08 07:00:00+00:00 股票: 300309.SZA 出现止损状况
      日期: 2015-07-08 07:00:00+00:00 股票: 002515.SZA 出现止损状况
      日期: 2015-07-08 07:00:00+00:00 股票: 002335.SZA 出现止损状况
      日期: 2015-07-08 07:00:00+00:00 股票: 002341.SZA 出现止损状况
      日期: 2015-07-08 07:00:00+00:00 股票: 600556.SHA 出现止损状况
      日期: 2015-07-08 07:00:00+00:00 股票: 600235.SHA 出现止损状况
      日期: 2015-07-08 07:00:00+00:00 股票: 600821.SHA 出现止损状况
      日期: 2015-07-08 07:00:00+00:00 股票: 300348.SZA 出现止损状况
      日期: 2015-07-08 07:00:00+00:00 股票: 300304.SZA 出现止损状况
      日期: 2015-07-08 07:00:00+00:00 股票: 002322.SZA 出现止损状况
      日期: 2015-07-08 07:00:00+00:00 股票: 600148.SHA 出现止损状况
      日期: 2015-07-08 07:00:00+00:00 股票: 002451.SZA 出现止损状况
      日期: 2015-07-08 07:00:00+00:00 股票: 300006.SZA 出现止损状况
      日期: 2015-07-09 07:00:00+00:00 股票: 300304.SZA 出现止损状况
      日期: 2015-07-09 07:00:00+00:00 股票: 002335.SZA 出现止损状况
      日期: 2015-07-09 07:00:00+00:00 股票: 002341.SZA 出现止损状况
      日期: 2015-07-09 07:00:00+00:00 股票: 000662.SZA 出现止损状况
      日期: 2015-07-09 07:00:00+00:00 股票: 600821.SHA 出现止损状况
      日期: 2015-07-09 07:00:00+00:00 股票: 002515.SZA 出现止损状况
      日期: 2015-07-09 07:00:00+00:00 股票: 300309.SZA 出现止损状况
      日期: 2015-07-09 07:00:00+00:00 股票: 002322.SZA 出现止损状况
      日期: 2015-07-09 07:00:00+00:00 股票: 002451.SZA 出现止损状况
      日期: 2015-07-09 07:00:00+00:00 股票: 300006.SZA 出现止损状况
      日期: 2015-07-09 07:00:00+00:00 股票: 300348.SZA 出现止损状况
      日期: 2015-07-10 07:00:00+00:00 股票: 300304.SZA 出现止损状况
      日期: 2015-07-10 07:00:00+00:00 股票: 002335.SZA 出现止损状况
      日期: 2015-07-10 07:00:00+00:00 股票: 002341.SZA 出现止损状况
      日期: 2015-07-10 07:00:00+00:00 股票: 000662.SZA 出现止损状况
      日期: 2015-07-10 07:00:00+00:00 股票: 300006.SZA 出现止损状况
      日期: 2015-07-10 07:00:00+00:00 股票: 600821.SHA 出现止损状况
      日期: 2015-07-10 07:00:00+00:00 股票: 002515.SZA 出现止损状况
      日期: 2015-07-10 07:00:00+00:00 股票: 300309.SZA 出现止损状况
      日期: 2015-07-10 07:00:00+00:00 股票: 002322.SZA 出现止损状况
      日期: 2015-07-10 07:00:00+00:00 股票: 002451.SZA 出现止损状况
      日期: 2015-07-10 07:00:00+00:00 股票: 300348.SZA 出现止损状况
      日期: 2015-07-13 07:00:00+00:00 股票: 300348.SZA 出现止损状况
      日期: 2015-07-13 07:00:00+00:00 股票: 002335.SZA 出现止损状况
      日期: 2015-07-13 07:00:00+00:00 股票: 002341.SZA 出现止损状况
      日期: 2015-07-13 07:00:00+00:00 股票: 002515.SZA 出现止损状况
      日期: 2015-07-13 07:00:00+00:00 股票: 300309.SZA 出现止损状况
      日期: 2015-07-13 07:00:00+00:00 股票: 300304.SZA 出现止损状况
      日期: 2015-07-13 07:00:00+00:00 股票: 002322.SZA 出现止损状况
      日期: 2015-07-13 07:00:00+00:00 股票: 002451.SZA 出现止损状况
      日期: 2015-07-13 07:00:00+00:00 股票: 300006.SZA 出现止损状况
      日期: 2015-07-13 07:00:00+00:00 股票: 000662.SZA 出现止损状况
      日期: 2015-07-14 07:00:00+00:00 股票: 002341.SZA 出现止损状况
      日期: 2015-07-14 07:00:00+00:00 股票: 300006.SZA 出现止损状况
      日期: 2015-07-14 07:00:00+00:00 股票: 000662.SZA 出现止损状况
      日期: 2015-07-14 07:00:00+00:00 股票: 300348.SZA 出现止损状况
      日期: 2015-07-14 07:00:00+00:00 股票: 300304.SZA 出现止损状况
      日期: 2015-07-14 07:00:00+00:00 股票: 002451.SZA 出现止损状况
      日期: 2015-07-14 07:00:00+00:00 股票: 002515.SZA 出现止损状况
      日期: 2015-07-15 07:00:00+00:00 股票: 002341.SZA 出现止损状况
      日期: 2015-07-15 07:00:00+00:00 股票: 000662.SZA 出现止损状况
      日期: 2015-07-15 07:00:00+00:00 股票: 002645.SZA 出现止损状况
      日期: 2015-07-15 07:00:00+00:00 股票: 300457.SZA 出现止损状况
      日期: 2015-07-15 07:00:00+00:00 股票: 002576.SZA 出现止损状况
      日期: 2015-07-15 07:00:00+00:00 股票: 300348.SZA 出现止损状况
      日期: 2015-07-15 07:00:00+00:00 股票: 002298.SZA 出现止损状况
      日期: 2015-07-15 07:00:00+00:00 股票: 600200.SHA 出现止损状况
      日期: 2015-07-15 07:00:00+00:00 股票: 600240.SHA 出现止损状况
      日期: 2015-07-15 07:00:00+00:00 股票: 002451.SZA 出现止损状况
      日期: 2015-07-15 07:00:00+00:00 股票: 002515.SZA 出现止损状况
      日期: 2015-07-16 07:00:00+00:00 股票: 002341.SZA 出现止损状况
      日期: 2015-07-16 07:00:00+00:00 股票: 000662.SZA 出现止损状况
      日期: 2015-07-16 07:00:00+00:00 股票: 300348.SZA 出现止损状况
      日期: 2015-07-16 07:00:00+00:00 股票: 002451.SZA 出现止损状况
      日期: 2015-07-16 07:00:00+00:00 股票: 002515.SZA 出现止损状况
      日期: 2015-07-17 07:00:00+00:00 股票: 002341.SZA 出现止损状况
      日期: 2015-07-17 07:00:00+00:00 股票: 002515.SZA 出现止损状况
      日期: 2015-07-20 07:00:00+00:00 股票: 002515.SZA 出现止损状况
      日期: 2015-07-21 07:00:00+00:00 股票: 002515.SZA 出现止损状况
      日期: 2015-07-22 07:00:00+00:00 股票: 002515.SZA 出现止损状况
      日期: 2015-07-23 07:00:00+00:00 股票: 002515.SZA 出现止损状况
      日期: 2015-07-24 07:00:00+00:00 股票: 002515.SZA 出现止损状况
      日期: 2015-07-27 07:00:00+00:00 股票: 300199.SZA 出现止损状况
      日期: 2015-07-27 07:00:00+00:00 股票: 002284.SZA 出现止损状况
      日期: 2015-07-27 07:00:00+00:00 股票: 600130.SHA 出现止损状况
      日期: 2015-07-27 07:00:00+00:00 股票: 002217.SZA 出现止损状况
      日期: 2015-07-27 07:00:00+00:00 股票: 000061.SZA 出现止损状况
      日期: 2015-07-27 07:00:00+00:00 股票: 002495.SZA 出现止损状况
      日期: 2015-07-27 07:00:00+00:00 股票: 000517.SZA 出现止损状况
      日期: 2015-07-27 07:00:00+00:00 股票: 002682.SZA 出现止损状况
      日期: 2015-07-27 07:00:00+00:00 股票: 000975.SZA 出现止损状况
      日期: 2015-07-27 07:00:00+00:00 股票: 002515.SZA 出现止损状况
      日期: 2015-07-27 07:00:00+00:00 股票: 300431.SZA 出现止损状况
      日期: 2015-07-27 07:00:00+00:00 股票: 002339.SZA 出现止损状况
      日期: 2015-07-28 07:00:00+00:00 股票: 002284.SZA 出现止损状况
      日期: 2015-07-28 07:00:00+00:00 股票: 300069.SZA 出现止损状况
      日期: 2015-07-28 07:00:00+00:00 股票: 600130.SHA 出现止损状况
      日期: 2015-07-28 07:00:00+00:00 股票: 002217.SZA 出现止损状况
      日期: 2015-07-28 07:00:00+00:00 股票: 600242.SHA 出现止损状况
      日期: 2015-07-28 07:00:00+00:00 股票: 300431.SZA 出现止损状况
      日期: 2015-07-28 07:00:00+00:00 股票: 002515.SZA 出现止损状况
      日期: 2015-07-28 07:00:00+00:00 股票: 002682.SZA 出现止损状况
      日期: 2015-07-28 07:00:00+00:00 股票: 000592.SZA 出现止损状况
      日期: 2015-07-28 07:00:00+00:00 股票: 002339.SZA 出现止损状况
      日期: 2015-07-29 07:00:00+00:00 股票: 002515.SZA 出现止损状况
      日期: 2015-07-30 07:00:00+00:00 股票: 300339.SZA 出现止损状况
      日期: 2015-07-30 07:00:00+00:00 股票: 300212.SZA 出现止损状况
      日期: 2015-07-30 07:00:00+00:00 股票: 300295.SZA 出现止损状况
      日期: 2015-07-30 07:00:00+00:00 股票: 300074.SZA 出现止损状况
      日期: 2015-07-30 07:00:00+00:00 股票: 002515.SZA 出现止损状况
      日期: 2015-07-31 07:00:00+00:00 股票: 002515.SZA 出现止损状况
      日期: 2015-08-03 07:00:00+00:00 股票: 600078.SHA 出现止损状况
      日期: 2015-08-03 07:00:00+00:00 股票: 600273.SHA 出现止损状况
      日期: 2015-08-03 07:00:00+00:00 股票: 002664.SZA 出现止损状况
      日期: 2015-08-03 07:00:00+00:00 股票: 600526.SHA 出现止损状况
      日期: 2015-08-03 07:00:00+00:00 股票: 300120.SZA 出现止损状况
      日期: 2015-08-03 07:00:00+00:00 股票: 002515.SZA 出现止损状况
      日期: 2015-08-03 07:00:00+00:00 股票: 000716.SZA 出现止损状况
      日期: 2015-08-04 07:00:00+00:00 股票: 000716.SZA 出现止损状况
      日期: 2015-08-04 07:00:00+00:00 股票: 002515.SZA 出现止损状况
      日期: 2015-08-05 07:00:00+00:00 股票: 300384.SZA 出现止损状况
      日期: 2015-08-05 07:00:00+00:00 股票: 002515.SZA 出现止损状况
      日期: 2015-08-06 07:00:00+00:00 股票: 002515.SZA 出现止损状况
      日期: 2015-08-07 07:00:00+00:00 股票: 002515.SZA 出现止损状况
      日期: 2015-08-10 07:00:00+00:00 股票: 002515.SZA 出现止损状况
      日期: 2015-08-11 07:00:00+00:00 股票: 002515.SZA 出现止损状况
      日期: 2015-08-12 07:00:00+00:00 股票: 002515.SZA 出现止损状况
      日期: 2015-08-13 07:00:00+00:00 股票: 002515.SZA 出现止损状况
      日期: 2015-08-14 07:00:00+00:00 股票: 002515.SZA 出现止损状况
      日期: 2015-08-17 07:00:00+00:00 股票: 002515.SZA 出现止损状况
      日期: 2015-08-18 07:00:00+00:00 股票: 002375.SZA 出现止损状况
      日期: 2015-08-18 07:00:00+00:00 股票: 300081.SZA 出现止损状况
      日期: 2015-08-18 07:00:00+00:00 股票: 300168.SZA 出现止损状况
      日期: 2015-08-18 07:00:00+00:00 股票: 002487.SZA 出现止损状况
      日期: 2015-08-18 07:00:00+00:00 股票: 000503.SZA 出现止损状况
      日期: 2015-08-18 07:00:00+00:00 股票: 002427.SZA 出现止损状况
      日期: 2015-08-18 07:00:00+00:00 股票: 002748.SZA 出现止损状况
      日期: 2015-08-18 07:00:00+00:00 股票: 600094.SHA 出现止损状况
      日期: 2015-08-18 07:00:00+00:00 股票: 002180.SZA 出现止损状况
      日期: 2015-08-18 07:00:00+00:00 股票: 002515.SZA 出现止损状况
      日期: 2015-08-18 07:00:00+00:00 股票: 300020.SZA 出现止损状况
      日期: 2015-08-19 07:00:00+00:00 股票: 002515.SZA 出现止损状况
      日期: 2015-08-20 07:00:00+00:00 股票: 002515.SZA 出现止损状况
      日期: 2015-08-21 07:00:00+00:00 股票: 300168.SZA 出现止损状况
      日期: 2015-08-21 07:00:00+00:00 股票: 300154.SZA 出现止损状况
      日期: 2015-08-21 07:00:00+00:00 股票: 300295.SZA 出现止损状况
      日期: 2015-08-21 07:00:00+00:00 股票: 300348.SZA 出现止损状况
      日期: 2015-08-21 07:00:00+00:00 股票: 300384.SZA 出现止损状况
      日期: 2015-08-21 07:00:00+00:00 股票: 300431.SZA 出现止损状况
      日期: 2015-08-21 07:00:00+00:00 股票: 002612.SZA 出现止损状况
      日期: 2015-08-21 07:00:00+00:00 股票: 300380.SZA 出现止损状况
      日期: 2015-08-21 07:00:00+00:00 股票: 002515.SZA 出现止损状况
      日期: 2015-08-24 07:00:00+00:00 股票: 000669.SZA 出现止损状况
      日期: 2015-08-24 07:00:00+00:00 股票: 300168.SZA 出现止损状况
      日期: 2015-08-24 07:00:00+00:00 股票: 300154.SZA 出现止损状况
      日期: 2015-08-24 07:00:00+00:00 股票: 300295.SZA 出现止损状况
      日期: 2015-08-24 07:00:00+00:00 股票: 300155.SZA 出现止损状况
      日期: 2015-08-24 07:00:00+00:00 股票: 002081.SZA 出现止损状况
      日期: 2015-08-24 07:00:00+00:00 股票: 300348.SZA 出现止损状况
      日期: 2015-08-24 07:00:00+00:00 股票: 300384.SZA 出现止损状况
      日期: 2015-08-24 07:00:00+00:00 股票: 300431.SZA 出现止损状况
      日期: 2015-08-24 07:00:00+00:00 股票: 002612.SZA 出现止损状况
      日期: 2015-08-24 07:00:00+00:00 股票: 300378.SZA 出现止损状况
      日期: 2015-08-25 07:00:00+00:00 股票: 300081.SZA 出现止损状况
      日期: 2015-08-25 07:00:00+00:00 股票: 300168.SZA 出现止损状况
      日期: 2015-08-25 07:00:00+00:00 股票: 300012.SZA 出现止损状况
      日期: 2015-08-25 07:00:00+00:00 股票: 300154.SZA 出现止损状况
      日期: 2015-08-25 07:00:00+00:00 股票: 300295.SZA 出现止损状况
      日期: 2015-08-25 07:00:00+00:00 股票: 300155.SZA 出现止损状况
      日期: 2015-08-25 07:00:00+00:00 股票: 300378.SZA 出现止损状况
      日期: 2015-08-25 07:00:00+00:00 股票: 300348.SZA 出现止损状况
      日期: 2015-08-25 07:00:00+00:00 股票: 300384.SZA 出现止损状况
      日期: 2015-08-25 07:00:00+00:00 股票: 300431.SZA 出现止损状况
      日期: 2015-08-25 07:00:00+00:00 股票: 300152.SZA 出现止损状况
      日期: 2015-08-25 07:00:00+00:00 股票: 002612.SZA 出现止损状况
      日期: 2015-08-25 07:00:00+00:00 股票: 300252.SZA 出现止损状况
      日期: 2015-08-25 07:00:00+00:00 股票: 300380.SZA 出现止损状况
      日期: 2015-08-25 07:00:00+00:00 股票: 002081.SZA 出现止损状况
      日期: 2015-08-26 07:00:00+00:00 股票: 300053.SZA 出现止损状况
      日期: 2015-08-26 07:00:00+00:00 股票: 300168.SZA 出现止损状况
      日期: 2015-08-26 07:00:00+00:00 股票: 300155.SZA 出现止损状况
      日期: 2015-08-26 07:00:00+00:00 股票: 300348.SZA 出现止损状况
      日期: 2015-08-26 07:00:00+00:00 股票: 002290.SZA 出现止损状况
      日期: 2015-08-26 07:00:00+00:00 股票: 600029.SHA 出现止损状况
      日期: 2015-08-26 07:00:00+00:00 股票: 300252.SZA 出现止损状况
      日期: 2015-08-26 07:00:00+00:00 股票: 300380.SZA 出现止损状况
      日期: 2015-08-31 07:00:00+00:00 股票: 300460.SZA 出现止损状况
      日期: 2015-08-31 07:00:00+00:00 股票: 300259.SZA 出现止损状况
      日期: 2015-08-31 07:00:00+00:00 股票: 002288.SZA 出现止损状况
      日期: 2015-08-31 07:00:00+00:00 股票: 002290.SZA 出现止损状况
      日期: 2015-09-01 07:00:00+00:00 股票: 300038.SZA 出现止损状况
      日期: 2015-09-01 07:00:00+00:00 股票: 300460.SZA 出现止损状况
      日期: 2015-09-01 07:00:00+00:00 股票: 300212.SZA 出现止损状况
      日期: 2015-09-01 07:00:00+00:00 股票: 002518.SZA 出现止损状况
      日期: 2015-09-01 07:00:00+00:00 股票: 300259.SZA 出现止损状况
      日期: 2015-09-01 07:00:00+00:00 股票: 002288.SZA 出现止损状况
      日期: 2015-09-01 07:00:00+00:00 股票: 002290.SZA 出现止损状况
      日期: 2015-09-01 07:00:00+00:00 股票: 600416.SHA 出现止损状况
      日期: 2015-09-01 07:00:00+00:00 股票: 300065.SZA 出现止损状况
      日期: 2015-09-02 07:00:00+00:00 股票: 300038.SZA 出现止损状况
      日期: 2015-09-02 07:00:00+00:00 股票: 002617.SZA 出现止损状况
      日期: 2015-09-02 07:00:00+00:00 股票: 002115.SZA 出现止损状况
      日期: 2015-09-02 07:00:00+00:00 股票: 600416.SHA 出现止损状况
      日期: 2015-09-02 07:00:00+00:00 股票: 600433.SHA 出现止损状况
      日期: 2015-09-02 07:00:00+00:00 股票: 300065.SZA 出现止损状况
      日期: 2015-09-02 07:00:00+00:00 股票: 002288.SZA 出现止损状况
      日期: 2015-09-07 07:00:00+00:00 股票: 600714.SHA 出现止损状况
      日期: 2015-09-14 07:00:00+00:00 股票: 600118.SHA 出现止损状况
      日期: 2015-09-14 07:00:00+00:00 股票: 300388.SZA 出现止损状况
      日期: 2015-09-14 07:00:00+00:00 股票: 000738.SZA 出现止损状况
      日期: 2015-09-14 07:00:00+00:00 股票: 000628.SZA 出现止损状况
      日期: 2015-09-14 07:00:00+00:00 股票: 002190.SZA 出现止损状况
      日期: 2015-09-14 07:00:00+00:00 股票: 600760.SHA 出现止损状况
      日期: 2015-09-14 07:00:00+00:00 股票: 002576.SZA 出现止损状况
      日期: 2015-09-14 07:00:00+00:00 股票: 600391.SHA 出现止损状况
      日期: 2015-09-14 07:00:00+00:00 股票: 601890.SHA 出现止损状况
      日期: 2015-09-14 07:00:00+00:00 股票: 002269.SZA 出现止损状况
      日期: 2015-09-14 07:00:00+00:00 股票: 300277.SZA 出现止损状况
      日期: 2015-09-14 07:00:00+00:00 股票: 600184.SHA 出现止损状况
      日期: 2015-09-14 07:00:00+00:00 股票: 000768.SZA 出现止损状况
      日期: 2015-09-14 07:00:00+00:00 股票: 300101.SZA 出现止损状况
      日期: 2015-09-14 07:00:00+00:00 股票: 002515.SZA 出现止损状况
      日期: 2015-09-14 07:00:00+00:00 股票: 600807.SHA 出现止损状况
      日期: 2015-09-14 07:00:00+00:00 股票: 300276.SZA 出现止损状况
      [2018-04-26 00:18:29.240683] INFO: Blotter: 2015-09-15 cancel order Equity(1442 [000738.SZA]) 
      日期: 2015-09-15 07:00:00+00:00 股票: 600118.SHA 出现止损状况
      日期: 2015-09-15 07:00:00+00:00 股票: 300388.SZA 出现止损状况
      日期: 2015-09-15 07:00:00+00:00 股票: 000628.SZA 出现止损状况
      日期: 2015-09-15 07:00:00+00:00 股票: 002190.SZA 出现止损状况
      日期: 2015-09-15 07:00:00+00:00 股票: 300101.SZA 出现止损状况
      日期: 2015-09-15 07:00:00+00:00 股票: 600391.SHA 出现止损状况
      日期: 2015-09-15 07:00:00+00:00 股票: 601890.SHA 出现止损状况
      日期: 2015-09-15 07:00:00+00:00 股票: 002269.SZA 出现止损状况
      日期: 2015-09-15 07:00:00+00:00 股票: 300277.SZA 出现止损状况
      日期: 2015-09-15 07:00:00+00:00 股票: 600184.SHA 出现止损状况
      日期: 2015-09-15 07:00:00+00:00 股票: 000768.SZA 出现止损状况
      日期: 2015-09-15 07:00:00+00:00 股票: 002515.SZA 出现止损状况
      日期: 2015-09-15 07:00:00+00:00 股票: 300276.SZA 出现止损状况
      日期: 2015-09-25 07:00:00+00:00 股票: 603021.SHA 出现止损状况
      日期: 2015-10-21 07:00:00+00:00 股票: 002272.SZA 出现止损状况
      日期: 2015-10-21 07:00:00+00:00 股票: 603600.SHA 出现止损状况
      日期: 2015-10-21 07:00:00+00:00 股票: 000887.SZA 出现止损状况
      日期: 2015-10-21 07:00:00+00:00 股票: 300135.SZA 出现止损状况
      日期: 2015-10-21 07:00:00+00:00 股票: 600879.SHA 出现止损状况
      日期: 2015-10-21 07:00:00+00:00 股票: 000782.SZA 出现止损状况
      日期: 2015-10-21 07:00:00+00:00 股票: 000712.SZA 出现止损状况
      日期: 2015-10-21 07:00:00+00:00 股票: 603017.SHA 出现止损状况
      日期: 2015-11-27 07:00:00+00:00 股票: 000018.SZA 出现止损状况
      日期: 2015-11-27 07:00:00+00:00 股票: 300357.SZA 出现止损状况
      日期: 2015-11-30 07:00:00+00:00 股票: 000611.SZA 出现止损状况
      日期: 2015-11-30 07:00:00+00:00 股票: 000590.SZA 出现止损状况
      日期: 2015-11-30 07:00:00+00:00 股票: 600145.SHA 出现止损状况
      日期: 2015-11-30 07:00:00+00:00 股票: 000912.SZA 出现止损状况
      日期: 2015-12-09 07:00:00+00:00 股票: 000908.SZA 出现止损状况
      日期: 2015-12-09 07:00:00+00:00 股票: 002210.SZA 出现止损状况
      日期: 2015-12-10 07:00:00+00:00 股票: 002301.SZA 出现止损状况
      日期: 2016-01-04 07:00:00+00:00 股票: 300418.SZA 出现止损状况
      日期: 2016-01-04 07:00:00+00:00 股票: 300294.SZA 出现止损状况
      日期: 2016-01-04 07:00:00+00:00 股票: 002135.SZA 出现止损状况
      日期: 2016-01-04 07:00:00+00:00 股票: 002599.SZA 出现止损状况
      日期: 2016-01-04 07:00:00+00:00 股票: 000155.SZA 出现止损状况
      日期: 2016-01-04 07:00:00+00:00 股票: 300094.SZA 出现止损状况
      日期: 2016-01-04 07:00:00+00:00 股票: 600613.SHA 出现止损状况
      日期: 2016-01-04 07:00:00+00:00 股票: 000688.SZA 出现止损状况
      日期: 2016-01-05 07:00:00+00:00 股票: 002599.SZA 出现止损状况
      日期: 2016-01-05 07:00:00+00:00 股票: 600408.SHA 出现止损状况
      日期: 2016-01-05 07:00:00+00:00 股票: 000155.SZA 出现止损状况
      日期: 2016-01-06 07:00:00+00:00 股票: 000155.SZA 出现止损状况
      日期: 2016-01-07 07:00:00+00:00 股票: 300094.SZA 出现止损状况
      日期: 2016-01-07 07:00:00+00:00 股票: 300467.SZA 出现止损状况
      日期: 2016-01-07 07:00:00+00:00 股票: 300441.SZA 出现止损状况
      日期: 2016-01-07 07:00:00+00:00 股票: 002758.SZA 出现止损状况
      日期: 2016-01-07 07:00:00+00:00 股票: 002668.SZA 出现止损状况
      日期: 2016-01-07 07:00:00+00:00 股票: 002741.SZA 出现止损状况
      日期: 2016-01-07 07:00:00+00:00 股票: 300449.SZA 出现止损状况
      日期: 2016-01-07 07:00:00+00:00 股票: 000155.SZA 出现止损状况
      日期: 2016-01-07 07:00:00+00:00 股票: 300189.SZA 出现止损状况
      日期: 2016-01-08 07:00:00+00:00 股票: 300149.SZA 出现止损状况
      日期: 2016-01-11 07:00:00+00:00 股票: 002751.SZA 出现止损状况
      日期: 2016-01-11 07:00:00+00:00 股票: 002625.SZA 出现止损状况
      日期: 2016-01-11 07:00:00+00:00 股票: 002355.SZA 出现止损状况
      日期: 2016-01-11 07:00:00+00:00 股票: 002481.SZA 出现止损状况
      日期: 2016-01-11 07:00:00+00:00 股票: 300149.SZA 出现止损状况
      日期: 2016-01-11 07:00:00+00:00 股票: 000502.SZA 出现止损状况
      日期: 2016-01-13 07:00:00+00:00 股票: 300384.SZA 出现止损状况
      日期: 2016-01-13 07:00:00+00:00 股票: 000917.SZA 出现止损状况
      日期: 2016-01-13 07:00:00+00:00 股票: 300339.SZA 出现止损状况
      日期: 2016-01-13 07:00:00+00:00 股票: 603598.SHA 出现止损状况
      日期: 2016-01-13 07:00:00+00:00 股票: 300248.SZA 出现止损状况
      日期: 2016-01-13 07:00:00+00:00 股票: 002189.SZA 出现止损状况
      日期: 2016-01-15 07:00:00+00:00 股票: 002205.SZA 出现止损状况
      日期: 2016-01-21 07:00:00+00:00 股票: 002072.SZA 出现止损状况
      日期: 2016-01-21 07:00:00+00:00 股票: 002474.SZA 出现止损状况
      日期: 2016-01-21 07:00:00+00:00 股票: 300368.SZA 出现止损状况
      日期: 2016-01-21 07:00:00+00:00 股票: 600053.SHA 出现止损状况
      日期: 2016-01-21 07:00:00+00:00 股票: 300092.SZA 出现止损状况
      日期: 2016-01-22 07:00:00+00:00 股票: 300309.SZA 出现止损状况
      日期: 2016-01-26 07:00:00+00:00 股票: 603600.SHA 出现止损状况
      日期: 2016-01-26 07:00:00+00:00 股票: 600683.SHA 出现止损状况
      日期: 2016-01-26 07:00:00+00:00 股票: 000517.SZA 出现止损状况
      日期: 2016-01-26 07:00:00+00:00 股票: 600288.SHA 出现止损状况
      日期: 2016-01-26 07:00:00+00:00 股票: 600881.SHA 出现止损状况
      日期: 2016-01-26 07:00:00+00:00 股票: 002329.SZA 出现止损状况
      日期: 2016-01-26 07:00:00+00:00 股票: 002702.SZA 出现止损状况
      日期: 2016-01-26 07:00:00+00:00 股票: 600694.SHA 出现止损状况
      日期: 2016-01-27 07:00:00+00:00 股票: 600146.SHA 出现止损状况
      日期: 2016-01-27 07:00:00+00:00 股票: 002260.SZA 出现止损状况
      日期: 2016-01-27 07:00:00+00:00 股票: 002045.SZA 出现止损状况
      日期: 2016-01-28 07:00:00+00:00 股票: 000519.SZA 出现止损状况
      日期: 2016-01-28 07:00:00+00:00 股票: 002739.SZA 出现止损状况
      日期: 2016-01-28 07:00:00+00:00 股票: 600432.SHA 出现止损状况
      日期: 2016-02-25 07:00:00+00:00 股票: 002308.SZA 出现止损状况
      日期: 2016-02-25 07:00:00+00:00 股票: 002261.SZA 出现止损状况
      日期: 2016-02-25 07:00:00+00:00 股票: 300011.SZA 出现止损状况
      日期: 2016-02-25 07:00:00+00:00 股票: 002373.SZA 出现止损状况
      日期: 2016-02-25 07:00:00+00:00 股票: 300355.SZA 出现止损状况
      日期: 2016-02-25 07:00:00+00:00 股票: 000901.SZA 出现止损状况
      日期: 2016-02-25 07:00:00+00:00 股票: 002568.SZA 出现止损状况
      日期: 2016-02-29 07:00:00+00:00 股票: 300310.SZA 出现止损状况
      日期: 2016-02-29 07:00:00+00:00 股票: 300245.SZA 出现止损状况
      日期: 2016-03-04 07:00:00+00:00 股票: 002228.SZA 出现止损状况
      日期: 2016-03-04 07:00:00+00:00 股票: 300365.SZA 出现止损状况
      日期: 2016-04-11 07:00:00+00:00 股票: 300028.SZA 出现止损状况
      日期: 2016-04-20 07:00:00+00:00 股票: 600725.SHA 出现止损状况
      日期: 2016-04-21 07:00:00+00:00 股票: 300028.SZA 出现止损状况
      日期: 2016-04-25 07:00:00+00:00 股票: 600654.SHA 出现止损状况
      日期: 2016-05-09 07:00:00+00:00 股票: 600265.SHA 出现止损状况
      日期: 2016-05-09 07:00:00+00:00 股票: 600745.SHA 出现止损状况
      日期: 2016-05-09 07:00:00+00:00 股票: 002326.SZA 出现止损状况
      日期: 2016-05-10 07:00:00+00:00 股票: 600265.SHA 出现止损状况
      日期: 2016-05-11 07:00:00+00:00 股票: 600265.SHA 出现止损状况
      日期: 2016-05-11 07:00:00+00:00 股票: 601918.SHA 出现止损状况
      日期: 2016-05-12 07:00:00+00:00 股票: 600265.SHA 出现止损状况
      日期: 2016-05-18 07:00:00+00:00 股票: 002018.SZA 出现止损状况
      日期: 2016-06-13 07:00:00+00:00 股票: 600247.SHA 出现止损状况
      日期: 2016-06-14 07:00:00+00:00 股票: 600247.SHA 出现止损状况
      日期: 2016-06-22 07:00:00+00:00 股票: 000717.SZA 出现止损状况
      日期: 2016-08-01 07:00:00+00:00 股票: 600581.SHA 出现止损状况
      日期: 2016-08-08 07:00:00+00:00 股票: 002112.SZA 出现止损状况
      日期: 2016-12-12 07:00:00+00:00 股票: 300211.SZA 出现止损状况
      日期: 2016-12-12 07:00:00+00:00 股票: 002703.SZA 出现止损状况
      日期: 2016-12-12 07:00:00+00:00 股票: 002207.SZA 出现止损状况
      [2018-04-26 00:22:59.443814] INFO: Performance: Simulated 488 trading days out of 488.
      [2018-04-26 00:22:59.450278] INFO: Performance: first open: 2015-01-05 01:30:00+00:00
      [2018-04-26 00:22:59.463235] INFO: Performance: last close: 2016-12-30 07:00:00+00:00
      [注意] 有 327 笔卖出是在多天内完成的。当日卖出股票超过了当日股票交易的2.5%会出现这种情况。
      
      • 收益率257.92%
      • 年化收益率93.18%
      • 基准收益率-6.33%
      • 阿尔法0.96
      • 贝塔0.98
      • 夏普比率2.0
      • 胜率0.622
      • 盈亏比0.898
      • 收益波动率44.84%
      • 信息比率3.01
      • 最大回撤60.07%
      [2018-04-26 00:23:32.185818] INFO: bigquant: backtest.v7 运行完成[663.371966s].
      

      (yilong10) #3

      好的,感谢回复~