复制链接
克隆策略

    {"description":"实验创建于2018/10/16","graph":{"edges":[{"to_node_id":"-43:instruments","from_node_id":"-1483:data_1"},{"to_node_id":"-43:options_data","from_node_id":"-1483:data_2"}],"nodes":[{"node_id":"-1483","module_id":"BigQuantSpace.cached.cached-v3","parameters":[{"name":"run","value":"# Python 代码入口函数,input_1/2/3 对应三个输入端,data_1/2/3 对应三个输出端\ndef bigquant_run(input_1, input_2, input_3,before_days):\n tmp = DataSource('dominant_CN_FUTURE').read()\n \n future_ins = list(set(tmp['instrument']))\n commodity_ins = [i for i in future_ins if not i.endswith('CFE')]\n contracts = tmp.dominant.unique().tolist()\n\n fields=['open','high','low','close','volume','open_intl']\n start_date= '2022-01-01'\n end_date = '2022-08-24'\n price_df = DataSource('bar1d_CN_FUTURE').read(commodity_ins,start_date,end_date,fields)\n price_df['adjust_factor']=1.0\n \n ds3 = DataSource.write_df(price_df)\n\n ds1 = DataSource.write_pickle({'start_date':start_date, 'end_date':end_date, 'instruments':contracts})\n\n def caclu(df):\n length = 1\n df['mom'] = df['open'] / df['open'].shift(length) - 1\n df['roll_open_intl'] = df['open_intl'].rolling(22).mean()\n return df \n mom_df = price_df.groupby('instrument').apply(caclu)\n mom_df = mom_df[mom_df['roll_open_intl']>=100000]\n \n symbol_nums = 5\n winners = mom_df.groupby('date').apply(lambda x:x.dropna().sort_values('mom', ascending=False)['instrument'][:symbol_nums].tolist())\n losers = mom_df.groupby('date').apply(lambda x:x.dropna().sort_values('mom', ascending=False)['instrument'][-1*symbol_nums:].tolist())\n\n ds2 = DataSource.write_pickle({'winners':winners, 'losers':losers})\n \n return Outputs(data_1=ds1, data_2=ds2)\n","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":"{'before_days':1}","type":"Literal","bound_global_parameter":null},{"name":"output_ports","value":"","type":"Literal","bound_global_parameter":null}],"input_ports":[{"name":"input_1","node_id":"-1483"},{"name":"input_2","node_id":"-1483"},{"name":"input_3","node_id":"-1483"}],"output_ports":[{"name":"data_1","node_id":"-1483"},{"name":"data_2","node_id":"-1483"},{"name":"data_3","node_id":"-1483"}],"cacheable":true,"seq_num":4,"comment":"","comment_collapsed":true},{"node_id":"-43","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 print(\"initialize\") \n\n context.today_open = 0 #当天开盘价\n context.closetime_day = \"14:58\"#日内策略白盘平仓时间,一般14:58\n context.closetime_night = \"22:58\"#日内策略夜盘平仓时间,一般22:58,注意有些商品夜盘收盘时间不一样\n \n import re\n # 设置是否是结算模式\n # context.set_need_settle(False)\n # 设置最大杠杆\n context.strategy_leverage = 3\n # context.set_max_leverage(1, 'fill_amap')\n outer_data = context.options['data'].read_pickle()\n context.winners = outer_data['winners']\n context.losers = outer_data['losers']\n context.rebalance_days = 1\n# if 'index' not in context.extension:\n# context.extension['index'] = 0 \n \n context.dom = DataSource('dominant_CN_FUTURE').read() ","type":"Literal","bound_global_parameter":null},{"name":"before_trading_start","value":"# 交易引擎:每个单位时间开盘前调用一次。\ndef bigquant_run(context, data):\n context.flag = 1 #用于获取今开\n # 盘前处理,订阅行情等\n \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":"# 交易引擎:bar数据处理函数,每个时间单位执行一次\ndef bigquant_run(context, data):\n if context.flag == 1 :\n# history_data = data.history(context.ins, [\"open\"], 1, \"1m\")\n# context.today_open = history_data.iloc[-1]['open'] \n context.flag += 1\n import re\n today = data.current_dt.strftime('%Y-%m-%d') # 当前交易日期\n\n# context.extension['index'] += 1\n\n # 整理赢者和输者\n try:\n winners = context.winners[today]\n losers = context.losers[today]\n\n except KeyError as e:\n return \n\n # 通过positions对象,使用列表生成式的方法获取目前持仓的股票列表\n contract_hold_now = [equity.symbol for equity in context.portfolio.positions]\n\n\n # if context.extension['index'] % context.rebalance_days != 0: # 调仓日不需要换合约\n # #if True:\n # for old_contract in contract_hold_now:\n # dom_contract = ''.join(re.findall(r'[A-Za-z]', old_contract.split('.')[0])) +'8888'+'.'+ old_contract.split('.')[1]\n\n # try:\n # new_contract = context.dom[(context.dom['instrument'] == dom_contract) & (context.dom['date']==today)]['dominant'].tolist()[0]\n # except IndexError as e:\n\n # continue\n # # 如果出现换月的情形,就移仓换月(先平 后开)\n # if old_contract != new_contract:\n\n # new_sid = context.future_symbol(new_contract)\n # sid = context.future_symbol(old_contract)\n # hold_amount = context.portfolio.positions[sid]['amount']\n\n # if data.can_trade(sid) and data.can_trade(new_sid) and hold_amount >0: # 卖平 再买开\n # # Long\n # context.order(sid, -1 * (hold_amount), position_effect='close')\n # context.order(new_sid, 1 * (hold_amount), position_effect='open')\n # print(today, '出现移仓换月!','当前持仓是多头!', '旧合约:',old_contract, '新合约:',new_contract,'当前持仓', hold_amount)\n\n # elif data.can_trade(sid) and data.can_trade(new_sid) and hold_amount <0: # 买平 再卖开\n # # Short\n # context.order(sid, -1 * (hold_amount), position_effect='close')\n # context.order(new_sid, 1 * (hold_amount), position_effect='open')\n # print(today, '出现移仓换月!','当前持仓是空头!', '旧合约:',old_contract, '新合约:',new_contract,'当前持仓', hold_amount)\n\n\n\n # # 不在换仓日就return,相当于后面的代码只会一个月运行一次,买入的股票会持有1个月\n # if context.extension['index'] % context.rebalance_days != 0:\n # return \n\n print(today, 'winners:',winners ,'losers:',losers)\n\n # 月初换仓第一步\n for old_contract in contract_hold_now:\n sid = context.future_symbol(old_contract )\n hold_amount = context.portfolio.positions[sid]['amount'] \n\n if data.can_trade(sid) and hold_amount >0: # 卖平\n context.order(sid, -1 * (hold_amount), position_effect='close')\n # context.order(sid, 0, position_effect='target')\n\n print(today,'_-_-'*3,'月初多仓进行平仓!', '合约',old_contract, '手数', hold_amount)\n\n elif data.can_trade(sid) and hold_amount <0: # 买平 \n\n context.order(sid, -1 * (hold_amount), position_effect='close')\n # context.order(sid, 0, position_effect='target')\n\n print(today,'____'*3,'月初空仓进行平仓!', '合约',old_contract, '手数', hold_amount)\n\n\n # if len(winners)+len(losers) <=5:\n # return \n\n # 等权重分配仓位\n weight = 1 / (len(winners)+len(losers))\n\n portfolio_value = context.portfolio.portfolio_value\n book_value = portfolio_value * context.strategy_leverage * weight\n\n # 月初换仓第二步\n for domin_contract in winners: # ['RB8888.SHF']\n future_variety = ''.join(re.findall(r'[A-Za-z]', domin_contract.split('.')[0])) # RB\n try:\n contract = context.dom[(context.dom['instrument'] == domin_contract ) & (context.dom['date']==today)]['dominant'].tolist()[0] # RB1901.SHF\n except IndexError as e:\n continue \n sid =context.future_symbol(contract)\n\n if data.can_trade(sid):\n# unit = context.get_multiplier(future_variety)\n unit = context.get_contract(future_variety).multiplier\n print(sid)\n print(data)\n\n print(data.current(sid,'open') )\n\n price = data.current(sid, 'price') \n lots = math.floor(book_value/(unit*price))\n if lots <= 0:\n continue\n context.order(sid, lots, position_effect='open')\n print(today,'____'*3,'月初建多仓!', '合约',contract, '手数',lots)\n\n for domin_contract in losers:\n future_variety = ''.join(re.findall(r'[A-Za-z]', domin_contract.split('.')[0])) # RB\n try:\n contract = context.dom[(context.dom['instrument'] == domin_contract ) & (context.dom['date']==today)]['dominant'].tolist()[0] # RB1901.SHF\n except IndexError as e:\n continue \n sid =context.future_symbol(contract)\n\n if data.can_trade(sid):\n# unit = context.get_multiplier(future_variety)\n unit = context.get_contract(future_variety).multiplier\n \n print(sid)\n print(data)\n\n print(data.current(sid,'open') )\n\n price = data.current(sid,'price') \n lots = math.floor(book_value/(unit*price))\n if lots <= 0:\n continue\n context.order(sid, -1*lots, position_effect='open')\n print(today,'____'*3,'月初建空仓!', '合约',contract, '手数',-1*lots)\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":1000000,"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":"False","type":"Literal","bound_global_parameter":null},{"name":"backtest_only","value":"False","type":"Literal","bound_global_parameter":null}],"input_ports":[{"name":"instruments","node_id":"-43"},{"name":"options_data","node_id":"-43"},{"name":"history_ds","node_id":"-43"},{"name":"benchmark_ds","node_id":"-43"}],"output_ports":[{"name":"raw_perf","node_id":"-43"}],"cacheable":false,"seq_num":1,"comment":"","comment_collapsed":true}],"node_layout":"<node_postions><node_position Node='-1483' Position='90,-100,200,200'/><node_position Node='-43' Position='359.8341979980469,217.12115478515625,200,200'/></node_postions>"},"nodes_readonly":false,"studio_version":"v2"}
    In [44]:
    # 本代码由可视化策略环境自动生成 2022年8月25日 23:29
    # 本代码单元只能在可视化模式下编辑。您也可以拷贝代码,粘贴到新建的代码单元或者策略,然后修改。
    
    
    # Python 代码入口函数,input_1/2/3 对应三个输入端,data_1/2/3 对应三个输出端
    def m4_run_bigquant_run(input_1, input_2, input_3,before_days):
        tmp = DataSource('dominant_CN_FUTURE').read()
       
        future_ins = list(set(tmp['instrument']))
        commodity_ins =  [i for i in future_ins if  not i.endswith('CFE')]
        contracts = tmp.dominant.unique().tolist()
    
        fields=['open','high','low','close','volume','open_intl']
        start_date= '2022-01-01'
        end_date = '2022-08-24'
        price_df = DataSource('bar1d_CN_FUTURE').read(commodity_ins,start_date,end_date,fields)
        price_df['adjust_factor']=1.0
        
        ds3 = DataSource.write_df(price_df)
    
        ds1 = DataSource.write_pickle({'start_date':start_date, 'end_date':end_date, 'instruments':contracts})
    
        def caclu(df):
            length = 1
            df['mom'] = df['open'] / df['open'].shift(length) - 1
            df['roll_open_intl'] = df['open_intl'].rolling(22).mean()
            return df 
        mom_df  = price_df.groupby('instrument').apply(caclu)
        mom_df = mom_df[mom_df['roll_open_intl']>=100000]
        
        symbol_nums = 5
        winners = mom_df.groupby('date').apply(lambda x:x.dropna().sort_values('mom', ascending=False)['instrument'][:symbol_nums].tolist())
        losers = mom_df.groupby('date').apply(lambda x:x.dropna().sort_values('mom', ascending=False)['instrument'][-1*symbol_nums:].tolist())
    
        ds2 = DataSource.write_pickle({'winners':winners, 'losers':losers})
         
        return Outputs(data_1=ds1, data_2=ds2)
    
    # 后处理函数,可选。输入是主函数的输出,可以在这里对数据做处理,或者返回更友好的outputs数据格式。此函数输出不会被缓存。
    def m4_post_run_bigquant_run(outputs):
        return outputs
    
    # 交易引擎:初始化函数,只执行一次
    def m1_initialize_bigquant_run(context):
        # 加载预测数据
        print("initialize")  
    
        context.today_open = 0 #当天开盘价
        context.closetime_day = "14:58"#日内策略白盘平仓时间,一般14:58
        context.closetime_night = "22:58"#日内策略夜盘平仓时间,一般22:58,注意有些商品夜盘收盘时间不一样
        
        import re
        # 设置是否是结算模式
        # context.set_need_settle(False)
        # 设置最大杠杆
        context.strategy_leverage = 3
        # context.set_max_leverage(1, 'fill_amap')
        outer_data = context.options['data'].read_pickle()
        context.winners = outer_data['winners']
        context.losers = outer_data['losers']
        context.rebalance_days = 1
    #     if 'index' not in context.extension:
    #         context.extension['index'] = 0 
            
        context.dom = DataSource('dominant_CN_FUTURE').read() 
    # 交易引擎:每个单位时间开盘前调用一次。
    def m1_before_trading_start_bigquant_run(context, data):
        context.flag = 1 #用于获取今开
        # 盘前处理,订阅行情等
        
    
    # 交易引擎:tick数据处理函数,每个tick执行一次
    def m1_handle_tick_bigquant_run(context, tick):
        pass
    
    # 交易引擎:bar数据处理函数,每个时间单位执行一次
    def m1_handle_data_bigquant_run(context, data):
        if context.flag == 1 :
    #         history_data = data.history(context.ins, ["open"], 1, "1m")
    #         context.today_open = history_data.iloc[-1]['open'] 
            context.flag += 1
            import re
            today = data.current_dt.strftime('%Y-%m-%d') # 当前交易日期
    
    #         context.extension['index'] += 1
    
            # 整理赢者和输者
            try:
                winners = context.winners[today]
                losers = context.losers[today]
    
            except KeyError as e:
                return 
    
            # 通过positions对象,使用列表生成式的方法获取目前持仓的股票列表
            contract_hold_now = [equity.symbol for equity in context.portfolio.positions]
    
    
        #     if  context.extension['index'] % context.rebalance_days != 0:  # 调仓日不需要换合约
        #     #if True:
        #         for old_contract  in contract_hold_now:
        #             dom_contract = ''.join(re.findall(r'[A-Za-z]',  old_contract.split('.')[0])) +'8888'+'.'+ old_contract.split('.')[1]
    
        #             try:
        #                 new_contract = context.dom[(context.dom['instrument'] ==  dom_contract) & (context.dom['date']==today)]['dominant'].tolist()[0]
        #             except IndexError as e:
    
        #                 continue
        #             # 如果出现换月的情形,就移仓换月(先平 后开)
        #             if old_contract != new_contract:
    
        #                 new_sid = context.future_symbol(new_contract)
        #                 sid = context.future_symbol(old_contract)
        #                 hold_amount = context.portfolio.positions[sid]['amount']
    
        #                 if data.can_trade(sid) and data.can_trade(new_sid) and  hold_amount >0:  # 卖平 再买开
        #                     # Long
        #                     context.order(sid, -1 * (hold_amount), position_effect='close')
        #                     context.order(new_sid, 1 * (hold_amount), position_effect='open')
        #                     print(today, '出现移仓换月!','当前持仓是多头!', '旧合约:',old_contract, '新合约:',new_contract,'当前持仓', hold_amount)
    
        #                 elif data.can_trade(sid)  and data.can_trade(new_sid) and hold_amount <0: # 买平 再卖开
        #                     # Short
        #                     context.order(sid, -1 * (hold_amount), position_effect='close')
        #                     context.order(new_sid, 1 * (hold_amount), position_effect='open')
        #                     print(today, '出现移仓换月!','当前持仓是空头!', '旧合约:',old_contract, '新合约:',new_contract,'当前持仓', hold_amount)
    
    
    
        #     # 不在换仓日就return,相当于后面的代码只会一个月运行一次,买入的股票会持有1个月
        #     if  context.extension['index'] % context.rebalance_days != 0:
        #         return 
    
            print(today, 'winners:',winners ,'losers:',losers)
    
            # 月初换仓第一步
            for old_contract  in contract_hold_now:
                sid = context.future_symbol(old_contract )
                hold_amount = context.portfolio.positions[sid]['amount']    
    
                if data.can_trade(sid) and hold_amount >0: # 卖平
                    context.order(sid, -1 * (hold_amount), position_effect='close')
        #             context.order(sid, 0, position_effect='target')
    
                    print(today,'_-_-'*3,'月初多仓进行平仓!', '合约',old_contract, '手数', hold_amount)
    
                elif data.can_trade(sid) and hold_amount <0: # 买平 
    
                    context.order(sid, -1 * (hold_amount), position_effect='close')
        #             context.order(sid, 0, position_effect='target')
    
                    print(today,'____'*3,'月初空仓进行平仓!', '合约',old_contract, '手数', hold_amount)
    
    
        #     if len(winners)+len(losers) <=5:
        #         return 
    
            # 等权重分配仓位
            weight =  1 / (len(winners)+len(losers))
    
            portfolio_value = context.portfolio.portfolio_value
            book_value = portfolio_value * context.strategy_leverage  * weight
    
            # 月初换仓第二步
            for domin_contract in winners:  # ['RB8888.SHF']
                future_variety = ''.join(re.findall(r'[A-Za-z]', domin_contract.split('.')[0]))  # RB
                try:
                     contract = context.dom[(context.dom['instrument'] == domin_contract ) & (context.dom['date']==today)]['dominant'].tolist()[0] # RB1901.SHF
                except IndexError as e:
                    continue 
                sid =context.future_symbol(contract)
    
                if data.can_trade(sid):
    #                 unit = context.get_multiplier(future_variety)
                    unit = context.get_contract(future_variety).multiplier
                    print(sid)
                    print(data)
    
                    print(data.current(sid,'open') )
    
                    price = data.current(sid, 'price') 
                    lots = math.floor(book_value/(unit*price))
                    if lots <= 0:
                        continue
                    context.order(sid, lots, position_effect='open')
                    print(today,'____'*3,'月初建多仓!', '合约',contract, '手数',lots)
    
            for domin_contract in losers:
                future_variety = ''.join(re.findall(r'[A-Za-z]', domin_contract.split('.')[0]))  # RB
                try:
                    contract = context.dom[(context.dom['instrument'] == domin_contract ) & (context.dom['date']==today)]['dominant'].tolist()[0] # RB1901.SHF
                except IndexError as e:
                    continue 
                sid =context.future_symbol(contract)
    
                if data.can_trade(sid):
    #                 unit = context.get_multiplier(future_variety)
                    unit = context.get_contract(future_variety).multiplier
            
                    print(sid)
                    print(data)
    
                    print(data.current(sid,'open') )
    
                    price = data.current(sid,'price') 
                    lots = math.floor(book_value/(unit*price))
                    if lots <= 0:
                        continue
                    context.order(sid, -1*lots, position_effect='open')
                    print(today,'____'*3,'月初建空仓!', '合约',contract, '手数',-1*lots)
    
    
    
    # 交易引擎:成交回报处理函数,每个成交发生时执行一次
    def m1_handle_trade_bigquant_run(context, trade):
        pass
    
    # 交易引擎:委托回报处理函数,每个委托变化时执行一次
    def m1_handle_order_bigquant_run(context, order):
        pass
    
    # 交易引擎:盘后处理函数,每日盘后执行一次
    def m1_after_trading_bigquant_run(context, data):
        pass
    
    
    m4 = M.cached.v3(
        run=m4_run_bigquant_run,
        post_run=m4_post_run_bigquant_run,
        input_ports='',
        params='{\'before_days\':1}',
        output_ports=''
    )
    
    m1 = M.hftrade.v2(
        instruments=m4.data_1,
        options_data=m4.data_2,
        start_date='',
        end_date='',
        initialize=m1_initialize_bigquant_run,
        before_trading_start=m1_before_trading_start_bigquant_run,
        handle_tick=m1_handle_tick_bigquant_run,
        handle_data=m1_handle_data_bigquant_run,
        handle_trade=m1_handle_trade_bigquant_run,
        handle_order=m1_handle_order_bigquant_run,
        after_trading=m1_after_trading_bigquant_run,
        capital_base=1000000,
        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=False,
        backtest_only=False
    )
    
    initialize
    2022-02-09 winners: ['AL8888.SHF', 'HC8888.SHF', 'SP8888.SHF', 'C8888.DCE', 'IC8888.CFX'] losers: ['P8888.DCE', 'OI8888.CZC', 'AP8888.CZC', 'FU8888.SHF', 'PP8888.DCE']
    Future(48306 [AL2203.SHF])
    BarDatas(current_dt:2022-02-09 21:01:00)
    2022-08-25 23:27:37.527220 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 2235, in bigtrader2.bigtrader.strategy.strategy_base.StrategyBase.call_handle_data
      File "<ipython-input-44-e20e00b3bddc>", line 179, in m1_handle_data_bigquant_run
        print(data.current(sid,'open') )
      File "/var/app/enabled/bigtrader2/bigtrader/protocol.py", line 285, in current
        return self.__data_engine.get_current_value(asset, curr_dt, fields)
      File "bigtrader/mdata/engine.py", line 690, in bigtrader2.bigtrader.mdata.engine.DataEngine._get_minute_value_from_df
    AttributeError: 'NoneType' object has no attribute 'get_value'
     
    
    ---------------------------------------------------------------------------
    AttributeError                            Traceback (most recent call last)
    <ipython-input-44-e20e00b3bddc> in <module>
        233 )
        234 
    --> 235 m1 = M.hftrade.v2(
        236     instruments=m4.data_1,
        237     options_data=m4.data_2,
    
    <ipython-input-44-e20e00b3bddc> in m1_handle_data_bigquant_run(context, data)
        177                 print(data)
        178 
    --> 179                 print(data.current(sid,'open') )
        180 
        181                 price = data.current(sid, 'price')
    
    AttributeError: 'NoneType' object has no attribute 'get_value'