---
title: "Future Options"
description: "Some of the Future Options data you can get include prices and indicator data."
canonical: https://www.quantconnect.com/docs/v2/writing-algorithms/historical-data/asset-classes/future-options
markdown: https://www.quantconnect.com/docs/v2/writing-algorithms/historical-data/asset-classes/future-options.md
language: python
source: https://github.com/QuantConnect/Documentation/tree/master/03%20Writing%20Algorithms/20%20Historical%20Data/04%20Asset%20Classes/07%20Future%20Options
modified: 2026-10-31
index: https://www.quantconnect.com/llms.txt
---

# Future Options

[Documentation](https://www.quantconnect.com/docs/v2.md) > [Writing Algorithms](https://www.quantconnect.com/docs/v2/writing-algorithms.md) > Historical Data > Asset Classes > Future Options

> 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 get historical data for Future Options. Some of the data you can get include prices and indicator data.

## Trades

To get historical [trade data](https://www.quantconnect.com/docs/v2/writing-algorithms/securities/asset-classes/future-options/handling-data.md#02-Trades), call the `history` method with the `TradeBar` type and a security's `Symbol`. This method returns a DataFrame with columns for the open, high, low, close, and volume.

```python
class FutureOptionsTradeBarHistoryAlgorithm(QCAlgorithm):

    def initialize(self) -> None:
        self.set_start_date(2024, 12, 19)
        self.set_end_date(2024, 12, 31)
        # Add a FOP universe.
        future = self.add_future(Futures.Indices.SP_500_E_MINI)
        future.set_filter(lambda universe: universe.front_month())
        self.add_future_option(future.symbol, lambda universe: universe.front_month().strikes(-1, 0).calls_only())

    # Get trailing data whenever a new FOP contract enters the universe.
    def on_securities_changed(self, changes):
        for security in changes.added_securities:
            if security.type == SecurityType.FUTURE_OPTION:
                # Get the 3 trailing daily TradeBar objects of the security in DataFrame format.
                history = self.history(TradeBar, security.symbol, 3, Resolution.DAILY)
```

| expiry | strike | type | symbol | time | close | high | low | open | volume |
| --- | --- | --- | --- | --- | --- | --- | --- | --- | --- |
| 2024-12-20 | 5870.0 | 1 | ES 32NKVT5YYX1US\|ES YOGVNNAOI1OH | 2024-12-16 17:00:00 | 2.15 | 2.15 | 1.45 | 1.80 | 227.0 |
| 2024-12-20 | 5870.0 | 1 | ES 32NKVT5YYX1US\|ES YOGVNNAOI1OH | 2024-12-17 17:00:00 | 2.35 | 3.05 | 2.30 | 2.30 | 14.0 |
| 2024-12-20 | 5870.0 | 1 | ES 32NKVT5YYX1US\|ES YOGVNNAOI1OH | 2024-12-18 17:00:00 | 38.75 | 43.75 | 1.75 | 1.85 | 399.0 |

```python
# Calculate the daily returns.
daily_returns = history.close.pct_change().iloc[1:]
```

```python
expiry      strike  type  symbol                            time
2024-12-20  5870.0  1     ES 32NKVT5YYX1US|ES YOGVNNAOI1OH  2024-12-17 17:00:00     0.093023
                                                            2024-12-18 17:00:00    15.489362
Name: close, dtype: float64
```

If you intend to use the data in the DataFrame to create `TradeBar` objects, request that the history request returns the data type you need. Otherwise, LEAN consumes unnecessary computational resources populating the DataFrame. To get a list of `TradeBar` objects instead of a DataFrame, call the `history[TradeBar]` method.

```python
# Get the 3 trailing daily TradeBar objects of the security in TradeBar format.
history = self.history[TradeBar](symbol, 3, Resolution.DAILY)
# Iterate through the TradeBar objects and access their volumes.
for trade_bar in history:
    t = trade_bar.end_time
    volume = trade_bar.volume
```

Request minute, hour, or daily resolution data. Otherwise, the history request won't return any data.

## Quotes

To get historical [quote data](https://www.quantconnect.com/docs/v2/writing-algorithms/securities/asset-classes/future-options/handling-data.md#03-Quotes), call the `history` method with the `QuoteBar` type and a security's `Symbol`. This method returns a DataFrame with columns for the open, high, low, close, and size of the bid and ask quotes. The columns that don't start with "bid" or "ask" are the mean of the quote prices on both sides of the market.

```python
class FutureOptionsQuoteBarHistoryAlgorithm(QCAlgorithm):

    def initialize(self) -> None:
        self.set_start_date(2024, 12, 19)
        self.set_end_date(2024, 12, 31)
        # Add a FOP universe.
        future = self.add_future(Futures.Indices.SP_500_E_MINI)
        future.set_filter(lambda universe: universe.front_month())
        self.add_future_option(future.symbol, lambda universe: universe.front_month().strikes(-1, 0).calls_only())

    # Get trailing data whenever a new FOP contract enters the universe.
    def on_securities_changed(self, changes):
        for security in changes.added_securities:
            if security.type == SecurityType.FUTURE_OPTION:
                # Get the 3 trailing daily QuoteBar objects of the security in DataFrame format.
                history = self.history(QuoteBar, security.symbol, 3, Resolution.DAILY)
```

| expiry | strike | type | symbol | time | askclose | askhigh | asklow | askopen | asksize | bidclose | bidhigh | bidlow | bidopen | bidsize | close | high | low | open |
| --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- |
| 2024-12-20 | 5870.0 | 1 | ES 32NKVT5YYX1US\|ES YOGVNNAOI1OH | 2024-12-16 17:00:00 | 2.5 | 2.55 | 1.45 | 1.85 | 2.0 | 2.35 | 2.40 | 1.35 | 1.75 | 46.0 | 2.425 | 2.475 | 1.4 | 1.800 |
| 2024-12-20 | 5870.0 | 1 | ES 32NKVT5YYX1US\|ES YOGVNNAOI1OH | 2024-12-17 17:00:00 | 2.7 | 3.15 | 2.15 | 3.05 | 179.0 | 2.45 | 3.05 | 2.05 | 2.90 | 46.0 | 2.575 | 3.100 | 2.1 | 2.975 |
| 2024-12-20 | 5870.0 | 1 | ES 32NKVT5YYX1US\|ES YOGVNNAOI1OH | 2024-12-18 17:00:00 | 40.0 | 215.50 | 1.55 | 2.30 | 3.0 | 36.50 | 60.50 | 0.05 | 2.15 | 2.0 | 38.250 | 138.000 | 0.8 | 2.225 |

```python
# Calculate the spread.
spread = history.askclose - history.bidclose
```

```python
expiry      strike  type  symbol                            time
2024-12-20  5870.0  1     ES 32NKVT5YYX1US|ES YOGVNNAOI1OH  2024-12-16 17:00:00    0.15
                                                            2024-12-17 17:00:00    0.25
                                                            2024-12-18 17:00:00    3.50
dtype: float64
```

If you intend to use the data in the DataFrame to create `QuoteBar` objects, request that the history request returns the data type you need. Otherwise, LEAN consumes unnecessary computational resources populating the DataFrame. To get a list of `QuoteBar` objects instead of a DataFrame, call the `history[QuoteBar]` method.

```python
# Get the 3 trailing daily QuoteBar objects of the security in QuoteBar format.
history = self.history[QuoteBar](symbol, 3, Resolution.DAILY)
# Iterate through each QuoteBar and calculate the dollar volume on the bid.
for quote_bar in history:
    t = quote_bar.end_time
    bid_dollar_volume = quote_bar.last_bid_size * quote_bar.bid.close
```

Request minute, hour, or daily resolution data. Otherwise, the history request won't return any data.

## Slices

To get historical [Slice](https://www.quantconnect.com/docs/v2/writing-algorithms/key-concepts/time-modeling/timeslices.md) data, call the `history` method without passing any `Symbol` objects. This method returns `Slice` objects, which contain data points from all the datasets in your algorithm. If you omit the `resolution` argument, it uses the resolution that you set for each security and dataset when you created the subscriptions.

```python
class SliceHistoryAlgorithm(QCAlgorithm):

    def initialize(self) -> None:
        self.set_start_date(2024, 12, 19)
        self.set_end_date(2024, 12, 31)
        # Add some securities and datasets.
        future = self.add_future(Futures.Indices.SP_500_E_MINI)
        future.set_filter(lambda universe: universe.front_month())
        self.add_future_option(future.symbol, lambda universe: universe.front_month().strikes(-1, 0).calls_only())
        # Add a Scheduled Event that runs at the start of each month.
        self.schedule.on(self.date_rules.month_start(future.symbol), self.time_rules.after_market_open(future.symbol, 60), self._trade)

    def _trade(self):
        # Get the historical Slice objects over the last 30 minutes for all the subcriptions in your algorithm.
        for slice_ in self.history(30, Resolution.MINUTE):
            # Iterate through each TradeBar in this Slice.
            for symbol, trade_bar in slice_.bars.items():
                close = trade_bar.close
```

## Indicators

To get historical [indicator](https://www.quantconnect.com/docs/v2/writing-algorithms/indicators/key-concepts.md) values, call the `indicator_history` method with an indicator and the security's `Symbol`.

```python
class FutureOptionIndicatorHistoryAlgorithm(QCAlgorithm):

    def initialize(self) -> None:
        self.set_start_date(2024, 12, 19)
        self.set_end_date(2024, 12, 31)
        # Add a FOP universe.
        future = self.add_future(Futures.Indices.SP_500_E_MINI)
        future.set_filter(lambda universe: universe.front_month())
        self.add_future_option(future.symbol, lambda universe: universe.front_month().strikes(0, 0).calls_only())

    def on_securities_changed(self, changes):
        for security in changes.added_securities:
            if security.type != SecurityType.FUTURE_OPTION:
                continue
            # Get the 21-day SMA values of the contract for the last 5 trading days.
            history = self.indicator_history(SimpleMovingAverage(21), security.symbol, 5, Resolution.DAILY)
```

To organize the data into a DataFrame, use the `data_frame` property of the result.

```python
# Organize the historical indicator data into a DataFrame to enable pandas wrangling.
history_df = history.data_frame
```

|  | current | rollingsum |
| --- | --- | --- |
| 2024-12-12 17:00:00 | 131.404762 | 2759.500 |
| 2024-12-13 17:00:00 | 132.101190 | 2774.125 |
| 2024-12-16 17:00:00 | 135.779762 | 2851.375 |
| 2024-12-17 17:00:00 | 138.047619 | 2899.000 |
| 2024-12-18 17:00:00 | 134.095238 | 2816.000 |

```python
# Get the maximum of the SMA values.
sma_max = history_df.current.max()
```

The `indicator_history` method resets your indicator, makes a history request, and updates the indicator with the historical data. Just like with regular history requests, the `indicator_history` method supports time periods based on a trailing number of bars, a trailing period of time, or a defined period of time. If you don't provide a `resolution` argument, it defaults to match the resolution of the security subscription.

To make the `indicator_history` method update the indicator with an [alternative price field](https://www.quantconnect.com/docs/v2/writing-algorithms/indicators/automatic-indicators.md#07-Alternative-Price-Fields) instead of the close (or mid-price) of each bar, pass a `selector` argument.

```python
# Get the historical values of an indicator over the last 30 days, applying the indicator to the contract's volume.
history = self.indicator_history(indicator, symbol, timedelta(30), selector=Field.VOLUME)
```

Some indicators require the prices of multiple securities to compute their value (for example, the [indicators for the Greeks and implied volatility](https://www.quantconnect.com/docs/v2/writing-algorithms/securities/asset-classes/future-options/greeks-and-implied-volatility/indicators.md)). In this case, pass a list of the `Symbol` objects to the method.

```python
class FutureOptionMultiAssetIndicatorHistoryAlgorithm(QCAlgorithm):

    def initialize(self) -> None:
        self.set_start_date(2024, 12, 19)
        self.set_end_date(2024, 12, 31)
        # Add a FOP universe.
        future = self.add_future(Futures.Indices.SP_500_E_MINI)
        future.set_filter(lambda universe: universe.front_month())
        self.add_future_option(future.symbol, lambda universe: universe.front_month().strikes(0, 0).calls_only())

    def on_securities_changed(self, changes):
        for security in changes.added_securities:
            if security.type != SecurityType.FUTURE_OPTION:
                continue
            option = security.symbol
            # Get the Symbol of the mirror contract.
            mirror = Symbol.create_option(
                option.underlying, option.id.market, option.id.option_style,
                OptionRight.CALL if option.id.option_right == OptionRight.PUT else OptionRight.PUT,
                option.id.strike_price, option.id.date
            )
            # Create the indicator.
            indicator = ImpliedVolatility(
                option, self.risk_free_interest_rate_model, ConstantDividendYieldModel(0),
                mirror, OptionPricingModelType.FORWARD_TREE
            )
            # Get the historical values of the indicator over the last 10 minutes.
            history = self.indicator_history(indicator, [option.underlying, option, mirror], 10, Resolution.MINUTE)
            # Get the average IV value.
            iv_avg = history.data_frame.current.mean()
```

## Examples

The following examples demonstrate some common practices for trading Future Options with historical data.

### Example 1: Trend Following on Front Month ATM Option Contract

This algorithm strategically trades the front month S&P 500 EMini Future Options by analyzing bid and ask volumes shortly after the market opens. Using scheduled events, it effectively executes trades based on historical quote data, optimizing decision-making. The algorithm aims for timely entries and exits, ensuring efficient capital management and quick adaptability in volatile markets.

```python
class FutureOptionsTradingAlgorithm(QCAlgorithm):
    def initialize(self) -> None:
        self.set_start_date(2024, 9, 1)
        self.set_end_date(2024, 12, 31)  # Limit to a single day for 0DTE
        self.set_cash(200000)  # Starting cash

        # Request ES option data for trading and signal generation.
        future = self.add_future(Futures.Indices.SP_500_E_MINI)
        future.set_filter(lambda universe: universe.front_month())
        # We are interested in ATM front-month options since they are the most popular.
        self.add_future_option(future.symbol, lambda u: u.expiration(0, 90).strikes(-3, 3))

        # Schedule event to enter and exit option contract position.
        self.schedule.on(self.date_rules.every_day(future.symbol), self.time_rules.after_market_open(future.symbol, 16), self.trade_option)
        self.schedule.on(self.date_rules.every_day(future.symbol), self.time_rules.before_market_close(future.symbol, 15), self.liquidate)

    def trade_option(self) -> None:
        # Get the option chain to trade.
        for option_chain in self.current_slice.option_chains.values():
            for option in option_chain:
                # Request historical quote data for signal generation.
                history = self.history(QuoteBar, option.symbol, 15, Resolution.MINUTE)
                if not history.empty:
                    # Calculate the total bid and ask for dollar volume to determine the capital directional force.
                    total_bid_volume = 0
                    total_ask_volume = 0
                    if 'bidclose' in history:
                        total_bid_volume += (history['bidclose'] * history['bidsize']).sum()
                    if 'askclose' in history:
                        total_ask_volume += (history['askclose'] * history['asksize']).sum()

                    # Follow the capital flow to trade.
                    if total_bid_volume > total_ask_volume:
                        self.market_order(option.symbol, 1)
                    else:
                        self.market_order(option.symbol, -1)
```
