tf_quant_finance.black_scholes.barrier_price

Last updated: 2023-03-16.

tf_quant_finance.black_scholes.barrier_price#

View source

Prices barrier options in a Black-Scholes Model.

tf_quant_finance.black_scholes.barrier_price(
    *, volatilities, strikes, expiries, spots, barriers, rebates=None,
    discount_rates=None, dividend_rates=None, is_barrier_down=None,
    is_knock_out=None, is_call_options=None, dtype=None, name=None
)

Computes the prices of options with a single barrier in Black-Scholes world as described in Ref. [1]. Note that the barrier is applied continuously.

Example#

This example is taken from Ref. [2], Page 154.

import tf_quant_finance as tff

dtype = np.float32
discount_rates = np.array([.08, .08])
dividend_rates = np.array([.04, .04])
spots = np.array([100., 100.])
strikes = np.array([90., 90.])
barriers = np.array([95. 95.])
rebates = np.array([3. 3.])
volatilities = np.array([.25, .25])
expiries = np.array([.5, .5])
barriers_type = np.array([5, 1])
is_barrier_down = np.array([True, False])
is_knock_out = np.array([False, False])
is_call_option = np.array([True, True])

price = tff.black_scholes.barrier_price(
  discount_rates, dividend_rates, spots, strikes,
  barriers, rebates, volatilities,
  expiries, is_barrier_down, is_knock_out, is_call_options)

# Expected output
#  `Tensor` with values [9.024, 7.7627]

References#

[1]: Lee Clewlow, Javier Llanos, Chris Strickland, Caracas Venezuela Pricing Exotic Options in a Black-Scholes World, 1994 https://warwick.ac.uk/fac/soc/wbs/subjects/finance/research/wpaperseries/1994/94-54.pdf [2]: Espen Gaarder Haug, The Complete Guide to Option Pricing Formulas, 2nd Edition, 1997

Args:#

  • volatilities: Real Tensor of any shape and dtype. The volatilities to expiry of the options to price.

  • strikes: A real Tensor of the same dtype and compatible shape as volatilities. The strikes of the options to be priced.

  • expiries: A real Tensor of same dtype and compatible shape as volatilities. The expiry of each option. The units should be such that expiry * volatility**2 is dimensionless.

  • spots: A real Tensor of any shape that broadcasts to the shape of the volatilities. The current spot price of the underlying.

  • barriers: A real Tensor of same dtype as the volatilities and of the shape that broadcasts with volatilities. The barriers of each option.

  • rebates: A real Tensor of same dtype as the volatilities and of the shape that broadcasts with volatilities. For knockouts, this is a fixed cash payout in case the barrier is breached. For knockins, this is a fixed cash payout in case the barrier level is not breached. In the former case, the rebate is paid immediately on breach whereas in the latter, the rebate is paid at the expiry of the option. Default value: None which maps to no rebates.

  • discount_rates: A real Tensor of same dtype as the volatilities and of the shape that broadcasts with volatilities. Discount rates, or risk free rates. Default value: None, equivalent to discount_rate = 0.

  • dividend_rates: A real Tensor of same dtype as the volatilities and of the shape that broadcasts with volatilities. A continuous dividend rate paid by the underlier. If None, then defaults to zero dividends. Default value: None, equivalent to zero dividends.

  • is_barrier_down: A real Tensor of boolean values and of the shape that broadcasts with volatilities. True if barrier is below asset price at expiration. Default value: True.

  • is_knock_out: A real Tensor of boolean values and of the shape that broadcasts with volatilities. True if option is knock out else false. Default value: True.

  • is_call_options: A real Tensor of boolean values and of the shape that broadcasts with volatilities. True if option is call else false. Default value: True.

  • dtype: Optional tf.DType. If supplied, the dtype to be used for conversion of any supplied non-Tensor arguments to Tensor. Default value: None which maps to the default dtype inferred by TensorFlow.

  • name: str. The name for the ops created by this function. Default value: None which is mapped to the default name barrier_price.

Returns:#

  • option_prices: A Tensor of same shape as spots. The approximate price of the barriers option under black scholes.