|
From: Christofer B. <bog...@gm...> - 2022-11-13 18:29:18
|
Hi,
I have below interest rate swap contract
from QuantLib import *
calc_date = Date(31, 12, 2013)
Settings.instance().evaluationDate = calc_date
spot_dates = [calc_date + Period("1d"), calc_date + Period("1w"),
calc_date + Period("1m"), calc_date + Period("2m"), calc_date +
Period("3m"), calc_date + Period("6m"),
calc_date + Period("1y"), calc_date + Period("2y"),
calc_date + Period("3y"), calc_date + Period("4y"), calc_date +
Period("5y"),
calc_date + Period("7y"), calc_date + Period("10y"),
calc_date + Period("30y")]
spot_rates = [0.1/100, 0.13/100, 0.17/100, 0.21/100, 0.2461/100,
0.35/100, 0.31/100, 0.49/100, 0.87/100, 1.33/100, 1.78/100, 2.47/100,
3.09/100, 3.91/100]
us_calendar = UnitedStates()
zero_curve = ZeroCurve(spot_dates, spot_rates, Actual365Fixed(),
us_calendar, Linear(), Compounded, Annual)
termStructure = YieldTermStructureHandle(zero_curve)
swap = VanillaSwap(VanillaSwap.Payer,
100,
Schedule(Date(1, 12, 2014) + Period("6m"),
Date(1, 12, 2019), Period(6, Months), us_calendar, Unadjusted,
Unadjusted, DateGeneration.Forward, False),
3/100,
Thirty360(Thirty360.BondBasis),
Schedule(Date(1, 12, 2014) + Period("6m"),
Date(1, 12, 2019), Period(6, Months), us_calendar, Unadjusted,
Unadjusted, DateGeneration.Forward, False),
USDLibor(Period(6, Months), termStructure),
0.0,
USDLibor(Period(6, Months), termStructure).dayCounter()
)
swap.setPricingEngine(DiscountingSwapEngine(termStructure))
I am wondering if there is any method available to calculate the Delta
sensitivity of this Swap contract w.r.t. different sopt rate e.g. let
say 2 year spot rate that was used to constract the term structure.
Any pointer will be very helpful.
Many thanks for your time.
|