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:

  1. Open the project that contains the backtests you want to view.
  2. In the top-right corner of the IDE, click the / Backtest Results icon.
  3. 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.

    All backtest table view
  4. (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.
  5. (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.
  6. (Optional) Use the pagination tools at the bottom to change the page.
  7. (Optional) Click a column name to sort the table by that column.
  8. Click a row in the table to open the results page of that backtest or optimization.

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:

  1. Open the backtest history of the project.
  2. Hover over the backtest you want to rename and then click the pencil icon that appears.
  3. Rename backtest navigation
  4. Enter the new backtest name and then click OK.

To programmatically set the backtest name, call the SetNameset_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.

You can also see our Videos. You can also get in touch with us via Discord.

Did you find this page helpful?

Contribute to the documentation: