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!

Clone Algorithm
2
Loading...
Backtest from to with initial capital
Total Returns
--
Alpha
--
Beta
--
Sharpe
--
Sortino
--
Max Drawdown
--
Benchmark Returns
--
Volatility
--
Returns 1 Month 3 Month 6 Month 12 Month
Alpha 1 Month 3 Month 6 Month 12 Month
Beta 1 Month 3 Month 6 Month 12 Month
Sharpe 1 Month 3 Month 6 Month 12 Month
Sortino 1 Month 3 Month 6 Month 12 Month
Volatility 1 Month 3 Month 6 Month 12 Month
Max Drawdown 1 Month 3 Month 6 Month 12 Month
# Backtest ID: 5a03bc770c82414490dd0f3b
There was a runtime error.
3 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.

Clone Algorithm
3
Loading...
Backtest from to with initial capital
Total Returns
--
Alpha
--
Beta
--
Sharpe
--
Sortino
--
Max Drawdown
--
Benchmark Returns
--
Volatility
--
Returns 1 Month 3 Month 6 Month 12 Month
Alpha 1 Month 3 Month 6 Month 12 Month
Beta 1 Month 3 Month 6 Month 12 Month
Sharpe 1 Month 3 Month 6 Month 12 Month
Sortino 1 Month 3 Month 6 Month 12 Month
Volatility 1 Month 3 Month 6 Month 12 Month
Max Drawdown 1 Month 3 Month 6 Month 12 Month
# Backtest ID: 5a045852526e4e401d9bbf65
There was a runtime error.

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.

Loading notebook preview...
Notebook previews are currently unavailable.