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

I suggest updating the help docs on the topic of the use of random number generators.

The help page states:

The use of random() isn't supported because of technical limitations with our start-of-day initialization.

This is out-dated. The actual requirement, as I understand, is that backtests are repeatable. This requirement can be met by fixing the random number generator seed within the algo.

For example:

random.seed(9001)  

Or if using numpy:

numpy.random.seed(9001)  

You might also note that any libraries utilizing random number generators need to have the seed set within the algo.

2 responses

Hypothetically, does this have an application with sorting?

sort_values(by = random.seed(9001)'price')  

Or something to that effect? Apologies in advance for the code, I'm definitely still learning Python.

One application is stability / sensitivity testing. Its a technique used in design of electronic circuits
(Monte Carlo analysis)

Say your algorithm has key numeric thresholds, purchase dates etc.
The can be replaced with randomly varying values (through an appropriate range, choosing the
range is the hard part here) and the back test run multiple times. If the results vary wildly it
indicates likely problems.

replace
purchase_day_of_month = 1
if rsi < 30 : do something

with:

purchase_day_of_month = rand(1,28)
if rsi < rand(20,40) : do something