Calculate the net expiration profit and loss (P&L) profile of a multi-leg option (and, optionally, stock) strategy across a range of stock prices.

A strategy is expressed as a list of “legs”. Each leg is a dictionary describing either an option position or a stock position:

  • For an option leg: “instrument”: “option” (default), “strike_price” (float, required), “put_option” (bool, defaults to False), “position” (“long” or “short”, defaults to “long”), “premium” (float, defaults to 0).
  • For a stock leg: “instrument”: “stock”, “position” (“long” or “short”, defaults to “long”), “premium” (float, the entry price, defaults to 0).

This single, generic building block can express many common strategies by combining legs, for example:

  • Straddle: long call + long put, same strike.
  • Strangle: long call + long put, different (OTM) strikes.
  • Bull call spread: long call (lower strike) + short call (higher strike).
  • Bear put spread: long put (higher strike) + short put (lower strike).
  • Covered call: long stock + short call.
  • Protective put: long stock + long put.
  • Iron condor: short put + long put (lower strikes) + short call + long call (higher strikes).

Also known as: option strategy payoff diagram, P&L profile.

No programming experience? With the Finance Toolkit MCP server, AI assistants such as Claude and ChatGPT can calculate the Strategy Payoff for you. Just ask in plain English.

Calculate the Strategy Payoff in Python

The Strategy Payoff is available in the Options module of the open-source Finance Toolkit. Install it with:

pip install financetoolkit -U

Then call get_strategy_payoff as shown below.

from financetoolkit import Toolkit

toolkit = Toolkit(["AMZN", "AAPL"], api_key="FINANCIAL_MODELING_PREP_KEY")

straddle_legs = [
    {"strike_price": 150, "put_option": False, "position": "long", "premium": 8},
    {"strike_price": 150, "put_option": True, "position": "long", "premium": 6},
]

strategy_payoff = toolkit.options.get_strategy_payoff(legs=straddle_legs)

strategy_payoff["AMZN"]

Parameters

get_strategy_payoff accepts the following parameters:

  • legs (list[dict]): A list of leg dictionaries as described above. Must contain at least one leg. The same legs are applied to every ticker, so strike prices should be chosen with the relevant tickers’ price levels in mind.
  • start_date (str | None, optional): The start date which determines the stock price. Defaults to None which means it will use the most recent date.
  • stock_price_range (float): The percentage range to use for the stock prices at expiration. Defaults to 0.5 which equals 50% and thus results in stock prices from 50 to 150 if the current stock price is 100.
  • stock_price_step_size (float): The step size to use for the stock prices at expiration. Defaults to 1.
  • rounding (int | None, optional): The number of decimals to round the results to. Defaults to 4.

The Options module page introduces the module, and the sidebar lists all of its functions.

Share