irs
Syntax
irs(settlement, resetInterval, start, maturity, notional, fixedRate, spread,
curve, frequency, calendar, [convention='ModifiedFollowing'], [basis=1],
[rateType=0])
Arguments
settlement is a DATE scalar or vector indicating the settlement date(s).
resetInterval is a DURATION scalar or vector indicating how often the interest rate is reset.
start is a DATE scalar or vector indicating the start date(s).
maturity is a DATE scalar or vector indicating the maturity date(s).
notional is a numeric scalar or vector indicating the notional amount.
fixedRate is a numeric scalar or vector indicating the fixed rate(s).
spread is a numeric scalar or vector indicating the spread of floating rate.
curve is a dictionary scalar or vector indicating the fitted yield curve.
frequency defines how often payments are made in the swap agreement.
- If it is an INT scalar or vector, it specifies the number of payments per year. For example, 1 means there's one payment annually.
- If it is a DURATION scalar or vector, it specifies time interval between payments. For example, "3M" means payments occur every 3 months (quarterly).
- It can take the following values:
- 1 / 1y: Annually. One payment per year.
- 2 / 6M: Semi-annually. Two payments per year, every 6 months.
- 3 / 4M: Triannually. Three payments per year, every 4 months
- 4 / 3M: Quarterly. Four payments per year, every 3 months.
- 6 / 2M: Bimonthly. Six payments per year, every 2 months.
- 12 / 1M: Monthly. 12 payments per year, once a month.
- 13 / 4w: Four-weekly. 13 payments per year, every 4 weeks.
- 26 / 2w: Fortnightly. 26 payments per year, every 2 weeks.
- 52 / 1w: Weekly. 52 payments per year, once a week.
- 365 / 1d: Daily. 365 payments per year, once a day.
calendar is a STRING scalar or vector indicating the trading calendar(s). See Trading Calendar for more information.
convention (optional) is a STRING scalar or vector indicating how cash flows that fall on a non-trading day are treated. It can be:
-
'Following': The following trading day.
-
'ModifiedFollowing' (default): The following trading day. If that day is in a different month, the preceding trading day is adopted instead.
-
'Preceding': The precedingtrading day.
-
'ModifiedPreceding': The preceding trading day. If that day is in a different month, the following trading day is adopted instead.
-
'Unadjusted': Unadjusted.
-
'HalfMonthModifiedFollowing': The following trading day. If that day crosses the mid-month (15th) or the end of month, the preceding trading day is adopted instead.
-
'Nearest': The nearest trading day. If both the preceding and following trading days are equally far away, default to following trading day.
basis (optional) is an INT scalar or vector indicating the day-count basis of the swap. It can be:
-
0: US (NASD) 30/360
-
1 (default): actual/actual
-
2: actual/360
-
3: actual/365
-
4: (European) 30/360
rateType (optional) is an INT scalar or vector indicating compound interest. It can be:
-
0 (default): continuous compounding
-
1: discrete compounding
Details
The irs
function prices an interest rate swap (IRS) for the
floating-rate side.
An IRS is a derivative contract in which two parties agree to exchange one stream of interest payments for another over a set period of time. The most commonly traded IRS is the exchange of a fixed interest rate payment and a floating rate payment (typically benchmarked to an interbank offered rate LIBOR).
Return Value: A DOUBLE scalar or vector.
Examples
This example describes an interest rate swap where fixed and floating rate payments are exchanged weekly over a 5-year period (2023.07.10-2028.01.10). The swap uses the XNYS calendar for determining trading days and applies a US (NASD) 30/360 day-count basis and continuous compounding for interest calculations.
settlement = 2023.07.10
calendar = `XNYS
day0 = temporalAdd(settlement, 0, calendar)
curveRateTime = [10y, 14d, 1d, 1M, 1y, 2y, 3M, 3y, 4y, 5y, 6M, 7d, 7y, 9M]
curveRateValue = [ 2.7013, 1.8, 1.27, 1.9425, 2.0263, 2.1265, 1.9725, 2.2438, 2.3575, 2.4538, 1.9938, 1.86, 2.5863, 2.0088] * 0.01
dates = []
for (dur in curveRateTime) {
dates.append!(temporalAdd(settlement, dur))
}
X = (dates - day0)$INT
// a curve for base rate (without spread)
curve = linearInterpolateFit(X, curveRateValue)
resetIntv = 7d
start = 2023.01.10
maturity = 2028.01.10
notional = 100.0
fixedRate = 0.02765
spread = 0.0
freq = 3M
basis = 0
irs(settlement, resetIntv, start, maturity, notional, fixedRate, spread, curve, freq, calendar, basis = basis)
// -1.54