Last updated: 2023-03-16.
tf_quant_finance.rates.analytics.swap.equity_leg_cashflows#
Computes cashflows for a batch of equity legs.
tf_quant_finance.rates.analytics.swap.equity_leg_cashflows(
forward_prices, spots, notional, dividends=None, dtype=None, name=None
)
Equity cashflows are defined as a total equity return between pay dates, say,
T_1, ..., T_n. Let S_i represent the value of the equity at time T_i and
d_i be a discrete dividend paid at this time. Then the the payment at time
T_i is defined as (S_i - S_{i - 1}) / S_{i-1} + d_i. The value of
the cashflow is then the discounted sum of the paments. See, e.g., [1] for the
reference.
Example#
notional = 10000
forward_prices = [[110, 120, 140], [210, 220, 240]]
spots = [100, 200]
dividends = [[1, 1, 1], [2, 2, 2]]
equity_leg_cashflows(forward_prices, spots, notional, dividends,
dtype=tf.float64)
# Expected:
# [[1000.01, 909.1, 1666.675],
# [ 500.01, 476.2, 909.1]]
Args:#
forward_prices: A realTensorof shapebatch_shape + [num_cashflows], wherenum_cashflowsis the number of cashflows for each batch element. Equity forward prices at leg reset times.spots: ATensorof the samedtypeasforward_pricesand of shape compatible withbatch_shape. Spot prices for each batch elementnotional: ATensorof the samedtypeasforward_pricesand of compatible shape. Notional amount for each cashflow.dividends: ATensorof the samedtypeasforward_pricesand of compatible shape. Discrete dividends paid at the leg reset times. Default value: None which maps to zero dividend.dtype:tf.Dtype. If supplied the dtype for the input and outputTensors. Default value: None which maps to the default dtype inferred fromforward_prices.name: Python str. The name to give to the ops created by this function. Default value: None which maps to ‘equity_leg_cashflows’.
Returns:#
A Tensor of the same dtype as forward_prices and of shape
batch_shape + [num_cashflows].
References#
[1] Don M. Chance and Don R Rich, The Pricing of Equity Swaps and Swaptions, 1998 https://jod.pm-research.com/content/5/4/19