Category: New Features

Scheduled Events

Scheduled events allow you to trigger code blocks for execution at specific times according to rules you set. This feature helps coordinate your algorithm activities and perform analysis at regular intervals; while letting the trading engine take care of market holidays.

The scheduling is set with two rules: the DateRules and TimeRules classes. The schedule manager takes one of each and executes an action code block:

Schedule.On(DateRules.On(2013, 10, 7), TimeRules.At(13, 0), () => 
         Debug("Specific Time: Fired at : " + Time);

The date rules can be specified as below:

Scheduled Events Date Rules
DateRules.On(2013, 10, 7) On a specific date
DateRules.EveryDay("SPY") Every trading day for SPY
DateRules.Every(DayOfWeek.Monday, ...) On specific days of week
DateRules.EveryDay() Every day
DateRules.MonthStart("SPY") SPY trading start of each month

The time rules trigger specify when on the day the event should be triggered. They can be specified as below:

Scheduled Events Time Rules
TimeRules.At(13, 0) At a specific time, 1:00pm
TimeRules.AfterMarketOpen("SPY", 10) Run 10 minutes after market open for SPY
TimeRules.BeforeMarketClose("SPY", 10) Run 10 minutes before market close for SPY
TimeRules.Every(TimeSpan.FromMinutes(10)) Every 10 minutes during day specified

For a demonstration see the tutorial video below:

Desktop Charting with LEAN

With a few configuration changes you can get desktop charting in LEAN with a HTML5 interface very similar to the one you see in This gives you better visual feedback on your strategy and allows you to improve faster. This tutorial guides you through configuring a desktop charting environment with LEAN.

Local charting (and all local backtesting) requires you to have your own source of data. We provide a way to download FX and CFD data through our API. To get started make sure you have your data in your data folder. By default this is the /Data/ directory relative to your LEAN installation.

Two configuration changes are required for desktop charting to work:

  1. Change the “environment” field to use “backtesting-desktop”. This instructs LEAN to use the configuration settings block at the bottom of the config file.
      "environment": "backtesting-desktop",
  2. Insert your API token and user id into configuration file. This is required for chart streaming.
      // To get your api access token go to
      "job-user-id": "....",
      "api-access-token": "...........",

With those changes in place you can simply run the project and your backtesting chart will appear in a few seconds. For live trading; use the”live-desktop” configuration environment.

If you get the run-time exception “The port configured in config.json is either being used or blocked by a firewall”- This normally means you’ve left the user interface open (you should close it between each run). It can also be because another program is sharing that port. You can fix this by changing the port LEAN transmits the data with the "desktop-http-port" setting.

In the tutorial video below we demonstrate this feature on LEAN:

Collaborating in QuantConnect

Collaborating is a powerful feature of QuantConnect which allows up to 10 team members to work on a project at the same time. This can be useful when a team of specialists collaborates to build a great strategy.

The project creator holds the master copy of the project and can add team members and control the project permissions. To add a team member you just click the “Share” button in the project tab and search for the user by name or email address. Once the user is added you can control their permissions or remove them from the project.

Collaboration allows setting permissions on user by user level

Changes to shared projects are instantly shared between the collaborators and can be see by the colorful cursor representing the other team members.

Introducing The Co-Pilot: Your Coding Companion

We’re happy to announce the release of the Co-Pilot; a rich automated documentation generator built to give you relevant hints while you’re building your strategy. With deep API’s it is impossible to memorize all the methods available; and time consuming to constantly search the documentation. As a coding companion, the co-pilot can inspect the types you’re working on and provide the properties that are available.

The methods of the API are shown by the tables of code blocks, and detailed properties of the working variables are also available. We generate documentation from the reference text but also from the code API. These different documentation types are noted by the icons next to the results.

There are multiple documentation result types; text and code results.

Using the QuantConnect Charting API

We’re pleased to announce the release of a new charting API which lets you create flexible, dynamic charts from your backtest. The charts stream to your browser as the backtest is running and can be configured in many different ways. It is a very simple API, allowing you to create custom charts with just 1 line of code. The minimal usage plots a second line on your strategy’s equity chart. It can be accessed like this:

//Minimum code required for custom plotting:
Plot(string seriesName, decimal/int/float value);
//Example using the 'Strategy Equity' chart by default.
Plot("Portfolio", Portfolio.TotalPortfolioValue);
Custom line plot stacked with your strategy equity.

Custom line plot stacked with your strategy equity.

With just one extra parameter, the chart name, you can also create your own chart and place any series onto it you wish:

//Create your own charts by specifying a chart name:
Plot(string chartName, string seriesName, decimal/int/float value);

Underneath the Plot() function are two key classes: Chart and Series. The Chart class is the canvas you’d like to draw on, it can be set so the Series are Stacked or Overlayed. The Series classes are the data on the chart, they default to Line plots but can be set to be Candles or Scatter. Below is an example of creating a customized chart and plotting our trades on top of the asset price:

Plot prices with trades to see where your algorithm is working.

Plot prices with trades to see where your algorithm is working.

//Our custom chart, id: "Currency Plotter", Overlay the series.
Chart plotter = new Chart("Currency Plotter", ChartType.Overlay);
//Line series for our EURUSD pricing.
plotter.AddSeries(new Series("EURUSD", SeriesType.Line));
//Scatter-series for our BUY-orders.
plotter.AddSeries(new Series("Buy", SeriesType.Scatter));
//Scatter-series for our SELL-orders
plotter.AddSeries(new Series("Sell", SeriesType.Scatter));   
AddChart(plotter); //Add the Chart to our algorithm

Once you’ve setup your custom chart you can access it with the Plot() function.

Plot("Currency Plotter", "EURUSD", price);      // Save End of Day prices.
Plot("Currency Plotter", "Buy", purchasePrice); // Plot purchasing prices.
Plot("Currency Plotter", "Sell", salePrice);    // Plot sale prices.

The SeriesType enum controls the style of a series. Data passed into candle plots gets automatically converted into Daily or Weekly candles depending on the quantity of data. Because of technical limitations of working in a browser all series are capped at 4000 samples. If you find your browser slowing down try sampling less!

Class Chart(string chartName, ChartType type);
Class Series(string seriesName, SeriesType type);
Enum ChartType { Overlay, Stacked }
Enum SeriesType { Line, Scatter, Candle }

Putting it all together the results are fairly exciting, we hope you’ll enjoy! To get you started we’ve made a demonstration algorithm which generates the charts below. Clone it and copy the bits you like into your algorithm.

Daily Data Updates, GIT Integration!

Thank you all those that have signed up and lent your support to QuantConnect. We are growing fast and appreciate your feedback. As a thank you, during July we’re giving away free 12 month licenses. If you’d like your free license just leave a request in the forums.

Thanks to your feedback – we’re happy to announce three major new features!

1. Daily Market Data Updates

After a few long nights of coding we’ve finished adding daily data updates to the QuantConnect backend, so now you can tap into the US Equities, and FX currency pairs tick data right up until Today-1. To use up to date data simply use: SetEndDate(DateTime.Today.AddDays(-1)); High quality data provided by QuantQuote and FXCM.

2. GIT API – Use your favorite IDE

QuantConnect is now fully integrated with GIT version control. Code your algorithms using your favorite developer tools, and commit your changes to GIT. We automatically run your backtests and email you the results.  After you commit code back to the server we automatically build it, run a backtest and email you the strategy results. If you check out a copy of our open-sourced code you can compile your algorithm on your desktop. Continue reading

US Equities And FX Tick Data Ready!

After months of work, and lots of coffee we’re proud to announce for the first time ever, tick data, a coveted asset of the financial industry is available through QuantConnect. We have every single trade on 16,000 stocks going back to 1998, along with 11 major currency FX pairs since 2007.

The IDE is faster than ever with a cluster of hundreds of machines running for your backtests: a 5 year tick simulation completes in about 60-120 seconds, and minute and second resolution candle complete much faster. This blistering speed is normally reserved for mega-quant funds and retail has never seen anything so powerful.

We’re grateful to our data providers, QuantQuote, and FXCM, thank you for giving us the highest quality data possible. In total it is 4 terabytes of data, entirely at your disposal. And, as always and forever, we’ve made it completely free for you.

To help you navigate, and give you some code examples to kick off we made the Data Library. Here you can copy-paste some code snippets to use the data.

Last week Simon interviewed Tadas Viskanta of Abnormal Returns, and FOREXThink interviewed Jared on the future of finance. We also finished the API documentation so you can dive in!

There’s a lot going on, so why don’t you drop us a line on the forums and we’d be happy to help –

Jared, Shai, Gustavo, Paul and Simon.
The QuantConnect Team

First New Data Set! Estimize Crowd Sentiment Data!

In our aim to provide you with the best quality, institutional level data we’re now working with to bring you crowd-sourced earnings estimate data.

Each financial quarter companies publish their earnings per share (EPS) and revenue figures to investors. When a company performs worse than expected, often the share price can fall dramatically, and vice versa.

Each time there is an earning announcement the community of 13,000 users makes predictions on what the Earnings Per Share (EPS) will be, along with the Revenue for the quarter. On average they are more accurate than Wall Street analysts 69% of the time!

For the first time you can freely use historical sentiment data to design trading algorithms! With QuantConnect you can now access estimates from the crowd into your algorithms to design powerful sentiment strategies. Imagine testing how a bad earnings announcement affects the stock price!

In your Initialize() Method:

AddSentimentData(SentimentDataType.Estimize, "IBM");

And then handle the events using the OnEstimize() handler:

public override void OnEstimize(Dictionary<string, Estimize> estimates) {
//Incoming IBM Estimate
Debug("IBM EPS:" + estimates["IBM"][0].Eps+" Rev:"+estimates["IBM"][0].Revenue);

See the full documentation at

© 2017 QuantConnect Blog

Democratizing algorithmic investments Up ↑