Quantopian's community platform is shutting down. Please read this post for more information and download your code.
Back to Community
The result of Backtest - 2

I have used this algorithm many times. Before, it could run the result that the returns was not equal to 0 and the log "Number of unique industries: 81". But recently, I found that the returns become 0 and the log "Number of unique industries is equal : 0". I think that maybe there is not any data in dataframe or the pipeline does not get any data. But several days ago, everything is OK. Does anyone know how to solve this problem? Thank you!

4 responses

Hello Joyce,

Using .naics in:

class Industry(CustomFactor):  
    inputs=[ms.asset_classification.naics]  
    window_length=100  
    def compute(self, today, assets, out, industry):  
        out[:] = industry[-1]  

Seemed to return value of -1 for every stock rather than industry code and that's why Number of unique industries came back as 0 and weights wouldn't be assigned. So I used .morningstar_industry_code instead of .naics and got your algorithm to run.

Thank you for your help. Becuase I think nais is the most common industry classification, if I still want to use naics, how to modify my code? Thank you!

Hmm... I couldn't get naics to work. Maybe there's a bug in Morningstar dataset or somewhere in Quantopian system, because like I said earlier using .naics results value -1 instead of naics code.

Any mod who can look at the NAICS issue here? All NAICS codes return -1.