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

# tf_quant_finance.experimental.american_option_pricing.andersen_lake.andersen_lake

<!-- 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/experimental/american_option_pricing/andersen_lake.py">View source</a>



Computes American option prices using the Andersen-Lake approximation.

```python
tf_quant_finance.experimental.american_option_pricing.andersen_lake.andersen_lake(
    *, volatilities, strikes, expiries, spots=None, forwards=None,
    discount_rates=None, discount_factors=None, dividend_rates=None,
    is_call_options=None, grid_num_points=10, integration_num_points_kronrod=31,
    integration_num_points_legendre=32, max_iterations_exercise_boundary=30,
    max_depth_kronrod=30, tolerance_exercise_boundary=1e-08,
    tolerance_kronrod=1e-08, dtype=None, name=None
)
```



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

#### Example

```python
volatilities = [0.1, 0.15]
strikes = [3, 2]
expiries = [1, 2]
spots = [8.0, 9.0]
discount_rates = [0.01, 0.02]
dividend_rates = [0.01, 0.02]
is_call_options = [True, False]
grid_num_points = 40
integration_num_points_kronrod = 31
integration_num_points_legendre = 32
max_iterations_exercise_boundary = 500
max_depth_kronrod = 50
tolerance_exercise_boundary = 1e-11
tolerance_kronrod = 1e-11
computed_prices = andersen_lake(
    volatilities=volatilities,
    strikes=strikes,
    expiries=expiries,
    spots=spots,
    discount_rates=discount_rates,
    dividend_rates=dividend_rates,
    is_call_options=is_call_options,
    grid_num_points=grid_num_points,
    integration_num_points_kronrod=integration_num_points_kronrod,
    integration_num_points_legendre=integration_num_points_legendre,
    max_iterations_exercise_boundary=max_iterations_exercise_boundary,
    max_depth_kronrod=max_depth_kronrod,
    tolerance_exercise_boundary=tolerance_exercise_boundary,
    tolerance_kronrod=tolerance_kronrod
    dtype=tf.float64)
# Expected print output of computed prices:
# [4.950249e+00, 7.768513e-14]
```

#### References:
[1] Leif Andersen, Mark Lake and Dimitri Offengenden. High-performance
American option pricing. 2015
https://engineering.nyu.edu/sites/default/files/2019-03/Carr-adjusting-exponential-levy-models.pdf#page=46

#### Args:


* <b>`volatilities`</b>: Real `Tensor` of any real dtype and shape `[num_options]`.
  The volatilities to expiry of the options to price.
* <b>`strikes`</b>: A real `Tensor` of the same dtype and same shape as `volatilities`.
  The strikes of the options to be priced.
* <b>`expiries`</b>: A real `Tensor` of same dtype and same 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 same shape as `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 same shape as `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 shape and dtype as the
  `volatilities`. If not `None`, discount factors are calculated as e^(-rT),
  where r are the discount rates, or risk free rates.
  Default value: `None`, which maps to `-log(discount_factors) / expiries`
    if `discount_factors` is not `None`, or maps to `0` when
    `discount_factors` is also `None`.
* <b>`discount_factors`</b>: An optional real `Tensor` of same shape and dtype as the
  `volatilities`. If not `None`, these are the discount factors to expiry
  (i.e. e^(-rT)). Mutually exclusive with `discount_rate`. 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.
  Default value: `None`.
* <b>`dividend_rates`</b>: An optional real `Tensor` of same shape and dtype as the
  `volatilities`. The continuous dividend rate on the underliers. May be
  negative (to indicate costs of holding the underlier).
  Default value: `None`, equivalent to zero dividends.
* <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>`grid_num_points`</b>: positive `int`. The number of equidistant points to divide
  the values given in `expiries` into in the grid of `tau_grid`.
  Default value: 10.
* <b>`integration_num_points_kronrod`</b>: positive `int`. The number of points used in
  the Gauss-Kronrod integration approximation method used for
  calculating the option prices.
  Default value: 31.
* <b>`integration_num_points_legendre`</b>: positive `int`. The number of points used
  in the Gauss-Legendre integration approximation method used for
  calculating the exercise boundary function used for pricing the options.
  Default value: 32.
* <b>`max_iterations_exercise_boundary`</b>: positive `int`. Maximum number of
  iterations for calculating the exercise boundary if it doesn't converge
  earlier.
  Default value: 30.
* <b>`max_depth_kronrod`</b>: positive `int`. Maximum number of iterations for
  calculating the Gauss-Kronrod integration approximation.
  Default value: 30.
* <b>`tolerance_exercise_boundary`</b>: Positive scalar `Tensor`. The tolerance for the
  convergence of calculating the exercise boundary function.
  Default value: 1e-8.
* <b>`tolerance_kronrod`</b>: Positive scalar `Tensor`. The tolerance for the
  convergence of calculating the Gauss-Kronrod integration approximation.
  Default value: 1e-8.
* <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 `andersen_lake`.


#### Returns:

`Tensor` of shape `[num_options]`, containing the calculated American option
prices.



#### Raises:


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