Thanks Pravin -
Why are you interested in leverage? Or did you just pick it arbitrarily as an example?
Also, I'd consider if this code handles splits point-in-time properly (I'd be worried that the pricing data aren't aligned in time with the shares_outstanding):
class MarketCap(CustomFactor):
inputs = [USEquityPricing.close, morningstar.valuation.shares_outstanding]
window_length = 1
def compute(self, today, assets, out, close, shares):
out[:] = close[-1] * shares[-1]
I simply use:
market_cap = mstar.valuation.market_cap.latest