# (IRS) ----------------------------------------------------------------------
valuation.swaps(maturity = "2026-06-01", analysis.date= Sys.Date(),
coupon.rate = 0.06, rates = 0.08, float.rate = 0.03)
valuation.swaps(maturity = "2021-03-09", analysis.date= "2018-03-09",
coupon.rate = 0.05, rates = 0.08, rate.type = 0)
valuation.swaps(maturity = "2026-07-01", analysis.date = "2023-01-02",
asset.type = "IBRSwaps", freq = 4,
coupon.rate = 0.04, rates = rep(0.05,14),
float.rate = 0.03, spread = 0)
# (CCS) ----------------------------------------------------------------------
# Curve Calibration for rates input
yield.curve <- c(0.103,0.1034,0.1092, 0.1161, 0.1233, 0.1280, 0.1310, 0.1320, 0.1325)
names(yield.curve) <- c(0,0.08,0.25,0.5,1,2,3,5,6)
nodes <- seq(0, 10, by = 0.001) # Our curve has nodes with three decimals.
rates <- curve.calibration (yield.curve = yield.curve, market.assets = NULL,
analysis.date = "2023-03-01", asset.type = "IBRSwaps",
freq = 4, rate.type = 0, daycount= "ACT/365",
fwd = 0, npieces = NULL, nodes = nodes, approximation = "constant")
# Curve Calibration for basis.rates input
nodes <- seq(0, 10, by = 0.001)
rates2 <- rates/4 # It is assumed foreign curve is proportional to local spot curve.
# Swaps input for calibration
ex.rate <- 4814
swaps <- rbind(c("2024-03-01", "FF", 0.07 , 0.0325, NA , NA , 2000 * ex.rate, 2000),
c("2025-03-01", "VV", NA , NA , 0.015, 0.0175, 2000 * ex.rate, 2000),
c("2026-03-01", "FF", 0.075, 0.03 , NA , NA , 500000, 5000000 / ex.rate),
c("2027-03-01", "VV", NA , NA , 0.01 , 0.015 , 5000000, 5000000 / ex.rate),
c("2028-03-01", "FF", 0.08 ,0.035 , NA , NA , 3000000, 3000000 / ex.rate),
c("2029-03-01", "VV", NA , NA , 0.01 , 0.0125, 3000000, 3000000 / ex.rate))
colnames(swaps) <- c("Mat" ,"Legs", "C1" , "C2", "spread1", "spread2", "prin1", "prin2")
# Calibration
basis.rates <- basis.curve(swaps, ex.rate = 4814, analysis.date = "2023-03-01",
freq = c(2,2,2,2,1,1), rates = rates, rates2 = rates2,
rate.type = 1, npieces = NULL, obj = "Price",
Weights = NULL, nodes = nodes, approximation = "linear")
# Valuation
valuation.swaps (maturity = "2024-03-01", analysis.date = "2023-03-01",
asset.type = "CCS", freq = 2, Legs = "FF", ex.rate = 4814,
coupon.rate = 0.07, coupon.rate2 = 0.0325,
rates = rates, rates2 = rates2, basis.rates = basis.rates,
float.rate = NULL, float.rate2 = NULL, spread = 0,
spread2 = 0, principal = 2000 * 4814, principal2 = 2000,
rate.type = 0, daycount = "ACT/365", loc = "BOG",
convention = "F")
Run the code above in your browser using DataLab