Quantopian's community platform is shutting down. Please read this post for more information and download your code.
Back to Community
Does this (or any) CustomFactor avoid look-ahead bias?

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?

2 responses

Quantopian puts a lot of effort in to ensure there’s no look ahead bias or data snooping in the data that you can access in the IDE.

This thread might help explain. Jamie ‘s notebook close to the end also includes a LastFourQuarters custom factor which looks similar to yours.

Thanks for the response, i'll investigate the links.