Backtesting
Getting Started
Introduction
Backtesting is the process of simulating a trading algorithm on historical data. By running a backtest, you can measure how the algorithm would have performed in the past. Although past performance doesn't guarantee future results, an algorithm that has a proven track record can provide investors with more confidence when deploying to live trading than an algorithm that hasn't performed favorably in the past. If you run local backtests, you can leverage your local data and hardware.
Run Backtests
Local Platform provides multiple deployment targets to enable you to run backtests on-premise and in the cloud. To run a backtest, open a project and then click the / Backtest icon. If the project successfully builds, "Received backtest backtestName request" displays. If the backtest successfully launches, the IDE displays the backtest results page in a new tab. If the backtest fails to launch due to coding errors, the new tab displays the error. As the backtest executes, you can close Local Platform and Docker Desktop without interfering with the backtest. Just don't quit Docker Desktop.
View All Backtests
Follow these steps to view all of the backtests of a project:
- Open the project that contains the backtests you want to view.
- In the top-right corner of the IDE, click the / Backtest Results icon.
- (Optional) In the top-right corner, select the Show field and then select one of the options from the drop-down menu to filter the table by backtest or optimization results.
- (Optional) In the bottom-right corner, click the Hide Error check box to remove backtest and optimization results from the table that had a runtime error.
- (Optional) Use the pagination tools at the bottom to change the page.
- (Optional) Click a column name to sort the table by that column.
- Click a row in the table to open the results page of that backtest or optimization.
A table containing all of the backtest results for the project is displayed. If there is a play icon to the left of the name, it's a backtest result. If there is a fast-forward icon next to the name, it's an optimization result. The Platform column displays the deployment target of the backtest.
Rename Backtests
We give an arbitrary name (for example, "Smooth Apricot Chicken") to your backtest result files, but you can follow these steps to rename them:
- Open the backtest history of the project.
- Hover over the backtest you want to rename and then click the pencil icon that appears.
- Enter the new backtest name and then click .
To programmatically set the backtest name, call the SetName
set_name
method.
SetName("Backtest Name");
self.set_name("Backtest Name")
For more information, see Set Name and Tags.
Results
The backtest results page and the backtests directory in your project show your algorithm's performance. Review the results to see how your algorithm has performed during the backtest and to investigate how you might improve your algorithm before live trading. For more information about backtest results, see Results.
Algorithm Lab Backtests
For information about cloud backtests through the Algorithm Lab, see Getting Started.
Get Backtest Id
To get the backtest Id, see the first line of the log file. An example local backtest Id is 1710698424. An example cloud backtest Id is 8b16cec0c44f75188d82f9eadb310e17.