Quantopian's community platform is shutting down. Please read this post for more information and download your code.
Back to Community
Yet another NonWindowSafeInput Error

Ladies and gentlemen,

I've got 2 custom factors:
One called 'cluster' combines the industry and the style. It works fine for me.
The other one picks the output of the first one and returns it with no changes. And it fails with NonWindowSafeInput.

How can I overcome this error?

P.S. groupby wouldn't solve the issue as this is yet another pairs trading and I need pairwise cointegration tests inside the clusters.
I've already tested this king of algorithm however the logic was outside pipeline. Now I want to have it in custom factors.

3 responses

From here about using factors as input of other factors:

"[...] is now allowed for a select few factors deemed safe for use as inputs. This includes Returns and any factors created from rank or zscore. The main reason that these factors can be used as inputs is that they are comparable across splits. Returns, rank and zscore produce normalized values, meaning that they can be meaningfully compared in any context."

To fix any other factor not already covered by the scenarios described above add window_safe = True to your factor class like this:

cluster.window_safe = True  

or

class cluster(CustomFactor):  
    window_safe = True  
     [...]  

Also, Q could improve the current behavior and avoid raising a NonWindowSafeInput when a factor that has window_length=1 receives "non safe" factors in input, because with window_length=1 there is no need to worry about splits/merges.

Thank you Luca, that's an easy solution I hoped for.