<!--
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.asset_or_nothing_price" />
<meta itemprop="path" content="Stable" />
</div>

# tf_quant_finance.black_scholes.asset_or_nothing_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>



Computes the Black Scholes price for a batch of asset-or-nothing options.

```python
tf_quant_finance.black_scholes.asset_or_nothing_price(
    *, volatilities, strikes, expiries, spots=None, forwards=None,
    discount_rates=None, dividend_rates=None, discount_factors=None,
    is_call_options=None, is_normal_volatility=False, dtype=None, name=None
)
```



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

The asset-or-nothing call (resp. put) pays out one unit of the underlying
asset if the spot is above (resp. below) the strike at maturity.

#### Example

```python
  # Price a batch of 5 asset_or_nothing call and put options.
  volatilities = np.array([0.0001, 102.0, 2.0, 0.1, 0.4])
  forwards = np.array([1.0, 2.0, 3.0, 4.0, 5.0])
  # Strikes will automatically be broadcasted to shape [5].
  strikes = np.array([3.0])
  # Expiries will be broadcast to shape [5], i.e. each option has strike=3
  # and expiry = 1.
  expiries = 1.0
  computed_prices = tff.black_scholes.asset_or_nothing_price(
      volatilities=volatilities,
      strikes=strikes,
      expiries=expiries,
      forwards=forwards)
# Expected print output of prices:
# [0., 2., 2.52403424, 3.99315108, 4.65085383]
```

#### References:

[1] Hull, John C., Options, Futures and Other Derivatives. Pearson, 2018.
[2] https://en.wikipedia.org/wiki/Binary_option#Asset-or-nothing_call

#### 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.
* <b>`spots`</b>: A real `Tensor` of any shape that broadcasts to the shape of the
  `volatilities`. The current spot price of the underlying. Either this
  argument or the `forwards` (but not both) must be supplied.
* <b>`forwards`</b>: A real `Tensor` of any shape that broadcasts to the shape of
  `volatilities`. The forwards to maturity. Either this argument or the
  `spots` must be supplied but both must not be supplied.
* <b>`discount_rates`</b>: An optional real `Tensor` of same dtype as the
  `volatilities` and of the shape that broadcasts with `volatilities`. If
  not `None`, discount factors are calculated as e^(-rT), where r are the
  discount rates, or risk free rates. At most one of discount_rates and
  discount_factors can be supplied.
  Default value: `None`, equivalent to r = 0 and discount factors = 1 when
    discount_factors also not given.
* <b>`dividend_rates`</b>: An optional real `Tensor` of same dtype as the
  `volatilities` and of the shape that broadcasts with `volatilities`.
  Default value: `None`, equivalent to q = 0.
* <b>`discount_factors`</b>: An optional real `Tensor` of same dtype as the
  `volatilities`. If not `None`, these are the discount factors to expiry
  (i.e. e^(-rT)). Mutually exclusive with discount_rates. If neither is
  given, no discounting is applied (i.e. the undiscounted option price is
  returned). If `spots` is supplied and `discount_factors` is not `None`
  then this is also used to compute the forwards to expiry. At most one of
  `discount_rates` and `discount_factors` can be supplied.
  Default value: `None`, which maps to e^(-rT) calculated from
    discount_rates.
* <b>`is_call_options`</b>: A boolean `Tensor` of a shape compatible with
  `volatilities`. Indicates whether the option is a call (if True) or a put
  (if False). If not supplied, call options are assumed.
* <b>`is_normal_volatility`</b>: An optional Python boolean specifying whether the
  `volatilities` correspond to lognormal Black volatility (if False) or
  normal Black volatility (if True).
  Default value: False, which corresponds to lognormal volatility.
* <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
    `asset_or_nothing_price`.


#### Returns:


* <b>`option_prices`</b>: A `Tensor` of the same shape as `forwards`. The Black
Scholes price of the options.


#### Raises:


* <b>`ValueError`</b>: If both `forwards` and `spots` are supplied or if neither is
  supplied.
* <b>`ValueError`</b>: If both `discount_rates` and `discount_factors` is supplied.