Key Concepts

Developing in the IDE

Coding Your Algorithm

The QuantConnect Algorithm Lab allows you to write code in project files and then press the Build button to compile your algorithm. Build errors will be displayed in the console and highlighted with red lines.

You can add, rename, and delete files in your project in the Projects tab. To rename your project, click into the project, hover over the title, and click on the pencil to the right of it. You can create a virtual folder for your project by placing a slash ("/") into the name of your file. The bare minimum to run an algorithm is your initialization and data event methods.

public class BasicTemplateAlgorithm : QCAlgorithm
	public override void Initialize() {
		// Setup algorithm requirements: cash, dates and securities.
                // Initialize is called once at the start of the algorithm.

	public override void OnData(Slice data) {
               // Data requested is then piped into event handlers like this one.
class BasicTemplateAlgorithm(QCAlgorithm):

	def Initialize(self):
		'''Initialise the data and resolution required, as well as the cash and start-end dates for your algorithm. All algorithms must initialized.'''
	def OnData(self, data):
        '''OnData event is the primary entry point for your algorithm. Each new data point will be pumped in here.
            data: Slice object keyed by symbol containing the stock data

QuantConnect Backtesting and Coding Environment.

Backtesting Your Algorithm

Once you've got an algorithm compiling, you can click the Play button to launch a backtest. Results are shown in the Result drop-down menu. Backtesting in parallel is limited to fair usage for each user and may be reduced when it affects others in the community.

Running backtests are summarized on the terminal homepage and can be canceled from there to make room for other backtests.

API Help Documentation

The API Tab details the classes and API of the underlying LEAN engine so you can see the methods and class infrastructure. It includes all the indicator helper methods to see all the indicators available. This is automatically generated from the source code of LEAN. If you are able, we recommend becoming familiar with QCAlgorithm base source code.

Data Manager

The Data Manager Tab is a searchable database of the QuantConnect Data Library. Each asset's details are accessible, including the start date, delist date, source of the data, resolutions available, and the exchange on which the asset is traded.

If you find an issue with the QuantConnect data library, you can report this through our Data page. The Data page provides a public reporting and tracking system to fix issues systematically.

Shortcut Keys

The website coding environment comes with some keyboard shortcuts to make coding easier.

Short Cut Description
Ctrl + Space Initiate full auto-complete
Ctrl + / Toggle comments on selected code
Ctrl + Up/Down Increase/decrease font size
Ctrl + F Find
Ctrl + H Replace
Ctrl + S Save document and compile project
Ctrl + D Remove line
Ctrl + Z Undo
Ctrl + Y (or Ctrl + Shift + Z) Redo
Alt + Up/Down Move line up/down
Alt + Shift + Up/Down Copy lines up/down
Alt + 0 (zero) Collapse all code blocks
Alt + Shift + 0 (zero) Expand all code blocks

The full list of shortcuts can be found in the ACE Editor open source project.

Learning Programming

We aim to make it as easy as possible to use QuantConnect, but you still need to be able to program. We've provided some links below to get you started:

Language Type Name Producer
C# Video C# Fundamentals for Absolute Beginners Microsoft
C# Text C# Jump Start - Advanced Concepts Microsoft
C# Video Top 20 C# Questions Microsoft
C# Text C# Tutorial tutorialspoint
F# Text Why use F#? F# for fun and profit
F# Text Tour of F# Microsoft
F# Video F# Talks, Videos and Podcasts F# Foundation
Python Text/Video Introduction to Python Google
Python Interactive Code Academy - Python Code Academy

Local Development

If you prefer coding in your own development environment, you can download the LEAN Open Source project and work locally. We recommend using Visual Studio as your programming environment because of the plugin that we offer for development. Visual Studio Community Edition has the full power of Visual Studio and enables programming in C#, F#, and Python. 

If you're running on Mac or Linux, you can also use MonoDevelop or Xamarin Studio and copy-paste your algorithms into Check out the LEAN-Getting Started Tutorial for more information. The LEAN installation takes about 5 minutes.

Python users should follow the Python Installation process line by line. It specifically requires Python 3.6.6.

You can also see our Tutorials and Videos. You can also get in touch with us via Discord.

Did you find this page helpful?

Contribute to the documentation: