Quantopian's community platform is shutting down. Please read this post for more information and download your code.
Back to Community
Zscore producing lots of Nans?

I would like to study the book to price ratio on tech stocks. For some reason the z-score is producing a lot of nans and alphales is dropping nearly 30% of the data.

Am I doing something wrong? Thanks.

2 responses

try this:

# Make Pipeline  
def make_pipeline():

    # Create Pipeline  
    pipe = Pipeline()  
    universe = Q500US()

    # My factor  
    myfactor = BookToPrice()  
    # Returns  
    returns = Returns(inputs=[USEquityPricing.close], window_length=2)  
    universe = universe & myfactor.notnull()  
    # Factor Rank  
    myfactor_rank = myfactor.zscore(mask=universe)

    # Pipeline to return  
    return Pipeline(  
      columns={  
          'myfactor': myfactor,  
          'myfactor_rank': myfactor_rank,  
          'sector' : Sector()  
      },  
      screen  = (universe & tech)  
    )

results = run_pipeline(make_pipeline(), begin_period, end_period)  
results.fillna(value=0);  

Thank you.