{"Description":"实验创建于2017/8/26","Summary":"","Graph":{"EdgesInternal":[{"DestinationInputPortId":"-50:features","SourceOutputPortId":"287d2cb0-f53c-4101-bdf8-104b137c8601-24:data"},{"DestinationInputPortId":"-57:features","SourceOutputPortId":"287d2cb0-f53c-4101-bdf8-104b137c8601-24:data"},{"DestinationInputPortId":"-50:instruments","SourceOutputPortId":"287d2cb0-f53c-4101-bdf8-104b137c8601-62:data"},{"DestinationInputPortId":"-102:instruments","SourceOutputPortId":"287d2cb0-f53c-4101-bdf8-104b137c8601-62:data"},{"DestinationInputPortId":"-102:options_data","SourceOutputPortId":"-86:data"},{"DestinationInputPortId":"-57:input_data","SourceOutputPortId":"-50:data"},{"DestinationInputPortId":"-86:input_data","SourceOutputPortId":"-57:data"}],"ModuleNodes":[{"Id":"287d2cb0-f53c-4101-bdf8-104b137c8601-24","ModuleId":"BigQuantSpace.input_features.input_features-v1","ModuleParameters":[{"Name":"features","Value":"# #号开始的表示注释\n# 多个特征,每行一个,可以包含基础特征和衍生特征\nbuy_condition=where(mean(close_0,5)>mean(close_0,20),1,0)\nsell_condition=where(mean(close_0,5)<mean(close_0,20),1,0)","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":false,"moduleIdForCode":1,"IsPartOfPartialRun":null,"Comment":"","CommentCollapsed":true},{"Id":"287d2cb0-f53c-4101-bdf8-104b137c8601-62","ModuleId":"BigQuantSpace.instruments.instruments-v2","ModuleParameters":[{"Name":"start_date","Value":"2016-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":"600519.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":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":6,"IsPartOfPartialRun":null,"Comment":"","CommentCollapsed":true},{"Id":"-50","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":"200","ValueType":"Literal","LinkedGlobalParameter":null}],"InputPortsInternal":[{"DataSourceId":null,"TrainedModelId":null,"TransformModuleId":null,"Name":"instruments","NodeId":"-50"},{"DataSourceId":null,"TrainedModelId":null,"TransformModuleId":null,"Name":"features","NodeId":"-50"}],"OutputPortsInternal":[{"Name":"data","NodeId":"-50","OutputType":null}],"UsePreviousResults":false,"moduleIdForCode":7,"IsPartOfPartialRun":null,"Comment":"","CommentCollapsed":true},{"Id":"-57","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":"-57"},{"DataSourceId":null,"TrainedModelId":null,"TransformModuleId":null,"Name":"features","NodeId":"-57"}],"OutputPortsInternal":[{"Name":"data","NodeId":"-57","OutputType":null}],"UsePreviousResults":true,"moduleIdForCode":8,"IsPartOfPartialRun":null,"Comment":"","CommentCollapsed":true},{"Id":"-102","ModuleId":"BigQuantSpace.trade.trade-v4","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 # 1. 获取今日的日期\n today = data.current_dt.strftime('%Y-%m-%d')\n \n # 2. 获取目前持仓的股票和最新市值\n stock_hold_now = {e.symbol: p.amount * p.last_sale_price for e, p in context.portfolio.positions.items()} \n \n # 3. 获取当前账户可用现金\n cash_for_buy = context.portfolio.cash\n \n # 4. 获取当日的买卖信号股票列表\n try:\n buy_stock = context.daily_stock_buy[today]\n except:\n buy_stock=[] # 如果没有符合条件的股票,就设置为空\n \n try:\n sell_stock = context.daily_stock_sell[today]\n except:\n sell_stock=[] # 如果没有符合条件的股票,就设置为空 \n \n # 5. 确认需要卖出的股票:已有持仓中符合卖出条件的股票\n stock_to_sell = [ i for i in stock_hold_now if i in sell_stock ]\n \n # 6. 执行卖出操作\n if len(stock_to_sell)>0:\n for instrument in stock_to_sell:\n sid = context.symbol(instrument) # 将标的转化为equity格式\n cur_position = context.portfolio.positions[sid].amount # 当前持仓\n if cur_position > 0 and data.can_trade(sid):\n context.order_target_percent(sid, 0) \n # 根据卖出的股票市值更新可用现金;\n cash_for_buy += stock_hold_now[instrument]\n \n # 7. 执行买入操作\n if len(buy_stock)>0:\n weight = 1/len(buy_stock) # 每只股票的比重为等资金比例持有\n for instrument in buy_stock:\n sid = context.symbol(instrument) # 将标的转化为equity格式\n cur_position = context.portfolio.positions[sid].amount # 当前持仓\n if data.can_trade(sid) and cur_position==0:\n context.order_target_value(sid, weight*cash_for_buy) # 按可用现金等比例买入","ValueType":"Literal","LinkedGlobalParameter":null},{"Name":"prepare","Value":"# 回测引擎:准备数据,只执行一次\ndef bigquant_run(context):\n # 加载预测数据\n df = context.options['data'].read_df()\n\n # 函数:求满足开仓条件的股票列表\n def open_pos_con(df):\n return list(df[df['buy_condition']>0].instrument)\n\n # 函数:求满足平仓条件的股票列表\n def close_pos_con(df):\n return list(df[df['sell_condition']>0].instrument)\n\n # 每日买入股票的数据框\n context.daily_stock_buy= df.groupby('date').apply(open_pos_con)\n # 每日卖出股票的数据框\n context.daily_stock_sell= df.groupby('date').apply(close_pos_con)","ValueType":"Literal","LinkedGlobalParameter":null},{"Name":"initialize","Value":"# 回测引擎:初始化函数,只执行一次\ndef bigquant_run(context):\n \n # 系统已经设置了默认的交易手续费和滑点,要修改手续费可使用如下函数\n context.set_commission(PerOrder(buy_cost=0.0003, sell_cost=0.0013, min_cost=5))","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":"close","ValueType":"Literal","LinkedGlobalParameter":null},{"Name":"order_price_field_sell","Value":"close","ValueType":"Literal","LinkedGlobalParameter":null},{"Name":"capital_base","Value":1000000,"ValueType":"Literal","LinkedGlobalParameter":null},{"Name":"auto_cancel_non_tradable_orders","Value":"True","ValueType":"Literal","LinkedGlobalParameter":null},{"Name":"data_frequency","Value":"daily","ValueType":"Literal","LinkedGlobalParameter":null},{"Name":"price_type","Value":"后复权","ValueType":"Literal","LinkedGlobalParameter":null},{"Name":"product_type","Value":"股票","ValueType":"Literal","LinkedGlobalParameter":null},{"Name":"plot_charts","Value":"True","ValueType":"Literal","LinkedGlobalParameter":null},{"Name":"backtest_only","Value":"False","ValueType":"Literal","LinkedGlobalParameter":null},{"Name":"benchmark","Value":"","ValueType":"Literal","LinkedGlobalParameter":null}],"InputPortsInternal":[{"DataSourceId":null,"TrainedModelId":null,"TransformModuleId":null,"Name":"instruments","NodeId":"-102"},{"DataSourceId":null,"TrainedModelId":null,"TransformModuleId":null,"Name":"options_data","NodeId":"-102"},{"DataSourceId":null,"TrainedModelId":null,"TransformModuleId":null,"Name":"history_ds","NodeId":"-102"},{"DataSourceId":null,"TrainedModelId":null,"TransformModuleId":null,"Name":"benchmark_ds","NodeId":"-102"},{"DataSourceId":null,"TrainedModelId":null,"TransformModuleId":null,"Name":"trading_calendar","NodeId":"-102"}],"OutputPortsInternal":[{"Name":"raw_perf","NodeId":"-102","OutputType":null}],"UsePreviousResults":false,"moduleIdForCode":3,"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-24' Position='1165,136,200,200'/><NodePosition Node='287d2cb0-f53c-4101-bdf8-104b137c8601-62' Position='868,91,200,200'/><NodePosition Node='-86' Position='1078,418,200,200'/><NodePosition Node='-50' Position='1071,238,200,200'/><NodePosition Node='-57' Position='1076,327,200,200'/><NodePosition Node='-102' Position='972,505,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-20 13:14:10.005262] INFO: bigquant: input_features.v1 开始运行..
[2019-06-20 13:14:10.063670] INFO: bigquant: input_features.v1 运行完成[0.058405s].
[2019-06-20 13:14:10.067459] INFO: bigquant: instruments.v2 开始运行..
[2019-06-20 13:14:10.094217] INFO: bigquant: 命中缓存
[2019-06-20 13:14:10.095947] INFO: bigquant: instruments.v2 运行完成[0.028497s].
[2019-06-20 13:14:10.128575] INFO: bigquant: general_feature_extractor.v7 开始运行..
[2019-06-20 13:14:10.246481] INFO: 基础特征抽取: 年份 2015, 特征行数=136
[2019-06-20 13:14:10.273475] INFO: 基础特征抽取: 年份 2016, 特征行数=244
[2019-06-20 13:14:10.285415] INFO: 基础特征抽取: 年份 2017, 特征行数=0
[2019-06-20 13:14:10.345540] INFO: 基础特征抽取: 总行数: 380
[2019-06-20 13:14:10.347480] INFO: bigquant: general_feature_extractor.v7 运行完成[0.218905s].
[2019-06-20 13:14:10.350536] INFO: bigquant: derived_feature_extractor.v3 开始运行..
[2019-06-20 13:14:10.436890] INFO: derived_feature_extractor: 提取完成 buy_condition=where(mean(close_0,5)>mean(close_0,20),1,0), 0.007s
[2019-06-20 13:14:10.446629] INFO: derived_feature_extractor: 提取完成 sell_condition=where(mean(close_0,5)[2019-06-20 13:14:10.486996] INFO: derived_feature_extractor: /y_2015, 136
[2019-06-20 13:14:10.513525] INFO: derived_feature_extractor: /y_2016, 244
[2019-06-20 13:14:10.613676] INFO: bigquant: derived_feature_extractor.v3 运行完成[0.263128s].
[2019-06-20 13:14:10.616840] INFO: bigquant: dropnan.v1 开始运行..
[2019-06-20 13:14:10.695606] INFO: dropnan: /y_2015, 136/136
[2019-06-20 13:14:10.726307] INFO: dropnan: /y_2016, 244/244
[2019-06-20 13:14:10.813265] INFO: dropnan: 行数: 380/380
[2019-06-20 13:14:10.816473] INFO: bigquant: dropnan.v1 运行完成[0.199615s].
[2019-06-20 13:14:10.860465] INFO: bigquant: backtest.v8 开始运行..
[2019-06-20 13:14:10.864171] INFO: bigquant: biglearning backtest:V8.2.2
[2019-06-20 13:14:11.500200] INFO: bigquant: product_type:stock by specified
[2019-06-20 13:14:11.687216] INFO: bigquant: cached.v2 开始运行..
[2019-06-20 13:14:11.726424] INFO: bigquant: 命中缓存
[2019-06-20 13:14:11.729266] INFO: bigquant: cached.v2 运行完成[0.04205s].
[2019-06-20 13:14:11.768565] INFO: algo: TradingAlgorithm V1.5.0
[2019-06-20 13:14:11.812191] INFO: algo: trading transform...
[2019-06-20 13:14:12.482313] INFO: Performance: Simulated 244 trading days out of 244.
[2019-06-20 13:14:12.484003] INFO: Performance: first open: 2016-01-04 09:30:00+00:00
[2019-06-20 13:14:12.485730] INFO: Performance: last close: 2016-12-30 15:00:00+00:00
[2019-06-20 13:14:13.484915] INFO: bigquant: backtest.v8 运行完成[2.624447s].
- 收益率40.57%
- 年化收益率42.15%
- 基准收益率-11.28%
- 阿尔法0.38
- 贝塔0.3
- 夏普比率1.59
- 胜率0.67
- 盈亏比3.01
- 收益波动率21.81%
- 信息比率0.12
- 最大回撤11.05%
bigcharts-data-start/{"__type":"tabs","__id":"bigchart-712f0f11151f472d97bd3a10ef466e4c"}/bigcharts-data-end