Welcome to The QuantConnect Research Page

Refer to this page for documentation

Contribute to this template file

QuantBook Basics

Start QuantBook

  • Add the references and imports
  • Create a QuantBook instance

In [ ]:
%matplotlib inline
# Imports
from clr import AddReference
from System import *
from QuantConnect import *
from QuantConnect.Data.Custom import *
from QuantConnect.Data.Market import TradeBar, QuoteBar
from QuantConnect.Research import *
from QuantConnect.Indicators import *
from datetime import datetime, timedelta
import matplotlib.pyplot as plt
import pandas as pd

# Create an instance
qb = QuantBook()

# Select asset data
spy = qb.AddEquity("SPY")

Historical Data Requests

We can use the QuantConnect API to make Historical Data Requests. The data will be presented as multi-index pandas.DataFrame where the first index is the Symbol.

For more information, please follow the link.

In [ ]:
# Gets historical data from the subscribed assets, the last 360 datapoints with daily resolution
h1 = qb.History(qb.Securities.Keys, 360, Resolution.Daily)

# Plot closing prices from "SPY" 


We can easily get the indicator of a given symbol with QuantBook.

For all indicators, please checkout QuantConnect Indicators Reference Table

In [ ]:
# Example with BB, it is a datapoint indicator
# Define the indicator
bb = BollingerBands(30, 2)

# Gets historical data of indicator
bbdf = qb.Indicator(bb, "SPY", 360, Resolution.Daily)

# drop undesired fields
bbdf = bbdf.drop('standarddeviation', 1)

# Plot