I am trying to write a custom factor to calculate the trailing 12 months eps using the following code:
class EPS(CustomFactor):
inputs = [USEquityPricing.close, mstar.earnings_report.basic_continuous_operations]
window_length = 3
def compute(self, today, assets, out,close,eps):
out[:] = np.sum(eps, axis=0)
I am expecting this code to sum the last 4 quarters eps from morningstar but it seems to take the latest eps and multiplies it by 4. What am I doing wrong?