S&P500 filter

Is there a way to select the stocks in the s&P 500 in the function is_symbol_qualified ? Otherwise is there another way to do that?

Best Answer

  • jh909952jh909952 Posts: 5
    edited July 2019 Answer ✓

    I believe you need to use the S&P500 GUID, although I haven't used it yet. Here is the code straight from the documentation:

    returning only those symbols that are in the S&P500 and between $2 and $500 with an average volume of over 100,000.

    @classmethod
    def is_symbol_qualified(cls, symbol, md, service, account):
        SP500guid = '9a802d98-a2d7-4326-af64-cea18f8b5d61'
        # This combination of service calls returns a 1 if the current symbol is in the specified list, a zero if it is not
        SP500 = service.symbol_list.in_list(service.symbol_list.get_handle(SP500guid),symbol)
        return SP500 and md.stat.prev_close>2 and md.stat.prev_close<500 and md.stat.avol>100000
Sign In or Register to comment.