{"description":"实验创建于2022/3/7","graph":{"edges":[{"to_node_id":"-248:instruments","from_node_id":"-290:data"}],"nodes":[{"node_id":"-290","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-03-11","type":"Literal","bound_global_parameter":"交易日期"},{"name":"market","value":"CN_STOCK_A","type":"Literal","bound_global_parameter":null},{"name":"instrument_list","value":"600519.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":"-290"}],"output_ports":[{"name":"data","node_id":"-290"}],"cacheable":false,"seq_num":1,"comment":"输入证券","comment_collapsed":true},{"node_id":"-248","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.subscribe(context.instruments[0])\n context.set_universe(context.instruments[0]) # 设置需要处理的合约\n context.bar_series = NumPyDeque(200, dtype='object') # 20个分钟 K线 (包括OHLC)\n context.bar_index = 0 # 分钟K线序号\n context.big_cycle_bar_index = 0 #30分钟大周期K线序号\n context.ma_periods = 26 \n\n \n \n ","type":"Literal","bound_global_parameter":null},{"name":"before_trading_start","value":"# 交易引擎:每个单位时间开盘前调用一次。\ndef bigquant_run(context, data):\n pass","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 import talib as ta\n context.bar_index += 1\n cur_date = data.current_dt\n cur_hm = cur_date.strftime('%H:%M')\n \n \n if context.bar_index % 30 == 0: # 30m k线\n context.big_cycle_bar_index += 1\n \n sid = context.symbol(context.instruments[0])# 标的为字符串格式\n hist = data.history(sid, [\"open\",\"high\",\"low\",\"close\"], 30, \"1m\")\n big_cycle_bar_data = {'datetime':hist.index[-1],'high':hist.high.max(),'open':hist.open.values[0],'low':hist.low.min(),'close':hist.close.values[-1]}\n context.bar_series.append(big_cycle_bar_data)\n \n if context.big_cycle_bar_index > context.ma_periods : # 30分钟大周期K线的移动平均26个周期的均值 \n price_data = pd.DataFrame(list(context.bar_series))\n \n sma = talib.SMA(price_data['close'], timeperiod=context.ma_periods ).values[-1]\n cur_price = price_data['close'].values[-1]\n cur_position = context.portfolio.positions[sid].amount # 持仓 \n \n if cur_position==0 and cur_price>sma:\n context.order(sid, 100)\n print('buy'*5, cur_date)\n \n elif cur_position>0 and cur_price<sma:\n context.order_target_percent(sid, 0)\n print('sell'*5, cur_date)\n\n \n \n\n \n \n\n \n \n \n \n \n \n \n \n \n \n \n \n\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":"500000","type":"Literal","bound_global_parameter":null},{"name":"frequency","value":"minute","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":"open","type":"Literal","bound_global_parameter":null},{"name":"order_price_field_sell","value":"open","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":"True","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":"-248"},{"name":"options_data","node_id":"-248"},{"name":"history_ds","node_id":"-248"},{"name":"benchmark_ds","node_id":"-248"}],"output_ports":[{"name":"raw_perf","node_id":"-248"}],"cacheable":false,"seq_num":3,"comment":"","comment_collapsed":true}],"node_layout":"<node_postions><node_position Node='-290' Position='-75,-332,200,200'/><node_position Node='-248' Position='-66.40879440307617,-202,200,200'/></node_postions>"},"nodes_readonly":false,"studio_version":"v2"}
[2022-12-12 14:10:35.419305] INFO: moduleinvoker: instruments.v2 开始运行..
[2022-12-12 14:10:35.439672] INFO: moduleinvoker: instruments.v2 运行完成[0.020366s].
[2022-12-12 14:10:35.492126] INFO: moduleinvoker: hfbacktest.v1 开始运行..
[2022-12-12 14:10:35.498119] INFO: hfbacktest: biglearning V1.4.19
[2022-12-12 14:10:35.500702] INFO: hfbacktest: bigtrader v1.9.11 2022-12-09
[2022-12-12 14:10:35.524976] INFO: moduleinvoker: cached.v2 开始运行..
[2022-12-12 14:10:35.534432] INFO: moduleinvoker: 命中缓存
[2022-12-12 14:10:35.541595] INFO: moduleinvoker: cached.v2 运行完成[0.016637s].
[2022-12-12 14:10:35.670056] INFO: moduleinvoker: cached.v2 开始运行..
[2022-12-12 14:10:35.678006] INFO: moduleinvoker: 命中缓存
[2022-12-12 14:10:35.680127] INFO: moduleinvoker: cached.v2 运行完成[0.010112s].
[2022-12-12 14:10:38.906027] INFO: hfbacktest: backtest done, raw_perf_ds:DataSource(acf3dd559179475bb893dad319ddbf2fT)
[2022-12-12 14:10:39.028997] ERROR: moduleinvoker: module name: hfbacktest, module version: v1, trackeback: AttributeError: 'BigQuantModule' object has no attribute '_basic_info_ds'
[2022-12-12 14:10:39.034498] ERROR: moduleinvoker: module name: hftrade, module version: v2, trackeback: AttributeError: 'BigQuantModule' object has no attribute '_basic_info_ds'
buybuybuybuybuy 2022-01-12 10:30:00
sellsellsellsellsell 2022-01-13 10:00:00
buybuybuybuybuy 2022-01-18 10:00:00
sellsellsellsellsell 2022-01-24 13:30:00
buybuybuybuybuy 2022-01-26 14:30:00
sellsellsellsellsell 2022-01-28 10:00:00
buybuybuybuybuy 2022-02-09 13:30:00
sellsellsellsellsell 2022-02-11 13:30:00
buybuybuybuybuy 2022-02-14 11:30:00
sellsellsellsellsell 2022-02-14 14:30:00
sellsellsellsellsell 2022-02-17 13:30:00
buybuybuybuybuy 2022-02-18 11:00:00
sellsellsellsellsell 2022-02-21 10:30:00
buybuybuybuybuy 2022-02-25 10:00:00
sellsellsellsellsell 2022-02-25 10:30:00
sellsellsellsellsell 2022-02-25 11:00:00
sellsellsellsellsell 2022-02-25 11:30:00
sellsellsellsellsell 2022-02-25 13:30:00
sellsellsellsellsell 2022-02-28 10:00:00
buybuybuybuybuy 2022-02-28 15:00:00
buybuybuybuybuy 2022-03-01 10:00:00
sellsellsellsellsell 2022-03-03 10:00:00
buybuybuybuybuy 2022-03-08 14:00:00
sellsellsellsellsell 2022-03-08 14:30:00
sellsellsellsellsell 2022-03-08 15:00:00
sellsellsellsellsell 2022-03-09 14:00:00
buybuybuybuybuy 2022-03-09 14:30:00
sellsellsellsellsell 2022-03-11 10:00:00
buybuybuybuybuy 2022-03-11 14:30:00
sellsellsellsellsell 2022-03-11 15:00:00
---------------------------------------------------------------------------
AttributeError Traceback (most recent call last)
<ipython-input-2-2232d4dc55fe> in <module>
97 )
98
---> 99 m3 = M.hftrade.v2(
100 instruments=m1.data,
101 start_date='',
AttributeError: 'BigQuantModule' object has no attribute '_basic_info_ds'