I hired a programmer to code this factor for me to sum the TTM for fundamental data points (I am using Morningstar data):
class SumLastFourQuarters(CustomFactor):
window_length = 195 + 65
def compute(self, today, assets, out, asof_date, values):
for column_ix in range(asof_date.shape[1]):
_, unique_indices = np.unique(asof_date[:, column_ix], return_index=True)
quarterly_values = values[unique_indices, column_ix]
if len(quarterly_values) < 4:
quarterly_values = np.hstack([
np.repeat([np.nan], 4 - len(quarterly_values)),
quarterly_values,
])
quarterly_values = quarterly_values[-4:]
out[column_ix] = quarterly_values.sum()
I have very limited knowledge of the Quantopian platform. When running a backtest, does this factor avoid look-ahead bias that would be introduced by the reporting lag in fundamental data? IE - does it use "point in time" data? Or maybe the platform does not allow look-ahead bias?