Projects

Autocomplete

Introduction

Local autocomplete is an important feature of the Lean CLI, making you more productive in your local development environment. The CLI automatically generates the necessary editor configuration when creating new projects to make local autocomplete almost seamless for most popular editors. However, not everything can be configured automatically. This page explains how to make local autocomplete work for Python and C# with all editors supported by the CLI.

Python and PyCharm

Follow these steps to set up local autocomplete for Python in PyCharm:

  1. Open a project directory, generated by the CLI, with PyCharm and wait for the project to load.
  2. Wait for PyCharm to index all packages and autocomplete starts working.
  3. Update your project to include the required imports.

Python and VS Code

Follow these steps to set up local autocomplete for Python in VS Code:

  1. Install the Python and Pylance extensions in VS Code.
  2. Open a project directory, generated by the CLI, with VS Code and Python autocomplete works automatically.
  3. Update your project to include the required imports.

C# and Visual Studio

Follow these steps to set up local autocomplete for C# in Visual Studio:

  1. Make sure the .NET 6.0 Runtime is installed in the Visual Studio Installer by clicking Modify in the installed Visual Studio version and opening the Individual components tab on the window that shows up.
  2. Click Open a project or solution on Visual Studio's home screen and open the .csproj file in one of the project directories generated by the CLI. Visual Studio automatically downloads the required dependencies and indexes them to provide autocomplete.
  3. Update your project to include the required imports.

C# and Rider

Follow these steps to set up local autocomplete for C# in Rider:

  1. Make sure the .NET 6.0 Runtime is installed.
  2. Open the .csproj file in a project directory, generated by the CLI, with Rider and wait for the project to load. Rider automatically downloads the required dependencies and indexes them to provide autocomplete.
  3. Update your project to include the required imports.

C# and VS Code

Follow these steps to set up local autocomplete for C# in VS Code:

  1. Make sure the .NET 6.0 Runtime is installed.
  2. Install the C# extension in VS Code.
  3. Open a project directory, generated by the CLI, with VS Code and wait for the project to load.
  4. Click Restore if a pop-up shows in the bottom-right telling you there are dependencies to restore.
  5. Update your project to include the required imports.

Imports

Some imports are automatically added to your files when you run them in the cloud. This does not happen locally, so in your local environment, you need to manually import all the classes that you use. You can copy the following code snippet to the top of every file to have the same imports as the ones used in the cloud:

using System;
using System.Collections;
using System.Collections.Generic;
using System.Drawing;
using System.Globalization;
using System.Linq;
using QuantConnect;
using QuantConnect.Parameters;
using QuantConnect.Benchmarks;
using QuantConnect.Brokerages;
using QuantConnect.Util;
using QuantConnect.Interfaces;
using QuantConnect.Algorithm;
using QuantConnect.Algorithm.Framework;
using QuantConnect.Algorithm.Framework.Selection;
using QuantConnect.Algorithm.Framework.Alphas;
using QuantConnect.Algorithm.Framework.Portfolio;
using QuantConnect.Algorithm.Framework.Execution;
using QuantConnect.Algorithm.Framework.Risk;
using QuantConnect.Indicators;
using QuantConnect.Data;
using QuantConnect.Data.Consolidators;
using QuantConnect.Data.Custom;
using QuantConnect.Data.Fundamental;
using QuantConnect.Data.Market;
using QuantConnect.Data.UniverseSelection;
using QuantConnect.Notifications;
using QuantConnect.Orders;
using QuantConnect.Orders.Fees;
using QuantConnect.Orders.Fills;
using QuantConnect.Orders.Slippage;
using QuantConnect.Scheduling;
using QuantConnect.Securities;
using QuantConnect.Securities.Equity;
using QuantConnect.Securities.Forex;
using QuantConnect.Securities.Interfaces;
using QuantConnect.Python;
using QuantConnect.Storage;
from AlgorithmImports import *

Staying Up-to-date

Follow these steps to update Python autocomplete to be aware of the latest changes to LEAN:

  1. Open a terminal.
  2. Run pip install --upgrade quantconnect-stubs to update the Python autocomplete.
    $ pip install --upgrade quantconnect-stubs
    Collecting quantconnect-stubs
    Installing collected packages: quantconnect-stubs
    Successfully installed quantconnect-stubs-11657
    

Follow these steps to update C# autocomplete to be aware of the latest changes to LEAN:

  1. Open a terminal in one of your organization workspaces.
  2. Run dotnet add "<projectName>" package QuantConnect.Lean to update the C# autocomplete for the project in . / <projectName>.
    $ dotnet add "My Project" package QuantConnect.Lean
    info : Adding PackageReference for package 'QuantConnect.Lean' into project '/home/john/My Project/My Project.csproj'.
    info : PackageReference for package 'QuantConnect.Lean' version '2.5.11800' updated in file '/home/john/My Project/My Project.csproj'.
    
    Additionally, you can also update C# autocomplete by updating the version of the QuantConnect.Lean package reference in the C# project file (the file ending with .csproj). This can be done manually or through your editor's built-in NuGet tooling if your editor has such a feature.

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: