Hi,
Been trying to use earnings stability (standard deviation of eps) across the past 5 years as an input for factor investing algo. Would appreciate it if anyone has an idea on how to do it. I have attached my attempt at it.
class Earnings_Stability(CustomFactor):
inputs = [earnings_report.normalized_basic_eps, USEquityPricing.close, valuation.shares_outstanding]
window_length = 252*5 # yearly earnings to prevent seasonal adjustment
def compute(self, today, assets, out, eps, close, shares):
out[:] = np.nanstd(np.diff(eps, axis=0), axis = 0)
Thanks,
J