{"Description":"实验创建于2017/8/26","Summary":"","Graph":{"EdgesInternal":[{"DestinationInputPortId":"-836:features","SourceOutputPortId":"287d2cb0-f53c-4101-bdf8-104b137c8601-24:data"},{"DestinationInputPortId":"-3301:features","SourceOutputPortId":"287d2cb0-f53c-4101-bdf8-104b137c8601-24:data"},{"DestinationInputPortId":"-836:instruments","SourceOutputPortId":"287d2cb0-f53c-4101-bdf8-104b137c8601-62:data"},{"DestinationInputPortId":"-3041:instruments","SourceOutputPortId":"287d2cb0-f53c-4101-bdf8-104b137c8601-62:data"},{"DestinationInputPortId":"-3301:input_data","SourceOutputPortId":"-836:data"},{"DestinationInputPortId":"-399:input_data","SourceOutputPortId":"-3301:data"},{"DestinationInputPortId":"-3041:options_data","SourceOutputPortId":"-399:data"}],"ModuleNodes":[{"Id":"287d2cb0-f53c-4101-bdf8-104b137c8601-24","ModuleId":"BigQuantSpace.input_features.input_features-v1","ModuleParameters":[{"Name":"features","Value":"# #号开始的表示注释\n# 多个特征,每行一个,可以包含基础特征和衍生特征\nclose_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":1,"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":"2018-10-28","ValueType":"Literal","LinkedGlobalParameter":"交易日期"},{"Name":"market","Value":"CN_STOCK_A","ValueType":"Literal","LinkedGlobalParameter":null},{"Name":"instrument_list","Value":"601328.SHA\n601998.SHA","ValueType":"Literal","LinkedGlobalParameter":null},{"Name":"max_count","Value":"0","ValueType":"Literal","LinkedGlobalParameter":null}],"InputPortsInternal":[{"DataSourceId":null,"TrainedModelId":null,"TransformModuleId":null,"Name":"rolling_conf","NodeId":"287d2cb0-f53c-4101-bdf8-104b137c8601-62"}],"OutputPortsInternal":[{"Name":"data","NodeId":"287d2cb0-f53c-4101-bdf8-104b137c8601-62","OutputType":null}],"UsePreviousResults":true,"moduleIdForCode":2,"IsPartOfPartialRun":null,"Comment":"预测数据,用于回测和模拟","CommentCollapsed":false},{"Id":"-836","ModuleId":"BigQuantSpace.general_feature_extractor.general_feature_extractor-v7","ModuleParameters":[{"Name":"start_date","Value":"","ValueType":"Literal","LinkedGlobalParameter":null},{"Name":"end_date","Value":"","ValueType":"Literal","LinkedGlobalParameter":null},{"Name":"before_start_days","Value":"300","ValueType":"Literal","LinkedGlobalParameter":null}],"InputPortsInternal":[{"DataSourceId":null,"TrainedModelId":null,"TransformModuleId":null,"Name":"instruments","NodeId":"-836"},{"DataSourceId":null,"TrainedModelId":null,"TransformModuleId":null,"Name":"features","NodeId":"-836"}],"OutputPortsInternal":[{"Name":"data","NodeId":"-836","OutputType":null}],"UsePreviousResults":true,"moduleIdForCode":7,"IsPartOfPartialRun":null,"Comment":"","CommentCollapsed":true},{"Id":"-3041","ModuleId":"BigQuantSpace.trade.trade-v4","ModuleParameters":[{"Name":"start_date","Value":"","ValueType":"Literal","LinkedGlobalParameter":null},{"Name":"end_date","Value":"","ValueType":"Literal","LinkedGlobalParameter":null},{"Name":"initialize","Value":"# 回测引擎:初始化函数,只执行一次\ndef bigquant_run(context):\n # 系统已经设置了默认的交易手续费和滑点,要修改手续费可使用如下函数\n context.set_commission(PerOrder(buy_cost=0.0003, sell_cost=0.0013, min_cost=5))","ValueType":"Literal","LinkedGlobalParameter":null},{"Name":"handle_data","Value":"# 回测引擎:每日数据处理函数,每天执行一次\ndef bigquant_run(context, data):\n today = data.current_dt.strftime('%Y-%m-%d')\n zscore_today =context.zscore.ix[today]\n #获取股票的列表\n stocklist=context.instruments\n # 转换成回测引擎所需要的symbol格式\n symbol_1 = context.symbol(stocklist[0]) \n symbol_2 = context.symbol(stocklist[1]) \n\n # 持仓\n cur_position_1 = context.portfolio.positions[symbol_1].amount\n cur_position_2 = context.portfolio.positions[symbol_2].amount\n \n # 交易逻辑\n # 如果zscore大于上轨(>1),则价差会向下回归均值,因此需要买入股票x,卖出股票y\n if zscore_today > 1 and cur_position_1 == 0 and data.can_trade(symbol_1) and data.can_trade(symbol_2): \n context.order_target_percent(symbol_2, 0)\n context.order_target_percent(symbol_1, 1)\n print(today, '全仓买入:',stocklist[0])\n \n # 如果zscore小于下轨(<-1),则价差会向上回归均值,因此需要买入股票y,卖出股票x\n elif zscore_today < -1 and cur_position_2 == 0 and data.can_trade(symbol_1) and data.can_trade(symbol_2): \n context.order_target_percent(symbol_1, 0) \n context.order_target_percent(symbol_2, 1)\n print(today, '全仓买入:',stocklist[1])\n \n \n","ValueType":"Literal","LinkedGlobalParameter":null},{"Name":"prepare","Value":"# 回测引擎:准备数据,只执行一次\ndef bigquant_run(context):\n pass","ValueType":"Literal","LinkedGlobalParameter":null},{"Name":"before_trading_start","Value":"# 回测引擎:准备数据,只执行一次\ndef bigquant_run(context,data):\n # 加载股票历史数据\n df = context.options['data'].read_df()\n df['date'] = df['date'].apply(lambda x:x.strftime('%Y-%m-%d'))\n today = data.current_dt.strftime('%Y-%m-%d')\n # 获取前240个自然日的数据\n start_date = (pd.to_datetime(data.current_dt)-datetime.timedelta(days=240)).strftime('%Y-%m-%d')\n stock_data = df[df.date <= today]\n # 由于可能上市天数不同,对缺失值填充处理\n prices_df=pd.pivot_table(stock_data, values='close_0', index=['date'], columns=['instrument'])\n prices_df.fillna(method='ffill',inplace=True)\n \n x = prices_df[context.instruments[0]] # 股票1\n y = prices_df[context.instruments[1]] # 股票2\n \n # 线性回归两个股票的股价 y=ax+b\n from pyfinance import ols\n model = ols.OLS(y=y, x=x)\n \n def zscore(series):\n return (series - series.mean()) / np.std(series)\n \n # 计算 y-a*x 序列的zscore值序列\n zscore_calcu = zscore(y-model.beta*x)\n context.zscore=zscore_calcu","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":"open","ValueType":"Literal","LinkedGlobalParameter":null},{"Name":"capital_base","Value":1000000,"ValueType":"Literal","LinkedGlobalParameter":null},{"Name":"auto_cancel_non_tradable_orders","Value":"True","ValueType":"Literal","LinkedGlobalParameter":null},{"Name":"data_frequency","Value":"daily","ValueType":"Literal","LinkedGlobalParameter":null},{"Name":"price_type","Value":"真实价格","ValueType":"Literal","LinkedGlobalParameter":null},{"Name":"product_type","Value":"股票","ValueType":"Literal","LinkedGlobalParameter":null},{"Name":"plot_charts","Value":"True","ValueType":"Literal","LinkedGlobalParameter":null},{"Name":"backtest_only","Value":"False","ValueType":"Literal","LinkedGlobalParameter":null},{"Name":"benchmark","Value":"","ValueType":"Literal","LinkedGlobalParameter":null}],"InputPortsInternal":[{"DataSourceId":null,"TrainedModelId":null,"TransformModuleId":null,"Name":"instruments","NodeId":"-3041"},{"DataSourceId":null,"TrainedModelId":null,"TransformModuleId":null,"Name":"options_data","NodeId":"-3041"},{"DataSourceId":null,"TrainedModelId":null,"TransformModuleId":null,"Name":"history_ds","NodeId":"-3041"},{"DataSourceId":null,"TrainedModelId":null,"TransformModuleId":null,"Name":"benchmark_ds","NodeId":"-3041"},{"DataSourceId":null,"TrainedModelId":null,"TransformModuleId":null,"Name":"trading_calendar","NodeId":"-3041"}],"OutputPortsInternal":[{"Name":"raw_perf","NodeId":"-3041","OutputType":null}],"UsePreviousResults":false,"moduleIdForCode":3,"IsPartOfPartialRun":null,"Comment":"","CommentCollapsed":true},{"Id":"-3301","ModuleId":"BigQuantSpace.derived_feature_extractor.derived_feature_extractor-v3","ModuleParameters":[{"Name":"date_col","Value":"date","ValueType":"Literal","LinkedGlobalParameter":null},{"Name":"instrument_col","Value":"instrument","ValueType":"Literal","LinkedGlobalParameter":null},{"Name":"drop_na","Value":"False","ValueType":"Literal","LinkedGlobalParameter":null},{"Name":"remove_extra_columns","Value":"False","ValueType":"Literal","LinkedGlobalParameter":null},{"Name":"user_functions","Value":"{}","ValueType":"Literal","LinkedGlobalParameter":null}],"InputPortsInternal":[{"DataSourceId":null,"TrainedModelId":null,"TransformModuleId":null,"Name":"input_data","NodeId":"-3301"},{"DataSourceId":null,"TrainedModelId":null,"TransformModuleId":null,"Name":"features","NodeId":"-3301"}],"OutputPortsInternal":[{"Name":"data","NodeId":"-3301","OutputType":null}],"UsePreviousResults":true,"moduleIdForCode":4,"IsPartOfPartialRun":null,"Comment":"","CommentCollapsed":true},{"Id":"-399","ModuleId":"BigQuantSpace.dropnan.dropnan-v2","ModuleParameters":[],"InputPortsInternal":[{"DataSourceId":null,"TrainedModelId":null,"TransformModuleId":null,"Name":"input_data","NodeId":"-399"},{"DataSourceId":null,"TrainedModelId":null,"TransformModuleId":null,"Name":"features","NodeId":"-399"}],"OutputPortsInternal":[{"Name":"data","NodeId":"-399","OutputType":null}],"UsePreviousResults":true,"moduleIdForCode":5,"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-24' Position='1306,105,200,200'/><NodePosition Node='287d2cb0-f53c-4101-bdf8-104b137c8601-62' Position='812,113,200,200'/><NodePosition Node='-836' Position='1079,236,200,200'/><NodePosition Node='-3041' Position='999,558,200,200'/><NodePosition Node='-3301' Position='1088,305,200,200'/><NodePosition Node='-399' Position='1079,397,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}
[2019-06-21 09:53:38.503017] INFO: bigquant: input_features.v1 开始运行..
[2019-06-21 09:53:38.545842] INFO: bigquant: 命中缓存
[2019-06-21 09:53:38.556901] INFO: bigquant: input_features.v1 运行完成[0.053881s].
[2019-06-21 09:53:38.560006] INFO: bigquant: instruments.v2 开始运行..
[2019-06-21 09:53:38.602468] INFO: bigquant: 命中缓存
[2019-06-21 09:53:38.604658] INFO: bigquant: instruments.v2 运行完成[0.044642s].
[2019-06-21 09:53:38.635206] INFO: bigquant: general_feature_extractor.v7 开始运行..
[2019-06-21 09:53:38.665744] INFO: bigquant: 命中缓存
[2019-06-21 09:53:38.667802] INFO: bigquant: general_feature_extractor.v7 运行完成[0.032597s].
[2019-06-21 09:53:38.670660] INFO: bigquant: derived_feature_extractor.v3 开始运行..
[2019-06-21 09:53:38.711715] INFO: bigquant: 命中缓存
[2019-06-21 09:53:38.713990] INFO: bigquant: derived_feature_extractor.v3 运行完成[0.04332s].
[2019-06-21 09:53:38.716530] INFO: bigquant: dropnan.v1 开始运行..
[2019-06-21 09:53:38.742758] INFO: bigquant: 命中缓存
[2019-06-21 09:53:38.744626] INFO: bigquant: dropnan.v1 运行完成[0.028085s].
[2019-06-21 09:53:38.791453] INFO: bigquant: backtest.v8 开始运行..
[2019-06-21 09:53:38.794461] INFO: bigquant: biglearning backtest:V8.2.2
[2019-06-21 09:53:38.795752] INFO: bigquant: product_type:stock by specified
[2019-06-21 09:53:39.084577] INFO: bigquant: cached.v2 开始运行..
[2019-06-21 09:53:39.128779] INFO: bigquant: 命中缓存
[2019-06-21 09:53:39.130639] INFO: bigquant: cached.v2 运行完成[0.046066s].
[2019-06-21 09:53:39.184503] INFO: algo: TradingAlgorithm V1.5.0
[2019-06-21 09:53:39.373587] INFO: algo: trading transform...
[2019-06-21 09:54:29.600489] INFO: algo: handle_splits get splits [dt:2016-07-25 00:00:00+00:00] [asset:Equity(0 [601998.SHA]), ratio:0.9657426445424234]
[2019-06-21 09:54:29.602455] INFO: Position: position stock handle split[sid:0, orig_amount:183300, new_amount:189802.0, orig_cost:5.690047724566808, new_cost:5.5, ratio:0.9657426445424234, last_sale_price:5.9200025215655305]
[2019-06-21 09:54:29.604078] INFO: Position: after split: asset: Equity(0 [601998.SHA]), amount: 189802.0, cost_basis: 5.5, last_sale_price: 6.130000114440918
[2019-06-21 09:54:29.605697] INFO: Position: returning cash: 0.7
[2019-06-21 09:55:01.107468] INFO: algo: handle_splits get splits [dt:2017-07-24 00:00:00+00:00] [asset:Equity(0 [601998.SHA]), ratio:0.9700427168666901]
[2019-06-21 09:55:01.110080] INFO: Position: position stock handle split[sid:0, orig_amount:218600, new_amount:225350.0, orig_cost:6.1500281882553605, new_cost:5.97, ratio:0.9700427168666901, last_sale_price:6.799999667260655]
[2019-06-21 09:55:01.112385] INFO: Position: after split: asset: Equity(0 [601998.SHA]), amount: 225350.0, cost_basis: 5.97, last_sale_price: 7.010000228881836
[2019-06-21 09:55:01.114301] INFO: Position: returning cash: 6.13
[2019-06-21 09:55:33.612472] INFO: algo: handle_splits get splits [dt:2018-07-16 00:00:00+00:00] [asset:Equity(1 [601328.SHA]), ratio:0.9517470390385913]
[2019-06-21 09:55:33.614314] INFO: Position: position stock handle split[sid:1, orig_amount:254600, new_amount:267508.0, orig_cost:7.0600000818200925, new_cost:6.72, ratio:0.9517470390385913, last_sale_price:5.7199994686311895]
[2019-06-21 09:55:33.615812] INFO: Position: after split: asset: Equity(1 [601328.SHA]), amount: 267508.0, cost_basis: 6.72, last_sale_price: 6.009999752044678
[2019-06-21 09:55:33.617095] INFO: Position: returning cash: 0.32
[2019-06-21 09:55:42.568981] INFO: Performance: Simulated 930 trading days out of 930.
[2019-06-21 09:55:42.571150] INFO: Performance: first open: 2015-01-05 09:30:00+00:00
[2019-06-21 09:55:42.573583] INFO: Performance: last close: 2018-10-26 15:00:00+00:00
[2019-06-21 09:55:44.571635] INFO: bigquant: backtest.v8 运行完成[125.780166s].
2015-01-05 全仓买入: 601328.SHA
2015-06-01 全仓买入: 601998.SHA
2015-07-08 全仓买入: 601328.SHA
2015-08-31 全仓买入: 601998.SHA
2015-11-18 全仓买入: 601328.SHA
2016-06-06 全仓买入: 601998.SHA
2016-11-28 全仓买入: 601328.SHA
2017-04-19 全仓买入: 601998.SHA
2018-02-05 全仓买入: 601328.SHA
2018-09-14 全仓买入: 601998.SHA
- 收益率54.33%
- 年化收益率12.48%
- 基准收益率-10.19%
- 阿尔法0.15
- 贝塔0.74
- 夏普比率0.44
- 胜率0.67
- 盈亏比0.69
- 收益波动率30.75%
- 信息比率0.04
- 最大回撤40.63%
bigcharts-data-start/{"__id":"bigchart-56cff1c73cbc45268d29cd7a4da5d1ce","__type":"tabs"}/bigcharts-data-end