tf_quant_finance.experimental.instruments.ForwardRateAgreement

Last updated: 2023-03-16.

tf_quant_finance.experimental.instruments.ForwardRateAgreement#

View source

Represents a batch of Forward Rate Agreements (FRA).

tf_quant_finance.experimental.instruments.ForwardRateAgreement(
    settlement_date, fixing_date, fixed_rate, notional=1.0,
    daycount_convention=None, rate_term=None, maturity_date=None, dtype=None,
    name=None
)

An FRA is a contract for the period [T, T+tau] where the holder exchanges a fixed rate (agreed at the start of the contract) against a floating payment determined at time T based on the spot Libor rate for term tau. The cashflows are exchanged at the settlement time T_s, which is either equal to T or close to T. The FRA are structured so that the payments are made in T+tau dollars (ref [1]).

The ForwardRateAgreement class can be used to create and price multiple FRAs simultaneously. However all FRAs within a FRA object must be priced using a common reference and discount curve.

Example:#

The following example illustrates the construction of a FRA instrument and calculating its price.

import numpy as np
import tensorflow as tf
import tf_quant_finance as tff
dates = tff.datetime

dtype = np.float64
notional = 1.
settlement_date = dates.convert_to_date_tensor([(2021, 2, 8)])
fixing_date = dates.convert_to_date_tensor([(2021, 2, 8)])
valuation_date = dates.convert_to_date_tensor([(2020, 2, 8)])
fixed_rate = 0.02
rate_term = rate_term = dates.periods.months(3)

fra = tff.experimental.instruments.ForwardRateAgreement(
      notional, settlement_date, fixing_date, fixed_rate,
      rate_term=rate_term, dtype=dtype)
curve_dates = valuation_date + dates.periods.months([1, 2, 3, 12, 24, 60])
reference_curve = tff.experimental.instruments.RateCurve(
    curve_dates,
    np.array([0.02, 0.025, 0.0275, 0.03, 0.035, 0.0325], dtype=dtype),
    dtype=dtype)
market = tff.experimental.instruments.InterestRateMarket(
    reference_curve=reference_curve, discount_curve=reference_curve)

price = fra.price(valuation_date, market)
# Expected result: 0.00378275

References:#

[1]: Leif B.G. Andersen and Vladimir V. Piterbarg. Interest Rate Modeling, Volume I: Foundations and Vanilla Models. Chapter 5. 2010.

Args:#

  • settlement_date: A rank 1 DateTensor specifying the dates on which cashflows are settled. The shape of the input correspond to the number of instruments being created.

  • fixing_date: A rank 1 DateTensor specifying the dates on which forward rate will be fixed. The shape of the inout should be the same as that of settlement_date.

  • fixed_rate: A rank 1 Tensor of real dtype specifying the fixed rate payment agreed at the initiation of the individual contracts. The shape should be the same as that of settlement_date.

  • notional: A scalar or a rank 1 Tensor of real dtype specifying the notional amount for each contract. When the notional is specified as a scalar, it is assumed that all contracts have the same notional. If the notional is in the form of a Tensor, then the shape must be the same as settlement_date. Default value: 1.0

  • daycount_convention: An optional DayCountConvention to determine how cashflows are accrued for each contract. Daycount is assumed to be the same for all contracts in a given batch. Default value: None in which case the daycount convention will default to DayCountConvention.ACTUAL_360 for all contracts.

  • rate_term: An optional rank 1 PeriodTensor specifying the term (or the tenor) of the Libor rate that determines the floating cashflow. The shape of the input should be the same as settlement_date. Default value: None in which case the the forward rate is determined for the period [settlement_date, maturity_date].

  • maturity_date: An optional rank 1 DateTensor specifying the maturity of the underlying forward rate for each contract. This input is only used if the input rate_term is None. Default value: None

  • dtype: tf.Dtype. If supplied the dtype for the real variables or ops either supplied to the FRA object or created by the FRA object. Default value: None which maps to the default dtype inferred by TensorFlow.

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

Raises:#

  • ValueError: If both maturity_date and rate_term are unspecified.

Methods#

price

View source

price(
    valuation_date, market, model=None
)

Returns the present value of the instrument on the valuation date.

Args:#

  • valuation_date: A scalar DateTensor specifying the date on which valuation is being desired.

  • market: A namedtuple of type InterestRateMarket which contains the necessary information for pricing the FRA instrument.

  • model: Reserved for future use.

Returns:#

A Rank 1 Tensor of real type containing the modeled price of each FRA contract based on the input market data.