Last updated: 2023-03-16.
tf_quant_finance.black_scholes.asian_option_price#
Computes the Black Scholes price for a batch of asian options.
tf_quant_finance.black_scholes.asian_option_price(
*, volatilities, 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,
is_normal_volatility=False,
averaging_type=tf_quant_finance.black_scholes.AveragingType.GEOMETRIC,
averaging_frequency=tf_quant_finance.black_scholes.AveragingFrequency.DISCRETE,
dtype=None, name=None
)
In Black-Scholes, the marginal distribution of the underlying at each sampling date is lognormal. The product of a sequence of lognormal variables is also lognormal so we can re-express these options as vanilla options with modified parameters and use the vanilla pricer to price them.
TODO(b/261568763): support volatility term structures
Example#
# Price a batch of 5 seasoned discrete geometric Asian 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
sampling_times = np.array([[0.5, 0.5, 0.5, 0.5, 0.5],
[1.0, 1.0, 1.0, 1.0, 1.0]])
past_fixings = np.array([[1.0, 2.0, 3.0, 4.0, 5.0]])
computed_prices = tff.black_scholes.asian_option_price(
volatilities=volatilities,
strikes=strikes,
expiries=expiries,
forwards=forwards,
sampling_times=sampling_times,
past_fixings=past_fixings)
# Expected print output of computed prices:
# [ 0.0, 0.0, 0.52833763, 0.99555802, 1.91452834]
References:#
[1] Haug, E. G., The Complete Guide to Option Pricing Formulas. McGraw-Hill.
Args:#
volatilities: RealTensorof any shape compatible with abatch_shapeand and anyy real dtype. The volatilities to expiry of the options to price. Herebatch_shapecorresponds to a batch of priced options.strikes: A realTensorof the same dtype and compatible shape asvolatilities. The strikes of the options to be priced.expiries: A realTensorof same dtype and compatible shape asvolatilities. The expiry of each option. The units should be such thatexpiry * volatility**2is dimensionless.spots: A realTensorof any shape that broadcasts to the shape of thevolatilities. The current spot price of the underlying. Either this argument or theforwards(but not both) must be supplied.forwards: A realTensorof any shape that broadcasts to the shape ofvolatilities. The forwards to maturity. Either this argument or thespotsmust be supplied but both must not be supplied.sampling_times: A realTensorof same dtype as expiries and shape[n] + batch_shapewhere n is the number of sampling times for the Asian options Default value:None, which will raise an error for discrete sampling Asian optionspast_fixings: A realTensorof same dtype as spots or forwards and shape[n] + batch_shapewhere n is the number of past fixings that have already been observed. Default value:None, equivalent to no past fixings (ie. unseasoned)discount_rates: An optional realTensorof same dtype as thevolatilitiesand of the shape that broadcasts withvolatilities. If notNone, discount factors are calculated as e^(-rT), where r are the discount rates, or risk free rates. At most one ofdiscount_ratesanddiscount_factorscan be supplied. Default value:None, equivalent tor = 0anddiscount factors = 1whendiscount_factorsalso not given.dividend_rates: An optional realTensorof same dtype as thevolatilitiesand of the shape that broadcasts withvolatilities. Default value:None, equivalent to q = 0.discount_factors: An optional realTensorof same dtype as thevolatilities. If notNone, these are the discount factors to expiry (i.e. e^(-rT)). Mutually exclusive withdiscount_rates. 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. At most one ofdiscount_ratesanddiscount_factorscan be supplied. Default value:None, which maps to e^(-rT) calculated fromdiscount_rates.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.is_normal_volatility: An optional Python boolean specifying whether thevolatilitiescorrespond to lognormal Black volatility (if False) or normal Black volatility (if True). Default value: False, which corresponds to lognormal volatility.averaging_type: Enum value of AveragingType to select the averaging method for the payoff calculation. Default value: AveragingType.GEOMETRICaveraging_frequency: Enum value of AveragingFrequency to select the averaging type for the payoff calculation (discrete vs continuous) Default value: AveragingFrequency.DISCRETEdtype: Optionaltf.DType. If supplied, the dtype to be used for conversion of any supplied non-Tensorarguments toTensor. Default value:Nonewhich maps to the default dtype inferred by TensorFlow.name: str. The name for the ops created by this function. Default value:Nonewhich is mapped to the default nameasian_option_price.
Returns:#
option_prices: ATensorof shapebatch_shapeand the same dtype asvolatilities. The Black Scholes price of the Asian options.
Raises:#
ValueError: If bothforwardsandspotsare supplied or if neither is supplied.ValueError: If bothdiscount_ratesanddiscount_factorsis supplied.ValueError: Ifis_normal_volatilityis true and option is geometric, oris_normal_volatilityis false (ie. lognormal) and option is arithmetic.ValueError: If option is discrete averaging andsampling_datesis None of if last sampling date is later than option expiry date.NotImplementedError: if option is continuous averaging.NotImplementedError: if option is arithmetic.