{"description":"实验创建于2017/8/26","graph":{"edges":[{"to_node_id":"-4862:features","from_node_id":"-4857:data"},{"to_node_id":"-6998:features","from_node_id":"-4857:data"},{"to_node_id":"-4862:instruments","from_node_id":"-4849:data"},{"to_node_id":"-281:instruments","from_node_id":"-4849:data"},{"to_node_id":"-768:instruments","from_node_id":"-4849:data"},{"to_node_id":"-40:instruments","from_node_id":"-4849:data"},{"to_node_id":"-6998:input_data","from_node_id":"-4862:data"},{"to_node_id":"-125:input_data","from_node_id":"-2687:data"},{"to_node_id":"-2687:input_data","from_node_id":"-6998:data"},{"to_node_id":"-118:data2","from_node_id":"-281:data"},{"to_node_id":"-768:options_data","from_node_id":"-110:sorted_data"},{"to_node_id":"-40:options_data","from_node_id":"-110:sorted_data"},{"to_node_id":"-110:input_ds","from_node_id":"-118:data"},{"to_node_id":"-118:data1","from_node_id":"-125:data"}],"nodes":[{"node_id":"-768","module_id":"BigQuantSpace.hftrade.hftrade-v2","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 context.test_data = 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 context.stock_count = 3\n # 每只的股票的权重,如下的权重分配会使得靠前的股票分配多一点的资金,[0.339160, 0.213986, 0.169580, ..]\n context.stock_weights = 1/context.stock_count\n #持仓周期\n context.hold_days = 7\n","type":"Literal","bound_global_parameter":null},{"name":"before_trading_start","value":"# 交易引擎:每个单位时间开盘前调用一次。\ndef bigquant_run(context, data):\n # 盘前处理,订阅行情等\n pass\n","type":"Literal","bound_global_parameter":null},{"name":"handle_tick","value":"# 交易引擎:tick数据处理函数,每个tick执行一次\ndef bigquant_run(context, tick):\n pass\n","type":"Literal","bound_global_parameter":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 # 赚30%就止赢\n if (stock_market_price - stock_cost ) / stock_cost>= 0.25: \n context.order_target_percent(context.symbol(i),0) \n current_stopwin_stock.append(i)\n print('日期:',date,'股票:',i,'出现止盈状况')\n #-------------------------------------------止赢模块END---------------------------------------------\n if context.trading_day_index % context.hold_days != 0:\n return \n \n today = data.current_dt.strftime('%Y-%m-%d')\n \n # 获取当前持仓\n positions = {e.symbol: p.amount for e, p in context.portfolio.positions.items()}\n \n # 按日期过滤得到今日数据\n today_data = context.test_data[context.test_data.date == today]\n #今日需要买入的股票\n stocks_buy = today_data.instrument.iloc[0:context.stock_count].to_list()\n stocks_buy_name = today_data.name.iloc[0:context.stock_count].to_list() #打印显示用\n #print(today,\"买入股票池:\",stocks_buy,'',stocks_buy_name)\n #卖出\n for instrument in positions.keys():\n if instrument not in stocks_buy:\n context.order_target(context.symbol(instrument), 0)\n #print(today,\"卖出\",instrument)\n #买入\n cash_per_instrument = context.portfolio.portfolio_value * context.stock_weights\n print(cash_per_instrument)\n for instrument in stocks_buy:\n if instrument not in positions.keys():\n context.order_value(context.symbol(instrument), cash_per_instrument)\n #print(today,\"买入\",instrument) \n ","type":"Literal","bound_global_parameter":null},{"name":"handle_trade","value":"# 交易引擎:成交回报处理函数,每个成交发生时执行一次\ndef bigquant_run(context, trade):\n pass\n","type":"Literal","bound_global_parameter":null},{"name":"handle_order","value":"# 交易引擎:委托回报处理函数,每个委托变化时执行一次\ndef bigquant_run(context, order):\n pass\n","type":"Literal","bound_global_parameter":null},{"name":"after_trading","value":"# 交易引擎:盘后处理函数,每日盘后执行一次\ndef bigquant_run(context, data):\n pass\n","type":"Literal","bound_global_parameter":null},{"name":"capital_base","value":1000000,"type":"Literal","bound_global_parameter":null},{"name":"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":"before_start_days","value":"0","type":"Literal","bound_global_parameter":null},{"name":"volume_limit","value":1,"type":"Literal","bound_global_parameter":null},{"name":"order_price_field_buy","value":"twap_1","type":"Literal","bound_global_parameter":null},{"name":"order_price_field_sell","value":"twap_8","type":"Literal","bound_global_parameter":null},{"name":"benchmark","value":"000300.HIX","type":"Literal","bound_global_parameter":null},{"name":"plot_charts","value":"True","type":"Literal","bound_global_parameter":null},{"name":"disable_cache","value":"False","type":"Literal","bound_global_parameter":null},{"name":"replay_bdb","value":"False","type":"Literal","bound_global_parameter":null},{"name":"show_debug_info","value":"False","type":"Literal","bound_global_parameter":null},{"name":"backtest_only","value":"False","type":"Literal","bound_global_parameter":null}],"input_ports":[{"name":"instruments","node_id":"-768"},{"name":"options_data","node_id":"-768"},{"name":"history_ds","node_id":"-768"},{"name":"benchmark_ds","node_id":"-768"}],"output_ports":[{"name":"raw_perf","node_id":"-768"}],"cacheable":false,"seq_num":1,"comment":"","comment_collapsed":true},{"node_id":"-40","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 context.test_data = 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 context.stock_count = 3\n # 每只的股票的权重,如下的权重分配会使得靠前的股票分配多一点的资金,[0.339160, 0.213986, 0.169580, ..]\n context.stock_weights = 1/context.stock_count\n #持仓周期\n context.hold_days = 7\n","type":"Literal","bound_global_parameter":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 # 赚30%就止赢\n if (stock_market_price - stock_cost ) / stock_cost>= 0.25: \n context.order_target_percent(context.symbol(i),0) \n current_stopwin_stock.append(i)\n print('日期:',date,'股票:',i,'出现止盈状况')\n #-------------------------------------------止赢模块END---------------------------------------------\n if context.trading_day_index % context.hold_days != 0:\n return \n \n today = data.current_dt.strftime('%Y-%m-%d')\n \n # 获取当前持仓\n positions = {e.symbol: p.amount for e, p in context.portfolio.positions.items()}\n \n # 按日期过滤得到今日数据\n today_data = context.test_data[context.test_data.date == today]\n #今日需要买入的股票\n stocks_buy = today_data.instrument.iloc[0:context.stock_count].to_list()\n stocks_buy_name = today_data.name.iloc[0:context.stock_count].to_list() #打印显示用\n #print(today,\"买入股票池:\",stocks_buy,'',stocks_buy_name)\n #卖出\n for instrument in positions.keys():\n if instrument not in stocks_buy:\n context.order_target(context.symbol(instrument), 0)\n #print(today,\"卖出\",instrument)\n #买入\n cash_per_instrument = context.portfolio.portfolio_value * context.stock_weights\n print(cash_per_instrument)\n for instrument in stocks_buy:\n if instrument not in positions.keys():\n context.order_value(context.symbol(instrument), cash_per_instrument)\n #print(today,\"买入\",instrument) \n ","type":"Literal","bound_global_parameter":null},{"name":"prepare","value":"# 回测引擎:准备数据,只执行一次\ndef bigquant_run(context):\n pass\n","type":"Literal","bound_global_parameter":null},{"name":"before_trading_start","value":"# 回测引擎:每个单位时间开始前调用一次,即每日开盘前调用一次。\ndef bigquant_run(context, data):\n pass\n","type":"Literal","bound_global_parameter":null},{"name":"volume_limit","value":"0","type":"Literal","bound_global_parameter":null},{"name":"order_price_field_buy","value":"twap_1","type":"Literal","bound_global_parameter":null},{"name":"order_price_field_sell","value":"twap_8","type":"Literal","bound_global_parameter":null},{"name":"capital_base","value":"346937","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":"-40"},{"name":"options_data","node_id":"-40"},{"name":"history_ds","node_id":"-40"},{"name":"benchmark_ds","node_id":"-40"},{"name":"trading_calendar","node_id":"-40"}],"output_ports":[{"name":"raw_perf","node_id":"-40"}],"cacheable":false,"seq_num":2,"comment":"","comment_collapsed":true},{"node_id":"-4857","module_id":"BigQuantSpace.input_features.input_features-v1","parameters":[{"name":"features","value":"# #号开始的表示注释,注释需单独一行\n\nhs=sum(turn_0,5)\nhs1=shift(hs,5)\nmy=where(hs>hs1,1,0)\nbuy_condition=where(my>0,1,0)\nsell_condition=where(close_0>mean(close_0,60),1,0)\n\n\n\n\n","type":"Literal","bound_global_parameter":null}],"input_ports":[{"name":"features_ds","node_id":"-4857"}],"output_ports":[{"name":"data","node_id":"-4857"}],"cacheable":true,"seq_num":3,"comment":"","comment_collapsed":true},{"node_id":"-4849","module_id":"BigQuantSpace.instruments.instruments-v2","parameters":[{"name":"start_date","value":"2022-01-01","type":"Literal","bound_global_parameter":null},{"name":"end_date","value":"2022-09-06","type":"Literal","bound_global_parameter":null},{"name":"market","value":"CN_STOCK_A","type":"Literal","bound_global_parameter":null},{"name":"instrument_list","value":"","type":"Literal","bound_global_parameter":null},{"name":"max_count","value":0,"type":"Literal","bound_global_parameter":null}],"input_ports":[{"name":"rolling_conf","node_id":"-4849"}],"output_ports":[{"name":"data","node_id":"-4849"}],"cacheable":true,"seq_num":4,"comment":"","comment_collapsed":true},{"node_id":"-4862","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":"120","type":"Literal","bound_global_parameter":null}],"input_ports":[{"name":"instruments","node_id":"-4862"},{"name":"features","node_id":"-4862"}],"output_ports":[{"name":"data","node_id":"-4862"}],"cacheable":true,"seq_num":5,"comment":"","comment_collapsed":true},{"node_id":"-2687","module_id":"BigQuantSpace.chinaa_stock_filter.chinaa_stock_filter-v1","parameters":[{"name":"index_constituent_cond","value":"%7B%22enumItems%22%3A%5B%7B%22value%22%3A%22%E5%85%A8%E9%83%A8%22%2C%22displayValue%22%3A%22%E5%85%A8%E9%83%A8%22%2C%22selected%22%3Atrue%7D%2C%7B%22value%22%3A%22%E4%B8%8A%E8%AF%8150%22%2C%22displayValue%22%3A%22%E4%B8%8A%E8%AF%8150%22%2C%22selected%22%3Afalse%7D%2C%7B%22value%22%3A%22%E6%B2%AA%E6%B7%B1300%22%2C%22displayValue%22%3A%22%E6%B2%AA%E6%B7%B1300%22%2C%22selected%22%3Afalse%7D%2C%7B%22value%22%3A%22%E4%B8%AD%E8%AF%81500%22%2C%22displayValue%22%3A%22%E4%B8%AD%E8%AF%81500%22%2C%22selected%22%3Afalse%7D%2C%7B%22value%22%3A%22%E4%B8%AD%E8%AF%81800%22%2C%22displayValue%22%3A%22%E4%B8%AD%E8%AF%81800%22%2C%22selected%22%3Afalse%7D%2C%7B%22value%22%3A%22%E4%B8%8A%E8%AF%81180%22%2C%22displayValue%22%3A%22%E4%B8%8A%E8%AF%81180%22%2C%22selected%22%3Afalse%7D%2C%7B%22value%22%3A%22%E4%B8%AD%E8%AF%81100%22%2C%22displayValue%22%3A%22%E4%B8%AD%E8%AF%81100%22%2C%22selected%22%3Afalse%7D%2C%7B%22value%22%3A%22%E6%B7%B1%E8%AF%81100%22%2C%22displayValue%22%3A%22%E6%B7%B1%E8%AF%81100%22%2C%22selected%22%3Afalse%7D%5D%7D","type":"Literal","bound_global_parameter":null},{"name":"board_cond","value":"%7B%22enumItems%22%3A%5B%7B%22value%22%3A%22%E5%85%A8%E9%83%A8%22%2C%22displayValue%22%3A%22%E5%85%A8%E9%83%A8%22%2C%22selected%22%3Afalse%7D%2C%7B%22value%22%3A%22%E4%B8%8A%E8%AF%81%E4%B8%BB%E6%9D%BF%22%2C%22displayValue%22%3A%22%E4%B8%8A%E8%AF%81%E4%B8%BB%E6%9D%BF%22%2C%22selected%22%3Atrue%7D%2C%7B%22value%22%3A%22%E6%B7%B1%E8%AF%81%E4%B8%BB%E6%9D%BF%22%2C%22displayValue%22%3A%22%E6%B7%B1%E8%AF%81%E4%B8%BB%E6%9D%BF%22%2C%22selected%22%3Atrue%7D%2C%7B%22value%22%3A%22%E5%88%9B%E4%B8%9A%E6%9D%BF%22%2C%22displayValue%22%3A%22%E5%88%9B%E4%B8%9A%E6%9D%BF%22%2C%22selected%22%3Atrue%7D%2C%7B%22value%22%3A%22%E7%A7%91%E5%88%9B%E6%9D%BF%22%2C%22displayValue%22%3A%22%E7%A7%91%E5%88%9B%E6%9D%BF%22%2C%22selected%22%3Afalse%7D%5D%7D","type":"Literal","bound_global_parameter":null},{"name":"industry_cond","value":"%7B%22enumItems%22%3A%5B%7B%22value%22%3A%22%E5%85%A8%E9%83%A8%22%2C%22displayValue%22%3A%22%E5%85%A8%E9%83%A8%22%2C%22selected%22%3Atrue%7D%2C%7B%22value%22%3A%22%E4%BA%A4%E9%80%9A%E8%BF%90%E8%BE%93%22%2C%22displayValue%22%3A%22%E4%BA%A4%E9%80%9A%E8%BF%90%E8%BE%93%22%2C%22selected%22%3Afalse%7D%2C%7B%22value%22%3A%22%E4%BC%91%E9%97%B2%E6%9C%8D%E5%8A%A1%22%2C%22displayValue%22%3A%22%E4%BC%91%E9%97%B2%E6%9C%8D%E5%8A%A1%22%2C%22selected%22%3Afalse%7D%2C%7B%22value%22%3A%22%E4%BC%A0%E5%AA%92%2F%E4%BF%A1%E6%81%AF%E6%9C%8D%E5%8A%A1%22%2C%22displayValue%22%3A%22%E4%BC%A0%E5%AA%92%2F%E4%BF%A1%E6%81%AF%E6%9C%8D%E5%8A%A1%22%2C%22selected%22%3Afalse%7D%2C%7B%22value%22%3A%22%E5%85%AC%E7%94%A8%E4%BA%8B%E4%B8%9A%22%2C%22displayValue%22%3A%22%E5%85%AC%E7%94%A8%E4%BA%8B%E4%B8%9A%22%2C%22selected%22%3Afalse%7D%2C%7B%22value%22%3A%22%E5%86%9C%E6%9E%97%E7%89%A7%E6%B8%94%22%2C%22displayValue%22%3A%22%E5%86%9C%E6%9E%97%E7%89%A7%E6%B8%94%22%2C%22selected%22%3Afalse%7D%2C%7B%22value%22%3A%22%E5%8C%96%E5%B7%A5%22%2C%22displayValue%22%3A%22%E5%8C%96%E5%B7%A5%22%2C%22selected%22%3Afalse%7D%2C%7B%22value%22%3A%22%E5%8C%BB%E8%8D%AF%E7%94%9F%E7%89%A9%22%2C%22displayValue%22%3A%22%E5%8C%BB%E8%8D%AF%E7%94%9F%E7%89%A9%22%2C%22selected%22%3Afalse%7D%2C%7B%22value%22%3A%22%E5%95%86%E4%B8%9A%E8%B4%B8%E6%98%93%22%2C%22displayValue%22%3A%22%E5%95%86%E4%B8%9A%E8%B4%B8%E6%98%93%22%2C%22selected%22%3Afalse%7D%2C%7B%22value%22%3A%22%E5%9B%BD%E9%98%B2%E5%86%9B%E5%B7%A5%22%2C%22displayValue%22%3A%22%E5%9B%BD%E9%98%B2%E5%86%9B%E5%B7%A5%22%2C%22selected%22%3Afalse%7D%2C%7B%22value%22%3A%22%E5%AE%B6%E7%94%A8%E7%94%B5%E5%99%A8%22%2C%22displayValue%22%3A%22%E5%AE%B6%E7%94%A8%E7%94%B5%E5%99%A8%22%2C%22selected%22%3Afalse%7D%2C%7B%22value%22%3A%22%E5%BB%BA%E7%AD%91%E6%9D%90%E6%96%99%2F%E5%BB%BA%E7%AD%91%E5%BB%BA%E6%9D%90%22%2C%22displayValue%22%3A%22%E5%BB%BA%E7%AD%91%E6%9D%90%E6%96%99%2F%E5%BB%BA%E7%AD%91%E5%BB%BA%E6%9D%90%22%2C%22selected%22%3Afalse%7D%2C%7B%22value%22%3A%22%E5%BB%BA%E7%AD%91%E8%A3%85%E9%A5%B0%22%2C%22displayValue%22%3A%22%E5%BB%BA%E7%AD%91%E8%A3%85%E9%A5%B0%22%2C%22selected%22%3Afalse%7D%2C%7B%22value%22%3A%22%E6%88%BF%E5%9C%B0%E4%BA%A7%22%2C%22displayValue%22%3A%22%E6%88%BF%E5%9C%B0%E4%BA%A7%22%2C%22selected%22%3Afalse%7D%2C%7B%22value%22%3A%22%E6%9C%89%E8%89%B2%E9%87%91%E5%B1%9E%22%2C%22displayValue%22%3A%22%E6%9C%89%E8%89%B2%E9%87%91%E5%B1%9E%22%2C%22selected%22%3Afalse%7D%2C%7B%22value%22%3A%22%E6%9C%BA%E6%A2%B0%E8%AE%BE%E5%A4%87%22%2C%22displayValue%22%3A%22%E6%9C%BA%E6%A2%B0%E8%AE%BE%E5%A4%87%22%2C%22selected%22%3Afalse%7D%2C%7B%22value%22%3A%22%E6%B1%BD%E8%BD%A6%2F%E4%BA%A4%E8%BF%90%E8%AE%BE%E5%A4%87%22%2C%22displayValue%22%3A%22%E6%B1%BD%E8%BD%A6%2F%E4%BA%A4%E8%BF%90%E8%AE%BE%E5%A4%87%22%2C%22selected%22%3Afalse%7D%2C%7B%22value%22%3A%22%E7%94%B5%E5%AD%90%22%2C%22displayValue%22%3A%22%E7%94%B5%E5%AD%90%22%2C%22selected%22%3Afalse%7D%2C%7B%22value%22%3A%22%E7%94%B5%E6%B0%94%E8%AE%BE%E5%A4%87%22%2C%22displayValue%22%3A%22%E7%94%B5%E6%B0%94%E8%AE%BE%E5%A4%87%22%2C%22selected%22%3Afalse%7D%2C%7B%22value%22%3A%22%E7%BA%BA%E7%BB%87%E6%9C%8D%E8%A3%85%22%2C%22displayValue%22%3A%22%E7%BA%BA%E7%BB%87%E6%9C%8D%E8%A3%85%22%2C%22selected%22%3Afalse%7D%2C%7B%22value%22%3A%22%E7%BB%BC%E5%90%88%22%2C%22displayValue%22%3A%22%E7%BB%BC%E5%90%88%22%2C%22selected%22%3Afalse%7D%2C%7B%22value%22%3A%22%E8%AE%A1%E7%AE%97%E6%9C%BA%22%2C%22displayValue%22%3A%22%E8%AE%A1%E7%AE%97%E6%9C%BA%22%2C%22selected%22%3Afalse%7D%2C%7B%22value%22%3A%22%E8%BD%BB%E5%B7%A5%E5%88%B6%E9%80%A0%22%2C%22displayValue%22%3A%22%E8%BD%BB%E5%B7%A5%E5%88%B6%E9%80%A0%22%2C%22selected%22%3Afalse%7D%2C%7B%22value%22%3A%22%E9%80%9A%E4%BF%A1%22%2C%22displayValue%22%3A%22%E9%80%9A%E4%BF%A1%22%2C%22selected%22%3Afalse%7D%2C%7B%22value%22%3A%22%E9%87%87%E6%8E%98%22%2C%22displayValue%22%3A%22%E9%87%87%E6%8E%98%22%2C%22selected%22%3Afalse%7D%2C%7B%22value%22%3A%22%E9%92%A2%E9%93%81%22%2C%22displayValue%22%3A%22%E9%92%A2%E9%93%81%22%2C%22selected%22%3Afalse%7D%2C%7B%22value%22%3A%22%E9%93%B6%E8%A1%8C%22%2C%22displayValue%22%3A%22%E9%93%B6%E8%A1%8C%22%2C%22selected%22%3Afalse%7D%2C%7B%22value%22%3A%22%E9%9D%9E%E9%93%B6%E9%87%91%E8%9E%8D%22%2C%22displayValue%22%3A%22%E9%9D%9E%E9%93%B6%E9%87%91%E8%9E%8D%22%2C%22selected%22%3Afalse%7D%2C%7B%22value%22%3A%22%E9%A3%9F%E5%93%81%E9%A5%AE%E6%96%99%22%2C%22displayValue%22%3A%22%E9%A3%9F%E5%93%81%E9%A5%AE%E6%96%99%22%2C%22selected%22%3Afalse%7D%5D%7D","type":"Literal","bound_global_parameter":null},{"name":"st_cond","value":"%7B%22enumItems%22%3A%5B%7B%22value%22%3A%22%E5%85%A8%E9%83%A8%22%2C%22displayValue%22%3A%22%E5%85%A8%E9%83%A8%22%2C%22selected%22%3Afalse%7D%2C%7B%22value%22%3A%22%E6%AD%A3%E5%B8%B8%22%2C%22displayValue%22%3A%22%E6%AD%A3%E5%B8%B8%22%2C%22selected%22%3Atrue%7D%2C%7B%22value%22%3A%22ST%22%2C%22displayValue%22%3A%22ST%22%2C%22selected%22%3Afalse%7D%2C%7B%22value%22%3A%22*ST%22%2C%22displayValue%22%3A%22*ST%22%2C%22selected%22%3Afalse%7D%2C%7B%22value%22%3A%22%E6%9A%82%E5%81%9C%E4%B8%8A%E5%B8%82%22%2C%22displayValue%22%3A%22%E6%9A%82%E5%81%9C%E4%B8%8A%E5%B8%82%22%2C%22selected%22%3Afalse%7D%5D%7D","type":"Literal","bound_global_parameter":null},{"name":"delist_cond","value":"%7B%22enumItems%22%3A%5B%7B%22value%22%3A%22%E5%85%A8%E9%83%A8%22%2C%22displayValue%22%3A%22%E5%85%A8%E9%83%A8%22%2C%22selected%22%3Afalse%7D%2C%7B%22value%22%3A%22%E9%80%80%E5%B8%82%22%2C%22displayValue%22%3A%22%E9%80%80%E5%B8%82%22%2C%22selected%22%3Afalse%7D%2C%7B%22value%22%3A%22%E9%9D%9E%E9%80%80%E5%B8%82%22%2C%22displayValue%22%3A%22%E9%9D%9E%E9%80%80%E5%B8%82%22%2C%22selected%22%3Atrue%7D%5D%7D","type":"Literal","bound_global_parameter":null},{"name":"output_left_data","value":"False","type":"Literal","bound_global_parameter":null}],"input_ports":[{"name":"input_data","node_id":"-2687"}],"output_ports":[{"name":"data","node_id":"-2687"},{"name":"left_data","node_id":"-2687"}],"cacheable":true,"seq_num":6,"comment":"","comment_collapsed":true},{"node_id":"-6998","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":"-6998"},{"name":"features","node_id":"-6998"}],"output_ports":[{"name":"data","node_id":"-6998"}],"cacheable":true,"seq_num":7,"comment":"","comment_collapsed":true},{"node_id":"-281","module_id":"BigQuantSpace.use_datasource.use_datasource-v1","parameters":[{"name":"datasource_id","value":"instruments_CN_STOCK_A","type":"Literal","bound_global_parameter":null},{"name":"start_date","value":"","type":"Literal","bound_global_parameter":null},{"name":"end_date","value":"","type":"Literal","bound_global_parameter":null}],"input_ports":[{"name":"instruments","node_id":"-281"},{"name":"features","node_id":"-281"}],"output_ports":[{"name":"data","node_id":"-281"}],"cacheable":true,"seq_num":8,"comment":"","comment_collapsed":true},{"node_id":"-110","module_id":"BigQuantSpace.sort.sort-v5","parameters":[{"name":"sort_by","value":"hs","type":"Literal","bound_global_parameter":null},{"name":"group_by","value":"date","type":"Literal","bound_global_parameter":null},{"name":"keep_columns","value":"--","type":"Literal","bound_global_parameter":null},{"name":"ascending","value":"False","type":"Literal","bound_global_parameter":null}],"input_ports":[{"name":"input_ds","node_id":"-110"},{"name":"sort_by_ds","node_id":"-110"}],"output_ports":[{"name":"sorted_data","node_id":"-110"}],"cacheable":true,"seq_num":9,"comment":"","comment_collapsed":true},{"node_id":"-118","module_id":"BigQuantSpace.join.join-v3","parameters":[{"name":"on","value":"date,instrument","type":"Literal","bound_global_parameter":null},{"name":"how","value":"left","type":"Literal","bound_global_parameter":null},{"name":"sort","value":"False","type":"Literal","bound_global_parameter":null}],"input_ports":[{"name":"data1","node_id":"-118"},{"name":"data2","node_id":"-118"}],"output_ports":[{"name":"data","node_id":"-118"}],"cacheable":true,"seq_num":10,"comment":"","comment_collapsed":true},{"node_id":"-125","module_id":"BigQuantSpace.filter.filter-v3","parameters":[{"name":"expr","value":"my>0","type":"Literal","bound_global_parameter":null},{"name":"output_left_data","value":"False","type":"Literal","bound_global_parameter":null}],"input_ports":[{"name":"input_data","node_id":"-125"}],"output_ports":[{"name":"data","node_id":"-125"},{"name":"left_data","node_id":"-125"}],"cacheable":true,"seq_num":11,"comment":"","comment_collapsed":true}],"node_layout":"<node_postions><node_position Node='-768' Position='766.0714721679688,1184.3074035644531,200,200'/><node_position Node='-40' Position='21.395309448242188,1134.2052917480469,200,200'/><node_position Node='-4857' Position='565,-116,200,200'/><node_position Node='-4849' Position='-24,-118,200,200'/><node_position Node='-4862' Position='401,184,200,200'/><node_position Node='-2687' Position='425,533,200,200'/><node_position Node='-6998' Position='454,403,200,200'/><node_position Node='-281' Position='-47,509,200,200'/><node_position Node='-110' Position='1008,1061,200,200'/><node_position Node='-118' Position='1010,956,200,200'/><node_position Node='-125' Position='1019,784,200,200'/></node_postions>"},"nodes_readonly":false,"studio_version":"v2"}
[2022-09-20 10:50:27.654572] INFO: moduleinvoker: input_features.v1 开始运行..
[2022-09-20 10:50:27.662758] INFO: moduleinvoker: 命中缓存
[2022-09-20 10:50:27.664728] INFO: moduleinvoker: input_features.v1 运行完成[0.010169s].
[2022-09-20 10:50:27.679542] INFO: moduleinvoker: instruments.v2 开始运行..
[2022-09-20 10:50:27.685666] INFO: moduleinvoker: 命中缓存
[2022-09-20 10:50:27.687668] INFO: moduleinvoker: instruments.v2 运行完成[0.008124s].
[2022-09-20 10:50:27.710756] INFO: moduleinvoker: general_feature_extractor.v7 开始运行..
[2022-09-20 10:50:27.717378] INFO: moduleinvoker: 命中缓存
[2022-09-20 10:50:27.719472] INFO: moduleinvoker: general_feature_extractor.v7 运行完成[0.008719s].
[2022-09-20 10:50:27.728209] INFO: moduleinvoker: derived_feature_extractor.v3 开始运行..
[2022-09-20 10:50:27.733328] INFO: moduleinvoker: 命中缓存
[2022-09-20 10:50:27.734695] INFO: moduleinvoker: derived_feature_extractor.v3 运行完成[0.006483s].
[2022-09-20 10:50:27.742643] INFO: moduleinvoker: chinaa_stock_filter.v1 开始运行..
[2022-09-20 10:50:27.748005] INFO: moduleinvoker: 命中缓存
[2022-09-20 10:50:27.749962] INFO: moduleinvoker: chinaa_stock_filter.v1 运行完成[0.007304s].
[2022-09-20 10:50:27.759892] INFO: moduleinvoker: filter.v3 开始运行..
[2022-09-20 10:50:27.765380] INFO: moduleinvoker: 命中缓存
[2022-09-20 10:50:27.767504] INFO: moduleinvoker: filter.v3 运行完成[0.007614s].
[2022-09-20 10:50:27.777493] INFO: moduleinvoker: use_datasource.v1 开始运行..
[2022-09-20 10:50:27.783639] INFO: moduleinvoker: 命中缓存
[2022-09-20 10:50:27.785711] INFO: moduleinvoker: use_datasource.v1 运行完成[0.008227s].
[2022-09-20 10:50:27.796229] INFO: moduleinvoker: join.v3 开始运行..
[2022-09-20 10:50:27.802069] INFO: moduleinvoker: 命中缓存
[2022-09-20 10:50:27.804260] INFO: moduleinvoker: join.v3 运行完成[0.008026s].
[2022-09-20 10:50:27.811004] INFO: moduleinvoker: sort.v5 开始运行..
[2022-09-20 10:50:29.114221] INFO: moduleinvoker: sort.v5 运行完成[1.303215s].
[2022-09-20 10:50:29.156623] INFO: moduleinvoker: hfbacktest.v1 开始运行..
[2022-09-20 10:50:29.883386] INFO: hfbacktest: biglearning V1.4.19
[2022-09-20 10:50:29.885241] INFO: hfbacktest: bigtrader v1.9.7_sp8 2022-09-16
[2022-09-20 10:50:29.928525] INFO: moduleinvoker: cached.v2 开始运行..
[2022-09-20 10:50:30.141534] INFO: moduleinvoker: cached.v2 运行完成[0.213022s].
[2022-09-20 10:50:30.252103] INFO: moduleinvoker: cached.v2 开始运行..
[2022-09-20 10:50:55.988355] INFO: moduleinvoker: cached.v2 运行完成[25.736263s].
[2022-09-20 10:51:03.551373] ERROR: moduleinvoker: module name: hfbacktest, module version: v1, trackeback: AttributeError: 'str' object has no attribute 'symbol'
[2022-09-20 10:51:03.559271] ERROR: moduleinvoker: module name: hftrade, module version: v2, trackeback: AttributeError: 'str' object has no attribute 'symbol'
333333.3333333333
2022-09-20 10:51:03.550750 strategy strategy exception:Traceback (most recent call last):
File "bigtrader/strategy/engine.py", line 713, in bigtrader2.bigtrader.strategy.engine.StrategyEngine._call_strategy_func
File "bigtrader/strategy/strategy_base.py", line 2244, in bigtrader2.bigtrader.strategy.strategy_base.StrategyBase.call_handle_data
File "<ipython-input-4-5715c2018ab3>", line 34, in m1_handle_data_bigquant_run
positions = {e.symbol: p.cost_basis for e, p in context.portfolio.positions.items()}
File "<ipython-input-4-5715c2018ab3>", line 34, in <dictcomp>
positions = {e.symbol: p.cost_basis for e, p in context.portfolio.positions.items()}
AttributeError: 'str' object has no attribute 'symbol'
---------------------------------------------------------------------------
AttributeError Traceback (most recent call last)
<ipython-input-4-5715c2018ab3> in <module>
233 )
234
--> 235 m1 = M.hftrade.v2(
236 instruments=m4.data,
237 options_data=m9.sorted_data,
<ipython-input-4-5715c2018ab3> in m1_handle_data_bigquant_run(context, data)
32 #------------------------------------------止赢模块START--------------------------------------------
33 date = data.current_dt.strftime('%Y-%m-%d')
---> 34 positions = {e.symbol: p.cost_basis for e, p in context.portfolio.positions.items()}
35 # 新建当日止赢股票列表是为了handle_data 策略逻辑部分不再对该股票进行判断
36 current_stopwin_stock = []
<ipython-input-4-5715c2018ab3> in <dictcomp>(.0)
32 #------------------------------------------止赢模块START--------------------------------------------
33 date = data.current_dt.strftime('%Y-%m-%d')
---> 34 positions = {e.symbol: p.cost_basis for e, p in context.portfolio.positions.items()}
35 # 新建当日止赢股票列表是为了handle_data 策略逻辑部分不再对该股票进行判断
36 current_stopwin_stock = []
AttributeError: 'str' object has no attribute 'symbol'