Last updated: 2023-03-16.
tf_quant_finance.rates.analytics.swap.rate_leg_cashflows#
Computes cashflows for a batch or interest rate legs.
tf_quant_finance.rates.analytics.swap.rate_leg_cashflows(
coupon_rates, notional, daycount_fractions, dtype=None, name=None
)
Example#
coupon_rates = [[0.1, 0.1, 0.1], [0.02, 0.12, 0.14]]
notional = 1000
daycount_fractions = [[1, 1, 1], [1, 2, 1]]
rate_leg_cashflows(
coupon_rates, notional, daycount_fractions, dtype=tf.float64)
# Expected:
# [[100.0, 100.0, 100.0],
# [ 20.0, 240.0, 140.0]]
Args:#
coupon_rates: A realTensorof shapebatch_shape + [num_cashflows], wherenum_cashflowsis the number of cashflows for each batch element. Coupon rates for each cashflow of the leg. Can be a scalar for a fixed leg or represent forward rates for a floating leg.notional: ATensorof the samedtypeascoupon_ratesand of compatible shape. Notional amount for each cashflow.daycount_fractions: ATensorof the samedtypeascoupon_ratesand of compatible shape. Year fractions for the coupon accrual.dtype:tf.Dtype. If supplied the dtype for the input and outputTensors. Default value: None which maps to the default dtype inferred fromcoupon_rates.name: Python str. The name to give to the ops created by this function. Default value: None which maps to ‘rate_leg_cashflows’.
Returns:#
A Tensor of the same dtype as coupon_rates and of shape
batch_shape + [num_cashflows].