<!--
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.models.heston.approximations.asian_option_price" />
<meta itemprop="path" content="Stable" />
</div>

# tf_quant_finance.models.heston.approximations.asian_option_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/models/heston/approximations/asian_prices.py">View source</a>



Computes the Heston price for a batch of asian options.

```python
tf_quant_finance.models.heston.approximations.asian_option_price(
    *, variances, mean_reversion, theta, volvol, rho, strikes, expiries, spots=None,
    forwards=None, sampling_times=None, past_fixings=None, discount_rates=None,
    dividend_rates=None, discount_factors=None, is_call_options=None,
    averaging_type=tf_quant_finance.black_scholes.AveragingType.GEOMETRIC,
    averaging_frequency=tf_quant_finance.black_scholes.AveragingFrequency.DISCRETE,
    integration_method=None, dtype=None, name=None, **kwargs
)
```



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

Discrete and continuous geometric asian options can be priced using a
semi-analytical expression in the Heston model.

#### Example
```python
  # Price a batch of seasoned discrete geometric asians in Heston model
  # This example reproduces some prices from the reference paper
  variances = 0.09
  mean_reversion = 1.15
  volvol = 0.39
  theta = 0.0348
  rho = -0.64
  spots = 100.0
  strikes = [90.0, 100.0, 110.0]
  discount_rates = 0.05

  T = 0.5
  expiries = T
  sampling_times = np.linspace(1/365, T, 182)[:, np.newaxis]

  computed_prices_asians = asian_option_price(
    variances=variances,
    mean_reversion=mean_reversion,
    theta=theta,
    volvol=volvol,
    rho=rho,
    strikes=strikes,
    expiries=expiries,
    spots=spots,
    sampling_times=sampling_times,
    discount_rates=discount_rates
  )
  # Expected print output of computed prices:
  # [[11.884178 ], [ 5.080889 ], [ 1.3527349]]
```

#### References:
[1] B. Kim, J. Kim, J. Kim & I. S. Wee, "A Recursive Method for Discretely
  Monitored Geometric Asian Option Prices", Bull. Korean Math. Soc. 53,
  733-749 (2016)

#### Args:


* <b>`variances`</b>: Real `Tensor` of any shape compatible with a `batch_shape` and
  and any real dtype. The initial value of the variance.
* <b>`mean_reversion`</b>: A real `Tensor` of the same dtype and compatible shape as
  `variances`. Corresponds to the mean reversion rate.
* <b>`theta`</b>: A real `Tensor` of the same dtype and compatible shape as
  `variances`. Corresponds to the long run price variance.
* <b>`volvol`</b>: A real `Tensor` of the same dtype and compatible shape as
  `variances`. Corresponds to the volatility of the volatility.
* <b>`rho`</b>: A real `Tensor` of the same dtype and compatible shape as
  `variances`. Corresponds to the correlation between dW_{X}` and `dW_{V}`.
* <b>`strikes`</b>: A real `Tensor` of the same dtype and compatible shape as
  `variances`. The strikes of the options to be priced.
* <b>`expiries`</b>: A real `Tensor` of same dtype and compatible shape as
  `variances`. 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
  `variances`. 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
  `variances`. The forwards to maturity. Either this argument or the
  `spots` must be supplied but both must not be supplied.
* <b>`sampling_times`</b>: A real `Tensor` of same dtype as expiries and shape
  `[n] + batch_shape` where `n` is the number of sampling times for
  the asian options
  Default value: `None`, which will raise an error for discrete sampling
  asian options
* <b>`past_fixings`</b>: A real `Tensor` of same dtype as spots or forwards and shape
  `[n] + batch_shape` where n is the number of past fixings that have
  already been observed
  Default value: `None`, equivalent to no past fixings (ie. unseasoned)
* <b>`discount_rates`</b>: An optional real `Tensor` of same dtype as the
  `variances` and of the shape that broadcasts with `variances`.
  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
  `variances` and of the shape that broadcasts with `variances`.
  Default value: `None`, equivalent to q = 0.
* <b>`discount_factors`</b>: An optional real `Tensor` of same dtype as the
  `variances`. 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
  `variances`. Indicates whether the option is a call (if True) or a put
  (if False). If not supplied, call options are assumed.
* <b>`averaging_type`</b>: Enum value of AveragingType to select the averaging method
  for the payoff calculation
  Default value: AveragingType.GEOMETRIC
* <b>`averaging_frequency`</b>: Enum value of AveragingFrequency to select the
  averaging type for the payoff calculation (discrete vs continuous)
  Default value: AveragingFrequency.DISCRETE
* <b>`integration_method`</b>: An instance of <a href="../../../../tf_quant_finance/math/integration/IntegrationMethod.md"><code>math.integration.IntegrationMethod</code></a>.
  Default value: `None` which maps to Gaussian quadrature.
* <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
  `asian_option_price`.
* <b>`**kwargs`</b>: Additional parameters for the underlying integration method.
  If not supplied, uses bounds `lower=1e-9`, `upper=100`.


#### Returns:


* <b>`option_prices`</b>: A `Tensor` of the same shape as `strikes`. The Heston 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.
* <b>`ValueError`</b>: If option is arithmetic.
* <b>`NotImplementedError`</b>: if option is continuous averaging.
* <b>`NotImplementedError`</b>: if any of the Heston model parameters are of type
  PiecewiseConstantFunc.