never executed always true always false
1 -- GENERATED by C->Haskell Compiler, version 0.28.8 Switcheroo, 25 November 2017 (Haskell)
2 -- Edit the ORIGNAL .chs file instead!
3
4
5 {-# LANGUAGE TemplateHaskell, FlexibleInstances #-}
6 module QuantLib.TermStructure.Volatility
7 (
8 -- * Types
9 -- ** Volatility hierarchies
10 GenVolatilityTermStructure
11 , VolatilityTermStructure
12 , GenBlackVolTermStructure
13 , BlackVolTermStructure
14 , RelinkableBlackVolTermStructure
15 , BlackVarianceCurve
16 , BlackVolatilitySurfaceDelta
17 , GenBlackAtmVolCurve
18 , BlackAtmVolCurve
19 , AbcdAtmVolCurve
20 , GenBlackVolSurface
21 , BlackVolSurface
22 , SabrVolSurface
23 , GenLocalVolTermStructure
24 , LocalVolTermStructure
25 , GridModelLocalVolSurface
26 , AndreasenHugeVolatilityInterpl
27 , GenCapFloorTermVolatilityStructure
28 , CapFloorTermVolatilityStructure
29 , CapFloorTermVolCurve
30 , CapFloorTermVolSurface
31 , GenOptionletVolatilityStructure
32 , OptionletVolatilityStructure
33 , RelinkableOptionletVolatilityStructure
34 , OptionletStripper2
35 , GenSwaptionVolatilityStructure
36 , SwaptionVolatilityStructure
37 , RelinkableSwaptionVolatilityStructure
38 , SwaptionVolatilityMatrix
39 , SabrSwaptionVolatilityCube
40 , NoArbSabrSwaptionVolatilityCube
41 , ZabrSwaptionVolatilityCube
42 , InterpolatedSwaptionVolatilityCube
43 , CallableBondVolatilityStructure
44 , SmileSection
45 , SabrInterpolatedSmileSection
46 , SviInterpolatedSmileSection
47 , NoArbSabrInterpolatedSmileSection
48 , ZabrInterpolatedSmileSection
49
50 -- ** Configuration and extrapolation
51 , BlackVarianceSurfaceExtrapolation(..)
52 , ExtendedBlackVarianceSurfaceExtrapolation(..)
53 , FixedLocalVolSurfaceExtrapolation(..)
54 , AndreasenHugeInterpolationType(..)
55 , AndreasenHugeCalibrationType(..)
56 , ZabrEvaluation(..)
57 , SmileInterpolationMethod(..)
58 , BlackVolTimeExtrapolationType(..)
59 , BlackVolatilitySurfaceDeltaOpts(..)
60 , SabrInterpolatedSmileSectionOpts(..)
61
62 -- ** Coordinates
63 , Reference(..)
64 , CalendarReference(..)
65 , TermPoint(..)
66 , TermInterval(..)
67 , RatePoint(..)
68 , OptionMaturity(..)
69 , SwapMaturity(..)
70 , CallableBondMaturity(..)
71 , CallableBondSmileMaturity(..)
72 , SabrVolatilitySpreadsMaturity(..)
73 , AtmStrikeMaturity(..)
74
75 -- * Constructors
76 -- ** Hierarchy conversions
77 , asVolatilityTermStructure
78 , asBlackVolTermStructure
79 , asOptionletVolatilityStructure
80 , sabrAsSmileSection
81 , sviAsSmileSection
82 , noArbSabrAsSmileSection
83 , zabrInterpolatedAsSmileSection
84
85 -- ** Optionlet and cap-floor volatility
86 , localVolSurface
87 , constantOptionletVolatility
88 , capletVarianceCurve
89 , optionletStripper
90 , optionletStripperWithAtm
91
92 -- ** Black, local and swaption volatility
93 , impliedVolTermStructure
94 , blackConstantVol
95 , sabrVolTermStructure
96 , relinkableBlackVolTermStructure
97 , constantSwaptionVolatility
98 -- ** Smile sections and parametrizations
99 , defaultSabrInterpolatedSmileSectionOpts
100 , sabrSmileSection
101 , sabrSmileSectionAtDate
102 , noArbSabrSmileSection
103 , sabrInterpolatedSmileSection
104 , sviInterpolatedSmileSection
105 , noArbSabrInterpolatedSmileSection
106 , zabrInterpolatedSmileSection
107 , flatSmileSection
108 , spreadedSmileSection
109 , atmSmileSection
110 , sviSmileSection
111 , zabrSmileSection
112 -- ** Bond and cap-floor structures
113 , callableBondConstantVolatility
114 , constantCapFloorTermVolatility
115 -- ** ATM curves and SABR surfaces
116 , abcdAtmVolCurve
117 , sabrVolSurface
118 -- ** Relinkable and spreaded structures
119 , spreadedSwaptionVolatility
120 , gaussian1dSwaptionVolatility
121 , spreadedOptionletVol
122 , relinkableSwaptionVolatilityStructure
123 , relinkableOptionletVolatilityStructure
124 -- ** Curves and surfaces
125 , localConstantVol
126 , localVolCurve
127 , capFloorTermVolCurve
128 , blackVarianceCurve
129 , extendedBlackVarianceCurve
130 , extendedBlackVarianceSurface
131 , capFloorTermVolSurface
132 , blackVarianceSurface
133 , piecewiseBlackVarianceSurface
134 , blackVolatilitySurfaceDelta
135 , blackVolatilitySurfaceDeltaWithOptions
136 , defaultBlackVolatilitySurfaceDeltaOpts
137 -- ** Swaption matrices and cubes
138 , swaptionVolatilityMatrix
139 , sabrSwaptionVolatilityCube
140 , noArbSabrSwaptionVolatilityCube
141 , zabrSwaptionVolatilityCube
142 , interpolatedSwaptionVolatilityCube
143 , swaptionVolatilityMatrixMoving
144 -- ** Local-volatility and Andreasen-Huge models
145 , noExceptLocalVolSurface
146 , fixedLocalVolSurface
147 , gridModelLocalVolSurface
148 , gridModelLocalVolSurfaceAsCalibratedModel
149 , hestonBlackVolSurface
150 , andreasenHugeVolatilityInterpolation
151 , andreasenHugeVolatilityAdapter
152 , andreasenHugeLocalVolAdapter
153 -- * Mutators
154 , linkBlackVolTo
155 , linkSwaptionVolTo
156 , linkOptionletVolTo
157
158 -- * Inspectors
159 -- ** Strike and maturity capabilities
160 , HasStrikeBounds(..)
161 , HasAtmStrike(..)
162 , optionDateFromTenor
163
164 -- ** Optionlet and cap-floor volatility
165 , atmCapFloorStrikes
166 , atmCapFloorPrices
167 , spreadsVol
168 , capFloorVolatility
169 , capFloorTermVolCurveOptionDates
170 , capFloorTermVolCurveOptionTimes
171 , capFloorTermVolSurfaceOptionDates
172 , capFloorTermVolSurfaceOptionTimes
173 -- ** Black and local volatility
174 , blackVol
175 , blackVolVariance
176 , blackForwardVol
177 , blackForwardVariance
178 , localVol
179 , blackVolSmile
180 , blackVolSurfaceSmileSection
181 -- ** Swaption and callable-bond volatility
182 , swaptionVolatility
183 , swaptionBlackVariance
184 , maxSwapLength
185 , maxSwapTenor
186 , smileSection
187 , swapLengthBetweenDates
188 , swapLength
189 , callableBondVolatility
190 , callableBondBlackVariance
191 , callableBondSmileSection
192 , maxBondTenor
193 -- ** Smile values and calibration results
194 , smileSectionVolatility
195 , smileSectionVariance
196 , smileSectionAtmLevel
197 , smileSectionOptionPrice
198 , smileSectionDigitalOptionPrice
199 , smileSectionDensity
200 , smileSectionVega
201 , sabrAlpha
202 , sabrBeta
203 , sabrNu
204 , sabrRho
205 , sabrRmsError
206 , sabrMaxError
207 , sabrCalibrationEndCriteria
208 , sviA
209 , sviB
210 , sviSigma
211 , sviRho
212 , sviM
213 , sviRmsError
214 , sviMaxError
215 , sviEndCriteria
216 , noArbSabrAlpha
217 , noArbSabrBeta
218 , noArbSabrNu
219 , noArbSabrRho
220 , noArbSabrRmsError
221 , noArbSabrMaxError
222 , noArbSabrEndCriteria
223 , zabrInterpolatedAlpha
224 , zabrInterpolatedBeta
225 , zabrInterpolatedNu
226 , zabrInterpolatedRho
227 , zabrInterpolatedGamma
228 , zabrInterpolatedRmsError
229 , zabrInterpolatedMaxError
230 , zabrInterpolatedEndCriteria
231 -- ** ATM curves and SABR surfaces
232 , atmVol
233 , atmVariance
234 , abcdA
235 , abcdB
236 , abcdC
237 , abcdD
238 , abcdRmsError
239 , abcdMaxError
240 , abcdEndCriteria
241 , abcdK
242 , abcdKs
243 , abcdAtmVolCurveOptionTenors
244 , abcdOptionTenorsInInterpolation
245 , abcdOptionDates
246 , abcdOptionTimes
247 , sabrVolSurfaceAtmCurve
248 , sabrVolSurfaceIndex
249 , sabrVolSurfaceOptionDateFromTenor
250 , sabrVolatilitySpreads
251 -- ** Swaption matrices and cubes
252 , swaptionVolatilityMatrixLocate
253 , interpolatedSwaptionVolatilityCubeVolSpreads
254 , sparseSabrParameters
255 , denseSabrParameters
256 , marketVolCube
257 , volCubeAtmCalibrated
258 , noArbSabrSparseSabrParameters
259 , noArbSabrDenseSabrParameters
260 , noArbSabrMarketVolCube
261 , noArbSabrVolCubeAtmCalibrated
262 , zabrSparseParameters
263 , zabrDenseParameters
264 , zabrMarketVolCube
265 , zabrVolCubeAtmCalibrated
266 -- ** Andreasen-Huge results
267 , andreasenHugeCalibrationError
268 , andreasenHugeForward
269 , andreasenHugeOptionPrice
270 , andreasenHugeLocalVol
271 ) where
272 import qualified Foreign.C.Types as C2HSImp
273 import qualified Foreign.ForeignPtr as C2HSImp
274 import qualified Foreign.Marshal.Utils as C2HSImp
275 import qualified Foreign.Ptr as C2HSImp
276
277
278 import QuantLib.Internal
279 import QuantLib.InterestRate(VolatilityType)
280 import QuantLib.Math(EndCriteriaType, ComplexLogFormula)
281 import QuantLib.Quote(DeltaType(..), AtmType(..))
282 import QuantLib.Internal.Type
283 import QuantLib.Internal.Common
284 import QuantLib.Internal.Syntax(deriveOptionsRecord)
285 import QuantLib.TermStructure(Reference(..), CalendarReference(..), TermPoint(..), TermInterval(..), RatePoint(..))
286 import QuantLib.Time.Schedule(dayCounter, DayCounterConstructor(..))
287 import Data.List.NonEmpty(NonEmpty, toList)
288 import Foreign.Marshal.Alloc(alloca)
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378 data BlackVarianceSurfaceExtrapolation = BlackVarianceSurfaceConstantExtrapolation
379 | BlackVarianceSurfaceInterpolatorDefaultExtrapolation
380 deriving (Enum,Show,Eq,Read)
381
382
383 data ExtendedBlackVarianceSurfaceExtrapolation = ExtendedBlackVarianceSurfaceConstantExtrapolation
384 | ExtendedBlackVarianceSurfaceInterpolatorDefaultExtrapolation
385 deriving (Enum,Show,Eq,Read)
386
387
388
389 -- |'BlackVolatilitySurfaceDelta::SmileInterpolationMethod', local to that class -- not shared
390 -- with any other binding, so declared here rather than in 'QuantLib.Internal.Common'.
391 data SmileInterpolationMethod = SmileLinear
392 | NaturalCubic
393 | FinancialCubic
394 | CubicSpline
395 deriving (Enum,Show,Eq,Read)
396
397
398
399 -- |'BlackVolTimeExtrapolation::Type', consumed only by 'blackVolatilitySurfaceDelta' today --
400 -- same local-declaration treatment as 'SmileInterpolationMethod'. Named
401 -- @BlackVolTimeExtrapolationType@ (rather than reusing the bare @Type@ c2hs would otherwise
402 -- emit) to avoid a top-level name clash.
403 data BlackVolTimeExtrapolationType = FlatVolatility
404 | UseInterpolator
405 | LinearVariance
406 deriving (Enum,Show,Eq,Read)
407
408
409
410 -- |'FixedLocalVolSurface::Extrapolation', local to that class -- not shared with any other
411 -- binding, same local-declaration treatment as 'SmileInterpolationMethod'.
412 data FixedLocalVolSurfaceExtrapolation = FixedLocalVolSurfaceConstantExtrapolation
413 | FixedLocalVolSurfaceInterpolatorDefaultExtrapolation
414 deriving (Enum,Show,Eq,Read)
415
416
417 data AndreasenHugeInterpolationType = AndreasenHugeInterpolationPiecewiseConstant
418 | AndreasenHugeInterpolationLinear
419 | AndreasenHugeInterpolationCubicSpline
420 deriving (Enum,Show,Eq,Read)
421
422
423
424 -- |'ZabrSmileSection'\'s evaluation-tag axis (Andreasen\/Huge 2011): 'ZabrShortMaturityLognormal'\/
425 -- 'ZabrShortMaturityNormal' are closed-form short-maturity expansions (fast, less accurate away
426 -- from short maturities); 'ZabrLocalVolatility' and 'ZabrFullFd' solve a finite-difference PDE
427 -- (slower, more accurate). Local to this binding -- not shared with any other cross-cutting enum.
428 data ZabrEvaluation = ZabrShortMaturityLognormal
429 | ZabrShortMaturityNormal
430 | ZabrLocalVolatility
431 | ZabrFullFd
432 deriving (Show,Eq,Read)
433 instance Enum ZabrEvaluation where
434 succ ZabrShortMaturityLognormal = ZabrShortMaturityNormal
435 succ ZabrShortMaturityNormal = ZabrLocalVolatility
436 succ ZabrLocalVolatility = ZabrFullFd
437 succ ZabrFullFd = error "ZabrEvaluation.succ: ZabrFullFd has no successor"
438
439 pred ZabrShortMaturityNormal = ZabrShortMaturityLognormal
440 pred ZabrLocalVolatility = ZabrShortMaturityNormal
441 pred ZabrFullFd = ZabrLocalVolatility
442 pred ZabrShortMaturityLognormal = error "ZabrEvaluation.pred: ZabrShortMaturityLognormal has no predecessor"
443
444 enumFromTo from to = go from
445 where
446 end = fromEnum to
447 go v = case compare (fromEnum v) end of
448 LT -> v : go (succ v)
449 EQ -> [v]
450 GT -> []
451
452 enumFrom from = enumFromTo from ZabrFullFd
453
454 fromEnum ZabrShortMaturityLognormal = 0
455 fromEnum ZabrShortMaturityNormal = 1
456 fromEnum ZabrLocalVolatility = 2
457 fromEnum ZabrFullFd = 3
458
459 toEnum 0 = ZabrShortMaturityLognormal
460 toEnum 1 = ZabrShortMaturityNormal
461 toEnum 2 = ZabrLocalVolatility
462 toEnum 3 = ZabrFullFd
463 toEnum unmatched = error ("ZabrEvaluation.toEnum: Cannot match " ++ show unmatched)
464
465
466
467 -- |Calibration choice for Andreasen-Huge local-volatility calibration.
468 data AndreasenHugeCalibrationType = AndreasenHugeCalibrationAndreasenHugePut
469 | AndreasenHugeCalibrationCallPut
470 | AndreasenHugeCalibrationAndreasenHugeCall
471 deriving (Show,Eq,Read)
472 instance Enum AndreasenHugeCalibrationType where
473 succ AndreasenHugeCalibrationAndreasenHugePut = AndreasenHugeCalibrationCallPut
474 succ AndreasenHugeCalibrationCallPut = AndreasenHugeCalibrationAndreasenHugeCall
475 succ AndreasenHugeCalibrationAndreasenHugeCall = error "AndreasenHugeCalibrationType.succ: AndreasenHugeCalibrationAndreasenHugeCall has no successor"
476
477 pred AndreasenHugeCalibrationCallPut = AndreasenHugeCalibrationAndreasenHugePut
478 pred AndreasenHugeCalibrationAndreasenHugeCall = AndreasenHugeCalibrationCallPut
479 pred AndreasenHugeCalibrationAndreasenHugePut = error "AndreasenHugeCalibrationType.pred: AndreasenHugeCalibrationAndreasenHugePut has no predecessor"
480
481 enumFromTo from to = go from
482 where
483 end = fromEnum to
484 go v = case compare (fromEnum v) end of
485 LT -> v : go (succ v)
486 EQ -> [v]
487 GT -> []
488
489 enumFrom from = enumFromTo from AndreasenHugeCalibrationAndreasenHugeCall
490
491 fromEnum AndreasenHugeCalibrationAndreasenHugePut = (-1)
492 fromEnum AndreasenHugeCalibrationCallPut = 0
493 fromEnum AndreasenHugeCalibrationAndreasenHugeCall = 1
494
495 toEnum (-1) = AndreasenHugeCalibrationAndreasenHugePut
496 toEnum 0 = AndreasenHugeCalibrationCallPut
497 toEnum 1 = AndreasenHugeCalibrationAndreasenHugeCall
498 toEnum unmatched = error ("AndreasenHugeCalibrationType.toEnum: Cannot match " ++ show unmatched)
499
500
501
502 -- |The option-maturity coordinate of a swaption volatility query.
503 data OptionMaturity
504 = OptionDate Day
505 | OptionTime Double
506 | OptionTenor (Word, TimeUnit)
507 deriving (Eq, Show)
508
509 -- |The underlying-swap maturity coordinate of a swaption volatility query.
510 data SwapMaturity
511 = SwapLength Double
512 | SwapTenor (Word, TimeUnit)
513 deriving (Eq, Show)
514
515 -- |Supported option and bond maturity pairs for callable-bond volatility queries.
516 data CallableBondMaturity
517 = CallableBondTimeLength !Double !Double
518 | CallableBondDateTenor !Day !(Word, TimeUnit)
519 | CallableBondTenorTenor !(Word, TimeUnit) !(Word, TimeUnit)
520 deriving (Eq, Show)
521
522 -- |Supported maturity pairs for callable-bond smile-section queries.
523 data CallableBondSmileMaturity
524 = CallableBondSmileDateTenor !Day !(Word, TimeUnit)
525 | CallableBondSmileTenorTenor !(Word, TimeUnit) !(Word, TimeUnit)
526 deriving (Eq, Show)
527
528 -- |Option maturities accepted by 'sabrVolatilitySpreads'.
529 data SabrVolatilitySpreadsMaturity
530 = SabrVolatilitySpreadsDate !Day
531 | SabrVolatilitySpreadsTenor !(Word, TimeUnit)
532 deriving (Eq, Show)
533
534 -- |Option maturities accepted by swaption-cube 'atmStrike' queries.
535 data AtmStrikeMaturity
536 = AtmStrikeDate !Day
537 | AtmStrikeTenor !(Word, TimeUnit)
538 deriving (Eq, Show)
539
540 -- SabrInterpolatedSmileSectionOpts bundles every trailing param
541 -- sabrInterpolatedSmileSection_ hardcodes, pre-populated with upstream's own defaults,
542 -- overridden through record-update syntax -- see OISRateHelperOpts (QuantLib.TermStructure.Yield)
543 -- for the worked example this follows. dayCounter is Maybe here (unlike the raw binding's
544 -- plain DayCounter) since a real DayCounter is only obtainable in IO (`dayCounter
545 -- Actual365FixedStandard`) and can't live in a pure default record value;
546 -- sabrInterpolatedSmileSection substitutes a fresh Actual365Fixed for Nothing, same as
547 -- OISRateHelperOpts does for its Calendar fields. This splice must stay textually before
548 -- every {#fun#}-generated binding in this file -- see the comment above OISRateHelperOpts
549 -- for why (c2hs always appends its raw foreign-import stubs at the physical end of the
550 -- generated module regardless of where a {#fun#} hook appears in the source).
551 $(deriveOptionsRecord "SabrInterpolatedSmileSectionOpts" []
552 [ ("sabrIsAlphaFixed", [t|Bool|], [|False|])
553 , ("sabrIsBetaFixed", [t|Bool|], [|False|])
554 , ("sabrIsNuFixed", [t|Bool|], [|False|])
555 , ("sabrIsRhoFixed", [t|Bool|], [|False|])
556 , ("sabrVegaWeighted", [t|Bool|], [|True|])
557 , ("sabrEndCriteria", [t|Maybe EndCriteria|], [|Nothing|])
558 , ("sabrOptimizationMethod", [t|Maybe OptimizationMethod|], [|Nothing|])
559 , ("sabrDayCounter", [t|Maybe DayCounter|], [|Nothing|])
560 , ("sabrShift", [t|Double|], [|0.0|])
561 ])
562
563 -- BlackVolatilitySurfaceDeltaOpts bundles every trailing defaulted param of
564 -- 'BlackVolatilitySurfaceDelta''s one constructor (deltaType through longTermAtmDeltaType),
565 -- pre-populated with upstream's own defaults via defaultBlackVolatilitySurfaceDeltaOpts,
566 -- overridden through record-update syntax at the call site -- see OISRateHelperOpts
567 -- (QuantLib.TermStructure.Yield) for the worked example this follows. Same
568 -- splice-placement constraint as SabrInterpolatedSmileSectionOpts above.
569 $(deriveOptionsRecord "BlackVolatilitySurfaceDeltaOpts" []
570 [ ("bvsdDeltaType", [t|DeltaType|], [|Spot|])
571 , ("bvsdAtmType", [t|AtmType|], [|AtmDeltaNeutral|])
572 , ("bvsdAtmDeltaType", [t|Maybe DeltaType|], [|Nothing|])
573 , ("bvsdInterpolationMethod", [t|SmileInterpolationMethod|], [|SmileLinear|])
574 , ("bvsdFlatStrikeExtrapolation", [t|Bool|], [|False|])
575 , ("bvsdTimeExtrapolationType", [t|BlackVolTimeExtrapolationType|], [|FlatVolatility|])
576 , ("bvsdSwitchTenor", [t|(Int, TimeUnit)|], [|(0, Days)|])
577 , ("bvsdLongTermDeltaType", [t|DeltaType|], [|Fwd|])
578 , ("bvsdLongTermAtmType", [t|AtmType|], [|AtmDeltaNeutral|])
579 , ("bvsdLongTermAtmDeltaType", [t|Maybe DeltaType|], [|Nothing|])
580 ])
581
582 -- |A local vol surface derived from a Black vol surface via Dupire's formula (Gatheral's
583 -- implementation).
584 localVolSurface :: (GenBlackVolTermStructure bv) -> (GenYieldTermStructure y1) -- ^riskFreeTS
585 -> (GenYieldTermStructure y2) -- ^dividendTS
586 -> (GenQuote q) -- ^underlying
587 -> IO ((LocalVolTermStructure))
588 localVolSurface a1 a2 a3 a4 =
589 withBlackVolTermStructure a1 $ \a1' ->
590 withYieldTermStructure a2 $ \a2' ->
591 withYieldTermStructure a3 $ \a3' ->
592 withQuote a4 $ \a4' ->
593 preErrorCheck $ \a5' ->
594 localVolSurface'_ a1' a2' a3' a4' a5' >>= \res ->
595 peekLocalVolTermStructure res >>= \res' ->
596 errorCheck a5'>>
597 return (res')
598
599
600
601 -- |as 'localVolSurface', but a local vol calculation that would otherwise throw returns
602 -- @illegalLocalVolOverwrite@ instead
603 noExceptLocalVolSurface :: (GenBlackVolTermStructure bv) -> (GenYieldTermStructure y1) -- ^riskFreeTS
604 -> (GenYieldTermStructure y2) -- ^dividendTS
605 -> (GenQuote q) -- ^underlying
606 -> (Double) -- ^illegalLocalVolOverwrite
607 -> IO ((LocalVolTermStructure))
608 noExceptLocalVolSurface a1 a2 a3 a4 a5 =
609 withBlackVolTermStructure a1 $ \a1' ->
610 withYieldTermStructure a2 $ \a2' ->
611 withYieldTermStructure a3 $ \a3' ->
612 withQuote a4 $ \a4' ->
613 let {a5' = realToFrac a5} in
614 preErrorCheck $ \a6' ->
615 noExceptLocalVolSurface'_ a1' a2' a3' a4' a5' a6' >>= \res ->
616 peekLocalVolTermStructure res >>= \res' ->
617 errorCheck a6'>>
618 return (res')
619
620
621
622 -- |a local vol surface fed directly from a matrix of local vols (rather than derived from a
623 -- Black vol surface, as 'localVolSurface' is) -- one flat strike grid shared across all dates,
624 -- same shape as 'blackVarianceSurface'.
625 fixedLocalVolSurface :: Day -> [Day] -- ^dates
626 -> [Double] -- ^strikes
627 -> RealMatrix -- ^localVolMatrix
628 -> DayCounter
629 -> FixedLocalVolSurfaceExtrapolation -- ^lowerExtrapolation
630 -> FixedLocalVolSurfaceExtrapolation -- ^upperExtrapolation
631 -> IO LocalVolTermStructure
632 fixedLocalVolSurface d ds s (RealMatrix mr mc md) = qlFixedLocalVolSurface d ds s mr mc md
633 qlFixedLocalVolSurface :: (Day) -> ([Day]) -> ([Double]) -> (Word) -> (Word) -> (RealVector) -> (DayCounter) -> (FixedLocalVolSurfaceExtrapolation) -> (FixedLocalVolSurfaceExtrapolation) -> IO ((LocalVolTermStructure))
634 qlFixedLocalVolSurface a1 a2 a3 a4 a5 a6 a7 a8 a9 =
635 withDay a1 $ \a1' ->
636 withDayArray a2 $ \(a2'1, a2'2) ->
637 withDoubleArray a3 $ \(a3'1, a3'2) ->
638 let {a4' = fromIntegral a4} in
639 let {a5' = fromIntegral a5} in
640 withRealVectorRaw a6 $ \a6' ->
641 withDayCounter a7 $ \a7' ->
642 let {a8' = (fromIntegral . fromEnum) a8} in
643 let {a9' = (fromIntegral . fromEnum) a9} in
644 preErrorCheck $ \a10' ->
645 qlFixedLocalVolSurface'_ a1' a2'1 a2'2 a3'1 a3'2 a4' a5' a6' a7' a8' a9' a10' >>= \res ->
646 peekLocalVolTermStructure res >>= \res' ->
647 errorCheck a10'>>
648 return (res')
649
650
651
652 -- |A local-volatility surface whose node values are model parameters. Each date is paired with
653 -- its non-empty strike row, so this genuinely ragged grid does not masquerade as a rectangular
654 -- 'Matrix'. Use 'gridModelLocalVolSurfaceAsCalibratedModel' to access QuantLib's generic
655 -- calibrated-model operations.
656 gridModelLocalVolSurface :: Day -> NonEmpty (Day, NonEmpty Double) -> DayCounter
657 -> FixedLocalVolSurfaceExtrapolation -> FixedLocalVolSurfaceExtrapolation
658 -> IO GridModelLocalVolSurface
659 gridModelLocalVolSurface d nodes = qlGridModelLocalVolSurface d dates rowSizes values
660 where
661 (dates, rows) = unzip (toList nodes)
662 rowLists = map toList rows
663 rowSizes = map (fromIntegral . length) rowLists
664 values = concat rowLists
665 qlGridModelLocalVolSurface :: (Day) -> ([Day]) -> ([Word]) -> ([Double]) -> (DayCounter) -> (FixedLocalVolSurfaceExtrapolation) -> (FixedLocalVolSurfaceExtrapolation) -> IO ((GridModelLocalVolSurface))
666 qlGridModelLocalVolSurface a1 a2 a3 a4 a5 a6 a7 =
667 withDay a1 $ \a1' ->
668 withDayArray a2 $ \(a2'1, a2'2) ->
669 withIntArray a3 $ \(a3'1, a3'2) ->
670 withDoubleArrayRaw a4 $ \a4' ->
671 withDayCounter a5 $ \a5' ->
672 let {a6' = (fromIntegral . fromEnum) a6} in
673 let {a7' = (fromIntegral . fromEnum) a7} in
674 preErrorCheck $ \a8' ->
675 qlGridModelLocalVolSurface'_ a1' a2'1 a2'2 a3'1 a3'2 a4' a5' a6' a7' a8' >>= \res ->
676 peekGridModelLocalVolSurface res >>= \res' ->
677 errorCheck a8'>>
678 return (res')
679
680
681
682 -- |View a grid local-vol surface through its secondary 'CalibratedModel' interface. This is a
683 -- safe C++ multiple-inheritance upcast, materialized as an independently owned shared pointer.
684 gridModelLocalVolSurfaceAsCalibratedModel :: (GridModelLocalVolSurface) -- ^surface
685 -> IO ((CalibratedModel))
686 gridModelLocalVolSurfaceAsCalibratedModel a1 =
687 withGridModelLocalVolSurface a1 $ \a1' ->
688 preErrorCheck $ \a2' ->
689 gridModelLocalVolSurfaceAsCalibratedModel'_ a1' a2' >>= \res ->
690 peekCalibratedModel res >>= \res' ->
691 errorCheck a2'>>
692 return (res')
693
694
695
696 -- |A Black implied-volatility surface computed from a Heston model. The integration argument is
697 -- the order of QuantLib's Gauss-Laguerre quadrature; the supplied complex-log formula controls
698 -- the characteristic-function representation.
699 hestonBlackVolSurface :: (GenHestonModel hm) -- ^model
700 -> (ComplexLogFormula) -- ^complexLogFormula
701 -> (Word) -- ^integrationOrder
702 -> IO ((BlackVolTermStructure))
703 hestonBlackVolSurface a1 a2 a3 =
704 withHestonModel a1 $ \a1' ->
705 let {a2' = (fromIntegral . fromEnum) a2} in
706 let {a3' = fromIntegral a3} in
707 preErrorCheck $ \a4' ->
708 hestonBlackVolSurface'_ a1' a2' a3' a4' >>= \res ->
709 peekBlackVolTermStructure res >>= \res' ->
710 errorCheck a4'>>
711 return (res')
712
713
714
715 -- |Interpolation choice for Andreasen-Huge local-volatility calibration.
716 andreasenHugeVolatilityInterpolation :: NonEmpty (VanillaOption, GenQuote q) -> GenQuote q
717 -> GenYieldTermStructure y1 -> GenYieldTermStructure y2
718 -> AndreasenHugeInterpolationType -> AndreasenHugeCalibrationType -> Word
719 -> Maybe Double -> Maybe Double -> OptimizationMethod -> EndCriteria
720 -> IO AndreasenHugeVolatilityInterpl
721 andreasenHugeVolatilityInterpolation xs spot r q = qlAndreasenHugeVolatilityInterpl os qs spot r q
722 where (os, qs) = unzip (toList xs)
723 qlAndreasenHugeVolatilityInterpl :: ([VanillaOption]) -> ([GenQuote q1]) -> (GenQuote q2) -> (GenYieldTermStructure y1) -> (GenYieldTermStructure y2) -> (AndreasenHugeInterpolationType) -> (AndreasenHugeCalibrationType) -> (Word) -> (Maybe Double) -> (Maybe Double) -> (OptimizationMethod) -> (EndCriteria) -> IO ((AndreasenHugeVolatilityInterpl))
724 qlAndreasenHugeVolatilityInterpl a1 a2 a3 a4 a5 a6 a7 a8 a9 a10 a11 a12 =
725 withVanillaOptionArray a1 $ \(a1'1, a1'2) ->
726 withQuoteArrayRaw a2 $ \a2' ->
727 withQuote a3 $ \a3' ->
728 withYieldTermStructure a4 $ \a4' ->
729 withYieldTermStructure a5 $ \a5' ->
730 let {a6' = (fromIntegral . fromEnum) a6} in
731 let {a7' = (fromIntegral . fromEnum) a7} in
732 let {a8' = fromIntegral a8} in
733 let {a9' = fromMaybeDouble a9} in
734 let {a10' = fromMaybeDouble a10} in
735 withOptimizationMethod a11 $ \a11' ->
736 withEndCriteria a12 $ \a12' ->
737 preErrorCheck $ \a13' ->
738 qlAndreasenHugeVolatilityInterpl'_ a1'1 a1'2 a2' a3' a4' a5' a6' a7' a8' a9' a10' a11' a12' a13' >>= \res ->
739 peekAndreasenHugeVolatilityInterpl res >>= \res' ->
740 errorCheck a13'>>
741 return (res')
742
743
744
745 -- |Minimum, maximum, and average calibration errors, expressed in volatility units.
746 andreasenHugeCalibrationError :: AndreasenHugeVolatilityInterpl -> IO (Double, Double, Double)
747 andreasenHugeCalibrationError x = do
748 [mn, mx, av] <- qlAndreasenHugeVolatilityInterplCalibrationError x
749 pure (mn, mx, av)
750 qlAndreasenHugeVolatilityInterplCalibrationError :: (AndreasenHugeVolatilityInterpl) -> IO (([Double]))
751 qlAndreasenHugeVolatilityInterplCalibrationError a1 =
752 withAndreasenHugeVolatilityInterpl a1 $ \a1' ->
753 preDoubleArray $ \(a2'1, a2'2) ->
754 preErrorCheck $ \a3' ->
755 qlAndreasenHugeVolatilityInterplCalibrationError'_ a1' a2'1 a2'2 a3' >>
756 peekDoubleArray a2'1 a2'2>>= \a2'' ->
757 errorCheck a3'>>
758 return (a2'')
759
760
761
762 -- |Forward level implied by an Andreasen-Huge calibration at time @t@.
763 andreasenHugeForward :: (AndreasenHugeVolatilityInterpl) -- ^interpolation
764 -> (Double) -- ^t
765 -> IO ((Double))
766 andreasenHugeForward a1 a2 =
767 withAndreasenHugeVolatilityInterpl a1 $ \a1' ->
768 let {a2' = realToFrac a2} in
769 preErrorCheck $ \a3' ->
770 andreasenHugeForward'_ a1' a2' a3' >>= \res ->
771 let {res' = realToFrac res} in
772 errorCheck a3'>>
773 return (res')
774
775
776
777 -- |Calibrated option price at time, strike, and put/call type.
778 andreasenHugeOptionPrice :: (AndreasenHugeVolatilityInterpl) -- ^interpolation
779 -> (Double) -- ^t
780 -> (Double) -- ^strike
781 -> (OptionType) -- ^optionType
782 -> IO ((Double))
783 andreasenHugeOptionPrice a1 a2 a3 a4 =
784 withAndreasenHugeVolatilityInterpl a1 $ \a1' ->
785 let {a2' = realToFrac a2} in
786 let {a3' = realToFrac a3} in
787 let {a4' = fromEnumC a4} in
788 preErrorCheck $ \a5' ->
789 andreasenHugeOptionPrice'_ a1' a2' a3' a4' a5' >>= \res ->
790 let {res' = realToFrac res} in
791 errorCheck a5'>>
792 return (res')
793
794
795
796 -- |Calibrated local volatility at time and strike.
797 andreasenHugeLocalVol :: (AndreasenHugeVolatilityInterpl) -- ^interpolation
798 -> (Double) -- ^t
799 -> (Double) -- ^strike
800 -> IO ((Double))
801 andreasenHugeLocalVol a1 a2 a3 =
802 withAndreasenHugeVolatilityInterpl a1 $ \a1' ->
803 let {a2' = realToFrac a2} in
804 let {a3' = realToFrac a3} in
805 preErrorCheck $ \a4' ->
806 andreasenHugeLocalVol'_ a1' a2' a3' a4' >>= \res ->
807 let {res' = realToFrac res} in
808 errorCheck a4'>>
809 return (res')
810
811
812
813 -- |Adapts an Andreasen-Huge interpolation to QuantLib's Black-volatility term-structure interface.
814 andreasenHugeVolatilityAdapter :: (AndreasenHugeVolatilityInterpl) -- ^interpolation
815 -> (Double) -- ^eps
816 -> IO ((BlackVolTermStructure))
817 andreasenHugeVolatilityAdapter a1 a2 =
818 withAndreasenHugeVolatilityInterpl a1 $ \a1' ->
819 let {a2' = realToFrac a2} in
820 preErrorCheck $ \a3' ->
821 andreasenHugeVolatilityAdapter'_ a1' a2' a3' >>= \res ->
822 peekBlackVolTermStructure res >>= \res' ->
823 errorCheck a3'>>
824 return (res')
825
826
827
828 -- |Adapts an Andreasen-Huge interpolation to QuantLib's local-volatility term-structure interface.
829 andreasenHugeLocalVolAdapter :: (AndreasenHugeVolatilityInterpl) -- ^interpolation
830 -> IO ((LocalVolTermStructure))
831 andreasenHugeLocalVolAdapter a1 =
832 withAndreasenHugeVolatilityInterpl a1 $ \a1' ->
833 preErrorCheck $ \a2' ->
834 andreasenHugeLocalVolAdapter'_ a1' a2' >>= \res ->
835 peekLocalVolTermStructure res >>= \res' ->
836 errorCheck a2'>>
837 return (res')
838
839
840
841 -- |the local vol at a given date and underlying level, for any 'LocalVolTermStructure' (however
842 -- it was constructed) -- the only way to observe what a local vol surface actually computes.
843 localVol :: (GenLocalVolTermStructure lv) -> (Day) -> (Double) -- ^underlyingLevel
844 -> (Bool) -- ^extrapolate
845 -> IO ((Double))
846 localVol a1 a2 a3 a4 =
847 withGenLocalVolTermStructure a1 $ \a1' ->
848 withDay a2 $ \a2' ->
849 let {a3' = realToFrac a3} in
850 let {a4' = C2HSImp.fromBool a4} in
851 preErrorCheck $ \a5' ->
852 localVol'_ a1' a2' a3' a4' a5' >>= \res ->
853 let {res' = realToFrac res} in
854 errorCheck a5'>>
855 return (res')
856
857
858
859 -- |Constant caplet volatility with either a fixed or evaluation-date-relative reference point.
860 constantOptionletVolatility :: CalendarReference -> Calendar -> BusinessDayConvention
861 -> GenQuote q -> DayCounter -> VolatilityType -> Double -> IO OptionletVolatilityStructure
862 constantOptionletVolatility reference cal = case reference of
863 CalendarReferenceDate d -> constantOptionletVolatilityFixed d cal
864 CalendarSettlementDays n -> constantOptionletVolatilityMovingRaw n cal
865
866 constantOptionletVolatilityMovingRaw :: (Word) -> (Calendar) -> (BusinessDayConvention) -> (GenQuote q) -> (DayCounter) -> (VolatilityType) -- ^type
867 -> (Double) -- ^displacement
868 -> IO ((OptionletVolatilityStructure))
869 constantOptionletVolatilityMovingRaw a1 a2 a3 a4 a5 a6 a7 =
870 let {a1' = fromIntegral a1} in
871 withCalendar a2 $ \a2' ->
872 let {a3' = fromEnumC a3} in
873 withQuote a4 $ \a4' ->
874 withDayCounter a5 $ \a5' ->
875 let {a6' = (fromIntegral . fromEnum) a6} in
876 let {a7' = realToFrac a7} in
877 preErrorCheck $ \a8' ->
878 constantOptionletVolatilityMovingRaw'_ a1' a2' a3' a4' a5' a6' a7' a8' >>= \res ->
879 peekOptionletVolatilityStructure res >>= \res' ->
880 errorCheck a8'>>
881 return (res')
882
883
884
885 constantOptionletVolatilityFixed :: (Day) -> (Calendar) -> (BusinessDayConvention) -> (GenQuote q) -> (DayCounter) -> (VolatilityType) -- ^type
886 -> (Double) -- ^displacement
887 -> IO ((OptionletVolatilityStructure))
888 constantOptionletVolatilityFixed a1 a2 a3 a4 a5 a6 a7 =
889 withDay a1 $ \a1' ->
890 withCalendar a2 $ \a2' ->
891 let {a3' = fromEnumC a3} in
892 withQuote a4 $ \a4' ->
893 withDayCounter a5 $ \a5' ->
894 let {a6' = (fromIntegral . fromEnum) a6} in
895 let {a7' = realToFrac a7} in
896 preErrorCheck $ \a8' ->
897 constantOptionletVolatilityFixed'_ a1' a2' a3' a4' a5' a6' a7' a8' >>= \res ->
898 peekOptionletVolatilityStructure res >>= \res' ->
899 errorCheck a8'>>
900 return (res')
901
902
903
904 -- |Optionlet volatility curve interpolating the supplied caplet-volatility nodes by variance.
905 -- Each node pairs an option date with its volatility, so mismatched date/value inputs are
906 -- unrepresentable.
907 capletVarianceCurve :: Day -> NonEmpty (Day, Double) -> DayCounter -> VolatilityType -> Double
908 -> IO OptionletVolatilityStructure
909 capletVarianceCurve referenceDate nodes = qlCapletVarianceCurve referenceDate dates vols
910 where (dates, vols) = unzip (toList nodes)
911 qlCapletVarianceCurve :: (Day) -- ^referenceDate
912 -> ([Day]) -- ^dates
913 -> ([Double]) -- ^capletVolCurve
914 -> (DayCounter) -- ^dayCounter
915 -> (VolatilityType) -- ^type
916 -> (Double) -- ^displacement
917 -> IO ((OptionletVolatilityStructure))
918 qlCapletVarianceCurve a1 a2 a3 a4 a5 a6 =
919 withDay a1 $ \a1' ->
920 withDayArray a2 $ \(a2'1, a2'2) ->
921 withDoubleArray a3 $ \(a3'1, a3'2) ->
922 withDayCounter a4 $ \a4' ->
923 let {a5' = (fromIntegral . fromEnum) a5} in
924 let {a6' = realToFrac a6} in
925 preErrorCheck $ \a7' ->
926 qlCapletVarianceCurve'_ a1' a2'1 a2'2 a3'1 a3'2 a4' a5' a6' a7' >>= \res ->
927 peekOptionletVolatilityStructure res >>= \res' ->
928 errorCheck a7'>>
929 return (res')
930
931
932
933 -- |Strips a 'CapFloorTermVolSurface' (quoted cap\/floor term vols) into caplet\/floorlet vols via
934 -- 'OptionletStripper1', immediately wrapping the result behind 'StrippedOptionletAdapter' in one
935 -- step -- 'OptionletStripper1' itself is never exposed as a Haskell type, since none of its own
936 -- getters (capFloorPrices\/capletVols\/etc.) are needed beyond feeding the adapter, per the "bind
937 -- few inspectors" rule.
938 optionletStripper :: (CapFloorTermVolSurface) -> (GenIborIndex ibor) -> (Maybe Double) -- ^switchStrikes
939 -> (Double) -- ^accuracy
940 -> (Word) -- ^maxIter
941 -> (Maybe (GenYieldTermStructure y)) -- ^discount
942 -> (VolatilityType) -- ^type
943 -> (Double) -- ^displacement
944 -> (Bool) -- ^dontThrow
945 -> (Maybe (Word, TimeUnit)) -- ^optionletFrequency
946 -> (Word) -- ^paymentLag (1.44; QuantLib 1.43 requires 0)
947 -> IO ((OptionletVolatilityStructure))
948 optionletStripper a1 a2 a3 a4 a5 a6 a7 a8 a9 a10 a11 =
949 withCapFloorTermVolSurface a1 $ \a1' ->
950 withIborIndex a2 $ \a2' ->
951 let {a3' = fromMaybeDouble a3} in
952 let {a4' = realToFrac a4} in
953 let {a5' = fromIntegral a5} in
954 withMaybeYieldTermStructure a6 $ \a6' ->
955 let {a7' = (fromIntegral . fromEnum) a7} in
956 let {a8' = realToFrac a8} in
957 let {a9' = C2HSImp.fromBool a9} in
958 let {(a10'1, a10'2) = fromMaybeEnumQuantity a10} in
959 let {a11' = fromIntegral a11} in
960 preErrorCheck $ \a12' ->
961 optionletStripper'_ a1' a2' a3' a4' a5' a6' a7' a8' a9' a10'1 a10'2 a11' a12' >>= \res ->
962 peekOptionletVolatilityStructure res >>= \res' ->
963 errorCheck a12'>>
964 return (res')
965
966
967
968 -- |Extends an 'OptionletStripper1' (built internally, never exposed as its own Haskell type --
969 -- same fusion as 'optionletStripper') by reconciling it against an ATM 'CapFloorTermVolCurve',
970 -- producing forward-forward optionlet vols. Unlike 'optionletStripper', this keeps its own
971 -- concrete 'OptionletStripper2' object around, since it has real diagnostic getters
972 -- ('atmCapFloorStrikes'\/'atmCapFloorPrices'\/'spreadsVol') not reachable through the generic
973 -- 'OptionletVolatilityStructure' interface. Use 'asOptionletVolatilityStructure'
974 -- to pass one into anything expecting the generic interface.
975 optionletStripperWithAtm :: (CapFloorTermVolSurface) -> (GenIborIndex ibor) -> (Maybe Double) -- ^switchStrikes
976 -> (Double) -- ^accuracy
977 -> (Word) -- ^maxIter
978 -> (Maybe (GenYieldTermStructure y)) -- ^discount
979 -> (VolatilityType) -- ^type
980 -> (Double) -- ^displacement
981 -> (Bool) -- ^dontThrow
982 -> (Maybe (Word, TimeUnit)) -- ^optionletFrequency
983 -> (CapFloorTermVolCurve) -- ^atmCapFloorTermVolCurve
984 -> (Word) -- ^paymentLag (1.44; QuantLib 1.43 requires 0)
985 -> IO ((OptionletStripper2))
986 optionletStripperWithAtm a1 a2 a3 a4 a5 a6 a7 a8 a9 a10 a11 a12 =
987 withCapFloorTermVolSurface a1 $ \a1' ->
988 withIborIndex a2 $ \a2' ->
989 let {a3' = fromMaybeDouble a3} in
990 let {a4' = realToFrac a4} in
991 let {a5' = fromIntegral a5} in
992 withMaybeYieldTermStructure a6 $ \a6' ->
993 let {a7' = (fromIntegral . fromEnum) a7} in
994 let {a8' = realToFrac a8} in
995 let {a9' = C2HSImp.fromBool a9} in
996 let {(a10'1, a10'2) = fromMaybeEnumQuantity a10} in
997 withCapFloorTermVolCurve a11 $ \a11' ->
998 let {a12' = fromIntegral a12} in
999 preErrorCheck $ \a13' ->
1000 optionletStripperWithAtm'_ a1' a2' a3' a4' a5' a6' a7' a8' a9' a10'1 a10'2 a11' a12' a13' >>= \res ->
1001 peekOptionletStripper2 res >>= \res' ->
1002 errorCheck a13'>>
1003 return (res')
1004
1005
1006
1007 -- |Fresh construction (a 'StrippedOptionletAdapter' wrapping the 'OptionletStripper2' itself),
1008 -- never a cast -- same idiom as 'sabrAsSmileSection'.
1009 asOptionletVolatilityStructure :: (OptionletStripper2) -> IO ((OptionletVolatilityStructure))
1010 asOptionletVolatilityStructure a1 =
1011 withOptionletStripper2 a1 $ \a1' ->
1012 preErrorCheck $ \a2' ->
1013 asOptionletVolatilityStructure'_ a1' a2' >>= \res ->
1014 peekOptionletVolatilityStructure res >>= \res' ->
1015 errorCheck a2'>>
1016 return (res')
1017
1018
1019
1020 atmCapFloorStrikes :: (OptionletStripper2) -> IO (([Double]))
1021 atmCapFloorStrikes a1 =
1022 withOptionletStripper2 a1 $ \a1' ->
1023 preDoubleArray $ \(a2'1, a2'2) ->
1024 preErrorCheck $ \a3' ->
1025 atmCapFloorStrikes'_ a1' a2'1 a2'2 a3' >>
1026 peekDoubleArray a2'1 a2'2>>= \a2'' ->
1027 errorCheck a3'>>
1028 return (a2'')
1029
1030
1031
1032 atmCapFloorPrices :: (OptionletStripper2) -> IO (([Double]))
1033 atmCapFloorPrices a1 =
1034 withOptionletStripper2 a1 $ \a1' ->
1035 preDoubleArray $ \(a2'1, a2'2) ->
1036 preErrorCheck $ \a3' ->
1037 atmCapFloorPrices'_ a1' a2'1 a2'2 a3' >>
1038 peekDoubleArray a2'1 a2'2>>= \a2'' ->
1039 errorCheck a3'>>
1040 return (a2'')
1041
1042
1043
1044 spreadsVol :: (OptionletStripper2) -> IO (([Double]))
1045 spreadsVol a1 =
1046 withOptionletStripper2 a1 $ \a1' ->
1047 preDoubleArray $ \(a2'1, a2'2) ->
1048 preErrorCheck $ \a3' ->
1049 spreadsVol'_ a1' a2'1 a2'2 a3' >>
1050 peekDoubleArray a2'1 a2'2>>= \a2'' ->
1051 errorCheck a3'>>
1052 return (a2'')
1053
1054
1055
1056 -- |An optionlet vol surface behind a relinkable handle. The result /is/ an
1057 -- 'OptionletVolatilityStructure': pass it anywhere one is expected and everything built on it
1058 -- keeps tracking whatever the handle currently points at, so a later 'linkOptionletVolTo'
1059 -- reprices already-constructed instruments without rebuilding them. Mirrors
1060 -- 'relinkableSwaptionVolatilityStructure'.
1061 relinkableOptionletVolatilityStructure :: (Maybe (GenOptionletVolatilityStructure ov)) -> IO ((RelinkableOptionletVolatilityStructure))
1062 relinkableOptionletVolatilityStructure a1 =
1063 withMaybeOptionletVolatilityStructure a1 $ \a1' ->
1064 preErrorCheck $ \a2' ->
1065 relinkableOptionletVolatilityStructure'_ a1' a2' >>= \res ->
1066 peekRelinkableOptionletVolatilityStructure res >>= \res' ->
1067 errorCheck a2'>>
1068 return (res')
1069
1070
1071
1072 -- |Point a relinkable optionlet vol handle at a different surface. Everything already built on
1073 -- the handle reprices against the new surface, with no engine rebuilt. Named distinctly from
1074 -- 'QuantLib.TermStructure.Yield.linkTo'\/'linkBlackVolTo'\/'linkSwaptionVolTo' for the same
1075 -- reason as those: all four relinkable vol types live in this one module.
1076 linkOptionletVolTo :: (RelinkableOptionletVolatilityStructure) -> (GenOptionletVolatilityStructure ov) -> IO ()
1077 linkOptionletVolTo a1 a2 =
1078 withRelinkableOptionletVolatilityStructure a1 $ \a1' ->
1079 withOptionletVolatilityStructure a2 $ \a2' ->
1080 preErrorCheck $ \a3' ->
1081 linkOptionletVolTo'_ a1' a2' a3' >>
1082 errorCheck a3'>>
1083 return ()
1084
1085
1086
1087 -- |A constant Black volatility with either a fixed or evaluation-date-relative reference point.
1088 blackConstantVol :: CalendarReference -> Calendar -> GenQuote q -> DayCounter -> IO BlackVolTermStructure
1089 blackConstantVol reference cal = case reference of
1090 CalendarReferenceDate d -> blackConstantVolFixed d cal
1091 CalendarSettlementDays n -> blackConstantVolMovingRaw n cal
1092 blackConstantVolMovingRaw :: (Word) -> (Calendar) -> (GenQuote q) -> (DayCounter) -> IO ((BlackVolTermStructure))
1093 blackConstantVolMovingRaw a1 a2 a3 a4 =
1094 let {a1' = fromIntegral a1} in
1095 withCalendar a2 $ \a2' ->
1096 withQuote a3 $ \a3' ->
1097 withDayCounter a4 $ \a4' ->
1098 preErrorCheck $ \a5' ->
1099 blackConstantVolMovingRaw'_ a1' a2' a3' a4' a5' >>= \res ->
1100 peekBlackVolTermStructure res >>= \res' ->
1101 errorCheck a5'>>
1102 return (res')
1103
1104
1105 blackConstantVolFixed :: (Day) -> (Calendar) -> (GenQuote q) -> (DayCounter) -> IO ((BlackVolTermStructure))
1106 blackConstantVolFixed a1 a2 a3 a4 =
1107 withDay a1 $ \a1' ->
1108 withCalendar a2 $ \a2' ->
1109 withQuote a3 $ \a3' ->
1110 withDayCounter a4 $ \a4' ->
1111 preErrorCheck $ \a5' ->
1112 blackConstantVolFixed'_ a1' a2' a3' a4' a5' >>= \res ->
1113 peekBlackVolTermStructure res >>= \res' ->
1114 errorCheck a5'>>
1115 return (res')
1116
1117
1118
1119 -- |SABR-parameterized Black volatility term structure. @gamma@ is upstream's vol-of-vol
1120 -- (@nu@ in the usual SABR notation); @s0@\/@r@ are the initial forward and the
1121 -- continuously-compounded rate used to roll it forward -- see
1122 -- 'ql/experimental/volatility/sabrvoltermstructure.hpp'.
1123 sabrVolTermStructure :: (Double) -> (Double) -> (Double) -> (Double) -> (Double) -> (Double) -> (Day) -> (DayCounter) -> IO ((BlackVolTermStructure))
1124 sabrVolTermStructure a1 a2 a3 a4 a5 a6 a7 a8 =
1125 let {a1' = realToFrac a1} in
1126 let {a2' = realToFrac a2} in
1127 let {a3' = realToFrac a3} in
1128 let {a4' = realToFrac a4} in
1129 let {a5' = realToFrac a5} in
1130 let {a6' = realToFrac a6} in
1131 withDay a7 $ \a7' ->
1132 withDayCounter a8 $ \a8' ->
1133 preErrorCheck $ \a9' ->
1134 sabrVolTermStructure'_ a1' a2' a3' a4' a5' a6' a7' a8' a9' >>= \res ->
1135 peekBlackVolTermStructure res >>= \res' ->
1136 errorCheck a9'>>
1137 return (res')
1138
1139
1140
1141 -- |A Black vol surface behind a relinkable handle. The result /is/ a 'BlackVolTermStructure':
1142 -- pass it anywhere one is expected and everything built on it keeps tracking whatever the
1143 -- handle currently points at, so a later 'linkBlackVolTo' reprices already-constructed
1144 -- instruments without rebuilding them. Mirrors
1145 -- 'QuantLib.TermStructure.Yield.relinkableYieldTermStructure'.
1146 relinkableBlackVolTermStructure :: (Maybe (GenBlackVolTermStructure bv)) -> IO ((RelinkableBlackVolTermStructure))
1147 relinkableBlackVolTermStructure a1 =
1148 withMaybeBlackVolTermStructure a1 $ \a1' ->
1149 preErrorCheck $ \a2' ->
1150 relinkableBlackVolTermStructure'_ a1' a2' >>= \res ->
1151 peekRelinkableBlackVolTermStructure res >>= \res' ->
1152 errorCheck a2'>>
1153 return (res')
1154
1155
1156
1157 -- |Point a relinkable Black vol handle at a different surface. Everything already built on the
1158 -- handle reprices against the new surface, with no engine rebuilt. Mirrors
1159 -- 'QuantLib.TermStructure.Yield.linkTo' -- see its haddock for why this mutator is justified.
1160 linkBlackVolTo :: (RelinkableBlackVolTermStructure) -> (GenBlackVolTermStructure bv) -> IO ()
1161 linkBlackVolTo a1 a2 =
1162 withRelinkableBlackVolTermStructure a1 $ \a1' ->
1163 withBlackVolTermStructure a2 $ \a2' ->
1164 preErrorCheck $ \a3' ->
1165 linkBlackVolTo'_ a1' a2' a3' >>
1166 errorCheck a3'>>
1167 return ()
1168
1169
1170
1171 blackVolAtDateRaw :: (GenBlackVolTermStructure bv) -> (Day) -> (Double) -- ^strike
1172 -> (Bool) -- ^extrapolate
1173 -> IO ((Double))
1174 blackVolAtDateRaw a1 a2 a3 a4 =
1175 withBlackVolTermStructure a1 $ \a1' ->
1176 withDay a2 $ \a2' ->
1177 let {a3' = realToFrac a3} in
1178 let {a4' = C2HSImp.fromBool a4} in
1179 preErrorCheck $ \a5' ->
1180 blackVolAtDateRaw'_ a1' a2' a3' a4' a5' >>= \res ->
1181 let {res' = realToFrac res} in
1182 errorCheck a5'>>
1183 return (res')
1184
1185
1186 blackVolAtTimeRaw :: (GenBlackVolTermStructure bv) -> (Double) -> (Double) -- ^strike
1187 -> (Bool) -- ^extrapolate
1188 -> IO ((Double))
1189 blackVolAtTimeRaw a1 a2 a3 a4 =
1190 withBlackVolTermStructure a1 $ \a1' ->
1191 let {a2' = realToFrac a2} in
1192 let {a3' = realToFrac a3} in
1193 let {a4' = C2HSImp.fromBool a4} in
1194 preErrorCheck $ \a5' ->
1195 blackVolAtTimeRaw'_ a1' a2' a3' a4' a5' >>= \res ->
1196 let {res' = realToFrac res} in
1197 errorCheck a5'>>
1198 return (res')
1199
1200
1201
1202 -- |Black volatility for the given maturity and strike.
1203 blackVol :: GenBlackVolTermStructure bv -> TermPoint -> Double -> Bool -> IO Double
1204 blackVol surface point strike = case point of
1205 DatePoint d -> blackVolAtDateRaw surface d strike
1206 TimePoint t -> blackVolAtTimeRaw surface t strike
1207
1208 blackVarianceAtDateRaw :: (GenBlackVolTermStructure bv) -> (Day) -> (Double) -- ^strike
1209 -> (Bool) -- ^extrapolate
1210 -> IO ((Double))
1211 blackVarianceAtDateRaw a1 a2 a3 a4 =
1212 withBlackVolTermStructure a1 $ \a1' ->
1213 withDay a2 $ \a2' ->
1214 let {a3' = realToFrac a3} in
1215 let {a4' = C2HSImp.fromBool a4} in
1216 preErrorCheck $ \a5' ->
1217 blackVarianceAtDateRaw'_ a1' a2' a3' a4' a5' >>= \res ->
1218 let {res' = realToFrac res} in
1219 errorCheck a5'>>
1220 return (res')
1221
1222
1223 blackVarianceAtTimeRaw :: (GenBlackVolTermStructure bv) -> (Double) -> (Double) -- ^strike
1224 -> (Bool) -- ^extrapolate
1225 -> IO ((Double))
1226 blackVarianceAtTimeRaw a1 a2 a3 a4 =
1227 withBlackVolTermStructure a1 $ \a1' ->
1228 let {a2' = realToFrac a2} in
1229 let {a3' = realToFrac a3} in
1230 let {a4' = C2HSImp.fromBool a4} in
1231 preErrorCheck $ \a5' ->
1232 blackVarianceAtTimeRaw'_ a1' a2' a3' a4' a5' >>= \res ->
1233 let {res' = realToFrac res} in
1234 errorCheck a5'>>
1235 return (res')
1236
1237
1238
1239 -- |Black variance for the given maturity and strike. Named 'blackVolVariance' to distinguish it
1240 -- from the two-maturity swaption and callable-bond queries.
1241 blackVolVariance :: GenBlackVolTermStructure bv -> TermPoint -> Double -> Bool -> IO Double
1242 blackVolVariance surface point strike = case point of
1243 DatePoint d -> blackVarianceAtDateRaw surface d strike
1244 TimePoint t -> blackVarianceAtTimeRaw surface t strike
1245
1246 blackForwardVolBetweenDatesRaw :: (GenBlackVolTermStructure bv) -> (Day) -> (Day) -> (Double) -- ^strike
1247 -> (Bool) -- ^extrapolate
1248 -> IO ((Double))
1249 blackForwardVolBetweenDatesRaw a1 a2 a3 a4 a5 =
1250 withBlackVolTermStructure a1 $ \a1' ->
1251 withDay a2 $ \a2' ->
1252 withDay a3 $ \a3' ->
1253 let {a4' = realToFrac a4} in
1254 let {a5' = C2HSImp.fromBool a5} in
1255 preErrorCheck $ \a6' ->
1256 blackForwardVolBetweenDatesRaw'_ a1' a2' a3' a4' a5' a6' >>= \res ->
1257 let {res' = realToFrac res} in
1258 errorCheck a6'>>
1259 return (res')
1260
1261
1262 blackForwardVolBetweenTimesRaw :: (GenBlackVolTermStructure bv) -> (Double) -> (Double) -> (Double) -- ^strike
1263 -> (Bool) -- ^extrapolate
1264 -> IO ((Double))
1265 blackForwardVolBetweenTimesRaw a1 a2 a3 a4 a5 =
1266 withBlackVolTermStructure a1 $ \a1' ->
1267 let {a2' = realToFrac a2} in
1268 let {a3' = realToFrac a3} in
1269 let {a4' = realToFrac a4} in
1270 let {a5' = C2HSImp.fromBool a5} in
1271 preErrorCheck $ \a6' ->
1272 blackForwardVolBetweenTimesRaw'_ a1' a2' a3' a4' a5' a6' >>= \res ->
1273 let {res' = realToFrac res} in
1274 errorCheck a6'>>
1275 return (res')
1276
1277
1278
1279 -- |Forward (at-the-money) Black volatility between two dates or year fractions, for the given
1280 -- strike.
1281 blackForwardVol :: GenBlackVolTermStructure bv -> TermInterval -> Double -> Bool -> IO Double
1282 blackForwardVol surface interval strike = case interval of
1283 DateInterval d1 d2 -> blackForwardVolBetweenDatesRaw surface d1 d2 strike
1284 TimeInterval t1 t2 -> blackForwardVolBetweenTimesRaw surface t1 t2 strike
1285
1286 blackForwardVarianceBetweenDatesRaw :: (GenBlackVolTermStructure bv) -> (Day) -> (Day) -> (Double) -- ^strike
1287 -> (Bool) -- ^extrapolate
1288 -> IO ((Double))
1289 blackForwardVarianceBetweenDatesRaw a1 a2 a3 a4 a5 =
1290 withBlackVolTermStructure a1 $ \a1' ->
1291 withDay a2 $ \a2' ->
1292 withDay a3 $ \a3' ->
1293 let {a4' = realToFrac a4} in
1294 let {a5' = C2HSImp.fromBool a5} in
1295 preErrorCheck $ \a6' ->
1296 blackForwardVarianceBetweenDatesRaw'_ a1' a2' a3' a4' a5' a6' >>= \res ->
1297 let {res' = realToFrac res} in
1298 errorCheck a6'>>
1299 return (res')
1300
1301
1302 blackForwardVarianceBetweenTimesRaw :: (GenBlackVolTermStructure bv) -> (Double) -> (Double) -> (Double) -- ^strike
1303 -> (Bool) -- ^extrapolate
1304 -> IO ((Double))
1305 blackForwardVarianceBetweenTimesRaw a1 a2 a3 a4 a5 =
1306 withBlackVolTermStructure a1 $ \a1' ->
1307 let {a2' = realToFrac a2} in
1308 let {a3' = realToFrac a3} in
1309 let {a4' = realToFrac a4} in
1310 let {a5' = C2HSImp.fromBool a5} in
1311 preErrorCheck $ \a6' ->
1312 blackForwardVarianceBetweenTimesRaw'_ a1' a2' a3' a4' a5' a6' >>= \res ->
1313 let {res' = realToFrac res} in
1314 errorCheck a6'>>
1315 return (res')
1316
1317
1318
1319 -- |Forward (at-the-money) Black variance between two dates or year fractions, for the given
1320 -- strike.
1321 blackForwardVariance :: GenBlackVolTermStructure bv -> TermInterval -> Double -> Bool -> IO Double
1322 blackForwardVariance surface interval strike = case interval of
1323 DateInterval d1 d2 -> blackForwardVarianceBetweenDatesRaw surface d1 d2 strike
1324 TimeInterval t1 t2 -> blackForwardVarianceBetweenTimesRaw surface t1 t2 strike
1325
1326 -- |Constant swaption volatility with either a fixed or evaluation-date-relative reference point.
1327 constantSwaptionVolatility :: CalendarReference -> Calendar -> BusinessDayConvention
1328 -> GenQuote q -> DayCounter -> VolatilityType -> Double -> IO SwaptionVolatilityStructure
1329 constantSwaptionVolatility reference cal = case reference of
1330 CalendarReferenceDate d -> constantSwaptionVolatilityFixed d cal
1331 CalendarSettlementDays n -> constantSwaptionVolatilityMovingRaw n cal
1332 constantSwaptionVolatilityFixed :: (Day) -> (Calendar) -> (BusinessDayConvention) -> (GenQuote q) -> (DayCounter) -> (VolatilityType) -- ^type
1333 -> (Double) -- ^shift
1334 -> IO ((SwaptionVolatilityStructure))
1335 constantSwaptionVolatilityFixed a1 a2 a3 a4 a5 a6 a7 =
1336 withDay a1 $ \a1' ->
1337 withCalendar a2 $ \a2' ->
1338 let {a3' = fromEnumC a3} in
1339 withQuote a4 $ \a4' ->
1340 withDayCounter a5 $ \a5' ->
1341 let {a6' = (fromIntegral . fromEnum) a6} in
1342 let {a7' = realToFrac a7} in
1343 preErrorCheck $ \a8' ->
1344 constantSwaptionVolatilityFixed'_ a1' a2' a3' a4' a5' a6' a7' a8' >>= \res ->
1345 peekSwaptionVolatilityStructure res >>= \res' ->
1346 errorCheck a8'>>
1347 return (res')
1348
1349
1350
1351 constantSwaptionVolatilityMovingRaw :: (Word) -> (Calendar) -> (BusinessDayConvention) -> (GenQuote q) -> (DayCounter) -> (VolatilityType) -- ^type
1352 -> (Double) -- ^shift
1353 -> IO ((SwaptionVolatilityStructure))
1354 constantSwaptionVolatilityMovingRaw a1 a2 a3 a4 a5 a6 a7 =
1355 let {a1' = fromIntegral a1} in
1356 withCalendar a2 $ \a2' ->
1357 let {a3' = fromEnumC a3} in
1358 withQuote a4 $ \a4' ->
1359 withDayCounter a5 $ \a5' ->
1360 let {a6' = (fromIntegral . fromEnum) a6} in
1361 let {a7' = realToFrac a7} in
1362 preErrorCheck $ \a8' ->
1363 constantSwaptionVolatilityMovingRaw'_ a1' a2' a3' a4' a5' a6' a7' a8' >>= \res ->
1364 peekSwaptionVolatilityStructure res >>= \res' ->
1365 errorCheck a8'>>
1366 return (res')
1367
1368
1369
1370 -- |returns the Black variance for a given option date and swap tenor
1371 blackVarianceDateTenor :: (GenSwaptionVolatilityStructure sv) -> (Day) -- ^optionDate
1372 -> ((Word,TimeUnit)) -- ^swapTenor
1373 -> (Double) -- ^strike
1374 -> (Bool) -- ^extrapolate
1375 -> IO ((Double))
1376 blackVarianceDateTenor a1 a2 a3 a4 a5 =
1377 withSwaptionVolatilityStructure a1 $ \a1' ->
1378 withDay a2 $ \a2' ->
1379 let {(a3'1, a3'2) = fromEnumQuantity a3} in
1380 let {a4' = realToFrac a4} in
1381 let {a5' = C2HSImp.fromBool a5} in
1382 preErrorCheck $ \a6' ->
1383 blackVarianceDateTenor'_ a1' a2' a3'1 a3'2 a4' a5' a6' >>= \res ->
1384 let {res' = realToFrac res} in
1385 errorCheck a6'>>
1386 return (res')
1387
1388
1389
1390 -- |returns the Black variance for a given option time and swap tenor
1391 blackVarianceTimeTenor :: (GenSwaptionVolatilityStructure sv) -> (Double) -- optionTime
1392 -> ((Word,TimeUnit)) -- swapTenor
1393 -> (Double) -- ^strike
1394 -> (Bool) -- ^extrapolate
1395 -> IO ((Double))
1396 blackVarianceTimeTenor a1 a2 a3 a4 a5 =
1397 withSwaptionVolatilityStructure a1 $ \a1' ->
1398 let {a2' = realToFrac a2} in
1399 let {(a3'1, a3'2) = fromEnumQuantity a3} in
1400 let {a4' = realToFrac a4} in
1401 let {a5' = C2HSImp.fromBool a5} in
1402 preErrorCheck $ \a6' ->
1403 blackVarianceTimeTenor'_ a1' a2' a3'1 a3'2 a4' a5' a6' >>= \res ->
1404 let {res' = realToFrac res} in
1405 errorCheck a6'>>
1406 return (res')
1407
1408
1409
1410 -- |returns the Black variance for a given option tenor and swap length
1411 blackVarianceTenorLength :: (GenSwaptionVolatilityStructure sv) -> ((Word,TimeUnit)) -- ^optionTenor
1412 -> (Double) -- ^swapLength
1413 -> (Double) -- ^strike
1414 -> (Bool) -- ^extrapolate
1415 -> IO ((Double))
1416 blackVarianceTenorLength a1 a2 a3 a4 a5 =
1417 withSwaptionVolatilityStructure a1 $ \a1' ->
1418 let {(a2'1, a2'2) = fromEnumQuantity a2} in
1419 let {a3' = realToFrac a3} in
1420 let {a4' = realToFrac a4} in
1421 let {a5' = C2HSImp.fromBool a5} in
1422 preErrorCheck $ \a6' ->
1423 blackVarianceTenorLength'_ a1' a2'1 a2'2 a3' a4' a5' a6' >>= \res ->
1424 let {res' = realToFrac res} in
1425 errorCheck a6'>>
1426 return (res')
1427
1428
1429
1430 -- |returns the Black variance for a given option date and swap length
1431 blackVarianceDateLength :: (GenSwaptionVolatilityStructure sv) -> (Day) -- ^optionDate
1432 -> (Double) -- ^swapLength
1433 -> (Double) -- ^strike
1434 -> (Bool) -- ^extrapolate
1435 -> IO ((Double))
1436 blackVarianceDateLength a1 a2 a3 a4 a5 =
1437 withSwaptionVolatilityStructure a1 $ \a1' ->
1438 withDay a2 $ \a2' ->
1439 let {a3' = realToFrac a3} in
1440 let {a4' = realToFrac a4} in
1441 let {a5' = C2HSImp.fromBool a5} in
1442 preErrorCheck $ \a6' ->
1443 blackVarianceDateLength'_ a1' a2' a3' a4' a5' a6' >>= \res ->
1444 let {res' = realToFrac res} in
1445 errorCheck a6'>>
1446 return (res')
1447
1448
1449
1450 -- |returns the Black variance for a given option time and swap length
1451 blackVarianceTimeLength :: (GenSwaptionVolatilityStructure sv) -> (Double) -- ^optionTime
1452 -> (Double) -- ^swapLength
1453 -> (Double) -- ^strike
1454 -> (Bool) -- ^extrapolate
1455 -> IO ((Double))
1456 blackVarianceTimeLength a1 a2 a3 a4 a5 =
1457 withSwaptionVolatilityStructure a1 $ \a1' ->
1458 let {a2' = realToFrac a2} in
1459 let {a3' = realToFrac a3} in
1460 let {a4' = realToFrac a4} in
1461 let {a5' = C2HSImp.fromBool a5} in
1462 preErrorCheck $ \a6' ->
1463 blackVarianceTimeLength'_ a1' a2' a3' a4' a5' a6' >>= \res ->
1464 let {res' = realToFrac res} in
1465 errorCheck a6'>>
1466 return (res')
1467
1468
1469
1470 -- |returns the Black variance for a given option tenor and swap tenor
1471 blackVarianceTenorTenor :: (GenSwaptionVolatilityStructure sv) -> ((Word,TimeUnit)) -- ^optionTenor
1472 -> ((Word,TimeUnit)) -- ^swapTenor
1473 -> (Double) -- ^strike
1474 -> (Bool) -- ^extrapolate
1475 -> IO ((Double))
1476 blackVarianceTenorTenor a1 a2 a3 a4 a5 =
1477 withSwaptionVolatilityStructure a1 $ \a1' ->
1478 let {(a2'1, a2'2) = fromEnumQuantity a2} in
1479 let {(a3'1, a3'2) = fromEnumQuantity a3} in
1480 let {a4' = realToFrac a4} in
1481 let {a5' = C2HSImp.fromBool a5} in
1482 preErrorCheck $ \a6' ->
1483 blackVarianceTenorTenor'_ a1' a2'1 a2'2 a3'1 a3'2 a4' a5' a6' >>= \res ->
1484 let {res' = realToFrac res} in
1485 errorCheck a6'>>
1486 return (res')
1487
1488
1489
1490 -- |Returns the Black variance for any option-maturity and swap-maturity representation.
1491 swaptionBlackVariance :: GenSwaptionVolatilityStructure sv -> OptionMaturity -> SwapMaturity -> Double -> Bool -> IO Double
1492 swaptionBlackVariance sv optionMaturity swapMaturity =
1493 case (optionMaturity, swapMaturity) of
1494 (OptionDate d, SwapTenor t) -> blackVarianceDateTenor sv d t
1495 (OptionTime t, SwapTenor p) -> blackVarianceTimeTenor sv t p
1496 (OptionTenor p, SwapLength l) -> blackVarianceTenorLength sv p l
1497 (OptionDate d, SwapLength l) -> blackVarianceDateLength sv d l
1498 (OptionTime t, SwapLength l) -> blackVarianceTimeLength sv t l
1499 (OptionTenor o, SwapTenor s) -> blackVarianceTenorTenor sv o s
1500
1501 -- |the largest swapLength for which the term structure can return vols
1502 maxSwapLength :: (GenSwaptionVolatilityStructure sv) -> IO ((Double))
1503 maxSwapLength a1 =
1504 withSwaptionVolatilityStructure a1 $ \a1' ->
1505 preErrorCheck $ \a2' ->
1506 maxSwapLength'_ a1' a2' >>= \res ->
1507 let {res' = realToFrac res} in
1508 errorCheck a2'>>
1509 return (res')
1510
1511
1512
1513 -- |the largest length for which the term structure can return vols
1514 maxSwapTenor :: (GenSwaptionVolatilityStructure sv) -> IO ((Int), (TimeUnit))
1515 maxSwapTenor a1 =
1516 withSwaptionVolatilityStructure a1 $ \a1' ->
1517 preEnum $ \a2' ->
1518 preErrorCheck $ \a3' ->
1519 maxSwapTenor'_ a1' a2' a3' >>= \res ->
1520 let {res' = fromIntegral res} in
1521 peekEnum a2'>>= \a2'' ->
1522 errorCheck a3'>>
1523 return (res', a2'')
1524
1525
1526
1527 -- |returns the smile for a given option date and swap tenor
1528 smileSectionDateTenor :: (GenSwaptionVolatilityStructure sv) -> (Day) -- ^optionDate
1529 -> ((Word,TimeUnit)) -- ^swapTenor
1530 -> (Bool) -- ^extrapolate
1531 -> IO ((SmileSection))
1532 smileSectionDateTenor a1 a2 a3 a4 =
1533 withSwaptionVolatilityStructure a1 $ \a1' ->
1534 withDay a2 $ \a2' ->
1535 let {(a3'1, a3'2) = fromEnumQuantity a3} in
1536 let {a4' = C2HSImp.fromBool a4} in
1537 preErrorCheck $ \a5' ->
1538 smileSectionDateTenor'_ a1' a2' a3'1 a3'2 a4' a5' >>= \res ->
1539 peekSmileSection res >>= \res' ->
1540 errorCheck a5'>>
1541 return (res')
1542
1543
1544
1545 -- |returns the smile for a given option time and swap tenor
1546 smileSectionTimeTenor :: (GenSwaptionVolatilityStructure sv) -> (Double) -- ^optionTime
1547 -> ((Word,TimeUnit)) -- ^swapTenor
1548 -> (Bool) -- ^extrapolate
1549 -> IO ((SmileSection))
1550 smileSectionTimeTenor a1 a2 a3 a4 =
1551 withSwaptionVolatilityStructure a1 $ \a1' ->
1552 let {a2' = realToFrac a2} in
1553 let {(a3'1, a3'2) = fromEnumQuantity a3} in
1554 let {a4' = C2HSImp.fromBool a4} in
1555 preErrorCheck $ \a5' ->
1556 smileSectionTimeTenor'_ a1' a2' a3'1 a3'2 a4' a5' >>= \res ->
1557 peekSmileSection res >>= \res' ->
1558 errorCheck a5'>>
1559 return (res')
1560
1561
1562
1563 -- |returns the smile for a given option tenor and swap length
1564 smileSectionTenorLength :: (GenSwaptionVolatilityStructure sv) -> ((Word,TimeUnit)) -- ^optionTenor
1565 -> (Double) -- ^swapLength
1566 -> (Bool) -- ^extrapolate
1567 -> IO ((SmileSection))
1568 smileSectionTenorLength a1 a2 a3 a4 =
1569 withSwaptionVolatilityStructure a1 $ \a1' ->
1570 let {(a2'1, a2'2) = fromEnumQuantity a2} in
1571 let {a3' = realToFrac a3} in
1572 let {a4' = C2HSImp.fromBool a4} in
1573 preErrorCheck $ \a5' ->
1574 smileSectionTenorLength'_ a1' a2'1 a2'2 a3' a4' a5' >>= \res ->
1575 peekSmileSection res >>= \res' ->
1576 errorCheck a5'>>
1577 return (res')
1578
1579
1580
1581 -- |returns the smile for a given option date and swap length
1582 smileSectionDateLength :: (GenSwaptionVolatilityStructure sv) -> (Day) -- ^optionDate
1583 -> (Double) -- ^swapLength
1584 -> (Bool) -- ^extr
1585 -> IO ((SmileSection))
1586 smileSectionDateLength a1 a2 a3 a4 =
1587 withSwaptionVolatilityStructure a1 $ \a1' ->
1588 withDay a2 $ \a2' ->
1589 let {a3' = realToFrac a3} in
1590 let {a4' = C2HSImp.fromBool a4} in
1591 preErrorCheck $ \a5' ->
1592 smileSectionDateLength'_ a1' a2' a3' a4' a5' >>= \res ->
1593 peekSmileSection res >>= \res' ->
1594 errorCheck a5'>>
1595 return (res')
1596
1597
1598
1599 -- |returns the smile for a given option time and swap length
1600 smileSectionTimeLength :: (GenSwaptionVolatilityStructure sv) -> (Double) -- ^optionTime
1601 -> (Double) -- ^swapLength
1602 -> (Bool) -- ^extr
1603 -> IO ((SmileSection))
1604 smileSectionTimeLength a1 a2 a3 a4 =
1605 withSwaptionVolatilityStructure a1 $ \a1' ->
1606 let {a2' = realToFrac a2} in
1607 let {a3' = realToFrac a3} in
1608 let {a4' = C2HSImp.fromBool a4} in
1609 preErrorCheck $ \a5' ->
1610 smileSectionTimeLength'_ a1' a2' a3' a4' a5' >>= \res ->
1611 peekSmileSection res >>= \res' ->
1612 errorCheck a5'>>
1613 return (res')
1614
1615
1616
1617 -- |returns the smile for a given option tenor and swap tenor
1618 smileSectionTenorTenor :: (GenSwaptionVolatilityStructure sv) -> ((Word,TimeUnit)) -- ^optionTenor
1619 -> ((Word,TimeUnit)) -- ^swapTenor
1620 -> (Bool) -- ^extr
1621 -> IO ((SmileSection))
1622 smileSectionTenorTenor a1 a2 a3 a4 =
1623 withSwaptionVolatilityStructure a1 $ \a1' ->
1624 let {(a2'1, a2'2) = fromEnumQuantity a2} in
1625 let {(a3'1, a3'2) = fromEnumQuantity a3} in
1626 let {a4' = C2HSImp.fromBool a4} in
1627 preErrorCheck $ \a5' ->
1628 smileSectionTenorTenor'_ a1' a2'1 a2'2 a3'1 a3'2 a4' a5' >>= \res ->
1629 peekSmileSection res >>= \res' ->
1630 errorCheck a5'>>
1631 return (res')
1632
1633
1634
1635 -- |Returns the smile section for any option-maturity and swap-maturity representation.
1636 smileSection :: GenSwaptionVolatilityStructure sv -> OptionMaturity -> SwapMaturity -> Bool -> IO SmileSection
1637 smileSection sv optionMaturity swapMaturity =
1638 case (optionMaturity, swapMaturity) of
1639 (OptionDate d, SwapTenor t) -> smileSectionDateTenor sv d t
1640 (OptionTime t, SwapTenor p) -> smileSectionTimeTenor sv t p
1641 (OptionTenor p, SwapLength l) -> smileSectionTenorLength sv p l
1642 (OptionDate d, SwapLength l) -> smileSectionDateLength sv d l
1643 (OptionTime t, SwapLength l) -> smileSectionTimeLength sv t l
1644 (OptionTenor o, SwapTenor s) -> smileSectionTenorTenor sv o s
1645
1646 -- |A smile section built directly from SABR parameters (Hagan et al. 2002) at a year-fraction
1647 -- expiry, rather than interpolated from a 'SwaptionVolatilityStructure'.
1648 sabrSmileSection :: (Double) -- ^timeToExpiry
1649 -> (Double) -- ^forward
1650 -> (Double) -- ^alpha
1651 -> (Double) -- ^beta
1652 -> (Double) -- ^nu
1653 -> (Double) -- ^rho
1654 -> (Double) -- ^shift
1655 -> (VolatilityType) -- ^volatilityType
1656 -> IO ((SmileSection))
1657 sabrSmileSection a1 a2 a3 a4 a5 a6 a7 a8 =
1658 let {a1' = realToFrac a1} in
1659 let {a2' = realToFrac a2} in
1660 let {a3' = realToFrac a3} in
1661 let {a4' = realToFrac a4} in
1662 let {a5' = realToFrac a5} in
1663 let {a6' = realToFrac a6} in
1664 let {a7' = realToFrac a7} in
1665 let {a8' = (fromIntegral . fromEnum) a8} in
1666 preErrorCheck $ \a9' ->
1667 sabrSmileSection'_ a1' a2' a3' a4' a5' a6' a7' a8' a9' >>= \res ->
1668 peekSmileSection res >>= \res' ->
1669 errorCheck a9'>>
1670 return (res')
1671
1672
1673
1674 -- |As 'sabrSmileSection', at an option date. A 'Just' reference date pins the section; 'Nothing'
1675 -- makes it float, registering with the evaluation date and recomputing the exercise time whenever
1676 -- the evaluation date moves.
1677 sabrSmileSectionAtDate :: Day -> DayCounter -> Maybe Day
1678 -> Double -> Double -> Double -> Double -> Double -> Double -> VolatilityType -> IO SmileSection
1679 sabrSmileSectionAtDate optionDate dc refDate forward alpha beta nu rho shift volatilityType =
1680 sabrSmileSectionAtDateRaw optionDate forward alpha beta nu rho refDate dc shift volatilityType
1681
1682 sabrSmileSectionAtDateRaw :: (Day) -- ^optionDate
1683 -> (Double) -- ^forward
1684 -> (Double) -- ^alpha
1685 -> (Double) -- ^beta
1686 -> (Double) -- ^nu
1687 -> (Double) -- ^rho
1688 -> (Maybe Day) -- ^referenceDate
1689 -> (DayCounter) -> (Double) -- ^shift
1690 -> (VolatilityType) -- ^volatilityType
1691 -> IO ((SmileSection))
1692 sabrSmileSectionAtDateRaw a1 a2 a3 a4 a5 a6 a7 a8 a9 a10 =
1693 withDay a1 $ \a1' ->
1694 let {a2' = realToFrac a2} in
1695 let {a3' = realToFrac a3} in
1696 let {a4' = realToFrac a4} in
1697 let {a5' = realToFrac a5} in
1698 let {a6' = realToFrac a6} in
1699 withMaybeDay a7 $ \a7' ->
1700 withDayCounter a8 $ \a8' ->
1701 let {a9' = realToFrac a9} in
1702 let {a10' = (fromIntegral . fromEnum) a10} in
1703 preErrorCheck $ \a11' ->
1704 sabrSmileSectionAtDateRaw'_ a1' a2' a3' a4' a5' a6' a7' a8' a9' a10' a11' >>= \res ->
1705 peekSmileSection res >>= \res' ->
1706 errorCheck a11'>>
1707 return (res')
1708
1709
1710
1711 -- |An arbitrage-free SABR smile section (Doust's approach via 'NoArbSabrSmileSection'), built
1712 -- directly from SABR parameters like 'sabrSmileSection' but guaranteeing a proper terminal density.
1713 noArbSabrSmileSection :: RatePoint -> Double -> Double -> Double -> Double -> Double -> Double
1714 -> VolatilityType -> IO SmileSection
1715 noArbSabrSmileSection point forward alpha beta nu rho shift volatilityType = case point of
1716 RateAtDate d dc ->
1717 noArbSabrSmileSectionAtDateRaw d forward alpha beta nu rho dc shift volatilityType
1718 RateAtTime t ->
1719 noArbSabrSmileSectionAtTimeRaw t forward alpha beta nu rho shift volatilityType
1720
1721 noArbSabrSmileSectionAtTimeRaw :: (Double) -- ^timeToExpiry
1722 -> (Double) -- ^forward
1723 -> (Double) -- ^alpha
1724 -> (Double) -- ^beta
1725 -> (Double) -- ^nu
1726 -> (Double) -- ^rho
1727 -> (Double) -- ^shift
1728 -> (VolatilityType) -- ^volatilityType
1729 -> IO ((SmileSection))
1730 noArbSabrSmileSectionAtTimeRaw a1 a2 a3 a4 a5 a6 a7 a8 =
1731 let {a1' = realToFrac a1} in
1732 let {a2' = realToFrac a2} in
1733 let {a3' = realToFrac a3} in
1734 let {a4' = realToFrac a4} in
1735 let {a5' = realToFrac a5} in
1736 let {a6' = realToFrac a6} in
1737 let {a7' = realToFrac a7} in
1738 let {a8' = (fromIntegral . fromEnum) a8} in
1739 preErrorCheck $ \a9' ->
1740 noArbSabrSmileSectionAtTimeRaw'_ a1' a2' a3' a4' a5' a6' a7' a8' a9' >>= \res ->
1741 peekSmileSection res >>= \res' ->
1742 errorCheck a9'>>
1743 return (res')
1744
1745
1746
1747 noArbSabrSmileSectionAtDateRaw :: (Day) -- ^optionDate
1748 -> (Double) -- ^forward
1749 -> (Double) -- ^alpha
1750 -> (Double) -- ^beta
1751 -> (Double) -- ^nu
1752 -> (Double) -- ^rho
1753 -> (DayCounter) -> (Double) -- ^shift
1754 -> (VolatilityType) -- ^volatilityType
1755 -> IO ((SmileSection))
1756 noArbSabrSmileSectionAtDateRaw a1 a2 a3 a4 a5 a6 a7 a8 a9 =
1757 withDay a1 $ \a1' ->
1758 let {a2' = realToFrac a2} in
1759 let {a3' = realToFrac a3} in
1760 let {a4' = realToFrac a4} in
1761 let {a5' = realToFrac a5} in
1762 let {a6' = realToFrac a6} in
1763 withDayCounter a7 $ \a7' ->
1764 let {a8' = realToFrac a8} in
1765 let {a9' = (fromIntegral . fromEnum) a9} in
1766 preErrorCheck $ \a10' ->
1767 noArbSabrSmileSectionAtDateRaw'_ a1' a2' a3' a4' a5' a6' a7' a8' a9' a10' >>= \res ->
1768 peekSmileSection res >>= \res' ->
1769 errorCheck a10'>>
1770 return (res')
1771
1772
1773
1774 -- |the volatility for the given strike, for any 'SmileSection' (however it was constructed)
1775 smileSectionVolatility :: (SmileSection) -> (Double) -- ^strike
1776 -> IO ((Double))
1777 smileSectionVolatility a1 a2 =
1778 withSmileSection a1 $ \a1' ->
1779 let {a2' = realToFrac a2} in
1780 preErrorCheck $ \a3' ->
1781 smileSectionVolatility'_ a1' a2' a3' >>= \res ->
1782 let {res' = realToFrac res} in
1783 errorCheck a3'>>
1784 return (res')
1785
1786
1787
1788 -- |the Black variance for the given strike, for any 'SmileSection' (however it was constructed)
1789 smileSectionVariance :: (SmileSection) -> (Double) -- ^strike
1790 -> IO ((Double))
1791 smileSectionVariance a1 a2 =
1792 withSmileSection a1 $ \a1' ->
1793 let {a2' = realToFrac a2} in
1794 preErrorCheck $ \a3' ->
1795 smileSectionVariance'_ a1' a2' a3' >>= \res ->
1796 let {res' = realToFrac res} in
1797 errorCheck a3'>>
1798 return (res')
1799
1800
1801
1802 -- |the ATM level baked into the 'SmileSection' at construction (or later re-anchored via
1803 -- 'atmSmileSection'), for any 'SmileSection' (however it was constructed)
1804 smileSectionAtmLevel :: (SmileSection) -> IO ((Double))
1805 smileSectionAtmLevel a1 =
1806 withSmileSection a1 $ \a1' ->
1807 preErrorCheck $ \a2' ->
1808 smileSectionAtmLevel'_ a1' a2' >>= \res ->
1809 let {res' = realToFrac res} in
1810 errorCheck a2'>>
1811 return (res')
1812
1813
1814
1815 -- |the (non-discounted-by-default) price of a European option with the given strike\/type,
1816 -- for any 'SmileSection' (however it was constructed)
1817 smileSectionOptionPrice :: (SmileSection) -> (Double) -- ^strike
1818 -> (OptionType) -- ^type
1819 -> (Double) -- ^discount
1820 -> IO ((Double))
1821 smileSectionOptionPrice a1 a2 a3 a4 =
1822 withSmileSection a1 $ \a1' ->
1823 let {a2' = realToFrac a2} in
1824 let {a3' = fromEnumC a3} in
1825 let {a4' = realToFrac a4} in
1826 preErrorCheck $ \a5' ->
1827 smileSectionOptionPrice'_ a1' a2' a3' a4' a5' >>= \res ->
1828 let {res' = realToFrac res} in
1829 errorCheck a5'>>
1830 return (res')
1831
1832
1833
1834 -- |the price of a cash-or-nothing digital option with the given strike\/type, approximated via a
1835 -- call\/put spread of width @gap@, for any 'SmileSection' (however it was constructed)
1836 smileSectionDigitalOptionPrice :: (SmileSection) -> (Double) -- ^strike
1837 -> (OptionType) -- ^type
1838 -> (Double) -- ^discount
1839 -> (Double) -- ^gap
1840 -> IO ((Double))
1841 smileSectionDigitalOptionPrice a1 a2 a3 a4 a5 =
1842 withSmileSection a1 $ \a1' ->
1843 let {a2' = realToFrac a2} in
1844 let {a3' = fromEnumC a3} in
1845 let {a4' = realToFrac a4} in
1846 let {a5' = realToFrac a5} in
1847 preErrorCheck $ \a6' ->
1848 smileSectionDigitalOptionPrice'_ a1' a2' a3' a4' a5' a6' >>= \res ->
1849 let {res' = realToFrac res} in
1850 errorCheck a6'>>
1851 return (res')
1852
1853
1854
1855 -- |the risk-neutral probability density at the given strike, approximated via a finite difference
1856 -- of width @gap@ on 'smileSectionOptionPrice', for any 'SmileSection' (however it was constructed)
1857 smileSectionDensity :: (SmileSection) -> (Double) -- ^strike
1858 -> (Double) -- ^discount
1859 -> (Double) -- ^gap
1860 -> IO ((Double))
1861 smileSectionDensity a1 a2 a3 a4 =
1862 withSmileSection a1 $ \a1' ->
1863 let {a2' = realToFrac a2} in
1864 let {a3' = realToFrac a3} in
1865 let {a4' = realToFrac a4} in
1866 preErrorCheck $ \a5' ->
1867 smileSectionDensity'_ a1' a2' a3' a4' a5' >>= \res ->
1868 let {res' = realToFrac res} in
1869 errorCheck a5'>>
1870 return (res')
1871
1872
1873
1874 -- |the strike derivative of 'smileSectionOptionPrice', for any 'SmileSection' (however it was constructed)
1875 smileSectionVega :: (SmileSection) -> (Double) -- ^strike
1876 -> (Double) -- ^discount
1877 -> IO ((Double))
1878 smileSectionVega a1 a2 a3 =
1879 withSmileSection a1 $ \a1' ->
1880 let {a2' = realToFrac a2} in
1881 let {a3' = realToFrac a3} in
1882 preErrorCheck $ \a4' ->
1883 smileSectionVega'_ a1' a2' a3' a4' >>= \res ->
1884 let {res' = realToFrac res} in
1885 errorCheck a4'>>
1886 return (res')
1887
1888
1889
1890 minStrikeSmileSectionRaw :: (SmileSection) -> IO ((Double))
1891 minStrikeSmileSectionRaw a1 =
1892 withSmileSection a1 $ \a1' ->
1893 preErrorCheck $ \a2' ->
1894 minStrikeSmileSectionRaw'_ a1' a2' >>= \res ->
1895 let {res' = realToFrac res} in
1896 errorCheck a2'>>
1897 return (res')
1898
1899
1900 maxStrikeSmileSectionRaw :: (SmileSection) -> IO ((Double))
1901 maxStrikeSmileSectionRaw a1 =
1902 withSmileSection a1 $ \a1' ->
1903 preErrorCheck $ \a2' ->
1904 maxStrikeSmileSectionRaw'_ a1' a2' >>= \res ->
1905 let {res' = realToFrac res} in
1906 errorCheck a2'>>
1907 return (res')
1908
1909
1910
1911 -- |a flat-volatility smile section: 'volatility' returns @vol@ for every strike.
1912 -- 'Nothing'\/'Nothing' reproduce upstream's own defaults for @referenceDate@\/@atmLevel@.
1913 flatSmileSection :: (Day) -> (Double) -- ^vol
1914 -> (DayCounter) -> (Maybe Day) -- ^referenceDate
1915 -> (Maybe Double) -- ^atmLevel
1916 -> (VolatilityType) -- ^type
1917 -> (Double) -- ^shift
1918 -> IO ((SmileSection))
1919 flatSmileSection a1 a2 a3 a4 a5 a6 a7 =
1920 withDay a1 $ \a1' ->
1921 let {a2' = realToFrac a2} in
1922 withDayCounter a3 $ \a3' ->
1923 withMaybeDay a4 $ \a4' ->
1924 let {a5' = fromMaybeDouble a5} in
1925 let {a6' = (fromIntegral . fromEnum) a6} in
1926 let {a7' = realToFrac a7} in
1927 preErrorCheck $ \a8' ->
1928 flatSmileSection'_ a1' a2' a3' a4' a5' a6' a7' a8' >>= \res ->
1929 peekSmileSection res >>= \res' ->
1930 errorCheck a8'>>
1931 return (res')
1932
1933
1934
1935 -- |a 'SmileSection' whose volatility at every strike is @source@'s plus @spread@ (which may
1936 -- change over time, since it's a live t'GenQuote' rather than a fixed number)
1937 spreadedSmileSection :: (SmileSection) -> (GenQuote q) -> IO ((SmileSection))
1938 spreadedSmileSection a1 a2 =
1939 withSmileSection a1 $ \a1' ->
1940 withQuote a2 $ \a2' ->
1941 preErrorCheck $ \a3' ->
1942 spreadedSmileSection'_ a1' a2' a3' >>= \res ->
1943 peekSmileSection res >>= \res' ->
1944 errorCheck a3'>>
1945 return (res')
1946
1947
1948
1949 -- |@source@ re-anchored to a different ATM level ('Nothing' reproduces upstream's own default,
1950 -- which recomputes the ATM level from @source@ itself). @source@'s volatility at every other
1951 -- strike is unchanged -- use 'smileSectionAtmLevel' to observe what this changed.
1952 atmSmileSection :: (SmileSection) -> (Maybe Double) -- ^atm
1953 -> IO ((SmileSection))
1954 atmSmileSection a1 a2 =
1955 withSmileSection a1 $ \a1' ->
1956 let {a2' = fromMaybeDouble a2} in
1957 preErrorCheck $ \a3' ->
1958 atmSmileSection'_ a1' a2' a3' >>= \res ->
1959 peekSmileSection res >>= \res' ->
1960 errorCheck a3'>>
1961 return (res')
1962
1963
1964
1965 -- |a Stochastic Volatility Inspired (SVI) smile section: total variance at
1966 -- log-moneyness @k = log(strike\/forward)@ is @a + b*(rho*(k-m) + sqrt((k-m)^2 + sigma^2))@.
1967 -- Direct evaluation, no calibration.
1968 sviSmileSection :: (Day) -> (Double) -- ^forward
1969 -> (Double) -- ^a
1970 -> (Double) -- ^b
1971 -> (Double) -- ^sigma
1972 -> (Double) -- ^rho
1973 -> (Double) -- ^m
1974 -> (DayCounter) -> IO ((SmileSection))
1975 sviSmileSection a1 a2 a3 a4 a5 a6 a7 a8 =
1976 withDay a1 $ \a1' ->
1977 let {a2' = realToFrac a2} in
1978 let {a3' = realToFrac a3} in
1979 let {a4' = realToFrac a4} in
1980 let {a5' = realToFrac a5} in
1981 let {a6' = realToFrac a6} in
1982 let {a7' = realToFrac a7} in
1983 withDayCounter a8 $ \a8' ->
1984 preErrorCheck $ \a9' ->
1985 sviSmileSection'_ a1' a2' a3' a4' a5' a6' a7' a8' a9' >>= \res ->
1986 peekSmileSection res >>= \res' ->
1987 errorCheck a9'>>
1988 return (res')
1989
1990
1991
1992 -- |A ZABR (Andreasen\/Huge 2011) smile section: direct evaluation (no calibration) of a SABR-like
1993 -- model widened by a fifth parameter, @gamma@, that controls the backbone shape away from
1994 -- @gamma = 1@ (which reduces exactly to Hagan\'s SABR). @evaluation@ selects how the price\/vol at
1995 -- a strike is computed -- see 'ZabrEvaluation'. @moneyness@ is the strike grid (as multiples of
1996 -- the forward) used only by 'ZabrLocalVolatility'\/'ZabrFullFd' to build their finite-difference
1997 -- solve; an empty list reproduces upstream\'s own 21-point default grid, and it is ignored by the
1998 -- two closed-form evaluation modes. @fdRefinement@ subdivides each grid interval for the FD
1999 -- solve\'s accuracy\/speed tradeoff (upstream\'s own default is 5).
2000 zabrSmileSection :: ZabrEvaluation -> RatePoint -> Double -> Double -> Double -> Double -> Double
2001 -> Double -> [Double] -> Word -> IO SmileSection
2002 zabrSmileSection evaluation point forward alpha beta nu rho gamma moneyness fdRefinement =
2003 case point of
2004 RateAtDate d dc ->
2005 zabrSmileSectionAtDateRaw evaluation d forward alpha beta nu rho gamma dc moneyness fdRefinement
2006 RateAtTime t ->
2007 zabrSmileSectionAtTimeRaw evaluation t forward alpha beta nu rho gamma moneyness fdRefinement
2008
2009 zabrSmileSectionAtTimeRaw :: (ZabrEvaluation) -> (Double) -- ^timeToExpiry
2010 -> (Double) -- ^forward
2011 -> (Double) -- ^alpha
2012 -> (Double) -- ^beta
2013 -> (Double) -- ^nu
2014 -> (Double) -- ^rho
2015 -> (Double) -- ^gamma
2016 -> ([Double]) -- ^moneyness
2017 -> (Word) -- ^fdRefinement
2018 -> IO ((SmileSection))
2019 zabrSmileSectionAtTimeRaw a1 a2 a3 a4 a5 a6 a7 a8 a9 a10 =
2020 let {a1' = (fromIntegral . fromEnum) a1} in
2021 let {a2' = realToFrac a2} in
2022 let {a3' = realToFrac a3} in
2023 let {a4' = realToFrac a4} in
2024 let {a5' = realToFrac a5} in
2025 let {a6' = realToFrac a6} in
2026 let {a7' = realToFrac a7} in
2027 let {a8' = realToFrac a8} in
2028 withDoubleArray a9 $ \(a9'1, a9'2) ->
2029 let {a10' = fromIntegral a10} in
2030 preErrorCheck $ \a11' ->
2031 zabrSmileSectionAtTimeRaw'_ a1' a2' a3' a4' a5' a6' a7' a8' a9'1 a9'2 a10' a11' >>= \res ->
2032 peekSmileSection res >>= \res' ->
2033 errorCheck a11'>>
2034 return (res')
2035
2036
2037
2038 zabrSmileSectionAtDateRaw :: (ZabrEvaluation) -> (Day) -- ^optionDate
2039 -> (Double) -- ^forward
2040 -> (Double) -- ^alpha
2041 -> (Double) -- ^beta
2042 -> (Double) -- ^nu
2043 -> (Double) -- ^rho
2044 -> (Double) -- ^gamma
2045 -> (DayCounter) -> ([Double]) -- ^moneyness
2046 -> (Word) -- ^fdRefinement
2047 -> IO ((SmileSection))
2048 zabrSmileSectionAtDateRaw a1 a2 a3 a4 a5 a6 a7 a8 a9 a10 a11 =
2049 let {a1' = (fromIntegral . fromEnum) a1} in
2050 withDay a2 $ \a2' ->
2051 let {a3' = realToFrac a3} in
2052 let {a4' = realToFrac a4} in
2053 let {a5' = realToFrac a5} in
2054 let {a6' = realToFrac a6} in
2055 let {a7' = realToFrac a7} in
2056 let {a8' = realToFrac a8} in
2057 withDayCounter a9 $ \a9' ->
2058 withDoubleArray a10 $ \(a10'1, a10'2) ->
2059 let {a11' = fromIntegral a11} in
2060 preErrorCheck $ \a12' ->
2061 zabrSmileSectionAtDateRaw'_ a1' a2' a3' a4' a5' a6' a7' a8' a9' a10'1 a10'2 a11' a12' >>= \res ->
2062 peekSmileSection res >>= \res' ->
2063 errorCheck a12'>>
2064 return (res')
2065
2066
2067
2068 -- |a smile section calibrated to a market smile (strikes/vols given directly, not as live
2069 -- quotes -- calibration runs once, eagerly, at construction). alpha\/beta\/nu\/rho\/vegaWeighted
2070 -- are the SABR calibration's initial guess and fixed\/free flags; 'sabrEndCriteria'\/
2071 -- 'sabrOptimizationMethod' default to 'Nothing', which falls back to QuantLib's own internal
2072 -- defaults -- a caller-supplied 'EndCriteria'\/'OptimizationMethod' is safe to pass here since
2073 -- both are shared_ptr-boxed on the C++ side (see the qlaux.h comment above the
2074 -- QlEndCriteria\/QlOptimizationMethod typedefs), so the copy this object's constructor keeps
2075 -- survives regardless of when Haskell's own handle is collected.
2076 sabrInterpolatedSmileSection :: Day -- ^optionDate
2077 -> GenQuote q1 -- ^forward
2078 -> NonEmpty (Double, GenQuote q3) -- ^strike/volatility quotes
2079 -> Bool -- ^hasFloatingStrikes
2080 -> GenQuote q2 -- ^atmVolatility
2081 -> Double -- ^alpha
2082 -> Double -- ^beta
2083 -> Double -- ^nu
2084 -> Double -- ^rho
2085 -> SabrInterpolatedSmileSectionOpts -> IO SabrInterpolatedSmileSection
2086 sabrInterpolatedSmileSection optionDate forward strikeVols hasFloatingStrikes atmVolatility
2087 alpha beta nu rho opts = do
2088 dc <- maybe (dayCounter Actual365FixedStandard) return (sabrDayCounter opts)
2089 sabrInterpolatedSmileSection_ optionDate forward strikes hasFloatingStrikes atmVolatility vols
2090 alpha beta nu rho (sabrIsAlphaFixed opts) (sabrIsBetaFixed opts) (sabrIsNuFixed opts)
2091 (sabrIsRhoFixed opts) (sabrVegaWeighted opts) (sabrEndCriteria opts) (sabrOptimizationMethod opts)
2092 dc (sabrShift opts)
2093 where (strikes, vols) = unzip (toList strikeVols)
2094
2095 sabrInterpolatedSmileSection_ :: (Day) -> (GenQuote q1) -- ^forward
2096 -> ([Double]) -- ^strikes
2097 -> (Bool) -- ^hasFloatingStrikes
2098 -> (GenQuote q2) -- ^atmVolatility
2099 -> ([GenQuote q3]) -- ^vols
2100 -> (Double) -- ^alpha
2101 -> (Double) -- ^beta
2102 -> (Double) -- ^nu
2103 -> (Double) -- ^rho
2104 -> (Bool) -- ^isAlphaFixed
2105 -> (Bool) -- ^isBetaFixed
2106 -> (Bool) -- ^isNuFixed
2107 -> (Bool) -- ^isRhoFixed
2108 -> (Bool) -- ^vegaWeighted
2109 -> (Maybe EndCriteria) -> (Maybe OptimizationMethod) -> (DayCounter) -> (Double) -- ^shift
2110 -> IO ((SabrInterpolatedSmileSection))
2111 sabrInterpolatedSmileSection_ a1 a2 a3 a4 a5 a6 a7 a8 a9 a10 a11 a12 a13 a14 a15 a16 a17 a18 a19 =
2112 withDay a1 $ \a1' ->
2113 withQuote a2 $ \a2' ->
2114 withDoubleArray a3 $ \(a3'1, a3'2) ->
2115 let {a4' = C2HSImp.fromBool a4} in
2116 withQuote a5 $ \a5' ->
2117 withQuoteArray a6 $ \(a6'1, a6'2) ->
2118 let {a7' = realToFrac a7} in
2119 let {a8' = realToFrac a8} in
2120 let {a9' = realToFrac a9} in
2121 let {a10' = realToFrac a10} in
2122 let {a11' = C2HSImp.fromBool a11} in
2123 let {a12' = C2HSImp.fromBool a12} in
2124 let {a13' = C2HSImp.fromBool a13} in
2125 let {a14' = C2HSImp.fromBool a14} in
2126 let {a15' = C2HSImp.fromBool a15} in
2127 withMaybeEndCriteria a16 $ \a16' ->
2128 withMaybeOptimizationMethod a17 $ \a17' ->
2129 withDayCounter a18 $ \a18' ->
2130 let {a19' = realToFrac a19} in
2131 preErrorCheck $ \a20' ->
2132 sabrInterpolatedSmileSection_'_ a1' a2' a3'1 a3'2 a4' a5' a6'1 a6'2 a7' a8' a9' a10' a11' a12' a13' a14' a15' a16' a17' a18' a19' a20' >>= \res ->
2133 peekSabrInterpolatedSmileSection res >>= \res' ->
2134 errorCheck a20'>>
2135 return (res')
2136
2137
2138
2139 -- |upcast to the generic 'SmileSection' interface (e.g. for 'smileSectionVolatility'\/'smileSectionVariance').
2140 -- A fresh-@shared_ptr@ upcast, always safe -- not the reverse (downcast) direction.
2141 sabrAsSmileSection :: (SabrInterpolatedSmileSection) -> IO ((SmileSection))
2142 sabrAsSmileSection a1 =
2143 withSabrInterpolatedSmileSection a1 $ \a1' ->
2144 preErrorCheck $ \a2' ->
2145 sabrAsSmileSection'_ a1' a2' >>= \res ->
2146 peekSmileSection res >>= \res' ->
2147 errorCheck a2'>>
2148 return (res')
2149
2150
2151
2152 -- |calibrated alpha (post-fit; can differ from the initial guess passed to
2153 -- 'sabrInterpolatedSmileSection' unless @sabrIsAlphaFixed@ was set).
2154 sabrAlpha :: (SabrInterpolatedSmileSection) -> IO ((Double))
2155 sabrAlpha a1 =
2156 withSabrInterpolatedSmileSection a1 $ \a1' ->
2157 preErrorCheck $ \a2' ->
2158 sabrAlpha'_ a1' a2' >>= \res ->
2159 let {res' = realToFrac res} in
2160 errorCheck a2'>>
2161 return (res')
2162
2163
2164
2165 -- |calibrated beta, see 'sabrAlpha'
2166 sabrBeta :: (SabrInterpolatedSmileSection) -> IO ((Double))
2167 sabrBeta a1 =
2168 withSabrInterpolatedSmileSection a1 $ \a1' ->
2169 preErrorCheck $ \a2' ->
2170 sabrBeta'_ a1' a2' >>= \res ->
2171 let {res' = realToFrac res} in
2172 errorCheck a2'>>
2173 return (res')
2174
2175
2176
2177 -- |calibrated nu, see 'sabrAlpha'
2178 sabrNu :: (SabrInterpolatedSmileSection) -> IO ((Double))
2179 sabrNu a1 =
2180 withSabrInterpolatedSmileSection a1 $ \a1' ->
2181 preErrorCheck $ \a2' ->
2182 sabrNu'_ a1' a2' >>= \res ->
2183 let {res' = realToFrac res} in
2184 errorCheck a2'>>
2185 return (res')
2186
2187
2188
2189 -- |calibrated rho, see 'sabrAlpha'
2190 sabrRho :: (SabrInterpolatedSmileSection) -> IO ((Double))
2191 sabrRho a1 =
2192 withSabrInterpolatedSmileSection a1 $ \a1' ->
2193 preErrorCheck $ \a2' ->
2194 sabrRho'_ a1' a2' >>= \res ->
2195 let {res' = realToFrac res} in
2196 errorCheck a2'>>
2197 return (res')
2198
2199
2200
2201 -- |root-mean-square calibration error
2202 sabrRmsError :: (SabrInterpolatedSmileSection) -> IO ((Double))
2203 sabrRmsError a1 =
2204 withSabrInterpolatedSmileSection a1 $ \a1' ->
2205 preErrorCheck $ \a2' ->
2206 sabrRmsError'_ a1' a2' >>= \res ->
2207 let {res' = realToFrac res} in
2208 errorCheck a2'>>
2209 return (res')
2210
2211
2212
2213 -- |maximum calibration error
2214 sabrMaxError :: (SabrInterpolatedSmileSection) -> IO ((Double))
2215 sabrMaxError a1 =
2216 withSabrInterpolatedSmileSection a1 $ \a1' ->
2217 preErrorCheck $ \a2' ->
2218 sabrMaxError'_ a1' a2' >>= \res ->
2219 let {res' = realToFrac res} in
2220 errorCheck a2'>>
2221 return (res')
2222
2223
2224
2225 -- |the reason the SABR calibration's optimizer stopped
2226 sabrCalibrationEndCriteria :: (SabrInterpolatedSmileSection) -> IO ((EndCriteriaType))
2227 sabrCalibrationEndCriteria a1 =
2228 withSabrInterpolatedSmileSection a1 $ \a1' ->
2229 preErrorCheck $ \a2' ->
2230 sabrCalibrationEndCriteria'_ a1' a2' >>= \res ->
2231 let {res' = (toEnum . fromIntegral) res} in
2232 errorCheck a2'>>
2233 return (res')
2234
2235
2236
2237 -- |a smile section calibrated to a market smile using Stochastic Volatility Inspired (SVI, Gatheral
2238 -- 2004) parameterization: total variance at log-moneyness @k = log(strike\/forward)@ is
2239 -- @a + b*(rho*(k-m) + sqrt((k-m)^2 + sigma^2))@. Strikes\/vols are given directly (not as live
2240 -- quotes) -- calibration runs once, eagerly, at construction, same as 'sabrInterpolatedSmileSection'.
2241 -- @a@\/@b@\/@sigma@\/@rho@\/@m@ are the SVI calibration's initial guess;
2242 -- @aIsFixed@\/@bIsFixed@\/@sigmaIsFixed@\/@rhoIsFixed@\/@mIsFixed@ have no upstream default (unlike
2243 -- SABR's fixed flags, which default to 'False') and so are always required here. Calibration
2244 -- enforces, at construction: @b >= 0@, @|rho| < 1@, @sigma > 0@,
2245 -- @a + b*sigma*sqrt(1-rho^2) >= 0@, and @b*(1+|rho|) <= 4@.
2246 sviInterpolatedSmileSection :: Day -- ^optionDate
2247 -> GenQuote q1 -- ^forward
2248 -> NonEmpty (Double, GenQuote q3) -- ^strike/volatility quotes
2249 -> Bool -- ^hasFloatingStrikes
2250 -> GenQuote q2 -- ^atmVolatility
2251 -> Double -- ^a
2252 -> Double -- ^b
2253 -> Double -- ^sigma
2254 -> Double -- ^rho
2255 -> Double -- ^m
2256 -> Bool -- ^aIsFixed
2257 -> Bool -- ^bIsFixed
2258 -> Bool -- ^sigmaIsFixed
2259 -> Bool -- ^rhoIsFixed
2260 -> Bool -- ^mIsFixed
2261 -> Bool -- ^vegaWeighted
2262 -> Maybe EndCriteria
2263 -> Maybe OptimizationMethod
2264 -> DayCounter -> IO SviInterpolatedSmileSection
2265 sviInterpolatedSmileSection optionDate forward strikeVols hasFloatingStrikes atmVolatility
2266 a b sigma rho m aIsFixed bIsFixed sigmaIsFixed rhoIsFixed mIsFixed vegaWeighted
2267 endCriteria method dc =
2268 sviInterpolatedSmileSection_ optionDate forward strikes hasFloatingStrikes atmVolatility vols
2269 a b sigma rho m aIsFixed bIsFixed sigmaIsFixed rhoIsFixed mIsFixed vegaWeighted
2270 endCriteria method dc
2271 where (strikes, vols) = unzip (toList strikeVols)
2272
2273 sviInterpolatedSmileSection_ :: (Day) -> (GenQuote q1) -- ^forward
2274 -> ([Double]) -- ^strikes
2275 -> (Bool) -- ^hasFloatingStrikes
2276 -> (GenQuote q2) -- ^atmVolatility
2277 -> ([GenQuote q3]) -- ^vols
2278 -> (Double) -- ^a
2279 -> (Double) -- ^b
2280 -> (Double) -- ^sigma
2281 -> (Double) -- ^rho
2282 -> (Double) -- ^m
2283 -> (Bool) -- ^aIsFixed
2284 -> (Bool) -- ^bIsFixed
2285 -> (Bool) -- ^sigmaIsFixed
2286 -> (Bool) -- ^rhoIsFixed
2287 -> (Bool) -- ^mIsFixed
2288 -> (Bool) -- ^vegaWeighted
2289 -> (Maybe EndCriteria) -> (Maybe OptimizationMethod) -> (DayCounter) -> IO ((SviInterpolatedSmileSection))
2290 sviInterpolatedSmileSection_ a1 a2 a3 a4 a5 a6 a7 a8 a9 a10 a11 a12 a13 a14 a15 a16 a17 a18 a19 a20 =
2291 withDay a1 $ \a1' ->
2292 withQuote a2 $ \a2' ->
2293 withDoubleArray a3 $ \(a3'1, a3'2) ->
2294 let {a4' = C2HSImp.fromBool a4} in
2295 withQuote a5 $ \a5' ->
2296 withQuoteArray a6 $ \(a6'1, a6'2) ->
2297 let {a7' = realToFrac a7} in
2298 let {a8' = realToFrac a8} in
2299 let {a9' = realToFrac a9} in
2300 let {a10' = realToFrac a10} in
2301 let {a11' = realToFrac a11} in
2302 let {a12' = C2HSImp.fromBool a12} in
2303 let {a13' = C2HSImp.fromBool a13} in
2304 let {a14' = C2HSImp.fromBool a14} in
2305 let {a15' = C2HSImp.fromBool a15} in
2306 let {a16' = C2HSImp.fromBool a16} in
2307 let {a17' = C2HSImp.fromBool a17} in
2308 withMaybeEndCriteria a18 $ \a18' ->
2309 withMaybeOptimizationMethod a19 $ \a19' ->
2310 withDayCounter a20 $ \a20' ->
2311 preErrorCheck $ \a21' ->
2312 sviInterpolatedSmileSection_'_ a1' a2' a3'1 a3'2 a4' a5' a6'1 a6'2 a7' a8' a9' a10' a11' a12' a13' a14' a15' a16' a17' a18' a19' a20' a21' >>= \res ->
2313 peekSviInterpolatedSmileSection res >>= \res' ->
2314 errorCheck a21'>>
2315 return (res')
2316
2317
2318
2319 -- |upcast to the generic 'SmileSection' interface (e.g. for 'smileSectionVolatility'\/'smileSectionVariance').
2320 -- A fresh-@shared_ptr@ upcast, always safe -- not the reverse (downcast) direction.
2321 sviAsSmileSection :: (SviInterpolatedSmileSection) -> IO ((SmileSection))
2322 sviAsSmileSection a1 =
2323 withSviInterpolatedSmileSection a1 $ \a1' ->
2324 preErrorCheck $ \a2' ->
2325 sviAsSmileSection'_ a1' a2' >>= \res ->
2326 peekSmileSection res >>= \res' ->
2327 errorCheck a2'>>
2328 return (res')
2329
2330
2331
2332 -- |calibrated @a@ (post-fit; can differ from the initial guess passed to
2333 -- 'sviInterpolatedSmileSection' unless @aIsFixed@ was set).
2334 sviA :: (SviInterpolatedSmileSection) -> IO ((Double))
2335 sviA a1 =
2336 withSviInterpolatedSmileSection a1 $ \a1' ->
2337 preErrorCheck $ \a2' ->
2338 sviA'_ a1' a2' >>= \res ->
2339 let {res' = realToFrac res} in
2340 errorCheck a2'>>
2341 return (res')
2342
2343
2344
2345 -- |calibrated @b@, see 'sviA'
2346 sviB :: (SviInterpolatedSmileSection) -> IO ((Double))
2347 sviB a1 =
2348 withSviInterpolatedSmileSection a1 $ \a1' ->
2349 preErrorCheck $ \a2' ->
2350 sviB'_ a1' a2' >>= \res ->
2351 let {res' = realToFrac res} in
2352 errorCheck a2'>>
2353 return (res')
2354
2355
2356
2357 -- |calibrated @sigma@, see 'sviA'
2358 sviSigma :: (SviInterpolatedSmileSection) -> IO ((Double))
2359 sviSigma a1 =
2360 withSviInterpolatedSmileSection a1 $ \a1' ->
2361 preErrorCheck $ \a2' ->
2362 sviSigma'_ a1' a2' >>= \res ->
2363 let {res' = realToFrac res} in
2364 errorCheck a2'>>
2365 return (res')
2366
2367
2368
2369 -- |calibrated @rho@, see 'sviA'
2370 sviRho :: (SviInterpolatedSmileSection) -> IO ((Double))
2371 sviRho a1 =
2372 withSviInterpolatedSmileSection a1 $ \a1' ->
2373 preErrorCheck $ \a2' ->
2374 sviRho'_ a1' a2' >>= \res ->
2375 let {res' = realToFrac res} in
2376 errorCheck a2'>>
2377 return (res')
2378
2379
2380
2381 -- |calibrated @m@, see 'sviA'
2382 sviM :: (SviInterpolatedSmileSection) -> IO ((Double))
2383 sviM a1 =
2384 withSviInterpolatedSmileSection a1 $ \a1' ->
2385 preErrorCheck $ \a2' ->
2386 sviM'_ a1' a2' >>= \res ->
2387 let {res' = realToFrac res} in
2388 errorCheck a2'>>
2389 return (res')
2390
2391
2392
2393 -- |root-mean-square calibration error
2394 sviRmsError :: (SviInterpolatedSmileSection) -> IO ((Double))
2395 sviRmsError a1 =
2396 withSviInterpolatedSmileSection a1 $ \a1' ->
2397 preErrorCheck $ \a2' ->
2398 sviRmsError'_ a1' a2' >>= \res ->
2399 let {res' = realToFrac res} in
2400 errorCheck a2'>>
2401 return (res')
2402
2403
2404
2405 -- |maximum calibration error
2406 sviMaxError :: (SviInterpolatedSmileSection) -> IO ((Double))
2407 sviMaxError a1 =
2408 withSviInterpolatedSmileSection a1 $ \a1' ->
2409 preErrorCheck $ \a2' ->
2410 sviMaxError'_ a1' a2' >>= \res ->
2411 let {res' = realToFrac res} in
2412 errorCheck a2'>>
2413 return (res')
2414
2415
2416
2417 -- |the reason the SVI calibration's optimizer stopped
2418 sviEndCriteria :: (SviInterpolatedSmileSection) -> IO ((EndCriteriaType))
2419 sviEndCriteria a1 =
2420 withSviInterpolatedSmileSection a1 $ \a1' ->
2421 preErrorCheck $ \a2' ->
2422 sviEndCriteria'_ a1' a2' >>= \res ->
2423 let {res' = (toEnum . fromIntegral) res} in
2424 errorCheck a2'>>
2425 return (res')
2426
2427
2428
2429 -- |a smile section calibrated to a market smile using the arbitrage-free SABR parameterization
2430 -- (Doust's approach, via 'NoArbSabrModel' -- see 'noArbSabrSmileSection'). Unlike
2431 -- 'noArbSabrSmileSection', which takes fixed calibrated parameters directly, this runs the
2432 -- alpha\/beta\/nu\/rho calibration itself against the given strike\/volatility quotes -- eagerly,
2433 -- at construction, same as 'sabrInterpolatedSmileSection'. @alpha@\/@beta@\/@nu@\/@rho@ are the
2434 -- calibration's initial guess; @isAlphaFixed@\/@isBetaFixed@\/@isNuFixed@\/@isRhoFixed@ default to
2435 -- 'False' upstream (unlike SVI's fixed flags, which have no default), and there is no @shift@
2436 -- parameter (unlike 'sabrInterpolatedSmileSection').
2437 noArbSabrInterpolatedSmileSection :: Day -- ^optionDate
2438 -> GenQuote q1 -- ^forward
2439 -> NonEmpty (Double, GenQuote q3) -- ^strike/volatility quotes
2440 -> Bool -- ^hasFloatingStrikes
2441 -> GenQuote q2 -- ^atmVolatility
2442 -> Double -- ^alpha
2443 -> Double -- ^beta
2444 -> Double -- ^nu
2445 -> Double -- ^rho
2446 -> Bool -- ^isAlphaFixed
2447 -> Bool -- ^isBetaFixed
2448 -> Bool -- ^isNuFixed
2449 -> Bool -- ^isRhoFixed
2450 -> Bool -- ^vegaWeighted
2451 -> Maybe EndCriteria
2452 -> Maybe OptimizationMethod
2453 -> DayCounter -> IO NoArbSabrInterpolatedSmileSection
2454 noArbSabrInterpolatedSmileSection optionDate forward strikeVols hasFloatingStrikes atmVolatility
2455 alpha beta nu rho isAlphaFixed isBetaFixed isNuFixed isRhoFixed vegaWeighted
2456 endCriteria method dc =
2457 noArbSabrInterpolatedSmileSection_ optionDate forward strikes hasFloatingStrikes atmVolatility vols
2458 alpha beta nu rho isAlphaFixed isBetaFixed isNuFixed isRhoFixed vegaWeighted
2459 endCriteria method dc
2460 where (strikes, vols) = unzip (toList strikeVols)
2461
2462 noArbSabrInterpolatedSmileSection_ :: (Day) -> (GenQuote q1) -- ^forward
2463 -> ([Double]) -- ^strikes
2464 -> (Bool) -- ^hasFloatingStrikes
2465 -> (GenQuote q2) -- ^atmVolatility
2466 -> ([GenQuote q3]) -- ^vols
2467 -> (Double) -- ^alpha
2468 -> (Double) -- ^beta
2469 -> (Double) -- ^nu
2470 -> (Double) -- ^rho
2471 -> (Bool) -- ^isAlphaFixed
2472 -> (Bool) -- ^isBetaFixed
2473 -> (Bool) -- ^isNuFixed
2474 -> (Bool) -- ^isRhoFixed
2475 -> (Bool) -- ^vegaWeighted
2476 -> (Maybe EndCriteria) -> (Maybe OptimizationMethod) -> (DayCounter) -> IO ((NoArbSabrInterpolatedSmileSection))
2477 noArbSabrInterpolatedSmileSection_ a1 a2 a3 a4 a5 a6 a7 a8 a9 a10 a11 a12 a13 a14 a15 a16 a17 a18 =
2478 withDay a1 $ \a1' ->
2479 withQuote a2 $ \a2' ->
2480 withDoubleArray a3 $ \(a3'1, a3'2) ->
2481 let {a4' = C2HSImp.fromBool a4} in
2482 withQuote a5 $ \a5' ->
2483 withQuoteArray a6 $ \(a6'1, a6'2) ->
2484 let {a7' = realToFrac a7} in
2485 let {a8' = realToFrac a8} in
2486 let {a9' = realToFrac a9} in
2487 let {a10' = realToFrac a10} in
2488 let {a11' = C2HSImp.fromBool a11} in
2489 let {a12' = C2HSImp.fromBool a12} in
2490 let {a13' = C2HSImp.fromBool a13} in
2491 let {a14' = C2HSImp.fromBool a14} in
2492 let {a15' = C2HSImp.fromBool a15} in
2493 withMaybeEndCriteria a16 $ \a16' ->
2494 withMaybeOptimizationMethod a17 $ \a17' ->
2495 withDayCounter a18 $ \a18' ->
2496 preErrorCheck $ \a19' ->
2497 noArbSabrInterpolatedSmileSection_'_ a1' a2' a3'1 a3'2 a4' a5' a6'1 a6'2 a7' a8' a9' a10' a11' a12' a13' a14' a15' a16' a17' a18' a19' >>= \res ->
2498 peekNoArbSabrInterpolatedSmileSection res >>= \res' ->
2499 errorCheck a19'>>
2500 return (res')
2501
2502
2503
2504 -- |upcast to the generic 'SmileSection' interface (e.g. for 'smileSectionVolatility'\/'smileSectionVariance').
2505 -- A fresh-@shared_ptr@ upcast, always safe -- not the reverse (downcast) direction.
2506 noArbSabrAsSmileSection :: (NoArbSabrInterpolatedSmileSection) -> IO ((SmileSection))
2507 noArbSabrAsSmileSection a1 =
2508 withNoArbSabrInterpolatedSmileSection a1 $ \a1' ->
2509 preErrorCheck $ \a2' ->
2510 noArbSabrAsSmileSection'_ a1' a2' >>= \res ->
2511 peekSmileSection res >>= \res' ->
2512 errorCheck a2'>>
2513 return (res')
2514
2515
2516
2517 -- |calibrated @alpha@ (post-fit; can differ from the initial guess passed to
2518 -- 'noArbSabrInterpolatedSmileSection' unless @isAlphaFixed@ was set).
2519 noArbSabrAlpha :: (NoArbSabrInterpolatedSmileSection) -> IO ((Double))
2520 noArbSabrAlpha a1 =
2521 withNoArbSabrInterpolatedSmileSection a1 $ \a1' ->
2522 preErrorCheck $ \a2' ->
2523 noArbSabrAlpha'_ a1' a2' >>= \res ->
2524 let {res' = realToFrac res} in
2525 errorCheck a2'>>
2526 return (res')
2527
2528
2529
2530 -- |calibrated @beta@, see 'noArbSabrAlpha'
2531 noArbSabrBeta :: (NoArbSabrInterpolatedSmileSection) -> IO ((Double))
2532 noArbSabrBeta a1 =
2533 withNoArbSabrInterpolatedSmileSection a1 $ \a1' ->
2534 preErrorCheck $ \a2' ->
2535 noArbSabrBeta'_ a1' a2' >>= \res ->
2536 let {res' = realToFrac res} in
2537 errorCheck a2'>>
2538 return (res')
2539
2540
2541
2542 -- |calibrated @nu@, see 'noArbSabrAlpha'
2543 noArbSabrNu :: (NoArbSabrInterpolatedSmileSection) -> IO ((Double))
2544 noArbSabrNu a1 =
2545 withNoArbSabrInterpolatedSmileSection a1 $ \a1' ->
2546 preErrorCheck $ \a2' ->
2547 noArbSabrNu'_ a1' a2' >>= \res ->
2548 let {res' = realToFrac res} in
2549 errorCheck a2'>>
2550 return (res')
2551
2552
2553
2554 -- |calibrated @rho@, see 'noArbSabrAlpha'
2555 noArbSabrRho :: (NoArbSabrInterpolatedSmileSection) -> IO ((Double))
2556 noArbSabrRho a1 =
2557 withNoArbSabrInterpolatedSmileSection a1 $ \a1' ->
2558 preErrorCheck $ \a2' ->
2559 noArbSabrRho'_ a1' a2' >>= \res ->
2560 let {res' = realToFrac res} in
2561 errorCheck a2'>>
2562 return (res')
2563
2564
2565
2566 -- |root-mean-square calibration error
2567 noArbSabrRmsError :: (NoArbSabrInterpolatedSmileSection) -> IO ((Double))
2568 noArbSabrRmsError a1 =
2569 withNoArbSabrInterpolatedSmileSection a1 $ \a1' ->
2570 preErrorCheck $ \a2' ->
2571 noArbSabrRmsError'_ a1' a2' >>= \res ->
2572 let {res' = realToFrac res} in
2573 errorCheck a2'>>
2574 return (res')
2575
2576
2577
2578 -- |maximum calibration error
2579 noArbSabrMaxError :: (NoArbSabrInterpolatedSmileSection) -> IO ((Double))
2580 noArbSabrMaxError a1 =
2581 withNoArbSabrInterpolatedSmileSection a1 $ \a1' ->
2582 preErrorCheck $ \a2' ->
2583 noArbSabrMaxError'_ a1' a2' >>= \res ->
2584 let {res' = realToFrac res} in
2585 errorCheck a2'>>
2586 return (res')
2587
2588
2589
2590 -- |the reason the calibration's optimizer stopped
2591 noArbSabrEndCriteria :: (NoArbSabrInterpolatedSmileSection) -> IO ((EndCriteriaType))
2592 noArbSabrEndCriteria a1 =
2593 withNoArbSabrInterpolatedSmileSection a1 $ \a1' ->
2594 preErrorCheck $ \a2' ->
2595 noArbSabrEndCriteria'_ a1' a2' >>= \res ->
2596 let {res' = (toEnum . fromIntegral) res} in
2597 errorCheck a2'>>
2598 return (res')
2599
2600
2601
2602 -- |a smile section calibrated to a market smile using the ZABR parameterization (SABR extended
2603 -- with a @gamma@ shape parameter -- see 'zabrSmileSection'). Unlike 'zabrSmileSection', which
2604 -- takes fixed calibrated parameters directly, this runs the alpha\/beta\/nu\/rho\/gamma
2605 -- calibration itself against the given strike\/volatility quotes -- eagerly, at construction,
2606 -- same as 'sabrInterpolatedSmileSection'\/'noArbSabrInterpolatedSmileSection'.
2607 -- @alpha@\/@beta@\/@nu@\/@rho@\/@gamma@ are the calibration's initial guess;
2608 -- @isAlphaFixed@\/@isBetaFixed@\/@isNuFixed@\/@isRhoFixed@\/@isGammaFixed@ default to 'False'
2609 -- upstream. 'ZabrEvaluation' picks the same short-maturity\/local-volatility\/full-PDE evaluation
2610 -- method as 'zabrSmileSection'.
2611 zabrInterpolatedSmileSection :: ZabrEvaluation
2612 -> Day -- ^optionDate
2613 -> GenQuote q1 -- ^forward
2614 -> NonEmpty (Double, GenQuote q3) -- ^strike/volatility quotes
2615 -> Bool -- ^hasFloatingStrikes
2616 -> GenQuote q2 -- ^atmVolatility
2617 -> Double -- ^alpha
2618 -> Double -- ^beta
2619 -> Double -- ^nu
2620 -> Double -- ^rho
2621 -> Double -- ^gamma
2622 -> Bool -- ^isAlphaFixed
2623 -> Bool -- ^isBetaFixed
2624 -> Bool -- ^isNuFixed
2625 -> Bool -- ^isRhoFixed
2626 -> Bool -- ^isGammaFixed
2627 -> Bool -- ^vegaWeighted
2628 -> Maybe EndCriteria
2629 -> Maybe OptimizationMethod
2630 -> DayCounter -> IO ZabrInterpolatedSmileSection
2631 zabrInterpolatedSmileSection evaluation optionDate forward strikeVols hasFloatingStrikes atmVolatility
2632 alpha beta nu rho gamma isAlphaFixed isBetaFixed isNuFixed isRhoFixed isGammaFixed vegaWeighted
2633 endCriteria method dc =
2634 zabrInterpolatedSmileSection_ evaluation optionDate forward strikes hasFloatingStrikes atmVolatility vols
2635 alpha beta nu rho gamma isAlphaFixed isBetaFixed isNuFixed isRhoFixed isGammaFixed vegaWeighted
2636 endCriteria method dc
2637 where (strikes, vols) = unzip (toList strikeVols)
2638
2639 zabrInterpolatedSmileSection_ :: (ZabrEvaluation) -> (Day) -> (GenQuote q1) -- ^forward
2640 -> ([Double]) -- ^strikes
2641 -> (Bool) -- ^hasFloatingStrikes
2642 -> (GenQuote q2) -- ^atmVolatility
2643 -> ([GenQuote q3]) -- ^vols
2644 -> (Double) -- ^alpha
2645 -> (Double) -- ^beta
2646 -> (Double) -- ^nu
2647 -> (Double) -- ^rho
2648 -> (Double) -- ^gamma
2649 -> (Bool) -- ^isAlphaFixed
2650 -> (Bool) -- ^isBetaFixed
2651 -> (Bool) -- ^isNuFixed
2652 -> (Bool) -- ^isRhoFixed
2653 -> (Bool) -- ^isGammaFixed
2654 -> (Bool) -- ^vegaWeighted
2655 -> (Maybe EndCriteria) -> (Maybe OptimizationMethod) -> (DayCounter) -> IO ((ZabrInterpolatedSmileSection))
2656 zabrInterpolatedSmileSection_ a1 a2 a3 a4 a5 a6 a7 a8 a9 a10 a11 a12 a13 a14 a15 a16 a17 a18 a19 a20 a21 =
2657 let {a1' = (fromIntegral . fromEnum) a1} in
2658 withDay a2 $ \a2' ->
2659 withQuote a3 $ \a3' ->
2660 withDoubleArray a4 $ \(a4'1, a4'2) ->
2661 let {a5' = C2HSImp.fromBool a5} in
2662 withQuote a6 $ \a6' ->
2663 withQuoteArray a7 $ \(a7'1, a7'2) ->
2664 let {a8' = realToFrac a8} in
2665 let {a9' = realToFrac a9} in
2666 let {a10' = realToFrac a10} in
2667 let {a11' = realToFrac a11} in
2668 let {a12' = realToFrac a12} in
2669 let {a13' = C2HSImp.fromBool a13} in
2670 let {a14' = C2HSImp.fromBool a14} in
2671 let {a15' = C2HSImp.fromBool a15} in
2672 let {a16' = C2HSImp.fromBool a16} in
2673 let {a17' = C2HSImp.fromBool a17} in
2674 let {a18' = C2HSImp.fromBool a18} in
2675 withMaybeEndCriteria a19 $ \a19' ->
2676 withMaybeOptimizationMethod a20 $ \a20' ->
2677 withDayCounter a21 $ \a21' ->
2678 preErrorCheck $ \a22' ->
2679 zabrInterpolatedSmileSection_'_ a1' a2' a3' a4'1 a4'2 a5' a6' a7'1 a7'2 a8' a9' a10' a11' a12' a13' a14' a15' a16' a17' a18' a19' a20' a21' a22' >>= \res ->
2680 peekZabrInterpolatedSmileSection res >>= \res' ->
2681 errorCheck a22'>>
2682 return (res')
2683
2684
2685
2686 -- |upcast to the generic 'SmileSection' interface (e.g. for 'smileSectionVolatility'\/'smileSectionVariance').
2687 -- A fresh-@shared_ptr@ upcast, always safe -- not the reverse (downcast) direction.
2688 zabrInterpolatedAsSmileSection :: (ZabrInterpolatedSmileSection) -> IO ((SmileSection))
2689 zabrInterpolatedAsSmileSection a1 =
2690 withZabrInterpolatedSmileSection a1 $ \a1' ->
2691 preErrorCheck $ \a2' ->
2692 zabrInterpolatedAsSmileSection'_ a1' a2' >>= \res ->
2693 peekSmileSection res >>= \res' ->
2694 errorCheck a2'>>
2695 return (res')
2696
2697
2698
2699 -- |calibrated @alpha@ (post-fit; can differ from the initial guess passed to
2700 -- 'zabrInterpolatedSmileSection' unless @isAlphaFixed@ was set).
2701 zabrInterpolatedAlpha :: (ZabrInterpolatedSmileSection) -> IO ((Double))
2702 zabrInterpolatedAlpha a1 =
2703 withZabrInterpolatedSmileSection a1 $ \a1' ->
2704 preErrorCheck $ \a2' ->
2705 zabrInterpolatedAlpha'_ a1' a2' >>= \res ->
2706 let {res' = realToFrac res} in
2707 errorCheck a2'>>
2708 return (res')
2709
2710
2711
2712 -- |calibrated @beta@, see 'zabrInterpolatedAlpha'
2713 zabrInterpolatedBeta :: (ZabrInterpolatedSmileSection) -> IO ((Double))
2714 zabrInterpolatedBeta a1 =
2715 withZabrInterpolatedSmileSection a1 $ \a1' ->
2716 preErrorCheck $ \a2' ->
2717 zabrInterpolatedBeta'_ a1' a2' >>= \res ->
2718 let {res' = realToFrac res} in
2719 errorCheck a2'>>
2720 return (res')
2721
2722
2723
2724 -- |calibrated @nu@, see 'zabrInterpolatedAlpha'
2725 zabrInterpolatedNu :: (ZabrInterpolatedSmileSection) -> IO ((Double))
2726 zabrInterpolatedNu a1 =
2727 withZabrInterpolatedSmileSection a1 $ \a1' ->
2728 preErrorCheck $ \a2' ->
2729 zabrInterpolatedNu'_ a1' a2' >>= \res ->
2730 let {res' = realToFrac res} in
2731 errorCheck a2'>>
2732 return (res')
2733
2734
2735
2736 -- |calibrated @rho@, see 'zabrInterpolatedAlpha'
2737 zabrInterpolatedRho :: (ZabrInterpolatedSmileSection) -> IO ((Double))
2738 zabrInterpolatedRho a1 =
2739 withZabrInterpolatedSmileSection a1 $ \a1' ->
2740 preErrorCheck $ \a2' ->
2741 zabrInterpolatedRho'_ a1' a2' >>= \res ->
2742 let {res' = realToFrac res} in
2743 errorCheck a2'>>
2744 return (res')
2745
2746
2747
2748 -- |calibrated @gamma@, see 'zabrInterpolatedAlpha'
2749 zabrInterpolatedGamma :: (ZabrInterpolatedSmileSection) -> IO ((Double))
2750 zabrInterpolatedGamma a1 =
2751 withZabrInterpolatedSmileSection a1 $ \a1' ->
2752 preErrorCheck $ \a2' ->
2753 zabrInterpolatedGamma'_ a1' a2' >>= \res ->
2754 let {res' = realToFrac res} in
2755 errorCheck a2'>>
2756 return (res')
2757
2758
2759
2760 -- |root-mean-square calibration error
2761 zabrInterpolatedRmsError :: (ZabrInterpolatedSmileSection) -> IO ((Double))
2762 zabrInterpolatedRmsError a1 =
2763 withZabrInterpolatedSmileSection a1 $ \a1' ->
2764 preErrorCheck $ \a2' ->
2765 zabrInterpolatedRmsError'_ a1' a2' >>= \res ->
2766 let {res' = realToFrac res} in
2767 errorCheck a2'>>
2768 return (res')
2769
2770
2771
2772 -- |maximum calibration error
2773 zabrInterpolatedMaxError :: (ZabrInterpolatedSmileSection) -> IO ((Double))
2774 zabrInterpolatedMaxError a1 =
2775 withZabrInterpolatedSmileSection a1 $ \a1' ->
2776 preErrorCheck $ \a2' ->
2777 zabrInterpolatedMaxError'_ a1' a2' >>= \res ->
2778 let {res' = realToFrac res} in
2779 errorCheck a2'>>
2780 return (res')
2781
2782
2783
2784 -- |the reason the calibration's optimizer stopped
2785 zabrInterpolatedEndCriteria :: (ZabrInterpolatedSmileSection) -> IO ((EndCriteriaType))
2786 zabrInterpolatedEndCriteria a1 =
2787 withZabrInterpolatedSmileSection a1 $ \a1' ->
2788 preErrorCheck $ \a2' ->
2789 zabrInterpolatedEndCriteria'_ a1' a2' >>= \res ->
2790 let {res' = (toEnum . fromIntegral) res} in
2791 errorCheck a2'>>
2792 return (res')
2793
2794
2795
2796 -- |implements the conversion between swap dates and swap (time) length
2797 swapLengthBetweenDates :: (GenSwaptionVolatilityStructure sv) -> (Day) -- ^start
2798 -> (Day) -- ^end
2799 -> IO ((Double))
2800 swapLengthBetweenDates a1 a2 a3 =
2801 withSwaptionVolatilityStructure a1 $ \a1' ->
2802 withDay a2 $ \a2' ->
2803 withDay a3 $ \a3' ->
2804 preErrorCheck $ \a4' ->
2805 swapLengthBetweenDates'_ a1' a2' a3' a4' >>= \res ->
2806 let {res' = realToFrac res} in
2807 errorCheck a4'>>
2808 return (res')
2809
2810
2811
2812 -- |implements the conversion between swap tenor and swap (time) length
2813 swapLength :: (GenSwaptionVolatilityStructure sv) -> ((Word,TimeUnit)) -> IO ((Double))
2814 swapLength a1 a2 =
2815 withSwaptionVolatilityStructure a1 $ \a1' ->
2816 let {(a2'1, a2'2) = fromEnumQuantity a2} in
2817 preErrorCheck $ \a3' ->
2818 swapLength'_ a1' a2'1 a2'2 a3' >>= \res ->
2819 let {res' = realToFrac res} in
2820 errorCheck a3'>>
2821 return (res')
2822
2823
2824
2825 -- |returns the volatility for a given option date and swap tenor
2826 volatilityDateTenor :: (GenSwaptionVolatilityStructure sv) -> (Day) -- ^optionDate
2827 -> ((Word,TimeUnit)) -- ^swapTenor
2828 -> (Double) -- ^strike
2829 -> (Bool) -- ^extrapolate
2830 -> IO ((Double))
2831 volatilityDateTenor a1 a2 a3 a4 a5 =
2832 withSwaptionVolatilityStructure a1 $ \a1' ->
2833 withDay a2 $ \a2' ->
2834 let {(a3'1, a3'2) = fromEnumQuantity a3} in
2835 let {a4' = realToFrac a4} in
2836 let {a5' = C2HSImp.fromBool a5} in
2837 preErrorCheck $ \a6' ->
2838 volatilityDateTenor'_ a1' a2' a3'1 a3'2 a4' a5' a6' >>= \res ->
2839 let {res' = realToFrac res} in
2840 errorCheck a6'>>
2841 return (res')
2842
2843
2844
2845 -- |returns the volatility for a given option time and swap tenor
2846 volatilityTimeTenor :: (GenSwaptionVolatilityStructure sv) -> (Double) -- ^optionTime
2847 -> ((Word,TimeUnit)) -- ^swapTenor
2848 -> (Double) -- ^strike
2849 -> (Bool) -- ^extrapolate
2850 -> IO ((Double))
2851 volatilityTimeTenor a1 a2 a3 a4 a5 =
2852 withSwaptionVolatilityStructure a1 $ \a1' ->
2853 let {a2' = realToFrac a2} in
2854 let {(a3'1, a3'2) = fromEnumQuantity a3} in
2855 let {a4' = realToFrac a4} in
2856 let {a5' = C2HSImp.fromBool a5} in
2857 preErrorCheck $ \a6' ->
2858 volatilityTimeTenor'_ a1' a2' a3'1 a3'2 a4' a5' a6' >>= \res ->
2859 let {res' = realToFrac res} in
2860 errorCheck a6'>>
2861 return (res')
2862
2863
2864
2865 -- |returns the volatility for a given option tenor and swap length
2866 volatilityTenorLength :: (GenSwaptionVolatilityStructure sv) -> ((Word,TimeUnit)) -- ^optionTenor
2867 -> (Double) -- ^swapLength
2868 -> (Double) -- ^strike
2869 -> (Bool) -- ^extrapolate
2870 -> IO ((Double))
2871 volatilityTenorLength a1 a2 a3 a4 a5 =
2872 withSwaptionVolatilityStructure a1 $ \a1' ->
2873 let {(a2'1, a2'2) = fromEnumQuantity a2} in
2874 let {a3' = realToFrac a3} in
2875 let {a4' = realToFrac a4} in
2876 let {a5' = C2HSImp.fromBool a5} in
2877 preErrorCheck $ \a6' ->
2878 volatilityTenorLength'_ a1' a2'1 a2'2 a3' a4' a5' a6' >>= \res ->
2879 let {res' = realToFrac res} in
2880 errorCheck a6'>>
2881 return (res')
2882
2883
2884
2885 -- |returns the volatility for a given option date and swap length
2886 volatilityDateLength :: (GenSwaptionVolatilityStructure sv) -> (Day) -- ^optionDate
2887 -> (Double) -- ^swapLength
2888 -> (Double) -- ^strike
2889 -> (Bool) -- ^extrapolate
2890 -> IO ((Double))
2891 volatilityDateLength a1 a2 a3 a4 a5 =
2892 withSwaptionVolatilityStructure a1 $ \a1' ->
2893 withDay a2 $ \a2' ->
2894 let {a3' = realToFrac a3} in
2895 let {a4' = realToFrac a4} in
2896 let {a5' = C2HSImp.fromBool a5} in
2897 preErrorCheck $ \a6' ->
2898 volatilityDateLength'_ a1' a2' a3' a4' a5' a6' >>= \res ->
2899 let {res' = realToFrac res} in
2900 errorCheck a6'>>
2901 return (res')
2902
2903
2904
2905 -- |returns the volatility for a given option time and swap length
2906 volatilityTimeLength :: (GenSwaptionVolatilityStructure sv) -> (Double) -- ^optionTime
2907 -> (Double) -- ^swapLength
2908 -> (Double) -- ^strike
2909 -> (Bool) -- ^extrapolate
2910 -> IO ((Double))
2911 volatilityTimeLength a1 a2 a3 a4 a5 =
2912 withSwaptionVolatilityStructure a1 $ \a1' ->
2913 let {a2' = realToFrac a2} in
2914 let {a3' = realToFrac a3} in
2915 let {a4' = realToFrac a4} in
2916 let {a5' = C2HSImp.fromBool a5} in
2917 preErrorCheck $ \a6' ->
2918 volatilityTimeLength'_ a1' a2' a3' a4' a5' a6' >>= \res ->
2919 let {res' = realToFrac res} in
2920 errorCheck a6'>>
2921 return (res')
2922
2923
2924
2925 -- |returns the volatility for a given option tenor and swap tenor
2926 volatilityTenorTenor :: (GenSwaptionVolatilityStructure sv) -> ((Word,TimeUnit)) -- ^optionTenor
2927 -> ((Word,TimeUnit)) -- ^swapTenor
2928 -> (Double) -- ^strike
2929 -> (Bool) -- ^extrapolate
2930 -> IO ((Double))
2931 volatilityTenorTenor a1 a2 a3 a4 a5 =
2932 withSwaptionVolatilityStructure a1 $ \a1' ->
2933 let {(a2'1, a2'2) = fromEnumQuantity a2} in
2934 let {(a3'1, a3'2) = fromEnumQuantity a3} in
2935 let {a4' = realToFrac a4} in
2936 let {a5' = C2HSImp.fromBool a5} in
2937 preErrorCheck $ \a6' ->
2938 volatilityTenorTenor'_ a1' a2'1 a2'2 a3'1 a3'2 a4' a5' a6' >>= \res ->
2939 let {res' = realToFrac res} in
2940 errorCheck a6'>>
2941 return (res')
2942
2943
2944
2945 -- |Returns the volatility for any option-maturity and swap-maturity representation.
2946 swaptionVolatility :: GenSwaptionVolatilityStructure sv -> OptionMaturity -> SwapMaturity -> Double -> Bool -> IO Double
2947 swaptionVolatility sv optionMaturity swapMaturity =
2948 case (optionMaturity, swapMaturity) of
2949 (OptionDate d, SwapTenor t) -> volatilityDateTenor sv d t
2950 (OptionTime t, SwapTenor p) -> volatilityTimeTenor sv t p
2951 (OptionTenor p, SwapLength l) -> volatilityTenorLength sv p l
2952 (OptionDate d, SwapLength l) -> volatilityDateLength sv d l
2953 (OptionTime t, SwapLength l) -> volatilityTimeLength sv t l
2954 (OptionTenor o, SwapTenor s) -> volatilityTenorTenor sv o s
2955
2956 -- |A constant callable-bond volatility with either a fixed or evaluation-date-relative
2957 -- reference point.
2958 callableBondConstantVolatility :: Reference -> GenQuote q -> DayCounter -> IO CallableBondVolatilityStructure
2959 callableBondConstantVolatility reference = case reference of
2960 ReferenceDate d -> callableBondConstantVolatilityFixed d
2961 SettlementDays n cal -> callableBondConstantVolatilityMovingRaw n cal
2962 callableBondConstantVolatilityMovingRaw :: (Word) -> (Calendar) -> (GenQuote q) -> (DayCounter) -> IO ((CallableBondVolatilityStructure))
2963 callableBondConstantVolatilityMovingRaw a1 a2 a3 a4 =
2964 let {a1' = fromIntegral a1} in
2965 withCalendar a2 $ \a2' ->
2966 withQuote a3 $ \a3' ->
2967 withDayCounter a4 $ \a4' ->
2968 preErrorCheck $ \a5' ->
2969 callableBondConstantVolatilityMovingRaw'_ a1' a2' a3' a4' a5' >>= \res ->
2970 peekCallableBondVolatilityStructure res >>= \res' ->
2971 errorCheck a5'>>
2972 return (res')
2973
2974
2975 callableBondConstantVolatilityFixed :: (Day) -> (GenQuote q) -> (DayCounter) -> IO ((CallableBondVolatilityStructure))
2976 callableBondConstantVolatilityFixed a1 a2 a3 =
2977 withDay a1 $ \a1' ->
2978 withQuote a2 $ \a2' ->
2979 withDayCounter a3 $ \a3' ->
2980 preErrorCheck $ \a4' ->
2981 callableBondConstantVolatilityFixed'_ a1' a2' a3' a4' >>= \res ->
2982 peekCallableBondVolatilityStructure res >>= \res' ->
2983 errorCheck a4'>>
2984 return (res')
2985
2986
2987
2988 -- |The volatility for a given option time and bond length.
2989 qlCallableBondVolatilityStructureVolatilityForTime :: (CallableBondVolatilityStructure) -> (Double) -- ^optionTime
2990 -> (Double) -- ^bondLength
2991 -> (Double) -- ^strike
2992 -> (Bool) -- ^extrapolate
2993 -> IO ((Double))
2994 qlCallableBondVolatilityStructureVolatilityForTime a1 a2 a3 a4 a5 =
2995 withGenTermStructure a1 $ \a1' ->
2996 let {a2' = realToFrac a2} in
2997 let {a3' = realToFrac a3} in
2998 let {a4' = realToFrac a4} in
2999 let {a5' = C2HSImp.fromBool a5} in
3000 preErrorCheck $ \a6' ->
3001 qlCallableBondVolatilityStructureVolatilityForTime'_ a1' a2' a3' a4' a5' a6' >>= \res ->
3002 let {res' = realToFrac res} in
3003 errorCheck a6'>>
3004 return (res')
3005
3006
3007
3008 -- |The volatility for a given option date and bond tenor.
3009 qlCallableBondVolatilityStructureVolatilityForDate :: (CallableBondVolatilityStructure) -> (Day) -- ^optionDate
3010 -> ((Word,TimeUnit)) -- ^bondTenor
3011 -> (Double) -- ^strike
3012 -> (Bool) -- ^extrapolate
3013 -> IO ((Double))
3014 qlCallableBondVolatilityStructureVolatilityForDate a1 a2 a3 a4 a5 =
3015 withGenTermStructure a1 $ \a1' ->
3016 withDay a2 $ \a2' ->
3017 let {(a3'1, a3'2) = fromEnumQuantity a3} in
3018 let {a4' = realToFrac a4} in
3019 let {a5' = C2HSImp.fromBool a5} in
3020 preErrorCheck $ \a6' ->
3021 qlCallableBondVolatilityStructureVolatilityForDate'_ a1' a2' a3'1 a3'2 a4' a5' a6' >>= \res ->
3022 let {res' = realToFrac res} in
3023 errorCheck a6'>>
3024 return (res')
3025
3026
3027
3028 -- |The volatility for a given option tenor and bond tenor.
3029 qlCallableBondVolatilityStructureVolatilityForPeriod :: (CallableBondVolatilityStructure) -> ((Word,TimeUnit)) -- ^optionTenor
3030 -> ((Word,TimeUnit)) -- ^bondTenor
3031 -> (Double) -- ^strike
3032 -> (Bool) -- ^extrapolate
3033 -> IO ((Double))
3034 qlCallableBondVolatilityStructureVolatilityForPeriod a1 a2 a3 a4 a5 =
3035 withGenTermStructure a1 $ \a1' ->
3036 let {(a2'1, a2'2) = fromEnumQuantity a2} in
3037 let {(a3'1, a3'2) = fromEnumQuantity a3} in
3038 let {a4' = realToFrac a4} in
3039 let {a5' = C2HSImp.fromBool a5} in
3040 preErrorCheck $ \a6' ->
3041 qlCallableBondVolatilityStructureVolatilityForPeriod'_ a1' a2'1 a2'2 a3'1 a3'2 a4' a5' a6' >>= \res ->
3042 let {res' = realToFrac res} in
3043 errorCheck a6'>>
3044 return (res')
3045
3046
3047
3048 -- |The Black variance for a given option time and bond length.
3049 qlCallableBondVolatilityStructureBlackVarianceForTime :: (CallableBondVolatilityStructure) -> (Double) -- ^optionTime
3050 -> (Double) -- ^bondLength
3051 -> (Double) -- ^strike
3052 -> (Bool) -- ^extrapolate
3053 -> IO ((Double))
3054 qlCallableBondVolatilityStructureBlackVarianceForTime a1 a2 a3 a4 a5 =
3055 withGenTermStructure a1 $ \a1' ->
3056 let {a2' = realToFrac a2} in
3057 let {a3' = realToFrac a3} in
3058 let {a4' = realToFrac a4} in
3059 let {a5' = C2HSImp.fromBool a5} in
3060 preErrorCheck $ \a6' ->
3061 qlCallableBondVolatilityStructureBlackVarianceForTime'_ a1' a2' a3' a4' a5' a6' >>= \res ->
3062 let {res' = realToFrac res} in
3063 errorCheck a6'>>
3064 return (res')
3065
3066
3067
3068 -- |The Black variance for a given option date and bond tenor.
3069 qlCallableBondVolatilityStructureBlackVarianceForDate :: (CallableBondVolatilityStructure) -> (Day) -- ^optionDate
3070 -> ((Word,TimeUnit)) -- ^bondTenor
3071 -> (Double) -- ^strike
3072 -> (Bool) -- ^extrapolate
3073 -> IO ((Double))
3074 qlCallableBondVolatilityStructureBlackVarianceForDate a1 a2 a3 a4 a5 =
3075 withGenTermStructure a1 $ \a1' ->
3076 withDay a2 $ \a2' ->
3077 let {(a3'1, a3'2) = fromEnumQuantity a3} in
3078 let {a4' = realToFrac a4} in
3079 let {a5' = C2HSImp.fromBool a5} in
3080 preErrorCheck $ \a6' ->
3081 qlCallableBondVolatilityStructureBlackVarianceForDate'_ a1' a2' a3'1 a3'2 a4' a5' a6' >>= \res ->
3082 let {res' = realToFrac res} in
3083 errorCheck a6'>>
3084 return (res')
3085
3086
3087
3088 -- |The Black variance for a given option tenor and bond tenor.
3089 qlCallableBondVolatilityStructureBlackVarianceForPeriod :: (CallableBondVolatilityStructure) -> ((Word,TimeUnit)) -- ^optionTenor
3090 -> ((Word,TimeUnit)) -- ^bondTenor
3091 -> (Double) -- ^strike
3092 -> (Bool) -- ^extrapolate
3093 -> IO ((Double))
3094 qlCallableBondVolatilityStructureBlackVarianceForPeriod a1 a2 a3 a4 a5 =
3095 withGenTermStructure a1 $ \a1' ->
3096 let {(a2'1, a2'2) = fromEnumQuantity a2} in
3097 let {(a3'1, a3'2) = fromEnumQuantity a3} in
3098 let {a4' = realToFrac a4} in
3099 let {a5' = C2HSImp.fromBool a5} in
3100 preErrorCheck $ \a6' ->
3101 qlCallableBondVolatilityStructureBlackVarianceForPeriod'_ a1' a2'1 a2'2 a3'1 a3'2 a4' a5' a6' >>= \res ->
3102 let {res' = realToFrac res} in
3103 errorCheck a6'>>
3104 return (res')
3105
3106
3107
3108 -- |Callable-bond volatility for a supported option and bond maturity pair.
3109 callableBondVolatility :: CallableBondVolatilityStructure -> CallableBondMaturity -> Double -> Bool -> IO Double
3110 callableBondVolatility structure maturity = case maturity of
3111 CallableBondTimeLength optionTime bondLength ->
3112 qlCallableBondVolatilityStructureVolatilityForTime structure optionTime bondLength
3113 CallableBondDateTenor optionDate bondTenor ->
3114 qlCallableBondVolatilityStructureVolatilityForDate structure optionDate bondTenor
3115 CallableBondTenorTenor optionTenor bondTenor ->
3116 qlCallableBondVolatilityStructureVolatilityForPeriod structure optionTenor bondTenor
3117
3118 -- |Callable-bond Black variance for a supported option and bond maturity pair.
3119 callableBondBlackVariance :: CallableBondVolatilityStructure -> CallableBondMaturity -> Double -> Bool -> IO Double
3120 callableBondBlackVariance structure maturity = case maturity of
3121 CallableBondTimeLength optionTime bondLength ->
3122 qlCallableBondVolatilityStructureBlackVarianceForTime structure optionTime bondLength
3123 CallableBondDateTenor optionDate bondTenor ->
3124 qlCallableBondVolatilityStructureBlackVarianceForDate structure optionDate bondTenor
3125 CallableBondTenorTenor optionTenor bondTenor ->
3126 qlCallableBondVolatilityStructureBlackVarianceForPeriod structure optionTenor bondTenor
3127
3128 -- |The smile section for a given option date and bond tenor.
3129 callableBondSmileSectionAtDateRaw :: (CallableBondVolatilityStructure) -> (Day) -- ^optionDate
3130 -> ((Word,TimeUnit)) -- ^bondTenor
3131 -> IO ((SmileSection))
3132 callableBondSmileSectionAtDateRaw a1 a2 a3 =
3133 withGenTermStructure a1 $ \a1' ->
3134 withDay a2 $ \a2' ->
3135 let {(a3'1, a3'2) = fromEnumQuantity a3} in
3136 preErrorCheck $ \a4' ->
3137 callableBondSmileSectionAtDateRaw'_ a1' a2' a3'1 a3'2 a4' >>= \res ->
3138 peekSmileSection res >>= \res' ->
3139 errorCheck a4'>>
3140 return (res')
3141
3142
3143
3144 -- |The smile section for a given option tenor and bond tenor.
3145 callableBondSmileSectionForTenorsRaw :: (CallableBondVolatilityStructure) -> ((Word,TimeUnit)) -- ^optionTenor
3146 -> ((Word,TimeUnit)) -- ^bondTenor
3147 -> IO ((SmileSection))
3148 callableBondSmileSectionForTenorsRaw a1 a2 a3 =
3149 withGenTermStructure a1 $ \a1' ->
3150 let {(a2'1, a2'2) = fromEnumQuantity a2} in
3151 let {(a3'1, a3'2) = fromEnumQuantity a3} in
3152 preErrorCheck $ \a4' ->
3153 callableBondSmileSectionForTenorsRaw'_ a1' a2'1 a2'2 a3'1 a3'2 a4' >>= \res ->
3154 peekSmileSection res >>= \res' ->
3155 errorCheck a4'>>
3156 return (res')
3157
3158
3159
3160 -- |Callable-bond smile section for a supported option and bond maturity pair.
3161 callableBondSmileSection :: CallableBondVolatilityStructure -> CallableBondSmileMaturity -> IO SmileSection
3162 callableBondSmileSection structure maturity = case maturity of
3163 CallableBondSmileDateTenor optionDate bondTenor ->
3164 callableBondSmileSectionAtDateRaw structure optionDate bondTenor
3165 CallableBondSmileTenorTenor optionTenor bondTenor ->
3166 callableBondSmileSectionForTenorsRaw structure optionTenor bondTenor
3167
3168 -- |The largest bond tenor for which the structure can return vols.
3169 maxBondTenor :: (CallableBondVolatilityStructure) -> IO ((Int), (TimeUnit))
3170 maxBondTenor a1 =
3171 withGenTermStructure a1 $ \a1' ->
3172 preEnum $ \a2' ->
3173 preErrorCheck $ \a3' ->
3174 maxBondTenor'_ a1' a2' a3' >>= \res ->
3175 let {res' = fromIntegral res} in
3176 peekEnum a2'>>= \a2'' ->
3177 errorCheck a3'>>
3178 return (res', a2'')
3179
3180
3181
3182 minStrikeCallableBondRaw :: (CallableBondVolatilityStructure) -> IO ((Double))
3183 minStrikeCallableBondRaw a1 =
3184 withGenTermStructure a1 $ \a1' ->
3185 preErrorCheck $ \a2' ->
3186 minStrikeCallableBondRaw'_ a1' a2' >>= \res ->
3187 let {res' = realToFrac res} in
3188 errorCheck a2'>>
3189 return (res')
3190
3191
3192 maxStrikeCallableBondRaw :: (CallableBondVolatilityStructure) -> IO ((Double))
3193 maxStrikeCallableBondRaw a1 =
3194 withGenTermStructure a1 $ \a1' ->
3195 preErrorCheck $ \a2' ->
3196 maxStrikeCallableBondRaw'_ a1' a2' >>= \res ->
3197 let {res' = realToFrac res} in
3198 errorCheck a2'>>
3199 return (res')
3200
3201
3202
3203 minStrikeGenericRaw :: (GenVolatilityTermStructure v) -> IO ((Double))
3204 minStrikeGenericRaw a1 =
3205 withVolatilityTermStructure a1 $ \a1' ->
3206 preErrorCheck $ \a2' ->
3207 minStrikeGenericRaw'_ a1' a2' >>= \res ->
3208 let {res' = realToFrac res} in
3209 errorCheck a2'>>
3210 return (res')
3211
3212
3213 maxStrikeGenericRaw :: (GenVolatilityTermStructure v) -> IO ((Double))
3214 maxStrikeGenericRaw a1 =
3215 withVolatilityTermStructure a1 $ \a1' ->
3216 preErrorCheck $ \a2' ->
3217 maxStrikeGenericRaw'_ a1' a2' >>= \res ->
3218 let {res' = realToFrac res} in
3219 errorCheck a2'>>
3220 return (res')
3221
3222
3223
3224 -- |Converts an option tenor to its option date, for any 'GenVolatilityTermStructure' (however it
3225 -- was constructed).
3226 optionDateFromTenor :: (GenVolatilityTermStructure v) -> ((Word,TimeUnit)) -- ^optionTenor
3227 -> IO ((Day))
3228 optionDateFromTenor a1 a2 =
3229 withVolatilityTermStructure a1 $ \a1' ->
3230 let {(a2'1, a2'2) = fromEnumQuantity a2} in
3231 preErrorCheck $ \a3' ->
3232 optionDateFromTenor'_ a1' a2'1 a2'2 a3' >>= \res ->
3233 let {res' = toDay res} in
3234 errorCheck a3'>>
3235 return (res')
3236
3237
3238
3239 -- |The minimum and maximum strike for which a structure can return vols. 'CallableBondVolatilityStructure'
3240 -- and 'SmileSection' each declare their own unrelated pair (neither inherits 'VolatilityTermStructure'),
3241 -- so all three families need separate instances.
3242 class HasStrikeBounds structure where
3243 minStrike :: structure -> IO Double
3244 maxStrike :: structure -> IO Double
3245
3246 instance HasStrikeBounds CallableBondVolatilityStructure where
3247 minStrike = minStrikeCallableBondRaw
3248 maxStrike = maxStrikeCallableBondRaw
3249
3250 instance HasStrikeBounds SmileSection where
3251 minStrike = minStrikeSmileSectionRaw
3252 maxStrike = maxStrikeSmileSectionRaw
3253
3254 instance HasStrikeBounds (GenVolatilityTermStructure v) where
3255 minStrike = minStrikeGenericRaw
3256 maxStrike = maxStrikeGenericRaw
3257
3258 -- |Constant cap/floor term volatility with either a fixed or evaluation-date-relative reference
3259 -- point.
3260 constantCapFloorTermVolatility :: CalendarReference -> Calendar -> BusinessDayConvention
3261 -> GenQuote q -> DayCounter -> IO CapFloorTermVolatilityStructure
3262 constantCapFloorTermVolatility reference cal = case reference of
3263 CalendarReferenceDate d -> constantCapFloorTermVolatilityFixed d cal
3264 CalendarSettlementDays n -> constantCapFloorTermVolatilityMovingRaw n cal
3265 constantCapFloorTermVolatilityFixed :: (Day) -> (Calendar) -> (BusinessDayConvention) -> (GenQuote q) -> (DayCounter) -> IO ((CapFloorTermVolatilityStructure))
3266 constantCapFloorTermVolatilityFixed a1 a2 a3 a4 a5 =
3267 withDay a1 $ \a1' ->
3268 withCalendar a2 $ \a2' ->
3269 let {a3' = fromEnumC a3} in
3270 withQuote a4 $ \a4' ->
3271 withDayCounter a5 $ \a5' ->
3272 preErrorCheck $ \a6' ->
3273 constantCapFloorTermVolatilityFixed'_ a1' a2' a3' a4' a5' a6' >>= \res ->
3274 peekCapFloorTermVolatilityStructure res >>= \res' ->
3275 errorCheck a6'>>
3276 return (res')
3277
3278
3279 constantCapFloorTermVolatilityMovingRaw :: (Word) -> (Calendar) -> (BusinessDayConvention) -> (GenQuote q) -> (DayCounter) -> IO ((CapFloorTermVolatilityStructure))
3280 constantCapFloorTermVolatilityMovingRaw a1 a2 a3 a4 a5 =
3281 let {a1' = fromIntegral a1} in
3282 withCalendar a2 $ \a2' ->
3283 let {a3' = fromEnumC a3} in
3284 withQuote a4 $ \a4' ->
3285 withDayCounter a5 $ \a5' ->
3286 preErrorCheck $ \a6' ->
3287 constantCapFloorTermVolatilityMovingRaw'_ a1' a2' a3' a4' a5' a6' >>= \res ->
3288 peekCapFloorTermVolatilityStructure res >>= \res' ->
3289 errorCheck a6'>>
3290 return (res')
3291
3292
3293
3294 -- |Returns cap/floor volatility for any supported option-maturity representation.
3295 capFloorVolatility :: GenCapFloorTermVolatilityStructure c -> OptionMaturity -> Double -> Bool -> IO Double
3296 capFloorVolatility structure maturity = case maturity of
3297 OptionTenor p -> capFloorVolatilityForTenorRaw structure p
3298 OptionDate d -> capFloorVolatilityAtDateRaw structure d
3299 OptionTime t -> capFloorVolatilityAtTimeRaw structure t
3300
3301 capFloorVolatilityForTenorRaw :: (GenCapFloorTermVolatilityStructure c) -> ((Word,TimeUnit)) -- ^optionTenor
3302 -> (Double) -- ^strike
3303 -> (Bool) -- ^extrapolate
3304 -> IO ((Double))
3305 capFloorVolatilityForTenorRaw a1 a2 a3 a4 =
3306 withGenCapFloorTermVolatilityStructure a1 $ \a1' ->
3307 let {(a2'1, a2'2) = fromEnumQuantity a2} in
3308 let {a3' = realToFrac a3} in
3309 let {a4' = C2HSImp.fromBool a4} in
3310 preErrorCheck $ \a5' ->
3311 capFloorVolatilityForTenorRaw'_ a1' a2'1 a2'2 a3' a4' a5' >>= \res ->
3312 let {res' = realToFrac res} in
3313 errorCheck a5'>>
3314 return (res')
3315
3316
3317
3318 -- |returns the volatility for a given option date and strike
3319 capFloorVolatilityAtDateRaw :: (GenCapFloorTermVolatilityStructure c) -> (Day) -- ^optionDate
3320 -> (Double) -- ^strike
3321 -> (Bool) -- ^extrapolate
3322 -> IO ((Double))
3323 capFloorVolatilityAtDateRaw a1 a2 a3 a4 =
3324 withGenCapFloorTermVolatilityStructure a1 $ \a1' ->
3325 withDay a2 $ \a2' ->
3326 let {a3' = realToFrac a3} in
3327 let {a4' = C2HSImp.fromBool a4} in
3328 preErrorCheck $ \a5' ->
3329 capFloorVolatilityAtDateRaw'_ a1' a2' a3' a4' a5' >>= \res ->
3330 let {res' = realToFrac res} in
3331 errorCheck a5'>>
3332 return (res')
3333
3334
3335
3336 -- |returns the volatility for a given option time and strike
3337 capFloorVolatilityAtTimeRaw :: (GenCapFloorTermVolatilityStructure c) -> (Double) -- ^optionTime
3338 -> (Double) -- ^strike
3339 -> (Bool) -- ^extrapolate
3340 -> IO ((Double))
3341 capFloorVolatilityAtTimeRaw a1 a2 a3 a4 =
3342 withGenCapFloorTermVolatilityStructure a1 $ \a1' ->
3343 let {a2' = realToFrac a2} in
3344 let {a3' = realToFrac a3} in
3345 let {a4' = C2HSImp.fromBool a4} in
3346 preErrorCheck $ \a5' ->
3347 capFloorVolatilityAtTimeRaw'_ a1' a2' a3' a4' a5' >>= \res ->
3348 let {res' = realToFrac res} in
3349 errorCheck a5'>>
3350 return (res')
3351
3352
3353
3354 -- |The option-tenor grid's dates, calendar-advanced from the curve's reference date.
3355 capFloorTermVolCurveOptionDates :: (CapFloorTermVolCurve) -> IO (([Day]))
3356 capFloorTermVolCurveOptionDates a1 =
3357 withCapFloorTermVolCurve a1 $ \a1' ->
3358 preIntArray $ \(a2'1, a2'2) ->
3359 preErrorCheck $ \a3' ->
3360 capFloorTermVolCurveOptionDates'_ a1' a2'1 a2'2 a3' >>
3361 peekDayArray a2'1 a2'2>>= \a2'' ->
3362 errorCheck a3'>>
3363 return (a2'')
3364
3365
3366
3367 -- |As 'capFloorTermVolCurveOptionDates', in year fractions from the curve's reference date.
3368 capFloorTermVolCurveOptionTimes :: (CapFloorTermVolCurve) -> IO (([Double]))
3369 capFloorTermVolCurveOptionTimes a1 =
3370 withCapFloorTermVolCurve a1 $ \a1' ->
3371 preDoubleArray $ \(a2'1, a2'2) ->
3372 preErrorCheck $ \a3' ->
3373 capFloorTermVolCurveOptionTimes'_ a1' a2'1 a2'2 a3' >>
3374 peekDoubleArray a2'1 a2'2>>= \a2'' ->
3375 errorCheck a3'>>
3376 return (a2'')
3377
3378
3379
3380 -- |The option-tenor grid's dates, calendar-advanced from the surface's reference date.
3381 capFloorTermVolSurfaceOptionDates :: (CapFloorTermVolSurface) -> IO (([Day]))
3382 capFloorTermVolSurfaceOptionDates a1 =
3383 withCapFloorTermVolSurface a1 $ \a1' ->
3384 preIntArray $ \(a2'1, a2'2) ->
3385 preErrorCheck $ \a3' ->
3386 capFloorTermVolSurfaceOptionDates'_ a1' a2'1 a2'2 a3' >>
3387 peekDayArray a2'1 a2'2>>= \a2'' ->
3388 errorCheck a3'>>
3389 return (a2'')
3390
3391
3392
3393 -- |As 'capFloorTermVolSurfaceOptionDates', in year fractions from the surface's reference date.
3394 capFloorTermVolSurfaceOptionTimes :: (CapFloorTermVolSurface) -> IO (([Double]))
3395 capFloorTermVolSurfaceOptionTimes a1 =
3396 withCapFloorTermVolSurface a1 $ \a1' ->
3397 preDoubleArray $ \(a2'1, a2'2) ->
3398 preErrorCheck $ \a3' ->
3399 capFloorTermVolSurfaceOptionTimes'_ a1' a2'1 a2'2 a3' >>
3400 peekDoubleArray a2'1 a2'2>>= \a2'' ->
3401 errorCheck a3'>>
3402 return (a2'')
3403
3404
3405
3406 -- |Spot at-the-money volatility for any supported option-maturity representation.
3407 atmVol :: GenBlackAtmVolCurve b -> OptionMaturity -> Bool -> IO Double
3408 atmVol curve maturity = case maturity of
3409 OptionTenor p -> atmVolForTenorRaw curve p
3410 OptionDate d -> atmVolAtDateRaw curve d
3411 OptionTime t -> atmVolAtTimeRaw curve t
3412
3413 atmVolForTenorRaw :: (GenBlackAtmVolCurve b) -> ((Word,TimeUnit)) -- ^optionTenor
3414 -> (Bool) -- ^extrapolate
3415 -> IO ((Double))
3416 atmVolForTenorRaw a1 a2 a3 =
3417 withGenBlackAtmVolCurve a1 $ \a1' ->
3418 let {(a2'1, a2'2) = fromEnumQuantity a2} in
3419 let {a3' = C2HSImp.fromBool a3} in
3420 preErrorCheck $ \a4' ->
3421 atmVolForTenorRaw'_ a1' a2'1 a2'2 a3' a4' >>= \res ->
3422 let {res' = realToFrac res} in
3423 errorCheck a4'>>
3424 return (res')
3425
3426
3427
3428 -- |spot at-the-money volatility for a given option maturity date
3429 atmVolAtDateRaw :: (GenBlackAtmVolCurve b) -> (Day) -- ^maturity
3430 -> (Bool) -- ^extrapolate
3431 -> IO ((Double))
3432 atmVolAtDateRaw a1 a2 a3 =
3433 withGenBlackAtmVolCurve a1 $ \a1' ->
3434 withDay a2 $ \a2' ->
3435 let {a3' = C2HSImp.fromBool a3} in
3436 preErrorCheck $ \a4' ->
3437 atmVolAtDateRaw'_ a1' a2' a3' a4' >>= \res ->
3438 let {res' = realToFrac res} in
3439 errorCheck a4'>>
3440 return (res')
3441
3442
3443
3444 -- |spot at-the-money volatility for a given option maturity time
3445 atmVolAtTimeRaw :: (GenBlackAtmVolCurve b) -> (Double) -- ^maturity
3446 -> (Bool) -- ^extrapolate
3447 -> IO ((Double))
3448 atmVolAtTimeRaw a1 a2 a3 =
3449 withGenBlackAtmVolCurve a1 $ \a1' ->
3450 let {a2' = realToFrac a2} in
3451 let {a3' = C2HSImp.fromBool a3} in
3452 preErrorCheck $ \a4' ->
3453 atmVolAtTimeRaw'_ a1' a2' a3' a4' >>= \res ->
3454 let {res' = realToFrac res} in
3455 errorCheck a4'>>
3456 return (res')
3457
3458
3459
3460 -- |Spot at-the-money variance for any supported option-maturity representation.
3461 atmVariance :: GenBlackAtmVolCurve b -> OptionMaturity -> Bool -> IO Double
3462 atmVariance curve maturity = case maturity of
3463 OptionTenor p -> atmVarianceForTenorRaw curve p
3464 OptionDate d -> atmVarianceAtDateRaw curve d
3465 OptionTime t -> atmVarianceAtTimeRaw curve t
3466
3467 atmVarianceForTenorRaw :: (GenBlackAtmVolCurve b) -> ((Word,TimeUnit)) -- ^optionTenor
3468 -> (Bool) -- ^extrapolate
3469 -> IO ((Double))
3470 atmVarianceForTenorRaw a1 a2 a3 =
3471 withGenBlackAtmVolCurve a1 $ \a1' ->
3472 let {(a2'1, a2'2) = fromEnumQuantity a2} in
3473 let {a3' = C2HSImp.fromBool a3} in
3474 preErrorCheck $ \a4' ->
3475 atmVarianceForTenorRaw'_ a1' a2'1 a2'2 a3' a4' >>= \res ->
3476 let {res' = realToFrac res} in
3477 errorCheck a4'>>
3478 return (res')
3479
3480
3481
3482 -- |spot at-the-money variance for a given option maturity date
3483 atmVarianceAtDateRaw :: (GenBlackAtmVolCurve b) -> (Day) -- ^maturity
3484 -> (Bool) -- ^extrapolate
3485 -> IO ((Double))
3486 atmVarianceAtDateRaw a1 a2 a3 =
3487 withGenBlackAtmVolCurve a1 $ \a1' ->
3488 withDay a2 $ \a2' ->
3489 let {a3' = C2HSImp.fromBool a3} in
3490 preErrorCheck $ \a4' ->
3491 atmVarianceAtDateRaw'_ a1' a2' a3' a4' >>= \res ->
3492 let {res' = realToFrac res} in
3493 errorCheck a4'>>
3494 return (res')
3495
3496
3497
3498 -- |spot at-the-money variance for a given option maturity time
3499 atmVarianceAtTimeRaw :: (GenBlackAtmVolCurve b) -> (Double) -- ^maturity
3500 -> (Bool) -- ^extrapolate
3501 -> IO ((Double))
3502 atmVarianceAtTimeRaw a1 a2 a3 =
3503 withGenBlackAtmVolCurve a1 $ \a1' ->
3504 let {a2' = realToFrac a2} in
3505 let {a3' = C2HSImp.fromBool a3} in
3506 preErrorCheck $ \a4' ->
3507 atmVarianceAtTimeRaw'_ a1' a2' a3' a4' >>= \res ->
3508 let {res' = realToFrac res} in
3509 errorCheck a4'>>
3510 return (res')
3511
3512
3513
3514 -- |Returns a Black-volatility smile section for any supported option-maturity representation.
3515 blackVolSurfaceSmileSection :: GenBlackVolSurface b -> OptionMaturity -> Bool -> IO SmileSection
3516 blackVolSurfaceSmileSection surface maturity = case maturity of
3517 OptionTenor p -> blackVolSurfaceSmileSectionForTenorRaw surface p
3518 OptionDate d -> blackVolSurfaceSmileSectionAtDateRaw surface d
3519 OptionTime t -> blackVolSurfaceSmileSectionAtTimeRaw surface t
3520
3521 blackVolSurfaceSmileSectionForTenorRaw :: (GenBlackVolSurface b) -> ((Word,TimeUnit)) -- ^optionTenor
3522 -> (Bool) -- ^extrapolate
3523 -> IO ((SmileSection))
3524 blackVolSurfaceSmileSectionForTenorRaw a1 a2 a3 =
3525 withGenBlackVolSurface a1 $ \a1' ->
3526 let {(a2'1, a2'2) = fromEnumQuantity a2} in
3527 let {a3' = C2HSImp.fromBool a3} in
3528 preErrorCheck $ \a4' ->
3529 blackVolSurfaceSmileSectionForTenorRaw'_ a1' a2'1 a2'2 a3' a4' >>= \res ->
3530 peekSmileSection res >>= \res' ->
3531 errorCheck a4'>>
3532 return (res')
3533
3534
3535
3536 -- |returns the smile for a given option date
3537 blackVolSurfaceSmileSectionAtDateRaw :: (GenBlackVolSurface b) -> (Day) -- ^optionDate
3538 -> (Bool) -- ^extrapolate
3539 -> IO ((SmileSection))
3540 blackVolSurfaceSmileSectionAtDateRaw a1 a2 a3 =
3541 withGenBlackVolSurface a1 $ \a1' ->
3542 withDay a2 $ \a2' ->
3543 let {a3' = C2HSImp.fromBool a3} in
3544 preErrorCheck $ \a4' ->
3545 blackVolSurfaceSmileSectionAtDateRaw'_ a1' a2' a3' a4' >>= \res ->
3546 peekSmileSection res >>= \res' ->
3547 errorCheck a4'>>
3548 return (res')
3549
3550
3551
3552 -- |returns the smile for a given option time
3553 blackVolSurfaceSmileSectionAtTimeRaw :: (GenBlackVolSurface b) -> (Double) -- ^optionTime
3554 -> (Bool) -- ^extrapolate
3555 -> IO ((SmileSection))
3556 blackVolSurfaceSmileSectionAtTimeRaw a1 a2 a3 =
3557 withGenBlackVolSurface a1 $ \a1' ->
3558 let {a2' = realToFrac a2} in
3559 let {a3' = C2HSImp.fromBool a3} in
3560 preErrorCheck $ \a4' ->
3561 blackVolSurfaceSmileSectionAtTimeRaw'_ a1' a2' a3' a4' >>= \res ->
3562 peekSmileSection res >>= \res' ->
3563 errorCheck a4'>>
3564 return (res')
3565
3566
3567
3568 -- |Abcd-interpolated at-the-money (no-smile) volatility curve -- floating reference date,
3569 -- floating market data. @inclusionInInterpolationFlag@ selects which quotes feed the ABCD fit
3570 -- (upstream defaults this to all-'True' when omitted; hasquant always requires it explicitly,
3571 -- per the widen-in-place convention for a handful of trailing defaulted params).
3572 abcdAtmVolCurve :: Word -> Calendar
3573 -> NonEmpty ((Word, TimeUnit), GenQuote q, Bool) -- ^tenor, volatility, inclusion flag
3574 -> BusinessDayConvention -> DayCounter -> IO AbcdAtmVolCurve
3575 abcdAtmVolCurve d c points bdc dc = qlAbcdAtmVolCurve d c n t qs flags bdc dc
3576 where (ntenors, qs, flags) = unzip3 (toList points)
3577 (n, t) = unzip ntenors
3578 qlAbcdAtmVolCurve :: (Word) -> (Calendar) -> ([Word]) -> ([TimeUnit]) -> ([GenQuote q]) -> ([Bool]) -> (BusinessDayConvention) -> (DayCounter) -> IO ((AbcdAtmVolCurve))
3579 qlAbcdAtmVolCurve a1 a2 a3 a4 a5 a6 a7 a8 =
3580 let {a1' = fromIntegral a1} in
3581 withCalendar a2 $ \a2' ->
3582 withIntArray a3 $ \(a3'1, a3'2) ->
3583 withEnumArray a4 $ \(a4'1, a4'2) ->
3584 withQuoteArray a5 $ \(a5'1, a5'2) ->
3585 withBoolArray a6 $ \(a6'1, a6'2) ->
3586 let {a7' = fromEnumC a7} in
3587 withDayCounter a8 $ \a8' ->
3588 preErrorCheck $ \a9' ->
3589 qlAbcdAtmVolCurve'_ a1' a2' a3'1 a3'2 a4'1 a4'2 a5'1 a5'2 a6'1 a6'2 a7' a8' a9' >>= \res ->
3590 peekAbcdAtmVolCurve res >>= \res' ->
3591 errorCheck a9'>>
3592 return (res')
3593
3594
3595
3596 abcdA :: (AbcdAtmVolCurve) -> IO ((Double))
3597 abcdA a1 =
3598 withAbcdAtmVolCurve a1 $ \a1' ->
3599 preErrorCheck $ \a2' ->
3600 abcdA'_ a1' a2' >>= \res ->
3601 let {res' = realToFrac res} in
3602 errorCheck a2'>>
3603 return (res')
3604
3605
3606 abcdB :: (AbcdAtmVolCurve) -> IO ((Double))
3607 abcdB a1 =
3608 withAbcdAtmVolCurve a1 $ \a1' ->
3609 preErrorCheck $ \a2' ->
3610 abcdB'_ a1' a2' >>= \res ->
3611 let {res' = realToFrac res} in
3612 errorCheck a2'>>
3613 return (res')
3614
3615
3616 abcdC :: (AbcdAtmVolCurve) -> IO ((Double))
3617 abcdC a1 =
3618 withAbcdAtmVolCurve a1 $ \a1' ->
3619 preErrorCheck $ \a2' ->
3620 abcdC'_ a1' a2' >>= \res ->
3621 let {res' = realToFrac res} in
3622 errorCheck a2'>>
3623 return (res')
3624
3625
3626 abcdD :: (AbcdAtmVolCurve) -> IO ((Double))
3627 abcdD a1 =
3628 withAbcdAtmVolCurve a1 $ \a1' ->
3629 preErrorCheck $ \a2' ->
3630 abcdD'_ a1' a2' >>= \res ->
3631 let {res' = realToFrac res} in
3632 errorCheck a2'>>
3633 return (res')
3634
3635
3636 abcdRmsError :: (AbcdAtmVolCurve) -> IO ((Double))
3637 abcdRmsError a1 =
3638 withAbcdAtmVolCurve a1 $ \a1' ->
3639 preErrorCheck $ \a2' ->
3640 abcdRmsError'_ a1' a2' >>= \res ->
3641 let {res' = realToFrac res} in
3642 errorCheck a2'>>
3643 return (res')
3644
3645
3646 abcdMaxError :: (AbcdAtmVolCurve) -> IO ((Double))
3647 abcdMaxError a1 =
3648 withAbcdAtmVolCurve a1 $ \a1' ->
3649 preErrorCheck $ \a2' ->
3650 abcdMaxError'_ a1' a2' >>= \res ->
3651 let {res' = realToFrac res} in
3652 errorCheck a2'>>
3653 return (res')
3654
3655
3656 abcdEndCriteria :: (AbcdAtmVolCurve) -> IO ((EndCriteriaType))
3657 abcdEndCriteria a1 =
3658 withAbcdAtmVolCurve a1 $ \a1' ->
3659 preErrorCheck $ \a2' ->
3660 abcdEndCriteria'_ a1' a2' >>= \res ->
3661 let {res' = (toEnum . fromIntegral) res} in
3662 errorCheck a2'>>
3663 return (res')
3664
3665
3666
3667 -- |@k@ adjustment factor at a given time
3668 abcdK :: (AbcdAtmVolCurve) -> (Double) -> IO ((Double))
3669 abcdK a1 a2 =
3670 withAbcdAtmVolCurve a1 $ \a1' ->
3671 let {a2' = realToFrac a2} in
3672 preErrorCheck $ \a3' ->
3673 abcdK'_ a1' a2' a3' >>= \res ->
3674 let {res' = realToFrac res} in
3675 errorCheck a3'>>
3676 return (res')
3677
3678
3679
3680 -- |@k@ adjustment factors for every option tenor used in interpolation
3681 abcdKs :: (AbcdAtmVolCurve) -> IO (([Double]))
3682 abcdKs a1 =
3683 withAbcdAtmVolCurve a1 $ \a1' ->
3684 preDoubleArray $ \(a2'1, a2'2) ->
3685 preErrorCheck $ \a3' ->
3686 abcdKs'_ a1' a2'1 a2'2 a3' >>
3687 peekDoubleArray a2'1 a2'2>>= \a2'' ->
3688 errorCheck a3'>>
3689 return (a2'')
3690
3691
3692
3693 abcdAtmVolCurveOptionTenors :: AbcdAtmVolCurve -> IO [(Word, TimeUnit)]
3694 abcdAtmVolCurveOptionTenors o = do
3695 (ns, us) <- qlAbcdAtmVolCurveOptionTenors o
3696 pure $ zip (map fromIntegral ns) (map toEnum us)
3697 qlAbcdAtmVolCurveOptionTenors :: (AbcdAtmVolCurve) -> IO (([Int]), ([Int]))
3698 qlAbcdAtmVolCurveOptionTenors a1 =
3699 withAbcdAtmVolCurve a1 $ \a1' ->
3700 preIntArray $ \(a2'1, a2'2) ->
3701 preIntArray $ \(a3'1, a3'2) ->
3702 preErrorCheck $ \a4' ->
3703 qlAbcdAtmVolCurveOptionTenors'_ a1' a2'1 a2'2 a3'1 a3'2 a4' >>
3704 peekIntArray a2'1 a2'2>>= \a2'' ->
3705 peekIntArray a3'1 a3'2>>= \a3'' ->
3706 errorCheck a4'>>
3707 return (a2'', a3'')
3708
3709
3710
3711 -- |As 'abcdAtmVolCurveOptionTenors', but only the tenors actually used in the ABCD fit.
3712 abcdOptionTenorsInInterpolation :: AbcdAtmVolCurve -> IO [(Word, TimeUnit)]
3713 abcdOptionTenorsInInterpolation o = do
3714 (ns, us) <- qlAbcdAtmVolCurveOptionTenorsInInterpolation o
3715 pure $ zip (map fromIntegral ns) (map toEnum us)
3716 qlAbcdAtmVolCurveOptionTenorsInInterpolation :: (AbcdAtmVolCurve) -> IO (([Int]), ([Int]))
3717 qlAbcdAtmVolCurveOptionTenorsInInterpolation a1 =
3718 withAbcdAtmVolCurve a1 $ \a1' ->
3719 preIntArray $ \(a2'1, a2'2) ->
3720 preIntArray $ \(a3'1, a3'2) ->
3721 preErrorCheck $ \a4' ->
3722 qlAbcdAtmVolCurveOptionTenorsInInterpolation'_ a1' a2'1 a2'2 a3'1 a3'2 a4' >>
3723 peekIntArray a2'1 a2'2>>= \a2'' ->
3724 peekIntArray a3'1 a3'2>>= \a3'' ->
3725 errorCheck a4'>>
3726 return (a2'', a3'')
3727
3728
3729
3730 abcdOptionDates :: (AbcdAtmVolCurve) -> IO (([Day]))
3731 abcdOptionDates a1 =
3732 withAbcdAtmVolCurve a1 $ \a1' ->
3733 preIntArray $ \(a2'1, a2'2) ->
3734 preErrorCheck $ \a3' ->
3735 abcdOptionDates'_ a1' a2'1 a2'2 a3' >>
3736 peekDayArray a2'1 a2'2>>= \a2'' ->
3737 errorCheck a3'>>
3738 return (a2'')
3739
3740
3741
3742 -- |As 'abcdOptionDates', in year fractions from the curve's reference date.
3743 abcdOptionTimes :: (AbcdAtmVolCurve) -> IO (([Double]))
3744 abcdOptionTimes a1 =
3745 withAbcdAtmVolCurve a1 $ \a1' ->
3746 preDoubleArray $ \(a2'1, a2'2) ->
3747 preErrorCheck $ \a3' ->
3748 abcdOptionTimes'_ a1' a2'1 a2'2 a3' >>
3749 peekDoubleArray a2'1 a2'2>>= \a2'' ->
3750 errorCheck a3'>>
3751 return (a2'')
3752
3753
3754
3755 -- |SABR-smile 'BlackVolSurface' built from an interest-rate index, an ATM 'BlackAtmVolCurve', and
3756 -- per-tenor ATM-rate spreads\/vol-spread matrix. @volSpreads@'s rows follow @optionTenors@ and
3757 -- columns follow @atmRateSpreads@ (same row\/column convention as 'sabrSwaptionVolatilityCube's
3758 -- @volSpreads@).
3759 sabrVolSurface :: GenInterestRateIndex ix -> GenBlackAtmVolCurve b -> NonEmpty (Word, TimeUnit) -- ^optionTenors
3760 -> NonEmpty Double -- ^atmRateSpreads
3761 -> Matrix (GenQuote q) -- ^volSpreads
3762 -> IO SabrVolSurface
3763 sabrVolSurface ix atm ntenors spreads (Matrix vr vc vd) =
3764 qlSabrVolSurface ix atm n t (toList spreads) vr vc vd
3765 where (n, t) = unzip (toList ntenors)
3766 qlSabrVolSurface :: (GenInterestRateIndex ix) -> (GenBlackAtmVolCurve b) -> ([Word]) -> ([TimeUnit]) -> ([Double]) -> (Word) -> (Word) -> ([GenQuote q]) -> IO ((SabrVolSurface))
3767 qlSabrVolSurface a1 a2 a3 a4 a5 a6 a7 a8 =
3768 withInterestRateIndex a1 $ \a1' ->
3769 withGenBlackAtmVolCurve a2 $ \a2' ->
3770 withIntArray a3 $ \(a3'1, a3'2) ->
3771 withEnumArray a4 $ \(a4'1, a4'2) ->
3772 withDoubleArray a5 $ \(a5'1, a5'2) ->
3773 let {a6' = fromIntegral a6} in
3774 let {a7' = fromIntegral a7} in
3775 withQuoteArrayRaw a8 $ \a8' ->
3776 preErrorCheck $ \a9' ->
3777 qlSabrVolSurface'_ a1' a2' a3'1 a3'2 a4'1 a4'2 a5'1 a5'2 a6' a7' a8' a9' >>= \res ->
3778 peekSabrVolSurface res >>= \res' ->
3779 errorCheck a9'>>
3780 return (res')
3781
3782
3783
3784 -- |the 'BlackAtmVolCurve' this surface's ATM level is anchored to
3785 sabrVolSurfaceAtmCurve :: (SabrVolSurface) -> IO ((BlackAtmVolCurve))
3786 sabrVolSurfaceAtmCurve a1 =
3787 withSabrVolSurface a1 $ \a1' ->
3788 preErrorCheck $ \a2' ->
3789 sabrVolSurfaceAtmCurve'_ a1' a2' >>= \res ->
3790 peekBlackAtmVolCurve res >>= \res' ->
3791 errorCheck a2'>>
3792 return (res')
3793
3794
3795
3796 sabrVolSurfaceVolatilitySpreadsForTenorRaw :: (SabrVolSurface) -> ((Word,TimeUnit)) -- ^optionTenor
3797 -> IO (([Double]))
3798 sabrVolSurfaceVolatilitySpreadsForTenorRaw a1 a2 =
3799 withSabrVolSurface a1 $ \a1' ->
3800 let {(a2'1, a2'2) = fromEnumQuantity a2} in
3801 preDoubleArray $ \(a3'1, a3'2) ->
3802 preErrorCheck $ \a4' ->
3803 sabrVolSurfaceVolatilitySpreadsForTenorRaw'_ a1' a2'1 a2'2 a3'1 a3'2 a4' >>
3804 peekDoubleArray a3'1 a3'2>>= \a3'' ->
3805 errorCheck a4'>>
3806 return (a3'')
3807
3808
3809
3810 sabrVolSurfaceVolatilitySpreadsAtDateRaw :: (SabrVolSurface) -> (Day) -- ^optionDate
3811 -> IO (([Double]))
3812 sabrVolSurfaceVolatilitySpreadsAtDateRaw a1 a2 =
3813 withSabrVolSurface a1 $ \a1' ->
3814 withDay a2 $ \a2' ->
3815 preDoubleArray $ \(a3'1, a3'2) ->
3816 preErrorCheck $ \a4' ->
3817 sabrVolSurfaceVolatilitySpreadsAtDateRaw'_ a1' a2' a3'1 a3'2 a4' >>
3818 peekDoubleArray a3'1 a3'2>>= \a3'' ->
3819 errorCheck a4'>>
3820 return (a3'')
3821
3822
3823
3824 -- |Volatility-spread row at an option date or tenor.
3825 sabrVolatilitySpreads :: SabrVolSurface -> SabrVolatilitySpreadsMaturity -> IO [Double]
3826 sabrVolatilitySpreads surface maturity = case maturity of
3827 SabrVolatilitySpreadsDate optionDate ->
3828 sabrVolSurfaceVolatilitySpreadsAtDateRaw surface optionDate
3829 SabrVolatilitySpreadsTenor optionTenor ->
3830 sabrVolSurfaceVolatilitySpreadsForTenorRaw surface optionTenor
3831
3832 -- |the interest rate index this surface was built from (folded in from upstream's
3833 -- @InterestRateVolSurface@, not given its own hierarchy level here -- see 'SabrVolSurface').
3834 sabrVolSurfaceIndex :: (SabrVolSurface) -> IO ((InterestRateIndex))
3835 sabrVolSurfaceIndex a1 =
3836 withSabrVolSurface a1 $ \a1' ->
3837 preErrorCheck $ \a2' ->
3838 sabrVolSurfaceIndex'_ a1' a2' >>= \res ->
3839 peekInterestRateIndex res >>= \res' ->
3840 errorCheck a2'>>
3841 return (res')
3842
3843
3844
3845 -- |as 'sabrVolSurfaceIndex', converts an option tenor to its option date (folded in from
3846 -- @InterestRateVolSurface@)
3847 sabrVolSurfaceOptionDateFromTenor :: (SabrVolSurface) -> ((Word,TimeUnit)) -- ^optionTenor
3848 -> IO ((Day))
3849 sabrVolSurfaceOptionDateFromTenor a1 a2 =
3850 withSabrVolSurface a1 $ \a1' ->
3851 let {(a2'1, a2'2) = fromEnumQuantity a2} in
3852 preErrorCheck $ \a3' ->
3853 sabrVolSurfaceOptionDateFromTenor'_ a1' a2'1 a2'2 a3' >>= \res ->
3854 let {res' = toDay res} in
3855 errorCheck a3'>>
3856 return (res')
3857
3858
3859
3860 -- |A 'SwaptionVolatilityStructure' whose volatility at every point is @source@'s plus @spread@
3861 -- (which may change over time, since it's a live t'GenQuote' rather than a fixed number)
3862 spreadedSwaptionVolatility :: (GenSwaptionVolatilityStructure sv) -> (GenQuote q) -> IO ((SwaptionVolatilityStructure))
3863 spreadedSwaptionVolatility a1 a2 =
3864 withSwaptionVolatilityStructure a1 $ \a1' ->
3865 withQuote a2 $ \a2' ->
3866 preErrorCheck $ \a3' ->
3867 spreadedSwaptionVolatility'_ a1' a2' a3' >>= \res ->
3868 peekSwaptionVolatilityStructure res >>= \res' ->
3869 errorCheck a3'>>
3870 return (res')
3871
3872
3873
3874 -- |Swaption volatilities implied from a Gaussian one-factor model: each smile section prices
3875 -- swaptions with upstream's default @Gaussian1dSwaptionEngine@ and inverts Black's formula.
3876 -- The reference date is the model curve's; every query reprices, and the max date is unbounded.
3877 -- On QuantLib <= 1.43 the shim prices with a unit nominal to work around upstream's
3878 -- uninitialized one; newer versions use @Gaussian1dSwaptionVolatility@ directly.
3879 gaussian1dSwaptionVolatility :: (Calendar) -- ^cal
3880 -> (BusinessDayConvention) -- ^bdc
3881 -> (GenSwapIndex sidx) -- ^indexBase
3882 -> (Gaussian1dModel) -- ^model
3883 -> (DayCounter) -- ^dc
3884 -> IO ((SwaptionVolatilityStructure))
3885 gaussian1dSwaptionVolatility a1 a2 a3 a4 a5 =
3886 withCalendar a1 $ \a1' ->
3887 let {a2' = fromEnumC a2} in
3888 withSwapIndex a3 $ \a3' ->
3889 withStandalone a4 $ \a4' ->
3890 withDayCounter a5 $ \a5' ->
3891 preErrorCheck $ \a6' ->
3892 gaussian1dSwaptionVolatility'_ a1' a2' a3' a4' a5' a6' >>= \res ->
3893 peekSwaptionVolatilityStructure res >>= \res' ->
3894 errorCheck a6'>>
3895 return (res')
3896
3897
3898
3899 -- |as 'spreadedSwaptionVolatility', for 'OptionletVolatilityStructure' rather than
3900 -- 'SwaptionVolatilityStructure'
3901 spreadedOptionletVol :: (GenOptionletVolatilityStructure ov) -> (GenQuote q) -> IO ((OptionletVolatilityStructure))
3902 spreadedOptionletVol a1 a2 =
3903 withOptionletVolatilityStructure a1 $ \a1' ->
3904 withQuote a2 $ \a2' ->
3905 preErrorCheck $ \a3' ->
3906 spreadedOptionletVol'_ a1' a2' a3' >>= \res ->
3907 peekOptionletVolatilityStructure res >>= \res' ->
3908 errorCheck a3'>>
3909 return (res')
3910
3911
3912
3913 -- |A swaption vol surface behind a relinkable handle. The result /is/ a
3914 -- 'SwaptionVolatilityStructure': pass it anywhere one is expected and everything built on it
3915 -- keeps tracking whatever the handle currently points at, so a later 'linkSwaptionVolTo'
3916 -- reprices already-constructed instruments without rebuilding them. Mirrors
3917 -- 'QuantLib.TermStructure.Yield.relinkableYieldTermStructure'.
3918 relinkableSwaptionVolatilityStructure :: (Maybe (GenSwaptionVolatilityStructure sv)) -> IO ((RelinkableSwaptionVolatilityStructure))
3919 relinkableSwaptionVolatilityStructure a1 =
3920 withMaybeSwaptionVolatilityStructure a1 $ \a1' ->
3921 preErrorCheck $ \a2' ->
3922 relinkableSwaptionVolatilityStructure'_ a1' a2' >>= \res ->
3923 peekRelinkableSwaptionVolatilityStructure res >>= \res' ->
3924 errorCheck a2'>>
3925 return (res')
3926
3927
3928
3929 -- |Point a relinkable swaption vol handle at a different surface. Everything already built on
3930 -- the handle reprices against the new surface, with no engine rebuilt. Named distinctly from
3931 -- 'QuantLib.TermStructure.Yield.linkTo' and 'linkBlackVolTo' because
3932 -- 'BlackVolTermStructure'\/'SwaptionVolatilityStructure'\/'OptionletVolatilityStructure' all
3933 -- live in this one module and a bare 'linkTo' per type would collide with its own siblings,
3934 -- not just with 'Yield.chs'\/'Quote.chs'.
3935 linkSwaptionVolTo :: (RelinkableSwaptionVolatilityStructure) -> (GenSwaptionVolatilityStructure sv) -> IO ()
3936 linkSwaptionVolTo a1 a2 =
3937 withRelinkableSwaptionVolatilityStructure a1 $ \a1' ->
3938 withSwaptionVolatilityStructure a2 $ \a2' ->
3939 preErrorCheck $ \a3' ->
3940 linkSwaptionVolTo'_ a1' a2' a3' >>
3941 errorCheck a3'>>
3942 return ()
3943
3944
3945
3946 -- |A constant local volatility with either a fixed or evaluation-date-relative reference point.
3947 localConstantVol :: Reference -> GenQuote q -> DayCounter -> IO LocalVolTermStructure
3948 localConstantVol reference = case reference of
3949 ReferenceDate d -> localConstantVolFixed d
3950 SettlementDays n cal -> localConstantVolMovingRaw n cal
3951 localConstantVolMovingRaw :: (Word) -> (Calendar) -> (GenQuote q) -> (DayCounter) -> IO ((LocalVolTermStructure))
3952 localConstantVolMovingRaw a1 a2 a3 a4 =
3953 let {a1' = fromIntegral a1} in
3954 withCalendar a2 $ \a2' ->
3955 withQuote a3 $ \a3' ->
3956 withDayCounter a4 $ \a4' ->
3957 preErrorCheck $ \a5' ->
3958 localConstantVolMovingRaw'_ a1' a2' a3' a4' a5' >>= \res ->
3959 peekLocalVolTermStructure res >>= \res' ->
3960 errorCheck a5'>>
3961 return (res')
3962
3963
3964 localConstantVolFixed :: (Day) -> (GenQuote q) -> (DayCounter) -> IO ((LocalVolTermStructure))
3965 localConstantVolFixed a1 a2 a3 =
3966 withDay a1 $ \a1' ->
3967 withQuote a2 $ \a2' ->
3968 withDayCounter a3 $ \a3' ->
3969 preErrorCheck $ \a4' ->
3970 localConstantVolFixed'_ a1' a2' a3' a4' >>= \res ->
3971 peekLocalVolTermStructure res >>= \res' ->
3972 errorCheck a4'>>
3973 return (res')
3974
3975
3976
3977 -- |a local vol term structure derived from a 'BlackVarianceCurve' (no strike dependence): local
3978 -- vol at time @t@ is the derivative of the Black variance curve's total variance
3979 localVolCurve :: (BlackVarianceCurve) -> IO ((LocalVolTermStructure))
3980 localVolCurve a1 =
3981 withBlackVarianceCurve a1 $ \a1' ->
3982 preErrorCheck $ \a2' ->
3983 localVolCurve'_ a1' a2' >>= \res ->
3984 peekLocalVolTermStructure res >>= \res' ->
3985 errorCheck a2'>>
3986 return (res')
3987
3988
3989
3990 -- |@origTS@ re-anchored to a new reference date, tracking @origTS@ for later changes. Only
3991 -- financially sensible for a time-dependent (not asset-dependent) source structure.
3992 impliedVolTermStructure :: (GenBlackVolTermStructure bv) -> (Day) -> IO ((BlackVolTermStructure))
3993 impliedVolTermStructure a1 a2 =
3994 withBlackVolTermStructure a1 $ \a1' ->
3995 withDay a2 $ \a2' ->
3996 preErrorCheck $ \a3' ->
3997 impliedVolTermStructure'_ a1' a2' a3' >>= \res ->
3998 peekBlackVolTermStructure res >>= \res' ->
3999 errorCheck a3'>>
4000 return (res')
4001
4002
4003
4004 -- |A cap/floor term-volatility curve with either a fixed or evaluation-date-relative reference.
4005 capFloorTermVolCurve :: CalendarReference -> Calendar -> BusinessDayConvention
4006 -> NonEmpty (Word, TimeUnit, GenQuote q) -> DayCounter -> IO CapFloorTermVolCurve
4007 capFloorTermVolCurve reference c bd ntq = case reference of
4008 CalendarReferenceDate d -> qlCapFloorTermVolCurveFixed d c bd n t q
4009 CalendarSettlementDays d -> qlCapFloorTermVolCurveMovingRaw d c bd n t q
4010 where (n, t, q) = unzip3 (toList ntq)
4011 qlCapFloorTermVolCurveFixed :: (Day) -> (Calendar) -> (BusinessDayConvention) -> ([Word]) -> ([TimeUnit]) -> ([GenQuote q]) -> (DayCounter) -> IO ((CapFloorTermVolCurve))
4012 qlCapFloorTermVolCurveFixed a1 a2 a3 a4 a5 a6 a7 =
4013 withDay a1 $ \a1' ->
4014 withCalendar a2 $ \a2' ->
4015 let {a3' = fromEnumC a3} in
4016 withIntArray a4 $ \(a4'1, a4'2) ->
4017 withEnumArray a5 $ \(a5'1, a5'2) ->
4018 withQuoteArray a6 $ \(a6'1, a6'2) ->
4019 withDayCounter a7 $ \a7' ->
4020 preErrorCheck $ \a8' ->
4021 qlCapFloorTermVolCurveFixed'_ a1' a2' a3' a4'1 a4'2 a5'1 a5'2 a6'1 a6'2 a7' a8' >>= \res ->
4022 peekCapFloorTermVolCurve res >>= \res' ->
4023 errorCheck a8'>>
4024 return (res')
4025
4026
4027 qlCapFloorTermVolCurveMovingRaw :: (Word) -> (Calendar) -> (BusinessDayConvention) -> ([Word]) -> ([TimeUnit]) -> ([GenQuote q]) -> (DayCounter) -> IO ((CapFloorTermVolCurve))
4028 qlCapFloorTermVolCurveMovingRaw a1 a2 a3 a4 a5 a6 a7 =
4029 let {a1' = fromIntegral a1} in
4030 withCalendar a2 $ \a2' ->
4031 let {a3' = fromEnumC a3} in
4032 withIntArray a4 $ \(a4'1, a4'2) ->
4033 withEnumArray a5 $ \(a5'1, a5'2) ->
4034 withQuoteArray a6 $ \(a6'1, a6'2) ->
4035 withDayCounter a7 $ \a7' ->
4036 preErrorCheck $ \a8' ->
4037 qlCapFloorTermVolCurveMovingRaw'_ a1' a2' a3' a4'1 a4'2 a5'1 a5'2 a6'1 a6'2 a7' a8' >>= \res ->
4038 peekCapFloorTermVolCurve res >>= \res' ->
4039 errorCheck a8'>>
4040 return (res')
4041
4042
4043
4044 -- |A Black volatility curve built from time-dependent (ATM) market vols, interpolating on total
4045 -- variance (linear by default, or the given 'Interpolation') -- no strike dependence; see
4046 -- 'blackVarianceSurface' for that.
4047 blackVarianceCurve :: Day -> NonEmpty (Day, Double) -> DayCounter -> Bool -- ^forceMonotoneVariance
4048 -> Maybe Interpolation -> IO BlackVarianceCurve
4049 blackVarianceCurve d dq dc f i = uncurryNested (qlBlackVarianceCurve d dd q dc f) (qlInterpolation' i) where (dd, q) = unzip (toList dq)
4050 qlBlackVarianceCurve :: (Day) -> ([Day]) -> ([Double]) -> (DayCounter) -> (Bool) -> (Int) -> (Int) -> (Int) -> IO ((BlackVarianceCurve))
4051 qlBlackVarianceCurve a1 a2 a3 a4 a5 a6 a7 a8 =
4052 withDay a1 $ \a1' ->
4053 withDayArray a2 $ \(a2'1, a2'2) ->
4054 withDoubleArray a3 $ \(a3'1, a3'2) ->
4055 withDayCounter a4 $ \a4' ->
4056 let {a5' = C2HSImp.fromBool a5} in
4057 let {a6' = fromIntegral a6} in
4058 let {a7' = fromIntegral a7} in
4059 let {a8' = fromIntegral a8} in
4060 preErrorCheck $ \a9' ->
4061 qlBlackVarianceCurve'_ a1' a2'1 a2'2 a3'1 a3'2 a4' a5' a6' a7' a8' a9' >>= \res ->
4062 peekBlackVarianceCurve res >>= \res' ->
4063 errorCheck a9'>>
4064 return (res')
4065
4066
4067
4068 -- |The @interpolator@ is applied through @BlackVarianceSurface::setInterpolation@ right after
4069 -- construction; 'Bilinear' reproduces upstream's default. Both interpolators reproduce
4070 -- @blackVolMatrix@ exactly at its own (date, strike) nodes -- they only differ between them.
4071 blackVarianceSurface :: Day -> Calendar -> [Day] -- ^dates
4072 -> [Double] -- ^strikes
4073 -> RealMatrix -- ^blackVolMatrix
4074 -> DayCounter
4075 -> BlackVarianceSurfaceExtrapolation -- ^lowerExtrapolation
4076 -> BlackVarianceSurfaceExtrapolation -- ^upperExtrapolation
4077 -> Interpolation2D -- ^interpolator
4078 -> IO BlackVolTermStructure
4079 blackVarianceSurface d c ds s (RealMatrix mr mc md) = qlBlackVarianceSurface d c ds s mr mc md
4080 qlBlackVarianceSurface :: (Day) -> (Calendar) -> ([Day]) -> ([Double]) -> (Word) -> (Word) -> (RealVector) -> (DayCounter) -> (BlackVarianceSurfaceExtrapolation) -> (BlackVarianceSurfaceExtrapolation) -> (Interpolation2D) -> IO ((BlackVolTermStructure))
4081 qlBlackVarianceSurface a1 a2 a3 a4 a5 a6 a7 a8 a9 a10 a11 =
4082 withDay a1 $ \a1' ->
4083 withCalendar a2 $ \a2' ->
4084 withDayArray a3 $ \(a3'1, a3'2) ->
4085 withDoubleArray a4 $ \(a4'1, a4'2) ->
4086 let {a5' = fromIntegral a5} in
4087 let {a6' = fromIntegral a6} in
4088 withRealVectorRaw a7 $ \a7' ->
4089 withDayCounter a8 $ \a8' ->
4090 let {a9' = (fromIntegral . fromEnum) a9} in
4091 let {a10' = (fromIntegral . fromEnum) a10} in
4092 let {a11' = fromEnumC a11} in
4093 preErrorCheck $ \a12' ->
4094 qlBlackVarianceSurface'_ a1' a2' a3'1 a3'2 a4'1 a4'2 a5' a6' a7' a8' a9' a10' a11' a12' >>= \res ->
4095 peekBlackVolTermStructure res >>= \res' ->
4096 errorCheck a12'>>
4097 return (res')
4098
4099
4100
4101 -- |Like 'blackVarianceCurve', but volatilities are live quotes -- the curve updates when
4102 -- any of them changes (e.g. via 'QuantLib.Quote.setValue'). Interpolation is fixed to Linear upstream.
4103 extendedBlackVarianceCurve :: Day -> NonEmpty (Day, GenQuote q) -> DayCounter -> Bool -- ^forceMonotoneVariance
4104 -> IO BlackVolTermStructure
4105 extendedBlackVarianceCurve d dq dc f = qlExtendedBlackVarianceCurve d dd q dc f where (dd, q) = unzip (toList dq)
4106 qlExtendedBlackVarianceCurve :: (Day) -> ([Day]) -> ([GenQuote q]) -> (DayCounter) -> (Bool) -> IO ((BlackVolTermStructure))
4107 qlExtendedBlackVarianceCurve a1 a2 a3 a4 a5 =
4108 withDay a1 $ \a1' ->
4109 withDayArray a2 $ \(a2'1, a2'2) ->
4110 withQuoteArray a3 $ \(a3'1, a3'2) ->
4111 withDayCounter a4 $ \a4' ->
4112 let {a5' = C2HSImp.fromBool a5} in
4113 preErrorCheck $ \a6' ->
4114 qlExtendedBlackVarianceCurve'_ a1' a2'1 a2'2 a3'1 a3'2 a4' a5' a6' >>= \res ->
4115 peekBlackVolTermStructure res >>= \res' ->
4116 errorCheck a6'>>
4117 return (res')
4118
4119
4120
4121 -- |Like 'blackVarianceSurface', but volatilities are live quotes (rows strikes, columns dates).
4122 -- On QuantLib <= 1.43 this throws 'CPlusPlusException' instead of invoking upstream code that
4123 -- accesses the grid out of bounds (fixed in QuantLib 1.44).
4124 extendedBlackVarianceSurface :: Day -> Calendar -> [Day] -- ^dates
4125 -> [Double] -- ^strikes
4126 -> Matrix (GenQuote q) -- ^volatilities
4127 -> DayCounter
4128 -> ExtendedBlackVarianceSurfaceExtrapolation -- ^lowerExtrapolation
4129 -> ExtendedBlackVarianceSurfaceExtrapolation -- ^upperExtrapolation
4130 -> IO BlackVolTermStructure
4131 extendedBlackVarianceSurface d c ds s (Matrix mr mc md) = qlExtendedBlackVarianceSurface d c ds s mr mc md
4132 qlExtendedBlackVarianceSurface :: (Day) -> (Calendar) -> ([Day]) -> ([Double]) -> (Word) -> (Word) -> ([GenQuote q]) -> (DayCounter) -> (ExtendedBlackVarianceSurfaceExtrapolation) -> (ExtendedBlackVarianceSurfaceExtrapolation) -> IO ((BlackVolTermStructure))
4133 qlExtendedBlackVarianceSurface a1 a2 a3 a4 a5 a6 a7 a8 a9 a10 =
4134 withDay a1 $ \a1' ->
4135 withCalendar a2 $ \a2' ->
4136 withDayArray a3 $ \(a3'1, a3'2) ->
4137 withDoubleArray a4 $ \(a4'1, a4'2) ->
4138 let {a5' = fromIntegral a5} in
4139 let {a6' = fromIntegral a6} in
4140 withQuoteArrayRaw a7 $ \a7' ->
4141 withDayCounter a8 $ \a8' ->
4142 let {a9' = (fromIntegral . fromEnum) a9} in
4143 let {a10' = (fromIntegral . fromEnum) a10} in
4144 preErrorCheck $ \a11' ->
4145 qlExtendedBlackVarianceSurface'_ a1' a2' a3'1 a3'2 a4'1 a4'2 a5' a6' a7' a8' a9' a10' a11' >>= \res ->
4146 peekBlackVolTermStructure res >>= \res' ->
4147 errorCheck a11'>>
4148 return (res')
4149
4150
4151
4152 -- |Builds a Black volatility surface from a rectangular vol grid via
4153 -- 'PiecewiseBlackVarianceSurface::makeFromGrid': one interpolated smile section per date
4154 -- column, linear in total variance between columns -- a fixed interpolation scheme, unlike
4155 -- 'blackVarianceSurface''s configurable 2-D interpolator.
4156 piecewiseBlackVarianceSurface :: Day -> [Day] -- ^dates
4157 -> [Double] -- ^strikes
4158 -> RealMatrix -- ^blackVols
4159 -> DayCounter
4160 -> IO BlackVolTermStructure
4161 piecewiseBlackVarianceSurface d ds s (RealMatrix mr mc md) dc = qlPiecewiseBlackVarianceSurface d ds s mr mc md dc
4162 qlPiecewiseBlackVarianceSurface :: (Day) -> ([Day]) -> ([Double]) -> (Word) -> (Word) -> (RealVector) -> (DayCounter) -> IO ((BlackVolTermStructure))
4163 qlPiecewiseBlackVarianceSurface a1 a2 a3 a4 a5 a6 a7 =
4164 withDay a1 $ \a1' ->
4165 withDayArray a2 $ \(a2'1, a2'2) ->
4166 withDoubleArray a3 $ \(a3'1, a3'2) ->
4167 let {a4' = fromIntegral a4} in
4168 let {a5' = fromIntegral a5} in
4169 withRealVectorRaw a6 $ \a6' ->
4170 withDayCounter a7 $ \a7' ->
4171 preErrorCheck $ \a8' ->
4172 qlPiecewiseBlackVarianceSurface'_ a1' a2'1 a2'2 a3'1 a3'2 a4' a5' a6' a7' a8' >>= \res ->
4173 peekBlackVolTermStructure res >>= \res' ->
4174 errorCheck a8'>>
4175 return (res')
4176
4177
4178
4179 -- |A Black volatility surface parameterized by market deltas (put\/call deltas and, optionally,
4180 -- an ATM quote) rather than fixed strikes -- the standard FX vol quoting convention. Constructed
4181 -- with upstream's own defaults for the trailing options; use 'blackVolatilitySurfaceDeltaWithOptions'
4182 -- to override them.
4183 blackVolatilitySurfaceDelta :: Day -> [Day] -- ^dates
4184 -> [Double] -- ^putDeltas
4185 -> [Double] -- ^callDeltas
4186 -> Bool -- ^hasAtm
4187 -> RealMatrix -- ^blackVolMatrix
4188 -> DayCounter -> Calendar -> GenQuote q -- ^spot
4189 -> GenYieldTermStructure y1 -- ^domesticTS
4190 -> GenYieldTermStructure y2 -- ^foreignTS
4191 -> IO BlackVolatilitySurfaceDelta
4192 blackVolatilitySurfaceDelta d ds pd cd hasAtm (RealMatrix mr mc md) dc cal spot dts fts =
4193 blackVolatilitySurfaceDelta_ d ds pd cd hasAtm mr mc md dc cal spot dts fts
4194 Spot AtmDeltaNeutral Nothing SmileLinear False FlatVolatility (0, Days) Fwd AtmDeltaNeutral Nothing
4195
4196 -- |As 'blackVolatilitySurfaceDelta', but takes a 'BlackVolatilitySurfaceDeltaOpts' record for
4197 -- the trailing options instead of hardcoding upstream's defaults.
4198 blackVolatilitySurfaceDeltaWithOptions :: Day -> [Day] -> [Double] -> [Double] -> Bool -> RealMatrix
4199 -> DayCounter -> Calendar -> GenQuote q -> GenYieldTermStructure y1 -> GenYieldTermStructure y2
4200 -> BlackVolatilitySurfaceDeltaOpts -> IO BlackVolatilitySurfaceDelta
4201 blackVolatilitySurfaceDeltaWithOptions d ds pd cd hasAtm (RealMatrix mr mc md) dc cal spot dts fts opts =
4202 blackVolatilitySurfaceDelta_ d ds pd cd hasAtm mr mc md dc cal spot dts fts
4203 (bvsdDeltaType opts) (bvsdAtmType opts) (bvsdAtmDeltaType opts)
4204 (bvsdInterpolationMethod opts) (bvsdFlatStrikeExtrapolation opts) (bvsdTimeExtrapolationType opts)
4205 (bvsdSwitchTenor opts) (bvsdLongTermDeltaType opts) (bvsdLongTermAtmType opts) (bvsdLongTermAtmDeltaType opts)
4206
4207 blackVolatilitySurfaceDelta_ :: (Day) -> ([Day]) -> ([Double]) -- ^putDeltas
4208 -> ([Double]) -- ^callDeltas
4209 -> (Bool) -- ^hasAtm
4210 -> (Word) -> (Word) -> (RealVector) -- ^blackVolMatrix
4211 -> (DayCounter) -> (Calendar) -> (GenQuote q) -- ^spot
4212 -> (GenYieldTermStructure y1) -- ^domesticTS
4213 -> (GenYieldTermStructure y2) -- ^foreignTS
4214 -> (DeltaType) -- ^deltaType
4215 -> (AtmType) -- ^atmType
4216 -> (Maybe DeltaType) -- ^atmDeltaType
4217 -> (SmileInterpolationMethod) -- ^interpolationMethod
4218 -> (Bool) -- ^flatStrikeExtrapolation
4219 -> (BlackVolTimeExtrapolationType) -- ^timeExtrapolationType
4220 -> ((Int,TimeUnit)) -- ^switchTenor
4221 -> (DeltaType) -- ^longTermDeltaType
4222 -> (AtmType) -- ^longTermAtmType
4223 -> (Maybe DeltaType) -- ^longTermAtmDeltaType
4224 -> IO ((BlackVolatilitySurfaceDelta))
4225 blackVolatilitySurfaceDelta_ a1 a2 a3 a4 a5 a6 a7 a8 a9 a10 a11 a12 a13 a14 a15 a16 a17 a18 a19 a20 a21 a22 a23 =
4226 withDay a1 $ \a1' ->
4227 withDayArray a2 $ \(a2'1, a2'2) ->
4228 withDoubleArray a3 $ \(a3'1, a3'2) ->
4229 withDoubleArray a4 $ \(a4'1, a4'2) ->
4230 let {a5' = C2HSImp.fromBool a5} in
4231 let {a6' = fromIntegral a6} in
4232 let {a7' = fromIntegral a7} in
4233 withRealVectorRaw a8 $ \a8' ->
4234 withDayCounter a9 $ \a9' ->
4235 withCalendar a10 $ \a10' ->
4236 withQuote a11 $ \a11' ->
4237 withYieldTermStructure a12 $ \a12' ->
4238 withYieldTermStructure a13 $ \a13' ->
4239 let {a14' = fromEnumC a14} in
4240 let {a15' = fromEnumC a15} in
4241 let {a16' = fromMaybeEnum a16} in
4242 let {a17' = fromEnumC a17} in
4243 let {a18' = C2HSImp.fromBool a18} in
4244 let {a19' = fromEnumC a19} in
4245 let {(a20'1, a20'2) = fromEnumQuantity a20} in
4246 let {a21' = fromEnumC a21} in
4247 let {a22' = fromEnumC a22} in
4248 let {a23' = fromMaybeEnum a23} in
4249 preErrorCheck $ \a24' ->
4250 blackVolatilitySurfaceDelta_'_ a1' a2'1 a2'2 a3'1 a3'2 a4'1 a4'2 a5' a6' a7' a8' a9' a10' a11' a12' a13' a14' a15' a16' a17' a18' a19' a20'1 a20'2 a21' a22' a23' a24' >>= \res ->
4251 peekBlackVolatilitySurfaceDelta res >>= \res' ->
4252 errorCheck a24'>>
4253 return (res')
4254
4255
4256
4257 -- |The Black-volatility smile at a date or time to expiry. The returned 'SmileSection' does not
4258 -- track later changes to the surface's spot or curve handles; recreate it if those change.
4259 blackVolSmile :: BlackVolatilitySurfaceDelta -> TermPoint -> IO SmileSection
4260 blackVolSmile surface point = case point of
4261 DatePoint d -> blackVolSmileAtDateRaw surface d
4262 TimePoint t -> blackVolSmileAtTimeRaw surface t
4263 blackVolSmileAtTimeRaw :: (BlackVolatilitySurfaceDelta) -> (Double) -- ^t
4264 -> IO ((SmileSection))
4265 blackVolSmileAtTimeRaw a1 a2 =
4266 withBlackVolatilitySurfaceDelta a1 $ \a1' ->
4267 let {a2' = realToFrac a2} in
4268 preErrorCheck $ \a3' ->
4269 blackVolSmileAtTimeRaw'_ a1' a2' a3' >>= \res ->
4270 peekSmileSection res >>= \res' ->
4271 errorCheck a3'>>
4272 return (res')
4273
4274
4275
4276 blackVolSmileAtDateRaw :: (BlackVolatilitySurfaceDelta) -> (Day) -- ^d
4277 -> IO ((SmileSection))
4278 blackVolSmileAtDateRaw a1 a2 =
4279 withBlackVolatilitySurfaceDelta a1 $ \a1' ->
4280 withDay a2 $ \a2' ->
4281 preErrorCheck $ \a3' ->
4282 blackVolSmileAtDateRaw'_ a1' a2' a3' >>= \res ->
4283 peekSmileSection res >>= \res' ->
4284 errorCheck a3'>>
4285 return (res')
4286
4287
4288
4289 -- |A cap/floor term-volatility surface with either a fixed or evaluation-date-relative reference.
4290 capFloorTermVolSurface :: CalendarReference -> Calendar -> BusinessDayConvention -> [(Word, TimeUnit)] -- ^optionTenors
4291 -> [Double] -- ^strikes
4292 -> Matrix (GenQuote q) -- ^volatilities
4293 -> DayCounter -> IO CapFloorTermVolSurface
4294 capFloorTermVolSurface reference c bd t s (Matrix mr mc md) = case reference of
4295 CalendarReferenceDate d -> qlCapFloorTermVolSurfaceFixed d c bd pl pu s mr mc md
4296 CalendarSettlementDays d -> qlCapFloorTermVolSurfaceMovingRaw d c bd pl pu s mr mc md
4297 where (pl, pu) = unzip t
4298 qlCapFloorTermVolSurfaceMovingRaw :: (Word) -> (Calendar) -> (BusinessDayConvention) -> ([Word]) -> ([TimeUnit]) -> ([Double]) -> (Word) -> (Word) -> ([GenQuote q]) -> (DayCounter) -> IO ((CapFloorTermVolSurface))
4299 qlCapFloorTermVolSurfaceMovingRaw a1 a2 a3 a4 a5 a6 a7 a8 a9 a10 =
4300 let {a1' = fromIntegral a1} in
4301 withCalendar a2 $ \a2' ->
4302 let {a3' = fromEnumC a3} in
4303 withIntArray a4 $ \(a4'1, a4'2) ->
4304 withEnumArray a5 $ \(a5'1, a5'2) ->
4305 withDoubleArray a6 $ \(a6'1, a6'2) ->
4306 let {a7' = fromIntegral a7} in
4307 let {a8' = fromIntegral a8} in
4308 withQuoteArrayRaw a9 $ \a9' ->
4309 withDayCounter a10 $ \a10' ->
4310 preErrorCheck $ \a11' ->
4311 qlCapFloorTermVolSurfaceMovingRaw'_ a1' a2' a3' a4'1 a4'2 a5'1 a5'2 a6'1 a6'2 a7' a8' a9' a10' a11' >>= \res ->
4312 peekCapFloorTermVolSurface res >>= \res' ->
4313 errorCheck a11'>>
4314 return (res')
4315
4316
4317 qlCapFloorTermVolSurfaceFixed :: (Day) -> (Calendar) -> (BusinessDayConvention) -> ([Word]) -> ([TimeUnit]) -> ([Double]) -> (Word) -> (Word) -> ([GenQuote q]) -> (DayCounter) -> IO ((CapFloorTermVolSurface))
4318 qlCapFloorTermVolSurfaceFixed a1 a2 a3 a4 a5 a6 a7 a8 a9 a10 =
4319 withDay a1 $ \a1' ->
4320 withCalendar a2 $ \a2' ->
4321 let {a3' = fromEnumC a3} in
4322 withIntArray a4 $ \(a4'1, a4'2) ->
4323 withEnumArray a5 $ \(a5'1, a5'2) ->
4324 withDoubleArray a6 $ \(a6'1, a6'2) ->
4325 let {a7' = fromIntegral a7} in
4326 let {a8' = fromIntegral a8} in
4327 withQuoteArrayRaw a9 $ \a9' ->
4328 withDayCounter a10 $ \a10' ->
4329 preErrorCheck $ \a11' ->
4330 qlCapFloorTermVolSurfaceFixed'_ a1' a2' a3' a4'1 a4'2 a5'1 a5'2 a6'1 a6'2 a7' a8' a9' a10' a11' >>= \res ->
4331 peekCapFloorTermVolSurface res >>= \res' ->
4332 errorCheck a11'>>
4333 return (res')
4334
4335
4336
4337 -- |fixed reference date, floating market data. Pass an empty 'RealMatrix'
4338 -- (@realMatrixFromVector 0 0 Data.Vector.Storable.empty@) for @shifts@
4339 -- when no shift is needed -- upstream treats a zero-row shift matrix as all-zero.
4340 swaptionVolatilityMatrix :: Day -> Calendar -> BusinessDayConvention
4341 -> [(Word, TimeUnit)] -- ^optionTenors
4342 -> [(Word, TimeUnit)] -- ^swapTenors
4343 -> Matrix (GenQuote q) -- ^volatilities
4344 -> DayCounter
4345 -> Bool -- ^flatExtrapolation
4346 -> VolatilityType
4347 -> RealMatrix -- ^shifts
4348 -> IO SwaptionVolatilityMatrix
4349 swaptionVolatilityMatrix d c bdc ot st (Matrix vr vc vd) dc' fe ty (RealMatrix sr sc sd) =
4350 qlSwaptionVolatilityMatrix d c bdc opl opu spl spu vr vc vd dc' fe ty sr sc sd
4351 where (opl, opu) = unzip ot; (spl, spu) = unzip st
4352 qlSwaptionVolatilityMatrix :: (Day) -> (Calendar) -> (BusinessDayConvention) -> ([Word]) -> ([TimeUnit]) -> ([Word]) -> ([TimeUnit]) -> (Word) -> (Word) -> ([GenQuote q]) -> (DayCounter) -> (Bool) -> (VolatilityType) -> (Word) -> (Word) -> (RealVector) -> IO ((SwaptionVolatilityMatrix))
4353 qlSwaptionVolatilityMatrix a1 a2 a3 a4 a5 a6 a7 a8 a9 a10 a11 a12 a13 a14 a15 a16 =
4354 withDay a1 $ \a1' ->
4355 withCalendar a2 $ \a2' ->
4356 let {a3' = fromEnumC a3} in
4357 withIntArray a4 $ \(a4'1, a4'2) ->
4358 withEnumArray a5 $ \(a5'1, a5'2) ->
4359 withIntArray a6 $ \(a6'1, a6'2) ->
4360 withEnumArray a7 $ \(a7'1, a7'2) ->
4361 let {a8' = fromIntegral a8} in
4362 let {a9' = fromIntegral a9} in
4363 withQuoteArrayRaw a10 $ \a10' ->
4364 withDayCounter a11 $ \a11' ->
4365 let {a12' = C2HSImp.fromBool a12} in
4366 let {a13' = (fromIntegral . fromEnum) a13} in
4367 let {a14' = fromIntegral a14} in
4368 let {a15' = fromIntegral a15} in
4369 withRealVectorRaw a16 $ \a16' ->
4370 preErrorCheck $ \a17' ->
4371 qlSwaptionVolatilityMatrix'_ a1' a2' a3' a4'1 a4'2 a5'1 a5'2 a6'1 a6'2 a7'1 a7'2 a8' a9' a10' a11' a12' a13' a14' a15' a16' a17' >>= \res ->
4372 peekSwaptionVolatilityMatrix res >>= \res' ->
4373 errorCheck a17'>>
4374 return (res')
4375
4376
4377
4378 -- |floating reference date, floating market data. See 'swaptionVolatilityMatrix' for the
4379 -- @shifts@ convention
4380 -- (@realMatrixFromVector 0 0 Data.Vector.Storable.empty@ for "no shift").
4381 swaptionVolatilityMatrixMoving :: Calendar -> BusinessDayConvention
4382 -> [(Word, TimeUnit)] -- ^optionTenors
4383 -> [(Word, TimeUnit)] -- ^swapTenors
4384 -> Matrix (GenQuote q) -- ^volatilities
4385 -> DayCounter
4386 -> Bool -- ^flatExtrapolation
4387 -> VolatilityType
4388 -> RealMatrix -- ^shifts
4389 -> IO SwaptionVolatilityMatrix
4390 swaptionVolatilityMatrixMoving c bdc ot st (Matrix vr vc vd) dc' fe ty (RealMatrix sr sc sd) =
4391 qlSwaptionVolatilityMatrix1 c bdc opl opu spl spu vr vc vd dc' fe ty sr sc sd
4392 where (opl, opu) = unzip ot; (spl, spu) = unzip st
4393 qlSwaptionVolatilityMatrix1 :: (Calendar) -> (BusinessDayConvention) -> ([Word]) -> ([TimeUnit]) -> ([Word]) -> ([TimeUnit]) -> (Word) -> (Word) -> ([GenQuote q]) -> (DayCounter) -> (Bool) -> (VolatilityType) -> (Word) -> (Word) -> (RealVector) -> IO ((SwaptionVolatilityMatrix))
4394 qlSwaptionVolatilityMatrix1 a1 a2 a3 a4 a5 a6 a7 a8 a9 a10 a11 a12 a13 a14 a15 =
4395 withCalendar a1 $ \a1' ->
4396 let {a2' = fromEnumC a2} in
4397 withIntArray a3 $ \(a3'1, a3'2) ->
4398 withEnumArray a4 $ \(a4'1, a4'2) ->
4399 withIntArray a5 $ \(a5'1, a5'2) ->
4400 withEnumArray a6 $ \(a6'1, a6'2) ->
4401 let {a7' = fromIntegral a7} in
4402 let {a8' = fromIntegral a8} in
4403 withQuoteArrayRaw a9 $ \a9' ->
4404 withDayCounter a10 $ \a10' ->
4405 let {a11' = C2HSImp.fromBool a11} in
4406 let {a12' = (fromIntegral . fromEnum) a12} in
4407 let {a13' = fromIntegral a13} in
4408 let {a14' = fromIntegral a14} in
4409 withRealVectorRaw a15 $ \a15' ->
4410 preErrorCheck $ \a16' ->
4411 qlSwaptionVolatilityMatrix1'_ a1' a2' a3'1 a3'2 a4'1 a4'2 a5'1 a5'2 a6'1 a6'2 a7' a8' a9' a10' a11' a12' a13' a14' a15' a16' >>= \res ->
4412 peekSwaptionVolatilityMatrix res >>= \res' ->
4413 errorCheck a16'>>
4414 return (res')
4415
4416
4417
4418 -- |Lower indexes of the grid corners surrounding @(optionDate, swapTenor)@, into the row\/column
4419 -- axes this matrix was built from (see 'swaptionVolatilityMatrix' and 'swaptionVolatilityMatrixMoving').
4420 swaptionVolatilityMatrixLocate :: SwaptionVolatilityMatrix -> Day -> (Word, TimeUnit) -> IO (Word, Word)
4421 swaptionVolatilityMatrixLocate = qlSwaptionVolatilityMatrixLocate
4422 qlSwaptionVolatilityMatrixLocate :: (SwaptionVolatilityMatrix) -> (Day) -- ^optionDate
4423 -> ((Word,TimeUnit)) -- ^swapTenor
4424 -> IO ((Word), (Word))
4425 qlSwaptionVolatilityMatrixLocate a1 a2 a3 =
4426 withSwaptionVolatilityMatrix a1 $ \a1' ->
4427 withDay a2 $ \a2' ->
4428 let {(a3'1, a3'2) = fromEnumQuantity a3} in
4429 alloca $ \a4' ->
4430 alloca $ \a5' ->
4431 preErrorCheck $ \a6' ->
4432 qlSwaptionVolatilityMatrixLocate'_ a1' a2' a3'1 a3'2 a4' a5' a6' >>
4433 peekWord a4'>>= \a4'' ->
4434 peekWord a5'>>= \a5'' ->
4435 errorCheck a6'>>
4436 return (a4'', a5'')
4437
4438
4439
4440 -- |A SABR-calibrated swaption volatility cube: fits a SABR smile at every (option tenor, swap
4441 -- tenor) node from an ATM surface plus a grid of vol spreads. The result /is/ a
4442 -- 'SwaptionVolatilityStructure' -- pass it anywhere one is expected (pricing engines,
4443 -- 'smileSection'\/'volatility'\/etc.) -- but its own extra getters
4444 -- ('sparseSabrParameters', 'denseSabrParameters', 'marketVolCube', 'volCubeAtmCalibrated',
4445 -- ('atmStrike')
4446 -- only accept this concrete type, not the generic one.
4447 --
4448 -- @endCriteria@\/@optMethod@ default to 'Nothing', which falls back to upstream's own internal
4449 -- Levenberg-Marquardt\/EndCriteria defaults at every calibrated node. A caller-supplied
4450 -- 'EndCriteria'\/'OptimizationMethod' is safe here since both are @shared_ptr@-boxed on the C++
4451 -- side (see the qlaux.h comment above the QlEndCriteria\/QlOptimizationMethod typedefs) -- the
4452 -- copy 'SabrSwaptionVolatilityCube' keeps as its own @shared_ptr@ member survives regardless of
4453 -- when Haskell's own handle is collected, same as 'sabrInterpolatedSmileSection' and
4454 -- 'QuantLib.TermStructure.Yield.fittedBondDiscountCurve' fitting methods.
4455 --
4456 -- @volSpreads@ and @parametersGuess@ are both flattened over the (optionTenor x swapTenor)
4457 -- product as the *outer* index (row = j*nSwapTenors+k, j over @optionTenors@, k over
4458 -- @swapTenors@) -- not one row per @optionTenor@ the way 'swaptionVolatilityMatrix' grid is:
4459 -- @matrixRows == length optionTenors * length swapTenors@ for both. @volSpreads@'s columns are
4460 -- one per @strikeSpreads@ entry; @parametersGuess@'s columns are always exactly 4, in order
4461 -- alpha\/beta\/nu\/rho.
4462 --
4463 -- Calibration is lazy: unlike 'sabrInterpolatedSmileSection', construction here does /not/ force
4464 -- an eager fit, so this call can succeed even for inputs that will later fail to calibrate -- the
4465 -- error only surfaces on the first 'smileSection'\/'volatility'\/diagnostic call.
4466 sabrSwaptionVolatilityCube :: GenSwaptionVolatilityStructure sv -- ^atmVolStructure
4467 -> [(Word, TimeUnit)] -- ^optionTenors
4468 -> [(Word, TimeUnit)] -- ^swapTenors
4469 -> [Double] -- ^strikeSpreads
4470 -> Matrix (GenQuote q1) -- ^volSpreads
4471 -> GenSwapIndex sidx1 -- ^swapIndexBase
4472 -> GenSwapIndex sidx2 -- ^shortSwapIndexBase
4473 -> Bool -- ^vegaWeightedSmileFit
4474 -> Matrix (GenQuote q2) -- ^parametersGuess (alpha, beta, nu, rho per node)
4475 -> Bool -- ^isAlphaFixed
4476 -> Bool -- ^isBetaFixed
4477 -> Bool -- ^isNuFixed
4478 -> Bool -- ^isRhoFixed
4479 -> Bool -- ^isAtmCalibrated: if 'True', @atmVolStructure@ must be a discrete grid structure
4480 -- (e.g. 'swaptionVolatilityMatrix' or another cube) -- upstream's ATM-recalibration path
4481 -- ('denseSabrParameters'\/one branch of 'volCubeAtmCalibrated') downcasts it to
4482 -- @SwaptionVolatilityDiscrete@ and dereferences the result unchecked, which crashes given a
4483 -- flat 'constantSwaptionVolatility'.
4484 -> Maybe Double -- ^maxErrorTolerance
4485 -> Maybe Double -- ^errorAccept
4486 -> Bool -- ^useMaxError
4487 -> Word -- ^maxGuesses
4488 -> Bool -- ^backwardFlat
4489 -> Double -- ^cutoffStrike
4490 -> Maybe EndCriteria -- ^endCriteria
4491 -> Maybe OptimizationMethod -- ^optMethod
4492 -> Bool -- ^singlePassCalibration (1.44; QuantLib 1.43 requires 'False')
4493 -> IO SabrSwaptionVolatilityCube
4494 sabrSwaptionVolatilityCube atm ot st ss (Matrix vr vc vd) sidx1 sidx2 vw (Matrix pr pc pd)
4495 iaf ibf inf irf iac met eat ume mg bf cs ec om singlePass =
4496 qlSabrSwaptionVolatilityCube atm opl opu spl spu ss vr vc vd sidx1 sidx2 vw pr pc pd
4497 iaf ibf inf irf iac ec om met eat ume mg bf cs singlePass
4498 where (opl, opu) = unzip ot; (spl, spu) = unzip st
4499 qlSabrSwaptionVolatilityCube :: (GenSwaptionVolatilityStructure sv) -> ([Word]) -> ([TimeUnit]) -> ([Word]) -> ([TimeUnit]) -> ([Double]) -> (Word) -> (Word) -> ([GenQuote q1]) -> (GenSwapIndex sidx1) -> (GenSwapIndex sidx2) -> (Bool) -> (Word) -> (Word) -> ([GenQuote q2]) -> (Bool) -> (Bool) -> (Bool) -> (Bool) -> (Bool) -> (Maybe EndCriteria) -> (Maybe OptimizationMethod) -> (Maybe Double) -> (Maybe Double) -> (Bool) -> (Word) -> (Bool) -> (Double) -> (Bool) -- ^singlePassCalibration (1.44; QuantLib 1.43 requires 'False')
4500 -> IO ((SabrSwaptionVolatilityCube))
4501 qlSabrSwaptionVolatilityCube a1 a2 a3 a4 a5 a6 a7 a8 a9 a10 a11 a12 a13 a14 a15 a16 a17 a18 a19 a20 a21 a22 a23 a24 a25 a26 a27 a28 a29 =
4502 withSwaptionVolatilityStructure a1 $ \a1' ->
4503 withIntArray a2 $ \(a2'1, a2'2) ->
4504 withEnumArray a3 $ \(a3'1, a3'2) ->
4505 withIntArray a4 $ \(a4'1, a4'2) ->
4506 withEnumArray a5 $ \(a5'1, a5'2) ->
4507 withDoubleArray a6 $ \(a6'1, a6'2) ->
4508 let {a7' = fromIntegral a7} in
4509 let {a8' = fromIntegral a8} in
4510 withQuoteArrayRaw a9 $ \a9' ->
4511 withSwapIndex a10 $ \a10' ->
4512 withSwapIndex a11 $ \a11' ->
4513 let {a12' = C2HSImp.fromBool a12} in
4514 let {a13' = fromIntegral a13} in
4515 let {a14' = fromIntegral a14} in
4516 withQuoteArrayRaw a15 $ \a15' ->
4517 let {a16' = C2HSImp.fromBool a16} in
4518 let {a17' = C2HSImp.fromBool a17} in
4519 let {a18' = C2HSImp.fromBool a18} in
4520 let {a19' = C2HSImp.fromBool a19} in
4521 let {a20' = C2HSImp.fromBool a20} in
4522 withMaybeEndCriteria a21 $ \a21' ->
4523 withMaybeOptimizationMethod a22 $ \a22' ->
4524 let {a23' = fromMaybeDouble a23} in
4525 let {a24' = fromMaybeDouble a24} in
4526 let {a25' = C2HSImp.fromBool a25} in
4527 let {a26' = fromIntegral a26} in
4528 let {a27' = C2HSImp.fromBool a27} in
4529 let {a28' = realToFrac a28} in
4530 let {a29' = C2HSImp.fromBool a29} in
4531 preErrorCheck $ \a30' ->
4532 qlSabrSwaptionVolatilityCube'_ a1' a2'1 a2'2 a3'1 a3'2 a4'1 a4'2 a5'1 a5'2 a6'1 a6'2 a7' a8' a9' a10' a11' a12' a13' a14' a15' a16' a17' a18' a19' a20' a21' a22' a23' a24' a25' a26' a27' a28' a29' a30' >>= \res ->
4533 peekSabrSwaptionVolatilityCube res >>= \res' ->
4534 errorCheck a30'>>
4535 return (res')
4536
4537
4538
4539 -- |An arbitrage-free SABR (Doust) swaption volatility cube: the same
4540 -- @XabrSwaptionVolatilityCube@ construction as 'sabrSwaptionVolatilityCube', one model policy
4541 -- over -- fits an arbitrage-free SABR smile (via 'NoArbSabrModel') at every node instead of the
4542 -- Hagan-formula SABR smile. Same argument shapes, flattening conventions, lazy calibration, and
4543 -- 'EndCriteria'\/'OptimizationMethod' safety as 'sabrSwaptionVolatilityCube'; its own extra
4544 -- getters ('noArbSabrSparseSabrParameters', 'noArbSabrDenseSabrParameters',
4545 -- 'noArbSabrMarketVolCube', 'noArbSabrVolCubeAtmCalibrated',
4546 -- 'atmStrike') only accept this concrete type.
4547 noArbSabrSwaptionVolatilityCube :: GenSwaptionVolatilityStructure sv -- ^atmVolStructure
4548 -> [(Word, TimeUnit)] -- ^optionTenors
4549 -> [(Word, TimeUnit)] -- ^swapTenors
4550 -> [Double] -- ^strikeSpreads
4551 -> Matrix (GenQuote q1) -- ^volSpreads
4552 -> GenSwapIndex sidx1 -- ^swapIndexBase
4553 -> GenSwapIndex sidx2 -- ^shortSwapIndexBase
4554 -> Bool -- ^vegaWeightedSmileFit
4555 -> Matrix (GenQuote q2) -- ^parametersGuess (alpha, beta, nu, rho per node)
4556 -> Bool -- ^isAlphaFixed
4557 -> Bool -- ^isBetaFixed
4558 -> Bool -- ^isNuFixed
4559 -> Bool -- ^isRhoFixed
4560 -> Bool -- ^isAtmCalibrated, see 'sabrSwaptionVolatilityCube'
4561 -> Maybe Double -- ^maxErrorTolerance
4562 -> Maybe Double -- ^errorAccept
4563 -> Bool -- ^useMaxError
4564 -> Word -- ^maxGuesses
4565 -> Bool -- ^backwardFlat
4566 -> Double -- ^cutoffStrike
4567 -> Maybe EndCriteria -- ^endCriteria
4568 -> Maybe OptimizationMethod -- ^optMethod
4569 -> Bool -- ^singlePassCalibration (1.44; QuantLib 1.43 requires 'False')
4570 -> IO NoArbSabrSwaptionVolatilityCube
4571 noArbSabrSwaptionVolatilityCube atm ot st ss (Matrix vr vc vd) sidx1 sidx2 vw (Matrix pr pc pd)
4572 iaf ibf inf irf iac met eat ume mg bf cs ec om singlePass =
4573 qlNoArbSabrSwaptionVolatilityCube atm opl opu spl spu ss vr vc vd sidx1 sidx2 vw pr pc pd
4574 iaf ibf inf irf iac ec om met eat ume mg bf cs singlePass
4575 where (opl, opu) = unzip ot; (spl, spu) = unzip st
4576 qlNoArbSabrSwaptionVolatilityCube :: (GenSwaptionVolatilityStructure sv) -> ([Word]) -> ([TimeUnit]) -> ([Word]) -> ([TimeUnit]) -> ([Double]) -> (Word) -> (Word) -> ([GenQuote q1]) -> (GenSwapIndex sidx1) -> (GenSwapIndex sidx2) -> (Bool) -> (Word) -> (Word) -> ([GenQuote q2]) -> (Bool) -> (Bool) -> (Bool) -> (Bool) -> (Bool) -> (Maybe EndCriteria) -> (Maybe OptimizationMethod) -> (Maybe Double) -> (Maybe Double) -> (Bool) -> (Word) -> (Bool) -> (Double) -> (Bool) -- ^singlePassCalibration (1.44; QuantLib 1.43 requires 'False')
4577 -> IO ((NoArbSabrSwaptionVolatilityCube))
4578 qlNoArbSabrSwaptionVolatilityCube a1 a2 a3 a4 a5 a6 a7 a8 a9 a10 a11 a12 a13 a14 a15 a16 a17 a18 a19 a20 a21 a22 a23 a24 a25 a26 a27 a28 a29 =
4579 withSwaptionVolatilityStructure a1 $ \a1' ->
4580 withIntArray a2 $ \(a2'1, a2'2) ->
4581 withEnumArray a3 $ \(a3'1, a3'2) ->
4582 withIntArray a4 $ \(a4'1, a4'2) ->
4583 withEnumArray a5 $ \(a5'1, a5'2) ->
4584 withDoubleArray a6 $ \(a6'1, a6'2) ->
4585 let {a7' = fromIntegral a7} in
4586 let {a8' = fromIntegral a8} in
4587 withQuoteArrayRaw a9 $ \a9' ->
4588 withSwapIndex a10 $ \a10' ->
4589 withSwapIndex a11 $ \a11' ->
4590 let {a12' = C2HSImp.fromBool a12} in
4591 let {a13' = fromIntegral a13} in
4592 let {a14' = fromIntegral a14} in
4593 withQuoteArrayRaw a15 $ \a15' ->
4594 let {a16' = C2HSImp.fromBool a16} in
4595 let {a17' = C2HSImp.fromBool a17} in
4596 let {a18' = C2HSImp.fromBool a18} in
4597 let {a19' = C2HSImp.fromBool a19} in
4598 let {a20' = C2HSImp.fromBool a20} in
4599 withMaybeEndCriteria a21 $ \a21' ->
4600 withMaybeOptimizationMethod a22 $ \a22' ->
4601 let {a23' = fromMaybeDouble a23} in
4602 let {a24' = fromMaybeDouble a24} in
4603 let {a25' = C2HSImp.fromBool a25} in
4604 let {a26' = fromIntegral a26} in
4605 let {a27' = C2HSImp.fromBool a27} in
4606 let {a28' = realToFrac a28} in
4607 let {a29' = C2HSImp.fromBool a29} in
4608 preErrorCheck $ \a30' ->
4609 qlNoArbSabrSwaptionVolatilityCube'_ a1' a2'1 a2'2 a3'1 a3'2 a4'1 a4'2 a5'1 a5'2 a6'1 a6'2 a7' a8' a9' a10' a11' a12' a13' a14' a15' a16' a17' a18' a19' a20' a21' a22' a23' a24' a25' a26' a27' a28' a29' a30' >>= \res ->
4610 peekNoArbSabrSwaptionVolatilityCube res >>= \res' ->
4611 errorCheck a30'>>
4612 return (res')
4613
4614
4615
4616 -- |A ZABR swaption volatility cube: 'sabrSwaptionVolatilityCube' with a fifth model parameter,
4617 -- gamma (1 approximates SABR), using the short-maturity lognormal kernel. Same shapes and lazy
4618 -- calibration; shifted or normal ATM volatilities are rejected when a node is calibrated.
4619 zabrSwaptionVolatilityCube :: GenSwaptionVolatilityStructure sv -- ^atmVolStructure
4620 -> [(Word, TimeUnit)] -- ^optionTenors
4621 -> [(Word, TimeUnit)] -- ^swapTenors
4622 -> [Double] -- ^strikeSpreads
4623 -> Matrix (GenQuote q1) -- ^volSpreads
4624 -> GenSwapIndex sidx1 -- ^swapIndexBase
4625 -> GenSwapIndex sidx2 -- ^shortSwapIndexBase
4626 -> Bool -- ^vegaWeightedSmileFit
4627 -> Matrix (GenQuote q2) -- ^parametersGuess (alpha, beta, nu, rho, gamma per node)
4628 -> Bool -- ^isAlphaFixed
4629 -> Bool -- ^isBetaFixed
4630 -> Bool -- ^isNuFixed
4631 -> Bool -- ^isRhoFixed
4632 -> Bool -- ^isGammaFixed
4633 -> Bool -- ^isAtmCalibrated, see 'sabrSwaptionVolatilityCube'
4634 -> Maybe Double -- ^maxErrorTolerance
4635 -> Maybe Double -- ^errorAccept
4636 -> Bool -- ^useMaxError
4637 -> Word -- ^maxGuesses
4638 -> Bool -- ^backwardFlat
4639 -> Double -- ^cutoffStrike
4640 -> Maybe EndCriteria -- ^endCriteria
4641 -> Maybe OptimizationMethod -- ^optMethod
4642 -> Bool -- ^singlePassCalibration (1.44; QuantLib 1.43 requires 'False')
4643 -> IO ZabrSwaptionVolatilityCube
4644 zabrSwaptionVolatilityCube atm ot st ss (Matrix vr vc vd) sidx1 sidx2 vw (Matrix pr pc pd)
4645 iaf ibf inf irf igf iac met eat ume mg bf cs ec om singlePass =
4646 qlZabrSwaptionVolatilityCube atm opl opu spl spu ss vr vc vd sidx1 sidx2 vw pr pc pd
4647 iaf ibf inf irf igf iac ec om met eat ume mg bf cs singlePass
4648 where (opl, opu) = unzip ot; (spl, spu) = unzip st
4649 qlZabrSwaptionVolatilityCube :: (GenSwaptionVolatilityStructure sv) -> ([Word]) -> ([TimeUnit]) -> ([Word]) -> ([TimeUnit]) -> ([Double]) -> (Word) -> (Word) -> ([GenQuote q1]) -> (GenSwapIndex sidx1) -> (GenSwapIndex sidx2) -> (Bool) -> (Word) -> (Word) -> ([GenQuote q2]) -> (Bool) -> (Bool) -> (Bool) -> (Bool) -> (Bool) -> (Bool) -> (Maybe EndCriteria) -> (Maybe OptimizationMethod) -> (Maybe Double) -> (Maybe Double) -> (Bool) -> (Word) -> (Bool) -> (Double) -> (Bool) -- ^singlePassCalibration (1.44; QuantLib 1.43 requires 'False')
4650 -> IO ((ZabrSwaptionVolatilityCube))
4651 qlZabrSwaptionVolatilityCube a1 a2 a3 a4 a5 a6 a7 a8 a9 a10 a11 a12 a13 a14 a15 a16 a17 a18 a19 a20 a21 a22 a23 a24 a25 a26 a27 a28 a29 a30 =
4652 withSwaptionVolatilityStructure a1 $ \a1' ->
4653 withIntArray a2 $ \(a2'1, a2'2) ->
4654 withEnumArray a3 $ \(a3'1, a3'2) ->
4655 withIntArray a4 $ \(a4'1, a4'2) ->
4656 withEnumArray a5 $ \(a5'1, a5'2) ->
4657 withDoubleArray a6 $ \(a6'1, a6'2) ->
4658 let {a7' = fromIntegral a7} in
4659 let {a8' = fromIntegral a8} in
4660 withQuoteArrayRaw a9 $ \a9' ->
4661 withSwapIndex a10 $ \a10' ->
4662 withSwapIndex a11 $ \a11' ->
4663 let {a12' = C2HSImp.fromBool a12} in
4664 let {a13' = fromIntegral a13} in
4665 let {a14' = fromIntegral a14} in
4666 withQuoteArrayRaw a15 $ \a15' ->
4667 let {a16' = C2HSImp.fromBool a16} in
4668 let {a17' = C2HSImp.fromBool a17} in
4669 let {a18' = C2HSImp.fromBool a18} in
4670 let {a19' = C2HSImp.fromBool a19} in
4671 let {a20' = C2HSImp.fromBool a20} in
4672 let {a21' = C2HSImp.fromBool a21} in
4673 withMaybeEndCriteria a22 $ \a22' ->
4674 withMaybeOptimizationMethod a23 $ \a23' ->
4675 let {a24' = fromMaybeDouble a24} in
4676 let {a25' = fromMaybeDouble a25} in
4677 let {a26' = C2HSImp.fromBool a26} in
4678 let {a27' = fromIntegral a27} in
4679 let {a28' = C2HSImp.fromBool a28} in
4680 let {a29' = realToFrac a29} in
4681 let {a30' = C2HSImp.fromBool a30} in
4682 preErrorCheck $ \a31' ->
4683 qlZabrSwaptionVolatilityCube'_ a1' a2'1 a2'2 a3'1 a3'2 a4'1 a4'2 a5'1 a5'2 a6'1 a6'2 a7' a8' a9' a10' a11' a12' a13' a14' a15' a16' a17' a18' a19' a20' a21' a22' a23' a24' a25' a26' a27' a28' a29' a30' a31' >>= \res ->
4684 peekZabrSwaptionVolatilityCube res >>= \res' ->
4685 errorCheck a31'>>
4686 return (res')
4687
4688
4689
4690 -- |The non-SABR, linear-interpolation swaption volatility cube: interpolates the given
4691 -- @volSpreads@ rather than calibrating a smile model. No 'EndCriteria'\/'OptimizationMethod'
4692 -- hazard here -- this class never calibrates anything. See 'sabrSwaptionVolatilityCube' for the
4693 -- @volSpreads@ flattening convention (identical here, minus @parametersGuess@).
4694 interpolatedSwaptionVolatilityCube :: GenSwaptionVolatilityStructure sv -- ^atmVolStructure
4695 -> [(Word, TimeUnit)] -- ^optionTenors
4696 -> [(Word, TimeUnit)] -- ^swapTenors
4697 -> [Double] -- ^strikeSpreads
4698 -> Matrix (GenQuote q) -- ^volSpreads
4699 -> GenSwapIndex sidx1 -- ^swapIndexBase
4700 -> GenSwapIndex sidx2 -- ^shortSwapIndexBase
4701 -> Bool -- ^vegaWeightedSmileFit
4702 -> IO InterpolatedSwaptionVolatilityCube
4703 interpolatedSwaptionVolatilityCube atm ot st ss (Matrix vr vc vd) sidx1 sidx2 vw =
4704 qlInterpolatedSwaptionVolatilityCube atm opl opu spl spu ss vr vc vd sidx1 sidx2 vw
4705 where (opl, opu) = unzip ot; (spl, spu) = unzip st
4706 qlInterpolatedSwaptionVolatilityCube :: (GenSwaptionVolatilityStructure sv) -> ([Word]) -> ([TimeUnit]) -> ([Word]) -> ([TimeUnit]) -> ([Double]) -> (Word) -> (Word) -> ([GenQuote q]) -> (GenSwapIndex sidx1) -> (GenSwapIndex sidx2) -> (Bool) -> IO ((InterpolatedSwaptionVolatilityCube))
4707 qlInterpolatedSwaptionVolatilityCube a1 a2 a3 a4 a5 a6 a7 a8 a9 a10 a11 a12 =
4708 withSwaptionVolatilityStructure a1 $ \a1' ->
4709 withIntArray a2 $ \(a2'1, a2'2) ->
4710 withEnumArray a3 $ \(a3'1, a3'2) ->
4711 withIntArray a4 $ \(a4'1, a4'2) ->
4712 withEnumArray a5 $ \(a5'1, a5'2) ->
4713 withDoubleArray a6 $ \(a6'1, a6'2) ->
4714 let {a7' = fromIntegral a7} in
4715 let {a8' = fromIntegral a8} in
4716 withQuoteArrayRaw a9 $ \a9' ->
4717 withSwapIndex a10 $ \a10' ->
4718 withSwapIndex a11 $ \a11' ->
4719 let {a12' = C2HSImp.fromBool a12} in
4720 preErrorCheck $ \a13' ->
4721 qlInterpolatedSwaptionVolatilityCube'_ a1' a2'1 a2'2 a3'1 a3'2 a4'1 a4'2 a5'1 a5'2 a6'1 a6'2 a7' a8' a9' a10' a11' a12' a13' >>= \res ->
4722 peekInterpolatedSwaptionVolatilityCube res >>= \res' ->
4723 errorCheck a13'>>
4724 return (res')
4725
4726
4727
4728 -- |The interpolated volatility-spread matrix (option tenor x swap tenor) at the given strike
4729 -- index (0-based, into the @strikeSpreads@ the cube was built with).
4730 interpolatedSwaptionVolatilityCubeVolSpreads :: InterpolatedSwaptionVolatilityCube -> Word -> IO RealMatrix
4731 interpolatedSwaptionVolatilityCubeVolSpreads sv i = toRealMatrix <$> qlInterpolatedSwaptionVolatilityCubeVolSpreads sv i
4732 qlInterpolatedSwaptionVolatilityCubeVolSpreads :: (InterpolatedSwaptionVolatilityCube) -> (Word) -- ^i
4733 -> IO ((Word), (Word), (RealVector))
4734 qlInterpolatedSwaptionVolatilityCubeVolSpreads a1 a2 =
4735 withInterpolatedSwaptionVolatilityCube a1 $ \a1' ->
4736 let {a2' = fromIntegral a2} in
4737 prePtr $ \a3' ->
4738 prePtr $ \a4' ->
4739 preDoubleArray $ \(a5'1, a5'2) ->
4740 preErrorCheck $ \a6' ->
4741 qlInterpolatedSwaptionVolatilityCubeVolSpreads'_ a1' a2' a3' a4' a5'1 a5'2 a6' >>
4742 peekWord a3'>>= \a3'' ->
4743 peekWord a4'>>= \a4'' ->
4744 peekRealVector a5'1 a5'2>>= \a5'' ->
4745 errorCheck a6'>>
4746 return (a3'', a4'', a5'')
4747
4748
4749
4750 toRealMatrix :: (Word, Word, RealVector) -> RealMatrix
4751 toRealMatrix (r, c, d) = RealMatrix r c d
4752
4753 -- |Per-node calibrated SABR parameters (alpha, beta, nu, rho columns) before ATM recalibration.
4754 sparseSabrParameters :: SabrSwaptionVolatilityCube -> IO RealMatrix
4755 sparseSabrParameters sv = toRealMatrix <$> qlSabrSwaptionVolatilityCubeSparseSabrParameters sv
4756 qlSabrSwaptionVolatilityCubeSparseSabrParameters :: (SabrSwaptionVolatilityCube) -> IO ((Word), (Word), (RealVector))
4757 qlSabrSwaptionVolatilityCubeSparseSabrParameters a1 =
4758 withSabrSwaptionVolatilityCube a1 $ \a1' ->
4759 prePtr $ \a2' ->
4760 prePtr $ \a3' ->
4761 preDoubleArray $ \(a4'1, a4'2) ->
4762 preErrorCheck $ \a5' ->
4763 qlSabrSwaptionVolatilityCubeSparseSabrParameters'_ a1' a2' a3' a4'1 a4'2 a5' >>
4764 peekWord a2'>>= \a2'' ->
4765 peekWord a3'>>= \a3'' ->
4766 peekRealVector a4'1 a4'2>>= \a4'' ->
4767 errorCheck a5'>>
4768 return (a2'', a3'', a4'')
4769
4770
4771
4772 -- |Per-node calibrated SABR parameters, meaningfully populated only when the cube was built with
4773 -- @isAtmCalibrated = True@ (see 'sabrSwaptionVolatilityCube').
4774 denseSabrParameters :: SabrSwaptionVolatilityCube -> IO RealMatrix
4775 denseSabrParameters sv = toRealMatrix <$> qlSabrSwaptionVolatilityCubeDenseSabrParameters sv
4776 qlSabrSwaptionVolatilityCubeDenseSabrParameters :: (SabrSwaptionVolatilityCube) -> IO ((Word), (Word), (RealVector))
4777 qlSabrSwaptionVolatilityCubeDenseSabrParameters a1 =
4778 withSabrSwaptionVolatilityCube a1 $ \a1' ->
4779 prePtr $ \a2' ->
4780 prePtr $ \a3' ->
4781 preDoubleArray $ \(a4'1, a4'2) ->
4782 preErrorCheck $ \a5' ->
4783 qlSabrSwaptionVolatilityCubeDenseSabrParameters'_ a1' a2' a3' a4'1 a4'2 a5' >>
4784 peekWord a2'>>= \a2'' ->
4785 peekWord a3'>>= \a3'' ->
4786 peekRealVector a4'1 a4'2>>= \a4'' ->
4787 errorCheck a5'>>
4788 return (a2'', a3'', a4'')
4789
4790
4791
4792 -- |The raw market vol grid the cube's SABR fit targets: ATM vol (interpolated from
4793 -- @atmVolStructure@ at each node) plus @volSpreads@.
4794 marketVolCube :: SabrSwaptionVolatilityCube -> IO RealMatrix
4795 marketVolCube sv = toRealMatrix <$> qlSabrSwaptionVolatilityCubeMarketVolCube sv
4796 qlSabrSwaptionVolatilityCubeMarketVolCube :: (SabrSwaptionVolatilityCube) -> IO ((Word), (Word), (RealVector))
4797 qlSabrSwaptionVolatilityCubeMarketVolCube a1 =
4798 withSabrSwaptionVolatilityCube a1 $ \a1' ->
4799 prePtr $ \a2' ->
4800 prePtr $ \a3' ->
4801 preDoubleArray $ \(a4'1, a4'2) ->
4802 preErrorCheck $ \a5' ->
4803 qlSabrSwaptionVolatilityCubeMarketVolCube'_ a1' a2' a3' a4'1 a4'2 a5' >>
4804 peekWord a2'>>= \a2'' ->
4805 peekWord a3'>>= \a3'' ->
4806 peekRealVector a4'1 a4'2>>= \a4'' ->
4807 errorCheck a5'>>
4808 return (a2'', a3'', a4'')
4809
4810
4811
4812 -- |Like 'marketVolCube', adjusted so the cube's own ATM row is consistent with @atmVolStructure@;
4813 -- meaningfully populated only when the cube was built with @isAtmCalibrated = True@.
4814 volCubeAtmCalibrated :: SabrSwaptionVolatilityCube -> IO RealMatrix
4815 volCubeAtmCalibrated sv = toRealMatrix <$> qlSabrSwaptionVolatilityCubeVolCubeAtmCalibrated sv
4816 qlSabrSwaptionVolatilityCubeVolCubeAtmCalibrated :: (SabrSwaptionVolatilityCube) -> IO ((Word), (Word), (RealVector))
4817 qlSabrSwaptionVolatilityCubeVolCubeAtmCalibrated a1 =
4818 withSabrSwaptionVolatilityCube a1 $ \a1' ->
4819 prePtr $ \a2' ->
4820 prePtr $ \a3' ->
4821 preDoubleArray $ \(a4'1, a4'2) ->
4822 preErrorCheck $ \a5' ->
4823 qlSabrSwaptionVolatilityCubeVolCubeAtmCalibrated'_ a1' a2' a3' a4'1 a4'2 a5' >>
4824 peekWord a2'>>= \a2'' ->
4825 peekWord a3'>>= \a3'' ->
4826 peekRealVector a4'1 a4'2>>= \a4'' ->
4827 errorCheck a5'>>
4828 return (a2'', a3'', a4'')
4829
4830
4831
4832 -- |Swaption cubes exposing an ATM-strike query.
4833 class HasAtmStrike structure where
4834 atmStrike :: structure -> AtmStrikeMaturity -> (Word, TimeUnit) -> IO Double
4835
4836 instance HasAtmStrike SabrSwaptionVolatilityCube where
4837 atmStrike cube maturity = case maturity of
4838 AtmStrikeDate optionDate -> sabrSwaptionVolatilityCubeAtmStrikeAtDateRaw cube optionDate
4839 AtmStrikeTenor optionTenor -> sabrSwaptionVolatilityCubeAtmStrikeForTenorRaw cube optionTenor
4840
4841 instance HasAtmStrike NoArbSabrSwaptionVolatilityCube where
4842 atmStrike cube maturity = case maturity of
4843 AtmStrikeDate optionDate -> noArbSabrSwaptionVolatilityCubeAtmStrikeAtDateRaw cube optionDate
4844 AtmStrikeTenor optionTenor -> noArbSabrSwaptionVolatilityCubeAtmStrikeForTenorRaw cube optionTenor
4845
4846 instance HasAtmStrike ZabrSwaptionVolatilityCube where
4847 atmStrike cube maturity = case maturity of
4848 AtmStrikeDate optionDate -> zabrSwaptionVolatilityCubeAtmStrikeAtDateRaw cube optionDate
4849 AtmStrikeTenor optionTenor -> zabrSwaptionVolatilityCubeAtmStrikeForTenorRaw cube optionTenor
4850
4851 instance HasAtmStrike InterpolatedSwaptionVolatilityCube where
4852 atmStrike cube maturity = case maturity of
4853 AtmStrikeDate optionDate -> interpolatedSwaptionVolatilityCubeAtmStrikeAtDateRaw cube optionDate
4854 AtmStrikeTenor optionTenor -> interpolatedSwaptionVolatilityCubeAtmStrikeForTenorRaw cube optionTenor
4855
4856 sabrSwaptionVolatilityCubeAtmStrikeAtDateRaw :: (SabrSwaptionVolatilityCube) -> (Day) -- ^optionDate
4857 -> ((Word,TimeUnit)) -- ^swapTenor
4858 -> IO ((Double))
4859 sabrSwaptionVolatilityCubeAtmStrikeAtDateRaw a1 a2 a3 =
4860 withSabrSwaptionVolatilityCube a1 $ \a1' ->
4861 withDay a2 $ \a2' ->
4862 let {(a3'1, a3'2) = fromEnumQuantity a3} in
4863 preErrorCheck $ \a4' ->
4864 sabrSwaptionVolatilityCubeAtmStrikeAtDateRaw'_ a1' a2' a3'1 a3'2 a4' >>= \res ->
4865 let {res' = realToFrac res} in
4866 errorCheck a4'>>
4867 return (res')
4868
4869
4870
4871 sabrSwaptionVolatilityCubeAtmStrikeForTenorRaw :: (SabrSwaptionVolatilityCube) -> ((Word,TimeUnit)) -- ^optionTenor
4872 -> ((Word,TimeUnit)) -- ^swapTenor
4873 -> IO ((Double))
4874 sabrSwaptionVolatilityCubeAtmStrikeForTenorRaw a1 a2 a3 =
4875 withSabrSwaptionVolatilityCube a1 $ \a1' ->
4876 let {(a2'1, a2'2) = fromEnumQuantity a2} in
4877 let {(a3'1, a3'2) = fromEnumQuantity a3} in
4878 preErrorCheck $ \a4' ->
4879 sabrSwaptionVolatilityCubeAtmStrikeForTenorRaw'_ a1' a2'1 a2'2 a3'1 a3'2 a4' >>= \res ->
4880 let {res' = realToFrac res} in
4881 errorCheck a4'>>
4882 return (res')
4883
4884
4885
4886 -- |Per-node calibrated no-arb SABR parameters (alpha, beta, nu, rho columns) before ATM
4887 -- recalibration, see 'sparseSabrParameters'.
4888 noArbSabrSparseSabrParameters :: NoArbSabrSwaptionVolatilityCube -> IO RealMatrix
4889 noArbSabrSparseSabrParameters sv = toRealMatrix <$> qlNoArbSabrSwaptionVolatilityCubeSparseSabrParameters sv
4890 qlNoArbSabrSwaptionVolatilityCubeSparseSabrParameters :: (NoArbSabrSwaptionVolatilityCube) -> IO ((Word), (Word), (RealVector))
4891 qlNoArbSabrSwaptionVolatilityCubeSparseSabrParameters a1 =
4892 withNoArbSabrSwaptionVolatilityCube a1 $ \a1' ->
4893 prePtr $ \a2' ->
4894 prePtr $ \a3' ->
4895 preDoubleArray $ \(a4'1, a4'2) ->
4896 preErrorCheck $ \a5' ->
4897 qlNoArbSabrSwaptionVolatilityCubeSparseSabrParameters'_ a1' a2' a3' a4'1 a4'2 a5' >>
4898 peekWord a2'>>= \a2'' ->
4899 peekWord a3'>>= \a3'' ->
4900 peekRealVector a4'1 a4'2>>= \a4'' ->
4901 errorCheck a5'>>
4902 return (a2'', a3'', a4'')
4903
4904
4905
4906 -- |Per-node calibrated no-arb SABR parameters, meaningfully populated only when the cube was
4907 -- built with @isAtmCalibrated = True@, see 'denseSabrParameters'.
4908 noArbSabrDenseSabrParameters :: NoArbSabrSwaptionVolatilityCube -> IO RealMatrix
4909 noArbSabrDenseSabrParameters sv = toRealMatrix <$> qlNoArbSabrSwaptionVolatilityCubeDenseSabrParameters sv
4910 qlNoArbSabrSwaptionVolatilityCubeDenseSabrParameters :: (NoArbSabrSwaptionVolatilityCube) -> IO ((Word), (Word), (RealVector))
4911 qlNoArbSabrSwaptionVolatilityCubeDenseSabrParameters a1 =
4912 withNoArbSabrSwaptionVolatilityCube a1 $ \a1' ->
4913 prePtr $ \a2' ->
4914 prePtr $ \a3' ->
4915 preDoubleArray $ \(a4'1, a4'2) ->
4916 preErrorCheck $ \a5' ->
4917 qlNoArbSabrSwaptionVolatilityCubeDenseSabrParameters'_ a1' a2' a3' a4'1 a4'2 a5' >>
4918 peekWord a2'>>= \a2'' ->
4919 peekWord a3'>>= \a3'' ->
4920 peekRealVector a4'1 a4'2>>= \a4'' ->
4921 errorCheck a5'>>
4922 return (a2'', a3'', a4'')
4923
4924
4925
4926 -- |The raw market vol grid the cube's no-arb SABR fit targets, see 'marketVolCube'.
4927 noArbSabrMarketVolCube :: NoArbSabrSwaptionVolatilityCube -> IO RealMatrix
4928 noArbSabrMarketVolCube sv = toRealMatrix <$> qlNoArbSabrSwaptionVolatilityCubeMarketVolCube sv
4929 qlNoArbSabrSwaptionVolatilityCubeMarketVolCube :: (NoArbSabrSwaptionVolatilityCube) -> IO ((Word), (Word), (RealVector))
4930 qlNoArbSabrSwaptionVolatilityCubeMarketVolCube a1 =
4931 withNoArbSabrSwaptionVolatilityCube a1 $ \a1' ->
4932 prePtr $ \a2' ->
4933 prePtr $ \a3' ->
4934 preDoubleArray $ \(a4'1, a4'2) ->
4935 preErrorCheck $ \a5' ->
4936 qlNoArbSabrSwaptionVolatilityCubeMarketVolCube'_ a1' a2' a3' a4'1 a4'2 a5' >>
4937 peekWord a2'>>= \a2'' ->
4938 peekWord a3'>>= \a3'' ->
4939 peekRealVector a4'1 a4'2>>= \a4'' ->
4940 errorCheck a5'>>
4941 return (a2'', a3'', a4'')
4942
4943
4944
4945 -- |Like 'noArbSabrMarketVolCube', adjusted so the cube's own ATM row is consistent with
4946 -- @atmVolStructure@; meaningfully populated only when the cube was built with
4947 -- @isAtmCalibrated = True@, see 'volCubeAtmCalibrated'.
4948 noArbSabrVolCubeAtmCalibrated :: NoArbSabrSwaptionVolatilityCube -> IO RealMatrix
4949 noArbSabrVolCubeAtmCalibrated sv = toRealMatrix <$> qlNoArbSabrSwaptionVolatilityCubeVolCubeAtmCalibrated sv
4950 qlNoArbSabrSwaptionVolatilityCubeVolCubeAtmCalibrated :: (NoArbSabrSwaptionVolatilityCube) -> IO ((Word), (Word), (RealVector))
4951 qlNoArbSabrSwaptionVolatilityCubeVolCubeAtmCalibrated a1 =
4952 withNoArbSabrSwaptionVolatilityCube a1 $ \a1' ->
4953 prePtr $ \a2' ->
4954 prePtr $ \a3' ->
4955 preDoubleArray $ \(a4'1, a4'2) ->
4956 preErrorCheck $ \a5' ->
4957 qlNoArbSabrSwaptionVolatilityCubeVolCubeAtmCalibrated'_ a1' a2' a3' a4'1 a4'2 a5' >>
4958 peekWord a2'>>= \a2'' ->
4959 peekWord a3'>>= \a3'' ->
4960 peekRealVector a4'1 a4'2>>= \a4'' ->
4961 errorCheck a5'>>
4962 return (a2'', a3'', a4'')
4963
4964
4965
4966 noArbSabrSwaptionVolatilityCubeAtmStrikeAtDateRaw :: (NoArbSabrSwaptionVolatilityCube) -> (Day) -- ^optionDate
4967 -> ((Word,TimeUnit)) -- ^swapTenor
4968 -> IO ((Double))
4969 noArbSabrSwaptionVolatilityCubeAtmStrikeAtDateRaw a1 a2 a3 =
4970 withNoArbSabrSwaptionVolatilityCube a1 $ \a1' ->
4971 withDay a2 $ \a2' ->
4972 let {(a3'1, a3'2) = fromEnumQuantity a3} in
4973 preErrorCheck $ \a4' ->
4974 noArbSabrSwaptionVolatilityCubeAtmStrikeAtDateRaw'_ a1' a2' a3'1 a3'2 a4' >>= \res ->
4975 let {res' = realToFrac res} in
4976 errorCheck a4'>>
4977 return (res')
4978
4979
4980
4981 noArbSabrSwaptionVolatilityCubeAtmStrikeForTenorRaw :: (NoArbSabrSwaptionVolatilityCube) -> ((Word,TimeUnit)) -- ^optionTenor
4982 -> ((Word,TimeUnit)) -- ^swapTenor
4983 -> IO ((Double))
4984 noArbSabrSwaptionVolatilityCubeAtmStrikeForTenorRaw a1 a2 a3 =
4985 withNoArbSabrSwaptionVolatilityCube a1 $ \a1' ->
4986 let {(a2'1, a2'2) = fromEnumQuantity a2} in
4987 let {(a3'1, a3'2) = fromEnumQuantity a3} in
4988 preErrorCheck $ \a4' ->
4989 noArbSabrSwaptionVolatilityCubeAtmStrikeForTenorRaw'_ a1' a2'1 a2'2 a3'1 a3'2 a4' >>= \res ->
4990 let {res' = realToFrac res} in
4991 errorCheck a4'>>
4992 return (res')
4993
4994
4995
4996 -- |Per-node calibrated ZABR parameters (alpha, beta, nu, rho, gamma columns) before ATM
4997 -- recalibration, see 'sparseSabrParameters'.
4998 zabrSparseParameters :: ZabrSwaptionVolatilityCube -> IO RealMatrix
4999 zabrSparseParameters sv = toRealMatrix <$> qlZabrSwaptionVolatilityCubeSparseSabrParameters sv
5000 qlZabrSwaptionVolatilityCubeSparseSabrParameters :: (ZabrSwaptionVolatilityCube) -> IO ((Word), (Word), (RealVector))
5001 qlZabrSwaptionVolatilityCubeSparseSabrParameters a1 =
5002 withZabrSwaptionVolatilityCube a1 $ \a1' ->
5003 prePtr $ \a2' ->
5004 prePtr $ \a3' ->
5005 preDoubleArray $ \(a4'1, a4'2) ->
5006 preErrorCheck $ \a5' ->
5007 qlZabrSwaptionVolatilityCubeSparseSabrParameters'_ a1' a2' a3' a4'1 a4'2 a5' >>
5008 peekWord a2'>>= \a2'' ->
5009 peekWord a3'>>= \a3'' ->
5010 peekRealVector a4'1 a4'2>>= \a4'' ->
5011 errorCheck a5'>>
5012 return (a2'', a3'', a4'')
5013
5014
5015
5016 -- |Per-node calibrated ZABR parameters, meaningfully populated only when the cube was built with
5017 -- @isAtmCalibrated = True@, see 'denseSabrParameters'.
5018 zabrDenseParameters :: ZabrSwaptionVolatilityCube -> IO RealMatrix
5019 zabrDenseParameters sv = toRealMatrix <$> qlZabrSwaptionVolatilityCubeDenseSabrParameters sv
5020 qlZabrSwaptionVolatilityCubeDenseSabrParameters :: (ZabrSwaptionVolatilityCube) -> IO ((Word), (Word), (RealVector))
5021 qlZabrSwaptionVolatilityCubeDenseSabrParameters a1 =
5022 withZabrSwaptionVolatilityCube a1 $ \a1' ->
5023 prePtr $ \a2' ->
5024 prePtr $ \a3' ->
5025 preDoubleArray $ \(a4'1, a4'2) ->
5026 preErrorCheck $ \a5' ->
5027 qlZabrSwaptionVolatilityCubeDenseSabrParameters'_ a1' a2' a3' a4'1 a4'2 a5' >>
5028 peekWord a2'>>= \a2'' ->
5029 peekWord a3'>>= \a3'' ->
5030 peekRealVector a4'1 a4'2>>= \a4'' ->
5031 errorCheck a5'>>
5032 return (a2'', a3'', a4'')
5033
5034
5035
5036 -- |The raw market vol grid the cube's ZABR fit targets, see 'marketVolCube'.
5037 zabrMarketVolCube :: ZabrSwaptionVolatilityCube -> IO RealMatrix
5038 zabrMarketVolCube sv = toRealMatrix <$> qlZabrSwaptionVolatilityCubeMarketVolCube sv
5039 qlZabrSwaptionVolatilityCubeMarketVolCube :: (ZabrSwaptionVolatilityCube) -> IO ((Word), (Word), (RealVector))
5040 qlZabrSwaptionVolatilityCubeMarketVolCube a1 =
5041 withZabrSwaptionVolatilityCube a1 $ \a1' ->
5042 prePtr $ \a2' ->
5043 prePtr $ \a3' ->
5044 preDoubleArray $ \(a4'1, a4'2) ->
5045 preErrorCheck $ \a5' ->
5046 qlZabrSwaptionVolatilityCubeMarketVolCube'_ a1' a2' a3' a4'1 a4'2 a5' >>
5047 peekWord a2'>>= \a2'' ->
5048 peekWord a3'>>= \a3'' ->
5049 peekRealVector a4'1 a4'2>>= \a4'' ->
5050 errorCheck a5'>>
5051 return (a2'', a3'', a4'')
5052
5053
5054
5055 -- |Like 'zabrMarketVolCube', adjusted so the ATM row is consistent with @atmVolStructure@;
5056 -- meaningfully populated only when the cube was built with @isAtmCalibrated = True@.
5057 zabrVolCubeAtmCalibrated :: ZabrSwaptionVolatilityCube -> IO RealMatrix
5058 zabrVolCubeAtmCalibrated sv = toRealMatrix <$> qlZabrSwaptionVolatilityCubeVolCubeAtmCalibrated sv
5059 qlZabrSwaptionVolatilityCubeVolCubeAtmCalibrated :: (ZabrSwaptionVolatilityCube) -> IO ((Word), (Word), (RealVector))
5060 qlZabrSwaptionVolatilityCubeVolCubeAtmCalibrated a1 =
5061 withZabrSwaptionVolatilityCube a1 $ \a1' ->
5062 prePtr $ \a2' ->
5063 prePtr $ \a3' ->
5064 preDoubleArray $ \(a4'1, a4'2) ->
5065 preErrorCheck $ \a5' ->
5066 qlZabrSwaptionVolatilityCubeVolCubeAtmCalibrated'_ a1' a2' a3' a4'1 a4'2 a5' >>
5067 peekWord a2'>>= \a2'' ->
5068 peekWord a3'>>= \a3'' ->
5069 peekRealVector a4'1 a4'2>>= \a4'' ->
5070 errorCheck a5'>>
5071 return (a2'', a3'', a4'')
5072
5073
5074
5075 zabrSwaptionVolatilityCubeAtmStrikeAtDateRaw :: (ZabrSwaptionVolatilityCube) -> (Day) -- ^optionDate
5076 -> ((Word,TimeUnit)) -- ^swapTenor
5077 -> IO ((Double))
5078 zabrSwaptionVolatilityCubeAtmStrikeAtDateRaw a1 a2 a3 =
5079 withZabrSwaptionVolatilityCube a1 $ \a1' ->
5080 withDay a2 $ \a2' ->
5081 let {(a3'1, a3'2) = fromEnumQuantity a3} in
5082 preErrorCheck $ \a4' ->
5083 zabrSwaptionVolatilityCubeAtmStrikeAtDateRaw'_ a1' a2' a3'1 a3'2 a4' >>= \res ->
5084 let {res' = realToFrac res} in
5085 errorCheck a4'>>
5086 return (res')
5087
5088
5089
5090 zabrSwaptionVolatilityCubeAtmStrikeForTenorRaw :: (ZabrSwaptionVolatilityCube) -> ((Word,TimeUnit)) -- ^optionTenor
5091 -> ((Word,TimeUnit)) -- ^swapTenor
5092 -> IO ((Double))
5093 zabrSwaptionVolatilityCubeAtmStrikeForTenorRaw a1 a2 a3 =
5094 withZabrSwaptionVolatilityCube a1 $ \a1' ->
5095 let {(a2'1, a2'2) = fromEnumQuantity a2} in
5096 let {(a3'1, a3'2) = fromEnumQuantity a3} in
5097 preErrorCheck $ \a4' ->
5098 zabrSwaptionVolatilityCubeAtmStrikeForTenorRaw'_ a1' a2'1 a2'2 a3'1 a3'2 a4' >>= \res ->
5099 let {res' = realToFrac res} in
5100 errorCheck a4'>>
5101 return (res')
5102
5103
5104
5105 interpolatedSwaptionVolatilityCubeAtmStrikeAtDateRaw :: (InterpolatedSwaptionVolatilityCube) -> (Day) -- ^optionDate
5106 -> ((Word,TimeUnit)) -- ^swapTenor
5107 -> IO ((Double))
5108 interpolatedSwaptionVolatilityCubeAtmStrikeAtDateRaw a1 a2 a3 =
5109 withInterpolatedSwaptionVolatilityCube a1 $ \a1' ->
5110 withDay a2 $ \a2' ->
5111 let {(a3'1, a3'2) = fromEnumQuantity a3} in
5112 preErrorCheck $ \a4' ->
5113 interpolatedSwaptionVolatilityCubeAtmStrikeAtDateRaw'_ a1' a2' a3'1 a3'2 a4' >>= \res ->
5114 let {res' = realToFrac res} in
5115 errorCheck a4'>>
5116 return (res')
5117
5118
5119
5120 interpolatedSwaptionVolatilityCubeAtmStrikeForTenorRaw :: (InterpolatedSwaptionVolatilityCube) -> ((Word,TimeUnit)) -- ^optionTenor
5121 -> ((Word,TimeUnit)) -- ^swapTenor
5122 -> IO ((Double))
5123 interpolatedSwaptionVolatilityCubeAtmStrikeForTenorRaw a1 a2 a3 =
5124 withInterpolatedSwaptionVolatilityCube a1 $ \a1' ->
5125 let {(a2'1, a2'2) = fromEnumQuantity a2} in
5126 let {(a3'1, a3'2) = fromEnumQuantity a3} in
5127 preErrorCheck $ \a4' ->
5128 interpolatedSwaptionVolatilityCubeAtmStrikeForTenorRaw'_ a1' a2'1 a2'2 a3'1 a3'2 a4' >>= \res ->
5129 let {res' = realToFrac res} in
5130 errorCheck a4'>>
5131 return (res')
5132
5133
5134
5135 -- vim: set ff=unix ts=8 sts=2 sw=2 et:
5136
5137 foreign import ccall safe "QuantLib/TermStructure/Volatility.chs.h qlLocalVolSurface"
5138 localVolSurface'_ :: ((C2HSImp.Ptr (CBlackVolTermStructure')) -> ((C2HSImp.Ptr (CYieldTermStructure')) -> ((C2HSImp.Ptr (CYieldTermStructure')) -> ((C2HSImp.Ptr (CQuote')) -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO (C2HSImp.Ptr (CLocalVolTermStructure'))))))))
5139
5140 foreign import ccall safe "QuantLib/TermStructure/Volatility.chs.h qlNoExceptLocalVolSurface"
5141 noExceptLocalVolSurface'_ :: ((C2HSImp.Ptr (CBlackVolTermStructure')) -> ((C2HSImp.Ptr (CYieldTermStructure')) -> ((C2HSImp.Ptr (CYieldTermStructure')) -> ((C2HSImp.Ptr (CQuote')) -> (C2HSImp.CDouble -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO (C2HSImp.Ptr (CLocalVolTermStructure')))))))))
5142
5143 foreign import ccall safe "QuantLib/TermStructure/Volatility.chs.h qlFixedLocalVolSurface"
5144 qlFixedLocalVolSurface'_ :: (C2HSImp.CInt -> (C2HSImp.CUInt -> ((C2HSImp.Ptr C2HSImp.CInt) -> (C2HSImp.CUInt -> ((C2HSImp.Ptr C2HSImp.CDouble) -> (C2HSImp.CUInt -> (C2HSImp.CUInt -> ((C2HSImp.Ptr C2HSImp.CDouble) -> ((C2HSImp.Ptr (CDayCounter)) -> (C2HSImp.CInt -> (C2HSImp.CInt -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO (C2HSImp.Ptr (CLocalVolTermStructure')))))))))))))))
5145
5146 foreign import ccall safe "QuantLib/TermStructure/Volatility.chs.h qlGridModelLocalVolSurface"
5147 qlGridModelLocalVolSurface'_ :: (C2HSImp.CInt -> (C2HSImp.CUInt -> ((C2HSImp.Ptr C2HSImp.CInt) -> (C2HSImp.CUInt -> ((C2HSImp.Ptr C2HSImp.CUInt) -> ((C2HSImp.Ptr C2HSImp.CDouble) -> ((C2HSImp.Ptr (CDayCounter)) -> (C2HSImp.CInt -> (C2HSImp.CInt -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO (C2HSImp.Ptr (CGridModelLocalVolSurface')))))))))))))
5148
5149 foreign import ccall safe "QuantLib/TermStructure/Volatility.chs.h qlGridModelLocalVolSurfaceAsCalibratedModel"
5150 gridModelLocalVolSurfaceAsCalibratedModel'_ :: ((C2HSImp.Ptr (CGridModelLocalVolSurface')) -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO (C2HSImp.Ptr (CCalibratedModel')))))
5151
5152 foreign import ccall safe "QuantLib/TermStructure/Volatility.chs.h qlHestonBlackVolSurface"
5153 hestonBlackVolSurface'_ :: ((C2HSImp.Ptr (CHestonModel')) -> (C2HSImp.CInt -> (C2HSImp.CUInt -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO (C2HSImp.Ptr (CBlackVolTermStructure')))))))
5154
5155 foreign import ccall safe "QuantLib/TermStructure/Volatility.chs.h qlAndreasenHugeVolatilityInterpl"
5156 qlAndreasenHugeVolatilityInterpl'_ :: (C2HSImp.CUInt -> ((C2HSImp.Ptr (C2HSImp.Ptr (CVanillaOption'))) -> ((C2HSImp.Ptr (C2HSImp.Ptr (CQuote'))) -> ((C2HSImp.Ptr (CQuote')) -> ((C2HSImp.Ptr (CYieldTermStructure')) -> ((C2HSImp.Ptr (CYieldTermStructure')) -> (C2HSImp.CInt -> (C2HSImp.CInt -> (C2HSImp.CUInt -> (C2HSImp.CDouble -> (C2HSImp.CDouble -> ((C2HSImp.Ptr (COptimizationMethod)) -> ((C2HSImp.Ptr (CEndCriteria)) -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO (C2HSImp.Ptr (CAndreasenHugeVolatilityInterpl)))))))))))))))))
5157
5158 foreign import ccall safe "QuantLib/TermStructure/Volatility.chs.h qlAndreasenHugeVolatilityInterplCalibrationError"
5159 qlAndreasenHugeVolatilityInterplCalibrationError'_ :: ((C2HSImp.Ptr (CAndreasenHugeVolatilityInterpl)) -> ((C2HSImp.Ptr C2HSImp.CUInt) -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CDouble)) -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO ())))))
5160
5161 foreign import ccall safe "QuantLib/TermStructure/Volatility.chs.h qlAndreasenHugeVolatilityInterplFwd"
5162 andreasenHugeForward'_ :: ((C2HSImp.Ptr (CAndreasenHugeVolatilityInterpl)) -> (C2HSImp.CDouble -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO C2HSImp.CDouble))))
5163
5164 foreign import ccall safe "QuantLib/TermStructure/Volatility.chs.h qlAndreasenHugeVolatilityInterplOptionPrice"
5165 andreasenHugeOptionPrice'_ :: ((C2HSImp.Ptr (CAndreasenHugeVolatilityInterpl)) -> (C2HSImp.CDouble -> (C2HSImp.CDouble -> (C2HSImp.CInt -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO C2HSImp.CDouble))))))
5166
5167 foreign import ccall safe "QuantLib/TermStructure/Volatility.chs.h qlAndreasenHugeVolatilityInterplLocalVol"
5168 andreasenHugeLocalVol'_ :: ((C2HSImp.Ptr (CAndreasenHugeVolatilityInterpl)) -> (C2HSImp.CDouble -> (C2HSImp.CDouble -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO C2HSImp.CDouble)))))
5169
5170 foreign import ccall safe "QuantLib/TermStructure/Volatility.chs.h qlAndreasenHugeVolatilityAdapter"
5171 andreasenHugeVolatilityAdapter'_ :: ((C2HSImp.Ptr (CAndreasenHugeVolatilityInterpl)) -> (C2HSImp.CDouble -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO (C2HSImp.Ptr (CBlackVolTermStructure'))))))
5172
5173 foreign import ccall safe "QuantLib/TermStructure/Volatility.chs.h qlAndreasenHugeLocalVolAdapter"
5174 andreasenHugeLocalVolAdapter'_ :: ((C2HSImp.Ptr (CAndreasenHugeVolatilityInterpl)) -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO (C2HSImp.Ptr (CLocalVolTermStructure')))))
5175
5176 foreign import ccall safe "QuantLib/TermStructure/Volatility.chs.h qlLocalVolTermStructureLocalVol"
5177 localVol'_ :: ((C2HSImp.Ptr (CLocalVolTermStructure')) -> (C2HSImp.CInt -> (C2HSImp.CDouble -> (C2HSImp.CInt -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO C2HSImp.CDouble))))))
5178
5179 foreign import ccall safe "QuantLib/TermStructure/Volatility.chs.h qlConstantOptionletVol1"
5180 constantOptionletVolatilityMovingRaw'_ :: (C2HSImp.CUInt -> ((C2HSImp.Ptr (CCalendar)) -> (C2HSImp.CInt -> ((C2HSImp.Ptr (CQuote')) -> ((C2HSImp.Ptr (CDayCounter)) -> (C2HSImp.CInt -> (C2HSImp.CDouble -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO (C2HSImp.Ptr (COptionletVolatilityStructure')))))))))))
5181
5182 foreign import ccall safe "QuantLib/TermStructure/Volatility.chs.h qlConstantOptionletVolatility"
5183 constantOptionletVolatilityFixed'_ :: (C2HSImp.CInt -> ((C2HSImp.Ptr (CCalendar)) -> (C2HSImp.CInt -> ((C2HSImp.Ptr (CQuote')) -> ((C2HSImp.Ptr (CDayCounter)) -> (C2HSImp.CInt -> (C2HSImp.CDouble -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO (C2HSImp.Ptr (COptionletVolatilityStructure')))))))))))
5184
5185 foreign import ccall safe "QuantLib/TermStructure/Volatility.chs.h qlCapletVarianceCurve"
5186 qlCapletVarianceCurve'_ :: (C2HSImp.CInt -> (C2HSImp.CUInt -> ((C2HSImp.Ptr C2HSImp.CInt) -> (C2HSImp.CUInt -> ((C2HSImp.Ptr C2HSImp.CDouble) -> ((C2HSImp.Ptr (CDayCounter)) -> (C2HSImp.CInt -> (C2HSImp.CDouble -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO (C2HSImp.Ptr (COptionletVolatilityStructure'))))))))))))
5187
5188 foreign import ccall safe "QuantLib/TermStructure/Volatility.chs.h qlOptionletStripper1"
5189 optionletStripper'_ :: ((C2HSImp.Ptr (CCapFloorTermVolSurface')) -> ((C2HSImp.Ptr (CIborIndex')) -> (C2HSImp.CDouble -> (C2HSImp.CDouble -> (C2HSImp.CUInt -> ((C2HSImp.Ptr (CYieldTermStructure')) -> (C2HSImp.CInt -> (C2HSImp.CDouble -> (C2HSImp.CInt -> (C2HSImp.CInt -> (C2HSImp.CInt -> (C2HSImp.CUInt -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO (C2HSImp.Ptr (COptionletVolatilityStructure'))))))))))))))))
5190
5191 foreign import ccall safe "QuantLib/TermStructure/Volatility.chs.h qlOptionletStripper2"
5192 optionletStripperWithAtm'_ :: ((C2HSImp.Ptr (CCapFloorTermVolSurface')) -> ((C2HSImp.Ptr (CIborIndex')) -> (C2HSImp.CDouble -> (C2HSImp.CDouble -> (C2HSImp.CUInt -> ((C2HSImp.Ptr (CYieldTermStructure')) -> (C2HSImp.CInt -> (C2HSImp.CDouble -> (C2HSImp.CInt -> (C2HSImp.CInt -> (C2HSImp.CInt -> ((C2HSImp.Ptr (CCapFloorTermVolCurve')) -> (C2HSImp.CUInt -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO (C2HSImp.Ptr (COptionletStripper2)))))))))))))))))
5193
5194 foreign import ccall safe "QuantLib/TermStructure/Volatility.chs.h qlOptionletStripper2AsOptionletVolatilityStructure"
5195 asOptionletVolatilityStructure'_ :: ((C2HSImp.Ptr (COptionletStripper2)) -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO (C2HSImp.Ptr (COptionletVolatilityStructure')))))
5196
5197 foreign import ccall safe "QuantLib/TermStructure/Volatility.chs.h qlOptionletStripper2AtmCapFloorStrikes"
5198 atmCapFloorStrikes'_ :: ((C2HSImp.Ptr (COptionletStripper2)) -> ((C2HSImp.Ptr C2HSImp.CUInt) -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CDouble)) -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO ())))))
5199
5200 foreign import ccall safe "QuantLib/TermStructure/Volatility.chs.h qlOptionletStripper2AtmCapFloorPrices"
5201 atmCapFloorPrices'_ :: ((C2HSImp.Ptr (COptionletStripper2)) -> ((C2HSImp.Ptr C2HSImp.CUInt) -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CDouble)) -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO ())))))
5202
5203 foreign import ccall safe "QuantLib/TermStructure/Volatility.chs.h qlOptionletStripper2SpreadsVol"
5204 spreadsVol'_ :: ((C2HSImp.Ptr (COptionletStripper2)) -> ((C2HSImp.Ptr C2HSImp.CUInt) -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CDouble)) -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO ())))))
5205
5206 foreign import ccall safe "QuantLib/TermStructure/Volatility.chs.h qlRelinkableOptionletVolatilityStructure"
5207 relinkableOptionletVolatilityStructure'_ :: ((C2HSImp.Ptr (COptionletVolatilityStructure')) -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO (C2HSImp.Ptr (CRelinkableOptionletVolatilityStructure')))))
5208
5209 foreign import ccall safe "QuantLib/TermStructure/Volatility.chs.h qlRelinkableOptionletVolatilityStructureLinkTo"
5210 linkOptionletVolTo'_ :: ((C2HSImp.Ptr (CRelinkableOptionletVolatilityStructure')) -> ((C2HSImp.Ptr (COptionletVolatilityStructure')) -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO ()))))
5211
5212 foreign import ccall safe "QuantLib/TermStructure/Volatility.chs.h qlBlackConstantVol1"
5213 blackConstantVolMovingRaw'_ :: (C2HSImp.CUInt -> ((C2HSImp.Ptr (CCalendar)) -> ((C2HSImp.Ptr (CQuote')) -> ((C2HSImp.Ptr (CDayCounter)) -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO (C2HSImp.Ptr (CBlackVolTermStructure'))))))))
5214
5215 foreign import ccall safe "QuantLib/TermStructure/Volatility.chs.h qlBlackConstantVol"
5216 blackConstantVolFixed'_ :: (C2HSImp.CInt -> ((C2HSImp.Ptr (CCalendar)) -> ((C2HSImp.Ptr (CQuote')) -> ((C2HSImp.Ptr (CDayCounter)) -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO (C2HSImp.Ptr (CBlackVolTermStructure'))))))))
5217
5218 foreign import ccall safe "QuantLib/TermStructure/Volatility.chs.h qlSabrVolTermStructure"
5219 sabrVolTermStructure'_ :: (C2HSImp.CDouble -> (C2HSImp.CDouble -> (C2HSImp.CDouble -> (C2HSImp.CDouble -> (C2HSImp.CDouble -> (C2HSImp.CDouble -> (C2HSImp.CInt -> ((C2HSImp.Ptr (CDayCounter)) -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO (C2HSImp.Ptr (CBlackVolTermStructure'))))))))))))
5220
5221 foreign import ccall safe "QuantLib/TermStructure/Volatility.chs.h qlRelinkableBlackVolTermStructure"
5222 relinkableBlackVolTermStructure'_ :: ((C2HSImp.Ptr (CBlackVolTermStructure')) -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO (C2HSImp.Ptr (CRelinkableBlackVolTermStructure')))))
5223
5224 foreign import ccall safe "QuantLib/TermStructure/Volatility.chs.h qlRelinkableBlackVolTermStructureLinkTo"
5225 linkBlackVolTo'_ :: ((C2HSImp.Ptr (CRelinkableBlackVolTermStructure')) -> ((C2HSImp.Ptr (CBlackVolTermStructure')) -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO ()))))
5226
5227 foreign import ccall safe "QuantLib/TermStructure/Volatility.chs.h qlBlackVolTermStructureBlackVol"
5228 blackVolAtDateRaw'_ :: ((C2HSImp.Ptr (CBlackVolTermStructure')) -> (C2HSImp.CInt -> (C2HSImp.CDouble -> (C2HSImp.CInt -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO C2HSImp.CDouble))))))
5229
5230 foreign import ccall safe "QuantLib/TermStructure/Volatility.chs.h qlBlackVolTermStructureBlackVol1"
5231 blackVolAtTimeRaw'_ :: ((C2HSImp.Ptr (CBlackVolTermStructure')) -> (C2HSImp.CDouble -> (C2HSImp.CDouble -> (C2HSImp.CInt -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO C2HSImp.CDouble))))))
5232
5233 foreign import ccall safe "QuantLib/TermStructure/Volatility.chs.h qlBlackVolTermStructureBlackVariance"
5234 blackVarianceAtDateRaw'_ :: ((C2HSImp.Ptr (CBlackVolTermStructure')) -> (C2HSImp.CInt -> (C2HSImp.CDouble -> (C2HSImp.CInt -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO C2HSImp.CDouble))))))
5235
5236 foreign import ccall safe "QuantLib/TermStructure/Volatility.chs.h qlBlackVolTermStructureBlackVariance1"
5237 blackVarianceAtTimeRaw'_ :: ((C2HSImp.Ptr (CBlackVolTermStructure')) -> (C2HSImp.CDouble -> (C2HSImp.CDouble -> (C2HSImp.CInt -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO C2HSImp.CDouble))))))
5238
5239 foreign import ccall safe "QuantLib/TermStructure/Volatility.chs.h qlBlackVolTermStructureBlackForwardVol"
5240 blackForwardVolBetweenDatesRaw'_ :: ((C2HSImp.Ptr (CBlackVolTermStructure')) -> (C2HSImp.CInt -> (C2HSImp.CInt -> (C2HSImp.CDouble -> (C2HSImp.CInt -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO C2HSImp.CDouble)))))))
5241
5242 foreign import ccall safe "QuantLib/TermStructure/Volatility.chs.h qlBlackVolTermStructureBlackForwardVol1"
5243 blackForwardVolBetweenTimesRaw'_ :: ((C2HSImp.Ptr (CBlackVolTermStructure')) -> (C2HSImp.CDouble -> (C2HSImp.CDouble -> (C2HSImp.CDouble -> (C2HSImp.CInt -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO C2HSImp.CDouble)))))))
5244
5245 foreign import ccall safe "QuantLib/TermStructure/Volatility.chs.h qlBlackVolTermStructureBlackForwardVariance"
5246 blackForwardVarianceBetweenDatesRaw'_ :: ((C2HSImp.Ptr (CBlackVolTermStructure')) -> (C2HSImp.CInt -> (C2HSImp.CInt -> (C2HSImp.CDouble -> (C2HSImp.CInt -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO C2HSImp.CDouble)))))))
5247
5248 foreign import ccall safe "QuantLib/TermStructure/Volatility.chs.h qlBlackVolTermStructureBlackForwardVariance1"
5249 blackForwardVarianceBetweenTimesRaw'_ :: ((C2HSImp.Ptr (CBlackVolTermStructure')) -> (C2HSImp.CDouble -> (C2HSImp.CDouble -> (C2HSImp.CDouble -> (C2HSImp.CInt -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO C2HSImp.CDouble)))))))
5250
5251 foreign import ccall safe "QuantLib/TermStructure/Volatility.chs.h qlConstantSwaptionVolatility1"
5252 constantSwaptionVolatilityFixed'_ :: (C2HSImp.CInt -> ((C2HSImp.Ptr (CCalendar)) -> (C2HSImp.CInt -> ((C2HSImp.Ptr (CQuote')) -> ((C2HSImp.Ptr (CDayCounter)) -> (C2HSImp.CInt -> (C2HSImp.CDouble -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO (C2HSImp.Ptr (CSwaptionVolatilityStructure')))))))))))
5253
5254 foreign import ccall safe "QuantLib/TermStructure/Volatility.chs.h qlConstantSwaptionVolatility"
5255 constantSwaptionVolatilityMovingRaw'_ :: (C2HSImp.CUInt -> ((C2HSImp.Ptr (CCalendar)) -> (C2HSImp.CInt -> ((C2HSImp.Ptr (CQuote')) -> ((C2HSImp.Ptr (CDayCounter)) -> (C2HSImp.CInt -> (C2HSImp.CDouble -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO (C2HSImp.Ptr (CSwaptionVolatilityStructure')))))))))))
5256
5257 foreign import ccall safe "QuantLib/TermStructure/Volatility.chs.h qlSwaptionVolatilityStructureBlackVariance1"
5258 blackVarianceDateTenor'_ :: ((C2HSImp.Ptr (CSwaptionVolatilityStructure')) -> (C2HSImp.CInt -> (C2HSImp.CInt -> (C2HSImp.CInt -> (C2HSImp.CDouble -> (C2HSImp.CInt -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO C2HSImp.CDouble))))))))
5259
5260 foreign import ccall safe "QuantLib/TermStructure/Volatility.chs.h qlSwaptionVolatilityStructureBlackVariance2"
5261 blackVarianceTimeTenor'_ :: ((C2HSImp.Ptr (CSwaptionVolatilityStructure')) -> (C2HSImp.CDouble -> (C2HSImp.CInt -> (C2HSImp.CInt -> (C2HSImp.CDouble -> (C2HSImp.CInt -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO C2HSImp.CDouble))))))))
5262
5263 foreign import ccall safe "QuantLib/TermStructure/Volatility.chs.h qlSwaptionVolatilityStructureBlackVariance3"
5264 blackVarianceTenorLength'_ :: ((C2HSImp.Ptr (CSwaptionVolatilityStructure')) -> (C2HSImp.CInt -> (C2HSImp.CInt -> (C2HSImp.CDouble -> (C2HSImp.CDouble -> (C2HSImp.CInt -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO C2HSImp.CDouble))))))))
5265
5266 foreign import ccall safe "QuantLib/TermStructure/Volatility.chs.h qlSwaptionVolatilityStructureBlackVariance4"
5267 blackVarianceDateLength'_ :: ((C2HSImp.Ptr (CSwaptionVolatilityStructure')) -> (C2HSImp.CInt -> (C2HSImp.CDouble -> (C2HSImp.CDouble -> (C2HSImp.CInt -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO C2HSImp.CDouble)))))))
5268
5269 foreign import ccall safe "QuantLib/TermStructure/Volatility.chs.h qlSwaptionVolatilityStructureBlackVariance5"
5270 blackVarianceTimeLength'_ :: ((C2HSImp.Ptr (CSwaptionVolatilityStructure')) -> (C2HSImp.CDouble -> (C2HSImp.CDouble -> (C2HSImp.CDouble -> (C2HSImp.CInt -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO C2HSImp.CDouble)))))))
5271
5272 foreign import ccall safe "QuantLib/TermStructure/Volatility.chs.h qlSwaptionVolatilityStructureBlackVariance"
5273 blackVarianceTenorTenor'_ :: ((C2HSImp.Ptr (CSwaptionVolatilityStructure')) -> (C2HSImp.CInt -> (C2HSImp.CInt -> (C2HSImp.CInt -> (C2HSImp.CInt -> (C2HSImp.CDouble -> (C2HSImp.CInt -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO C2HSImp.CDouble)))))))))
5274
5275 foreign import ccall safe "QuantLib/TermStructure/Volatility.chs.h qlSwaptionVolatilityStructureMaxSwapLength"
5276 maxSwapLength'_ :: ((C2HSImp.Ptr (CSwaptionVolatilityStructure')) -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO C2HSImp.CDouble)))
5277
5278 foreign import ccall safe "QuantLib/TermStructure/Volatility.chs.h qlSwaptionVolatilityStructureMaxSwapTenor"
5279 maxSwapTenor'_ :: ((C2HSImp.Ptr (CSwaptionVolatilityStructure')) -> ((C2HSImp.Ptr C2HSImp.CInt) -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO C2HSImp.CInt))))
5280
5281 foreign import ccall safe "QuantLib/TermStructure/Volatility.chs.h qlSwaptionVolatilityStructureSmileSection1"
5282 smileSectionDateTenor'_ :: ((C2HSImp.Ptr (CSwaptionVolatilityStructure')) -> (C2HSImp.CInt -> (C2HSImp.CInt -> (C2HSImp.CInt -> (C2HSImp.CInt -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO (C2HSImp.Ptr (CSmileSection)))))))))
5283
5284 foreign import ccall safe "QuantLib/TermStructure/Volatility.chs.h qlSwaptionVolatilityStructureSmileSection2"
5285 smileSectionTimeTenor'_ :: ((C2HSImp.Ptr (CSwaptionVolatilityStructure')) -> (C2HSImp.CDouble -> (C2HSImp.CInt -> (C2HSImp.CInt -> (C2HSImp.CInt -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO (C2HSImp.Ptr (CSmileSection)))))))))
5286
5287 foreign import ccall safe "QuantLib/TermStructure/Volatility.chs.h qlSwaptionVolatilityStructureSmileSection3"
5288 smileSectionTenorLength'_ :: ((C2HSImp.Ptr (CSwaptionVolatilityStructure')) -> (C2HSImp.CInt -> (C2HSImp.CInt -> (C2HSImp.CDouble -> (C2HSImp.CInt -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO (C2HSImp.Ptr (CSmileSection)))))))))
5289
5290 foreign import ccall safe "QuantLib/TermStructure/Volatility.chs.h qlSwaptionVolatilityStructureSmileSection4"
5291 smileSectionDateLength'_ :: ((C2HSImp.Ptr (CSwaptionVolatilityStructure')) -> (C2HSImp.CInt -> (C2HSImp.CDouble -> (C2HSImp.CInt -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO (C2HSImp.Ptr (CSmileSection))))))))
5292
5293 foreign import ccall safe "QuantLib/TermStructure/Volatility.chs.h qlSwaptionVolatilityStructureSmileSection5"
5294 smileSectionTimeLength'_ :: ((C2HSImp.Ptr (CSwaptionVolatilityStructure')) -> (C2HSImp.CDouble -> (C2HSImp.CDouble -> (C2HSImp.CInt -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO (C2HSImp.Ptr (CSmileSection))))))))
5295
5296 foreign import ccall safe "QuantLib/TermStructure/Volatility.chs.h qlSwaptionVolatilityStructureSmileSection"
5297 smileSectionTenorTenor'_ :: ((C2HSImp.Ptr (CSwaptionVolatilityStructure')) -> (C2HSImp.CInt -> (C2HSImp.CInt -> (C2HSImp.CInt -> (C2HSImp.CInt -> (C2HSImp.CInt -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO (C2HSImp.Ptr (CSmileSection))))))))))
5298
5299 foreign import ccall safe "QuantLib/TermStructure/Volatility.chs.h qlSabrSmileSection"
5300 sabrSmileSection'_ :: (C2HSImp.CDouble -> (C2HSImp.CDouble -> (C2HSImp.CDouble -> (C2HSImp.CDouble -> (C2HSImp.CDouble -> (C2HSImp.CDouble -> (C2HSImp.CDouble -> (C2HSImp.CInt -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO (C2HSImp.Ptr (CSmileSection))))))))))))
5301
5302 foreign import ccall safe "QuantLib/TermStructure/Volatility.chs.h qlSabrSmileSection1"
5303 sabrSmileSectionAtDateRaw'_ :: (C2HSImp.CInt -> (C2HSImp.CDouble -> (C2HSImp.CDouble -> (C2HSImp.CDouble -> (C2HSImp.CDouble -> (C2HSImp.CDouble -> (C2HSImp.CInt -> ((C2HSImp.Ptr (CDayCounter)) -> (C2HSImp.CDouble -> (C2HSImp.CInt -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO (C2HSImp.Ptr (CSmileSection))))))))))))))
5304
5305 foreign import ccall safe "QuantLib/TermStructure/Volatility.chs.h qlNoArbSabrSmileSection"
5306 noArbSabrSmileSectionAtTimeRaw'_ :: (C2HSImp.CDouble -> (C2HSImp.CDouble -> (C2HSImp.CDouble -> (C2HSImp.CDouble -> (C2HSImp.CDouble -> (C2HSImp.CDouble -> (C2HSImp.CDouble -> (C2HSImp.CInt -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO (C2HSImp.Ptr (CSmileSection))))))))))))
5307
5308 foreign import ccall safe "QuantLib/TermStructure/Volatility.chs.h qlNoArbSabrSmileSection1"
5309 noArbSabrSmileSectionAtDateRaw'_ :: (C2HSImp.CInt -> (C2HSImp.CDouble -> (C2HSImp.CDouble -> (C2HSImp.CDouble -> (C2HSImp.CDouble -> (C2HSImp.CDouble -> ((C2HSImp.Ptr (CDayCounter)) -> (C2HSImp.CDouble -> (C2HSImp.CInt -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO (C2HSImp.Ptr (CSmileSection)))))))))))))
5310
5311 foreign import ccall safe "QuantLib/TermStructure/Volatility.chs.h qlSmileSectionVolatility"
5312 smileSectionVolatility'_ :: ((C2HSImp.Ptr (CSmileSection)) -> (C2HSImp.CDouble -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO C2HSImp.CDouble))))
5313
5314 foreign import ccall safe "QuantLib/TermStructure/Volatility.chs.h qlSmileSectionVariance"
5315 smileSectionVariance'_ :: ((C2HSImp.Ptr (CSmileSection)) -> (C2HSImp.CDouble -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO C2HSImp.CDouble))))
5316
5317 foreign import ccall safe "QuantLib/TermStructure/Volatility.chs.h qlSmileSectionAtmLevel"
5318 smileSectionAtmLevel'_ :: ((C2HSImp.Ptr (CSmileSection)) -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO C2HSImp.CDouble)))
5319
5320 foreign import ccall safe "QuantLib/TermStructure/Volatility.chs.h qlSmileSectionOptionPrice"
5321 smileSectionOptionPrice'_ :: ((C2HSImp.Ptr (CSmileSection)) -> (C2HSImp.CDouble -> (C2HSImp.CInt -> (C2HSImp.CDouble -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO C2HSImp.CDouble))))))
5322
5323 foreign import ccall safe "QuantLib/TermStructure/Volatility.chs.h qlSmileSectionDigitalOptionPrice"
5324 smileSectionDigitalOptionPrice'_ :: ((C2HSImp.Ptr (CSmileSection)) -> (C2HSImp.CDouble -> (C2HSImp.CInt -> (C2HSImp.CDouble -> (C2HSImp.CDouble -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO C2HSImp.CDouble)))))))
5325
5326 foreign import ccall safe "QuantLib/TermStructure/Volatility.chs.h qlSmileSectionDensity"
5327 smileSectionDensity'_ :: ((C2HSImp.Ptr (CSmileSection)) -> (C2HSImp.CDouble -> (C2HSImp.CDouble -> (C2HSImp.CDouble -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO C2HSImp.CDouble))))))
5328
5329 foreign import ccall safe "QuantLib/TermStructure/Volatility.chs.h qlSmileSectionVega"
5330 smileSectionVega'_ :: ((C2HSImp.Ptr (CSmileSection)) -> (C2HSImp.CDouble -> (C2HSImp.CDouble -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO C2HSImp.CDouble)))))
5331
5332 foreign import ccall safe "QuantLib/TermStructure/Volatility.chs.h qlSmileSectionMinStrike"
5333 minStrikeSmileSectionRaw'_ :: ((C2HSImp.Ptr (CSmileSection)) -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO C2HSImp.CDouble)))
5334
5335 foreign import ccall safe "QuantLib/TermStructure/Volatility.chs.h qlSmileSectionMaxStrike"
5336 maxStrikeSmileSectionRaw'_ :: ((C2HSImp.Ptr (CSmileSection)) -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO C2HSImp.CDouble)))
5337
5338 foreign import ccall safe "QuantLib/TermStructure/Volatility.chs.h qlFlatSmileSection"
5339 flatSmileSection'_ :: (C2HSImp.CInt -> (C2HSImp.CDouble -> ((C2HSImp.Ptr (CDayCounter)) -> (C2HSImp.CInt -> (C2HSImp.CDouble -> (C2HSImp.CInt -> (C2HSImp.CDouble -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO (C2HSImp.Ptr (CSmileSection)))))))))))
5340
5341 foreign import ccall safe "QuantLib/TermStructure/Volatility.chs.h qlSpreadedSmileSection"
5342 spreadedSmileSection'_ :: ((C2HSImp.Ptr (CSmileSection)) -> ((C2HSImp.Ptr (CQuote')) -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO (C2HSImp.Ptr (CSmileSection))))))
5343
5344 foreign import ccall safe "QuantLib/TermStructure/Volatility.chs.h qlAtmSmileSection"
5345 atmSmileSection'_ :: ((C2HSImp.Ptr (CSmileSection)) -> (C2HSImp.CDouble -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO (C2HSImp.Ptr (CSmileSection))))))
5346
5347 foreign import ccall safe "QuantLib/TermStructure/Volatility.chs.h qlSviSmileSection"
5348 sviSmileSection'_ :: (C2HSImp.CInt -> (C2HSImp.CDouble -> (C2HSImp.CDouble -> (C2HSImp.CDouble -> (C2HSImp.CDouble -> (C2HSImp.CDouble -> (C2HSImp.CDouble -> ((C2HSImp.Ptr (CDayCounter)) -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO (C2HSImp.Ptr (CSmileSection))))))))))))
5349
5350 foreign import ccall safe "QuantLib/TermStructure/Volatility.chs.h qlZabrSmileSection"
5351 zabrSmileSectionAtTimeRaw'_ :: (C2HSImp.CInt -> (C2HSImp.CDouble -> (C2HSImp.CDouble -> (C2HSImp.CDouble -> (C2HSImp.CDouble -> (C2HSImp.CDouble -> (C2HSImp.CDouble -> (C2HSImp.CDouble -> (C2HSImp.CUInt -> ((C2HSImp.Ptr C2HSImp.CDouble) -> (C2HSImp.CUInt -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO (C2HSImp.Ptr (CSmileSection)))))))))))))))
5352
5353 foreign import ccall safe "QuantLib/TermStructure/Volatility.chs.h qlZabrSmileSection1"
5354 zabrSmileSectionAtDateRaw'_ :: (C2HSImp.CInt -> (C2HSImp.CInt -> (C2HSImp.CDouble -> (C2HSImp.CDouble -> (C2HSImp.CDouble -> (C2HSImp.CDouble -> (C2HSImp.CDouble -> (C2HSImp.CDouble -> ((C2HSImp.Ptr (CDayCounter)) -> (C2HSImp.CUInt -> ((C2HSImp.Ptr C2HSImp.CDouble) -> (C2HSImp.CUInt -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO (C2HSImp.Ptr (CSmileSection))))))))))))))))
5355
5356 foreign import ccall safe "QuantLib/TermStructure/Volatility.chs.h qlSabrInterpolatedSmileSection"
5357 sabrInterpolatedSmileSection_'_ :: (C2HSImp.CInt -> ((C2HSImp.Ptr (CQuote')) -> (C2HSImp.CUInt -> ((C2HSImp.Ptr C2HSImp.CDouble) -> (C2HSImp.CInt -> ((C2HSImp.Ptr (CQuote')) -> (C2HSImp.CUInt -> ((C2HSImp.Ptr (C2HSImp.Ptr (CQuote'))) -> (C2HSImp.CDouble -> (C2HSImp.CDouble -> (C2HSImp.CDouble -> (C2HSImp.CDouble -> (C2HSImp.CInt -> (C2HSImp.CInt -> (C2HSImp.CInt -> (C2HSImp.CInt -> (C2HSImp.CInt -> ((C2HSImp.Ptr (CEndCriteria)) -> ((C2HSImp.Ptr (COptimizationMethod)) -> ((C2HSImp.Ptr (CDayCounter)) -> (C2HSImp.CDouble -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO (C2HSImp.Ptr (CSabrInterpolatedSmileSection)))))))))))))))))))))))))
5358
5359 foreign import ccall safe "QuantLib/TermStructure/Volatility.chs.h qlSabrInterpolatedSmileSectionAsSmileSection"
5360 sabrAsSmileSection'_ :: ((C2HSImp.Ptr (CSabrInterpolatedSmileSection)) -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO (C2HSImp.Ptr (CSmileSection)))))
5361
5362 foreign import ccall safe "QuantLib/TermStructure/Volatility.chs.h qlSabrInterpolatedSmileSectionAlpha"
5363 sabrAlpha'_ :: ((C2HSImp.Ptr (CSabrInterpolatedSmileSection)) -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO C2HSImp.CDouble)))
5364
5365 foreign import ccall safe "QuantLib/TermStructure/Volatility.chs.h qlSabrInterpolatedSmileSectionBeta"
5366 sabrBeta'_ :: ((C2HSImp.Ptr (CSabrInterpolatedSmileSection)) -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO C2HSImp.CDouble)))
5367
5368 foreign import ccall safe "QuantLib/TermStructure/Volatility.chs.h qlSabrInterpolatedSmileSectionNu"
5369 sabrNu'_ :: ((C2HSImp.Ptr (CSabrInterpolatedSmileSection)) -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO C2HSImp.CDouble)))
5370
5371 foreign import ccall safe "QuantLib/TermStructure/Volatility.chs.h qlSabrInterpolatedSmileSectionRho"
5372 sabrRho'_ :: ((C2HSImp.Ptr (CSabrInterpolatedSmileSection)) -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO C2HSImp.CDouble)))
5373
5374 foreign import ccall safe "QuantLib/TermStructure/Volatility.chs.h qlSabrInterpolatedSmileSectionRmsError"
5375 sabrRmsError'_ :: ((C2HSImp.Ptr (CSabrInterpolatedSmileSection)) -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO C2HSImp.CDouble)))
5376
5377 foreign import ccall safe "QuantLib/TermStructure/Volatility.chs.h qlSabrInterpolatedSmileSectionMaxError"
5378 sabrMaxError'_ :: ((C2HSImp.Ptr (CSabrInterpolatedSmileSection)) -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO C2HSImp.CDouble)))
5379
5380 foreign import ccall safe "QuantLib/TermStructure/Volatility.chs.h qlSabrInterpolatedSmileSectionEndCriteria"
5381 sabrCalibrationEndCriteria'_ :: ((C2HSImp.Ptr (CSabrInterpolatedSmileSection)) -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO C2HSImp.CInt)))
5382
5383 foreign import ccall safe "QuantLib/TermStructure/Volatility.chs.h qlSviInterpolatedSmileSection"
5384 sviInterpolatedSmileSection_'_ :: (C2HSImp.CInt -> ((C2HSImp.Ptr (CQuote')) -> (C2HSImp.CUInt -> ((C2HSImp.Ptr C2HSImp.CDouble) -> (C2HSImp.CInt -> ((C2HSImp.Ptr (CQuote')) -> (C2HSImp.CUInt -> ((C2HSImp.Ptr (C2HSImp.Ptr (CQuote'))) -> (C2HSImp.CDouble -> (C2HSImp.CDouble -> (C2HSImp.CDouble -> (C2HSImp.CDouble -> (C2HSImp.CDouble -> (C2HSImp.CInt -> (C2HSImp.CInt -> (C2HSImp.CInt -> (C2HSImp.CInt -> (C2HSImp.CInt -> (C2HSImp.CInt -> ((C2HSImp.Ptr (CEndCriteria)) -> ((C2HSImp.Ptr (COptimizationMethod)) -> ((C2HSImp.Ptr (CDayCounter)) -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO (C2HSImp.Ptr (CSviInterpolatedSmileSection))))))))))))))))))))))))))
5385
5386 foreign import ccall safe "QuantLib/TermStructure/Volatility.chs.h qlSviInterpolatedSmileSectionAsSmileSection"
5387 sviAsSmileSection'_ :: ((C2HSImp.Ptr (CSviInterpolatedSmileSection)) -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO (C2HSImp.Ptr (CSmileSection)))))
5388
5389 foreign import ccall safe "QuantLib/TermStructure/Volatility.chs.h qlSviInterpolatedSmileSectionA"
5390 sviA'_ :: ((C2HSImp.Ptr (CSviInterpolatedSmileSection)) -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO C2HSImp.CDouble)))
5391
5392 foreign import ccall safe "QuantLib/TermStructure/Volatility.chs.h qlSviInterpolatedSmileSectionB"
5393 sviB'_ :: ((C2HSImp.Ptr (CSviInterpolatedSmileSection)) -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO C2HSImp.CDouble)))
5394
5395 foreign import ccall safe "QuantLib/TermStructure/Volatility.chs.h qlSviInterpolatedSmileSectionSigma"
5396 sviSigma'_ :: ((C2HSImp.Ptr (CSviInterpolatedSmileSection)) -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO C2HSImp.CDouble)))
5397
5398 foreign import ccall safe "QuantLib/TermStructure/Volatility.chs.h qlSviInterpolatedSmileSectionRho"
5399 sviRho'_ :: ((C2HSImp.Ptr (CSviInterpolatedSmileSection)) -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO C2HSImp.CDouble)))
5400
5401 foreign import ccall safe "QuantLib/TermStructure/Volatility.chs.h qlSviInterpolatedSmileSectionM"
5402 sviM'_ :: ((C2HSImp.Ptr (CSviInterpolatedSmileSection)) -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO C2HSImp.CDouble)))
5403
5404 foreign import ccall safe "QuantLib/TermStructure/Volatility.chs.h qlSviInterpolatedSmileSectionRmsError"
5405 sviRmsError'_ :: ((C2HSImp.Ptr (CSviInterpolatedSmileSection)) -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO C2HSImp.CDouble)))
5406
5407 foreign import ccall safe "QuantLib/TermStructure/Volatility.chs.h qlSviInterpolatedSmileSectionMaxError"
5408 sviMaxError'_ :: ((C2HSImp.Ptr (CSviInterpolatedSmileSection)) -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO C2HSImp.CDouble)))
5409
5410 foreign import ccall safe "QuantLib/TermStructure/Volatility.chs.h qlSviInterpolatedSmileSectionEndCriteria"
5411 sviEndCriteria'_ :: ((C2HSImp.Ptr (CSviInterpolatedSmileSection)) -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO C2HSImp.CInt)))
5412
5413 foreign import ccall safe "QuantLib/TermStructure/Volatility.chs.h qlNoArbSabrInterpolatedSmileSection"
5414 noArbSabrInterpolatedSmileSection_'_ :: (C2HSImp.CInt -> ((C2HSImp.Ptr (CQuote')) -> (C2HSImp.CUInt -> ((C2HSImp.Ptr C2HSImp.CDouble) -> (C2HSImp.CInt -> ((C2HSImp.Ptr (CQuote')) -> (C2HSImp.CUInt -> ((C2HSImp.Ptr (C2HSImp.Ptr (CQuote'))) -> (C2HSImp.CDouble -> (C2HSImp.CDouble -> (C2HSImp.CDouble -> (C2HSImp.CDouble -> (C2HSImp.CInt -> (C2HSImp.CInt -> (C2HSImp.CInt -> (C2HSImp.CInt -> (C2HSImp.CInt -> ((C2HSImp.Ptr (CEndCriteria)) -> ((C2HSImp.Ptr (COptimizationMethod)) -> ((C2HSImp.Ptr (CDayCounter)) -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO (C2HSImp.Ptr (CNoArbSabrInterpolatedSmileSection))))))))))))))))))))))))
5415
5416 foreign import ccall safe "QuantLib/TermStructure/Volatility.chs.h qlNoArbSabrInterpolatedSmileSectionAsSmileSection"
5417 noArbSabrAsSmileSection'_ :: ((C2HSImp.Ptr (CNoArbSabrInterpolatedSmileSection)) -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO (C2HSImp.Ptr (CSmileSection)))))
5418
5419 foreign import ccall safe "QuantLib/TermStructure/Volatility.chs.h qlNoArbSabrInterpolatedSmileSectionAlpha"
5420 noArbSabrAlpha'_ :: ((C2HSImp.Ptr (CNoArbSabrInterpolatedSmileSection)) -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO C2HSImp.CDouble)))
5421
5422 foreign import ccall safe "QuantLib/TermStructure/Volatility.chs.h qlNoArbSabrInterpolatedSmileSectionBeta"
5423 noArbSabrBeta'_ :: ((C2HSImp.Ptr (CNoArbSabrInterpolatedSmileSection)) -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO C2HSImp.CDouble)))
5424
5425 foreign import ccall safe "QuantLib/TermStructure/Volatility.chs.h qlNoArbSabrInterpolatedSmileSectionNu"
5426 noArbSabrNu'_ :: ((C2HSImp.Ptr (CNoArbSabrInterpolatedSmileSection)) -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO C2HSImp.CDouble)))
5427
5428 foreign import ccall safe "QuantLib/TermStructure/Volatility.chs.h qlNoArbSabrInterpolatedSmileSectionRho"
5429 noArbSabrRho'_ :: ((C2HSImp.Ptr (CNoArbSabrInterpolatedSmileSection)) -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO C2HSImp.CDouble)))
5430
5431 foreign import ccall safe "QuantLib/TermStructure/Volatility.chs.h qlNoArbSabrInterpolatedSmileSectionRmsError"
5432 noArbSabrRmsError'_ :: ((C2HSImp.Ptr (CNoArbSabrInterpolatedSmileSection)) -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO C2HSImp.CDouble)))
5433
5434 foreign import ccall safe "QuantLib/TermStructure/Volatility.chs.h qlNoArbSabrInterpolatedSmileSectionMaxError"
5435 noArbSabrMaxError'_ :: ((C2HSImp.Ptr (CNoArbSabrInterpolatedSmileSection)) -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO C2HSImp.CDouble)))
5436
5437 foreign import ccall safe "QuantLib/TermStructure/Volatility.chs.h qlNoArbSabrInterpolatedSmileSectionEndCriteria"
5438 noArbSabrEndCriteria'_ :: ((C2HSImp.Ptr (CNoArbSabrInterpolatedSmileSection)) -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO C2HSImp.CInt)))
5439
5440 foreign import ccall safe "QuantLib/TermStructure/Volatility.chs.h qlZabrInterpolatedSmileSection"
5441 zabrInterpolatedSmileSection_'_ :: (C2HSImp.CInt -> (C2HSImp.CInt -> ((C2HSImp.Ptr (CQuote')) -> (C2HSImp.CUInt -> ((C2HSImp.Ptr C2HSImp.CDouble) -> (C2HSImp.CInt -> ((C2HSImp.Ptr (CQuote')) -> (C2HSImp.CUInt -> ((C2HSImp.Ptr (C2HSImp.Ptr (CQuote'))) -> (C2HSImp.CDouble -> (C2HSImp.CDouble -> (C2HSImp.CDouble -> (C2HSImp.CDouble -> (C2HSImp.CDouble -> (C2HSImp.CInt -> (C2HSImp.CInt -> (C2HSImp.CInt -> (C2HSImp.CInt -> (C2HSImp.CInt -> (C2HSImp.CInt -> ((C2HSImp.Ptr (CEndCriteria)) -> ((C2HSImp.Ptr (COptimizationMethod)) -> ((C2HSImp.Ptr (CDayCounter)) -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO (C2HSImp.Ptr (CZabrInterpolatedSmileSection)))))))))))))))))))))))))))
5442
5443 foreign import ccall safe "QuantLib/TermStructure/Volatility.chs.h qlZabrInterpolatedSmileSectionAsSmileSection"
5444 zabrInterpolatedAsSmileSection'_ :: ((C2HSImp.Ptr (CZabrInterpolatedSmileSection)) -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO (C2HSImp.Ptr (CSmileSection)))))
5445
5446 foreign import ccall safe "QuantLib/TermStructure/Volatility.chs.h qlZabrInterpolatedSmileSectionAlpha"
5447 zabrInterpolatedAlpha'_ :: ((C2HSImp.Ptr (CZabrInterpolatedSmileSection)) -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO C2HSImp.CDouble)))
5448
5449 foreign import ccall safe "QuantLib/TermStructure/Volatility.chs.h qlZabrInterpolatedSmileSectionBeta"
5450 zabrInterpolatedBeta'_ :: ((C2HSImp.Ptr (CZabrInterpolatedSmileSection)) -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO C2HSImp.CDouble)))
5451
5452 foreign import ccall safe "QuantLib/TermStructure/Volatility.chs.h qlZabrInterpolatedSmileSectionNu"
5453 zabrInterpolatedNu'_ :: ((C2HSImp.Ptr (CZabrInterpolatedSmileSection)) -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO C2HSImp.CDouble)))
5454
5455 foreign import ccall safe "QuantLib/TermStructure/Volatility.chs.h qlZabrInterpolatedSmileSectionRho"
5456 zabrInterpolatedRho'_ :: ((C2HSImp.Ptr (CZabrInterpolatedSmileSection)) -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO C2HSImp.CDouble)))
5457
5458 foreign import ccall safe "QuantLib/TermStructure/Volatility.chs.h qlZabrInterpolatedSmileSectionGamma"
5459 zabrInterpolatedGamma'_ :: ((C2HSImp.Ptr (CZabrInterpolatedSmileSection)) -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO C2HSImp.CDouble)))
5460
5461 foreign import ccall safe "QuantLib/TermStructure/Volatility.chs.h qlZabrInterpolatedSmileSectionRmsError"
5462 zabrInterpolatedRmsError'_ :: ((C2HSImp.Ptr (CZabrInterpolatedSmileSection)) -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO C2HSImp.CDouble)))
5463
5464 foreign import ccall safe "QuantLib/TermStructure/Volatility.chs.h qlZabrInterpolatedSmileSectionMaxError"
5465 zabrInterpolatedMaxError'_ :: ((C2HSImp.Ptr (CZabrInterpolatedSmileSection)) -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO C2HSImp.CDouble)))
5466
5467 foreign import ccall safe "QuantLib/TermStructure/Volatility.chs.h qlZabrInterpolatedSmileSectionEndCriteria"
5468 zabrInterpolatedEndCriteria'_ :: ((C2HSImp.Ptr (CZabrInterpolatedSmileSection)) -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO C2HSImp.CInt)))
5469
5470 foreign import ccall safe "QuantLib/TermStructure/Volatility.chs.h qlSwaptionVolatilityStructureSwapLength1"
5471 swapLengthBetweenDates'_ :: ((C2HSImp.Ptr (CSwaptionVolatilityStructure')) -> (C2HSImp.CInt -> (C2HSImp.CInt -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO C2HSImp.CDouble)))))
5472
5473 foreign import ccall safe "QuantLib/TermStructure/Volatility.chs.h qlSwaptionVolatilityStructureSwapLength"
5474 swapLength'_ :: ((C2HSImp.Ptr (CSwaptionVolatilityStructure')) -> (C2HSImp.CInt -> (C2HSImp.CInt -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO C2HSImp.CDouble)))))
5475
5476 foreign import ccall safe "QuantLib/TermStructure/Volatility.chs.h qlSwaptionVolatilityStructureVolatility1"
5477 volatilityDateTenor'_ :: ((C2HSImp.Ptr (CSwaptionVolatilityStructure')) -> (C2HSImp.CInt -> (C2HSImp.CInt -> (C2HSImp.CInt -> (C2HSImp.CDouble -> (C2HSImp.CInt -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO C2HSImp.CDouble))))))))
5478
5479 foreign import ccall safe "QuantLib/TermStructure/Volatility.chs.h qlSwaptionVolatilityStructureVolatility2"
5480 volatilityTimeTenor'_ :: ((C2HSImp.Ptr (CSwaptionVolatilityStructure')) -> (C2HSImp.CDouble -> (C2HSImp.CInt -> (C2HSImp.CInt -> (C2HSImp.CDouble -> (C2HSImp.CInt -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO C2HSImp.CDouble))))))))
5481
5482 foreign import ccall safe "QuantLib/TermStructure/Volatility.chs.h qlSwaptionVolatilityStructureVolatility3"
5483 volatilityTenorLength'_ :: ((C2HSImp.Ptr (CSwaptionVolatilityStructure')) -> (C2HSImp.CInt -> (C2HSImp.CInt -> (C2HSImp.CDouble -> (C2HSImp.CDouble -> (C2HSImp.CInt -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO C2HSImp.CDouble))))))))
5484
5485 foreign import ccall safe "QuantLib/TermStructure/Volatility.chs.h qlSwaptionVolatilityStructureVolatility4"
5486 volatilityDateLength'_ :: ((C2HSImp.Ptr (CSwaptionVolatilityStructure')) -> (C2HSImp.CInt -> (C2HSImp.CDouble -> (C2HSImp.CDouble -> (C2HSImp.CInt -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO C2HSImp.CDouble)))))))
5487
5488 foreign import ccall safe "QuantLib/TermStructure/Volatility.chs.h qlSwaptionVolatilityStructureVolatility5"
5489 volatilityTimeLength'_ :: ((C2HSImp.Ptr (CSwaptionVolatilityStructure')) -> (C2HSImp.CDouble -> (C2HSImp.CDouble -> (C2HSImp.CDouble -> (C2HSImp.CInt -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO C2HSImp.CDouble)))))))
5490
5491 foreign import ccall safe "QuantLib/TermStructure/Volatility.chs.h qlSwaptionVolatilityStructureVolatility"
5492 volatilityTenorTenor'_ :: ((C2HSImp.Ptr (CSwaptionVolatilityStructure')) -> (C2HSImp.CInt -> (C2HSImp.CInt -> (C2HSImp.CInt -> (C2HSImp.CInt -> (C2HSImp.CDouble -> (C2HSImp.CInt -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO C2HSImp.CDouble)))))))))
5493
5494 foreign import ccall safe "QuantLib/TermStructure/Volatility.chs.h qlCallableBondConstantVolatility1"
5495 callableBondConstantVolatilityMovingRaw'_ :: (C2HSImp.CUInt -> ((C2HSImp.Ptr (CCalendar)) -> ((C2HSImp.Ptr (CQuote')) -> ((C2HSImp.Ptr (CDayCounter)) -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO (C2HSImp.Ptr (CCallableBondVolatilityStructure'))))))))
5496
5497 foreign import ccall safe "QuantLib/TermStructure/Volatility.chs.h qlCallableBondConstantVolatility"
5498 callableBondConstantVolatilityFixed'_ :: (C2HSImp.CInt -> ((C2HSImp.Ptr (CQuote')) -> ((C2HSImp.Ptr (CDayCounter)) -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO (C2HSImp.Ptr (CCallableBondVolatilityStructure')))))))
5499
5500 foreign import ccall safe "QuantLib/TermStructure/Volatility.chs.h qlCallableBondVolatilityStructureVolatilityForTime"
5501 qlCallableBondVolatilityStructureVolatilityForTime'_ :: ((C2HSImp.Ptr (CCallableBondVolatilityStructure')) -> (C2HSImp.CDouble -> (C2HSImp.CDouble -> (C2HSImp.CDouble -> (C2HSImp.CInt -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO C2HSImp.CDouble)))))))
5502
5503 foreign import ccall safe "QuantLib/TermStructure/Volatility.chs.h qlCallableBondVolatilityStructureVolatilityForDate"
5504 qlCallableBondVolatilityStructureVolatilityForDate'_ :: ((C2HSImp.Ptr (CCallableBondVolatilityStructure')) -> (C2HSImp.CInt -> (C2HSImp.CInt -> (C2HSImp.CInt -> (C2HSImp.CDouble -> (C2HSImp.CInt -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO C2HSImp.CDouble))))))))
5505
5506 foreign import ccall safe "QuantLib/TermStructure/Volatility.chs.h qlCallableBondVolatilityStructureVolatilityForPeriod"
5507 qlCallableBondVolatilityStructureVolatilityForPeriod'_ :: ((C2HSImp.Ptr (CCallableBondVolatilityStructure')) -> (C2HSImp.CInt -> (C2HSImp.CInt -> (C2HSImp.CInt -> (C2HSImp.CInt -> (C2HSImp.CDouble -> (C2HSImp.CInt -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO C2HSImp.CDouble)))))))))
5508
5509 foreign import ccall safe "QuantLib/TermStructure/Volatility.chs.h qlCallableBondVolatilityStructureBlackVarianceForTime"
5510 qlCallableBondVolatilityStructureBlackVarianceForTime'_ :: ((C2HSImp.Ptr (CCallableBondVolatilityStructure')) -> (C2HSImp.CDouble -> (C2HSImp.CDouble -> (C2HSImp.CDouble -> (C2HSImp.CInt -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO C2HSImp.CDouble)))))))
5511
5512 foreign import ccall safe "QuantLib/TermStructure/Volatility.chs.h qlCallableBondVolatilityStructureBlackVarianceForDate"
5513 qlCallableBondVolatilityStructureBlackVarianceForDate'_ :: ((C2HSImp.Ptr (CCallableBondVolatilityStructure')) -> (C2HSImp.CInt -> (C2HSImp.CInt -> (C2HSImp.CInt -> (C2HSImp.CDouble -> (C2HSImp.CInt -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO C2HSImp.CDouble))))))))
5514
5515 foreign import ccall safe "QuantLib/TermStructure/Volatility.chs.h qlCallableBondVolatilityStructureBlackVarianceForPeriod"
5516 qlCallableBondVolatilityStructureBlackVarianceForPeriod'_ :: ((C2HSImp.Ptr (CCallableBondVolatilityStructure')) -> (C2HSImp.CInt -> (C2HSImp.CInt -> (C2HSImp.CInt -> (C2HSImp.CInt -> (C2HSImp.CDouble -> (C2HSImp.CInt -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO C2HSImp.CDouble)))))))))
5517
5518 foreign import ccall safe "QuantLib/TermStructure/Volatility.chs.h qlCallableBondVolatilityStructureSmileSectionForDate"
5519 callableBondSmileSectionAtDateRaw'_ :: ((C2HSImp.Ptr (CCallableBondVolatilityStructure')) -> (C2HSImp.CInt -> (C2HSImp.CInt -> (C2HSImp.CInt -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO (C2HSImp.Ptr (CSmileSection))))))))
5520
5521 foreign import ccall safe "QuantLib/TermStructure/Volatility.chs.h qlCallableBondVolatilityStructureSmileSectionForPeriod"
5522 callableBondSmileSectionForTenorsRaw'_ :: ((C2HSImp.Ptr (CCallableBondVolatilityStructure')) -> (C2HSImp.CInt -> (C2HSImp.CInt -> (C2HSImp.CInt -> (C2HSImp.CInt -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO (C2HSImp.Ptr (CSmileSection)))))))))
5523
5524 foreign import ccall safe "QuantLib/TermStructure/Volatility.chs.h qlCallableBondVolatilityStructureMaxBondTenor"
5525 maxBondTenor'_ :: ((C2HSImp.Ptr (CCallableBondVolatilityStructure')) -> ((C2HSImp.Ptr C2HSImp.CInt) -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO C2HSImp.CInt))))
5526
5527 foreign import ccall safe "QuantLib/TermStructure/Volatility.chs.h qlCallableBondVolatilityStructureMinStrike"
5528 minStrikeCallableBondRaw'_ :: ((C2HSImp.Ptr (CCallableBondVolatilityStructure')) -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO C2HSImp.CDouble)))
5529
5530 foreign import ccall safe "QuantLib/TermStructure/Volatility.chs.h qlCallableBondVolatilityStructureMaxStrike"
5531 maxStrikeCallableBondRaw'_ :: ((C2HSImp.Ptr (CCallableBondVolatilityStructure')) -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO C2HSImp.CDouble)))
5532
5533 foreign import ccall safe "QuantLib/TermStructure/Volatility.chs.h qlVolatilityTermStructureMinStrike"
5534 minStrikeGenericRaw'_ :: ((C2HSImp.Ptr (CVolatilityTermStructure')) -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO C2HSImp.CDouble)))
5535
5536 foreign import ccall safe "QuantLib/TermStructure/Volatility.chs.h qlVolatilityTermStructureMaxStrike"
5537 maxStrikeGenericRaw'_ :: ((C2HSImp.Ptr (CVolatilityTermStructure')) -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO C2HSImp.CDouble)))
5538
5539 foreign import ccall safe "QuantLib/TermStructure/Volatility.chs.h qlVolatilityTermStructureOptionDateFromTenor"
5540 optionDateFromTenor'_ :: ((C2HSImp.Ptr (CVolatilityTermStructure')) -> (C2HSImp.CInt -> (C2HSImp.CInt -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO C2HSImp.CInt)))))
5541
5542 foreign import ccall safe "QuantLib/TermStructure/Volatility.chs.h qlConstantCapFloorTermVolatility1"
5543 constantCapFloorTermVolatilityFixed'_ :: (C2HSImp.CInt -> ((C2HSImp.Ptr (CCalendar)) -> (C2HSImp.CInt -> ((C2HSImp.Ptr (CQuote')) -> ((C2HSImp.Ptr (CDayCounter)) -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO (C2HSImp.Ptr (CCapFloorTermVolatilityStructure')))))))))
5544
5545 foreign import ccall safe "QuantLib/TermStructure/Volatility.chs.h qlConstantCapFloorTermVolatility"
5546 constantCapFloorTermVolatilityMovingRaw'_ :: (C2HSImp.CUInt -> ((C2HSImp.Ptr (CCalendar)) -> (C2HSImp.CInt -> ((C2HSImp.Ptr (CQuote')) -> ((C2HSImp.Ptr (CDayCounter)) -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO (C2HSImp.Ptr (CCapFloorTermVolatilityStructure')))))))))
5547
5548 foreign import ccall safe "QuantLib/TermStructure/Volatility.chs.h qlCapFloorTermVolatilityStructureVolatilityForPeriod"
5549 capFloorVolatilityForTenorRaw'_ :: ((C2HSImp.Ptr (CCapFloorTermVolatilityStructure')) -> (C2HSImp.CInt -> (C2HSImp.CInt -> (C2HSImp.CDouble -> (C2HSImp.CInt -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO C2HSImp.CDouble)))))))
5550
5551 foreign import ccall safe "QuantLib/TermStructure/Volatility.chs.h qlCapFloorTermVolatilityStructureVolatilityForDate"
5552 capFloorVolatilityAtDateRaw'_ :: ((C2HSImp.Ptr (CCapFloorTermVolatilityStructure')) -> (C2HSImp.CInt -> (C2HSImp.CDouble -> (C2HSImp.CInt -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO C2HSImp.CDouble))))))
5553
5554 foreign import ccall safe "QuantLib/TermStructure/Volatility.chs.h qlCapFloorTermVolatilityStructureVolatilityForTime"
5555 capFloorVolatilityAtTimeRaw'_ :: ((C2HSImp.Ptr (CCapFloorTermVolatilityStructure')) -> (C2HSImp.CDouble -> (C2HSImp.CDouble -> (C2HSImp.CInt -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO C2HSImp.CDouble))))))
5556
5557 foreign import ccall safe "QuantLib/TermStructure/Volatility.chs.h qlCapFloorTermVolCurveOptionDates"
5558 capFloorTermVolCurveOptionDates'_ :: ((C2HSImp.Ptr (CCapFloorTermVolCurve')) -> ((C2HSImp.Ptr C2HSImp.CUInt) -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CInt)) -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO ())))))
5559
5560 foreign import ccall safe "QuantLib/TermStructure/Volatility.chs.h qlCapFloorTermVolCurveOptionTimes"
5561 capFloorTermVolCurveOptionTimes'_ :: ((C2HSImp.Ptr (CCapFloorTermVolCurve')) -> ((C2HSImp.Ptr C2HSImp.CUInt) -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CDouble)) -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO ())))))
5562
5563 foreign import ccall safe "QuantLib/TermStructure/Volatility.chs.h qlCapFloorTermVolSurfaceOptionDates"
5564 capFloorTermVolSurfaceOptionDates'_ :: ((C2HSImp.Ptr (CCapFloorTermVolSurface')) -> ((C2HSImp.Ptr C2HSImp.CUInt) -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CInt)) -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO ())))))
5565
5566 foreign import ccall safe "QuantLib/TermStructure/Volatility.chs.h qlCapFloorTermVolSurfaceOptionTimes"
5567 capFloorTermVolSurfaceOptionTimes'_ :: ((C2HSImp.Ptr (CCapFloorTermVolSurface')) -> ((C2HSImp.Ptr C2HSImp.CUInt) -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CDouble)) -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO ())))))
5568
5569 foreign import ccall safe "QuantLib/TermStructure/Volatility.chs.h qlBlackAtmVolCurveAtmVolForPeriod"
5570 atmVolForTenorRaw'_ :: ((C2HSImp.Ptr (CBlackAtmVolCurve')) -> (C2HSImp.CInt -> (C2HSImp.CInt -> (C2HSImp.CInt -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO C2HSImp.CDouble))))))
5571
5572 foreign import ccall safe "QuantLib/TermStructure/Volatility.chs.h qlBlackAtmVolCurveAtmVolForDate"
5573 atmVolAtDateRaw'_ :: ((C2HSImp.Ptr (CBlackAtmVolCurve')) -> (C2HSImp.CInt -> (C2HSImp.CInt -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO C2HSImp.CDouble)))))
5574
5575 foreign import ccall safe "QuantLib/TermStructure/Volatility.chs.h qlBlackAtmVolCurveAtmVolForTime"
5576 atmVolAtTimeRaw'_ :: ((C2HSImp.Ptr (CBlackAtmVolCurve')) -> (C2HSImp.CDouble -> (C2HSImp.CInt -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO C2HSImp.CDouble)))))
5577
5578 foreign import ccall safe "QuantLib/TermStructure/Volatility.chs.h qlBlackAtmVolCurveAtmVarianceForPeriod"
5579 atmVarianceForTenorRaw'_ :: ((C2HSImp.Ptr (CBlackAtmVolCurve')) -> (C2HSImp.CInt -> (C2HSImp.CInt -> (C2HSImp.CInt -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO C2HSImp.CDouble))))))
5580
5581 foreign import ccall safe "QuantLib/TermStructure/Volatility.chs.h qlBlackAtmVolCurveAtmVarianceForDate"
5582 atmVarianceAtDateRaw'_ :: ((C2HSImp.Ptr (CBlackAtmVolCurve')) -> (C2HSImp.CInt -> (C2HSImp.CInt -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO C2HSImp.CDouble)))))
5583
5584 foreign import ccall safe "QuantLib/TermStructure/Volatility.chs.h qlBlackAtmVolCurveAtmVarianceForTime"
5585 atmVarianceAtTimeRaw'_ :: ((C2HSImp.Ptr (CBlackAtmVolCurve')) -> (C2HSImp.CDouble -> (C2HSImp.CInt -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO C2HSImp.CDouble)))))
5586
5587 foreign import ccall safe "QuantLib/TermStructure/Volatility.chs.h qlBlackVolSurfaceSmileSectionForPeriod"
5588 blackVolSurfaceSmileSectionForTenorRaw'_ :: ((C2HSImp.Ptr (CBlackVolSurface')) -> (C2HSImp.CInt -> (C2HSImp.CInt -> (C2HSImp.CInt -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO (C2HSImp.Ptr (CSmileSection))))))))
5589
5590 foreign import ccall safe "QuantLib/TermStructure/Volatility.chs.h qlBlackVolSurfaceSmileSectionForDate"
5591 blackVolSurfaceSmileSectionAtDateRaw'_ :: ((C2HSImp.Ptr (CBlackVolSurface')) -> (C2HSImp.CInt -> (C2HSImp.CInt -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO (C2HSImp.Ptr (CSmileSection)))))))
5592
5593 foreign import ccall safe "QuantLib/TermStructure/Volatility.chs.h qlBlackVolSurfaceSmileSectionForTime"
5594 blackVolSurfaceSmileSectionAtTimeRaw'_ :: ((C2HSImp.Ptr (CBlackVolSurface')) -> (C2HSImp.CDouble -> (C2HSImp.CInt -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO (C2HSImp.Ptr (CSmileSection)))))))
5595
5596 foreign import ccall safe "QuantLib/TermStructure/Volatility.chs.h qlAbcdAtmVolCurve"
5597 qlAbcdAtmVolCurve'_ :: (C2HSImp.CUInt -> ((C2HSImp.Ptr (CCalendar)) -> (C2HSImp.CUInt -> ((C2HSImp.Ptr C2HSImp.CInt) -> (C2HSImp.CUInt -> ((C2HSImp.Ptr C2HSImp.CInt) -> (C2HSImp.CUInt -> ((C2HSImp.Ptr (C2HSImp.Ptr (CQuote'))) -> (C2HSImp.CUInt -> ((C2HSImp.Ptr C2HSImp.CInt) -> (C2HSImp.CInt -> ((C2HSImp.Ptr (CDayCounter)) -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO (C2HSImp.Ptr (CAbcdAtmVolCurve'))))))))))))))))
5598
5599 foreign import ccall safe "QuantLib/TermStructure/Volatility.chs.h qlAbcdAtmVolCurveA"
5600 abcdA'_ :: ((C2HSImp.Ptr (CAbcdAtmVolCurve')) -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO C2HSImp.CDouble)))
5601
5602 foreign import ccall safe "QuantLib/TermStructure/Volatility.chs.h qlAbcdAtmVolCurveB"
5603 abcdB'_ :: ((C2HSImp.Ptr (CAbcdAtmVolCurve')) -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO C2HSImp.CDouble)))
5604
5605 foreign import ccall safe "QuantLib/TermStructure/Volatility.chs.h qlAbcdAtmVolCurveC"
5606 abcdC'_ :: ((C2HSImp.Ptr (CAbcdAtmVolCurve')) -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO C2HSImp.CDouble)))
5607
5608 foreign import ccall safe "QuantLib/TermStructure/Volatility.chs.h qlAbcdAtmVolCurveD"
5609 abcdD'_ :: ((C2HSImp.Ptr (CAbcdAtmVolCurve')) -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO C2HSImp.CDouble)))
5610
5611 foreign import ccall safe "QuantLib/TermStructure/Volatility.chs.h qlAbcdAtmVolCurveRmsError"
5612 abcdRmsError'_ :: ((C2HSImp.Ptr (CAbcdAtmVolCurve')) -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO C2HSImp.CDouble)))
5613
5614 foreign import ccall safe "QuantLib/TermStructure/Volatility.chs.h qlAbcdAtmVolCurveMaxError"
5615 abcdMaxError'_ :: ((C2HSImp.Ptr (CAbcdAtmVolCurve')) -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO C2HSImp.CDouble)))
5616
5617 foreign import ccall safe "QuantLib/TermStructure/Volatility.chs.h qlAbcdAtmVolCurveEndCriteria"
5618 abcdEndCriteria'_ :: ((C2HSImp.Ptr (CAbcdAtmVolCurve')) -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO C2HSImp.CInt)))
5619
5620 foreign import ccall safe "QuantLib/TermStructure/Volatility.chs.h qlAbcdAtmVolCurveKAtTime"
5621 abcdK'_ :: ((C2HSImp.Ptr (CAbcdAtmVolCurve')) -> (C2HSImp.CDouble -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO C2HSImp.CDouble))))
5622
5623 foreign import ccall safe "QuantLib/TermStructure/Volatility.chs.h qlAbcdAtmVolCurveK"
5624 abcdKs'_ :: ((C2HSImp.Ptr (CAbcdAtmVolCurve')) -> ((C2HSImp.Ptr C2HSImp.CUInt) -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CDouble)) -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO ())))))
5625
5626 foreign import ccall safe "QuantLib/TermStructure/Volatility.chs.h qlAbcdAtmVolCurveOptionTenors"
5627 qlAbcdAtmVolCurveOptionTenors'_ :: ((C2HSImp.Ptr (CAbcdAtmVolCurve')) -> ((C2HSImp.Ptr C2HSImp.CUInt) -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CInt)) -> ((C2HSImp.Ptr C2HSImp.CUInt) -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CInt)) -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO ())))))))
5628
5629 foreign import ccall safe "QuantLib/TermStructure/Volatility.chs.h qlAbcdAtmVolCurveOptionTenorsInInterpolation"
5630 qlAbcdAtmVolCurveOptionTenorsInInterpolation'_ :: ((C2HSImp.Ptr (CAbcdAtmVolCurve')) -> ((C2HSImp.Ptr C2HSImp.CUInt) -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CInt)) -> ((C2HSImp.Ptr C2HSImp.CUInt) -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CInt)) -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO ())))))))
5631
5632 foreign import ccall safe "QuantLib/TermStructure/Volatility.chs.h qlAbcdAtmVolCurveOptionDates"
5633 abcdOptionDates'_ :: ((C2HSImp.Ptr (CAbcdAtmVolCurve')) -> ((C2HSImp.Ptr C2HSImp.CUInt) -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CInt)) -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO ())))))
5634
5635 foreign import ccall safe "QuantLib/TermStructure/Volatility.chs.h qlAbcdAtmVolCurveOptionTimes"
5636 abcdOptionTimes'_ :: ((C2HSImp.Ptr (CAbcdAtmVolCurve')) -> ((C2HSImp.Ptr C2HSImp.CUInt) -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CDouble)) -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO ())))))
5637
5638 foreign import ccall safe "QuantLib/TermStructure/Volatility.chs.h qlSabrVolSurface"
5639 qlSabrVolSurface'_ :: ((C2HSImp.Ptr (CInterestRateIndex')) -> ((C2HSImp.Ptr (CBlackAtmVolCurve')) -> (C2HSImp.CUInt -> ((C2HSImp.Ptr C2HSImp.CInt) -> (C2HSImp.CUInt -> ((C2HSImp.Ptr C2HSImp.CInt) -> (C2HSImp.CUInt -> ((C2HSImp.Ptr C2HSImp.CDouble) -> (C2HSImp.CUInt -> (C2HSImp.CUInt -> ((C2HSImp.Ptr (C2HSImp.Ptr (CQuote'))) -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO (C2HSImp.Ptr (CSabrVolSurface')))))))))))))))
5640
5641 foreign import ccall safe "QuantLib/TermStructure/Volatility.chs.h qlSabrVolSurfaceAtmCurve"
5642 sabrVolSurfaceAtmCurve'_ :: ((C2HSImp.Ptr (CSabrVolSurface')) -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO (C2HSImp.Ptr (CBlackAtmVolCurve')))))
5643
5644 foreign import ccall safe "QuantLib/TermStructure/Volatility.chs.h qlSabrVolSurfaceVolatilitySpreadsForPeriod"
5645 sabrVolSurfaceVolatilitySpreadsForTenorRaw'_ :: ((C2HSImp.Ptr (CSabrVolSurface')) -> (C2HSImp.CInt -> (C2HSImp.CInt -> ((C2HSImp.Ptr C2HSImp.CUInt) -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CDouble)) -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO ())))))))
5646
5647 foreign import ccall safe "QuantLib/TermStructure/Volatility.chs.h qlSabrVolSurfaceVolatilitySpreadsForDate"
5648 sabrVolSurfaceVolatilitySpreadsAtDateRaw'_ :: ((C2HSImp.Ptr (CSabrVolSurface')) -> (C2HSImp.CInt -> ((C2HSImp.Ptr C2HSImp.CUInt) -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CDouble)) -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO ()))))))
5649
5650 foreign import ccall safe "QuantLib/TermStructure/Volatility.chs.h qlSabrVolSurfaceIndex"
5651 sabrVolSurfaceIndex'_ :: ((C2HSImp.Ptr (CSabrVolSurface')) -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO (C2HSImp.Ptr (CInterestRateIndex')))))
5652
5653 foreign import ccall safe "QuantLib/TermStructure/Volatility.chs.h qlSabrVolSurfaceOptionDateFromTenor"
5654 sabrVolSurfaceOptionDateFromTenor'_ :: ((C2HSImp.Ptr (CSabrVolSurface')) -> (C2HSImp.CInt -> (C2HSImp.CInt -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO C2HSImp.CInt)))))
5655
5656 foreign import ccall safe "QuantLib/TermStructure/Volatility.chs.h qlSpreadedSwaptionVolatility"
5657 spreadedSwaptionVolatility'_ :: ((C2HSImp.Ptr (CSwaptionVolatilityStructure')) -> ((C2HSImp.Ptr (CQuote')) -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO (C2HSImp.Ptr (CSwaptionVolatilityStructure'))))))
5658
5659 foreign import ccall safe "QuantLib/TermStructure/Volatility.chs.h qlGaussian1dSwaptionVolatility"
5660 gaussian1dSwaptionVolatility'_ :: ((C2HSImp.Ptr (CCalendar)) -> (C2HSImp.CInt -> ((C2HSImp.Ptr (CSwapIndex')) -> ((C2HSImp.Ptr (CGaussian1dModel')) -> ((C2HSImp.Ptr (CDayCounter)) -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO (C2HSImp.Ptr (CSwaptionVolatilityStructure')))))))))
5661
5662 foreign import ccall safe "QuantLib/TermStructure/Volatility.chs.h qlSpreadedOptionletVolatility"
5663 spreadedOptionletVol'_ :: ((C2HSImp.Ptr (COptionletVolatilityStructure')) -> ((C2HSImp.Ptr (CQuote')) -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO (C2HSImp.Ptr (COptionletVolatilityStructure'))))))
5664
5665 foreign import ccall safe "QuantLib/TermStructure/Volatility.chs.h qlRelinkableSwaptionVolatilityStructure"
5666 relinkableSwaptionVolatilityStructure'_ :: ((C2HSImp.Ptr (CSwaptionVolatilityStructure')) -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO (C2HSImp.Ptr (CRelinkableSwaptionVolatilityStructure')))))
5667
5668 foreign import ccall safe "QuantLib/TermStructure/Volatility.chs.h qlRelinkableSwaptionVolatilityStructureLinkTo"
5669 linkSwaptionVolTo'_ :: ((C2HSImp.Ptr (CRelinkableSwaptionVolatilityStructure')) -> ((C2HSImp.Ptr (CSwaptionVolatilityStructure')) -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO ()))))
5670
5671 foreign import ccall safe "QuantLib/TermStructure/Volatility.chs.h qlLocalConstantVol1"
5672 localConstantVolMovingRaw'_ :: (C2HSImp.CUInt -> ((C2HSImp.Ptr (CCalendar)) -> ((C2HSImp.Ptr (CQuote')) -> ((C2HSImp.Ptr (CDayCounter)) -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO (C2HSImp.Ptr (CLocalVolTermStructure'))))))))
5673
5674 foreign import ccall safe "QuantLib/TermStructure/Volatility.chs.h qlLocalConstantVol"
5675 localConstantVolFixed'_ :: (C2HSImp.CInt -> ((C2HSImp.Ptr (CQuote')) -> ((C2HSImp.Ptr (CDayCounter)) -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO (C2HSImp.Ptr (CLocalVolTermStructure')))))))
5676
5677 foreign import ccall safe "QuantLib/TermStructure/Volatility.chs.h qlLocalVolCurve"
5678 localVolCurve'_ :: ((C2HSImp.Ptr (CBlackVarianceCurve')) -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO (C2HSImp.Ptr (CLocalVolTermStructure')))))
5679
5680 foreign import ccall safe "QuantLib/TermStructure/Volatility.chs.h qlImpliedVolTermStructure"
5681 impliedVolTermStructure'_ :: ((C2HSImp.Ptr (CBlackVolTermStructure')) -> (C2HSImp.CInt -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO (C2HSImp.Ptr (CBlackVolTermStructure'))))))
5682
5683 foreign import ccall safe "QuantLib/TermStructure/Volatility.chs.h qlCapFloorTermVolCurve1"
5684 qlCapFloorTermVolCurveFixed'_ :: (C2HSImp.CInt -> ((C2HSImp.Ptr (CCalendar)) -> (C2HSImp.CInt -> (C2HSImp.CUInt -> ((C2HSImp.Ptr C2HSImp.CInt) -> (C2HSImp.CUInt -> ((C2HSImp.Ptr C2HSImp.CInt) -> (C2HSImp.CUInt -> ((C2HSImp.Ptr (C2HSImp.Ptr (CQuote'))) -> ((C2HSImp.Ptr (CDayCounter)) -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO (C2HSImp.Ptr (CCapFloorTermVolCurve'))))))))))))))
5685
5686 foreign import ccall safe "QuantLib/TermStructure/Volatility.chs.h qlCapFloorTermVolCurve"
5687 qlCapFloorTermVolCurveMovingRaw'_ :: (C2HSImp.CUInt -> ((C2HSImp.Ptr (CCalendar)) -> (C2HSImp.CInt -> (C2HSImp.CUInt -> ((C2HSImp.Ptr C2HSImp.CInt) -> (C2HSImp.CUInt -> ((C2HSImp.Ptr C2HSImp.CInt) -> (C2HSImp.CUInt -> ((C2HSImp.Ptr (C2HSImp.Ptr (CQuote'))) -> ((C2HSImp.Ptr (CDayCounter)) -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO (C2HSImp.Ptr (CCapFloorTermVolCurve'))))))))))))))
5688
5689 foreign import ccall safe "QuantLib/TermStructure/Volatility.chs.h qlBlackVarianceCurve"
5690 qlBlackVarianceCurve'_ :: (C2HSImp.CInt -> (C2HSImp.CUInt -> ((C2HSImp.Ptr C2HSImp.CInt) -> (C2HSImp.CUInt -> ((C2HSImp.Ptr C2HSImp.CDouble) -> ((C2HSImp.Ptr (CDayCounter)) -> (C2HSImp.CInt -> (C2HSImp.CInt -> (C2HSImp.CInt -> (C2HSImp.CInt -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO (C2HSImp.Ptr (CBlackVarianceCurve'))))))))))))))
5691
5692 foreign import ccall safe "QuantLib/TermStructure/Volatility.chs.h qlBlackVarianceSurface"
5693 qlBlackVarianceSurface'_ :: (C2HSImp.CInt -> ((C2HSImp.Ptr (CCalendar)) -> (C2HSImp.CUInt -> ((C2HSImp.Ptr C2HSImp.CInt) -> (C2HSImp.CUInt -> ((C2HSImp.Ptr C2HSImp.CDouble) -> (C2HSImp.CUInt -> (C2HSImp.CUInt -> ((C2HSImp.Ptr C2HSImp.CDouble) -> ((C2HSImp.Ptr (CDayCounter)) -> (C2HSImp.CInt -> (C2HSImp.CInt -> (C2HSImp.CInt -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO (C2HSImp.Ptr (CBlackVolTermStructure')))))))))))))))))
5694
5695 foreign import ccall safe "QuantLib/TermStructure/Volatility.chs.h qlExtendedBlackVarianceCurve"
5696 qlExtendedBlackVarianceCurve'_ :: (C2HSImp.CInt -> (C2HSImp.CUInt -> ((C2HSImp.Ptr C2HSImp.CInt) -> (C2HSImp.CUInt -> ((C2HSImp.Ptr (C2HSImp.Ptr (CQuote'))) -> ((C2HSImp.Ptr (CDayCounter)) -> (C2HSImp.CInt -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO (C2HSImp.Ptr (CBlackVolTermStructure')))))))))))
5697
5698 foreign import ccall safe "QuantLib/TermStructure/Volatility.chs.h qlExtendedBlackVarianceSurface"
5699 qlExtendedBlackVarianceSurface'_ :: (C2HSImp.CInt -> ((C2HSImp.Ptr (CCalendar)) -> (C2HSImp.CUInt -> ((C2HSImp.Ptr C2HSImp.CInt) -> (C2HSImp.CUInt -> ((C2HSImp.Ptr C2HSImp.CDouble) -> (C2HSImp.CUInt -> (C2HSImp.CUInt -> ((C2HSImp.Ptr (C2HSImp.Ptr (CQuote'))) -> ((C2HSImp.Ptr (CDayCounter)) -> (C2HSImp.CInt -> (C2HSImp.CInt -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO (C2HSImp.Ptr (CBlackVolTermStructure'))))))))))))))))
5700
5701 foreign import ccall safe "QuantLib/TermStructure/Volatility.chs.h qlPiecewiseBlackVarianceSurface"
5702 qlPiecewiseBlackVarianceSurface'_ :: (C2HSImp.CInt -> (C2HSImp.CUInt -> ((C2HSImp.Ptr C2HSImp.CInt) -> (C2HSImp.CUInt -> ((C2HSImp.Ptr C2HSImp.CDouble) -> (C2HSImp.CUInt -> (C2HSImp.CUInt -> ((C2HSImp.Ptr C2HSImp.CDouble) -> ((C2HSImp.Ptr (CDayCounter)) -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO (C2HSImp.Ptr (CBlackVolTermStructure')))))))))))))
5703
5704 foreign import ccall safe "QuantLib/TermStructure/Volatility.chs.h qlBlackVolatilitySurfaceDelta"
5705 blackVolatilitySurfaceDelta_'_ :: (C2HSImp.CInt -> (C2HSImp.CUInt -> ((C2HSImp.Ptr C2HSImp.CInt) -> (C2HSImp.CUInt -> ((C2HSImp.Ptr C2HSImp.CDouble) -> (C2HSImp.CUInt -> ((C2HSImp.Ptr C2HSImp.CDouble) -> (C2HSImp.CInt -> (C2HSImp.CUInt -> (C2HSImp.CUInt -> ((C2HSImp.Ptr C2HSImp.CDouble) -> ((C2HSImp.Ptr (CDayCounter)) -> ((C2HSImp.Ptr (CCalendar)) -> ((C2HSImp.Ptr (CQuote')) -> ((C2HSImp.Ptr (CYieldTermStructure')) -> ((C2HSImp.Ptr (CYieldTermStructure')) -> (C2HSImp.CInt -> (C2HSImp.CInt -> (C2HSImp.CInt -> (C2HSImp.CInt -> (C2HSImp.CInt -> (C2HSImp.CInt -> (C2HSImp.CInt -> (C2HSImp.CInt -> (C2HSImp.CInt -> (C2HSImp.CInt -> (C2HSImp.CInt -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO (C2HSImp.Ptr (CBlackVolatilitySurfaceDelta')))))))))))))))))))))))))))))))
5706
5707 foreign import ccall safe "QuantLib/TermStructure/Volatility.chs.h qlBlackVolatilitySurfaceDeltaSmile1"
5708 blackVolSmileAtTimeRaw'_ :: ((C2HSImp.Ptr (CBlackVolatilitySurfaceDelta')) -> (C2HSImp.CDouble -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO (C2HSImp.Ptr (CSmileSection))))))
5709
5710 foreign import ccall safe "QuantLib/TermStructure/Volatility.chs.h qlBlackVolatilitySurfaceDeltaSmile"
5711 blackVolSmileAtDateRaw'_ :: ((C2HSImp.Ptr (CBlackVolatilitySurfaceDelta')) -> (C2HSImp.CInt -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO (C2HSImp.Ptr (CSmileSection))))))
5712
5713 foreign import ccall safe "QuantLib/TermStructure/Volatility.chs.h qlCapFloorTermVolSurface"
5714 qlCapFloorTermVolSurfaceMovingRaw'_ :: (C2HSImp.CUInt -> ((C2HSImp.Ptr (CCalendar)) -> (C2HSImp.CInt -> (C2HSImp.CUInt -> ((C2HSImp.Ptr C2HSImp.CInt) -> (C2HSImp.CUInt -> ((C2HSImp.Ptr C2HSImp.CInt) -> (C2HSImp.CUInt -> ((C2HSImp.Ptr C2HSImp.CDouble) -> (C2HSImp.CUInt -> (C2HSImp.CUInt -> ((C2HSImp.Ptr (C2HSImp.Ptr (CQuote'))) -> ((C2HSImp.Ptr (CDayCounter)) -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO (C2HSImp.Ptr (CCapFloorTermVolSurface')))))))))))))))))
5715
5716 foreign import ccall safe "QuantLib/TermStructure/Volatility.chs.h qlCapFloorTermVolSurface1"
5717 qlCapFloorTermVolSurfaceFixed'_ :: (C2HSImp.CInt -> ((C2HSImp.Ptr (CCalendar)) -> (C2HSImp.CInt -> (C2HSImp.CUInt -> ((C2HSImp.Ptr C2HSImp.CInt) -> (C2HSImp.CUInt -> ((C2HSImp.Ptr C2HSImp.CInt) -> (C2HSImp.CUInt -> ((C2HSImp.Ptr C2HSImp.CDouble) -> (C2HSImp.CUInt -> (C2HSImp.CUInt -> ((C2HSImp.Ptr (C2HSImp.Ptr (CQuote'))) -> ((C2HSImp.Ptr (CDayCounter)) -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO (C2HSImp.Ptr (CCapFloorTermVolSurface')))))))))))))))))
5718
5719 foreign import ccall safe "QuantLib/TermStructure/Volatility.chs.h qlSwaptionVolatilityMatrix"
5720 qlSwaptionVolatilityMatrix'_ :: (C2HSImp.CInt -> ((C2HSImp.Ptr (CCalendar)) -> (C2HSImp.CInt -> (C2HSImp.CUInt -> ((C2HSImp.Ptr C2HSImp.CInt) -> (C2HSImp.CUInt -> ((C2HSImp.Ptr C2HSImp.CInt) -> (C2HSImp.CUInt -> ((C2HSImp.Ptr C2HSImp.CInt) -> (C2HSImp.CUInt -> ((C2HSImp.Ptr C2HSImp.CInt) -> (C2HSImp.CUInt -> (C2HSImp.CUInt -> ((C2HSImp.Ptr (C2HSImp.Ptr (CQuote'))) -> ((C2HSImp.Ptr (CDayCounter)) -> (C2HSImp.CInt -> (C2HSImp.CInt -> (C2HSImp.CUInt -> (C2HSImp.CUInt -> ((C2HSImp.Ptr C2HSImp.CDouble) -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO (C2HSImp.Ptr (CSwaptionVolatilityMatrix'))))))))))))))))))))))))
5721
5722 foreign import ccall safe "QuantLib/TermStructure/Volatility.chs.h qlSwaptionVolatilityMatrix1"
5723 qlSwaptionVolatilityMatrix1'_ :: ((C2HSImp.Ptr (CCalendar)) -> (C2HSImp.CInt -> (C2HSImp.CUInt -> ((C2HSImp.Ptr C2HSImp.CInt) -> (C2HSImp.CUInt -> ((C2HSImp.Ptr C2HSImp.CInt) -> (C2HSImp.CUInt -> ((C2HSImp.Ptr C2HSImp.CInt) -> (C2HSImp.CUInt -> ((C2HSImp.Ptr C2HSImp.CInt) -> (C2HSImp.CUInt -> (C2HSImp.CUInt -> ((C2HSImp.Ptr (C2HSImp.Ptr (CQuote'))) -> ((C2HSImp.Ptr (CDayCounter)) -> (C2HSImp.CInt -> (C2HSImp.CInt -> (C2HSImp.CUInt -> (C2HSImp.CUInt -> ((C2HSImp.Ptr C2HSImp.CDouble) -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO (C2HSImp.Ptr (CSwaptionVolatilityMatrix')))))))))))))))))))))))
5724
5725 foreign import ccall safe "QuantLib/TermStructure/Volatility.chs.h qlSwaptionVolatilityMatrixLocate"
5726 qlSwaptionVolatilityMatrixLocate'_ :: ((C2HSImp.Ptr (CSwaptionVolatilityMatrix')) -> (C2HSImp.CInt -> (C2HSImp.CInt -> (C2HSImp.CInt -> ((C2HSImp.Ptr C2HSImp.CUInt) -> ((C2HSImp.Ptr C2HSImp.CUInt) -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO ()))))))))
5727
5728 foreign import ccall safe "QuantLib/TermStructure/Volatility.chs.h qlSabrSwaptionVolatilityCube"
5729 qlSabrSwaptionVolatilityCube'_ :: ((C2HSImp.Ptr (CSwaptionVolatilityStructure')) -> (C2HSImp.CUInt -> ((C2HSImp.Ptr C2HSImp.CInt) -> (C2HSImp.CUInt -> ((C2HSImp.Ptr C2HSImp.CInt) -> (C2HSImp.CUInt -> ((C2HSImp.Ptr C2HSImp.CInt) -> (C2HSImp.CUInt -> ((C2HSImp.Ptr C2HSImp.CInt) -> (C2HSImp.CUInt -> ((C2HSImp.Ptr C2HSImp.CDouble) -> (C2HSImp.CUInt -> (C2HSImp.CUInt -> ((C2HSImp.Ptr (C2HSImp.Ptr (CQuote'))) -> ((C2HSImp.Ptr (CSwapIndex')) -> ((C2HSImp.Ptr (CSwapIndex')) -> (C2HSImp.CInt -> (C2HSImp.CUInt -> (C2HSImp.CUInt -> ((C2HSImp.Ptr (C2HSImp.Ptr (CQuote'))) -> (C2HSImp.CInt -> (C2HSImp.CInt -> (C2HSImp.CInt -> (C2HSImp.CInt -> (C2HSImp.CInt -> ((C2HSImp.Ptr (CEndCriteria)) -> ((C2HSImp.Ptr (COptimizationMethod)) -> (C2HSImp.CDouble -> (C2HSImp.CDouble -> (C2HSImp.CInt -> (C2HSImp.CUInt -> (C2HSImp.CInt -> (C2HSImp.CDouble -> (C2HSImp.CInt -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO (C2HSImp.Ptr (CSabrSwaptionVolatilityCube'))))))))))))))))))))))))))))))))))))))
5730
5731 foreign import ccall safe "QuantLib/TermStructure/Volatility.chs.h qlNoArbSabrSwaptionVolatilityCube"
5732 qlNoArbSabrSwaptionVolatilityCube'_ :: ((C2HSImp.Ptr (CSwaptionVolatilityStructure')) -> (C2HSImp.CUInt -> ((C2HSImp.Ptr C2HSImp.CInt) -> (C2HSImp.CUInt -> ((C2HSImp.Ptr C2HSImp.CInt) -> (C2HSImp.CUInt -> ((C2HSImp.Ptr C2HSImp.CInt) -> (C2HSImp.CUInt -> ((C2HSImp.Ptr C2HSImp.CInt) -> (C2HSImp.CUInt -> ((C2HSImp.Ptr C2HSImp.CDouble) -> (C2HSImp.CUInt -> (C2HSImp.CUInt -> ((C2HSImp.Ptr (C2HSImp.Ptr (CQuote'))) -> ((C2HSImp.Ptr (CSwapIndex')) -> ((C2HSImp.Ptr (CSwapIndex')) -> (C2HSImp.CInt -> (C2HSImp.CUInt -> (C2HSImp.CUInt -> ((C2HSImp.Ptr (C2HSImp.Ptr (CQuote'))) -> (C2HSImp.CInt -> (C2HSImp.CInt -> (C2HSImp.CInt -> (C2HSImp.CInt -> (C2HSImp.CInt -> ((C2HSImp.Ptr (CEndCriteria)) -> ((C2HSImp.Ptr (COptimizationMethod)) -> (C2HSImp.CDouble -> (C2HSImp.CDouble -> (C2HSImp.CInt -> (C2HSImp.CUInt -> (C2HSImp.CInt -> (C2HSImp.CDouble -> (C2HSImp.CInt -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO (C2HSImp.Ptr (CNoArbSabrSwaptionVolatilityCube'))))))))))))))))))))))))))))))))))))))
5733
5734 foreign import ccall safe "QuantLib/TermStructure/Volatility.chs.h qlZabrSwaptionVolatilityCube"
5735 qlZabrSwaptionVolatilityCube'_ :: ((C2HSImp.Ptr (CSwaptionVolatilityStructure')) -> (C2HSImp.CUInt -> ((C2HSImp.Ptr C2HSImp.CInt) -> (C2HSImp.CUInt -> ((C2HSImp.Ptr C2HSImp.CInt) -> (C2HSImp.CUInt -> ((C2HSImp.Ptr C2HSImp.CInt) -> (C2HSImp.CUInt -> ((C2HSImp.Ptr C2HSImp.CInt) -> (C2HSImp.CUInt -> ((C2HSImp.Ptr C2HSImp.CDouble) -> (C2HSImp.CUInt -> (C2HSImp.CUInt -> ((C2HSImp.Ptr (C2HSImp.Ptr (CQuote'))) -> ((C2HSImp.Ptr (CSwapIndex')) -> ((C2HSImp.Ptr (CSwapIndex')) -> (C2HSImp.CInt -> (C2HSImp.CUInt -> (C2HSImp.CUInt -> ((C2HSImp.Ptr (C2HSImp.Ptr (CQuote'))) -> (C2HSImp.CInt -> (C2HSImp.CInt -> (C2HSImp.CInt -> (C2HSImp.CInt -> (C2HSImp.CInt -> (C2HSImp.CInt -> ((C2HSImp.Ptr (CEndCriteria)) -> ((C2HSImp.Ptr (COptimizationMethod)) -> (C2HSImp.CDouble -> (C2HSImp.CDouble -> (C2HSImp.CInt -> (C2HSImp.CUInt -> (C2HSImp.CInt -> (C2HSImp.CDouble -> (C2HSImp.CInt -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO (C2HSImp.Ptr (CZabrSwaptionVolatilityCube')))))))))))))))))))))))))))))))))))))))
5736
5737 foreign import ccall safe "QuantLib/TermStructure/Volatility.chs.h qlInterpolatedSwaptionVolatilityCube"
5738 qlInterpolatedSwaptionVolatilityCube'_ :: ((C2HSImp.Ptr (CSwaptionVolatilityStructure')) -> (C2HSImp.CUInt -> ((C2HSImp.Ptr C2HSImp.CInt) -> (C2HSImp.CUInt -> ((C2HSImp.Ptr C2HSImp.CInt) -> (C2HSImp.CUInt -> ((C2HSImp.Ptr C2HSImp.CInt) -> (C2HSImp.CUInt -> ((C2HSImp.Ptr C2HSImp.CInt) -> (C2HSImp.CUInt -> ((C2HSImp.Ptr C2HSImp.CDouble) -> (C2HSImp.CUInt -> (C2HSImp.CUInt -> ((C2HSImp.Ptr (C2HSImp.Ptr (CQuote'))) -> ((C2HSImp.Ptr (CSwapIndex')) -> ((C2HSImp.Ptr (CSwapIndex')) -> (C2HSImp.CInt -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO (C2HSImp.Ptr (CInterpolatedSwaptionVolatilityCube')))))))))))))))))))))
5739
5740 foreign import ccall safe "QuantLib/TermStructure/Volatility.chs.h qlInterpolatedSwaptionVolatilityCubeVolSpreads"
5741 qlInterpolatedSwaptionVolatilityCubeVolSpreads'_ :: ((C2HSImp.Ptr (CInterpolatedSwaptionVolatilityCube')) -> (C2HSImp.CUInt -> ((C2HSImp.Ptr C2HSImp.CUInt) -> ((C2HSImp.Ptr C2HSImp.CUInt) -> ((C2HSImp.Ptr C2HSImp.CUInt) -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CDouble)) -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO ()))))))))
5742
5743 foreign import ccall safe "QuantLib/TermStructure/Volatility.chs.h qlSabrSwaptionVolatilityCubeSparseSabrParameters"
5744 qlSabrSwaptionVolatilityCubeSparseSabrParameters'_ :: ((C2HSImp.Ptr (CSabrSwaptionVolatilityCube')) -> ((C2HSImp.Ptr C2HSImp.CUInt) -> ((C2HSImp.Ptr C2HSImp.CUInt) -> ((C2HSImp.Ptr C2HSImp.CUInt) -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CDouble)) -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO ())))))))
5745
5746 foreign import ccall safe "QuantLib/TermStructure/Volatility.chs.h qlSabrSwaptionVolatilityCubeDenseSabrParameters"
5747 qlSabrSwaptionVolatilityCubeDenseSabrParameters'_ :: ((C2HSImp.Ptr (CSabrSwaptionVolatilityCube')) -> ((C2HSImp.Ptr C2HSImp.CUInt) -> ((C2HSImp.Ptr C2HSImp.CUInt) -> ((C2HSImp.Ptr C2HSImp.CUInt) -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CDouble)) -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO ())))))))
5748
5749 foreign import ccall safe "QuantLib/TermStructure/Volatility.chs.h qlSabrSwaptionVolatilityCubeMarketVolCube"
5750 qlSabrSwaptionVolatilityCubeMarketVolCube'_ :: ((C2HSImp.Ptr (CSabrSwaptionVolatilityCube')) -> ((C2HSImp.Ptr C2HSImp.CUInt) -> ((C2HSImp.Ptr C2HSImp.CUInt) -> ((C2HSImp.Ptr C2HSImp.CUInt) -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CDouble)) -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO ())))))))
5751
5752 foreign import ccall safe "QuantLib/TermStructure/Volatility.chs.h qlSabrSwaptionVolatilityCubeVolCubeAtmCalibrated"
5753 qlSabrSwaptionVolatilityCubeVolCubeAtmCalibrated'_ :: ((C2HSImp.Ptr (CSabrSwaptionVolatilityCube')) -> ((C2HSImp.Ptr C2HSImp.CUInt) -> ((C2HSImp.Ptr C2HSImp.CUInt) -> ((C2HSImp.Ptr C2HSImp.CUInt) -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CDouble)) -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO ())))))))
5754
5755 foreign import ccall safe "QuantLib/TermStructure/Volatility.chs.h qlSabrSwaptionVolatilityCubeAtmStrike1"
5756 sabrSwaptionVolatilityCubeAtmStrikeAtDateRaw'_ :: ((C2HSImp.Ptr (CSabrSwaptionVolatilityCube')) -> (C2HSImp.CInt -> (C2HSImp.CInt -> (C2HSImp.CInt -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO C2HSImp.CDouble))))))
5757
5758 foreign import ccall safe "QuantLib/TermStructure/Volatility.chs.h qlSabrSwaptionVolatilityCubeAtmStrike"
5759 sabrSwaptionVolatilityCubeAtmStrikeForTenorRaw'_ :: ((C2HSImp.Ptr (CSabrSwaptionVolatilityCube')) -> (C2HSImp.CInt -> (C2HSImp.CInt -> (C2HSImp.CInt -> (C2HSImp.CInt -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO C2HSImp.CDouble)))))))
5760
5761 foreign import ccall safe "QuantLib/TermStructure/Volatility.chs.h qlNoArbSabrSwaptionVolatilityCubeSparseSabrParameters"
5762 qlNoArbSabrSwaptionVolatilityCubeSparseSabrParameters'_ :: ((C2HSImp.Ptr (CNoArbSabrSwaptionVolatilityCube')) -> ((C2HSImp.Ptr C2HSImp.CUInt) -> ((C2HSImp.Ptr C2HSImp.CUInt) -> ((C2HSImp.Ptr C2HSImp.CUInt) -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CDouble)) -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO ())))))))
5763
5764 foreign import ccall safe "QuantLib/TermStructure/Volatility.chs.h qlNoArbSabrSwaptionVolatilityCubeDenseSabrParameters"
5765 qlNoArbSabrSwaptionVolatilityCubeDenseSabrParameters'_ :: ((C2HSImp.Ptr (CNoArbSabrSwaptionVolatilityCube')) -> ((C2HSImp.Ptr C2HSImp.CUInt) -> ((C2HSImp.Ptr C2HSImp.CUInt) -> ((C2HSImp.Ptr C2HSImp.CUInt) -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CDouble)) -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO ())))))))
5766
5767 foreign import ccall safe "QuantLib/TermStructure/Volatility.chs.h qlNoArbSabrSwaptionVolatilityCubeMarketVolCube"
5768 qlNoArbSabrSwaptionVolatilityCubeMarketVolCube'_ :: ((C2HSImp.Ptr (CNoArbSabrSwaptionVolatilityCube')) -> ((C2HSImp.Ptr C2HSImp.CUInt) -> ((C2HSImp.Ptr C2HSImp.CUInt) -> ((C2HSImp.Ptr C2HSImp.CUInt) -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CDouble)) -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO ())))))))
5769
5770 foreign import ccall safe "QuantLib/TermStructure/Volatility.chs.h qlNoArbSabrSwaptionVolatilityCubeVolCubeAtmCalibrated"
5771 qlNoArbSabrSwaptionVolatilityCubeVolCubeAtmCalibrated'_ :: ((C2HSImp.Ptr (CNoArbSabrSwaptionVolatilityCube')) -> ((C2HSImp.Ptr C2HSImp.CUInt) -> ((C2HSImp.Ptr C2HSImp.CUInt) -> ((C2HSImp.Ptr C2HSImp.CUInt) -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CDouble)) -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO ())))))))
5772
5773 foreign import ccall safe "QuantLib/TermStructure/Volatility.chs.h qlNoArbSabrSwaptionVolatilityCubeAtmStrike1"
5774 noArbSabrSwaptionVolatilityCubeAtmStrikeAtDateRaw'_ :: ((C2HSImp.Ptr (CNoArbSabrSwaptionVolatilityCube')) -> (C2HSImp.CInt -> (C2HSImp.CInt -> (C2HSImp.CInt -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO C2HSImp.CDouble))))))
5775
5776 foreign import ccall safe "QuantLib/TermStructure/Volatility.chs.h qlNoArbSabrSwaptionVolatilityCubeAtmStrike"
5777 noArbSabrSwaptionVolatilityCubeAtmStrikeForTenorRaw'_ :: ((C2HSImp.Ptr (CNoArbSabrSwaptionVolatilityCube')) -> (C2HSImp.CInt -> (C2HSImp.CInt -> (C2HSImp.CInt -> (C2HSImp.CInt -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO C2HSImp.CDouble)))))))
5778
5779 foreign import ccall safe "QuantLib/TermStructure/Volatility.chs.h qlZabrSwaptionVolatilityCubeSparseSabrParameters"
5780 qlZabrSwaptionVolatilityCubeSparseSabrParameters'_ :: ((C2HSImp.Ptr (CZabrSwaptionVolatilityCube')) -> ((C2HSImp.Ptr C2HSImp.CUInt) -> ((C2HSImp.Ptr C2HSImp.CUInt) -> ((C2HSImp.Ptr C2HSImp.CUInt) -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CDouble)) -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO ())))))))
5781
5782 foreign import ccall safe "QuantLib/TermStructure/Volatility.chs.h qlZabrSwaptionVolatilityCubeDenseSabrParameters"
5783 qlZabrSwaptionVolatilityCubeDenseSabrParameters'_ :: ((C2HSImp.Ptr (CZabrSwaptionVolatilityCube')) -> ((C2HSImp.Ptr C2HSImp.CUInt) -> ((C2HSImp.Ptr C2HSImp.CUInt) -> ((C2HSImp.Ptr C2HSImp.CUInt) -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CDouble)) -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO ())))))))
5784
5785 foreign import ccall safe "QuantLib/TermStructure/Volatility.chs.h qlZabrSwaptionVolatilityCubeMarketVolCube"
5786 qlZabrSwaptionVolatilityCubeMarketVolCube'_ :: ((C2HSImp.Ptr (CZabrSwaptionVolatilityCube')) -> ((C2HSImp.Ptr C2HSImp.CUInt) -> ((C2HSImp.Ptr C2HSImp.CUInt) -> ((C2HSImp.Ptr C2HSImp.CUInt) -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CDouble)) -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO ())))))))
5787
5788 foreign import ccall safe "QuantLib/TermStructure/Volatility.chs.h qlZabrSwaptionVolatilityCubeVolCubeAtmCalibrated"
5789 qlZabrSwaptionVolatilityCubeVolCubeAtmCalibrated'_ :: ((C2HSImp.Ptr (CZabrSwaptionVolatilityCube')) -> ((C2HSImp.Ptr C2HSImp.CUInt) -> ((C2HSImp.Ptr C2HSImp.CUInt) -> ((C2HSImp.Ptr C2HSImp.CUInt) -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CDouble)) -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO ())))))))
5790
5791 foreign import ccall safe "QuantLib/TermStructure/Volatility.chs.h qlZabrSwaptionVolatilityCubeAtmStrike1"
5792 zabrSwaptionVolatilityCubeAtmStrikeAtDateRaw'_ :: ((C2HSImp.Ptr (CZabrSwaptionVolatilityCube')) -> (C2HSImp.CInt -> (C2HSImp.CInt -> (C2HSImp.CInt -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO C2HSImp.CDouble))))))
5793
5794 foreign import ccall safe "QuantLib/TermStructure/Volatility.chs.h qlZabrSwaptionVolatilityCubeAtmStrike"
5795 zabrSwaptionVolatilityCubeAtmStrikeForTenorRaw'_ :: ((C2HSImp.Ptr (CZabrSwaptionVolatilityCube')) -> (C2HSImp.CInt -> (C2HSImp.CInt -> (C2HSImp.CInt -> (C2HSImp.CInt -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO C2HSImp.CDouble)))))))
5796
5797 foreign import ccall safe "QuantLib/TermStructure/Volatility.chs.h qlInterpolatedSwaptionVolatilityCubeAtmStrike1"
5798 interpolatedSwaptionVolatilityCubeAtmStrikeAtDateRaw'_ :: ((C2HSImp.Ptr (CInterpolatedSwaptionVolatilityCube')) -> (C2HSImp.CInt -> (C2HSImp.CInt -> (C2HSImp.CInt -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO C2HSImp.CDouble))))))
5799
5800 foreign import ccall safe "QuantLib/TermStructure/Volatility.chs.h qlInterpolatedSwaptionVolatilityCubeAtmStrike"
5801 interpolatedSwaptionVolatilityCubeAtmStrikeForTenorRaw'_ :: ((C2HSImp.Ptr (CInterpolatedSwaptionVolatilityCube')) -> (C2HSImp.CInt -> (C2HSImp.CInt -> (C2HSImp.CInt -> (C2HSImp.CInt -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO C2HSImp.CDouble)))))))