Last updated: 2023-03-16.
tf_quant_finance.rates.analytics.swap.equity_swap_price#
Computes prices of a batch of equity swaps.
tf_quant_finance.rates.analytics.swap.equity_swap_price(
rate_leg_coupon_rates, equity_leg_forward_prices, equity_leg_spots,
rate_leg_notional, equity_leg_notional, rate_leg_daycount_fractions,
rate_leg_discount_factors, equity_leg_discount_factors, equity_dividends=None,
is_equity_receiver=None, dtype=None, name=None
)
The swap consists of an equity and interest rate legs.
Example#
rate_leg_coupon_rates = [[0.1, 0.2, 0.05], [0.1, 0.05, 0.2]]
# Two cashflows of 4 and 3 payments, respectively
forward_prices = [[110, 120, 140, 150], [210, 220, 240, 0]]
spots = [100, 200]
notional = 1000
pay_leg_daycount_fractions = 0.5
rate_leg_daycount_fractions = [[0.5, 0.5, 0.5], [0.4, 0.5, 0.6]]
rate_leg_discount_factors = [[0.95, 0.9, 0.85], [0.98, 0.92, 0.88]]
equity_leg_discount_factors = [[0.95, 0.9, 0.85, 0.8],
[0.98, 0.92, 0.88, 0.0]]
equity_swap_price(
rate_leg_coupon_rates=rate_leg_coupon_rates,
equity_leg_forward_prices=forward_prices,
equity_leg_spots=spots,
rate_leg_notional=notional,
equity_leg_notional=notional,
rate_leg_daycount_fractions=rate_leg_daycount_fractions,
rate_leg_discount_factors=rate_leg_discount_factors,
equity_leg_discount_factors=equity_leg_discount_factors,
is_equity_receiver=[True, False],
dtype=tf.float64)
# Expected: [216.87770563, -5.00952381]
forward_rates(df_start_dates, df_end_dates, daycount_fractions,
dtype=tf.float64)
Args:#
rate_leg_coupon_rates: A realTensorof shapebatch_shape + [num_rate_cashflows], wherenum_rate_cashflowsis the number of cashflows for each batch element. Coupon rates for the interest rate leg.equity_leg_forward_prices: ATensorof the samedtypeasrate_leg_coupon_ratesand of shapebatch_shape + [num_equity_cashflows], wherenum_equity_cashflowsis the number of cashflows for each batch element. Equity leg forward prices.equity_leg_spots: ATensorof the samedtypeasequity_leg_forward_pricesand of shape compatible withbatch_shape. Spot prices for each batch element of the equity leg.rate_leg_notional: ATensorof the samedtypeasrate_leg_coupon_ratesand of compatible shape. Notional amount for each cashflow.equity_leg_notional: ATensorof the samedtypeasequity_leg_forward_pricesand of compatible shape. Notional amount for each cashflow.rate_leg_daycount_fractions: ATensorof the samedtypeasrate_leg_coupon_ratesand of compatible shape. Year fractions for the coupon accrual.rate_leg_discount_factors: ATensorof the samedtypeasrate_leg_coupon_ratesand of compatible shape. Discount factors for each cashflow of the rate leg.equity_leg_discount_factors: ATensorof the samedtypeasequity_leg_forward_pricesand of compatible shape. Discount factors for each cashflow of the equity leg.equity_dividends: ATensorof the samedtypeasequity_leg_forward_pricesand of compatible shape. Dividends paid at the leg reset times. Default value: None which maps to zero dividend.is_equity_receiver: A booleanTensorof shape compatible withbatch_shape. Indicates whether the swap holder is equity holder or receiver. Default value: None which means that all swaps are equity reiver swaps.dtype:tf.Dtype. If supplied the dtype for the input and outputTensors. Default value: None which maps to the default dtype inferred fromrate_leg_coupon_rates.name: Python str. The name to give to the ops created by this function. Default value: None which maps to ‘equity_swap_price’.
Returns:#
A Tensor of the same dtype as rate_leg_coupon_rates and of shape
batch_shape. Present values of the equity swaps.