tf_quant_finance.experimental.instruments.RateCurve

Last updated: 2023-03-16.

tf_quant_finance.experimental.instruments.RateCurve#

View source

Represents an interest rate curve.

tf_quant_finance.experimental.instruments.RateCurve(
    maturity_dates, rates, valuation_date, compounding=None, interpolator=None,
    dtype=None, name=None
)

Args:#

  • maturity_dates: A DateTensor containing the maturity dates on which the curve is specified.

  • rates: A Tensor of real dtype specifying the rates (or yields) corresponding to the input maturities. The shape of this input should match the shape of maturity_dates.

  • valuation_date: A scalar DateTensor specifying the valuation (or settlement) date for the curve.

  • compounding: Optional scalar Tensor of dtype int32 specifying the compounding frequency of the input rates. Use compounding=0 for continuously compounded rates. If compounding is different than 0, then rates are converted to continuously componded rates to perform interpolation. Default value: If omitted, the default value is 0.

  • interpolator: Optional Python callable specifying the desired interpolation method. It should have the following interface: yi = interpolator(xi, x, y) x, y, ‘xi’, ‘yi’ are all Tensors of real dtype. x and y are the sample points and values (respectively) of the function to be interpolated. xi are the points at which the interpolation is desired and yi are the corresponding interpolated values returned by the function. Default value: None in which case linear interpolation is used.

  • dtype: tf.Dtype. Optional input specifying the dtype of the rates input.

  • name: Python str. The name to give to the ops created by this function. Default value: None which maps to ‘rate_curve’.

Attributes:#

  • valuation_date

Methods#

get_discount_factor

View source

get_discount_factor(
    interpolation_dates
)

Returns discount factors at interpolation_dates.

get_forward_rate

View source

get_forward_rate(
    start_date, maturity_date, daycount_fraction=None
)

Returns the simply accrued forward rate between [start_dt, maturity_dt].

Args:#

  • start_date: A DateTensor specifying the start of the accrual period for the forward rate.

  • maturity_date: A DateTensor specifying the end of the accrual period for the forward rate. The shape of maturity_date must be the same as the shape of the DateTensor start_date.

  • daycount_fraction: An optional Tensor of real dtype specifying the time between start_date and maturity_date in years computed using the forward rate’s day count basis. The shape of the input should be the same as that of start_date and maturity_date. Default value: None, in which case the daycount fraction is computed using ACTUAL_365 convention.

Returns:#

A real tensor of same shape as the inputs containing the simply compounded forward rate.

get_rates

View source

get_rates(
    interpolation_dates
)

Returns interpolated rates at interpolation_dates.