How to setup and use multiple symbol-list handles in is_symbol_qualified()?

I need to create an equivalent of Quantopian's context.sector_ids = [101,102,103,104,205,206,207,308,309,310,311]
- in CQ, I can make sector_ids = service.symbol_list.get_handle('GUID') , but if I put >1 GUID there, I get TypeError: get_handle() takes exactly 2 arguments (12 given)

Comments

  • Here's a working example:

    from cloudquant.interfaces import Strategy
    
    class multiple_GUID(Strategy):
    
        ########################################################################################
        #
        # high level strategy - start/finish
        #
        ########################################################################################
    
        # called when the strategy starts (aka before anything else)
        @classmethod
        def on_strategy_start(cls, md, service, account):
            pass
    
        # called when the strategy finish (aka after everything else has stopped)
        @classmethod
        def on_strategy_finish(cls, md, service, account):
            pass  
    
        @classmethod
        def is_symbol_qualified(cls, symbol, md, service, account):
            aero = 'b474a8cb-1aab-4e04-a446-65521583f48b'
            agri = '2b1a2401-b1b6-4144-abda-e1e1aa9542f0'
            clothing = '2f1619fd-c9cf-4e19-a7a3-f13925d1f759'
            banks = '2497d136-a920-4a64-8969-ea542913bddd'
            GUID_list = [aero,agri,clothing,banks]
            name_list = ['aero','agri','clothing','banks']
            handle_list = map(service.symbol_list.get_handle,GUID_list)
            for this_name,this_handle in zip(name_list,handle_list):
                if service.symbol_list.in_list(this_handle,symbol):
                    print(symbol+' in list: '+this_name)
                    return True
            return False
    
Sign In or Register to comment.