Open Source

Backtesting from Visual Studio

Backtesting from Visual Studio

Introduction

The Visual Studio plugin is a tool which allows you to code locally; harnessing all the power of Visual Studio's autocomplete and code analysis; while also backtesting in the QuantConnect Cloud. It aims to facilitate your strategy development. The plugin supports Visual Studio 2015 and 2017.

You can download the plugin here: QuantConnect.VisualStudioPlugin.vsix

Installation

To install the plugin simply execute the binary supplied download above, or you can rebuild it from scratch from the LEAN project. To build it from scratch please follow the instructions below.

Build

  1. Open LEAN Solution in Visual Studio. Select ‘Release’ solution configuration.
  2. Right click project ‘QuantConnect.VisualStudioPlugin’ and select ‘Rebuild’.
  3. Verify in the Visual Studio ‘Output’ panel the compilation succeeded with no errors.

Installation

If you have intstalled a previous version of the plugin you first need to remove this first. You do this from the ‘Tools’ Menu → ‘Extensions and Updates...’ → ‘Installed’. Then search for ‘QuantConnect.VisualStudioPlugin’ and click uninstall. Once uninstalled; remember to restart Visual Studio.

After building navigate to ‘..\Lean\VisualStudioPlugin\bin\Release’. If you built sucessfully you should be able to execute ‘QuantConnect.VisualStudioPlugin.vsix’.

Setting Up Your Plugin

  1. Login to QuantConnect and navigate to your My Account page.
  2. In the API panel, you will find your a ‘unique access token’ and your ‘user id’ which are required to connect to the API. Copy these to your clipboard.
  3. From the Visual Studio IDE go to ‘Tools’ menu → ‘QuantConnect’ → ‘Login’. Enter your API credentials and click Login.

Manually logging in is only required the first time. After the first login, the plugin will automatically log in using previously saved credentials.

Plugin Features

The Visual Studio plugin can currently save files to a project, compile the project, and backtest it in the cloud. Through the accompanying "tool window" it can also rename, open or add a note to a backtest, and create a new project.

Saving Files to QuantConnect

Save files from your local project to a QuantConnect project. You can save many files at a time.

  1. Select the desired files with your mouse from the Solution Explorer tool window.
  2. Right-click selection → ‘Save to QuantConnect’.
  3. Select target project name:
  4. Result:
    • If the operation succeeds you will be informed through the VS Status Bar.
    • If any error occurs you will be informed through VS Status Bar and with a popup box.

Send for Backtesting

This feature allows you to upload one or more files to a target project, compile it and backtest it in the QuantConnect cloud.

  1. Select the desired files you'd like to backtest.
  2. Right-click → ‘Send for Backtesting’
  3. Select the target project with the project list view.
  4. Result:
    • If the operation succeeds you will be informed through the VS Status Bar and the target QC project will be opened using the default browser pointing at your new backtest.
    • If any error occurs you will be informed through VS Status Bar and with a popup box.
    If the error is due to a compilation error, the pop-up box will contain the first compilation error.

    If the error is due to a run-time issue during the backtesting process, the popup box will contain error details and the corresponding stack trace.

Backtest Tool Window

The backtesting tool window utility allows you to monitor and control ongoing backtests, along with editing various properties of existing completed backtests.

If you select a project ‘BuyTheDip_007’ using the tool windows combo box and launch a backtest using ‘Send For Backtesting’ for ‘BuyTheDip_007’ project, it will display the backtests progress in the tool window.

How do I get the Backtest Window?

From the Visual Studio IDE go to ‘View’ menu → ‘Other Windows’ → ‘QuantConnect’. If there are previous valid credentials, the tool window will auto login when open or when the user performs an action.

Available Backtest Window Features

  • Open Backtest: Open backtest viewer on QuantConnect.
  • Refresh/Reload Project List
  • Delete Backtest
  • Edit Backtest: Rename or add notes to backtest results.
  • Create a New Project

Troubleshooting

VisualStudio plugin can write log data to the VisualStudio activity log, but only if VisualStudio is started with the /log parameter switch. To debug the QuantConnect plugin start VisualStudio with the following command:

devenv /log <path-to-log>

See Visual Studio Documentation for more information.

You can also see our Documentation and Videos. You can also get in touch with us via Chat.

Did you find this page Helpful ?