---
title: "Debugging"
description: "The debugger enables you to step through the program line-by-line, inspect the variables to understand the algorithm state, and debug any errors."
canonical: https://www.quantconnect.com/docs/v2/local-platform/backtesting/debugging
markdown: https://www.quantconnect.com/docs/v2/local-platform/backtesting/debugging.md
language: python
source: https://github.com/QuantConnect/Documentation/tree/master/02%20Local%20Platform/10%20Backtesting/05%20Debugging
modified: 2026-10-29
index: https://www.quantconnect.com/llms.txt
---

# Debugging

[Documentation](https://www.quantconnect.com/docs/v2.md) > [Local Platform](https://www.quantconnect.com/docs/v2/local-platform.md) > Backtesting > Debugging

> Code examples are shown in Python. Append `?lang=csharp` to this URL for the C# version of this page.

## Introduction

The debugger is a built-in tool to help you debug coding errors while backtesting. The debugger enables you to slow down the code execution, step through the program line-by-line, and inspect the variables to understand the internal state of the program.

Local debugging only works with local projects. Locally debugging cloud projects is not currently supported.

## Requirements

You need to install v2023.4.0 of [Microsoft's Python VS Code extension](https://marketplace.visualstudio.com/items?itemName=ms-python.python) to run the debugger.

## Breakpoints

Breakpoints are lines in your algorithm where execution pauses. You need at least one breakpoint in your code files to start the debugger. [Open a project](https://www.quantconnect.com/docs/v2/local-platform/projects/getting-started.md#04-Open-Projects) to start adjusting its breakpoints.

### Add Breakpoints

Click to the left of a line number to add a breakpoint on that line.

![Add breakpoint](https://cdn.quantconnect.com/i/tu/set-break-point-2.gif)

### Edit Breakpoint Conditions

Follow these steps to customize what happens when a breakpoint is hit:

1. Right-click the breakpoint and then click **Edit Breakpoint...**.
2. Click one of the options in the following table:

| Option | Additional Steps | Description |
| --- | --- | --- |
| **Expression** | Enter an expression and then press **Enter**. | The breakpoint only pauses the algorithm when the expression is true. |
| **Hit Count** | Enter an integer and then press **Enter**. | The breakpoint doesn't pause the algorithm until its hit the number of times you specify. |

### Enable and Disable Breakpoints

To enable a breakpoint, right-click it and then click **Enable Breakpoint**.

To disable a breakpoint, right-click it and then click **Disable Breakpoint**.

Follow these steps to enable and disable all breakpoints:

1. In the left navigation menu, click the ![Run & debug icon](https://cdn.quantconnect.com/i/tu/run-and-debug-icon.png) **Run and Debug** icon.
2. In the Run and Debug panel, hover over the **Breakpoints** section and then click the ![](https://cdn.quantconnect.com/i/tu/disable-all-breakpoints-icon.png) **Toggle Active Breakpoints** icon.

### Remove Breakpoints

To remove a breakpoint, right-click it and then click **Remove Breakpoint**.

Follow these steps to remove all breakpoints:

1. In the left navigation menu, click the ![Run & debug icon](https://cdn.quantconnect.com/i/tu/run-and-debug-icon.png) **Run and Debug** icon.
2. In the Run and Debug panel, hover over the **Breakpoints** section and then click the ![](https://cdn.quantconnect.com/i/tu/remove-all-breakpoints-icon.png) **Remove All Breakpoints** icon.

## Launch Debugger

Follow these steps to launch the debugger:

1. [Open the project](https://www.quantconnect.com/docs/v2/local-platform/projects/getting-started.md#04-Open-Projects) you want to debug.
2. In your project's code files, add at least one breakpoint.
3. Click the ![Debug icon](https://cdn.quantconnect.com/i/tu/local-platform-debug-icon.png) **Debug** icon.

If the Run and Debug panel is not open, it opens when the first breakpoint is hit.

## Control Debugger

After you launch the debugger, you can use the following buttons to control it:

| Button | Name | Default Keyboard Shortcut | Description |
| --- | --- | --- | --- |
| ![Debugger continue icon](https://cdn.quantconnect.com/i/tu/debugger-continue-button.png) | Continue |  | Continue execution until the next breakpoint |
| ![Debugger step over icon](https://cdn.quantconnect.com/i/tu/debugger-stop-over-button.png) | Step Over | **Alt+F10** | Step to the next line of code in the current or parent scope |
| ![Debugger step into icon](https://cdn.quantconnect.com/i/tu/debugger-step-into-button.png) | Step Into | **Alt+F11** | Step into the definition of the function call on the current line |
| ![Debugger restart icon](https://cdn.quantconnect.com/i/tu/debugger-restart-button.png) | Restart | **Shift+F11** | Restart the debugger |
| ![Debugger disconnect icon](https://cdn.quantconnect.com/i/tu/debugger-disconnect-button.png) | Disconnect | **Shift+F5** | Exit the debugger |

## Inspect Variables

After you launch the debugger, you can inspect the state of your algorithm as it executes each line of code. You can inspect local variables or custom expressions. The values of variables in your algorithm are formatted in the IDE to improve readability. For example, if you inspect a variable that references a DataFrame, the debugger represents the variable value as the following:

![Dataframe in a debugger variable view](https://cdn.quantconnect.com/i/tu/debugger-dataframe.png)

### Local Variables

The **Variables** section of the Run and Debug panel shows the local variables at the current breakpoint. If a variable in the panel is an object, click it to see its members. The panel updates as the algorithm runs.

![Local variables in debugger view](https://cdn.quantconnect.com/i/tu/inspect-local-variables.gif)

Follow these steps to update the value of a variable:

1. In the Run and Debug panel, right-click a variable and then click **Set Value**.
2. Enter the new value and then press **Enter**.

### Custom Expressions

The **Watch** section of the Run and Debug panel shows any custom expressions you add. For example, you can add an expression to show the current date in the backtest.

![Inspect custom variables in debugger view](https://cdn.quantconnect.com/i/tu/watch-variables.png)

Follow these steps to add a custom expression:

1. Hover over the **Watch** section and then click the **plus** icon that appears.
2. Enter an expression and then press **Enter**.
