self.get_chain_full_info

lumibot.strategies.strategy.Strategy.get_chain_full_info(self, asset: Asset, expiry: str | datetime | date, chains: dict = None, underlying_price: float = None, risk_free_rate: float = None, strike_min: float = None, strike_max: float = None) → DataFrame

Returns full option chain information for a given asset and expiry. This will include all known broker option information for each strike price, including: greeks, bid, ask, volume, open_interest etc. Not all Lumibot brokers provide all of this data and tick-style data like bid/ask/open_interest are not available during BackTesting.

This method can be quite slow for brokers that do not provide this data natively, as it will need to make multiple API calls (1 per strike) to get all the data. Min/Max strike values can be provided to reduce the number of queries made.

Using the chains dictionary obtained from get_chains finds all the options information for a given asset and expiry.

Parameters:
  • asset (Asset object) – The asset for which the option chain is being fetched.

  • expiry (str | datetime.datetime | datetime.date) – The expiry date for the option chain in the format of 2023-07-31.

  • chains (dictionary of dictionaries, optional) – The chains dictionary created by get_chains method. If not provided, the method will fetch the chains for the asset (if needed). This is needed to discover the list of strikes. Some brokers like Tradier or Polygon LiveData do not need the strike list.

  • underlying_price (float, optional) – The price of the underlying asset. If not provided, the method will fetch the price from the broker. Useful to provide to reduce the number of API calls.

  • risk_free_rate (float, optional) – The risk-free rate to use in the calculations. If not provided, the method will use the default risk-free rate.

  • strike_min (float, optional) – The minimum strike price to return. If not provided, the method will return all strikes.

  • strike_max (float, optional) – The maximum strike price to return. If not provided, the method will return all strikes.

Returns:

A DataFrame with the option chain information.

Return type:

pd.DataFrame

Example

>>> # Will return the option chains for SPY
>>> asset = "SPY"
>>> expiry = "2023-07-31"
>>> df = self.get_chain_full_info(asset, expiry)
>>> print(f"Strike: {df.iloc[0]['strike']}, Delta: {df.iloc[0]['greeks.delta']}")