Last updated: 2023-03-16.
tf_quant_finance.black_scholes.barrier_price#
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: RealTensorof any shape and dtype. The volatilities to expiry of the options to price.strikes: A realTensorof the same dtype and compatible shape asvolatilities. The strikes of the options to be priced.expiries: A realTensorof same dtype and compatible shape asvolatilities. The expiry of each option. The units should be such thatexpiry * volatility**2is dimensionless.spots: A realTensorof any shape that broadcasts to the shape of thevolatilities. The current spot price of the underlying.barriers: A realTensorof same dtype as thevolatilitiesand of the shape that broadcasts withvolatilities. The barriers of each option.rebates: A realTensorof same dtype as thevolatilitiesand of the shape that broadcasts withvolatilities. 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:Nonewhich maps to no rebates.discount_rates: A realTensorof same dtype as thevolatilitiesand of the shape that broadcasts withvolatilities. Discount rates, or risk free rates. Default value:None, equivalent to discount_rate = 0.dividend_rates: A realTensorof same dtype as thevolatilitiesand of the shape that broadcasts withvolatilities. A continuous dividend rate paid by the underlier. IfNone, then defaults to zero dividends. Default value:None, equivalent to zero dividends.is_barrier_down: A realTensorofbooleanvalues and of the shape that broadcasts withvolatilities. True if barrier is below asset price at expiration. Default value:True.is_knock_out: A realTensorofbooleanvalues and of the shape that broadcasts withvolatilities. True if option is knock out else false. Default value:True.is_call_options: A realTensorofbooleanvalues and of the shape that broadcasts withvolatilities. True if option is call else false. Default value:True.dtype: Optionaltf.DType. If supplied, the dtype to be used for conversion of any supplied non-Tensorarguments toTensor. Default value:Nonewhich maps to the default dtype inferred by TensorFlow.name: str. The name for the ops created by this function. Default value:Nonewhich is mapped to the default namebarrier_price.
Returns:#
option_prices: ATensorof same shape asspots. The approximate price of the barriers option under black scholes.