Hi everybody,
I'm quite new to quantopian and I am trying to build a custom pipeline factor that calculates the mean total revenue growth over 5 years.
But whenever I want to pass the quantopian.pipeline.data.morningstar.total_revenue.latest - Object into my factor, I get a big error : "Can't compute windowed expression MeanUniques([Latest(...)], 1275) with windowed input Latest([Fundamentals.total_revenue], 1)."
My approach was:
import numpy as np
from quantopian.pipeline import CustomFactor, Pipeline
from quantopian.research import run_pipeline
from quantopian.pipeline.data.morningstar import Fundamentals as morningstar
class MeanUniques(CustomFactor):
inputs = [morningstar.total_revenue.latest]
window_length=255*5
def compute(self, today, asset_ids, out, values): # values = 2D-Array(Size: window_length * nr_symbols)
out[:] = np.mean( np.unique(values, axis=0), axis=0) # ok this here would only calculate the 5 yr mean revenue, but understanding it would be a starting point for me... In the end I want to calculate the growth
def make_pipeline():
mean_growth = MeanUniques()
return Pipeline(columns={"growth" : mean_growth }
)
Does anybody have a better idea how to get the data of older fundamental data (that isn't "latest")? If it is possible to just read out the older data (e.g. 1 years, 2 years, 3 years ago) without needing to import all the window_length in between, would also make the computation much smaller I guess.
Unfortunately in the custom pipeline examples, there is no example utilizing fundamental data...
Thank's a lot in advance for any help, I'm kind of stuck here.