|
From: Renren D. <dr...@gm...> - 2023-12-23 00:36:04
|
Hi Quantlib Users,
I am very new to QuantLib and its Python interface, so apologies if this
was obvious.
I was trying to figure out how to use ql.SabrSwaptionVolatilityCube, I
can't seem to find a working example on how to work.
Here are the closest I got so far.
many thanks in advance,
thank you
-Renren
optionTenors = ['1y', '2y', '3y']
swapTenors = [ '5Y', '10Y']
normal_vols = [
[50, 60],
[70, 80],
[90, 95]]
normal_vols = [[vol / 10000 for vol in row] for row in normal_vols]
swapTenors = [ql.Period(tenor) for tenor in swapTenors]
optionTenors = [ql.Period(tenor) for tenor in optionTenors]
normal_vols = [[vol / 10000 for vol in row] for row in normal_vols]
calendar = ql.TARGET()
bdc = ql.ModifiedFollowing
dayCounter = ql.ActualActual(1)
swaptionVolMatrix = ql.SwaptionVolatilityMatrix(calendar
, bdc
, optionTenors
, swapTenors
, ql.Matrix(normal_vols)
, dayCounter
, False
, ql.Normal)
swaptionVolHandle = ql.SwaptionVolatilityStructureHandle(swaptionVolMatrix)
strikeSpreads = [ -0.01, 0.0, 0.01]
volSpreads = [
[0.5, 0.55, 0.6],
[0.5, 0.55, 0.6],
[0.5, 0.55, 0.6],
[0.5, 0.55, 0.6],
[0.5, 0.55, 0.6],
[0.5, 0.55, 0.6],
]
###
oisQuote = ql.QuoteHandle(ql.SimpleQuote(0.04))
ytsOis = ql.FlatForward(today, oisQuote, ql.Actual360())
ytsOis.enableExtrapolation()
t0_Ois = ql.YieldTermStructureHandle(ytsOis)
swapIndexBase = ql.EuriborSwapIsdaFixA(ql.Period(1, ql.Years), t0_Ois,
t0_Ois)
shortSwapIndexBase = ql.EuriborSwapIsdaFixA(ql.Period(1, ql.Years), t0_Ois,
t0_Ois)
##
vegaWeightedSmileFit = False
ql.SabrSwaptionVolatilityCube( swaptionVolHandle,
optionTenors,
swapTenors,
strikeSpreads,
volSpreads,
swapIndexBase,
shortSwapIndexBase,
vegaWeightedSmileFit,
[(0.1,0.1,0.1,0.1) ] * 6,
(False, False, False, False),
True
)
|