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:
- Open a project directory, generated by the CLI, with PyCharm and wait for the project to load.
- Wait for PyCharm to index all packages and autocomplete starts working.
- 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:
- Install the Python and Pylance extensions in VS Code.
- Open a project directory, generated by the CLI, with VS Code and Python autocomplete works automatically.
- 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:
- Make sure the .NET 6.0 Runtime is installed in the Visual Studio Installer by clicking Individual components tab on the window that shows up. in the installed Visual Studio version and opening the
- Click .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. on Visual Studio's home screen and open the
- Update your project to include the required imports.
C# and Rider
Follow these steps to set up local autocomplete for C# in Rider:
- Make sure the .NET 6.0 Runtime is installed.
- 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.
- 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:
- Make sure the .NET 6.0 Runtime is installed.
- Install the C# extension in VS Code.
- Open a project directory, generated by the CLI, with VS Code and wait for the project to load.
- Click if a pop-up shows in the bottom-right telling you there are dependencies to restore.
- 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:
- Open a terminal.
- 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:
- Open a terminal in one of your organization workspaces.
- 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'.