book
Checkout our new book! Hands on AI Trading with Python, QuantConnect, and AWS Learn More arrow

Futures Options

Universes

Introduction

This page explains how to request historical data for a universe of Future Option contracts.

Create Subscriptions

Follow these steps to subscribe to a Futures Options universe:

  1. Create a QuantBook.
  2. Select Language:
    qb = QuantBook()
  3. Add the underlying Future.
  4. Select Language:
    future = qb.add_future(Futures.Indices.SP_500_E_MINI)

    To view the available underlying Futures in the US Future Options dataset, see Supported Assets.

Price History

The contract filter determines which Future Option contracts are in your universe each trading day. The default filter selects the contracts with the following characteristics:

  • Standard type (weeklies and non-standard contracts are not available)
  • Within 1 strike price of the underlying asset price
  • Expire within 35 days

To get the prices and volumes for all of the Future Option contracts that pass your filter during a specific period of time, get the underlying Future contract and then call the option_history method with the Future contract's Symbol object, a start datetime, and an end datetime.

Select Language:
start_date = datetime(2024, 1, 1)

# Select an underlying Futures contract. For example, get the front-month contract.
chain = list(qb.history[FutureUniverse](future.symbol, start_date, start_date+timedelta(2)))[0]
futures_contract = list(chain)[0].symbol

# Get the Options data for the selected Futures contract.
option_history = qb.option_history(
    futures_contract, start_date, futures_contract.id.date, Resolution.HOUR, 
    fill_forward=False, extended_market_hours=False
)

To convert the OptionHistory object to a DataFrame that contains the trade and quote information of each contract and the underlying, use the data_frame property.

option_history.data_frame
askcloseaskhighasklowaskopenasksizebidclosebidhighbidlowbidopenbidsizeclosehighlowopenvolume
expirystriketypesymboltime
2024-03-154575.00ES YGT6I1W1ONB8|ES YGT6HGVF2SQP2024-01-02 10:00:00262.0316.50248.75256.01.0247.25257.25187.25253.501.0254.625286.875218.000254.750NaN
2024-01-02 11:00:00250.5300.00248.25262.02.0248.50256.50215.00247.252.0249.500278.250231.625254.625NaN
2024-01-02 12:00:00261.0300.00250.00250.51.0259.25259.75216.25248.501.0260.125279.875233.125249.500NaN
.........................................................
5215.01ES 32FX6NKT3COAS|ES YGT6HGVF2SQP2024-03-14 15:00:0070.592.2558.0064.52.069.7570.2536.7552.001.070.12581.25047.37558.250NaN
2024-03-14 16:00:0075.0183.5063.2570.510.044.7589.752.1069.7510.067.75067.75067.75067.7501.0
2024-03-14 17:00:0063.584.0058.0075.01.058.5061.5035.5044.751.061.00072.75046.75059.875NaN

To get the expiration dates of all the contracts in an OptionHistory object, call the method.

option_history.get_expiry_dates()
list of expiry dates

To get the strike prices of all the contracts in an OptionHistory object, call the method.

option_history.get_strikes()
List of strike prices

Examples

The following examples demonstrate some common practices for applying the Future Options dataset.

Example 1: Implied Volatility Line Chart

The following example plots a line chart on the implied volatility curve of the cloest expiring calls.

Select Language:
# Instantiate a QuantBook instance.
qb = QuantBook()
# Set the date being studied.
date = datetime(2024, 1, 4)

# Subscribe to the underlying Future.
future = qb.add_future(Futures.Indices.SP_500_E_MINI)
# Select an underlying Futures contract. For example, get the front-month contract.
chain = list(qb.history[FutureUniverse](future.symbol, date, date+timedelta(2)))[0]
futures_contract = list(chain)[0].symbol
# Get the Options data for the selected Futures contract.
option_history = qb.option_history(
    futures_contract, date - timedelta(1), date, Resolution.DAILY, 
    fill_forward=False, extended_market_hours=False
)

chain = list(option_history)[-1].OptionChains.values()[0]
# Study the closest expiring contracts.
expiry = min(x.expiry for x in chain)
# Filter for the closest expiring calls to study only.
filter_contracts = [x for x in chain if x.expiry == expiry and x.right == OptionRight.CALL]

# Obtain the strike and IV for plotting the IV curve.
iv_by_strike = pd.Series({x.strike: x.implied_volatility for x in filter_contracts})
iv_by_strike.plot(title=f"IV Curve of {futures_contract}", ylabel="Implied Volatility", xlabel="Strike")

You can also see our Videos. You can also get in touch with us via Discord.

Did you find this page helpful?

Contribute to the documentation: