Future Options

Requesting Data

Introduction

Request Future Options data in your algorithm to receive a feed of contract prices in the OnData method. For more information about the specific dataset we use for backtests, see the US Future Options dataset listing.

Create Subscriptions

Before you can subscribe to a Future Option contract, you must configure the underlying volatility model and get the contract Symbol.

Configure the Underlying Volatility Model

Before you add the Option contract subscription, set the underlying volatility model on the Future contract and warm it up.

futureContract.VolatilityModel = new StandardDeviationOfReturnsVolatilityModel(30);
foreach (var tradeBar in History(futureContract.Symbol, 30, Resolution.Daily))
{
    futureContract.VolatilityModel.Update(futureContract, tradeBar);
}
future_contract.VolatilityModel = StandardDeviationOfReturnsVolatilityModel(30)
trade_bars = self.History[TradeBar](future_contract.Symbol, 30, Resolution.Daily)
for trade_bar in trade_bars:
    future_contract.VolatilityModel.Update(future_contract, trade_bar) 

If you trade Options for many Future contracts you subscribe to, add this logic to a security initializer.

// In Initialize
var seeder = SecuritySeeder.Null;
SetSecurityInitializer(new MySecurityInitializer(BrokerageModel, seeder, this));

class MySecurityInitializer : BrokerageModelSecurityInitializer
{
    private QCAlgorithm _algorithm;
    
    public MySecurityInitializer(IBrokerageModel brokerageModel, ISecuritySeeder securitySeeder)
        : base(brokerageModel, securitySeeder)
    {
        _algorithm = algorithm;
    }
    
    public override void Initialize(Security security)
    {
        // First, call the superclass definition
        // This method sets the reality models of each security using the default reality models of the brokerage model
        base.Initialize(security);

        // Next, set and warm up the volatility model
        if (security.Type == SecurityType.Future)
        {
            security.VolatilityModel = new StandardDeviationOfReturnsVolatilityModel(30);
            foreach (var tradeBar in _algorithm.History(security.Symbol, 30, Resolution.Daily))
            {
                security.VolatilityModel.Update(security, tradeBar);
            }
        }
    }
}
# In Initialize
seeder = SecuritySeeder.Null
self.SetSecurityInitializer(MySecurityInitializer(self.BrokerageModel, seeder, self))

class MySecurityInitializer(BrokerageModelSecurityInitializer):

    def __init__(self, brokerage_model: IBrokerageModel, security_seeder: ISecuritySeeder, algorithm: QCAlgorithm) -> None:
        super().__init__(brokerage_model, security_seeder)
        self.algorithm = algorithm

    def Initialize(self, security: Security) -> None:
        # First, call the superclass definition
        # This method sets the reality models of each security using the default reality models of the brokerage model
        super().Initialize(security)

        # Next, set and warm up the volatility model
        if security.Type == SecurityType.Future:
            security.VolatilityModel = StandardDeviationOfReturnsVolatilityModel(30)
            trade_bars = self.algorithm.History[TradeBar](security.Symbol, 30, Resolution.Daily)
            for trade_bar in trade_bars:
                security.VolatilityModel.Update(security, trade_bar)

Get Contract Symbols

To subscribe to a Future Option contract, you need the contract Symbol. You can get the contract Symbol from the CreateOption method or from the OptionChainProvider. If you use the CreateOption method, you need to provide the contract details.

_futureContractSymbol = QuantConnect.Symbol.CreateFuture(Futures.Indices.SP500EMini,
    Market.CME, new DateTime(2022, 6, 17));
_optionContractSymbol = QuantConnect.Symbol.CreateOption(_futureContractSymbol,
    Market.CME, OptionStyle.American, OptionRight.Call, 3600, new DateTime(2022, 6, 17))
self.future_contract_symbol = Symbol.CreateFuture(Futures.Indices.SP500EMini,
    Market.CME, datetime(2022, 6, 17))
self.option_contract_symbol = Symbol.CreateOption(self.future_contract_symbol,
    Market.CME, OptionStyle.American, OptionRight.Call, 3600, datetime(2022, 6, 17))

Another way to get a Future Option contract Symbol is to use the OptionChainProvider. The GetOptionContractList method of OptionChainProvider returns a list of Symbol objects that reference the available Option contracts for a given underlying Future contract on a given date. The Symbol you pass to the method can reference any of the following Futures contracts:

var optionContractSymbols = OptionChainProvider.GetOptionContractList(_futureContractSymbol, Time);
var expiry = optionContractSymbols.Select(symbol => symbol.ID.Date).Min();
var filteredSymbols = optionContractSymbols.Where(symbol => symbol.ID.Date == expiry && symbol.ID.OptionRight == OptionRight.Call);
_optionContractSymbol = filteredSymbols.OrderByDescending(symbol => symbol.ID.StrikePrice).Last();
option_contract_symbols = self.OptionChainProvider.GetOptionContractList(self.future_contract_symbol, self.Time)
expiry = min([symbol.ID.Date for symbol in option_contract_symbols])
filtered_symbols = [symbol for symbol in option_contract_symbols if symbol.ID.Date == expiry and symbol.ID.OptionRight == OptionRight.Call]
self.option_contract_symbol = sorted(filtered_symbols, key=lambda symbol: symbol.ID.StrikePrice)[0]

The OptionRight enumeration has the following members:

Subscribe to Contracts

To create a Future Option contract subscription, pass the contract Symbol to the AddFutureOptionContract method. Save a reference to the contract Symbol so you can easily access the Option contract in the OptionChain that LEAN passes to the OnData method. To set the price model of the Option, set its PriceModel property.

var option = AddFutureOptionContract(_optionContractSymbol);
option.PriceModel = OptionPriceModels.BjerksundStensland();
option = self.AddFutureOptionContract(self.option_contract_symbol)
option.PriceModel = OptionPriceModels.BjerksundStensland()

The AddFutureOptionContract method creates a subscription for a single Option contract and adds it to your user-defined universe. To create a dynamic universe of Future Option contracts, add a Future Options universe.

Warm Up Contract Prices

If you subscribe to a Future Option contract with AddFutureOptionContract, you'll need to wait until the next Slice to receive data and trade the contract. To trade the contract in the same time step you subscribe to the contract, set the current price of the contract in a security initializer.

var seeder = new FuncSecuritySeeder(GetLastKnownPrices);
SetSecurityInitializer(new MySecurityInitializer(BrokerageModel, seeder, this));
seeder = FuncSecuritySeeder(self.GetLastKnownPrices)
self.SetSecurityInitializer(MySecurityInitializer(self.BrokerageModel, seeder, self))

Supported Assets

To view the supported assets in the US Future Options dataset, see Supported Assets.

Resolutions

The following table shows the available resolutions and data formats for Future Option contract subscriptions:

ResolutionTradeBarQuoteBarTrade TickQuote Tick
Tick

Second

Minutegreen checkgreen check
Hourgreen checkgreen check
Dailygreen checkgreen check

There is only one resolution option, so you don't need to pass a resolution argument to the AddFutureOptionContract method.

AddFutureOptionContract(_optionContractSymbol, Resolution.Minute);
self.AddFutureOptionContract(self.option_contract_symbol, Resolution.Minute)

To create custom resolution periods, see Consolidating Data.

Supported Markets

The following Market enumeration members are available for Future Options:

You don't need to pass a Market argument to the AddFutureOptionContract method because the contract Symbol already contains the market.

Margin and Leverage

LEAN models buying power and margin calls to ensure your algorithm stays within the margin requirements. Future Options are already leveraged products, so you can't change their leverage.

Remove Subscriptions

To remove a contract subscription that you created with AddFutureOptionContract, call the RemoveOptionContract method. This method is an alias for RemoveSecurity.

RemoveOptionContract(_optionContractSymbol);
self.RemoveOptionContract(self.option_contract_symbol)

The RemoveOptionContract method cancels your open orders for the contract and liquidates your holdings.

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: