---
title: "Individual Contracts"
description: "How to get data for individual Futures Options in the research environment in QuantConnect."
canonical: https://www.quantconnect.com/docs/v2/research-environment/datasets/futures-options/individual-contracts
markdown: https://www.quantconnect.com/docs/v2/research-environment/datasets/futures-options/individual-contracts.md
language: python
source: https://github.com/QuantConnect/Documentation/tree/master/04%20Research%20Environment/03%20Datasets/14%20Futures%20Options/03%20Individual%20Contracts
modified: 2026-11-01
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 Options > 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 Future Option contracts. The [history requests](https://www.quantconnect.com/docs/v2/research-environment/datasets/key-concepts.md) on this page only return the prices and open interest of the Option contracts, not their implied volatility or Greeks.

## Create Subscriptions

Follow these steps to subscribe to individual Futures Option contracts:

1. Create a `QuantBook`.
   ```python
   qb = QuantBook()
   ```
2. [Add the underlying Futures contract](https://www.quantconnect.com/docs/v2/research-environment/datasets/futures/individual-contracts.md#02-Create-Subscriptions).
   ```python
   future = qb.add_future(Futures.Indices.SP_500_E_MINI)
   start_date = datetime(2023, 12, 20)
   chain = list(qb.history[FutureUniverse](future.symbol, start_date, start_date+timedelta(2)))[0]
   futures_contract_symbol = list(chain)[0].symbol
   qb.add_future_contract(futures_contract_symbol, fill_forward=False)
   ```
   To view the available underlying Futures in the US Future Options dataset, see [Supported Assets](https://www.quantconnect.com/docs/v2/writing-algorithms/datasets/algoseek/us-future-options.md#08-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(futures_contract_symbol.id.date - timedelta(5))
   ```
   The method that you call in the next step returns data on all the contracts that were tradable on this date.
4. Call the `option_chain` method with the underlying Futures contract `Symbol`.
   ```python
   chain = qb.option_chain(futures_contract_symbol, flatten=True).data_frame
   ```
   This method returns an `OptionChain` object, which represent an entire chain of Option contracts for a single underlying security. 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 Futures Options contract(s) you want to analyze.
   ```python
   # Select a contract.
   expiry = chain.expiry.min()
   fop_contract_symbol = chain[
       # Select call contracts with the closest expiry.
       (chain.expiry == expiry) &
       (chain.right == OptionRight.CALL)
       # Select the contract with a strike price near the middle.
   ].sort_values('strike').index[150]
   ```
6. Call the `add_future_option_contract` method with an `OptionContract` Symbol and disable fill-forward.
   ```python
   option_contract = qb.add_future_option_contract(fop_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, fop_contract_symbol, timedelta(3))
display(history_df)

# TradeBar objects
history = qb.history[TradeBar](fop_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, fop_contract_symbol, timedelta(3))
display(history_df)

# QuoteBar objects
history = qb.history[QuoteBar](fop_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*

## 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, fop_contract_symbol, timedelta(3))
display(history_df)

# OpenInterest objects
history = qb.history[OpenInterest](fop_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*

## Greeks and IV History

The Greeks are measures that describe the sensitivity of an Option's price to various factors like underlying price changes (Delta), time decay (Theta), volatility (Vega), and interest rates (Rho), while Implied Volatility (IV) represents the market's expectation of the underlying asset's volatility over the life of the Option.

Follow these steps to get the Greeks and IV data:

1. Create the mirror contract `Symbol`.
   ```python
   mirror_contract_symbol = Symbol.create_option(
       option_contract.underlying.symbol,     fop_contract_symbol.id.market,
       option_contract.style,
       OptionRight.CALL if option_contract.right == OptionRight.PUT else OptionRight.PUT,
       option_contract.strike_price,
       option_contract.expiry
   )
   ```
2. Set up the [risk free interest rate](https://www.quantconnect.com/docs/v2/writing-algorithms/reality-modeling/risk-free-interest-rate/key-concepts.md), [dividend yield](https://www.quantconnect.com/docs/v2/writing-algorithms/reality-modeling/dividend-yield/key-concepts.md), and [Option pricing](https://www.quantconnect.com/docs/v2/writing-algorithms/reality-modeling/options-models/pricing.md) models.
   In [our research](https://www.quantconnect.com/research/16977/greeks-and-iv-implementation/p1), we found the Forward Tree model to be the best pricing model for indicators.
   ```python
   risk_free_rate_model = qb.risk_free_interest_rate_model
   dividend_yield_model = DividendYieldProvider(futures_contract_symbol)
   option_model = OptionPricingModelType.FORWARD_TREE
   ```
3. Define a method to return the [IV & Greeks indicator](https://www.quantconnect.com/docs/v2/writing-algorithms/securities/asset-classes/equity-options/greeks-and-implied-volatility/indicators.md) values for each contract.
   ```python
   def greeks_and_iv(contracts, period, risk_free_rate_model, dividend_yield_model, option_model):
       # Get the call and put contract.
       call, put = sorted(contracts, key=lambda s: s.id.option_right)

       def get_values(indicator_class, contract, mirror_contract):
           return qb.indicator_history(
               indicator_class(contract, risk_free_rate_model, dividend_yield_model, mirror_contract, option_model),
               [contract, mirror_contract, contract.underlying],
               period
           ).data_frame.current

       return pd.DataFrame({
           'iv_call': get_values(ImpliedVolatility, call, put),
           'iv_put': get_values(ImpliedVolatility, put, call),
           'delta_call': get_values(Delta, call, put),
           'delta_put': get_values(Delta, put, call),
           'gamma_call': get_values(Gamma, call, put),
           'gamma_put': get_values(Gamma, put, call),
           'rho_call': get_values(Rho, call, put),
           'rho_put': get_values(Rho, put, call),
           'vega_call': get_values(Vega, call, put),
           'vega_put': get_values(Vega, put, call),
           'theta_call': get_values(Theta, call, put),
           'theta_put': get_values(Theta, put, call),
       })
   ```
4. Call the preceding method and display the results.
   ```python
   greeks_and_iv([fop_contract_symbol, mirror_contract_symbol], 15, risk_free_rate_model, dividend_yield_model, option_model)
   ```

![DataFrame result of the preceding code snippets, containing the greeks and IV history.](https://cdn.quantconnect.com/i/tu/future-options-greeks-and-iv-history.png)

The DataFrame can have NaN entries if there is no data for the contracts or the underlying asset at a moment in time.

## Examples

The following examples demonstrate some common practices for analyzing individual Future Option contracts in the Research Environment.

### Example 1: Contract Mid-Price History

The following notebook plots the historical mid-prices of an E-mini S&P 500 Future Option contract using [Plotly](https://www.quantconnect.com/docs/v2/research-environment/charting/plotly.md):

```python
import plotly.graph_objects as go

# Add the underlying Future contract
# (the front-month ES Future contract as of December 12, 2023).
qb = QuantBook()
future = qb.add_future(Futures.Indices.SP_500_E_MINI)
start_date = datetime(2023, 12, 20)
chain = list(qb.history[FutureUniverse](future.symbol, start_date, start_date+timedelta(2)))[0]
futures_contract_symbol = list(chain)[0].symbol
qb.add_future_contract(futures_contract_symbol, fill_forward=False)

# Get the Future Option chain as of 5 days before the underlying Future's expiry date.
qb.set_start_date(futures_contract_symbol.id.date - timedelta(5))
chain = qb.option_chain(futures_contract_symbol, flatten=True).data_frame

# Select a Future Option contract from the chain.
expiry = chain.expiry.min()
fop_contract_symbol = chain[
    (chain.expiry == expiry) & (chain.right == OptionRight.CALL)
].sort_values('strike').index[50]

# Add the target Future Option contract.
qb.add_future_option_contract(fop_contract_symbol)

# Get the Future Option contract quote history.
history = qb.history(QuoteBar, fop_contract_symbol, datetime(2024, 2, 22), datetime(2024, 2, 23))

# Plot the mid-price values of the quote history.
go.Figure(
    data=go.Candlestick(
        x=history.index.levels[4],
        open=history['open'],
        high=history['high'],
        low=history['low'],
        close=history['close']
    ),
    layout=go.Layout(
        title=go.layout.Title(text=f'{fop_contract_symbol.value} OHLC'),
        xaxis_title='Date',
        yaxis_title='Price',
        xaxis_rangeslider_visible=False
    )
).show()
```

![Candlestick plot of the prices for an ES Future Option contract](https://cdn.quantconnect.com/i/tu/future-options-price-example-python.png)
