{"description":"实验创建于2017/8/26","graph":{"edges":[{"to_node_id":"-50:features","from_node_id":"287d2cb0-f53c-4101-bdf8-104b137c8601-24:data"},{"to_node_id":"-57:features","from_node_id":"287d2cb0-f53c-4101-bdf8-104b137c8601-24:data"},{"to_node_id":"-50:instruments","from_node_id":"287d2cb0-f53c-4101-bdf8-104b137c8601-62:data"},{"to_node_id":"-102:instruments","from_node_id":"287d2cb0-f53c-4101-bdf8-104b137c8601-62:data"},{"to_node_id":"-57:input_data","from_node_id":"-50:data"},{"to_node_id":"-689:input_data","from_node_id":"-57:data"},{"to_node_id":"-102:options_data","from_node_id":"-689:data"}],"nodes":[{"node_id":"287d2cb0-f53c-4101-bdf8-104b137c8601-24","module_id":"BigQuantSpace.input_features.input_features-v1","parameters":[{"name":"features","value":"# #号开始的表示注释\n# 多个特征,每行一个,可以包含基础特征和衍生特征\nbuy_condition=where(mean(close_0,5)>mean(close_0,10),1,0)\nsell_condition=where(mean(close_0,5)<mean(close_0,10),1,0)","type":"Literal","bound_global_parameter":null}],"input_ports":[{"name":"features_ds","node_id":"287d2cb0-f53c-4101-bdf8-104b137c8601-24"}],"output_ports":[{"name":"data","node_id":"287d2cb0-f53c-4101-bdf8-104b137c8601-24"}],"cacheable":false,"seq_num":1,"comment":"","comment_collapsed":true},{"node_id":"287d2cb0-f53c-4101-bdf8-104b137c8601-62","module_id":"BigQuantSpace.instruments.instruments-v2","parameters":[{"name":"start_date","value":"2021-05-01","type":"Literal","bound_global_parameter":"交易日期"},{"name":"end_date","value":"2021-06-01","type":"Literal","bound_global_parameter":"交易日期"},{"name":"market","value":"CN_STOCK_A","type":"Literal","bound_global_parameter":null},{"name":"instrument_list","value":"600519.SHA\n600333.SHA","type":"Literal","bound_global_parameter":null},{"name":"max_count","value":"0","type":"Literal","bound_global_parameter":null}],"input_ports":[{"name":"rolling_conf","node_id":"287d2cb0-f53c-4101-bdf8-104b137c8601-62"}],"output_ports":[{"name":"data","node_id":"287d2cb0-f53c-4101-bdf8-104b137c8601-62"}],"cacheable":true,"seq_num":2,"comment":"预测数据,用于回测和模拟","comment_collapsed":false},{"node_id":"-50","module_id":"BigQuantSpace.general_feature_extractor.general_feature_extractor-v7","parameters":[{"name":"start_date","value":"","type":"Literal","bound_global_parameter":null},{"name":"end_date","value":"","type":"Literal","bound_global_parameter":null},{"name":"before_start_days","value":"60","type":"Literal","bound_global_parameter":null}],"input_ports":[{"name":"instruments","node_id":"-50"},{"name":"features","node_id":"-50"}],"output_ports":[{"name":"data","node_id":"-50"}],"cacheable":true,"seq_num":7,"comment":"","comment_collapsed":true},{"node_id":"-57","module_id":"BigQuantSpace.derived_feature_extractor.derived_feature_extractor-v3","parameters":[{"name":"date_col","value":"date","type":"Literal","bound_global_parameter":null},{"name":"instrument_col","value":"instrument","type":"Literal","bound_global_parameter":null},{"name":"drop_na","value":"False","type":"Literal","bound_global_parameter":null},{"name":"remove_extra_columns","value":"False","type":"Literal","bound_global_parameter":null},{"name":"user_functions","value":"","type":"Literal","bound_global_parameter":null}],"input_ports":[{"name":"input_data","node_id":"-57"},{"name":"features","node_id":"-57"}],"output_ports":[{"name":"data","node_id":"-57"}],"cacheable":true,"seq_num":8,"comment":"","comment_collapsed":true},{"node_id":"-102","module_id":"BigQuantSpace.trade.trade-v4","parameters":[{"name":"start_date","value":"","type":"Literal","bound_global_parameter":null},{"name":"end_date","value":"","type":"Literal","bound_global_parameter":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","type":"Literal","bound_global_parameter":null},{"name":"handle_data","value":"# 回测引擎:每日数据处理函数,每天执行一次\ndef bigquant_run(context, data):\n # 获取今日的日期\n today = data.current_dt.strftime('%Y-%m-%d') \n # 通过positions对象,使用列表生成式的方法获取目前持仓的股票列表\n stock_hold_now = {e.symbol: p.amount * p.last_sale_price\n for e, p in context.perf_tracker.position_tracker.positions.items()}\n\n # 记录用于买入股票的可用现金,因为是早盘卖股票,需要记录卖出的股票市值并在买入下单前更新可用现金;\n # 如果是早盘买尾盘卖,则卖出时不需更新可用现金,因为尾盘卖出股票所得现金无法使用\n cash_for_buy = context.portfolio.cash \n \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 # 需要卖出的股票:已有持仓中符合卖出条件的股票\n stock_to_sell = [ i for i in stock_hold_now if i in sell_stock ]\n # 需要买入的股票:没有持仓且符合买入条件的股票\n stock_to_buy = [ i for i in buy_stock if i not in stock_hold_now ] \n # 需要调仓的股票:已有持仓且不符合卖出条件的股票\n stock_to_adjust=[ i for i in stock_hold_now if i not in sell_stock ]\n \n # 如果有卖出信号\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 # 如果有买入信号/有持仓\n if len(stock_to_buy)+len(stock_to_adjust)>0:\n weight = 1/(len(stock_to_buy)+len(stock_to_adjust)) # 每只股票的比重为等资金比例持有\n for instrument in stock_to_buy+stock_to_adjust:\n sid = context.symbol(instrument) # 将标的转化为equity格式\n if data.can_trade(sid):\n context.order_target_value(sid, weight*cash_for_buy) # 买入","type":"Literal","bound_global_parameter":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)","type":"Literal","bound_global_parameter":null},{"name":"before_trading_start","value":"","type":"Literal","bound_global_parameter":null},{"name":"volume_limit","value":0.025,"type":"Literal","bound_global_parameter":null},{"name":"order_price_field_buy","value":"open","type":"Literal","bound_global_parameter":null},{"name":"order_price_field_sell","value":"open","type":"Literal","bound_global_parameter":null},{"name":"capital_base","value":1000000,"type":"Literal","bound_global_parameter":null},{"name":"auto_cancel_non_tradable_orders","value":"True","type":"Literal","bound_global_parameter":null},{"name":"data_frequency","value":"daily","type":"Literal","bound_global_parameter":null},{"name":"price_type","value":"后复权","type":"Literal","bound_global_parameter":null},{"name":"product_type","value":"股票","type":"Literal","bound_global_parameter":null},{"name":"plot_charts","value":"True","type":"Literal","bound_global_parameter":null},{"name":"backtest_only","value":"False","type":"Literal","bound_global_parameter":null},{"name":"benchmark","value":"","type":"Literal","bound_global_parameter":null}],"input_ports":[{"name":"instruments","node_id":"-102"},{"name":"options_data","node_id":"-102"},{"name":"history_ds","node_id":"-102"},{"name":"benchmark_ds","node_id":"-102"},{"name":"trading_calendar","node_id":"-102"}],"output_ports":[{"name":"raw_perf","node_id":"-102"}],"cacheable":false,"seq_num":3,"comment":"","comment_collapsed":true},{"node_id":"-689","module_id":"BigQuantSpace.dropnan.dropnan-v2","parameters":[],"input_ports":[{"name":"input_data","node_id":"-689"},{"name":"features","node_id":"-689"}],"output_ports":[{"name":"data","node_id":"-689"}],"cacheable":true,"seq_num":4,"comment":"","comment_collapsed":true},{"node_id":"-1541","module_id":"BigQuantSpace.hyper_parameter_search.hyper_parameter_search-v1","parameters":[{"name":"param_grid_builder","value":"def bigquant_run():\n param_grid = {}\n para_list = []\n # 在这里设置需要调优的参数备选\n for p in [[10,20],[5,20],[5,10],[2,8],[10,20],[5,20],[5,10],[2,8],[5,10],[2,8]]:\n paras = \"\"\"buy_condition=where(mean(close_0,%s)>mean(close_0,%s),1,0)\n sell_condition=where(mean(close_0,%s)<mean(close_0,%s),1,0)\"\"\"%(p[0],p[1],p[0],p[1])\n \n para_list.append(paras)\n \n param_grid[\"m1.features\"] = para_list\n \n return param_grid\n","type":"Literal","bound_global_parameter":null},{"name":"scoring","value":"def bigquant_run(result):\n score = result.get('m3').read_raw_perf()['sharpe'].tail(1)[0]\n max_drawdown = result.get('m3').read_raw_perf()['max_drawdown'].tail(1)[0]\n win_percent = result.get('m3').read_raw_perf()['win_percent'].tail(1)[0]\n\n return {'score': score,\"max_drawdown\":max_drawdown,\"win_percent\":win_percent}\n","type":"Literal","bound_global_parameter":null},{"name":"search_algorithm","value":"网格搜索","type":"Literal","bound_global_parameter":null},{"name":"search_iterations","value":10,"type":"Literal","bound_global_parameter":null},{"name":"random_state","value":"","type":"Literal","bound_global_parameter":null},{"name":"workers","value":"1","type":"Literal","bound_global_parameter":null},{"name":"worker_distributed_run","value":"True","type":"Literal","bound_global_parameter":null},{"name":"worker_silent","value":"True","type":"Literal","bound_global_parameter":null},{"name":"run_now","value":"True","type":"Literal","bound_global_parameter":null},{"name":"bq_graph","value":"True","type":"Literal","bound_global_parameter":null}],"input_ports":[{"name":"bq_graph_port","node_id":"-1541"},{"name":"input_1","node_id":"-1541"},{"name":"input_2","node_id":"-1541"},{"name":"input_3","node_id":"-1541"}],"output_ports":[{"name":"result","node_id":"-1541"}],"cacheable":false,"seq_num":5,"comment":"","comment_collapsed":true}],"node_layout":"<node_postions><node_position Node='287d2cb0-f53c-4101-bdf8-104b137c8601-24' Position='1232,40,200,200'/><node_position Node='287d2cb0-f53c-4101-bdf8-104b137c8601-62' Position='879,25,200,200'/><node_position Node='-50' Position='1078,234,200,200'/><node_position Node='-57' Position='1076,327,200,200'/><node_position Node='-102' Position='1047,531,200,200'/><node_position Node='-689' Position='1078,418,200,200'/><node_position Node='-1541' Position='624,291,200,200'/></node_postions>"},"nodes_readonly":false,"studio_version":"v2"}
[2021-08-18 11:36:38.006240] INFO: cached.v3.7e743682: 任务状态: Pending
[2021-08-18 11:36:48.057085] INFO: cached.v3.7e743682: 任务状态: Running
[2021-08-18 11:36:58.099583] INFO: cached.v3.7e743682: [2021-08-18 11:36:48.650653] INFO moduleinvoker: input_features.v1 开始运行..
[2021-08-18 11:36:58.101067] INFO: cached.v3.7e743682: [2021-08-18 11:36:48.673170] INFO moduleinvoker: input_features.v1 运行完成[0.022565s].
[2021-08-18 11:36:58.102180] INFO: cached.v3.7e743682: [2021-08-18 11:36:48.675345] INFO moduleinvoker: instruments.v2 开始运行..
[2021-08-18 11:36:58.103185] INFO: cached.v3.7e743682: [2021-08-18 11:36:48.706664] INFO moduleinvoker: instruments.v2 运行完成[0.031221s].
[2021-08-18 11:36:58.104174] INFO: cached.v3.7e743682: [2021-08-18 11:36:48.743658] INFO moduleinvoker: general_feature_extractor.v7 开始运行..
[2021-08-18 11:36:58.105151] INFO: cached.v3.7e743682: [2021-08-18 11:36:49.247385] INFO 基础特征抽取: 年份 2021, 特征行数=124
[2021-08-18 11:36:58.106154] INFO: cached.v3.7e743682: [2021-08-18 11:36:49.269512] INFO 基础特征抽取: 总行数: 124
[2021-08-18 11:36:58.107259] INFO: cached.v3.7e743682: [2021-08-18 11:36:49.274755] INFO moduleinvoker: general_feature_extractor.v7 运行完成[0.530767s].
[2021-08-18 11:36:58.108253] INFO: cached.v3.7e743682: [2021-08-18 11:36:49.279962] INFO moduleinvoker: derived_feature_extractor.v3 开始运行..
[2021-08-18 11:36:58.109227] INFO: cached.v3.7e743682: [2021-08-18 11:36:49.357649] INFO derived_feature_extractor: 提取完成 buy_condition=where(mean(close_0,10)>mean(close_0,20),1,0), 0.011s
[2021-08-18 11:36:58.110220] INFO: cached.v3.7e743682: [2021-08-18 11:36:49.369165] INFO derived_feature_extractor: 提取完成 sell_condition=where(mean(close_0,10)[2021-08-18 11:36:58.111194] INFO: cached.v3.7e743682: [2021-08-18 11:36:49.436732] INFO derived_feature_extractor: /y_2021, 124
[2021-08-18 11:36:58.112185] INFO: cached.v3.7e743682: [2021-08-18 11:36:49.480026] INFO moduleinvoker: derived_feature_extractor.v3 运行完成[0.200037s].
[2021-08-18 11:36:58.113162] INFO: cached.v3.7e743682: [2021-08-18 11:36:49.485616] INFO moduleinvoker: dropnan.v2 开始运行..
[2021-08-18 11:36:58.114162] INFO: cached.v3.7e743682: [2021-08-18 11:36:49.574950] INFO dropnan: /y_2021, 124/124
[2021-08-18 11:36:58.115132] INFO: cached.v3.7e743682: [2021-08-18 11:36:49.598792] INFO dropnan: 行数: 124/124
[2021-08-18 11:36:58.116242] INFO: cached.v3.7e743682: [2021-08-18 11:36:49.602367] INFO moduleinvoker: dropnan.v2 运行完成[0.116658s].
[2021-08-18 11:36:58.117234] INFO: cached.v3.7e743682: [2021-08-18 11:36:51.349212] INFO moduleinvoker: backtest.v8 开始运行..
[2021-08-18 11:36:58.118220] INFO: cached.v3.7e743682: [2021-08-18 11:36:51.352712] INFO backtest: biglearning backtest:V8.5.0
[2021-08-18 11:36:58.119176] INFO: cached.v3.7e743682: [2021-08-18 11:36:51.497076] INFO backtest: product_type:stock by specified
[2021-08-18 11:36:58.120137] INFO: cached.v3.7e743682: [2021-08-18 11:36:51.963883] INFO moduleinvoker: cached.v2 开始运行..
[2021-08-18 11:36:58.121097] INFO: cached.v3.7e743682: [2021-08-18 11:36:57.741309] INFO backtest: 读取股票行情完成:81745
[2021-08-18 11:36:58.122116] INFO: cached.v3.7e743682: [2021-08-18 11:36:57.986789] INFO moduleinvoker: cached.v2 运行完成[6.022898s].
[2021-08-18 11:37:08.161146] INFO: cached.v3.7e743682: [2021-08-18 11:36:58.141397] INFO algo: TradingAlgorithm V1.8.4
[2021-08-18 11:37:08.163178] INFO: cached.v3.7e743682: [2021-08-18 11:36:58.366731] INFO algo: trading transform...
[2021-08-18 11:37:08.164559] INFO: cached.v3.7e743682: [2021-08-18 11:36:58.457320] INFO Performance: Simulated 19 trading days out of 19.
[2021-08-18 11:37:08.165734] INFO: cached.v3.7e743682: [2021-08-18 11:36:58.457425] INFO Performance: first open: 2021-05-06 09:30:00+00:00
[2021-08-18 11:37:08.167124] INFO: cached.v3.7e743682: [2021-08-18 11:36:58.457480] INFO Performance: last close: 2021-06-01 15:00:00+00:00
[2021-08-18 11:37:08.168533] INFO: cached.v3.7e743682:
[2021-08-18 11:37:08.170681] INFO: cached.v3.7e743682: [2021-08-18 11:36:58.890750] INFO moduleinvoker: backtest.v8 运行完成[7.541535s].
[2021-08-18 11:37:08.172022] INFO: cached.v3.7e743682: [2021-08-18 11:36:58.890887] INFO moduleinvoker: trade.v4 运行完成[9.281982s].
[2021-08-18 11:37:08.173536] INFO: cached.v3.7e743682: 任务状态: Succeeded
[2021-08-18 11:37:08.450226] INFO: cached.v3.9098f51e: 任务状态: Pending
[2021-08-18 11:37:18.491460] INFO: cached.v3.9098f51e: [2021-08-18 11:37:16.028236] INFO moduleinvoker: input_features.v1 开始运行..
[2021-08-18 11:37:18.493631] INFO: cached.v3.9098f51e: [2021-08-18 11:37:16.045637] INFO moduleinvoker: input_features.v1 运行完成[0.017436s].
[2021-08-18 11:37:18.495683] INFO: cached.v3.9098f51e: [2021-08-18 11:37:16.047475] INFO moduleinvoker: instruments.v2 开始运行..
[2021-08-18 11:37:18.497413] INFO: cached.v3.9098f51e: [2021-08-18 11:37:16.052078] INFO moduleinvoker: 命中缓存
[2021-08-18 11:37:18.498933] INFO: cached.v3.9098f51e: [2021-08-18 11:37:16.052374] INFO moduleinvoker: instruments.v2 运行完成[0.004931s].
[2021-08-18 11:37:18.500168] INFO: cached.v3.9098f51e: [2021-08-18 11:37:16.079558] INFO moduleinvoker: general_feature_extractor.v7 开始运行..
[2021-08-18 11:37:18.501647] INFO: cached.v3.9098f51e: [2021-08-18 11:37:16.084236] INFO moduleinvoker: 命中缓存
[2021-08-18 11:37:18.502820] INFO: cached.v3.9098f51e: [2021-08-18 11:37:16.084479] INFO moduleinvoker: general_feature_extractor.v7 运行完成[0.004965s].
[2021-08-18 11:37:18.504283] INFO: cached.v3.9098f51e: [2021-08-18 11:37:16.086264] INFO moduleinvoker: derived_feature_extractor.v3 开始运行..
[2021-08-18 11:37:18.505455] INFO: cached.v3.9098f51e: [2021-08-18 11:37:16.129414] INFO derived_feature_extractor: 提取完成 buy_condition=where(mean(close_0,5)>mean(close_0,20),1,0), 0.006s
[2021-08-18 11:37:18.506645] INFO: cached.v3.9098f51e: [2021-08-18 11:37:16.134245] INFO derived_feature_extractor: 提取完成 sell_condition=where(mean(close_0,5)[2021-08-18 11:37:18.507757] INFO: cached.v3.9098f51e: [2021-08-18 11:37:16.171104] INFO derived_feature_extractor: /y_2021, 124
[2021-08-18 11:37:18.508958] INFO: cached.v3.9098f51e: [2021-08-18 11:37:16.213389] INFO moduleinvoker: derived_feature_extractor.v3 运行完成[0.12702s].
[2021-08-18 11:37:18.510121] INFO: cached.v3.9098f51e: [2021-08-18 11:37:16.216942] INFO moduleinvoker: dropnan.v2 开始运行..
[2021-08-18 11:37:18.511154] INFO: cached.v3.9098f51e: [2021-08-18 11:37:16.283768] INFO dropnan: /y_2021, 124/124
[2021-08-18 11:37:18.512177] INFO: cached.v3.9098f51e: [2021-08-18 11:37:16.302365] INFO dropnan: 行数: 124/124
[2021-08-18 11:37:18.513504] INFO: cached.v3.9098f51e: [2021-08-18 11:37:16.304966] INFO moduleinvoker: dropnan.v2 运行完成[0.088049s].
[2021-08-18 11:37:18.514649] INFO: cached.v3.9098f51e: [2021-08-18 11:37:17.826483] INFO moduleinvoker: backtest.v8 开始运行..
[2021-08-18 11:37:18.515754] INFO: cached.v3.9098f51e: [2021-08-18 11:37:17.835032] INFO backtest: biglearning backtest:V8.5.0
[2021-08-18 11:37:18.516849] INFO: cached.v3.9098f51e: [2021-08-18 11:37:17.996719] INFO backtest: product_type:stock by specified
[2021-08-18 11:37:18.517966] INFO: cached.v3.9098f51e: [2021-08-18 11:37:18.364761] INFO moduleinvoker: cached.v2 开始运行..
[2021-08-18 11:37:18.519089] INFO: cached.v3.9098f51e: [2021-08-18 11:37:18.370674] INFO moduleinvoker: 命中缓存
[2021-08-18 11:37:18.520220] INFO: cached.v3.9098f51e: [2021-08-18 11:37:18.371062] INFO moduleinvoker: cached.v2 运行完成[0.006365s].
[2021-08-18 11:37:18.521369] INFO: cached.v3.9098f51e: 任务状态: Running
Fitting 1 folds for each of 10 candidates, totalling 10 fits
[Parallel(n_jobs=1)]: Using backend SequentialBackend with 1 concurrent workers.
[CV 1/1; 1/10] START m1.features=buy_condition=where(mean(close_0,10)>mean(close_0,20),1,0)
sell_condition=where(mean(close_0,10)<mean(close_0,20),1,0)
[CV 1/1; 1/10] END m1.features=buy_condition=where(mean(close_0,10)>mean(close_0,20),1,0)
sell_condition=where(mean(close_0,10)<mean(close_0,20),1,0); max_drawdown: (test=-0.076) score: (test=-7.195) win_percent: (test=0.143) total time= 30.4s
[Parallel(n_jobs=1)]: Done 1 out of 1 | elapsed: 30.4s remaining: 0.0s
[CV 1/1; 2/10] START m1.features=buy_condition=where(mean(close_0,5)>mean(close_0,20),1,0)
sell_condition=where(mean(close_0,5)<mean(close_0,20),1,0)