Last updated: 2023-03-16.
tf_quant_finance.experimental.instruments.ForwardRateAgreement#
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 1DateTensorspecifying the dates on which cashflows are settled. The shape of the input correspond to the number of instruments being created.fixing_date: A rank 1DateTensorspecifying the dates on which forward rate will be fixed. The shape of the inout should be the same as that ofsettlement_date.fixed_rate: A rank 1Tensorof real dtype specifying the fixed rate payment agreed at the initiation of the individual contracts. The shape should be the same as that ofsettlement_date.notional: A scalar or a rank 1Tensorof 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 aTensor, then the shape must be the same assettlement_date. Default value: 1.0daycount_convention: An optionalDayCountConventionto 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 1PeriodTensorspecifying the term (or the tenor) of the Libor rate that determines the floating cashflow. The shape of the input should be the same assettlement_date. Default value:Nonein which case the the forward rate is determined for the period [settlement_date, maturity_date].maturity_date: An optional rank 1DateTensorspecifying the maturity of the underlying forward rate for each contract. This input is only used if the inputrate_termisNone. Default value:Nonedtype: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:Nonewhich maps to ‘forward_rate_agreement’.
Raises:#
ValueError: If bothmaturity_dateandrate_termare unspecified.
Methods#
price
price(
valuation_date, market, model=None
)
Returns the present value of the instrument on the valuation date.
Args:#
valuation_date: A scalarDateTensorspecifying the date on which valuation is being desired.market: A namedtuple of typeInterestRateMarketwhich 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.