Project 2 Backtesting Environment
This program lets you test your own trading strategies on past prices in a scientifically sound way and shows how far to trust the result.
Already bought a plan? Sign in to open this project.
Sign inHow this project is built
The whole project consists of these six steps.
- A return and risk toolkitThe basic measures of return and risk come first, because every later number in the report is built from them.
- Portfolio weights to testAn optimizer finds the weights with the lowest volatility, and they form the portfolio that step 5 puts to the test.
- Value at risk and expected shortfallThe two measures of large losses are built and checked on later days here, because the report in step 5 needs them.
- A data layer and a backtester without look-aheadThe data layer cleans the prices and the backtester replays the past, so that the test in step 5 cannot look ahead.
- A risk report and an honest testHere all earlier parts come together, as the rule runs and the report shows with error bars whether its result means anything.
- A simple cost modelCosts come last because they only lower the result, and this step shows how much they take from accounts of three sizes.
After the last step, all six parts run together in one program,
backtest_tool.py. What the finished tool does
What the finished tool does
You can write a trading rule of your own as a short Python function that sees only the past and returns the weights to hold. The tool replays it on the simulated market first and later on real prices that you load yourself. The report then shows what the rule earned before and after costs and how sure that result is.
What you get
- 01The six steps with their code Each step explains its idea, walks through its code piece by piece and names its limits.
- 02The working tool,
backtest_tool.pyThe full program in one file, with its settings and experiments to try. - 03Defend it in an interview Typical follow-up questions, each with the reasoning you need to answer it.
- 04Use it with real data Which data the tool needs, how to load it and what to change in the code.