Calculate the closed-form price of a single-barrier (knock-in or knock-out, up or down) European option using the Reiner & Rubinstein (1991) formulas.

A barrier option is a path-dependent option whose payoff (and existence) depends on whether the underlying stock price touches a pre-specified barrier level at any point before expiration:

  • Knock-out: the option becomes worthless if the barrier is touched.
  • Knock-in: the option only comes into existence if the barrier is touched.
  • Down barrier: the barrier is below the current stock price.
  • Up barrier: the barrier is above the current stock price.

The barrier level is defined relative to the current stock price through barrier_percentage, e.g. a value of 0.9 sets the barrier at 90% of the current stock price (a sensible default for a down barrier).

A useful identity is in-out parity: for identical parameters, a knock-in option plus its corresponding knock-out option (same direction) always equals the price of the equivalent vanilla Black-Scholes option, since the underlying either does or does not touch the barrier.

Also known as: knock-in option, knock-out option, down-and-out, down-and-in, up-and-out, up-and-in option.

Barrier Option in Python

Install the Finance Toolkit with:

pip install financetoolkit -U

Then call get_barrier_option as shown below.

from financetoolkit import Toolkit

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

barrier_option = toolkit.options.get_barrier_option()

barrier_option.loc['AMZN']

Parameters

The function accepts the following parameters:

  • 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.
  • put_option (bool, optional): Whether to calculate the put option price. Defaults to False which means it will calculate the call option price.
  • barrier_percentage (float, optional): The barrier level as a percentage of the current stock price. Defaults to 0.9 which equals 90% of the current stock price.
  • barrier_direction (str, optional): Either “down” or “up”. Defaults to “down”.
  • knock_type (str, optional): Either “in” or “out”. Defaults to “out”.
  • rebate (float, optional): The fixed cash amount paid out if the option knocks out (or fails to knock in). Defaults to 0.0.
  • strike_price_range (float): The percentage range to use for the strike prices. Defaults to 0.25 which equals 25% and thus results in strike prices from 75 to 125 if the current stock price is 100.
  • strike_step_size (int): The step size to use for the strike prices. Defaults to 5 which means that the strike prices will be 75, 80, 85, 90, 95, 100, 105, 110, 115 and 120 if the current stock price is 100.
  • expiration_time_range (int): The number of days to use for the time to expiration. Defaults to 30 which equals 30 days.
  • risk_free_rate (float, optional): The risk free rate to use for the calculation. Defaults to None which means it will use the current risk free rate.
  • dividend_yield (float, optional): The dividend yield to use for the calculation. Defaults to None which means it will use the dividend yield as obtained through annual historical data.
  • show_input_info (bool, optional): Whether to show the input information. Defaults to False.
  • rounding (int | None, optional): The number of decimals to round the results to. Defaults to 4.
  • standardize (bool, optional): Whether to standardize (Z-Score) the result across the time to expiration columns for each ticker and strike price. Defaults to False.
Share