Me gustaría utilizar QuantLib Python para calcular el roll-down a 6 meses de un swap a 5 años.
Creo que el cálculo que tengo que hacer es el siguiente:
$Rolldown=r_{0,5Y}-r_{0,4.5Y}$
Dónde $r_{0,5Y}$ es el tipo de interés al contado a 5 años y $r_{0,4.5Y}$ es el tipo de interés al contado de 4 años.
Puede encontrar la definición de "roll-down" en los siguientes enlaces:
https://e-markets.nordea.com/api/research/attachment/2796
http://www.gioa.us/presentations/2012/4-Rajappa.pdf
Por favor, dígame si mi ecuación es correcta.
Asumiendo que mi ecuación es correcta, lo siguiente es cómo intenté calcular el roll-down del swap usando QuantLib Python:
from QuantLib import *
# global data
calendar = TARGET()
todaysDate = Date(6,November,2001);
Settings.instance().evaluationDate = todaysDate
settlementDate = Date(8,November,2001);
# market quotes
deposits = { (1,Weeks): 0.0382,
(1,Months): 0.0372,
(3,Months): 0.0363,
(6,Months): 0.0353,
(9,Months): 0.0348,
(1,Years): 0.0345 }
swaps = { (2,Years): 0.037125,
(3,Years): 0.0398,
(5,Years): 0.0443,
(10,Years): 0.05165,
(15,Years): 0.055175 }
# convert them to Quote objects
for n,unit in deposits.keys():
deposits[(n,unit)] = SimpleQuote(deposits[(n,unit)])
for n,unit in swaps.keys():
swaps[(n,unit)] = SimpleQuote(swaps[(n,unit)])
# build rate helpers
dayCounter = Actual360()
settlementDays = 2
depositHelpers = [ DepositRateHelper(QuoteHandle(deposits[(n,unit)]),
Period(n,unit), settlementDays,
calendar, ModifiedFollowing,
False, dayCounter)
for n, unit in [(1,Weeks),(1,Months),(3,Months),
(6,Months),(9,Months),(1,Years)] ]
fixedLegFrequency = Annual
fixedLegTenor = Period(1,Years)
fixedLegAdjustment = Unadjusted
fixedLegDayCounter = Thirty360()
floatingLegFrequency = Semiannual
floatingLegTenor = Period(6,Months)
floatingLegAdjustment = ModifiedFollowing
swapHelpers = [ SwapRateHelper(QuoteHandle(swaps[(n,unit)]),
Period(n,unit), calendar,
fixedLegFrequency, fixedLegAdjustment,
fixedLegDayCounter, Euribor6M())
for n, unit in swaps.keys() ]
# term structure handles
discountTermStructure = RelinkableYieldTermStructureHandle()
forecastTermStructure = RelinkableYieldTermStructureHandle()
# term-structure construction
helpers = depositHelpers + swapHelpers
depoSwapCurve = PiecewiseFlatForward(settlementDate, helpers, Actual360())
swapEngine = DiscountingSwapEngine(discountTermStructure)
# 5Y Swap
nominal = 1000000
maturity1 = calendar.advance(settlementDate,5,Years)
fixedLegFrequency = Annual
fixedLegAdjustment = Unadjusted
fixedLegDayCounter = Thirty360()
fixedRate = 0.04
floatingLegFrequency = Semiannual
spread = 0.0
fixingDays = 2
index = Euribor6M(forecastTermStructure)
floatingLegAdjustment = ModifiedFollowing
floatingLegDayCounter = index.dayCounter()
fixedSchedule1 = Schedule(settlementDate, maturity1,
fixedLegTenor, calendar,
fixedLegAdjustment, fixedLegAdjustment,
DateGeneration.Forward, False)
floatingSchedule1 = Schedule(settlementDate, maturity1,
floatingLegTenor, calendar,
floatingLegAdjustment, floatingLegAdjustment,
DateGeneration.Forward, False)
spot1 = VanillaSwap(VanillaSwap.Receiver, nominal,
fixedSchedule1, fixedRate, fixedLegDayCounter,
floatingSchedule1, index, spread,
floatingLegDayCounter)
spot1.setPricingEngine(swapEngine)
# 4.5Y Swap
rolldown_period = Period(6, Months)
maturity2 = calendar.advance(maturity1, -rolldown_period)
fixedSchedule2 = Schedule(settlementDate, maturity2,
fixedLegTenor, calendar,
fixedLegAdjustment, fixedLegAdjustment,
DateGeneration.Forward, False)
floatingSchedule2 = Schedule(settlementDate, maturity2,
floatingLegTenor, calendar,
floatingLegAdjustment, floatingLegAdjustment,
DateGeneration.Forward, False)
spot2 = VanillaSwap(VanillaSwap.Receiver, nominal,
fixedSchedule2, fixedRate, fixedLegDayCounter,
floatingSchedule2, index, spread,
floatingLegDayCounter)
spot2.setPricingEngine(swapEngine)
# price on two different evaluation dates
discountTermStructure.linkTo(depoSwapCurve)
forecastTermStructure.linkTo(depoSwapCurve)
spot5Y = spot1.fairRate()
spot4Y6M = spot2.fairRate()
print('5Y spot rate')
print(spot5Y)
print('4.5Y spot rate')
print(spot4Y6M)
print('6 month roll down')
print(spot5Y - spot4Y6M)
¿Estoy en lo cierto en cuanto a cómo utilizar QuantLib Python para calcular el roll-down a 6 meses de un swap a 5 años? ¿Es necesario crear 2 objetos de swap como he hecho para calcular el roll-down del swap?