We're proud to announce that we now support Morningstar Sector, Industry Group, and Industry codes! Sector, Industry Group, and Industry codes sort stocks based on their general market classification, with Sector being the coarsest classification (i.e, Energy) and Industry the finest-grained classification (i.e., Oil and Gas Drilling, Oil and Gas Midstream, etc.). This classification information is part of the Fundamental Data library and can be accessed like any other Fundamental Data in an algorithm.

To demonstrate these new features, we've created a Universe Selection module that returns exclusively Symbols in the banking industry. The Coarse Selection does our initial filtering for stocks with Fundamental Data and positive volume and price. The Morningstar industry filtering is done in the Fine Selection function using MorningstarIndustryGroupCode.Banks (which is equivalent to 10320, and the full list of codes can be found here). Our final list of Symbols will be banking stocks with positive trading volume and price, sorted in descending order of liquidity.

Morningstar Industry/Sector codes and other asset classification helpers are available as part of our Fundamental Data Library, and you can view the code for this and check out the other features on GitHub here. We've attached a backtest that gives a simple demonstration of how you can incorporate our new Fundamental Data features into your code and use our new Universe Selection module -- Banking Stocks!

def SelectCoarse(self, algorithm, coarse):
'''
Performs a coarse selection:

-The stock must have fundamental data
-The stock must have positive previous-day close price
-The stock must have positive volume on the previous trading day
'''
if algorithm.Time.month == self.lastMonth:
return self.symbols

filtered = [x for x in coarse if x.HasFundamentalData and x.Volume > 0 and x.Price > 0]
sortedByDollarVolume = sorted(filtered, key = lambda x: x.DollarVolume, reverse=True)[:self.numberOfSymbolsCoarse]

self.symbols.clear()
self.dollarVolumeBySymbol.clear()
for x in sortedByDollarVolume:
self.symbols.append(x.Symbol)
self.dollarVolumeBySymbol[x.Symbol] = x.DollarVolume

return self.symbols

def SelectFine(self, algorithm, fine):

## Performs a fine selection for companies in the Morningstar Banking Sector
if algorithm.Time.month == self.lastMonth:
return self.symbols
self.lastMonth = algorithm.Time.month

# Filter for banking stocks using MorningstarIndustryGroupCode.Banks (equivalently, this is 10320)
filteredFine = [x for x in fine if x.AssetClassification.MorningstarIndustryGroupCode == MorningstarIndustryGroupCode.Banks]

sortedByDollarVolume = []

# Sort stocks on dollar volume
sortedByDollarVolume = sorted(filteredFine, key = lambda x: self.dollarVolumeBySymbol[x.Symbol], reverse=True)

self.symbols = [x.Symbol for x in sortedByDollarVolume[:self.numberOfSymbolsFine]]

return self.symbols