|
From: Mike D. <mik...@gm...> - 2022-11-13 19:02:12
|
You will have to bump the 2y spot rate and revalue your swap, then diff the
npvs. As an alternative you can also shift the entire zero curve (using
ql.ZeroSpreadedTermStructure) and price the swap on that curve and then
diff the npvs. I believe this is detailed in the quantlib cookbook if you
want examples.
Personally, I’ve always kept two separate curve objects (original and
shifted), even though I know the code is supposed to support changing
quotes on the fly etc. For some reason I’ve always encountered memory leaks
when using relinkable term structure handles, but it’s probably an
implementation error or my end if I had to guess.
Hope that helps.
-Mike
On Sun, Nov 13, 2022 at 12:32 Christofer Bogaso <bog...@gm...>
wrote:
> 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.
>
>
> _______________________________________________
> QuantLib-users mailing list
> Qua...@li...
> https://lists.sourceforge.net/lists/listinfo/quantlib-users
>
|