Last updated: 2023-03-16.
tf_quant_finance.black_scholes.binary_price#
Computes the Black Scholes price for a batch of binary call or put options.
tf_quant_finance.black_scholes.binary_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
)
The binary call (resp. put) option priced here is that which pays off a unit of cash if the underlying asset has a value greater (resp. smaller) than the strike price at expiry. Hence the binary option price is the discounted probability that the asset will end up higher (resp. lower) than the strike price at expiry.
Example#
# Price a batch of 5 binary call 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.binary_price(
volatilities=volatilities,
strikes=strikes,
expiries=expiries,
forwards=forwards)
# Expected print output of prices:
# [0. 0. 0.15865525 0.99764937 0.85927418]
References:#
[1] Hull, John C., Options, Futures and Other Derivatives. Pearson, 2018. [2] Wikipedia contributors. Binary option. Available at: https://en.wikipedia.org/w/index.php?title=Binary_option
Args:#
volatilities: RealTensorof any shape and dtype. The volatilities to expiry of the options to price.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.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 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.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 not None, these are the discount factors to expiry (i.e. e^(-rT)). If None, no discounting is applied (i.e. the undiscounted option price is returned). Ifspotsis supplied anddiscount_factorsis not None then this is also used to compute the forwards to expiry. Default value: None, equivalent to discount factors = 1.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.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 (float32).name: str. The name for the ops created by this function. Default value: None which is mapped to the default namebinary_price.
Returns:#
binary_prices: ATensorof the same shape asforwards. The Black Scholes price of the binary options.
Raises:#
ValueError: If bothforwardsandspotsare supplied or if neither is supplied.ValueError: If bothdiscount_ratesanddiscount_factorsis supplied.