<!--
This file is generated by a tool. Do not edit directly.
For open-source contributions the docs will be updated automatically.
-->

*Last updated: 2023-03-16.*

<div itemscope itemtype="http://developers.google.com/ReferenceObject">
<meta itemprop="name" content="tf_quant_finance.black_scholes.barrier_price" />
<meta itemprop="path" content="Stable" />
</div>

# tf_quant_finance.black_scholes.barrier_price

<!-- Insert buttons and diff -->

<table class="tfo-notebook-buttons tfo-api" align="left">
</table>

<a target="_blank" href="https://github.com/paolodelia99/tf-quant-finance/blob/main/tf_quant_finance/black_scholes/vanilla_prices.py">View source</a>



Prices barrier options in a Black-Scholes Model.

```python
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
)
```



<!-- Placeholder for "Used in" -->

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.

```python
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:


* <b>`volatilities`</b>: Real `Tensor` of any shape and dtype. The volatilities to
  expiry of the options to price.
* <b>`strikes`</b>: A real `Tensor` of the same dtype and compatible shape as
  `volatilities`. The strikes of the options to be priced.
* <b>`expiries`</b>: 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.
* <b>`spots`</b>: A real `Tensor` of any shape that broadcasts to the shape of the
  `volatilities`. The current spot price of the underlying.
* <b>`barriers`</b>: A real `Tensor` of same dtype as the `volatilities` and of the
  shape that broadcasts with `volatilities`. The barriers of each option.
* <b>`rebates`</b>: 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.
* <b>`discount_rates`</b>: 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.
* <b>`dividend_rates`</b>: 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.
* <b>`is_barrier_down`</b>: 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`.
* <b>`is_knock_out`</b>: 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`.
* <b>`is_call_options`</b>: A real `Tensor` of `boolean` values and of the shape
  that broadcasts with `volatilities`. True if option is call else
  false.
  Default value: `True`.
* <b>`dtype`</b>: 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.
* <b>`name`</b>: str. The name for the ops created by this function.
  Default value: `None` which is mapped to the default name `barrier_price`.

#### Returns:


* <b>`option_prices`</b>: A `Tensor` of same shape as `spots`. The approximate price of
the barriers option under black scholes.