Hello everyone!
I'm currently working on a notebook researching the returns of REITs. I've successfully managed to isolate REITs in my pipeline using the Morningstar sector code, and I have calculated monthly returns using
percent_change_30 = Factors.Returns(inputs=[USEquityPricing.close], window_length=30, mask = our_filter)
Now I'd like to get the average monthly returns for my basket of REITs, one idea was to just get an arithmetic average return for each day. However, I'm a bit confused about how to get that and incorporate it within my pipeline.
Here is my pipeline code:
def make_pipeline():
#Our filter for REITs on NYSE and NASDAQ
group_code = asset_classification.morningstar_industry_group_code.latest
exchange = Fundamentals.exchange_id.latest
our_filter = (exchange.eq('NYS') | exchange.eq('NYSE') | exchange.eq('NAS')) & group_code.eq(10428)
#Industry code - We can use it later for more in-depth analysis
industry_code = ms.asset_classification.morningstar_industry_code.latest
#Close price
close_price = USEquityPricing.close.latest
#Monthly returns
percent_change_30 = Factors.Returns(inputs=[USEquityPricing.close], window_length=30, mask = our_filter)
return Pipeline(
columns ={
'close_price': close_price,
'group_code': group_code,
'exchange':exchange,
'monthly_returns':percent_change_30
},
#We screen for all REIT stocks
screen = our_filter
)
Any help would be greatly appreciated,
Thank you!