Skip to main content

Our trading algorithms are built-in QuantConnect, so we thought our first post ever should give an overview of this amazing platform.

What is QuantConnect?

In their own words, ‘QuantConnect is the next revolution in quant trading, combining cloud computing and open data access’.

Let me explain. QuantConnect is a robust algorithmic trading platform, powered by its open-source code LEAN, that allows you to research, design and backtest your strategies using their free data sources on Equities, FX, Options and Futures. You can code in multiple programming languages (Python, C#) and become fascinated by the modular design of its Algorithm Framework.

Yes, ALL this for free!

And if you want to do Live Trading (either paper trading or real money via your brokerage account), you can get a prime subscription for as little as $20/month to rent your own server in the cloud.

Introduction to the Algorithm Framework

The term Algorithm Framework refers to the design framework in which algorithms are built-in QuantConnect. This structure is based on the most common elements that a trading algorithm has, with the objective of building each of these blocks separately and then plugging them in and out to construct a full trading system. By creating these models independently, we generate reusable work that can be easily leveraged in other algorithms.

So today we will be having a first look at the different parts of this Algorithm Framework.

The first thing we need to understand is that these models run in a sequence, a continuous loop going in this direction Universe >> Alpha >> Portfolio >> Execution >> Risk. This doesn’t mean we always have to use all five of them, but that is the order in which they are designed to act.

  • Universe Selection: The purpose of this module is to select the securities that will be part of our ‘Universe’ of consideration. Therefore this model ensures we have data flowing into the rest of the framework for the relevant tickers. Broadly speaking, a selection of securities can be of two types:
    • Manual: Manually entering a list of tickers. This is done only once at the start of the algorithm.
    • Dynamic: Tickers are selected based on certain criteria (price, volume, technical indicators, fundamental data, etc.). This is similar to a classic screener that will find the securities that meet our specific criteria. This process runs daily by default, or we can schedule it for a specific frequency (e.g. weekly, monthly).
  • Alpha Creation: This part is concerned with the predictions (Up, Down, Flat) for the securities selected in the previous model. Basically, here we perform all necessary calculations and predictive modeling to come up with individual insights for the tickers in our ‘Universe’.
  • Portfolio Construction: This section will let us decide how much we want to invest in each security. It will take the insights from the previous ‘Alpha’ module and translate them into specific portfolio targets through some logic that we need to build. This could be simply equal weighting (invest the same percentage of the portfolio in each ticker), or some portfolio optimization technique (e.g. mean-variance, risk parity, maximum Sharpe ratio, etc.).
  • Execution: We are finally ready to place our orders! This module turns the previous portfolio targets into buy/sell orders. Once again, this can be as simple as executing market orders or limit orders, or more complicated models such as VWAP execution.
  • Risk Management: At this point, we are already invested in some securities so our main concern becomes how to handle risk. Things like stop-loss orders, take-profit and trailing stops will be coded here. Similar to the ‘Portfolio’ model, this will also send targets to the ‘Execution’ module to turn into orders.

Code Example

Let’s have a look at a real example!

Below is an embedded backtest from QuantConnect, with a simple example of a Buy and Hold strategy that buys SPY (ETF tracking S&P 500 Index) on the 1st of January 2015 and holds it until today. We will often be using this as a performance benchmark for our trading strategies.

Familiarize yourself with the Charts, the summary Statistics and the Code, and don’t forget to hit the CLONE ALGORITHM button below! It will make a copy of the code in your QuantConnect account so you can start playing with it.


At first, the code might look overly complex for a simple Buy and Hold strategy, but it’s a good way to illustrate how the different parts of the Algorithm Framework work together. As we continue to explain these parts in future posts, we will see how they interact with each other. Due to the modular design, if we understand how this basic strategy works, we can understand how the framework will work for any strategy. 

In the script, there is the below section for user-defined inputs that you can play with:

### user-defined inputs --------------------------------------------------------

self.SetStartDate(2015, 1, 1) # set start date
#self.SetEndDate(2019, 1, 1) # set end date
self.SetCash(100000) # set strategy cash
# add tickers to the list
tickers = ['SPY']
# rebalancing period (to enable rebalancing enter an integer for number of days, e.g. 1, 7, 30, 365)
rebalancingParam = False
### ---------------------------------------------------------------------------

Ideas to try (user-defined inputs in the script):

  • Play with the SetStartDate and SetEndDate dates to change the period of backtesting.
  • Add/change the tickers. For example, to select the FANG stocks simply change this line of code tickers = ['FB', 'AMZN', 'NFLX', 'GOOG']
  • Activate the rebalancing mechanism to ensure the portfolio goes back to equal weighting every so often. The rebalancingParam is set to False by default, but it can be set to a discretionary number of days to rebalance the portfolio. For instance, if you want to rebalance every 30 days simply do rebalancingParam = 30


Today we’ve introduced QuantConnect – the algorithmic trading platform we use to build our products.

The main takeaways from this post are:

  • QuantConnect allows you to backtest your trading strategies for free, coded in Python or C#.
  • It has a powerful modular design framework to develop your algorithms. This framework consists of five modules, each concerned with one part of a trading strategy, that interact with each other in a seamless way.
  • Like anything worthwhile, it takes time to learn and a lot more to master. But we’re here to help. We will be writing a series of posts to explain each of these modules with free Python code examples.

Do you have a strategy of your own that you would like to backtest and automate? Get in touch to learn more about our consulting services!

DISCLAIMER: The material on this website is provided for informational purposes only and does not constitute an offer to sell, a solicitation to buy, or a recommendation or endorsement for any security or strategy, nor does it constitute an offer to provide investment advisory services by InnoQuantivity. In addition, the material offers no opinion with respect to the suitability of any security or specific investment. InnoQuantivity makes no guarantees as to the accuracy or completeness of the views expressed in the website. The views are subject to change, and may have become unreliable for various reasons, including changes in market conditions or economic circumstances. All investments involve risk, including loss of principal. You should consult with an investment professional before making any investment decisions.

Author InnoQuantivity

More posts by InnoQuantivity

Join the discussion One Comment

Leave a Reply