Futures Options
Universes
Create Subscriptions
Follow these steps to subscribe to a Futures Options universe:
- Load the assembly files and data types in their own cell.
- Import the data types.
- Create a
QuantBook
. - Add the underlying Future.
#load "../Initialize.csx"
#load "../QuantConnect.csx" #r "../Microsoft.Data.Analysis.dll" using QuantConnect; using QuantConnect.Data; using QuantConnect.Algorithm; using QuantConnect.Research; using QuantConnect.Indicators; using QuantConnect.Securities; using QuantConnect.Data.UniverseSelection; using Microsoft.Data.Analysis;
var qb = new QuantBook();
qb = QuantBook()
var future = qb.AddFuture(Futures.Indices.SP500EMini);
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 OptionHistory
option_history
method with the Future contract's Symbol
object, a start DateTime
datetime
, and an end DateTime
datetime
.
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 )
var startDate = new DateTime(2024, 1, 1); // Select an underlying Futures contract. For example, get the front-month contract. var chain = qb.History<FutureUniverse>(future.Symbol, startDate, startDate.AddDays(2)).First(); var futuresContract = chain.First().Symbol; // Get the Options data for the selected Futures contract. var optionHistory = qb.OptionHistory( futuresContract, startDate, futuresContract.ID.Date, Resolution.Hour, fillForward: false, extendedMarketHours: 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
askclose | askhigh | asklow | askopen | asksize | bidclose | bidhigh | bidlow | bidopen | bidsize | close | high | low | open | volume | |||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
expiry | strike | type | symbol | time | |||||||||||||||
2024-03-15 | 4575.0 | 0 | ES YGT6I1W1ONB8|ES YGT6HGVF2SQP | 2024-01-02 10:00:00 | 262.0 | 316.50 | 248.75 | 256.0 | 1.0 | 247.25 | 257.25 | 187.25 | 253.50 | 1.0 | 254.625 | 286.875 | 218.000 | 254.750 | NaN |
2024-01-02 11:00:00 | 250.5 | 300.00 | 248.25 | 262.0 | 2.0 | 248.50 | 256.50 | 215.00 | 247.25 | 2.0 | 249.500 | 278.250 | 231.625 | 254.625 | NaN | ||||
2024-01-02 12:00:00 | 261.0 | 300.00 | 250.00 | 250.5 | 1.0 | 259.25 | 259.75 | 216.25 | 248.50 | 1.0 | 260.125 | 279.875 | 233.125 | 249.500 | NaN | ||||
... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | |
5215.0 | 1 | ES 32FX6NKT3COAS|ES YGT6HGVF2SQP | 2024-03-14 15:00:00 | 70.5 | 92.25 | 58.00 | 64.5 | 2.0 | 69.75 | 70.25 | 36.75 | 52.00 | 1.0 | 70.125 | 81.250 | 47.375 | 58.250 | NaN | |
2024-03-14 16:00:00 | 75.0 | 183.50 | 63.25 | 70.5 | 10.0 | 44.75 | 89.75 | 2.10 | 69.75 | 10.0 | 67.750 | 67.750 | 67.750 | 67.750 | 1.0 | ||||
2024-03-14 17:00:00 | 63.5 | 84.00 | 58.00 | 75.0 | 1.0 | 58.50 | 61.50 | 35.50 | 44.75 | 1.0 | 61.000 | 72.750 | 46.750 | 59.875 | NaN |
To get the expiration dates of all the contracts in an OptionHistory
object, call the GetExpiryDates
get_expiry_dates
method.
option_history.get_expiry_dates()

To get the strike prices of all the contracts in an OptionHistory
object, call the GetStrikes
get_strikes
method.
option_history.get_strikes()

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.
// Load the required assembly files and data types in a separate cell. #load "../Initialize.csx" #load "../QuantConnect.csx" using System; using System.Collections.Generic; using QuantConnect; using QuantConnect.Data; using QuantConnect.Data.Market; using QuantConnect.Data.UniverseSelection; using QuantConnect.Algorithm; using QuantConnect.Research; // Import Plotly for plotting. #r "../Plotly.NET.dll" using Plotly.NET; using Plotly.NET.LayoutObjects; // Create a QuantBook. var qb = new QuantBook(); // Set the date being studied. var date = new DateTime(2024, 1, 4); // Subscribe to the underlying Future. var future = qb.AddFuture(Futures.Indices.SP500EMini); // Select the front-month contract. var chain = qb.History<FutureUniverse>(future.Symbol, date, date.AddDays(2)).First(); var futuresContract = chain.First().Symbol; // Get the Options data for the selected Futures contract at the selected date. var optionHistory = qb.OptionHistory( futuresContract, date.AddDays(-1), date, Resolution.Daily, fillForward: false, extendedMarketHours: false ).Last(); var chain = optionHistory.OptionChains.Values.First(); // Study the closest expiring contracts. var expiry = chain.Min(x => x.Expiry); // Filter for the closest expiring calls to study only. var filterContracts = chain.Where(x => x.Expiry == expiry && x.Right == OptionRight.Call).ToList(); // Obtain the strike and IV for plotting the IV curve. var ivByStrike = new Dictionary<decimal, decimal>(); foreach (var contract in filterContracts) { var strike = contract.Strike; var iv = contract.ImpliedVolatility; ivByStrike[strike] = iv; } // Crete the Line Chart with the PE Ratios. var chart = Chart2D.Chart.Line<decimal, decimal, string>( ivByStrike.Keys, ivByStrike.Values ); // Create a Layout as the plot settings. LinearAxis xAxis = new LinearAxis(); xAxis.SetValue("title", "Strike"); LinearAxis yAxis = new LinearAxis(); yAxis.SetValue("title", "Implied Volatility"); Title title = Title.init($"IV Curve of {futuresContract}"); Layout layout = new Layout(); layout.SetValue("xaxis", xAxis); layout.SetValue("yaxis", yAxis); layout.SetValue("title", title); // Assign the Layout to the chart. chart.WithLayout(layout); // Display the plot. HTML(GenericChart.toChartHTML(chart))
# 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")