Last updated: 2023-03-16.
tf_quant_finance.experimental.american_option_pricing.andersen_lake.andersen_lake#
Computes American option prices using the Andersen-Lake approximation.
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
)
Example#
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:#
volatilities: RealTensorof any real dtype and shape[num_options]. The volatilities to expiry of the options to price.strikes: A realTensorof the same dtype and same shape asvolatilities. The strikes of the options to be priced.expiries: A realTensorof same dtype and same shape asvolatilities. The expiry of each option. The units should be such thatexpiry * volatility**2is dimensionless.spots: A realTensorof same shape asvolatilities. The current spot price of the underlying. Either this argument or theforwards(but not both) must be supplied.forwards: A realTensorof same shape asvolatilities. The forwards to maturity. Either this argument or thespotsmust be supplied but both must not be supplied.discount_rates: An optional realTensorof same shape and dtype as thevolatilities. If notNone, 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) / expiriesifdiscount_factorsis notNone, or maps to0whendiscount_factorsis alsoNone.discount_factors: An optional realTensorof same shape and dtype as thevolatilities. If notNone, these are the discount factors to expiry (i.e. e^(-rT)). Mutually exclusive withdiscount_rate. If neither is given, no discounting is applied (i.e. the undiscounted option price is returned). Ifspotsis supplied anddiscount_factorsis notNonethen this is also used to compute the forwards to expiry. Default value:None.dividend_rates: An optional realTensorof same shape and dtype as thevolatilities. The continuous dividend rate on the underliers. May be negative (to indicate costs of holding the underlier). Default value:None, equivalent to zero dividends.is_call_options: A booleanTensorof a shape compatible withvolatilities. Indicates whether the option is a call (if True) or a put (if False). If not supplied, call options are assumed.grid_num_points: positiveint. The number of equidistant points to divide the values given inexpiriesinto in the grid oftau_grid. Default value: 10.integration_num_points_kronrod: positiveint. The number of points used in the Gauss-Kronrod integration approximation method used for calculating the option prices. Default value: 31.integration_num_points_legendre: positiveint. 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.max_iterations_exercise_boundary: positiveint. Maximum number of iterations for calculating the exercise boundary if it doesn’t converge earlier. Default value: 30.max_depth_kronrod: positiveint. Maximum number of iterations for calculating the Gauss-Kronrod integration approximation. Default value: 30.tolerance_exercise_boundary: Positive scalarTensor. The tolerance for the convergence of calculating the exercise boundary function. Default value: 1e-8.tolerance_kronrod: Positive scalarTensor. The tolerance for the convergence of calculating the Gauss-Kronrod integration approximation. Default value: 1e-8.dtype: Optionaltf.DType. If supplied, the dtype to be used for conversion of any supplied non-Tensorarguments toTensor. Default value: None which maps to the default dtype inferred by TensorFlow.name: str. The name for the ops created by this function. Default value: None which is mapped to the default nameandersen_lake.
Returns:#
Tensor of shape [num_options], containing the calculated American option
prices.
Raises:#
ValueError: (a) If bothforwardsandspotsare supplied or if neither is supplied.