Quantopian's community platform is shutting down. Please read this post for more information and download your code.
Back to Community
How to program a backtest?

Hi all, I'm new to Quantopian and programming. Is there some way to program an automatic backtest where the code itself analyzes the backtest results? For example, could I write some code where the system analyzes its own performance, and adjusts accordingly? It seems as if backtesting takes some time, so could code be written where a backtest is only done once a day, or once every few hours? Thank you

2 responses

James,

Good question. You might look into the Quantopian research platform, which also supports backtests via zipline (although you can't actually call the browser-based backtester back-end from the research platform...sigh...). Within the research platform, I think you could write a backtest function. You would call it with a parameter set X0, get the results back, and then call it with a new parameter set X1, and so forth. In this fashion, you could make automatic adjustments.

Unfortunately, there is no way presently to do this sort of thing under live trading (e.g. automatic walk-forward optimization). I'm guessing folks are doing it manually on a nightly/weekly/monthly/quarterly basis, by stopping their algos and pasting updated parameters into the code and then re-starting. Fetcher (for loading external data) might work, too, which would avoid the need for stopping and re-launching the algo.

If you are completely new to programming, however, I'd suggest writing a very modest algo in the browser-based backtester, to start inching your way up the learning curve before jumping into the deep end of the pool.

Grant

Thanks for the reply, and yes I'm completely new to programming. Looking forward to learning new things with Quantopian!