{"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":"-57:input_data","SourceOutputPortId":"-50:data"},{"DestinationInputPortId":"-455:input_data","SourceOutputPortId":"-57:data"},{"DestinationInputPortId":"-102:options_data","SourceOutputPortId":"-455: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":false},{"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":"initialize","Value":"# 回测引擎:初始化函数,只执行一次\ndef bigquant_run(context):\n\n # 系统已经设置了默认的交易手续费和滑点,要修改手续费可使用如下函数\n context.set_commission(PerOrder(buy_cost=0.0003, sell_cost=0.0013, min_cost=5))\n","ValueType":"Literal","LinkedGlobalParameter":null},{"Name":"handle_data","Value":"# 回测引擎:每日数据处理函数,每天执行一次\ndef bigquant_run(context, data):\n \n #------------------------------------------止损模块START------------------------------------------- #\n date = data.current_dt.strftime('%Y-%m-%d')\n positions = {e.symbol: p.cost_basis for e, p in context.portfolio.positions.items()}\n # 新建当日止赢股票列表是为了handle_data 策略逻辑部分不再对该股票进行判断\n current_stopwin_stock = [] \n if len(positions) > 0:\n for i in positions.keys():\n stock_cost = positions[i] \n stock_market_price = data.current(context.symbol(i), 'price') \n # 赚10%止盈\n if stock_market_price / stock_cost -1 > 0.1: \n context.order_target_percent(context.symbol(i),0) \n current_stopwin_stock.append(i)\n print('日期:',date,'股票:',i,'出现上涨10%,触发止盈')\n #-------------------------------------------止损模块END---------------------------------------------#\n\n\n\n\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 # 如果股票已经在止盈列表中,则跳过卖出操作\n if instrument in current_stopwin_stock:\n continue\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":"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":"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":"-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},{"Id":"-455","ModuleId":"BigQuantSpace.dropnan.dropnan-v2","ModuleParameters":[],"InputPortsInternal":[{"DataSourceId":null,"TrainedModelId":null,"TransformModuleId":null,"Name":"input_data","NodeId":"-455"},{"DataSourceId":null,"TrainedModelId":null,"TransformModuleId":null,"Name":"features","NodeId":"-455"}],"OutputPortsInternal":[{"Name":"data","NodeId":"-455","OutputType":null}],"UsePreviousResults":true,"moduleIdForCode":4,"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='765,19,200,200'/><NodePosition Node='287d2cb0-f53c-4101-bdf8-104b137c8601-62' Position='1072,123,200,200'/><NodePosition Node='-50' Position='1078,232,200,200'/><NodePosition Node='-57' Position='1076,327,200,200'/><NodePosition Node='-102' Position='1048,529,200,200'/><NodePosition Node='-455' Position='1077,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}
[2019-09-19 17:23:07.792873] INFO: bigquant: input_features.v1 开始运行..
[2019-09-19 17:23:08.186172] INFO: bigquant: input_features.v1 运行完成[0.393294s].
[2019-09-19 17:23:08.197696] INFO: bigquant: instruments.v2 开始运行..
[2019-09-19 17:23:08.701834] INFO: bigquant: 命中缓存
[2019-09-19 17:23:08.704262] INFO: bigquant: instruments.v2 运行完成[0.506546s].
[2019-09-19 17:23:09.307162] INFO: bigquant: general_feature_extractor.v7 开始运行..
[2019-09-19 17:23:09.853597] INFO: 基础特征抽取: 年份 2015, 特征行数=136
[2019-09-19 17:23:09.896071] INFO: 基础特征抽取: 年份 2016, 特征行数=244
[2019-09-19 17:23:09.918153] INFO: 基础特征抽取: 年份 2017, 特征行数=0
[2019-09-19 17:23:10.247284] INFO: 基础特征抽取: 总行数: 380
[2019-09-19 17:23:10.254148] INFO: bigquant: general_feature_extractor.v7 运行完成[0.946984s].
[2019-09-19 17:23:10.261087] INFO: bigquant: derived_feature_extractor.v3 开始运行..
[2019-09-19 17:23:10.718868] INFO: derived_feature_extractor: 提取完成 buy_condition=where(mean(close_0,5)>mean(close_0,20),1,0), 0.012s
[2019-09-19 17:23:10.743357] INFO: derived_feature_extractor: 提取完成 sell_condition=where(mean(close_0,5)[2019-09-19 17:23:11.037936] INFO: derived_feature_extractor: /y_2015, 136
[2019-09-19 17:23:11.095965] INFO: derived_feature_extractor: /y_2016, 244
[2019-09-19 17:23:11.450596] INFO: bigquant: derived_feature_extractor.v3 运行完成[1.189501s].
[2019-09-19 17:23:11.458106] INFO: bigquant: dropnan.v1 开始运行..
[2019-09-19 17:23:11.694375] INFO: dropnan: /y_2015, 136/136
[2019-09-19 17:23:11.733158] INFO: dropnan: /y_2016, 244/244
[2019-09-19 17:23:11.935565] INFO: dropnan: 行数: 380/380
[2019-09-19 17:23:11.950387] INFO: bigquant: dropnan.v1 运行完成[0.492258s].
[2019-09-19 17:23:12.028427] INFO: bigquant: backtest.v8 开始运行..
[2019-09-19 17:23:12.117618] INFO: bigquant: biglearning backtest:V8.2.13
[2019-09-19 17:23:13.218853] INFO: bigquant: product_type:stock by specified
[2019-09-19 17:23:13.622276] INFO: bigquant: cached.v2 开始运行..
[2019-09-19 17:23:13.739935] INFO: bigquant: 命中缓存
[2019-09-19 17:23:13.745772] INFO: bigquant: cached.v2 运行完成[0.123481s].
[2019-09-19 17:23:13.916656] INFO: algo: TradingAlgorithm V1.5.8
[2019-09-19 17:23:14.001222] INFO: algo: trading transform...
[2019-09-19 17:23:15.111988] INFO: Performance: Simulated 244 trading days out of 244.
[2019-09-19 17:23:15.117268] INFO: Performance: first open: 2016-01-04 09:30:00+00:00
[2019-09-19 17:23:15.124464] INFO: Performance: last close: 2016-12-30 15:00:00+00:00
[2019-09-19 17:23:17.419454] INFO: bigquant: backtest.v8 运行完成[5.391029s].
日期: 2016-03-03 股票: 600519.SHA 出现上涨10%,触发止盈
日期: 2016-06-03 股票: 600519.SHA 出现上涨10%,触发止盈
日期: 2016-07-05 股票: 600519.SHA 出现上涨10%,触发止盈
- 收益率28.16%
- 年化收益率29.21%
- 基准收益率-11.28%
- 阿尔法0.29
- 贝塔0.3
- 夏普比率1.2
- 胜率0.56
- 盈亏比3.01
- 收益波动率20.66%
- 信息比率0.09
- 最大回撤10.38%
bigcharts-data-start/{"__type":"tabs","__id":"bigchart-98dd58eca2ef47d28cebe0c77f0b82b4"}/bigcharts-data-end