Quantopian's community platform is shutting down. Please read this post for more information and download your code.
Back to Community
How To Find Sector Group Averages?

Hello All,

I have been spending some time recently working with fundamentals. I know you are able to find overall sector averages by using:

from quantopian.pipeline.data import morningstar  
from quantopian.pipeline.classifiers.morningstar import Sector

pe_ratio = morningstar.valuation_ratios.pe_ratio.latest

sector_pe_ratio_avg = pe_ratio -pe_ratio.demean(groupby=Sector())

Then by adding a sector filter to the screen of the pipeline, I am able to find the averages of whatever fundamental that is specified for whatever sector that is specified.

My question is, is there a way to find the averages of the sector groups?

Morningstar fundamentals use Sectors and Sector Groups. The groups are like more refined sectors. Using the code posted above I am able to get the averages of whatever fundamental for every overall sector, but if I wanted to refine it by trying to find the sector group averages how would I go about doing that?

I appreciate any and all assistance!