Last updated: 2023-03-16.
tf_quant_finance.black_scholes.option_price_binomial#
Computes the BS price for a batch of European or American options.
tf_quant_finance.black_scholes.option_price_binomial(
*, volatilities, strikes, expiries, spots, discount_rates=None,
dividend_rates=None, is_call_options=None, is_american=None, num_steps=100,
dtype=None, name=None
)
Uses the Cox-Ross-Rubinstein version of the binomial tree method to compute the price of American or European options. Supports batching of the options and allows mixing of European and American style exercises in a batch. For more information about the binomial tree method and the Cox-Ross-Rubinstein method in particular see the references below.
Example#
# Prices 5 options with a mix of Call/Put, American/European features
# in a single batch.
dtype = np.float64
spots = np.array([1.0, 2.0, 3.0, 4.0, 5.0], dtype=dtype)
strikes = np.array([3.0, 3.0, 3.0, 3.0, 3.0], dtype=dtype)
volatilities = np.array([0.1, 0.22, 0.32, 0.01, 0.4], dtype=dtype)
is_call_options = np.array([True, True, False, False, False])
is_american = np.array([False, True, True, False, True])
discount_rates = np.array(0.035, dtype=dtype)
dividend_rates = np.array([0.02, 0.0, 0.07, 0.01, 0.0], dtype=dtype)
expiries = np.array(1.0, dtype=dtype)
prices = option_price_binomial(
volatilities=volatilities,
strikes=strikes,
expiries=expiries,
spots=spots,
discount_rates=discount_rates,
dividend_rates=dividend_rates,
is_call_options=is_call_options,
is_american=is_american,
dtype=dtype)
# Prints [0., 0.0098847, 0.41299509, 0., 0.06046989]
References#
[1] Hull, John C., Options, Futures and Other Derivatives. Pearson, 2018. [2] Wikipedia contributors. Binomial Options Pricing Model. Available at: https://en.wikipedia.org/wiki/Binomial_options_pricing_model
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.discount_rates: An optional realTensorof same dtype as thevolatilities. The risk free discount rate. If None the rate is assumed to be 0. Default value: None, equivalent to discount rates = 0..dividend_rates: An optional realTensorof same dtype as thevolatilities. If None the rate is assumed to be 0. Default value: None, equivalent to discount rates = 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. Default value: None, equivalent to is_call_options = True.is_american: A booleanTensorof a shape compatible withvolatilities. Indicates whether the option exercise style is American (if True) or European (if False). If not supplied, European style exercise is assumed. Default value: None, equivalent to is_american = False.num_steps: A positive scalar int32Tensor. The size of the time discretization to use. Default value: 100.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 nameoption_price.
Returns:#
A Tensor of the same shape as the inferred batch shape of the input data.
The Black Scholes price of the options computed on a binomial tree.