Backtests

Managing Backtests

Introduction

This page explains how to create and manage backtests from the Research Environment with the QuantConnect API.

Prerequisites

Working knowledge of C#.

Working knowledge of Python.

Compile Projects

To compile a project, call the CreateCompile method with the project ID.

#load "../Initialize.csx"
#load "../QuantConnect.csx"

using QuantConnect;
using QuantConnect.Api;

var compile = api.CreateCompile(projectID);
compile = api.CreateCompile(project_id)

The CreateCompile method returns a Compile object, which have the following attributes:

Create Backtests

To backtest a project, compile the project and then call the CreateBacktest method with the project ID, compile ID, and a backtest name.

var backtest = api.CreateBacktest(projectId, compile.CompileId, backtestName);
backtest = api.CreateBacktest(project_id, compile.CompileId, backtest_name)

The CreateBacktest method returns a Backtest object, which have the following attributes:

Update Backtests

To update the name and note of a backtest, call the UpdateBacktest method with the project ID, backtest ID, the new backtest name, and the new note.

var response = api.UpdateBacktest(projectId, backtestId, ""New Name", "New Note");
response = api.UpdateBacktest(project_id, backtest_id, "New Name", "New Note")

The UpdateBacktest method returns a RestResponse object, which have the following attributes:

Delete Backtests

To delete a backtest, call the DeleteBacktest method with the project ID, backtest ID.

var response = api.DeleteBacktest(projectId, backtestId);
response = api.DeleteBacktest(project_id, backtest_id)

The DeleteBacktest method returns a RestResponse object, which have the following attributes:

List Backtests

To get the backtests of a project, call the ListBacktests method with the project ID.

var response = api.ListBacktests(projectId);
response = api.ListBacktests(project_id)

The ListBacktests method returns a BacktestList object, which have the following attributes:

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: