复制链接
克隆策略

    {"description":"实验创建于2023/5/17","graph":{"edges":[{"to_node_id":"-48:input_data","from_node_id":"-104:data_1"},{"to_node_id":"-48:features","from_node_id":"-43:data"},{"to_node_id":"-83:options_data","from_node_id":"-48:data"},{"to_node_id":"-83:instruments","from_node_id":"-25:data"}],"nodes":[{"node_id":"-104","module_id":"BigQuantSpace.cached.cached-v3","parameters":[{"name":"run","value":"# 自定义python模块\n# 获取指定代码的数据源,计算orb值\ndef bigquant_run(instrument, start_time, end_time):\n import pandas as pd\n #读取指定时间范围内的数据\n data_1 = DataSource(\"bar1d_CN_FUTURE\").read(start_date=start_time\n ,end_date=end_time,instruments=[instrument])\n \n # 创建一个空的series储存orb信息\n orb = pd.Series([])\n for index,row in data_1.iterrows():\n # index跳过\n if index == 0:\n continue\n \n last_day_row = data_1.iloc[index-1]\n cur_orb = min(abs(last_day_row['high']-last_day_row['close']), abs(last_day_row['low']-last_day_row['close']))\n # 累加数据\n orb = orb.append(pd.Series({index:cur_orb}))\n\n # 赋值\n data_1['orb'] = orb\n data_1 = DataSource.write_df(data_1)\n \n return Outputs(data_1=data_1)","type":"Literal","bound_global_parameter":null},{"name":"post_run","value":"# 后处理函数,可选。输入是主函数的输出,可以在这里对数据做处理,或者返回更友好的outputs数据格式。此函数输出不会被缓存。\ndef bigquant_run(outputs):\n return outputs\n","type":"Literal","bound_global_parameter":null},{"name":"input_ports","value":"","type":"Literal","bound_global_parameter":null},{"name":"params","value":"{\n 'instrument':'IF9999.CFX',\n 'start_time':'2021-01-01',\n 'end_time':'2022-01-19'\n}","type":"Literal","bound_global_parameter":null},{"name":"output_ports","value":"date_1","type":"Literal","bound_global_parameter":null}],"input_ports":[{"name":"input_1","node_id":"-104"},{"name":"input_2","node_id":"-104"},{"name":"input_3","node_id":"-104"}],"output_ports":[{"name":"data_1","node_id":"-104"},{"name":"data_2","node_id":"-104"},{"name":"data_3","node_id":"-104"}],"cacheable":false,"seq_num":5,"comment":"","comment_collapsed":true},{"node_id":"-43","module_id":"BigQuantSpace.input_features.input_features-v1","parameters":[{"name":"features","value":"\n# #号开始的表示注释,注释需单独一行\n# 多个特征,每行一个,可以包含基础特征和衍生特征,特征须为本平台特征\ncross = open + mean(orb,3)*2.0\nthrough = open - mean(orb,3)*1.5\n","type":"Literal","bound_global_parameter":null}],"input_ports":[{"name":"features_ds","node_id":"-43"}],"output_ports":[{"name":"data","node_id":"-43"}],"cacheable":false,"seq_num":1,"comment":"","comment_collapsed":true},{"node_id":"-48","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":"-48"},{"name":"features","node_id":"-48"}],"output_ports":[{"name":"data","node_id":"-48"}],"cacheable":false,"seq_num":2,"comment":"","comment_collapsed":true},{"node_id":"-25","module_id":"BigQuantSpace.instruments.instruments-v2","parameters":[{"name":"start_date","value":"2021-01-01","type":"Literal","bound_global_parameter":null},{"name":"end_date","value":"2022-01-19","type":"Literal","bound_global_parameter":null},{"name":"market","value":"CN_FUTURE","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":"-25"}],"output_ports":[{"name":"data","node_id":"-25"}],"cacheable":false,"seq_num":4,"comment":"","comment_collapsed":true},{"node_id":"-83","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.set_commission(PerOrder(buy_cost=0.000023, sell_cost=0.000023, min_cost=5))\n \n","type":"Literal","bound_global_parameter":null},{"name":"before_trading_start","value":"# 交易引擎:每个单位时间开盘前调用一次。\ndef bigquant_run(context, data):\n # 盘前处理,订阅行情等\n df = context.options['data'].read_df()\n context.subscribe_bar(df.instrument.iloc[0], '1m')\n context.today_open = 0\n context.today_close = 0\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":"# K线处理函数\n# 回测引擎:每日数据处理函数,每天执行一次\ndef bigquant_run(context, data):\n df = context.options['data'].read_df()\n # 当前时间\n today = data.current_dt.strftime('%Y-%m-%d') \n cur_time = data.current_dt.strftime('%Y-%m-%d %H:%M:00') \n today_t = pd.Timestamp(today)\n # 尾盘时间\n end_t1 = data.current_dt.strftime('%Y-%m-%d 14:55:00')\n # 账户资金\n cash = context.portfolio.cash\n \n # 尾盘平仓\n if cur_time == end_t1:\n symbol = df[df['date']<=today_t].instrument.iloc[0]\n \n price = data.current(symbol, 'close')\n position_long = context.get_position(symbol, Direction.LONG)\n position_short = context.get_position(symbol, Direction.SHORT)\n \n if position_long.avail_qty > 0 and context.today_open == 1:\n rs = context.sell_open(symbol, position_long.avail_qty, price, OrderType.MARKET) \n if rs == 0:\n context.today_open = 0\n print('操作时间',cur_time,'price:',price,'持仓:',position_long.avail_qty,', rs:',rs,'尾盘多头平仓')\n if position_short.avail_qty > 0 and context.today_close == 1:\n rs = context.buy_close(symbol, position_short.avail_qty, price, OrderType.MARKET)\n if rs == 0:\n context.today_close = 0\n print('操作时间',cur_time,'price:',price,'持仓:',position_long.avail_qty,', rs:',rs, '尾盘空头平仓')\n return\n if cur_time > end_t1:\n return\n \n cur_day_frame = df[df['date']==today_t]\n if cur_day_frame.empty: \n return\n\n # 遍历所有进行判断\n for index,row in cur_day_frame.iterrows():\n symbol = row['instrument']\n cross = row['cross']\n through = row['through']\n # 期货价格\n \n price = data.current(symbol, 'price')\n\n \n position_long = context.get_position(symbol, Direction.LONG)\n position_short = context.get_position(symbol, Direction.SHORT)\n \n # 不可交易\n if not data.can_trade(symbol):\n return\n \n if position_long.avail_qty > 0:\n proportation = (price - position_long.cost_price)/position_long.cost_price\n if (proportation > 0.2 or proportation < -0.3) and context.today_open == 1:\n rs = context.sell_open(symbol, position_long.avail_qty, price, OrderType.MARKET)\n print('操作时间',cur_time,'price:',price,'proportation:',proportation,'成本:',position_long.cost_price,', rs:',rs,', 平多止盈止损')\n\n return\n if position_short.avail_qty > 0:\n proportation = (position_short.cost_price - price)/position_short.cost_price\n if (proportation > 0.2 or proportation) < -0.3 and context.today_close == 1:\n rs = context.buy_close(symbol, position_short.avail_qty, price, OrderType.MARKET)\n print('操作时间',cur_time,'price:',price,'proportation:',proportation,'成本:',position_short.cost_price,', rs:',rs,', 平空止盈止损')\n \n return\n \n if price > cross and context.today_open == 0:\n rs = context.buy_open(symbol, 1, price, OrderType.MARKET)\n if rs == 0:\n context.today_open = 1\n print('操作时间',cur_time,'price:',price,'cross:',cross,',through:',through\n ,'持仓:',position_long.current_qty,', rs:',rs,',cash:',cash,'买多')\n elif price < through and context.today_close == 0:\n\n rs = context.sell_close(symbol, 1, price, OrderType.MARKET)\n if rs == 0:\n context.today_close = 1\n print('操作时间',cur_time,'price:',price,'cross:',cross,',through:',through\n ,'持仓:',position_short.current_qty,', rs:',rs,',cash:',cash,'卖空')","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":"close","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":"True","type":"Literal","bound_global_parameter":null},{"name":"backtest_only","value":"False","type":"Literal","bound_global_parameter":null}],"input_ports":[{"name":"instruments","node_id":"-83"},{"name":"options_data","node_id":"-83"},{"name":"history_ds","node_id":"-83"},{"name":"benchmark_ds","node_id":"-83"}],"output_ports":[{"name":"raw_perf","node_id":"-83"}],"cacheable":false,"seq_num":7,"comment":"","comment_collapsed":true}],"node_layout":"<node_postions><node_position Node='-104' Position='92,-150,200,200'/><node_position Node='-43' Position='463,-147,200,200'/><node_position Node='-48' Position='296,21,200,200'/><node_position Node='-25' Position='-128,70,200,200'/><node_position Node='-83' Position='155,244,200,200'/></node_postions>"},"nodes_readonly":false,"studio_version":"v2"}
    In [4]:
    # 本代码由可视化策略环境自动生成 2023年5月26日 11:20
    # 本代码单元只能在可视化模式下编辑。您也可以拷贝代码,粘贴到新建的代码单元或者策略,然后修改。
    
    
    # 自定义python模块
    # 获取指定代码的数据源,计算orb值
    def m5_run_bigquant_run(instrument, start_time, end_time):
        import pandas as pd
        #读取指定时间范围内的数据
        data_1 = DataSource("bar1d_CN_FUTURE").read(start_date=start_time
                      ,end_date=end_time,instruments=[instrument])
        
        # 创建一个空的series储存orb信息
        orb = pd.Series([])
        for index,row in data_1.iterrows():
            # index跳过
            if index == 0:
                continue
            
            last_day_row = data_1.iloc[index-1]
            cur_orb = min(abs(last_day_row['high']-last_day_row['close']), abs(last_day_row['low']-last_day_row['close']))
            # 累加数据
            orb = orb.append(pd.Series({index:cur_orb}))
    
        # 赋值
        data_1['orb'] = orb
        data_1 = DataSource.write_df(data_1)
           
        return Outputs(data_1=data_1)
    # 后处理函数,可选。输入是主函数的输出,可以在这里对数据做处理,或者返回更友好的outputs数据格式。此函数输出不会被缓存。
    def m5_post_run_bigquant_run(outputs):
        return outputs
    
    # 回测引擎:初始化函数,只执行一次
    def m7_initialize_bigquant_run(context):
        # 系统已经设置了默认的交易手续费和滑点,要修改手续费可使用如下函数
        context.set_commission(PerOrder(buy_cost=0.000023, sell_cost=0.000023, min_cost=5))
        
    
    # 交易引擎:每个单位时间开盘前调用一次。
    def m7_before_trading_start_bigquant_run(context, data):
        # 盘前处理,订阅行情等
        df = context.options['data'].read_df()
        context.subscribe_bar(df.instrument.iloc[0], '1m')
        context.today_open = 0
        context.today_close = 0
    
    # 交易引擎:tick数据处理函数,每个tick执行一次
    def m7_handle_tick_bigquant_run(context, tick):
        pass
    
    # K线处理函数
    # 回测引擎:每日数据处理函数,每天执行一次
    def m7_handle_data_bigquant_run(context, data):
        df = context.options['data'].read_df()
        # 当前时间
        today = data.current_dt.strftime('%Y-%m-%d')    
        cur_time = data.current_dt.strftime('%Y-%m-%d %H:%M:00')    
        today_t = pd.Timestamp(today)
        # 尾盘时间
        end_t1 = data.current_dt.strftime('%Y-%m-%d 14:55:00')
        # 账户资金
        cash = context.portfolio.cash
        
        # 尾盘平仓
        if cur_time == end_t1:
            symbol = df[df['date']<=today_t].instrument.iloc[0]
           
            price = data.current(symbol, 'close')
            position_long = context.get_position(symbol, Direction.LONG)
            position_short = context.get_position(symbol, Direction.SHORT)
            
            if position_long.avail_qty > 0 and context.today_open == 1:
                rs = context.sell_open(symbol, position_long.avail_qty, price, OrderType.MARKET)            
                if rs == 0:
                    context.today_open = 0
                print('操作时间',cur_time,'price:',price,'持仓:',position_long.avail_qty,', rs:',rs,'尾盘多头平仓')
            if position_short.avail_qty > 0 and context.today_close == 1:
                rs = context.buy_close(symbol, position_short.avail_qty, price, OrderType.MARKET)
                if rs == 0:
                    context.today_close = 0
                print('操作时间',cur_time,'price:',price,'持仓:',position_long.avail_qty,', rs:',rs, '尾盘空头平仓')
            return
        if cur_time > end_t1:
            return
         
        cur_day_frame = df[df['date']==today_t]
        if cur_day_frame.empty:        
            return
    
        # 遍历所有进行判断
        for index,row in cur_day_frame.iterrows():
            symbol = row['instrument']
            cross = row['cross']
            through = row['through']
            # 期货价格
            
            price = data.current(symbol, 'price')
    
            
            position_long = context.get_position(symbol, Direction.LONG)
            position_short = context.get_position(symbol, Direction.SHORT)
            
            # 不可交易
            if not data.can_trade(symbol):
                return
      
            if position_long.avail_qty > 0:
                proportation = (price - position_long.cost_price)/position_long.cost_price
                if (proportation > 0.2 or proportation < -0.3) and context.today_open == 1:
                    rs = context.sell_open(symbol, position_long.avail_qty, price, OrderType.MARKET)
                    print('操作时间',cur_time,'price:',price,'proportation:',proportation,'成本:',position_long.cost_price,', rs:',rs,', 平多止盈止损')
    
                    return
            if position_short.avail_qty > 0:
                proportation = (position_short.cost_price - price)/position_short.cost_price
                if (proportation > 0.2 or proportation) < -0.3 and context.today_close == 1:
                    rs = context.buy_close(symbol, position_short.avail_qty, price, OrderType.MARKET)
                    print('操作时间',cur_time,'price:',price,'proportation:',proportation,'成本:',position_short.cost_price,', rs:',rs,', 平空止盈止损')
        
                    return
            
            if price > cross and context.today_open == 0:
                rs = context.buy_open(symbol, 1, price, OrderType.MARKET)
                if rs == 0:
                    context.today_open = 1
                print('操作时间',cur_time,'price:',price,'cross:',cross,',through:',through
                    ,'持仓:',position_long.current_qty,', rs:',rs,',cash:',cash,'买多')
            elif price < through and context.today_close == 0:
    
                rs = context.sell_close(symbol, 1, price, OrderType.MARKET)
                if rs == 0:
                    context.today_close = 1
                print('操作时间',cur_time,'price:',price,'cross:',cross,',through:',through
                    ,'持仓:',position_short.current_qty,', rs:',rs,',cash:',cash,'卖空')
    # 交易引擎:成交回报处理函数,每个成交发生时执行一次
    def m7_handle_trade_bigquant_run(context, trade):
        pass
    
    # 交易引擎:委托回报处理函数,每个委托变化时执行一次
    def m7_handle_order_bigquant_run(context, order):
        pass
    
    # 交易引擎:盘后处理函数,每日盘后执行一次
    def m7_after_trading_bigquant_run(context, data):
        pass
    
    
    m5 = M.cached.v3(
        run=m5_run_bigquant_run,
        post_run=m5_post_run_bigquant_run,
        input_ports='',
        params="""{
        'instrument':'IF9999.CFX',
        'start_time':'2021-01-01',
        'end_time':'2022-01-19'
    }""",
        output_ports='date_1',
        m_cached=False
    )
    
    m1 = M.input_features.v1(
        features="""
    # #号开始的表示注释,注释需单独一行
    # 多个特征,每行一个,可以包含基础特征和衍生特征,特征须为本平台特征
    cross = open + mean(orb,3)*2.0
    through = open - mean(orb,3)*1.5
    """,
        m_cached=False
    )
    
    m2 = M.derived_feature_extractor.v3(
        input_data=m5.data_1,
        features=m1.data,
        date_col='date',
        instrument_col='instrument',
        drop_na=False,
        remove_extra_columns=False,
        user_functions={},
        m_cached=False
    )
    
    m4 = M.instruments.v2(
        start_date='2021-01-01',
        end_date='2022-01-19',
        market='CN_FUTURE',
        instrument_list='',
        max_count=0,
        m_cached=False
    )
    
    m7 = M.hftrade.v2(
        instruments=m4.data,
        options_data=m2.data,
        start_date='',
        end_date='',
        initialize=m7_initialize_bigquant_run,
        before_trading_start=m7_before_trading_start_bigquant_run,
        handle_tick=m7_handle_tick_bigquant_run,
        handle_data=m7_handle_data_bigquant_run,
        handle_trade=m7_handle_trade_bigquant_run,
        handle_order=m7_handle_order_bigquant_run,
        after_trading=m7_after_trading_bigquant_run,
        capital_base=500000,
        frequency='minute',
        price_type='真实价格',
        product_type='期货',
        before_start_days='0',
        volume_limit=1,
        order_price_field_buy='open',
        order_price_field_sell='close',
        benchmark='000300.HIX',
        plot_charts=True,
        disable_cache=False,
        replay_bdb=False,
        show_debug_info=True,
        backtest_only=False
    )
    
    2023-05-26 11:18:23.056617 init history datas... 
    2023-05-26 11:18:23.057810 init history datas done. 
    2023-05-26 11:18:25.347224 run_backtest() capital_base:500000, frequency:1m, product_type:future, date:20210104 ~ 2022-01-19 
    2023-05-26 11:18:25.348297 run_backtest() running... 
    2023-05-26 11:18:25.796157 initial contracts len=0 
    2023-05-26 11:18:25.796834 backtest inited. 
    2023-05-26 11:18:25.848816 backtest transforming 1m, bars=1... 
    2023-05-26 11:18:25.849549 transform start_trading_day=2021-01-04 00:00:00, simulation period=20210104 ~ 2022-01-19 
    2023-05-26 11:18:25.849594 transform before_start_days=0 
    2023-05-26 11:18:25.849626 transform replay_func=<cyfunction BacktestEngine.transform.<locals>.replay_bars_dt at 0x7f24d44b4380> 
    操作时间 2021-01-07 11:16:00 price: 5048.2 cross: 5047.06640625 ,through: 4959.800537109375 持仓: 0 , rs: 0 ,cash: 500000.0 买多
    操作时间 2021-01-07 14:55:00 price: 5093.0 持仓: 1 , rs: 0 尾盘多头平仓
    操作时间 2021-01-08 09:41:00 price: 5092.2 cross: 5147.599609375 ,through: 5099.30029296875 持仓: 1 , rs: 0 ,cash: 134868.42648437497 卖空
    操作时间 2021-01-08 14:55:00 price: 5085.0 持仓: 0 , rs: 0 尾盘空头平仓
    2023-05-26 11:20:02.299841 handle_order_submit process req check position failed for order_req:OrderReq(bktfut,IF9999.CFX,'2','1',1,5038.7998,U,0,strategy,2021-01-11 14:00:00) 
    操作时间 2021-01-11 14:00:00 price: 5038.8 cross: 5139.266438802083 ,through: 5040.100341796875 持仓: 0 , rs: -113 ,cash: 515399.74199999997 卖空
    2023-05-26 11:20:02.328661 handle_order_submit process req check position failed for order_req:OrderReq(bktfut,IF9999.CFX,'2','1',1,5027.7998,U,0,strategy,2021-01-11 14:01:00) 
    操作时间 2021-01-11 14:01:00 price: 5027.8 cross: 5139.266438802083 ,through: 5040.100341796875 持仓: 0 , rs: -113 ,cash: 515399.74199999997 卖空
    2023-05-26 11:20:02.364143 handle_order_submit process req check position failed for order_req:OrderReq(bktfut,IF9999.CFX,'2','1',1,5025.2001,U,0,strategy,2021-01-11 14:02:00) 
    操作时间 2021-01-11 14:02:00 price: 5025.2 cross: 5139.266438802083 ,through: 5040.100341796875 持仓: 0 , rs: -113 ,cash: 515399.74199999997 卖空
    2023-05-26 11:20:02.394272 handle_order_submit process req check position failed for order_req:OrderReq(bktfut,IF9999.CFX,'2','1',1,5015.6,U,0,strategy,2021-01-11 14:03:00) 
    操作时间 2021-01-11 14:03:00 price: 5015.6 cross: 5139.266438802083 ,through: 5040.100341796875 持仓: 0 , rs: -113 ,cash: 515399.74199999997 卖空
    2023-05-26 11:20:02.421494 handle_order_submit process req check position failed for order_req:OrderReq(bktfut,IF9999.CFX,'2','1',1,5024.7998,U,0,strategy,2021-01-11 14:04:00) 
    操作时间 2021-01-11 14:04:00 price: 5024.8 cross: 5139.266438802083 ,through: 5040.100341796875 持仓: 0 , rs: -113 ,cash: 515399.74199999997 卖空
    2023-05-26 11:20:02.447749 handle_order_submit process req check position failed for order_req:OrderReq(bktfut,IF9999.CFX,'2','1',1,5028.3999,U,0,strategy,2021-01-11 14:05:00) 
    操作时间 2021-01-11 14:05:00 price: 5028.4 cross: 5139.266438802083 ,through: 5040.100341796875 持仓: 0 , rs: -113 ,cash: 515399.74199999997 卖空
    2023-05-26 11:20:02.475287 handle_order_submit process req check position failed for order_req:OrderReq(bktfut,IF9999.CFX,'2','1',1,5032.2001,U,0,strategy,2021-01-11 14:06:00) 
    操作时间 2021-01-11 14:06:00 price: 5032.2 cross: 5139.266438802083 ,through: 5040.100341796875 持仓: 0 , rs: -113 ,cash: 515399.74199999997 卖空
    2023-05-26 11:20:02.500366 handle_order_submit process req check position failed for order_req:OrderReq(bktfut,IF9999.CFX,'2','1',1,5029.7998,U,0,strategy,2021-01-11 14:07:00) 
    操作时间 2021-01-11 14:07:00 price: 5029.8 cross: 5139.266438802083 ,through: 5040.100341796875 持仓: 0 , rs: -113 ,cash: 515399.74199999997 卖空
    2023-05-26 11:20:02.524695 handle_order_submit process req check position failed for order_req:OrderReq(bktfut,IF9999.CFX,'2','1',1,5023.6,U,0,strategy,2021-01-11 14:08:00) 
    操作时间 2021-01-11 14:08:00 price: 5023.6 cross: 5139.266438802083 ,through: 5040.100341796875 持仓: 0 , rs: -113 ,cash: 515399.74199999997 卖空
    2023-05-26 11:20:02.548855 handle_order_submit process req check position failed for order_req:OrderReq(bktfut,IF9999.CFX,'2','1',1,5020.2001,U,0,strategy,2021-01-11 14:09:00) 
    操作时间 2021-01-11 14:09:00 price: 5020.2 cross: 5139.266438802083 ,through: 5040.100341796875 持仓: 0 , rs: -113 ,cash: 515399.74199999997 卖空
    2023-05-26 11:20:02.573935 handle_order_submit process req check position failed for order_req:OrderReq(bktfut,IF9999.CFX,'2','1',1,5026.7998,U,0,strategy,2021-01-11 14:10:00) 
    操作时间 2021-01-11 14:10:00 price: 5026.8 cross: 5139.266438802083 ,through: 5040.100341796875 持仓: 0 , rs: -113 ,cash: 515399.74199999997 卖空
    2023-05-26 11:20:02.599068 handle_order_submit process req check position failed for order_req:OrderReq(bktfut,IF9999.CFX,'2','1',1,5019.3999,U,0,strategy,2021-01-11 14:11:00) 
    操作时间 2021-01-11 14:11:00 price: 5019.4 cross: 5139.266438802083 ,through: 5040.100341796875 持仓: 0 , rs: -113 ,cash: 515399.74199999997 卖空
    2023-05-26 11:20:02.624329 handle_order_submit process req check position failed for order_req:OrderReq(bktfut,IF9999.CFX,'2','1',1,5006.3999,U,0,strategy,2021-01-11 14:12:00) 
    操作时间 2021-01-11 14:12:00 price: 5006.4 cross: 5139.266438802083 ,through: 5040.100341796875 持仓: 0 , rs: -113 ,cash: 515399.74199999997 卖空
    2023-05-26 11:20:02.651070 handle_order_submit process req check position failed for order_req:OrderReq(bktfut,IF9999.CFX,'2','1',1,5000.6,U,0,strategy,2021-01-11 14:13:00) 
    操作时间 2021-01-11 14:13:00 price: 5000.6 cross: 5139.266438802083 ,through: 5040.100341796875 持仓: 0 , rs: -113 ,cash: 515399.74199999997 卖空
    2023-05-26 11:20:02.677199 handle_order_submit process req check position failed for order_req:OrderReq(bktfut,IF9999.CFX,'2','1',1,5002.0,U,0,strategy,2021-01-11 14:14:00) 
    操作时间 2021-01-11 14:14:00 price: 5002.0 cross: 5139.266438802083 ,through: 5040.100341796875 持仓: 0 , rs: -113 ,cash: 515399.74199999997 卖空
    2023-05-26 11:20:02.702487 handle_order_submit process req check position failed for order_req:OrderReq(bktfut,IF9999.CFX,'2','1',1,5004.6,U,0,strategy,2021-01-11 14:15:00) 
    操作时间 2021-01-11 14:15:00 price: 5004.6 cross: 5139.266438802083 ,through: 5040.100341796875 持仓: 0 , rs: -113 ,cash: 515399.74199999997 卖空
    2023-05-26 11:20:02.727911 handle_order_submit process req check position failed for order_req:OrderReq(bktfut,IF9999.CFX,'2','1',1,5008.0,U,0,strategy,2021-01-11 14:16:00) 
    操作时间 2021-01-11 14:16:00 price: 5008.0 cross: 5139.266438802083 ,through: 5040.100341796875 持仓: 0 , rs: -113 ,cash: 515399.74199999997 卖空
    2023-05-26 11:20:02.753950 handle_order_submit process req check position failed for order_req:OrderReq(bktfut,IF9999.CFX,'2','1',1,4998.0,U,0,strategy,2021-01-11 14:17:00) 
    操作时间 2021-01-11 14:17:00 price: 4998.0 cross: 5139.266438802083 ,through: 5040.100341796875 持仓: 0 , rs: -113 ,cash: 515399.74199999997 卖空
    2023-05-26 11:20:02.781120 handle_order_submit process req check position failed for order_req:OrderReq(bktfut,IF9999.CFX,'2','1',1,5006.6,U,0,strategy,2021-01-11 14:18:00) 
    操作时间 2021-01-11 14:18:00 price: 5006.6 cross: 5139.266438802083 ,through: 5040.100341796875 持仓: 0 , rs: -113 ,cash: 515399.74199999997 卖空
    2023-05-26 11:20:02.807966 handle_order_submit process req check position failed for order_req:OrderReq(bktfut,IF9999.CFX,'2','1',1,5005.7998,U,0,strategy,2021-01-11 14:19:00) 
    操作时间 2021-01-11 14:19:00 price: 5005.8 cross: 5139.266438802083 ,through: 5040.100341796875 持仓: 0 , rs: -113 ,cash: 515399.74199999997 卖空
    2023-05-26 11:20:02.838663 handle_order_submit process req check position failed for order_req:OrderReq(bktfut,IF9999.CFX,'2','1',1,5009.7998,U,0,strategy,2021-01-11 14:20:00) 
    操作时间 2021-01-11 14:20:00 price: 5009.8 cross: 5139.266438802083 ,through: 5040.100341796875 持仓: 0 , rs: -113 ,cash: 515399.74199999997 卖空
    2023-05-26 11:20:02.864399 handle_order_submit process req check position failed for order_req:OrderReq(bktfut,IF9999.CFX,'2','1',1,5020.2001,U,0,strategy,2021-01-11 14:21:00) 
    操作时间 2021-01-11 14:21:00 price: 5020.2 cross: 5139.266438802083 ,through: 5040.100341796875 持仓: 0 , rs: -113 ,cash: 515399.74199999997 卖空
    2023-05-26 11:20:02.889494 handle_order_submit process req check position failed for order_req:OrderReq(bktfut,IF9999.CFX,'2','1',1,5018.3999,U,0,strategy,2021-01-11 14:22:00) 
    操作时间 2021-01-11 14:22:00 price: 5018.4 cross: 5139.266438802083 ,through: 5040.100341796875 持仓: 0 , rs: -113 ,cash: 515399.74199999997 卖空
    2023-05-26 11:20:02.916007 handle_order_submit process req check position failed for order_req:OrderReq(bktfut,IF9999.CFX,'2','1',1,5027.3999,U,0,strategy,2021-01-11 14:23:00) 
    操作时间 2021-01-11 14:23:00 price: 5027.4 cross: 5139.266438802083 ,through: 5040.100341796875 持仓: 0 , rs: -113 ,cash: 515399.74199999997 卖空
    2023-05-26 11:20:02.955216 handle_order_submit process req check position failed for order_req:OrderReq(bktfut,IF9999.CFX,'2','1',1,5021.2001,U,0,strategy,2021-01-11 14:24:00) 
    操作时间 2021-01-11 14:24:00 price: 5021.2 cross: 5139.266438802083 ,through: 5040.100341796875 持仓: 0 , rs: -113 ,cash: 515399.74199999997 卖空
    2023-05-26 11:20:02.988119 handle_order_submit process req check position failed for order_req:OrderReq(bktfut,IF9999.CFX,'2','1',1,5023.7998,U,0,strategy,2021-01-11 14:25:00) 
    操作时间 2021-01-11 14:25:00 price: 5023.8 cross: 5139.266438802083 ,through: 5040.100341796875 持仓: 0 , rs: -113 ,cash: 515399.74199999997 卖空
    2023-05-26 11:20:03.023785 handle_order_submit process req check position failed for order_req:OrderReq(bktfut,IF9999.CFX,'2','1',1,5016.2001,U,0,strategy,2021-01-11 14:26:00) 
    操作时间 2021-01-11 14:26:00 price: 5016.2 cross: 5139.266438802083 ,through: 5040.100341796875 持仓: 0 , rs: -113 ,cash: 515399.74199999997 卖空
    2023-05-26 11:20:03.057134 handle_order_submit process req check position failed for order_req:OrderReq(bktfut,IF9999.CFX,'2','1',1,5014.7998,U,0,strategy,2021-01-11 14:27:00) 
    操作时间 2021-01-11 14:27:00 price: 5014.8 cross: 5139.266438802083 ,through: 5040.100341796875 持仓: 0 , rs: -113 ,cash: 515399.74199999997 卖空
    2023-05-26 11:20:03.088510 handle_order_submit process req check position failed for order_req:OrderReq(bktfut,IF9999.CFX,'2','1',1,5019.2001,U,0,strategy,2021-01-11 14:28:00) 
    操作时间 2021-01-11 14:28:00 price: 5019.2 cross: 5139.266438802083 ,through: 5040.100341796875 持仓: 0 , rs: -113 ,cash: 515399.74199999997 卖空
    2023-05-26 11:20:03.116586 handle_order_submit process req check position failed for order_req:OrderReq(bktfut,IF9999.CFX,'2','1',1,5023.7998,U,0,strategy,2021-01-11 14:29:00) 
    操作时间 2021-01-11 14:29:00 price: 5023.8 cross: 5139.266438802083 ,through: 5040.100341796875 持仓: 0 , rs: -113 ,cash: 515399.74199999997 卖空
    2023-05-26 11:20:03.142963 handle_order_submit process req check position failed for order_req:OrderReq(bktfut,IF9999.CFX,'2','1',1,5023.7998,U,0,strategy,2021-01-11 14:30:00) 
    操作时间 2021-01-11 14:30:00 price: 5023.8 cross: 5139.266438802083 ,through: 5040.100341796875 持仓: 0 , rs: -113 ,cash: 515399.74199999997 卖空
    2023-05-26 11:20:03.170571 handle_order_submit process req check position failed for order_req:OrderReq(bktfut,IF9999.CFX,'2','1',1,5016.3999,U,0,strategy,2021-01-11 14:31:00) 
    操作时间 2021-01-11 14:31:00 price: 5016.4 cross: 5139.266438802083 ,through: 5040.100341796875 持仓: 0 , rs: -113 ,cash: 515399.74199999997 卖空
    2023-05-26 11:20:03.199456 handle_order_submit process req check position failed for order_req:OrderReq(bktfut,IF9999.CFX,'2','1',1,5024.6,U,0,strategy,2021-01-11 14:32:00) 
    操作时间 2021-01-11 14:32:00 price: 5024.6 cross: 5139.266438802083 ,through: 5040.100341796875 持仓: 0 , rs: -113 ,cash: 515399.74199999997 卖空
    2023-05-26 11:20:03.225796 handle_order_submit process req check position failed for order_req:OrderReq(bktfut,IF9999.CFX,'2','1',1,5025.7998,U,0,strategy,2021-01-11 14:33:00) 
    操作时间 2021-01-11 14:33:00 price: 5025.8 cross: 5139.266438802083 ,through: 5040.100341796875 持仓: 0 , rs: -113 ,cash: 515399.74199999997 卖空
    2023-05-26 11:20:03.252920 handle_order_submit process req check position failed for order_req:OrderReq(bktfut,IF9999.CFX,'2','1',1,5033.3999,U,0,strategy,2021-01-11 14:34:00) 
    操作时间 2021-01-11 14:34:00 price: 5033.4 cross: 5139.266438802083 ,through: 5040.100341796875 持仓: 0 , rs: -113 ,cash: 515399.74199999997 卖空
    2023-05-26 11:20:03.280782 handle_order_submit process req check position failed for order_req:OrderReq(bktfut,IF9999.CFX,'2','1',1,5035.6,U,0,strategy,2021-01-11 14:35:00) 
    操作时间 2021-01-11 14:35:00 price: 5035.6 cross: 5139.266438802083 ,through: 5040.100341796875 持仓: 0 , rs: -113 ,cash: 515399.74199999997 卖空
    2023-05-26 11:20:03.308129 handle_order_submit process req check position failed for order_req:OrderReq(bktfut,IF9999.CFX,'2','1',1,5033.0,U,0,strategy,2021-01-11 14:36:00) 
    操作时间 2021-01-11 14:36:00 price: 5033.0 cross: 5139.266438802083 ,through: 5040.100341796875 持仓: 0 , rs: -113 ,cash: 515399.74199999997 卖空
    2023-05-26 11:20:03.335718 handle_order_submit process req check position failed for order_req:OrderReq(bktfut,IF9999.CFX,'2','1',1,5038.6,U,0,strategy,2021-01-11 14:37:00) 
    操作时间 2021-01-11 14:37:00 price: 5038.6 cross: 5139.266438802083 ,through: 5040.100341796875 持仓: 0 , rs: -113 ,cash: 515399.74199999997 卖空
    2023-05-26 11:20:03.361763 handle_order_submit process req check position failed for order_req:OrderReq(bktfut,IF9999.CFX,'2','1',1,5037.3999,U,0,strategy,2021-01-11 14:38:00) 
    操作时间 2021-01-11 14:38:00 price: 5037.4 cross: 5139.266438802083 ,through: 5040.100341796875 持仓: 0 , rs: -113 ,cash: 515399.74199999997 卖空
    2023-05-26 11:20:03.391452 handle_order_submit process req check position failed for order_req:OrderReq(bktfut,IF9999.CFX,'2','1',1,5033.7998,U,0,strategy,2021-01-11 14:39:00) 
    操作时间 2021-01-11 14:39:00 price: 5033.8 cross: 5139.266438802083 ,through: 5040.100341796875 持仓: 0 , rs: -113 ,cash: 515399.74199999997 卖空
    2023-05-26 11:20:03.419778 handle_order_submit process req check position failed for order_req:OrderReq(bktfut,IF9999.CFX,'2','1',1,5031.3999,U,0,strategy,2021-01-11 14:40:00) 
    操作时间 2021-01-11 14:40:00 price: 5031.4 cross: 5139.266438802083 ,through: 5040.100341796875 持仓: 0 , rs: -113 ,cash: 515399.74199999997 卖空
    2023-05-26 11:20:03.446504 handle_order_submit process req check position failed for order_req:OrderReq(bktfut,IF9999.CFX,'2','1',1,5035.0,U,0,strategy,2021-01-11 14:41:00) 
    操作时间 2021-01-11 14:41:00 price: 5035.0 cross: 5139.266438802083 ,through: 5040.100341796875 持仓: 0 , rs: -113 ,cash: 515399.74199999997 卖空
    2023-05-26 11:20:03.472147 handle_order_submit process req check position failed for order_req:OrderReq(bktfut,IF9999.CFX,'2','1',1,5033.0,U,0,strategy,2021-01-11 14:42:00) 
    操作时间 2021-01-11 14:42:00 price: 5033.0 cross: 5139.266438802083 ,through: 5040.100341796875 持仓: 0 , rs: -113 ,cash: 515399.74199999997 卖空
    2023-05-26 11:20:03.496600 handle_order_submit process req check position failed for order_req:OrderReq(bktfut,IF9999.CFX,'2','1',1,5026.7998,U,0,strategy,2021-01-11 14:43:00) 
    操作时间 2021-01-11 14:43:00 price: 5026.8 cross: 5139.266438802083 ,through: 5040.100341796875 持仓: 0 , rs: -113 ,cash: 515399.74199999997 卖空
    2023-05-26 11:20:03.523289 handle_order_submit process req check position failed for order_req:OrderReq(bktfut,IF9999.CFX,'2','1',1,5032.6,U,0,strategy,2021-01-11 14:44:00) 
    操作时间 2021-01-11 14:44:00 price: 5032.6 cross: 5139.266438802083 ,through: 5040.100341796875 持仓: 0 , rs: -113 ,cash: 515399.74199999997 卖空
    2023-05-26 11:20:03.547475 handle_order_submit process req check position failed for order_req:OrderReq(bktfut,IF9999.CFX,'2','1',1,5030.0,U,0,strategy,2021-01-11 14:45:00) 
    操作时间 2021-01-11 14:45:00 price: 5030.0 cross: 5139.266438802083 ,through: 5040.100341796875 持仓: 0 , rs: -113 ,cash: 515399.74199999997 卖空
    2023-05-26 11:20:03.573807 handle_order_submit process req check position failed for order_req:OrderReq(bktfut,IF9999.CFX,'2','1',1,5035.2001,U,0,strategy,2021-01-11 14:46:00) 
    操作时间 2021-01-11 14:46:00 price: 5035.2 cross: 5139.266438802083 ,through: 5040.100341796875 持仓: 0 , rs: -113 ,cash: 515399.74199999997 卖空
    2023-05-26 11:20:03.603008 handle_order_submit process req check position failed for order_req:OrderReq(bktfut,IF9999.CFX,'2','1',1,5033.6,U,0,strategy,2021-01-11 14:47:00) 
    操作时间 2021-01-11 14:47:00 price: 5033.6 cross: 5139.266438802083 ,through: 5040.100341796875 持仓: 0 , rs: -113 ,cash: 515399.74199999997 卖空
    2023-05-26 11:20:03.629347 handle_order_submit process req check position failed for order_req:OrderReq(bktfut,IF9999.CFX,'2','1',1,5035.3999,U,0,strategy,2021-01-11 14:48:00) 
    操作时间 2021-01-11 14:48:00 price: 5035.4 cross: 5139.266438802083 ,through: 5040.100341796875 持仓: 0 , rs: -113 ,cash: 515399.74199999997 卖空
    2023-05-26 11:20:03.655381 handle_order_submit process req check position failed for order_req:OrderReq(bktfut,IF9999.CFX,'2','1',1,5032.2001,U,0,strategy,2021-01-11 14:49:00) 
    操作时间 2021-01-11 14:49:00 price: 5032.2 cross: 5139.266438802083 ,through: 5040.100341796875 持仓: 0 , rs: -113 ,cash: 515399.74199999997 卖空
    2023-05-26 11:20:03.683486 handle_order_submit process req check position failed for order_req:OrderReq(bktfut,IF9999.CFX,'2','1',1,5033.2001,U,0,strategy,2021-01-11 14:50:00) 
    操作时间 2021-01-11 14:50:00 price: 5033.2 cross: 5139.266438802083 ,through: 5040.100341796875 持仓: 0 , rs: -113 ,cash: 515399.74199999997 卖空
    2023-05-26 11:20:03.711554 handle_order_submit process req check position failed for order_req:OrderReq(bktfut,IF9999.CFX,'2','1',1,5027.3999,U,0,strategy,2021-01-11 14:51:00) 
    操作时间 2021-01-11 14:51:00 price: 5027.4 cross: 5139.266438802083 ,through: 5040.100341796875 持仓: 0 , rs: -113 ,cash: 515399.74199999997 卖空
    2023-05-26 11:20:03.737824 handle_order_submit process req check position failed for order_req:OrderReq(bktfut,IF9999.CFX,'2','1',1,5027.2001,U,0,strategy,2021-01-11 14:52:00) 
    操作时间 2021-01-11 14:52:00 price: 5027.2 cross: 5139.266438802083 ,through: 5040.100341796875 持仓: 0 , rs: -113 ,cash: 515399.74199999997 卖空
    2023-05-26 11:20:03.765247 handle_order_submit process req check position failed for order_req:OrderReq(bktfut,IF9999.CFX,'2','1',1,5025.7998,U,0,strategy,2021-01-11 14:53:00) 
    操作时间 2021-01-11 14:53:00 price: 5025.8 cross: 5139.266438802083 ,through: 5040.100341796875 持仓: 0 , rs: -113 ,cash: 515399.74199999997 卖空
    2023-05-26 11:20:03.802352 handle_order_submit process req check position failed for order_req:OrderReq(bktfut,IF9999.CFX,'2','1',1,5022.2001,U,0,strategy,2021-01-11 14:54:00) 
    操作时间 2021-01-11 14:54:00 price: 5022.2 cross: 5139.266438802083 ,through: 5040.100341796875 持仓: 0 , rs: -113 ,cash: 515399.74199999997 卖空
    操作时间 2021-01-12 11:07:00 price: 5077.6 cross: 5077.199544270833 ,through: 4985.5 持仓: 0 , rs: 0 ,cash: 515399.74199999997 买多
    操作时间 2021-01-12 14:55:00 price: 5158.0 持仓: 1 , rs: 0 尾盘多头平仓
    
    ---------------------------------------------------------------------------
    KeyboardInterrupt                         Traceback (most recent call last)
    <ipython-input-4-704745456850> in <module>
        190 )
        191 
    --> 192 m7 = M.hftrade.v2(
        193     instruments=m4.data,
        194     options_data=m2.data,
    
    <ipython-input-4-704745456850> in m7_handle_data_bigquant_run(context, data)
         53 # 回测引擎:每日数据处理函数,每天执行一次
         54 def m7_handle_data_bigquant_run(context, data):
    ---> 55     df = context.options['data'].read_df()
         56     # 当前时间
         57     today = data.current_dt.strftime('%Y-%m-%d')
    
    KeyboardInterrupt: