---
title: "Individual Contracts"
description: "This page explains how to request historical data for individual Futures contracts."
canonical: https://www.quantconnect.com/docs/v2/research-environment/datasets/futures/individual-contracts
markdown: https://www.quantconnect.com/docs/v2/research-environment/datasets/futures/individual-contracts.md
language: python
source: https://github.com/QuantConnect/Documentation/tree/master/04%20Research%20Environment/03%20Datasets/12%20Futures/03%20Individual%20Contracts
modified: 2026-10-31
index: https://www.quantconnect.com/llms.txt
---

# Individual Contracts

[Documentation](https://www.quantconnect.com/docs/v2.md) > [Research Environment](https://www.quantconnect.com/docs/v2/research-environment.md) > Datasets > Futures > Individual Contracts

> Code examples are shown in Python. Append `?lang=csharp` to this URL for the C# version of this page.

## Introduction

This page explains how to request historical data for individual Futures contracts.

## Create Subscriptions

Follow these steps to subscribe to a Future security:

1. Create a `QuantBook`.
   ```python
   qb = QuantBook()
   ```
2. Call the `add_future` method with a ticker.
   ```python
   future = qb.add_future(Futures.Indices.SP_500_E_MINI)
   ```
   To view the supported assets in the US Futures dataset, see [Supported Assets](https://www.quantconnect.com/docs/v2/writing-algorithms/datasets/algoseek/us-futures.md#09-Supported-Assets).
3. [Set the start date](https://www.quantconnect.com/docs/v2/research-environment/initialization.md#02-Set-Dates) to a date in the past that you want to use as the analysis date.
   ```python
   qb.set_start_date(2024, 1, 1)
   ```
   The method that you call in the next step returns data on all the contracts that were tradable on this date.
4. Call the `future_chain` method with the `Symbol` of the continuous Futures contract.
   ```python
   # Get the Futures contracts that were tradable on January 1st, 2024.
   chain = qb.future_chain(future.symbol, flatten=True)
   ```
   This method returns a `FutureChain` object, which represent an entire chain of Futures contracts. You can even format the chain data into a DataFrame where each row in the DataFrame represents a single contract.
5. Sort and filter the data to select the specific contract(s) you want to analyze.
   ```python
   # Get the contracts available to trade (in DataFrame format).
   chain = chain.data_frame

   # Select a contract.
   contract_symbol = chain[
       # Select contracts that have at least 1 week before expiry.
       chain.expiry > qb.time + timedelta(7)
       # Select the contract with the largest open interest.
   ].sort_values('openinterest').index[-1]
   ```
6. Call the `add_future_contract` method with a `FutureContract` `Symbol` and disable fill-forward.
   ```python
   qb.add_future_contract(contract_symbol, fill_forward=False)
   ```
   Disable fill-forward because there are only a few `OpenInterest` data points per day.

## Trade History

`TradeBar` objects are price bars that consolidate individual trades from the exchanges. They contain the open, high, low, close, and volume of trading activity over a period of time.

![Tradebar decomposition](https://cdn.quantconnect.com/docs/i/dataformat-tradebar.png)

To get trade data, call the `history` or `history[TradeBar]` method with the contract `Symbol` object(s).

```python
# DataFrame format
history_df = qb.history(TradeBar, contract_symbol, timedelta(3))
display(history_df)

# TradeBar objects
history = qb.history[TradeBar](contract_symbol, timedelta(3))
for trade_bar in history:
    print(trade_bar)
```

`TradeBar` objects have the following properties:

*Members of `QuantConnect.Data.Market.TradeBar` (JSON): https://www.quantconnect.com/services/inspector?type=T:QuantConnect.Data.Market.TradeBar&language=python*

## Quote History

`QuoteBar` objects are bars that consolidate NBBO quotes from the exchanges. They contain the open, high, low, and close prices of the bid and ask. The `open`, `high`, `low`, and `close` properties of the `QuoteBar` object are the mean of the respective bid and ask prices. If the bid or ask portion of the `QuoteBar` has no data, the `open`, `high`, `low`, and `close` properties of the `QuoteBar` copy the values of either the `bid` or `ask` instead of taking their mean.

![Quotebar decomposition](https://cdn.quantconnect.com/docs/i/dataformat-quotebar.png)

To get quote data, call the `history` or `history[QuoteBar]` method with the contract `Symbol` object(s).

```python
# DataFrame format
history_df = qb.history(QuoteBar, contract_symbol, timedelta(3))
display(history_df)

# QuoteBar objects
history = qb.history[QuoteBar](contract_symbol, timedelta(3))
for quote_bar in history:
    print(quote_bar)
```

`QuoteBar` objects have the following properties:

*Members of `QuantConnect.Data.Market.QuoteBar` (JSON): https://www.quantconnect.com/services/inspector?type=T:QuantConnect.Data.Market.QuoteBar&language=python*

## Tick History

`Tick` objects represent a single trade or quote at a moment in time. A trade tick is a record of a transaction for the security. A quote tick is an offer to buy or sell the security at a specific price.

Trade ticks have a non-zero value for the `quantity` and `price` properties, but they have a zero value for the `bid_price`, `bid_size`, `ask_price`, and `ask_size` properties. Quote ticks have non-zero values for `bid_price` and `bid_size` properties or have non-zero values for `ask_price` and `ask_size` properties. To check if a tick is a trade or a quote, use the `ticktype` property.

To get tick data, call the `history` or `history[Tick]` method with the contract Symbol object(s) and `Resolution.TICK`.

```python
# DataFrame format
history_df = qb.history(contract_symbol, timedelta(3), Resolution.TICK)
display(history_df)

# Tick objects
history = qb.history[Tick](contract_symbol, timedelta(3), Resolution.TICK)
for tick in history:
    print(tick)
```

`Tick` objects have the following properties:

*Members of `QuantConnect.Data.Market.Tick` (JSON): https://www.quantconnect.com/services/inspector?type=T:QuantConnect.Data.Market.Tick&language=python*

Tick data is grouped into one millisecond buckets. Ticks are a sparse dataset, so request ticks over a trailing period of time or between start and end times.

## Open Interest History

Open interest is the number of outstanding contracts that haven't been settled. It provides a measure of investor interest and the market liquidity, so it's a popular metric to use for contract selection. Open interest is calculated once per day.

To get open interest data, call the `history` or `history[OpenInterest]` method with the contract `Symbol` object(s).

```python
# DataFrame format
history_df = qb.history(OpenInterest, contract_symbol, timedelta(3))
display(history_df)

# OpenInterest objects
history = qb.history[OpenInterest](contract_symbol, timedelta(3))
for open_interest in history:
    print(open_interest)
```

`OpenInterest` objects have the following properties:

*Members of `QuantConnect.Data.Market.OpenInterest` (JSON): https://www.quantconnect.com/services/inspector?type=T:QuantConnect.Data.Market.OpenInterest&language=python*

## Examples

The following examples demonstrate some common practices for analyzing Futures data.

### Example 1: Candlestick Chart

The following cell creates a [candlestick plot](https://www.quantconnect.com/docs/v2/research-environment/charting/plotly.md#05-Create-Candlestick-Chart) for the front-month ES contract:

```python
import plotly.graph_objects as go

qb = QuantBook()
# Get the front-month ES contract as of December 31, 2021.
future = qb.add_future(Futures.Indices.SP_500_E_MINI)
qb.set_start_date(2021, 12, 31)
chain = qb.future_chain(future.symbol)
contract_symbol = list(chain)[0].symbol
# Get the trailing 30 days of trade data for this contract.
history = qb.history(contract_symbol, timedelta(30), Resolution.DAILY).loc[contract_symbol.id.date, contract_symbol]
# Create a candlestick plot with the data.
go.Figure(
    data=go.Candlestick(
        x=history.index,
        open=history['open'],
        high=history['high'],
        low=history['low'],
        close=history['close']
    ),
    layout=go.Layout(
        title=go.layout.Title(text=f'{contract_symbol.value} OHLC'),
        xaxis_title='Date',
        yaxis_title='Price',
        xaxis_rangeslider_visible=False
    )
).show()
```

![Candlestick plot of ES18H22 OHLC](https://cdn.quantconnect.com/i/tu/futures-candlestick-plot.jpg)

### Example 2: Line Chart

The following cell creates a [line plot](https://www.quantconnect.com/docs/v2/research-environment/charting/matplotlib.md#06-Create-Line-Plot) for all the tradable ES contracts:

```python
import plotly.graph_objects as go

qb = QuantBook()
# Get all the ES contract that were tradable on December 18, 2021.
future = qb.add_future(Futures.Indices.SP_500_E_MINI)
qb.set_start_date(2021, 12, 18)
chain = qb.future_chain(future.symbol)
contract_symbols = [c.symbol for c in chain]
# Get the trailing trade data for these contracts.
history = qb.history(contract_symbols, timedelta(17), Resolution.DAILY)
history.index = history.index.droplevel(0)
closing_prices = history['close'].unstack(level=0)
# Rename the DataFrame columns so the plot legend is readable.
closing_prices.columns = [Symbol.get_alias(x.id) for x in closing_prices.columns]
# Create the line plot.
closing_prices.plot(title="Close", figsize=(15, 8));
```

![Line chart of close price of Future contracts](https://cdn.quantconnect.com/i/tu/futures-line-plot.jpg)
