Quantopian's community platform is shutting down. Please read this post for more information and download your code.
Back to Community
A filter "isnan() and notnan()" returns items.

I'm starting with optimize and get errors in MaximizeAlpha(context.output['factor']):
ValueError: NaN values provided to MaximizeAlpha for argument 'alphas'.

Then I add a filter to the pipeline screen:
... and factor.notnan() or this filter:
... and ~factor.isnan() In both cases the error remains.

Then I experiment with a filter factor.notnan() and ~factor.notnan()
And this returns values! With different floats as factor.

What am I doing wrong?

3 responses

I mean I would expect (x.notnan() and x.isnan()) to return no entries as those filters seem mutually exclusive.

Maybe this is the problem? One cannot use the keywords 'and' 'or'. Instead use the symbols '&' '|'. See the documentation at https://www.quantopian.com/help#quantopian_pipeline_filters_Filter . Try this

factor.notnan() & ~factor.notnan()

Notice the '&' symbol.

Cannot believe I made such a stupid mistake. Thank you Dan.