Quantopian's community platform is shutting down. Please read this post for more information and download your code.
Back to Community
random seed

I understand that random() is generally not supported, but what about random seed? Namely, my backtests keep getting different results when I use different seeds (my algo resets the seed multiple times). It works fine when I just use one seed.

Should I be expecting this kind of behavior?

Edit: answered my own question. Solution: use RandomState().

Re-edit: solution does not work.

Code in question:

            if seed is not None:  
                np.subtract(returns, np.nanmean(returns), out=returns)  
                np.divide(returns, np.sqrt(np.nanvar(returns)+1e-12),  
                          out=returns)  
                np.random.seed(seed)  
                nan_count = np.sum(np.isnan(returns))  
                returns[np.isnan(returns)] = np.random.randn(nan_count)  
            else:  
                returns[np.isnan(returns)] = 0