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 #-}
    6 module QuantLib.TermStructure.Volatility
    7   (
    8     BlackVarianceSurfaceExtrapolation(..)
    9   , ExtendedBlackVarianceSurfaceExtrapolation(..)
   10   , FixedLocalVolSurfaceExtrapolation(..)
   11 
   12   , BlackVarianceCurve
   13   , BlackVolatilitySurfaceDelta
   14   , SmileInterpolationMethod(..)
   15   , BlackVolTimeExtrapolationType(..)
   16   , BlackVolatilitySurfaceDeltaOpts(..)
   17   , defaultBlackVolatilitySurfaceDeltaOpts
   18   , BlackVolTermStructure
   19   , GenBlackVolTermStructure
   20   , RelinkableBlackVolTermStructure
   21   , CallableBondVolatilityStructure
   22   , CapFloorTermVolatilityStructure
   23   , GenCapFloorTermVolatilityStructure
   24   , CapFloorTermVolCurve
   25   , CapFloorTermVolSurface
   26   , LocalVolTermStructure
   27   , OptionletVolatilityStructure
   28   , GenOptionletVolatilityStructure
   29   , RelinkableOptionletVolatilityStructure
   30   , SmileSection
   31   , SabrInterpolatedSmileSection
   32   , SwaptionVolatilityStructure
   33   , RelinkableSwaptionVolatilityStructure
   34   , VolatilityTermStructure
   35   , GenVolatilityTermStructure
   36   , BlackAtmVolCurve
   37   , GenBlackAtmVolCurve
   38   , BlackVolSurface
   39   , GenBlackVolSurface
   40   , AbcdAtmVolCurve
   41   , SabrVolSurface
   42   , OptionletStripper2
   43 
   44   , asVolatilityTermStructure
   45   , asBlackVolTermStructure
   46 
   47   , localVolSurface
   48   , constantOptionletVolatility
   49   , constantOptionletVolatility'
   50   , optionletStripper1
   51   , optionletStripper2
   52   , optionletStripper2AsOptionletVolatilityStructure
   53   , optionletStripper2AtmCapFloorStrikes
   54   , optionletStripper2AtmCapFloorPrices
   55   , optionletStripper2SpreadsVol
   56 
   57   , impliedVolTermStructure
   58   , blackConstantVol'
   59   , blackConstantVol
   60   , relinkableBlackVolTermStructure
   61   , linkBlackVolTo
   62   , constantSwaptionVolatility'
   63   , constantSwaptionVolatility
   64   , blackVarianceForPeriod'
   65   , blackVarianceForPeriod
   66   , blackVarianceForTenor
   67   , blackVariance'
   68   , blackVariance
   69   , blackVarianceForPeriods
   70   , maxSwapLength
   71   , maxSwapTenor
   72   , smileSectionForPeriod'
   73   , smileSectionForPeriod
   74   , smileSectionForTenor
   75   , smileSection'
   76   , smileSection
   77   , smileSectionForPeriods
   78   , sabrSmileSection
   79   , sabrSmileSection'
   80   , noArbSabrSmileSection
   81   , noArbSabrSmileSection'
   82   , smileSectionVolatility
   83   , smileSectionVariance
   84   , SabrInterpolatedSmileSectionOpts(..)
   85   , defaultSabrInterpolatedSmileSectionOpts
   86   , sabrInterpolatedSmileSection
   87   , sabrInterpolatedSmileSectionAsSmileSection
   88   , sabrInterpolatedSmileSectionAlpha
   89   , sabrInterpolatedSmileSectionBeta
   90   , sabrInterpolatedSmileSectionNu
   91   , sabrInterpolatedSmileSectionRho
   92   , sabrInterpolatedSmileSectionRmsError
   93   , sabrInterpolatedSmileSectionMaxError
   94   , sabrInterpolatedSmileSectionEndCriteria
   95   , swapLength'
   96   , swapLength
   97   , volatilityForPeriod'
   98   , volatilityForPeriod
   99   , volatilityForTenor
  100   , volatilityForTenor'
  101   , volatility
  102   , volatilityForPeriods
  103   , callableBondConstantVolatility'
  104   , callableBondConstantVolatility
  105   , constantCapFloorTermVolatility'
  106   , constantCapFloorTermVolatility
  107   , capFloorVolatilityForPeriod
  108   , capFloorVolatilityForDate
  109   , capFloorVolatilityForTime
  110   , capFloorTermVolCurveOptionDates
  111   , capFloorTermVolCurveOptionTimes
  112   , capFloorTermVolSurfaceOptionDates
  113   , capFloorTermVolSurfaceOptionTimes
  114   , atmVolForPeriod
  115   , atmVolForDate
  116   , atmVolForTime
  117   , atmVarianceForPeriod
  118   , atmVarianceForDate
  119   , atmVarianceForTime
  120   , blackVolSurfaceSmileSectionForPeriod
  121   , blackVolSurfaceSmileSectionForDate
  122   , blackVolSurfaceSmileSectionForTime
  123   , abcdAtmVolCurve
  124   , abcdAtmVolCurveA
  125   , abcdAtmVolCurveB
  126   , abcdAtmVolCurveC
  127   , abcdAtmVolCurveD
  128   , abcdAtmVolCurveRmsError
  129   , abcdAtmVolCurveMaxError
  130   , abcdAtmVolCurveEndCriteria
  131   , abcdAtmVolCurveK
  132   , abcdAtmVolCurveKAtTime
  133   , abcdAtmVolCurveOptionTenors
  134   , abcdAtmVolCurveOptionTenorsInInterpolation
  135   , abcdAtmVolCurveOptionDates
  136   , abcdAtmVolCurveOptionTimes
  137   , sabrVolSurface
  138   , sabrVolSurfaceAtmCurve
  139   , sabrVolSurfaceVolatilitySpreadsForPeriod
  140   , sabrVolSurfaceVolatilitySpreadsForDate
  141   , sabrVolSurfaceIndex
  142   , sabrVolSurfaceOptionDateFromTenor
  143   , spreadedSwaptionVolatility
  144   , relinkableSwaptionVolatilityStructure
  145   , linkSwaptionVolTo
  146   , relinkableOptionletVolatilityStructure
  147   , linkOptionletVolTo
  148   , localConstantVol'
  149   , localConstantVol
  150   , localVolCurve
  151   , capFloorTermVolCurve
  152   , capFloorTermVolCurve'
  153   , blackVarianceCurve
  154   , capFloorTermVolSurface
  155   , capFloorTermVolSurface'
  156   , blackVarianceSurface
  157   , piecewiseBlackVarianceSurface
  158   , blackVolatilitySurfaceDelta
  159   , blackVolatilitySurfaceDeltaFull
  160   , blackVolSmile
  161   , blackVolSmile'
  162   , swaptionVolatilityMatrix'
  163   , SabrSwaptionVolatilityCube
  164   , InterpolatedSwaptionVolatilityCube
  165   , sabrSwaptionVolatilityCube
  166   , interpolatedSwaptionVolatilityCube
  167   , sparseSabrParameters
  168   , denseSabrParameters
  169   , marketVolCube
  170   , volCubeAtmCalibrated
  171   , sabrSwaptionVolatilityCubeAtmStrike'
  172   , sabrSwaptionVolatilityCubeAtmStrike
  173   , interpolatedSwaptionVolatilityCubeAtmStrike'
  174   , interpolatedSwaptionVolatilityCubeAtmStrike
  175   , swaptionVolatilityMatrix
  176   , noExceptLocalVolSurface
  177   , fixedLocalVolSurface
  178   , spreadedOptionletVol
  179   , localVol
  180   , smileSectionAtmLevel
  181   , smileSectionOptionPrice
  182   , smileSectionDigitalOptionPrice
  183   , smileSectionDensity
  184   , flatSmileSection
  185   , spreadedSmileSection
  186   , atmSmileSection
  187   ) where
  188 import qualified Foreign.C.Types as C2HSImp
  189 import qualified Foreign.ForeignPtr as C2HSImp
  190 import qualified Foreign.Marshal.Utils as C2HSImp
  191 import qualified Foreign.Ptr as C2HSImp
  192 
  193 
  194 import QuantLib.Internal
  195 import QuantLib.InterestRate(VolatilityType)
  196 import QuantLib.Math(EndCriteriaType)
  197 import QuantLib.Quote(DeltaType(..), AtmType(..))
  198 import QuantLib.Internal.Type
  199 import QuantLib.Internal.Common
  200 import QuantLib.Internal.Syntax(deriveOptionsRecord)
  201 import QuantLib.Time.Schedule(dayCounter, DayCounterConstructor(..))
  202 
  203 
  204 
  205 
  206 
  207 
  208 
  209 
  210 
  211 
  212 
  213 
  214 
  215 
  216 
  217 
  218 
  219 
  220 
  221 
  222 
  223 
  224 
  225 
  226 
  227 
  228 
  229 
  230 
  231 
  232 
  233 
  234 
  235 
  236 
  237 
  238 
  239 
  240 
  241 
  242 
  243 
  244 
  245 
  246 
  247 
  248 
  249 
  250 
  251 
  252 
  253 
  254 
  255 
  256 
  257 
  258 
  259 
  260 
  261 
  262 
  263 
  264 
  265 
  266 
  267 
  268 
  269 
  270 
  271 
  272 data BlackVarianceSurfaceExtrapolation = BlackVarianceSurfaceConstantExtrapolation
  273                                        | BlackVarianceSurfaceInterpolatorDefaultExtrapolation
  274   deriving (Enum,Show,Eq,Read)
  275 
  276 
  277 data ExtendedBlackVarianceSurfaceExtrapolation = ExtendedBlackVarianceSurfaceConstantExtrapolation
  278                                                | ExtendedBlackVarianceSurfaceInterpolatorDefaultExtrapolation
  279   deriving (Enum,Show,Eq,Read)
  280 
  281 
  282 
  283 -- |'BlackVolatilitySurfaceDelta::SmileInterpolationMethod', local to that class -- not shared
  284 -- with any other binding, so declared here rather than in 'QuantLib.Internal.Common'.
  285 data SmileInterpolationMethod = SmileLinear
  286                               | NaturalCubic
  287                               | FinancialCubic
  288                               | CubicSpline
  289   deriving (Enum,Show,Eq,Read)
  290 
  291 
  292 
  293 -- |'BlackVolTimeExtrapolation::Type', consumed only by 'blackVolatilitySurfaceDelta' today --
  294 -- same local-declaration treatment as 'SmileInterpolationMethod'. Named
  295 -- @BlackVolTimeExtrapolationType@ (rather than reusing the bare @Type@ c2hs would otherwise
  296 -- emit) to avoid a top-level name clash.
  297 data BlackVolTimeExtrapolationType = FlatVolatility
  298                                    | UseInterpolator
  299                                    | LinearVariance
  300   deriving (Enum,Show,Eq,Read)
  301 
  302 
  303 
  304 -- |'FixedLocalVolSurface::Extrapolation', local to that class -- not shared with any other
  305 -- binding, same local-declaration treatment as 'SmileInterpolationMethod'.
  306 data FixedLocalVolSurfaceExtrapolation = FixedLocalVolSurfaceConstantExtrapolation
  307                                        | FixedLocalVolSurfaceInterpolatorDefaultExtrapolation
  308   deriving (Enum,Show,Eq,Read)
  309 
  310 
  311 
  312 -- SabrInterpolatedSmileSectionOpts bundles every trailing param
  313 -- sabrInterpolatedSmileSection_ hardcodes, pre-populated with upstream's own defaults,
  314 -- overridden through record-update syntax -- see OISRateHelperOpts (QuantLib.TermStructure.Yield)
  315 -- for the worked example this follows. dayCounter is Maybe here (unlike the raw binding's
  316 -- plain DayCounter) since a real DayCounter is only obtainable in IO (`dayCounter
  317 -- Actual365FixedStandard`) and can't live in a pure default record value;
  318 -- sabrInterpolatedSmileSection substitutes a fresh Actual365Fixed for Nothing, same as
  319 -- OISRateHelperOpts does for its Calendar fields. This splice must stay textually before
  320 -- every {#fun#}-generated binding in this file -- see the comment above OISRateHelperOpts
  321 -- for why (c2hs always appends its raw foreign-import stubs at the physical end of the
  322 -- generated module regardless of where a {#fun#} hook appears in the source).
  323 $(deriveOptionsRecord "SabrInterpolatedSmileSectionOpts" []
  324   [ ("sabrIsAlphaFixed", [t|Bool|], [|False|])
  325   , ("sabrIsBetaFixed", [t|Bool|], [|False|])
  326   , ("sabrIsNuFixed", [t|Bool|], [|False|])
  327   , ("sabrIsRhoFixed", [t|Bool|], [|False|])
  328   , ("sabrVegaWeighted", [t|Bool|], [|True|])
  329   , ("sabrEndCriteria", [t|Maybe EndCriteria|], [|Nothing|])
  330   , ("sabrOptimizationMethod", [t|Maybe OptimizationMethod|], [|Nothing|])
  331   , ("sabrDayCounter", [t|Maybe DayCounter|], [|Nothing|])
  332   , ("sabrShift", [t|Double|], [|0.0|])
  333   ])
  334 
  335 -- BlackVolatilitySurfaceDeltaOpts bundles every trailing defaulted param of
  336 -- 'BlackVolatilitySurfaceDelta''s one constructor (deltaType through longTermAtmDeltaType),
  337 -- pre-populated with upstream's own defaults via defaultBlackVolatilitySurfaceDeltaOpts,
  338 -- overridden through record-update syntax at the call site -- see OISRateHelperOpts
  339 -- (QuantLib.TermStructure.Yield) for the worked example this follows. Same
  340 -- splice-placement constraint as SabrInterpolatedSmileSectionOpts above.
  341 $(deriveOptionsRecord "BlackVolatilitySurfaceDeltaOpts" []
  342   [ ("bvsdDeltaType", [t|DeltaType|], [|Spot|])
  343   , ("bvsdAtmType", [t|AtmType|], [|AtmDeltaNeutral|])
  344   , ("bvsdAtmDeltaType", [t|Maybe DeltaType|], [|Nothing|])
  345   , ("bvsdInterpolationMethod", [t|SmileInterpolationMethod|], [|SmileLinear|])
  346   , ("bvsdFlatStrikeExtrapolation", [t|Bool|], [|False|])
  347   , ("bvsdTimeExtrapolationType", [t|BlackVolTimeExtrapolationType|], [|FlatVolatility|])
  348   , ("bvsdSwitchTenor", [t|(Int, TimeUnit)|], [|(0, Days)|])
  349   , ("bvsdLongTermDeltaType", [t|DeltaType|], [|Fwd|])
  350   , ("bvsdLongTermAtmType", [t|AtmType|], [|AtmDeltaNeutral|])
  351   , ("bvsdLongTermAtmDeltaType", [t|Maybe DeltaType|], [|Nothing|])
  352   ])
  353 
  354 -- |A local vol surface derived from a Black vol surface via Dupire's formula (Gatheral's
  355 -- implementation).
  356 localVolSurface :: (GenBlackVolTermStructure bv) -> (GenYieldTermStructure y1) -- ^riskFreeTS
  357  -> (GenYieldTermStructure y2) -- ^dividendTS
  358  -> (GenQuote q) -- ^underlying
  359  -> IO ((LocalVolTermStructure))
  360 localVolSurface a1 a2 a3 a4 =
  361   withBlackVolTermStructure a1 $ \a1' -> 
  362   withYieldTermStructure a2 $ \a2' -> 
  363   withYieldTermStructure a3 $ \a3' -> 
  364   withQuote a4 $ \a4' -> 
  365   preErrorCheck $ \a5' -> 
  366   localVolSurface'_ a1' a2' a3' a4' a5' >>= \res ->
  367   peekLocalVolTermStructure res >>= \res' ->
  368   errorCheck  a5'>>
  369   return (res')
  370 
  371 
  372 
  373 -- |as 'localVolSurface', but a local vol calculation that would otherwise throw returns
  374 -- @illegalLocalVolOverwrite@ instead
  375 noExceptLocalVolSurface :: (GenBlackVolTermStructure bv) -> (GenYieldTermStructure y1) -- ^riskFreeTS
  376  -> (GenYieldTermStructure y2) -- ^dividendTS
  377  -> (GenQuote q) -- ^underlying
  378  -> (Double) -- ^illegalLocalVolOverwrite
  379  -> IO ((LocalVolTermStructure))
  380 noExceptLocalVolSurface a1 a2 a3 a4 a5 =
  381   withBlackVolTermStructure a1 $ \a1' -> 
  382   withYieldTermStructure a2 $ \a2' -> 
  383   withYieldTermStructure a3 $ \a3' -> 
  384   withQuote a4 $ \a4' -> 
  385   let {a5' = realToFrac a5} in 
  386   preErrorCheck $ \a6' -> 
  387   noExceptLocalVolSurface'_ a1' a2' a3' a4' a5' a6' >>= \res ->
  388   peekLocalVolTermStructure res >>= \res' ->
  389   errorCheck  a6'>>
  390   return (res')
  391 
  392 
  393 
  394 -- |a local vol surface fed directly from a matrix of local vols (rather than derived from a
  395 -- Black vol surface, as 'localVolSurface' is) -- one flat strike grid shared across all dates,
  396 -- same shape as 'blackVarianceSurface'.
  397 fixedLocalVolSurface :: Day -> [Day] -- ^dates
  398   -> [Double] -- ^strikes
  399   -> Matrix Double -- ^localVolMatrix
  400   -> DayCounter
  401   -> FixedLocalVolSurfaceExtrapolation -- ^lowerExtrapolation
  402   -> FixedLocalVolSurfaceExtrapolation -- ^upperExtrapolation
  403   -> IO LocalVolTermStructure
  404 fixedLocalVolSurface d ds s (Matrix mr mc md) = qlFixedLocalVolSurface d ds s mr mc md
  405 qlFixedLocalVolSurface :: (Day) -> ([Day]) -> ([Double]) -> (Word) -> (Word) -> ([Double]) -> (DayCounter) -> (FixedLocalVolSurfaceExtrapolation) -> (FixedLocalVolSurfaceExtrapolation) -> IO ((LocalVolTermStructure))
  406 qlFixedLocalVolSurface a1 a2 a3 a4 a5 a6 a7 a8 a9 =
  407   withDay a1 $ \a1' -> 
  408   withDayArray a2 $ \(a2'1, a2'2) -> 
  409   withDoubleArray a3 $ \(a3'1, a3'2) -> 
  410   let {a4' = fromIntegral a4} in 
  411   let {a5' = fromIntegral a5} in 
  412   withDoubleArrayRaw a6 $ \a6' -> 
  413   withDayCounter a7 $ \a7' -> 
  414   let {a8' = (fromIntegral . fromEnum) a8} in 
  415   let {a9' = (fromIntegral . fromEnum) a9} in 
  416   preErrorCheck $ \a10' -> 
  417   qlFixedLocalVolSurface'_ a1' a2'1  a2'2 a3'1  a3'2 a4' a5' a6' a7' a8' a9' a10' >>= \res ->
  418   peekLocalVolTermStructure res >>= \res' ->
  419   errorCheck  a10'>>
  420   return (res')
  421 
  422 
  423 
  424 -- |the local vol at a given date and underlying level, for any 'LocalVolTermStructure' (however
  425 -- it was constructed) -- the only way to observe what a local vol surface actually computes.
  426 localVol :: (LocalVolTermStructure) -> (Day) -> (Double) -- ^underlyingLevel
  427  -> (Bool) -- ^extrapolate
  428  -> IO ((Double))
  429 localVol a1 a2 a3 a4 =
  430   withLocalVolTermStructure a1 $ \a1' -> 
  431   withDay a2 $ \a2' -> 
  432   let {a3' = realToFrac a3} in 
  433   let {a4' = C2HSImp.fromBool a4} in 
  434   preErrorCheck $ \a5' -> 
  435   localVol'_ a1' a2' a3' a4' a5' >>= \res ->
  436   let {res' = realToFrac res} in
  437   errorCheck  a5'>>
  438   return (res')
  439 
  440 
  441 
  442 -- |Constant caplet volatility, no time-strike dependence
  443 -- floating reference date, floating market data
  444 constantOptionletVolatility' :: (Word) -> (Calendar) -> (BusinessDayConvention) -> (GenQuote q) -> (DayCounter) -> (VolatilityType) -- ^type
  445  -> (Double) -- ^displacement
  446  -> IO ((OptionletVolatilityStructure))
  447 constantOptionletVolatility' a1 a2 a3 a4 a5 a6 a7 =
  448   let {a1' = fromIntegral a1} in 
  449   withCalendar a2 $ \a2' -> 
  450   let {a3' = fromEnumC a3} in 
  451   withQuote a4 $ \a4' -> 
  452   withDayCounter a5 $ \a5' -> 
  453   let {a6' = (fromIntegral . fromEnum) a6} in 
  454   let {a7' = realToFrac a7} in 
  455   preErrorCheck $ \a8' -> 
  456   constantOptionletVolatility''_ a1' a2' a3' a4' a5' a6' a7' a8' >>= \res ->
  457   peekOptionletVolatilityStructure res >>= \res' ->
  458   errorCheck  a8'>>
  459   return (res')
  460 
  461 
  462 
  463 -- |fixed reference date, floating market data
  464 constantOptionletVolatility :: (Day) -> (Calendar) -> (BusinessDayConvention) -> (GenQuote q) -> (DayCounter) -> (VolatilityType) -- ^type
  465  -> (Double) -- ^displacement
  466  -> IO ((OptionletVolatilityStructure))
  467 constantOptionletVolatility a1 a2 a3 a4 a5 a6 a7 =
  468   withDay a1 $ \a1' -> 
  469   withCalendar a2 $ \a2' -> 
  470   let {a3' = fromEnumC a3} in 
  471   withQuote a4 $ \a4' -> 
  472   withDayCounter a5 $ \a5' -> 
  473   let {a6' = (fromIntegral . fromEnum) a6} in 
  474   let {a7' = realToFrac a7} in 
  475   preErrorCheck $ \a8' -> 
  476   constantOptionletVolatility'_ a1' a2' a3' a4' a5' a6' a7' a8' >>= \res ->
  477   peekOptionletVolatilityStructure res >>= \res' ->
  478   errorCheck  a8'>>
  479   return (res')
  480 
  481 
  482 
  483 -- |Strips a 'CapFloorTermVolSurface' (quoted cap\/floor term vols) into caplet\/floorlet vols via
  484 -- 'OptionletStripper1', immediately wrapping the result behind 'StrippedOptionletAdapter' in one
  485 -- step -- 'OptionletStripper1' itself is never exposed as a Haskell type, since none of its own
  486 -- getters (capFloorPrices\/capletVols\/etc.) are needed beyond feeding the adapter, per the "bind
  487 -- few inspectors" rule.
  488 optionletStripper1 :: (CapFloorTermVolSurface) -> (GenIborIndex ibor) -> (Maybe Double) -- ^switchStrikes
  489  -> (Double) -- ^accuracy
  490  -> (Word) -- ^maxIter
  491  -> (Maybe (GenYieldTermStructure y)) -- ^discount
  492  -> (VolatilityType) -- ^type
  493  -> (Double) -- ^displacement
  494  -> (Bool) -- ^dontThrow
  495  -> (Maybe (Word, TimeUnit)) -- ^optionletFrequency
  496  -> IO ((OptionletVolatilityStructure))
  497 optionletStripper1 a1 a2 a3 a4 a5 a6 a7 a8 a9 a10 =
  498   withCapFloorTermVolSurface a1 $ \a1' -> 
  499   withIborIndex a2 $ \a2' -> 
  500   let {a3' = fromMaybeDouble a3} in 
  501   let {a4' = realToFrac a4} in 
  502   let {a5' = fromIntegral a5} in 
  503   withMaybeYieldTermStructure a6 $ \a6' -> 
  504   let {a7' = (fromIntegral . fromEnum) a7} in 
  505   let {a8' = realToFrac a8} in 
  506   let {a9' = C2HSImp.fromBool a9} in 
  507   let {(a10'1, a10'2) = fromMaybeEnumQuantity a10} in 
  508   preErrorCheck $ \a11' -> 
  509   optionletStripper1'_ a1' a2' a3' a4' a5' a6' a7' a8' a9' a10'1  a10'2 a11' >>= \res ->
  510   peekOptionletVolatilityStructure res >>= \res' ->
  511   errorCheck  a11'>>
  512   return (res')
  513 
  514 
  515 
  516 -- |Extends an 'OptionletStripper1' (built internally, never exposed as its own Haskell type --
  517 -- same fusion as 'optionletStripper1') by reconciling it against an ATM 'CapFloorTermVolCurve',
  518 -- producing forward-forward optionlet vols. Unlike 'optionletStripper1', this keeps its own
  519 -- concrete 'OptionletStripper2' object around, since it has real diagnostic getters
  520 -- ('optionletStripper2AtmCapFloorStrikes'\/'optionletStripper2AtmCapFloorPrices'\/
  521 -- 'optionletStripper2SpreadsVol') not reachable through the generic
  522 -- 'OptionletVolatilityStructure' interface. Use 'optionletStripper2AsOptionletVolatilityStructure'
  523 -- to pass one into anything expecting the generic interface.
  524 optionletStripper2 :: (CapFloorTermVolSurface) -> (GenIborIndex ibor) -> (Maybe Double) -- ^switchStrikes
  525  -> (Double) -- ^accuracy
  526  -> (Word) -- ^maxIter
  527  -> (Maybe (GenYieldTermStructure y)) -- ^discount
  528  -> (VolatilityType) -- ^type
  529  -> (Double) -- ^displacement
  530  -> (Bool) -- ^dontThrow
  531  -> (Maybe (Word, TimeUnit)) -- ^optionletFrequency
  532  -> (CapFloorTermVolCurve) -- ^atmCapFloorTermVolCurve
  533  -> IO ((OptionletStripper2))
  534 optionletStripper2 a1 a2 a3 a4 a5 a6 a7 a8 a9 a10 a11 =
  535   withCapFloorTermVolSurface a1 $ \a1' -> 
  536   withIborIndex a2 $ \a2' -> 
  537   let {a3' = fromMaybeDouble a3} in 
  538   let {a4' = realToFrac a4} in 
  539   let {a5' = fromIntegral a5} in 
  540   withMaybeYieldTermStructure a6 $ \a6' -> 
  541   let {a7' = (fromIntegral . fromEnum) a7} in 
  542   let {a8' = realToFrac a8} in 
  543   let {a9' = C2HSImp.fromBool a9} in 
  544   let {(a10'1, a10'2) = fromMaybeEnumQuantity a10} in 
  545   withCapFloorTermVolCurve a11 $ \a11' -> 
  546   preErrorCheck $ \a12' -> 
  547   optionletStripper2'_ a1' a2' a3' a4' a5' a6' a7' a8' a9' a10'1  a10'2 a11' a12' >>= \res ->
  548   peekOptionletStripper2 res >>= \res' ->
  549   errorCheck  a12'>>
  550   return (res')
  551 
  552 
  553 
  554 -- |Fresh construction (a 'StrippedOptionletAdapter' wrapping the 'OptionletStripper2' itself),
  555 -- never a cast -- same idiom as 'sabrInterpolatedSmileSectionAsSmileSection'.
  556 optionletStripper2AsOptionletVolatilityStructure :: (OptionletStripper2) -> IO ((OptionletVolatilityStructure))
  557 optionletStripper2AsOptionletVolatilityStructure a1 =
  558   withOptionletStripper2 a1 $ \a1' -> 
  559   preErrorCheck $ \a2' -> 
  560   optionletStripper2AsOptionletVolatilityStructure'_ a1' a2' >>= \res ->
  561   peekOptionletVolatilityStructure res >>= \res' ->
  562   errorCheck  a2'>>
  563   return (res')
  564 
  565 
  566 
  567 optionletStripper2AtmCapFloorStrikes :: (OptionletStripper2) -> IO (([Double]))
  568 optionletStripper2AtmCapFloorStrikes a1 =
  569   withOptionletStripper2 a1 $ \a1' -> 
  570   preArray $ \(a2'1, a2'2) -> 
  571   preErrorCheck $ \a3' -> 
  572   optionletStripper2AtmCapFloorStrikes'_ a1' a2'1  a2'2 a3' >>
  573   peekDoubleArray  a2'1  a2'2>>= \a2'' -> 
  574   errorCheck  a3'>>
  575   return (a2'')
  576 
  577 
  578 
  579 optionletStripper2AtmCapFloorPrices :: (OptionletStripper2) -> IO (([Double]))
  580 optionletStripper2AtmCapFloorPrices a1 =
  581   withOptionletStripper2 a1 $ \a1' -> 
  582   preArray $ \(a2'1, a2'2) -> 
  583   preErrorCheck $ \a3' -> 
  584   optionletStripper2AtmCapFloorPrices'_ a1' a2'1  a2'2 a3' >>
  585   peekDoubleArray  a2'1  a2'2>>= \a2'' -> 
  586   errorCheck  a3'>>
  587   return (a2'')
  588 
  589 
  590 
  591 optionletStripper2SpreadsVol :: (OptionletStripper2) -> IO (([Double]))
  592 optionletStripper2SpreadsVol a1 =
  593   withOptionletStripper2 a1 $ \a1' -> 
  594   preArray $ \(a2'1, a2'2) -> 
  595   preErrorCheck $ \a3' -> 
  596   optionletStripper2SpreadsVol'_ a1' a2'1  a2'2 a3' >>
  597   peekDoubleArray  a2'1  a2'2>>= \a2'' -> 
  598   errorCheck  a3'>>
  599   return (a2'')
  600 
  601 
  602 
  603 -- |An optionlet vol surface behind a relinkable handle. The result /is/ an
  604 -- 'OptionletVolatilityStructure': pass it anywhere one is expected and everything built on it
  605 -- keeps tracking whatever the handle currently points at, so a later 'linkOptionletVolTo'
  606 -- reprices already-constructed instruments without rebuilding them. Mirrors
  607 -- 'relinkableSwaptionVolatilityStructure'.
  608 relinkableOptionletVolatilityStructure :: (Maybe (GenOptionletVolatilityStructure ov)) -> IO ((RelinkableOptionletVolatilityStructure))
  609 relinkableOptionletVolatilityStructure a1 =
  610   withMaybeOptionletVolatilityStructure a1 $ \a1' -> 
  611   preErrorCheck $ \a2' -> 
  612   relinkableOptionletVolatilityStructure'_ a1' a2' >>= \res ->
  613   peekRelinkableOptionletVolatilityStructure res >>= \res' ->
  614   errorCheck  a2'>>
  615   return (res')
  616 
  617 
  618 
  619 -- |Point a relinkable optionlet vol handle at a different surface. Everything already built on
  620 -- the handle reprices against the new surface, with no engine rebuilt. Named distinctly from
  621 -- 'QuantLib.TermStructure.Yield.linkTo'\/'linkBlackVolTo'\/'linkSwaptionVolTo' for the same
  622 -- reason as those: all four relinkable vol types live in this one module.
  623 linkOptionletVolTo :: (RelinkableOptionletVolatilityStructure) -> (GenOptionletVolatilityStructure ov) -> IO ()
  624 linkOptionletVolTo a1 a2 =
  625   withRelinkableOptionletVolatilityStructure a1 $ \a1' -> 
  626   withOptionletVolatilityStructure a2 $ \a2' -> 
  627   preErrorCheck $ \a3' -> 
  628   linkOptionletVolTo'_ a1' a2' a3' >>
  629   errorCheck  a3'>>
  630   return ()
  631 
  632 
  633 
  634 -- |A constant Black volatility, no time-strike dependence -- floating reference date, floating
  635 -- market data
  636 blackConstantVol' :: (Word) -> (Calendar) -> (GenQuote q) -> (DayCounter) -> IO ((BlackVolTermStructure))
  637 blackConstantVol' a1 a2 a3 a4 =
  638   let {a1' = fromIntegral a1} in 
  639   withCalendar a2 $ \a2' -> 
  640   withQuote a3 $ \a3' -> 
  641   withDayCounter a4 $ \a4' -> 
  642   preErrorCheck $ \a5' -> 
  643   blackConstantVol''_ a1' a2' a3' a4' a5' >>= \res ->
  644   peekBlackVolTermStructure res >>= \res' ->
  645   errorCheck  a5'>>
  646   return (res')
  647 
  648 
  649 
  650 -- |as 'blackConstantVol\'', but a fixed reference date
  651 blackConstantVol :: (Day) -> (Calendar) -> (GenQuote q) -> (DayCounter) -> IO ((BlackVolTermStructure))
  652 blackConstantVol a1 a2 a3 a4 =
  653   withDay a1 $ \a1' -> 
  654   withCalendar a2 $ \a2' -> 
  655   withQuote a3 $ \a3' -> 
  656   withDayCounter a4 $ \a4' -> 
  657   preErrorCheck $ \a5' -> 
  658   blackConstantVol'_ a1' a2' a3' a4' a5' >>= \res ->
  659   peekBlackVolTermStructure res >>= \res' ->
  660   errorCheck  a5'>>
  661   return (res')
  662 
  663 
  664 
  665 -- |A Black vol surface behind a relinkable handle. The result /is/ a 'BlackVolTermStructure':
  666 -- pass it anywhere one is expected and everything built on it keeps tracking whatever the
  667 -- handle currently points at, so a later 'linkBlackVolTo' reprices already-constructed
  668 -- instruments without rebuilding them. Mirrors
  669 -- 'QuantLib.TermStructure.Yield.relinkableYieldTermStructure'.
  670 relinkableBlackVolTermStructure :: (Maybe (GenBlackVolTermStructure bv)) -> IO ((RelinkableBlackVolTermStructure))
  671 relinkableBlackVolTermStructure a1 =
  672   withMaybeBlackVolTermStructure a1 $ \a1' -> 
  673   preErrorCheck $ \a2' -> 
  674   relinkableBlackVolTermStructure'_ a1' a2' >>= \res ->
  675   peekRelinkableBlackVolTermStructure res >>= \res' ->
  676   errorCheck  a2'>>
  677   return (res')
  678 
  679 
  680 
  681 -- |Point a relinkable Black vol handle at a different surface. Everything already built on the
  682 -- handle reprices against the new surface, with no engine rebuilt. Mirrors
  683 -- 'QuantLib.TermStructure.Yield.linkTo' -- see its haddock for why this mutator is justified.
  684 linkBlackVolTo :: (RelinkableBlackVolTermStructure) -> (GenBlackVolTermStructure bv) -> IO ()
  685 linkBlackVolTo a1 a2 =
  686   withRelinkableBlackVolTermStructure a1 $ \a1' -> 
  687   withBlackVolTermStructure a2 $ \a2' -> 
  688   preErrorCheck $ \a3' -> 
  689   linkBlackVolTo'_ a1' a2' a3' >>
  690   errorCheck  a3'>>
  691   return ()
  692 
  693 
  694 
  695 -- |fixed reference date, floating market data
  696 constantSwaptionVolatility' :: (Day) -> (Calendar) -> (BusinessDayConvention) -> (GenQuote q) -> (DayCounter) -> (VolatilityType) -- ^type
  697  -> (Double) -- ^shift
  698  -> IO ((SwaptionVolatilityStructure))
  699 constantSwaptionVolatility' a1 a2 a3 a4 a5 a6 a7 =
  700   withDay a1 $ \a1' -> 
  701   withCalendar a2 $ \a2' -> 
  702   let {a3' = fromEnumC a3} in 
  703   withQuote a4 $ \a4' -> 
  704   withDayCounter a5 $ \a5' -> 
  705   let {a6' = (fromIntegral . fromEnum) a6} in 
  706   let {a7' = realToFrac a7} in 
  707   preErrorCheck $ \a8' -> 
  708   constantSwaptionVolatility''_ a1' a2' a3' a4' a5' a6' a7' a8' >>= \res ->
  709   peekSwaptionVolatilityStructure res >>= \res' ->
  710   errorCheck  a8'>>
  711   return (res')
  712 
  713 
  714 
  715 -- |floating reference date, floating market data
  716 constantSwaptionVolatility :: (Word) -> (Calendar) -> (BusinessDayConvention) -> (GenQuote q) -> (DayCounter) -> (VolatilityType) -- ^type
  717  -> (Double) -- ^shift
  718  -> IO ((SwaptionVolatilityStructure))
  719 constantSwaptionVolatility a1 a2 a3 a4 a5 a6 a7 =
  720   let {a1' = fromIntegral a1} in 
  721   withCalendar a2 $ \a2' -> 
  722   let {a3' = fromEnumC a3} in 
  723   withQuote a4 $ \a4' -> 
  724   withDayCounter a5 $ \a5' -> 
  725   let {a6' = (fromIntegral . fromEnum) a6} in 
  726   let {a7' = realToFrac a7} in 
  727   preErrorCheck $ \a8' -> 
  728   constantSwaptionVolatility'_ a1' a2' a3' a4' a5' a6' a7' a8' >>= \res ->
  729   peekSwaptionVolatilityStructure res >>= \res' ->
  730   errorCheck  a8'>>
  731   return (res')
  732 
  733 
  734 
  735 -- |returns the Black variance for a given option date and swap tenor
  736 blackVarianceForPeriod' :: (GenSwaptionVolatilityStructure sv) -> (Day) -- ^optionDate
  737  -> ((Word,TimeUnit)) -- ^swapTenor
  738  -> (Double) -- ^strike
  739  -> (Bool) -- ^extrapolate
  740  -> IO ((Double))
  741 blackVarianceForPeriod' a1 a2 a3 a4 a5 =
  742   withSwaptionVolatilityStructure a1 $ \a1' -> 
  743   withDay a2 $ \a2' -> 
  744   let {(a3'1, a3'2) = fromEnumQuantity a3} in 
  745   let {a4' = realToFrac a4} in 
  746   let {a5' = C2HSImp.fromBool a5} in 
  747   preErrorCheck $ \a6' -> 
  748   blackVarianceForPeriod''_ a1' a2' a3'1  a3'2 a4' a5' a6' >>= \res ->
  749   let {res' = realToFrac res} in
  750   errorCheck  a6'>>
  751   return (res')
  752 
  753 
  754 
  755 -- |returns the Black variance for a given option time and swap tenor
  756 blackVarianceForPeriod :: (GenSwaptionVolatilityStructure sv) -> (Double) -- optionTime
  757  -> ((Word,TimeUnit)) -- swapTenor
  758  -> (Double) -- ^strike
  759  -> (Bool) -- ^extrapolate
  760  -> IO ((Double))
  761 blackVarianceForPeriod a1 a2 a3 a4 a5 =
  762   withSwaptionVolatilityStructure a1 $ \a1' -> 
  763   let {a2' = realToFrac a2} in 
  764   let {(a3'1, a3'2) = fromEnumQuantity a3} in 
  765   let {a4' = realToFrac a4} in 
  766   let {a5' = C2HSImp.fromBool a5} in 
  767   preErrorCheck $ \a6' -> 
  768   blackVarianceForPeriod'_ a1' a2' a3'1  a3'2 a4' a5' a6' >>= \res ->
  769   let {res' = realToFrac res} in
  770   errorCheck  a6'>>
  771   return (res')
  772 
  773 
  774 
  775 -- |returns the Black variance for a given option tenor and swap length
  776 blackVarianceForTenor :: (GenSwaptionVolatilityStructure sv) -> ((Word,TimeUnit)) -- ^optionTenor
  777  -> (Double) -- ^swapLength
  778  -> (Double) -- ^strike
  779  -> (Bool) -- ^extrapolate
  780  -> IO ((Double))
  781 blackVarianceForTenor a1 a2 a3 a4 a5 =
  782   withSwaptionVolatilityStructure a1 $ \a1' -> 
  783   let {(a2'1, a2'2) = fromEnumQuantity a2} in 
  784   let {a3' = realToFrac a3} in 
  785   let {a4' = realToFrac a4} in 
  786   let {a5' = C2HSImp.fromBool a5} in 
  787   preErrorCheck $ \a6' -> 
  788   blackVarianceForTenor'_ a1' a2'1  a2'2 a3' a4' a5' a6' >>= \res ->
  789   let {res' = realToFrac res} in
  790   errorCheck  a6'>>
  791   return (res')
  792 
  793 
  794 
  795 -- |returns the Black variance for a given option date and swap length
  796 blackVariance' :: (GenSwaptionVolatilityStructure sv) -> (Day) -- ^optionDate
  797  -> (Double) -- ^swapLength
  798  -> (Double) -- ^strike
  799  -> (Bool) -- ^extrapolate
  800  -> IO ((Double))
  801 blackVariance' a1 a2 a3 a4 a5 =
  802   withSwaptionVolatilityStructure a1 $ \a1' -> 
  803   withDay a2 $ \a2' -> 
  804   let {a3' = realToFrac a3} in 
  805   let {a4' = realToFrac a4} in 
  806   let {a5' = C2HSImp.fromBool a5} in 
  807   preErrorCheck $ \a6' -> 
  808   blackVariance''_ a1' a2' a3' a4' a5' a6' >>= \res ->
  809   let {res' = realToFrac res} in
  810   errorCheck  a6'>>
  811   return (res')
  812 
  813 
  814 
  815 -- |returns the Black variance for a given option time and swap length
  816 blackVariance :: (GenSwaptionVolatilityStructure sv) -> (Double) -- ^optionTime
  817  -> (Double) -- ^swapLength
  818  -> (Double) -- ^strike
  819  -> (Bool) -- ^extrapolate
  820  -> IO ((Double))
  821 blackVariance a1 a2 a3 a4 a5 =
  822   withSwaptionVolatilityStructure a1 $ \a1' -> 
  823   let {a2' = realToFrac a2} in 
  824   let {a3' = realToFrac a3} in 
  825   let {a4' = realToFrac a4} in 
  826   let {a5' = C2HSImp.fromBool a5} in 
  827   preErrorCheck $ \a6' -> 
  828   blackVariance'_ a1' a2' a3' a4' a5' a6' >>= \res ->
  829   let {res' = realToFrac res} in
  830   errorCheck  a6'>>
  831   return (res')
  832 
  833 
  834 
  835 -- |returns the Black variance for a given option tenor and swap tenor
  836 blackVarianceForPeriods :: (GenSwaptionVolatilityStructure sv) -> ((Word,TimeUnit)) -- ^optionTenor
  837  -> ((Word,TimeUnit)) -- ^swapTenor
  838  -> (Double) -- ^strike
  839  -> (Bool) -- ^extrapolate
  840  -> IO ((Double))
  841 blackVarianceForPeriods a1 a2 a3 a4 a5 =
  842   withSwaptionVolatilityStructure a1 $ \a1' -> 
  843   let {(a2'1, a2'2) = fromEnumQuantity a2} in 
  844   let {(a3'1, a3'2) = fromEnumQuantity a3} in 
  845   let {a4' = realToFrac a4} in 
  846   let {a5' = C2HSImp.fromBool a5} in 
  847   preErrorCheck $ \a6' -> 
  848   blackVarianceForPeriods'_ a1' a2'1  a2'2 a3'1  a3'2 a4' a5' a6' >>= \res ->
  849   let {res' = realToFrac res} in
  850   errorCheck  a6'>>
  851   return (res')
  852 
  853 
  854 
  855 -- |the largest swapLength for which the term structure can return vols
  856 maxSwapLength :: (GenSwaptionVolatilityStructure sv) -> IO ((Double))
  857 maxSwapLength a1 =
  858   withSwaptionVolatilityStructure a1 $ \a1' -> 
  859   preErrorCheck $ \a2' -> 
  860   maxSwapLength'_ a1' a2' >>= \res ->
  861   let {res' = realToFrac res} in
  862   errorCheck  a2'>>
  863   return (res')
  864 
  865 
  866 
  867 -- |the largest length for which the term structure can return vols
  868 maxSwapTenor :: (GenSwaptionVolatilityStructure sv) -> IO ((Int), (TimeUnit))
  869 maxSwapTenor a1 =
  870   withSwaptionVolatilityStructure a1 $ \a1' -> 
  871   preEnum $ \a2' -> 
  872   preErrorCheck $ \a3' -> 
  873   maxSwapTenor'_ a1' a2' a3' >>= \res ->
  874   let {res' = fromIntegral res} in
  875   peekEnum  a2'>>= \a2'' -> 
  876   errorCheck  a3'>>
  877   return (res', a2'')
  878 
  879 
  880 
  881 -- |returns the smile for a given option date and swap tenor
  882 smileSectionForPeriod' :: (GenSwaptionVolatilityStructure sv) -> (Day) -- ^optionDate
  883  -> ((Word,TimeUnit)) -- ^swapTenor
  884  -> (Bool) -- ^extrapolate
  885  -> IO ((SmileSection))
  886 smileSectionForPeriod' a1 a2 a3 a4 =
  887   withSwaptionVolatilityStructure a1 $ \a1' -> 
  888   withDay a2 $ \a2' -> 
  889   let {(a3'1, a3'2) = fromEnumQuantity a3} in 
  890   let {a4' = C2HSImp.fromBool a4} in 
  891   preErrorCheck $ \a5' -> 
  892   smileSectionForPeriod''_ a1' a2' a3'1  a3'2 a4' a5' >>= \res ->
  893   peekSmileSection res >>= \res' ->
  894   errorCheck  a5'>>
  895   return (res')
  896 
  897 
  898 
  899 -- |returns the smile for a given option time and swap tenor
  900 smileSectionForPeriod :: (GenSwaptionVolatilityStructure sv) -> (Double) -- ^optionTime
  901  -> ((Word,TimeUnit)) -- ^swapTenor
  902  -> (Bool) -- ^extrapolate
  903  -> IO ((SmileSection))
  904 smileSectionForPeriod a1 a2 a3 a4 =
  905   withSwaptionVolatilityStructure a1 $ \a1' -> 
  906   let {a2' = realToFrac a2} in 
  907   let {(a3'1, a3'2) = fromEnumQuantity a3} in 
  908   let {a4' = C2HSImp.fromBool a4} in 
  909   preErrorCheck $ \a5' -> 
  910   smileSectionForPeriod'_ a1' a2' a3'1  a3'2 a4' a5' >>= \res ->
  911   peekSmileSection res >>= \res' ->
  912   errorCheck  a5'>>
  913   return (res')
  914 
  915 
  916 
  917 -- |returns the smile for a given option tenor and swap length
  918 smileSectionForTenor :: (GenSwaptionVolatilityStructure sv) -> ((Word,TimeUnit)) -- ^optionTenor
  919  -> (Double) -- ^swapLength
  920  -> (Bool) -- ^extrapolate
  921  -> IO ((SmileSection))
  922 smileSectionForTenor a1 a2 a3 a4 =
  923   withSwaptionVolatilityStructure a1 $ \a1' -> 
  924   let {(a2'1, a2'2) = fromEnumQuantity a2} in 
  925   let {a3' = realToFrac a3} in 
  926   let {a4' = C2HSImp.fromBool a4} in 
  927   preErrorCheck $ \a5' -> 
  928   smileSectionForTenor'_ a1' a2'1  a2'2 a3' a4' a5' >>= \res ->
  929   peekSmileSection res >>= \res' ->
  930   errorCheck  a5'>>
  931   return (res')
  932 
  933 
  934 
  935 -- |returns the smile for a given option date and swap length
  936 smileSection' :: (GenSwaptionVolatilityStructure sv) -> (Day) -- ^optionDate
  937  -> (Double) -- ^swapLength
  938  -> (Bool) -- ^extr
  939  -> IO ((SmileSection))
  940 smileSection' a1 a2 a3 a4 =
  941   withSwaptionVolatilityStructure a1 $ \a1' -> 
  942   withDay a2 $ \a2' -> 
  943   let {a3' = realToFrac a3} in 
  944   let {a4' = C2HSImp.fromBool a4} in 
  945   preErrorCheck $ \a5' -> 
  946   smileSection''_ a1' a2' a3' a4' a5' >>= \res ->
  947   peekSmileSection res >>= \res' ->
  948   errorCheck  a5'>>
  949   return (res')
  950 
  951 
  952 
  953 -- |returns the smile for a given option time and swap length
  954 smileSection :: (GenSwaptionVolatilityStructure sv) -> (Double) -- ^optionTime
  955  -> (Double) -- ^swapLength
  956  -> (Bool) -- ^extr
  957  -> IO ((SmileSection))
  958 smileSection a1 a2 a3 a4 =
  959   withSwaptionVolatilityStructure a1 $ \a1' -> 
  960   let {a2' = realToFrac a2} in 
  961   let {a3' = realToFrac a3} in 
  962   let {a4' = C2HSImp.fromBool a4} in 
  963   preErrorCheck $ \a5' -> 
  964   smileSection'_ a1' a2' a3' a4' a5' >>= \res ->
  965   peekSmileSection res >>= \res' ->
  966   errorCheck  a5'>>
  967   return (res')
  968 
  969 
  970 
  971 -- |returns the smile for a given option tenor and swap tenor
  972 smileSectionForPeriods :: (GenSwaptionVolatilityStructure sv) -> ((Word,TimeUnit)) -- ^optionTenor
  973  -> ((Word,TimeUnit)) -- ^swapTenor
  974  -> (Bool) -- ^extr
  975  -> IO ((SmileSection))
  976 smileSectionForPeriods a1 a2 a3 a4 =
  977   withSwaptionVolatilityStructure a1 $ \a1' -> 
  978   let {(a2'1, a2'2) = fromEnumQuantity a2} in 
  979   let {(a3'1, a3'2) = fromEnumQuantity a3} in 
  980   let {a4' = C2HSImp.fromBool a4} in 
  981   preErrorCheck $ \a5' -> 
  982   smileSectionForPeriods'_ a1' a2'1  a2'2 a3'1  a3'2 a4' a5' >>= \res ->
  983   peekSmileSection res >>= \res' ->
  984   errorCheck  a5'>>
  985   return (res')
  986 
  987 
  988 
  989 -- |a smile section built directly from SABR parameters (Hagan et al. 2002), rather than
  990 -- interpolated from a 'SwaptionVolatilityStructure'
  991 sabrSmileSection :: (Double) -- ^timeToExpiry
  992  -> (Double) -- ^forward
  993  -> (Double) -- ^alpha
  994  -> (Double) -- ^beta
  995  -> (Double) -- ^nu
  996  -> (Double) -- ^rho
  997  -> (Double) -- ^shift
  998  -> (VolatilityType) -- ^volatilityType
  999  -> IO ((SmileSection))
 1000 sabrSmileSection a1 a2 a3 a4 a5 a6 a7 a8 =
 1001   let {a1' = realToFrac a1} in 
 1002   let {a2' = realToFrac a2} in 
 1003   let {a3' = realToFrac a3} in 
 1004   let {a4' = realToFrac a4} in 
 1005   let {a5' = realToFrac a5} in 
 1006   let {a6' = realToFrac a6} in 
 1007   let {a7' = realToFrac a7} in 
 1008   let {a8' = (fromIntegral . fromEnum) a8} in 
 1009   preErrorCheck $ \a9' -> 
 1010   sabrSmileSection'_ a1' a2' a3' a4' a5' a6' a7' a8' a9' >>= \res ->
 1011   peekSmileSection res >>= \res' ->
 1012   errorCheck  a9'>>
 1013   return (res')
 1014 
 1015 
 1016 
 1017 -- |as 'sabrSmileSection', but the time to expiry is derived from a date, reference date and day
 1018 -- counter rather than given directly
 1019 sabrSmileSection' :: (Day) -- ^optionDate
 1020  -> (Double) -- ^forward
 1021  -> (Double) -- ^alpha
 1022  -> (Double) -- ^beta
 1023  -> (Double) -- ^nu
 1024  -> (Double) -- ^rho
 1025  -> (Maybe Day) -- ^referenceDate
 1026  -> (DayCounter) -> (Double) -- ^shift
 1027  -> (VolatilityType) -- ^volatilityType
 1028  -> IO ((SmileSection))
 1029 sabrSmileSection' a1 a2 a3 a4 a5 a6 a7 a8 a9 a10 =
 1030   withDay a1 $ \a1' -> 
 1031   let {a2' = realToFrac a2} in 
 1032   let {a3' = realToFrac a3} in 
 1033   let {a4' = realToFrac a4} in 
 1034   let {a5' = realToFrac a5} in 
 1035   let {a6' = realToFrac a6} in 
 1036   withMaybeDay a7 $ \a7' -> 
 1037   withDayCounter a8 $ \a8' -> 
 1038   let {a9' = realToFrac a9} in 
 1039   let {a10' = (fromIntegral . fromEnum) a10} in 
 1040   preErrorCheck $ \a11' -> 
 1041   sabrSmileSection''_ a1' a2' a3' a4' a5' a6' a7' a8' a9' a10' a11' >>= \res ->
 1042   peekSmileSection res >>= \res' ->
 1043   errorCheck  a11'>>
 1044   return (res')
 1045 
 1046 
 1047 
 1048 -- |an arbitrage-free SABR smile section (Doust's approach via 'NoArbSabrSmileSection'), built
 1049 -- directly from SABR parameters like 'sabrSmileSection' but guaranteeing a proper terminal density
 1050 noArbSabrSmileSection :: (Double) -- ^timeToExpiry
 1051  -> (Double) -- ^forward
 1052  -> (Double) -- ^alpha
 1053  -> (Double) -- ^beta
 1054  -> (Double) -- ^nu
 1055  -> (Double) -- ^rho
 1056  -> (Double) -- ^shift
 1057  -> (VolatilityType) -- ^volatilityType
 1058  -> IO ((SmileSection))
 1059 noArbSabrSmileSection a1 a2 a3 a4 a5 a6 a7 a8 =
 1060   let {a1' = realToFrac a1} in 
 1061   let {a2' = realToFrac a2} in 
 1062   let {a3' = realToFrac a3} in 
 1063   let {a4' = realToFrac a4} in 
 1064   let {a5' = realToFrac a5} in 
 1065   let {a6' = realToFrac a6} in 
 1066   let {a7' = realToFrac a7} in 
 1067   let {a8' = (fromIntegral . fromEnum) a8} in 
 1068   preErrorCheck $ \a9' -> 
 1069   noArbSabrSmileSection'_ a1' a2' a3' a4' a5' a6' a7' a8' a9' >>= \res ->
 1070   peekSmileSection res >>= \res' ->
 1071   errorCheck  a9'>>
 1072   return (res')
 1073 
 1074 
 1075 
 1076 -- |as 'noArbSabrSmileSection', but the time to expiry is derived from a date and day counter
 1077 -- rather than given directly
 1078 noArbSabrSmileSection' :: (Day) -- ^optionDate
 1079  -> (Double) -- ^forward
 1080  -> (Double) -- ^alpha
 1081  -> (Double) -- ^beta
 1082  -> (Double) -- ^nu
 1083  -> (Double) -- ^rho
 1084  -> (DayCounter) -> (Double) -- ^shift
 1085  -> (VolatilityType) -- ^volatilityType
 1086  -> IO ((SmileSection))
 1087 noArbSabrSmileSection' a1 a2 a3 a4 a5 a6 a7 a8 a9 =
 1088   withDay a1 $ \a1' -> 
 1089   let {a2' = realToFrac a2} in 
 1090   let {a3' = realToFrac a3} in 
 1091   let {a4' = realToFrac a4} in 
 1092   let {a5' = realToFrac a5} in 
 1093   let {a6' = realToFrac a6} in 
 1094   withDayCounter a7 $ \a7' -> 
 1095   let {a8' = realToFrac a8} in 
 1096   let {a9' = (fromIntegral . fromEnum) a9} in 
 1097   preErrorCheck $ \a10' -> 
 1098   noArbSabrSmileSection''_ a1' a2' a3' a4' a5' a6' a7' a8' a9' a10' >>= \res ->
 1099   peekSmileSection res >>= \res' ->
 1100   errorCheck  a10'>>
 1101   return (res')
 1102 
 1103 
 1104 
 1105 -- |the volatility for the given strike, for any 'SmileSection' (however it was constructed)
 1106 smileSectionVolatility :: (SmileSection) -> (Double) -- ^strike
 1107  -> IO ((Double))
 1108 smileSectionVolatility a1 a2 =
 1109   withSmileSection a1 $ \a1' -> 
 1110   let {a2' = realToFrac a2} in 
 1111   preErrorCheck $ \a3' -> 
 1112   smileSectionVolatility'_ a1' a2' a3' >>= \res ->
 1113   let {res' = realToFrac res} in
 1114   errorCheck  a3'>>
 1115   return (res')
 1116 
 1117 
 1118 
 1119 -- |the Black variance for the given strike, for any 'SmileSection' (however it was constructed)
 1120 smileSectionVariance :: (SmileSection) -> (Double) -- ^strike
 1121  -> IO ((Double))
 1122 smileSectionVariance a1 a2 =
 1123   withSmileSection a1 $ \a1' -> 
 1124   let {a2' = realToFrac a2} in 
 1125   preErrorCheck $ \a3' -> 
 1126   smileSectionVariance'_ a1' a2' a3' >>= \res ->
 1127   let {res' = realToFrac res} in
 1128   errorCheck  a3'>>
 1129   return (res')
 1130 
 1131 
 1132 
 1133 -- |the ATM level baked into the 'SmileSection' at construction (or later re-anchored via
 1134 -- 'atmSmileSection'), for any 'SmileSection' (however it was constructed)
 1135 smileSectionAtmLevel :: (SmileSection) -> IO ((Double))
 1136 smileSectionAtmLevel a1 =
 1137   withSmileSection a1 $ \a1' -> 
 1138   preErrorCheck $ \a2' -> 
 1139   smileSectionAtmLevel'_ a1' a2' >>= \res ->
 1140   let {res' = realToFrac res} in
 1141   errorCheck  a2'>>
 1142   return (res')
 1143 
 1144 
 1145 
 1146 -- |the (non-discounted-by-default) price of a European option with the given strike\/type,
 1147 -- for any 'SmileSection' (however it was constructed)
 1148 smileSectionOptionPrice :: (SmileSection) -> (Double) -- ^strike
 1149  -> (OptionType) -- ^type
 1150  -> (Double) -- ^discount
 1151  -> IO ((Double))
 1152 smileSectionOptionPrice a1 a2 a3 a4 =
 1153   withSmileSection a1 $ \a1' -> 
 1154   let {a2' = realToFrac a2} in 
 1155   let {a3' = fromEnumC a3} in 
 1156   let {a4' = realToFrac a4} in 
 1157   preErrorCheck $ \a5' -> 
 1158   smileSectionOptionPrice'_ a1' a2' a3' a4' a5' >>= \res ->
 1159   let {res' = realToFrac res} in
 1160   errorCheck  a5'>>
 1161   return (res')
 1162 
 1163 
 1164 
 1165 -- |the price of a cash-or-nothing digital option with the given strike\/type, approximated via a
 1166 -- call\/put spread of width @gap@, for any 'SmileSection' (however it was constructed)
 1167 smileSectionDigitalOptionPrice :: (SmileSection) -> (Double) -- ^strike
 1168  -> (OptionType) -- ^type
 1169  -> (Double) -- ^discount
 1170  -> (Double) -- ^gap
 1171  -> IO ((Double))
 1172 smileSectionDigitalOptionPrice a1 a2 a3 a4 a5 =
 1173   withSmileSection a1 $ \a1' -> 
 1174   let {a2' = realToFrac a2} in 
 1175   let {a3' = fromEnumC a3} in 
 1176   let {a4' = realToFrac a4} in 
 1177   let {a5' = realToFrac a5} in 
 1178   preErrorCheck $ \a6' -> 
 1179   smileSectionDigitalOptionPrice'_ a1' a2' a3' a4' a5' a6' >>= \res ->
 1180   let {res' = realToFrac res} in
 1181   errorCheck  a6'>>
 1182   return (res')
 1183 
 1184 
 1185 
 1186 -- |the risk-neutral probability density at the given strike, approximated via a finite difference
 1187 -- of width @gap@ on 'smileSectionOptionPrice', for any 'SmileSection' (however it was constructed)
 1188 smileSectionDensity :: (SmileSection) -> (Double) -- ^strike
 1189  -> (Double) -- ^discount
 1190  -> (Double) -- ^gap
 1191  -> IO ((Double))
 1192 smileSectionDensity a1 a2 a3 a4 =
 1193   withSmileSection a1 $ \a1' -> 
 1194   let {a2' = realToFrac a2} in 
 1195   let {a3' = realToFrac a3} in 
 1196   let {a4' = realToFrac a4} in 
 1197   preErrorCheck $ \a5' -> 
 1198   smileSectionDensity'_ a1' a2' a3' a4' a5' >>= \res ->
 1199   let {res' = realToFrac res} in
 1200   errorCheck  a5'>>
 1201   return (res')
 1202 
 1203 
 1204 
 1205 -- |a flat-volatility smile section: 'volatility' returns @vol@ for every strike.
 1206 -- 'Nothing'\/'Nothing' reproduce upstream's own defaults for @referenceDate@\/@atmLevel@.
 1207 flatSmileSection :: (Day) -> (Double) -- ^vol
 1208  -> (DayCounter) -> (Maybe Day) -- ^referenceDate
 1209  -> (Maybe Double) -- ^atmLevel
 1210  -> (VolatilityType) -- ^type
 1211  -> (Double) -- ^shift
 1212  -> IO ((SmileSection))
 1213 flatSmileSection a1 a2 a3 a4 a5 a6 a7 =
 1214   withDay a1 $ \a1' -> 
 1215   let {a2' = realToFrac a2} in 
 1216   withDayCounter a3 $ \a3' -> 
 1217   withMaybeDay a4 $ \a4' -> 
 1218   let {a5' = fromMaybeDouble a5} in 
 1219   let {a6' = (fromIntegral . fromEnum) a6} in 
 1220   let {a7' = realToFrac a7} in 
 1221   preErrorCheck $ \a8' -> 
 1222   flatSmileSection'_ a1' a2' a3' a4' a5' a6' a7' a8' >>= \res ->
 1223   peekSmileSection res >>= \res' ->
 1224   errorCheck  a8'>>
 1225   return (res')
 1226 
 1227 
 1228 
 1229 -- |a 'SmileSection' whose volatility at every strike is @source@'s plus @spread@ (which may
 1230 -- change over time, since it's a live 'GenQuote' rather than a fixed number)
 1231 spreadedSmileSection :: (SmileSection) -> (GenQuote q) -> IO ((SmileSection))
 1232 spreadedSmileSection a1 a2 =
 1233   withSmileSection a1 $ \a1' -> 
 1234   withQuote a2 $ \a2' -> 
 1235   preErrorCheck $ \a3' -> 
 1236   spreadedSmileSection'_ a1' a2' a3' >>= \res ->
 1237   peekSmileSection res >>= \res' ->
 1238   errorCheck  a3'>>
 1239   return (res')
 1240 
 1241 
 1242 
 1243 -- |@source@ re-anchored to a different ATM level ('Nothing' reproduces upstream's own default,
 1244 -- which recomputes the ATM level from @source@ itself). @source@'s volatility at every other
 1245 -- strike is unchanged -- use 'smileSectionAtmLevel' to observe what this changed.
 1246 atmSmileSection :: (SmileSection) -> (Maybe Double) -- ^atm
 1247  -> IO ((SmileSection))
 1248 atmSmileSection a1 a2 =
 1249   withSmileSection a1 $ \a1' -> 
 1250   let {a2' = fromMaybeDouble a2} in 
 1251   preErrorCheck $ \a3' -> 
 1252   atmSmileSection'_ a1' a2' a3' >>= \res ->
 1253   peekSmileSection res >>= \res' ->
 1254   errorCheck  a3'>>
 1255   return (res')
 1256 
 1257 
 1258 
 1259 -- |a smile section calibrated to a market smile (strikes/vols given directly, not as live
 1260 -- quotes -- calibration runs once, eagerly, at construction). alpha\/beta\/nu\/rho\/vegaWeighted
 1261 -- are the SABR calibration's initial guess and fixed\/free flags; 'sabrEndCriteria'\/
 1262 -- 'sabrOptimizationMethod' default to 'Nothing', which falls back to QuantLib's own internal
 1263 -- defaults -- a caller-supplied 'EndCriteria'\/'OptimizationMethod' is safe to pass here since
 1264 -- both are shared_ptr-boxed on the C++ side (see the qlaux.h comment above the
 1265 -- QlEndCriteria\/QlOptimizationMethod typedefs), so the copy this object's constructor keeps
 1266 -- survives regardless of when Haskell's own handle is collected.
 1267 sabrInterpolatedSmileSection :: Day -- ^optionDate
 1268   -> GenQuote q1 -- ^forward
 1269   -> [Double] -- ^strikes
 1270   -> Bool -- ^hasFloatingStrikes
 1271   -> GenQuote q2 -- ^atmVolatility
 1272   -> [GenQuote q3] -- ^vols
 1273   -> Double -- ^alpha
 1274   -> Double -- ^beta
 1275   -> Double -- ^nu
 1276   -> Double -- ^rho
 1277   -> SabrInterpolatedSmileSectionOpts -> IO SabrInterpolatedSmileSection
 1278 sabrInterpolatedSmileSection optionDate forward strikes hasFloatingStrikes atmVolatility vols
 1279   alpha beta nu rho opts = do
 1280   dc <- maybe (dayCounter Actual365FixedStandard) return (sabrDayCounter opts)
 1281   sabrInterpolatedSmileSection_ optionDate forward strikes hasFloatingStrikes atmVolatility vols
 1282     alpha beta nu rho (sabrIsAlphaFixed opts) (sabrIsBetaFixed opts) (sabrIsNuFixed opts)
 1283     (sabrIsRhoFixed opts) (sabrVegaWeighted opts) (sabrEndCriteria opts) (sabrOptimizationMethod opts)
 1284     dc (sabrShift opts)
 1285 
 1286 sabrInterpolatedSmileSection_ :: (Day) -> (GenQuote q1) -- ^forward
 1287  -> ([Double]) -- ^strikes
 1288  -> (Bool) -- ^hasFloatingStrikes
 1289  -> (GenQuote q2) -- ^atmVolatility
 1290  -> ([GenQuote q3]) -- ^vols
 1291  -> (Double) -- ^alpha
 1292  -> (Double) -- ^beta
 1293  -> (Double) -- ^nu
 1294  -> (Double) -- ^rho
 1295  -> (Bool) -- ^isAlphaFixed
 1296  -> (Bool) -- ^isBetaFixed
 1297  -> (Bool) -- ^isNuFixed
 1298  -> (Bool) -- ^isRhoFixed
 1299  -> (Bool) -- ^vegaWeighted
 1300  -> (Maybe EndCriteria) -> (Maybe OptimizationMethod) -> (DayCounter) -> (Double) -- ^shift
 1301  -> IO ((SabrInterpolatedSmileSection))
 1302 sabrInterpolatedSmileSection_ a1 a2 a3 a4 a5 a6 a7 a8 a9 a10 a11 a12 a13 a14 a15 a16 a17 a18 a19 =
 1303   withDay a1 $ \a1' -> 
 1304   withQuote a2 $ \a2' -> 
 1305   withDoubleArray a3 $ \(a3'1, a3'2) -> 
 1306   let {a4' = C2HSImp.fromBool a4} in 
 1307   withQuote a5 $ \a5' -> 
 1308   withQuoteArray a6 $ \(a6'1, a6'2) -> 
 1309   let {a7' = realToFrac a7} in 
 1310   let {a8' = realToFrac a8} in 
 1311   let {a9' = realToFrac a9} in 
 1312   let {a10' = realToFrac a10} in 
 1313   let {a11' = C2HSImp.fromBool a11} in 
 1314   let {a12' = C2HSImp.fromBool a12} in 
 1315   let {a13' = C2HSImp.fromBool a13} in 
 1316   let {a14' = C2HSImp.fromBool a14} in 
 1317   let {a15' = C2HSImp.fromBool a15} in 
 1318   withMaybeEndCriteria a16 $ \a16' -> 
 1319   withMaybeOptimizationMethod a17 $ \a17' -> 
 1320   withDayCounter a18 $ \a18' -> 
 1321   let {a19' = realToFrac a19} in 
 1322   preErrorCheck $ \a20' -> 
 1323   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 ->
 1324   peekSabrInterpolatedSmileSection res >>= \res' ->
 1325   errorCheck  a20'>>
 1326   return (res')
 1327 
 1328 
 1329 
 1330 -- |upcast to the generic 'SmileSection' interface (e.g. for 'smileSectionVolatility'\/'smileSectionVariance').
 1331 -- A fresh-@shared_ptr@ upcast, always safe -- not the reverse (downcast) direction.
 1332 sabrInterpolatedSmileSectionAsSmileSection :: (SabrInterpolatedSmileSection) -> IO ((SmileSection))
 1333 sabrInterpolatedSmileSectionAsSmileSection a1 =
 1334   withSabrInterpolatedSmileSection a1 $ \a1' -> 
 1335   preErrorCheck $ \a2' -> 
 1336   sabrInterpolatedSmileSectionAsSmileSection'_ a1' a2' >>= \res ->
 1337   peekSmileSection res >>= \res' ->
 1338   errorCheck  a2'>>
 1339   return (res')
 1340 
 1341 
 1342 
 1343 -- |calibrated alpha (post-fit; can differ from the initial guess passed to
 1344 -- 'sabrInterpolatedSmileSection' unless @sabrIsAlphaFixed@ was set).
 1345 sabrInterpolatedSmileSectionAlpha :: (SabrInterpolatedSmileSection) -> IO ((Double))
 1346 sabrInterpolatedSmileSectionAlpha a1 =
 1347   withSabrInterpolatedSmileSection a1 $ \a1' -> 
 1348   preErrorCheck $ \a2' -> 
 1349   sabrInterpolatedSmileSectionAlpha'_ a1' a2' >>= \res ->
 1350   let {res' = realToFrac res} in
 1351   errorCheck  a2'>>
 1352   return (res')
 1353 
 1354 
 1355 
 1356 -- |calibrated beta, see 'sabrInterpolatedSmileSectionAlpha'
 1357 sabrInterpolatedSmileSectionBeta :: (SabrInterpolatedSmileSection) -> IO ((Double))
 1358 sabrInterpolatedSmileSectionBeta a1 =
 1359   withSabrInterpolatedSmileSection a1 $ \a1' -> 
 1360   preErrorCheck $ \a2' -> 
 1361   sabrInterpolatedSmileSectionBeta'_ a1' a2' >>= \res ->
 1362   let {res' = realToFrac res} in
 1363   errorCheck  a2'>>
 1364   return (res')
 1365 
 1366 
 1367 
 1368 -- |calibrated nu, see 'sabrInterpolatedSmileSectionAlpha'
 1369 sabrInterpolatedSmileSectionNu :: (SabrInterpolatedSmileSection) -> IO ((Double))
 1370 sabrInterpolatedSmileSectionNu a1 =
 1371   withSabrInterpolatedSmileSection a1 $ \a1' -> 
 1372   preErrorCheck $ \a2' -> 
 1373   sabrInterpolatedSmileSectionNu'_ a1' a2' >>= \res ->
 1374   let {res' = realToFrac res} in
 1375   errorCheck  a2'>>
 1376   return (res')
 1377 
 1378 
 1379 
 1380 -- |calibrated rho, see 'sabrInterpolatedSmileSectionAlpha'
 1381 sabrInterpolatedSmileSectionRho :: (SabrInterpolatedSmileSection) -> IO ((Double))
 1382 sabrInterpolatedSmileSectionRho a1 =
 1383   withSabrInterpolatedSmileSection a1 $ \a1' -> 
 1384   preErrorCheck $ \a2' -> 
 1385   sabrInterpolatedSmileSectionRho'_ a1' a2' >>= \res ->
 1386   let {res' = realToFrac res} in
 1387   errorCheck  a2'>>
 1388   return (res')
 1389 
 1390 
 1391 
 1392 -- |root-mean-square calibration error
 1393 sabrInterpolatedSmileSectionRmsError :: (SabrInterpolatedSmileSection) -> IO ((Double))
 1394 sabrInterpolatedSmileSectionRmsError a1 =
 1395   withSabrInterpolatedSmileSection a1 $ \a1' -> 
 1396   preErrorCheck $ \a2' -> 
 1397   sabrInterpolatedSmileSectionRmsError'_ a1' a2' >>= \res ->
 1398   let {res' = realToFrac res} in
 1399   errorCheck  a2'>>
 1400   return (res')
 1401 
 1402 
 1403 
 1404 -- |maximum calibration error
 1405 sabrInterpolatedSmileSectionMaxError :: (SabrInterpolatedSmileSection) -> IO ((Double))
 1406 sabrInterpolatedSmileSectionMaxError a1 =
 1407   withSabrInterpolatedSmileSection a1 $ \a1' -> 
 1408   preErrorCheck $ \a2' -> 
 1409   sabrInterpolatedSmileSectionMaxError'_ a1' a2' >>= \res ->
 1410   let {res' = realToFrac res} in
 1411   errorCheck  a2'>>
 1412   return (res')
 1413 
 1414 
 1415 
 1416 -- |the reason the SABR calibration's optimizer stopped
 1417 sabrInterpolatedSmileSectionEndCriteria :: (SabrInterpolatedSmileSection) -> IO ((EndCriteriaType))
 1418 sabrInterpolatedSmileSectionEndCriteria a1 =
 1419   withSabrInterpolatedSmileSection a1 $ \a1' -> 
 1420   preErrorCheck $ \a2' -> 
 1421   sabrInterpolatedSmileSectionEndCriteria'_ a1' a2' >>= \res ->
 1422   let {res' = (toEnum . fromIntegral) res} in
 1423   errorCheck  a2'>>
 1424   return (res')
 1425 
 1426 
 1427 
 1428 -- |implements the conversion between swap dates and swap (time) length
 1429 swapLength' :: (GenSwaptionVolatilityStructure sv) -> (Day) -- ^start
 1430  -> (Day) -- ^end
 1431  -> IO ((Double))
 1432 swapLength' a1 a2 a3 =
 1433   withSwaptionVolatilityStructure a1 $ \a1' -> 
 1434   withDay a2 $ \a2' -> 
 1435   withDay a3 $ \a3' -> 
 1436   preErrorCheck $ \a4' -> 
 1437   swapLength''_ a1' a2' a3' a4' >>= \res ->
 1438   let {res' = realToFrac res} in
 1439   errorCheck  a4'>>
 1440   return (res')
 1441 
 1442 
 1443 
 1444 -- |implements the conversion between swap tenor and swap (time) length
 1445 swapLength :: (GenSwaptionVolatilityStructure sv) -> ((Word,TimeUnit)) -> IO ((Double))
 1446 swapLength a1 a2 =
 1447   withSwaptionVolatilityStructure a1 $ \a1' -> 
 1448   let {(a2'1, a2'2) = fromEnumQuantity a2} in 
 1449   preErrorCheck $ \a3' -> 
 1450   swapLength'_ a1' a2'1  a2'2 a3' >>= \res ->
 1451   let {res' = realToFrac res} in
 1452   errorCheck  a3'>>
 1453   return (res')
 1454 
 1455 
 1456 
 1457 -- |returns the volatility for a given option date and swap tenor
 1458 volatilityForPeriod' :: (GenSwaptionVolatilityStructure sv) -> (Day) -- ^optionDate
 1459  -> ((Word,TimeUnit)) -- ^swapTenor
 1460  -> (Double) -- ^strike
 1461  -> (Bool) -- ^extrapolate
 1462  -> IO ((Double))
 1463 volatilityForPeriod' a1 a2 a3 a4 a5 =
 1464   withSwaptionVolatilityStructure a1 $ \a1' -> 
 1465   withDay a2 $ \a2' -> 
 1466   let {(a3'1, a3'2) = fromEnumQuantity a3} in 
 1467   let {a4' = realToFrac a4} in 
 1468   let {a5' = C2HSImp.fromBool a5} in 
 1469   preErrorCheck $ \a6' -> 
 1470   volatilityForPeriod''_ a1' a2' a3'1  a3'2 a4' a5' a6' >>= \res ->
 1471   let {res' = realToFrac res} in
 1472   errorCheck  a6'>>
 1473   return (res')
 1474 
 1475 
 1476 
 1477 -- |returns the volatility for a given option time and swap tenor
 1478 volatilityForPeriod :: (GenSwaptionVolatilityStructure sv) -> (Double) -- ^optionTime
 1479  -> ((Word,TimeUnit)) -- ^swapTenor
 1480  -> (Double) -- ^strike
 1481  -> (Bool) -- ^extrapolate
 1482  -> IO ((Double))
 1483 volatilityForPeriod a1 a2 a3 a4 a5 =
 1484   withSwaptionVolatilityStructure a1 $ \a1' -> 
 1485   let {a2' = realToFrac a2} in 
 1486   let {(a3'1, a3'2) = fromEnumQuantity a3} in 
 1487   let {a4' = realToFrac a4} in 
 1488   let {a5' = C2HSImp.fromBool a5} in 
 1489   preErrorCheck $ \a6' -> 
 1490   volatilityForPeriod'_ a1' a2' a3'1  a3'2 a4' a5' a6' >>= \res ->
 1491   let {res' = realToFrac res} in
 1492   errorCheck  a6'>>
 1493   return (res')
 1494 
 1495 
 1496 
 1497 -- |returns the volatility for a given option tenor and swap length
 1498 volatilityForTenor :: (GenSwaptionVolatilityStructure sv) -> ((Word,TimeUnit)) -- ^optionTenor
 1499  -> (Double) -- ^swapLength
 1500  -> (Double) -- ^strike
 1501  -> (Bool) -- ^extrapolate
 1502  -> IO ((Double))
 1503 volatilityForTenor a1 a2 a3 a4 a5 =
 1504   withSwaptionVolatilityStructure a1 $ \a1' -> 
 1505   let {(a2'1, a2'2) = fromEnumQuantity a2} in 
 1506   let {a3' = realToFrac a3} in 
 1507   let {a4' = realToFrac a4} in 
 1508   let {a5' = C2HSImp.fromBool a5} in 
 1509   preErrorCheck $ \a6' -> 
 1510   volatilityForTenor'_ a1' a2'1  a2'2 a3' a4' a5' a6' >>= \res ->
 1511   let {res' = realToFrac res} in
 1512   errorCheck  a6'>>
 1513   return (res')
 1514 
 1515 
 1516 
 1517 -- |returns the volatility for a given option date and swap length
 1518 volatilityForTenor' :: (GenSwaptionVolatilityStructure sv) -> (Day) -- ^optionDate
 1519  -> (Double) -- ^swapLength
 1520  -> (Double) -- ^strike
 1521  -> (Bool) -- ^extrapolate
 1522  -> IO ((Double))
 1523 volatilityForTenor' a1 a2 a3 a4 a5 =
 1524   withSwaptionVolatilityStructure a1 $ \a1' -> 
 1525   withDay a2 $ \a2' -> 
 1526   let {a3' = realToFrac a3} in 
 1527   let {a4' = realToFrac a4} in 
 1528   let {a5' = C2HSImp.fromBool a5} in 
 1529   preErrorCheck $ \a6' -> 
 1530   volatilityForTenor''_ a1' a2' a3' a4' a5' a6' >>= \res ->
 1531   let {res' = realToFrac res} in
 1532   errorCheck  a6'>>
 1533   return (res')
 1534 
 1535 
 1536 
 1537 -- |returns the volatility for a given option time and swap length
 1538 volatility :: (GenSwaptionVolatilityStructure sv) -> (Double) -- ^optionTime
 1539  -> (Double) -- ^swapLength
 1540  -> (Double) -- ^strike
 1541  -> (Bool) -- ^extrapolate
 1542  -> IO ((Double))
 1543 volatility a1 a2 a3 a4 a5 =
 1544   withSwaptionVolatilityStructure a1 $ \a1' -> 
 1545   let {a2' = realToFrac a2} in 
 1546   let {a3' = realToFrac a3} in 
 1547   let {a4' = realToFrac a4} in 
 1548   let {a5' = C2HSImp.fromBool a5} in 
 1549   preErrorCheck $ \a6' -> 
 1550   volatility'_ a1' a2' a3' a4' a5' a6' >>= \res ->
 1551   let {res' = realToFrac res} in
 1552   errorCheck  a6'>>
 1553   return (res')
 1554 
 1555 
 1556 
 1557 -- |returns the volatility for a given option tenor and swap tenor
 1558 volatilityForPeriods :: (GenSwaptionVolatilityStructure sv) -> ((Word,TimeUnit)) -- ^optionTenor
 1559  -> ((Word,TimeUnit)) -- ^swapTenor
 1560  -> (Double) -- ^strike
 1561  -> (Bool) -- ^extrapolate
 1562  -> IO ((Double))
 1563 volatilityForPeriods a1 a2 a3 a4 a5 =
 1564   withSwaptionVolatilityStructure a1 $ \a1' -> 
 1565   let {(a2'1, a2'2) = fromEnumQuantity a2} in 
 1566   let {(a3'1, a3'2) = fromEnumQuantity a3} in 
 1567   let {a4' = realToFrac a4} in 
 1568   let {a5' = C2HSImp.fromBool a5} in 
 1569   preErrorCheck $ \a6' -> 
 1570   volatilityForPeriods'_ a1' a2'1  a2'2 a3'1  a3'2 a4' a5' a6' >>= \res ->
 1571   let {res' = realToFrac res} in
 1572   errorCheck  a6'>>
 1573   return (res')
 1574 
 1575 
 1576 
 1577 -- |A constant callable-bond volatility, no time-strike dependence -- floating reference date,
 1578 -- floating market data
 1579 callableBondConstantVolatility' :: (Word) -> (Calendar) -> (GenQuote q) -> (DayCounter) -> IO ((CallableBondVolatilityStructure))
 1580 callableBondConstantVolatility' a1 a2 a3 a4 =
 1581   let {a1' = fromIntegral a1} in 
 1582   withCalendar a2 $ \a2' -> 
 1583   withQuote a3 $ \a3' -> 
 1584   withDayCounter a4 $ \a4' -> 
 1585   preErrorCheck $ \a5' -> 
 1586   callableBondConstantVolatility''_ a1' a2' a3' a4' a5' >>= \res ->
 1587   peekCallableBondVolatilityStructure res >>= \res' ->
 1588   errorCheck  a5'>>
 1589   return (res')
 1590 
 1591 
 1592 
 1593 -- |as 'callableBondConstantVolatility\'', but a fixed reference date
 1594 callableBondConstantVolatility :: (Day) -> (GenQuote q) -> (DayCounter) -> IO ((CallableBondVolatilityStructure))
 1595 callableBondConstantVolatility a1 a2 a3 =
 1596   withDay a1 $ \a1' -> 
 1597   withQuote a2 $ \a2' -> 
 1598   withDayCounter a3 $ \a3' -> 
 1599   preErrorCheck $ \a4' -> 
 1600   callableBondConstantVolatility'_ a1' a2' a3' a4' >>= \res ->
 1601   peekCallableBondVolatilityStructure res >>= \res' ->
 1602   errorCheck  a4'>>
 1603   return (res')
 1604 
 1605 
 1606 
 1607 -- |fixed reference date, floating market data
 1608 constantCapFloorTermVolatility' :: (Day) -> (Calendar) -> (BusinessDayConvention) -> (GenQuote q) -> (DayCounter) -> IO ((CapFloorTermVolatilityStructure))
 1609 constantCapFloorTermVolatility' a1 a2 a3 a4 a5 =
 1610   withDay a1 $ \a1' -> 
 1611   withCalendar a2 $ \a2' -> 
 1612   let {a3' = fromEnumC a3} in 
 1613   withQuote a4 $ \a4' -> 
 1614   withDayCounter a5 $ \a5' -> 
 1615   preErrorCheck $ \a6' -> 
 1616   constantCapFloorTermVolatility''_ a1' a2' a3' a4' a5' a6' >>= \res ->
 1617   peekCapFloorTermVolatilityStructure res >>= \res' ->
 1618   errorCheck  a6'>>
 1619   return (res')
 1620 
 1621 
 1622 
 1623 -- |floating reference date, floating market data
 1624 constantCapFloorTermVolatility :: (Word) -> (Calendar) -> (BusinessDayConvention) -> (GenQuote q) -> (DayCounter) -> IO ((CapFloorTermVolatilityStructure))
 1625 constantCapFloorTermVolatility a1 a2 a3 a4 a5 =
 1626   let {a1' = fromIntegral a1} in 
 1627   withCalendar a2 $ \a2' -> 
 1628   let {a3' = fromEnumC a3} in 
 1629   withQuote a4 $ \a4' -> 
 1630   withDayCounter a5 $ \a5' -> 
 1631   preErrorCheck $ \a6' -> 
 1632   constantCapFloorTermVolatility'_ a1' a2' a3' a4' a5' a6' >>= \res ->
 1633   peekCapFloorTermVolatilityStructure res >>= \res' ->
 1634   errorCheck  a6'>>
 1635   return (res')
 1636 
 1637 
 1638 
 1639 -- |returns the volatility for a given option tenor and strike
 1640 capFloorVolatilityForPeriod :: (GenCapFloorTermVolatilityStructure c) -> ((Word,TimeUnit)) -- ^optionTenor
 1641  -> (Double) -- ^strike
 1642  -> (Bool) -- ^extrapolate
 1643  -> IO ((Double))
 1644 capFloorVolatilityForPeriod a1 a2 a3 a4 =
 1645   withGenCapFloorTermVolatilityStructure a1 $ \a1' -> 
 1646   let {(a2'1, a2'2) = fromEnumQuantity a2} in 
 1647   let {a3' = realToFrac a3} in 
 1648   let {a4' = C2HSImp.fromBool a4} in 
 1649   preErrorCheck $ \a5' -> 
 1650   capFloorVolatilityForPeriod'_ a1' a2'1  a2'2 a3' a4' a5' >>= \res ->
 1651   let {res' = realToFrac res} in
 1652   errorCheck  a5'>>
 1653   return (res')
 1654 
 1655 
 1656 
 1657 -- |returns the volatility for a given option date and strike
 1658 capFloorVolatilityForDate :: (GenCapFloorTermVolatilityStructure c) -> (Day) -- ^optionDate
 1659  -> (Double) -- ^strike
 1660  -> (Bool) -- ^extrapolate
 1661  -> IO ((Double))
 1662 capFloorVolatilityForDate a1 a2 a3 a4 =
 1663   withGenCapFloorTermVolatilityStructure a1 $ \a1' -> 
 1664   withDay a2 $ \a2' -> 
 1665   let {a3' = realToFrac a3} in 
 1666   let {a4' = C2HSImp.fromBool a4} in 
 1667   preErrorCheck $ \a5' -> 
 1668   capFloorVolatilityForDate'_ a1' a2' a3' a4' a5' >>= \res ->
 1669   let {res' = realToFrac res} in
 1670   errorCheck  a5'>>
 1671   return (res')
 1672 
 1673 
 1674 
 1675 -- |returns the volatility for a given option time and strike
 1676 capFloorVolatilityForTime :: (GenCapFloorTermVolatilityStructure c) -> (Double) -- ^optionTime
 1677  -> (Double) -- ^strike
 1678  -> (Bool) -- ^extrapolate
 1679  -> IO ((Double))
 1680 capFloorVolatilityForTime a1 a2 a3 a4 =
 1681   withGenCapFloorTermVolatilityStructure a1 $ \a1' -> 
 1682   let {a2' = realToFrac a2} in 
 1683   let {a3' = realToFrac a3} in 
 1684   let {a4' = C2HSImp.fromBool a4} in 
 1685   preErrorCheck $ \a5' -> 
 1686   capFloorVolatilityForTime'_ a1' a2' a3' a4' a5' >>= \res ->
 1687   let {res' = realToFrac res} in
 1688   errorCheck  a5'>>
 1689   return (res')
 1690 
 1691 
 1692 
 1693 -- |The option-tenor grid's dates, calendar-advanced from the curve's reference date.
 1694 capFloorTermVolCurveOptionDates :: (CapFloorTermVolCurve) -> IO (([Day]))
 1695 capFloorTermVolCurveOptionDates a1 =
 1696   withCapFloorTermVolCurve a1 $ \a1' -> 
 1697   preArray $ \(a2'1, a2'2) -> 
 1698   capFloorTermVolCurveOptionDates'_ a1' a2'1  a2'2 >>
 1699   peekDayArray  a2'1  a2'2>>= \a2'' -> 
 1700   return (a2'')
 1701 
 1702 
 1703 
 1704 -- |As 'capFloorTermVolCurveOptionDates', in year fractions from the curve's reference date.
 1705 capFloorTermVolCurveOptionTimes :: (CapFloorTermVolCurve) -> IO (([Double]))
 1706 capFloorTermVolCurveOptionTimes a1 =
 1707   withCapFloorTermVolCurve a1 $ \a1' -> 
 1708   preArray $ \(a2'1, a2'2) -> 
 1709   capFloorTermVolCurveOptionTimes'_ a1' a2'1  a2'2 >>
 1710   peekDoubleArray  a2'1  a2'2>>= \a2'' -> 
 1711   return (a2'')
 1712 
 1713 
 1714 
 1715 -- |The option-tenor grid's dates, calendar-advanced from the surface's reference date.
 1716 capFloorTermVolSurfaceOptionDates :: (CapFloorTermVolSurface) -> IO (([Day]))
 1717 capFloorTermVolSurfaceOptionDates a1 =
 1718   withCapFloorTermVolSurface a1 $ \a1' -> 
 1719   preArray $ \(a2'1, a2'2) -> 
 1720   capFloorTermVolSurfaceOptionDates'_ a1' a2'1  a2'2 >>
 1721   peekDayArray  a2'1  a2'2>>= \a2'' -> 
 1722   return (a2'')
 1723 
 1724 
 1725 
 1726 -- |As 'capFloorTermVolSurfaceOptionDates', in year fractions from the surface's reference date.
 1727 capFloorTermVolSurfaceOptionTimes :: (CapFloorTermVolSurface) -> IO (([Double]))
 1728 capFloorTermVolSurfaceOptionTimes a1 =
 1729   withCapFloorTermVolSurface a1 $ \a1' -> 
 1730   preArray $ \(a2'1, a2'2) -> 
 1731   capFloorTermVolSurfaceOptionTimes'_ a1' a2'1  a2'2 >>
 1732   peekDoubleArray  a2'1  a2'2>>= \a2'' -> 
 1733   return (a2'')
 1734 
 1735 
 1736 
 1737 -- |spot at-the-money volatility for a given option tenor
 1738 atmVolForPeriod :: (GenBlackAtmVolCurve b) -> ((Word,TimeUnit)) -- ^optionTenor
 1739  -> (Bool) -- ^extrapolate
 1740  -> IO ((Double))
 1741 atmVolForPeriod a1 a2 a3 =
 1742   withGenBlackAtmVolCurve a1 $ \a1' -> 
 1743   let {(a2'1, a2'2) = fromEnumQuantity a2} in 
 1744   let {a3' = C2HSImp.fromBool a3} in 
 1745   preErrorCheck $ \a4' -> 
 1746   atmVolForPeriod'_ a1' a2'1  a2'2 a3' a4' >>= \res ->
 1747   let {res' = realToFrac res} in
 1748   errorCheck  a4'>>
 1749   return (res')
 1750 
 1751 
 1752 
 1753 -- |spot at-the-money volatility for a given option maturity date
 1754 atmVolForDate :: (GenBlackAtmVolCurve b) -> (Day) -- ^maturity
 1755  -> (Bool) -- ^extrapolate
 1756  -> IO ((Double))
 1757 atmVolForDate a1 a2 a3 =
 1758   withGenBlackAtmVolCurve a1 $ \a1' -> 
 1759   withDay a2 $ \a2' -> 
 1760   let {a3' = C2HSImp.fromBool a3} in 
 1761   preErrorCheck $ \a4' -> 
 1762   atmVolForDate'_ a1' a2' a3' a4' >>= \res ->
 1763   let {res' = realToFrac res} in
 1764   errorCheck  a4'>>
 1765   return (res')
 1766 
 1767 
 1768 
 1769 -- |spot at-the-money volatility for a given option maturity time
 1770 atmVolForTime :: (GenBlackAtmVolCurve b) -> (Double) -- ^maturity
 1771  -> (Bool) -- ^extrapolate
 1772  -> IO ((Double))
 1773 atmVolForTime a1 a2 a3 =
 1774   withGenBlackAtmVolCurve a1 $ \a1' -> 
 1775   let {a2' = realToFrac a2} in 
 1776   let {a3' = C2HSImp.fromBool a3} in 
 1777   preErrorCheck $ \a4' -> 
 1778   atmVolForTime'_ a1' a2' a3' a4' >>= \res ->
 1779   let {res' = realToFrac res} in
 1780   errorCheck  a4'>>
 1781   return (res')
 1782 
 1783 
 1784 
 1785 -- |spot at-the-money variance for a given option tenor
 1786 atmVarianceForPeriod :: (GenBlackAtmVolCurve b) -> ((Word,TimeUnit)) -- ^optionTenor
 1787  -> (Bool) -- ^extrapolate
 1788  -> IO ((Double))
 1789 atmVarianceForPeriod a1 a2 a3 =
 1790   withGenBlackAtmVolCurve a1 $ \a1' -> 
 1791   let {(a2'1, a2'2) = fromEnumQuantity a2} in 
 1792   let {a3' = C2HSImp.fromBool a3} in 
 1793   preErrorCheck $ \a4' -> 
 1794   atmVarianceForPeriod'_ a1' a2'1  a2'2 a3' a4' >>= \res ->
 1795   let {res' = realToFrac res} in
 1796   errorCheck  a4'>>
 1797   return (res')
 1798 
 1799 
 1800 
 1801 -- |spot at-the-money variance for a given option maturity date
 1802 atmVarianceForDate :: (GenBlackAtmVolCurve b) -> (Day) -- ^maturity
 1803  -> (Bool) -- ^extrapolate
 1804  -> IO ((Double))
 1805 atmVarianceForDate a1 a2 a3 =
 1806   withGenBlackAtmVolCurve a1 $ \a1' -> 
 1807   withDay a2 $ \a2' -> 
 1808   let {a3' = C2HSImp.fromBool a3} in 
 1809   preErrorCheck $ \a4' -> 
 1810   atmVarianceForDate'_ a1' a2' a3' a4' >>= \res ->
 1811   let {res' = realToFrac res} in
 1812   errorCheck  a4'>>
 1813   return (res')
 1814 
 1815 
 1816 
 1817 -- |spot at-the-money variance for a given option maturity time
 1818 atmVarianceForTime :: (GenBlackAtmVolCurve b) -> (Double) -- ^maturity
 1819  -> (Bool) -- ^extrapolate
 1820  -> IO ((Double))
 1821 atmVarianceForTime a1 a2 a3 =
 1822   withGenBlackAtmVolCurve a1 $ \a1' -> 
 1823   let {a2' = realToFrac a2} in 
 1824   let {a3' = C2HSImp.fromBool a3} in 
 1825   preErrorCheck $ \a4' -> 
 1826   atmVarianceForTime'_ a1' a2' a3' a4' >>= \res ->
 1827   let {res' = realToFrac res} in
 1828   errorCheck  a4'>>
 1829   return (res')
 1830 
 1831 
 1832 
 1833 -- |returns the smile for a given option tenor
 1834 blackVolSurfaceSmileSectionForPeriod :: (GenBlackVolSurface b) -> ((Word,TimeUnit)) -- ^optionTenor
 1835  -> (Bool) -- ^extrapolate
 1836  -> IO ((SmileSection))
 1837 blackVolSurfaceSmileSectionForPeriod a1 a2 a3 =
 1838   withGenBlackVolSurface a1 $ \a1' -> 
 1839   let {(a2'1, a2'2) = fromEnumQuantity a2} in 
 1840   let {a3' = C2HSImp.fromBool a3} in 
 1841   preErrorCheck $ \a4' -> 
 1842   blackVolSurfaceSmileSectionForPeriod'_ a1' a2'1  a2'2 a3' a4' >>= \res ->
 1843   peekSmileSection res >>= \res' ->
 1844   errorCheck  a4'>>
 1845   return (res')
 1846 
 1847 
 1848 
 1849 -- |returns the smile for a given option date
 1850 blackVolSurfaceSmileSectionForDate :: (GenBlackVolSurface b) -> (Day) -- ^optionDate
 1851  -> (Bool) -- ^extrapolate
 1852  -> IO ((SmileSection))
 1853 blackVolSurfaceSmileSectionForDate a1 a2 a3 =
 1854   withGenBlackVolSurface a1 $ \a1' -> 
 1855   withDay a2 $ \a2' -> 
 1856   let {a3' = C2HSImp.fromBool a3} in 
 1857   preErrorCheck $ \a4' -> 
 1858   blackVolSurfaceSmileSectionForDate'_ a1' a2' a3' a4' >>= \res ->
 1859   peekSmileSection res >>= \res' ->
 1860   errorCheck  a4'>>
 1861   return (res')
 1862 
 1863 
 1864 
 1865 -- |returns the smile for a given option time
 1866 blackVolSurfaceSmileSectionForTime :: (GenBlackVolSurface b) -> (Double) -- ^optionTime
 1867  -> (Bool) -- ^extrapolate
 1868  -> IO ((SmileSection))
 1869 blackVolSurfaceSmileSectionForTime a1 a2 a3 =
 1870   withGenBlackVolSurface a1 $ \a1' -> 
 1871   let {a2' = realToFrac a2} in 
 1872   let {a3' = C2HSImp.fromBool a3} in 
 1873   preErrorCheck $ \a4' -> 
 1874   blackVolSurfaceSmileSectionForTime'_ a1' a2' a3' a4' >>= \res ->
 1875   peekSmileSection res >>= \res' ->
 1876   errorCheck  a4'>>
 1877   return (res')
 1878 
 1879 
 1880 
 1881 -- |Abcd-interpolated at-the-money (no-smile) volatility curve -- floating reference date,
 1882 -- floating market data. @inclusionInInterpolationFlag@ selects which quotes feed the ABCD fit
 1883 -- (upstream defaults this to all-'True' when omitted; hasquant always requires it explicitly,
 1884 -- per the widen-in-place convention for a handful of trailing defaulted params).
 1885 abcdAtmVolCurve :: Word -> Calendar -> [(Word, TimeUnit)] -- ^optionTenors
 1886   -> [GenQuote q] -- ^volsHandles
 1887   -> [Bool] -- ^inclusionInInterpolationFlag
 1888   -> BusinessDayConvention -> DayCounter -> IO AbcdAtmVolCurve
 1889 abcdAtmVolCurve d c ntenors qs flags bdc dc = qlAbcdAtmVolCurve d c n t qs flags bdc dc
 1890   where (n, t) = unzip ntenors
 1891 qlAbcdAtmVolCurve :: (Word) -> (Calendar) -> ([Word]) -> ([TimeUnit]) -> ([GenQuote q]) -> ([Bool]) -> (BusinessDayConvention) -> (DayCounter) -> IO ((AbcdAtmVolCurve))
 1892 qlAbcdAtmVolCurve a1 a2 a3 a4 a5 a6 a7 a8 =
 1893   let {a1' = fromIntegral a1} in 
 1894   withCalendar a2 $ \a2' -> 
 1895   withIntArray a3 $ \(a3'1, a3'2) -> 
 1896   withEnumArray a4 $ \(a4'1, a4'2) -> 
 1897   withQuoteArray a5 $ \(a5'1, a5'2) -> 
 1898   withBoolArray a6 $ \(a6'1, a6'2) -> 
 1899   let {a7' = fromEnumC a7} in 
 1900   withDayCounter a8 $ \a8' -> 
 1901   preErrorCheck $ \a9' -> 
 1902   qlAbcdAtmVolCurve'_ a1' a2' a3'1  a3'2 a4'1  a4'2 a5'1  a5'2 a6'1  a6'2 a7' a8' a9' >>= \res ->
 1903   peekAbcdAtmVolCurve res >>= \res' ->
 1904   errorCheck  a9'>>
 1905   return (res')
 1906 
 1907 
 1908 
 1909 abcdAtmVolCurveA :: (AbcdAtmVolCurve) -> IO ((Double))
 1910 abcdAtmVolCurveA a1 =
 1911   withAbcdAtmVolCurve a1 $ \a1' -> 
 1912   preErrorCheck $ \a2' -> 
 1913   abcdAtmVolCurveA'_ a1' a2' >>= \res ->
 1914   let {res' = realToFrac res} in
 1915   errorCheck  a2'>>
 1916   return (res')
 1917 
 1918 
 1919 abcdAtmVolCurveB :: (AbcdAtmVolCurve) -> IO ((Double))
 1920 abcdAtmVolCurveB a1 =
 1921   withAbcdAtmVolCurve a1 $ \a1' -> 
 1922   preErrorCheck $ \a2' -> 
 1923   abcdAtmVolCurveB'_ a1' a2' >>= \res ->
 1924   let {res' = realToFrac res} in
 1925   errorCheck  a2'>>
 1926   return (res')
 1927 
 1928 
 1929 abcdAtmVolCurveC :: (AbcdAtmVolCurve) -> IO ((Double))
 1930 abcdAtmVolCurveC a1 =
 1931   withAbcdAtmVolCurve a1 $ \a1' -> 
 1932   preErrorCheck $ \a2' -> 
 1933   abcdAtmVolCurveC'_ a1' a2' >>= \res ->
 1934   let {res' = realToFrac res} in
 1935   errorCheck  a2'>>
 1936   return (res')
 1937 
 1938 
 1939 abcdAtmVolCurveD :: (AbcdAtmVolCurve) -> IO ((Double))
 1940 abcdAtmVolCurveD a1 =
 1941   withAbcdAtmVolCurve a1 $ \a1' -> 
 1942   preErrorCheck $ \a2' -> 
 1943   abcdAtmVolCurveD'_ a1' a2' >>= \res ->
 1944   let {res' = realToFrac res} in
 1945   errorCheck  a2'>>
 1946   return (res')
 1947 
 1948 
 1949 abcdAtmVolCurveRmsError :: (AbcdAtmVolCurve) -> IO ((Double))
 1950 abcdAtmVolCurveRmsError a1 =
 1951   withAbcdAtmVolCurve a1 $ \a1' -> 
 1952   preErrorCheck $ \a2' -> 
 1953   abcdAtmVolCurveRmsError'_ a1' a2' >>= \res ->
 1954   let {res' = realToFrac res} in
 1955   errorCheck  a2'>>
 1956   return (res')
 1957 
 1958 
 1959 abcdAtmVolCurveMaxError :: (AbcdAtmVolCurve) -> IO ((Double))
 1960 abcdAtmVolCurveMaxError a1 =
 1961   withAbcdAtmVolCurve a1 $ \a1' -> 
 1962   preErrorCheck $ \a2' -> 
 1963   abcdAtmVolCurveMaxError'_ a1' a2' >>= \res ->
 1964   let {res' = realToFrac res} in
 1965   errorCheck  a2'>>
 1966   return (res')
 1967 
 1968 
 1969 abcdAtmVolCurveEndCriteria :: (AbcdAtmVolCurve) -> IO ((EndCriteriaType))
 1970 abcdAtmVolCurveEndCriteria a1 =
 1971   withAbcdAtmVolCurve a1 $ \a1' -> 
 1972   preErrorCheck $ \a2' -> 
 1973   abcdAtmVolCurveEndCriteria'_ a1' a2' >>= \res ->
 1974   let {res' = (toEnum . fromIntegral) res} in
 1975   errorCheck  a2'>>
 1976   return (res')
 1977 
 1978 
 1979 
 1980 -- |@k@ adjustment factor at a given time
 1981 abcdAtmVolCurveKAtTime :: (AbcdAtmVolCurve) -> (Double) -> IO ((Double))
 1982 abcdAtmVolCurveKAtTime a1 a2 =
 1983   withAbcdAtmVolCurve a1 $ \a1' -> 
 1984   let {a2' = realToFrac a2} in 
 1985   preErrorCheck $ \a3' -> 
 1986   abcdAtmVolCurveKAtTime'_ a1' a2' a3' >>= \res ->
 1987   let {res' = realToFrac res} in
 1988   errorCheck  a3'>>
 1989   return (res')
 1990 
 1991 
 1992 
 1993 -- |@k@ adjustment factors for every option tenor used in interpolation
 1994 abcdAtmVolCurveK :: (AbcdAtmVolCurve) -> IO (([Double]))
 1995 abcdAtmVolCurveK a1 =
 1996   withAbcdAtmVolCurve a1 $ \a1' -> 
 1997   preArray $ \(a2'1, a2'2) -> 
 1998   preErrorCheck $ \a3' -> 
 1999   abcdAtmVolCurveK'_ a1' a2'1  a2'2 a3' >>
 2000   peekDoubleArray  a2'1  a2'2>>= \a2'' -> 
 2001   errorCheck  a3'>>
 2002   return (a2'')
 2003 
 2004 
 2005 
 2006 abcdAtmVolCurveOptionTenors :: AbcdAtmVolCurve -> IO [(Word, TimeUnit)]
 2007 abcdAtmVolCurveOptionTenors o = do
 2008   (ns, us) <- qlAbcdAtmVolCurveOptionTenors o
 2009   pure $ zip (map fromIntegral ns) (map toEnum us)
 2010 qlAbcdAtmVolCurveOptionTenors :: (AbcdAtmVolCurve) -> IO (([Int]), ([Int]))
 2011 qlAbcdAtmVolCurveOptionTenors a1 =
 2012   withAbcdAtmVolCurve a1 $ \a1' -> 
 2013   preArray $ \(a2'1, a2'2) -> 
 2014   preArray $ \(a3'1, a3'2) -> 
 2015   preErrorCheck $ \a4' -> 
 2016   qlAbcdAtmVolCurveOptionTenors'_ a1' a2'1  a2'2 a3'1  a3'2 a4' >>
 2017   peekIntArray  a2'1  a2'2>>= \a2'' -> 
 2018   peekIntArray  a3'1  a3'2>>= \a3'' -> 
 2019   errorCheck  a4'>>
 2020   return (a2'', a3'')
 2021 
 2022 
 2023 
 2024 -- |As 'abcdAtmVolCurveOptionTenors', but only the tenors actually used in the ABCD fit.
 2025 abcdAtmVolCurveOptionTenorsInInterpolation :: AbcdAtmVolCurve -> IO [(Word, TimeUnit)]
 2026 abcdAtmVolCurveOptionTenorsInInterpolation o = do
 2027   (ns, us) <- qlAbcdAtmVolCurveOptionTenorsInInterpolation o
 2028   pure $ zip (map fromIntegral ns) (map toEnum us)
 2029 qlAbcdAtmVolCurveOptionTenorsInInterpolation :: (AbcdAtmVolCurve) -> IO (([Int]), ([Int]))
 2030 qlAbcdAtmVolCurveOptionTenorsInInterpolation a1 =
 2031   withAbcdAtmVolCurve a1 $ \a1' -> 
 2032   preArray $ \(a2'1, a2'2) -> 
 2033   preArray $ \(a3'1, a3'2) -> 
 2034   preErrorCheck $ \a4' -> 
 2035   qlAbcdAtmVolCurveOptionTenorsInInterpolation'_ a1' a2'1  a2'2 a3'1  a3'2 a4' >>
 2036   peekIntArray  a2'1  a2'2>>= \a2'' -> 
 2037   peekIntArray  a3'1  a3'2>>= \a3'' -> 
 2038   errorCheck  a4'>>
 2039   return (a2'', a3'')
 2040 
 2041 
 2042 
 2043 abcdAtmVolCurveOptionDates :: (AbcdAtmVolCurve) -> IO (([Day]))
 2044 abcdAtmVolCurveOptionDates a1 =
 2045   withAbcdAtmVolCurve a1 $ \a1' -> 
 2046   preArray $ \(a2'1, a2'2) -> 
 2047   preErrorCheck $ \a3' -> 
 2048   abcdAtmVolCurveOptionDates'_ a1' a2'1  a2'2 a3' >>
 2049   peekDayArray  a2'1  a2'2>>= \a2'' -> 
 2050   errorCheck  a3'>>
 2051   return (a2'')
 2052 
 2053 
 2054 
 2055 -- |As 'abcdAtmVolCurveOptionDates', in year fractions from the curve's reference date.
 2056 abcdAtmVolCurveOptionTimes :: (AbcdAtmVolCurve) -> IO (([Double]))
 2057 abcdAtmVolCurveOptionTimes a1 =
 2058   withAbcdAtmVolCurve a1 $ \a1' -> 
 2059   preArray $ \(a2'1, a2'2) -> 
 2060   preErrorCheck $ \a3' -> 
 2061   abcdAtmVolCurveOptionTimes'_ a1' a2'1  a2'2 a3' >>
 2062   peekDoubleArray  a2'1  a2'2>>= \a2'' -> 
 2063   errorCheck  a3'>>
 2064   return (a2'')
 2065 
 2066 
 2067 
 2068 -- |SABR-smile 'BlackVolSurface' built from an interest-rate index, an ATM 'BlackAtmVolCurve', and
 2069 -- per-tenor ATM-rate spreads\/vol-spread matrix. @volSpreads@'s rows follow @optionTenors@ and
 2070 -- columns follow @atmRateSpreads@ (same row\/column convention as 'sabrSwaptionVolatilityCube's
 2071 -- @volSpreads@).
 2072 sabrVolSurface :: GenInterestRateIndex ix -> GenBlackAtmVolCurve b -> [(Word, TimeUnit)] -- ^optionTenors
 2073   -> [Double] -- ^atmRateSpreads
 2074   -> Matrix (GenQuote q) -- ^volSpreads
 2075   -> IO SabrVolSurface
 2076 sabrVolSurface ix atm ntenors spreads (Matrix vr vc vd) =
 2077   qlSabrVolSurface ix atm n t spreads vr vc vd
 2078   where (n, t) = unzip ntenors
 2079 qlSabrVolSurface :: (GenInterestRateIndex ix) -> (GenBlackAtmVolCurve b) -> ([Word]) -> ([TimeUnit]) -> ([Double]) -> (Word) -> (Word) -> ([GenQuote q]) -> IO ((SabrVolSurface))
 2080 qlSabrVolSurface a1 a2 a3 a4 a5 a6 a7 a8 =
 2081   withInterestRateIndex a1 $ \a1' -> 
 2082   withGenBlackAtmVolCurve a2 $ \a2' -> 
 2083   withIntArray a3 $ \(a3'1, a3'2) -> 
 2084   withEnumArray a4 $ \(a4'1, a4'2) -> 
 2085   withDoubleArray a5 $ \(a5'1, a5'2) -> 
 2086   let {a6' = fromIntegral a6} in 
 2087   let {a7' = fromIntegral a7} in 
 2088   withQuoteArrayRaw a8 $ \a8' -> 
 2089   preErrorCheck $ \a9' -> 
 2090   qlSabrVolSurface'_ a1' a2' a3'1  a3'2 a4'1  a4'2 a5'1  a5'2 a6' a7' a8' a9' >>= \res ->
 2091   peekSabrVolSurface res >>= \res' ->
 2092   errorCheck  a9'>>
 2093   return (res')
 2094 
 2095 
 2096 
 2097 -- |the 'BlackAtmVolCurve' this surface's ATM level is anchored to
 2098 sabrVolSurfaceAtmCurve :: (SabrVolSurface) -> IO ((BlackAtmVolCurve))
 2099 sabrVolSurfaceAtmCurve a1 =
 2100   withSabrVolSurface a1 $ \a1' -> 
 2101   preErrorCheck $ \a2' -> 
 2102   sabrVolSurfaceAtmCurve'_ a1' a2' >>= \res ->
 2103   peekBlackAtmVolCurve res >>= \res' ->
 2104   errorCheck  a2'>>
 2105   return (res')
 2106 
 2107 
 2108 
 2109 -- |per-@atmRateSpreads@-column volatility spreads for a given option tenor
 2110 sabrVolSurfaceVolatilitySpreadsForPeriod :: (SabrVolSurface) -> ((Word,TimeUnit)) -- ^optionTenor
 2111  -> IO (([Double]))
 2112 sabrVolSurfaceVolatilitySpreadsForPeriod a1 a2 =
 2113   withSabrVolSurface a1 $ \a1' -> 
 2114   let {(a2'1, a2'2) = fromEnumQuantity a2} in 
 2115   preArray $ \(a3'1, a3'2) -> 
 2116   preErrorCheck $ \a4' -> 
 2117   sabrVolSurfaceVolatilitySpreadsForPeriod'_ a1' a2'1  a2'2 a3'1  a3'2 a4' >>
 2118   peekDoubleArray  a3'1  a3'2>>= \a3'' -> 
 2119   errorCheck  a4'>>
 2120   return (a3'')
 2121 
 2122 
 2123 
 2124 -- |as 'sabrVolSurfaceVolatilitySpreadsForPeriod', for a given option date
 2125 sabrVolSurfaceVolatilitySpreadsForDate :: (SabrVolSurface) -> (Day) -- ^optionDate
 2126  -> IO (([Double]))
 2127 sabrVolSurfaceVolatilitySpreadsForDate a1 a2 =
 2128   withSabrVolSurface a1 $ \a1' -> 
 2129   withDay a2 $ \a2' -> 
 2130   preArray $ \(a3'1, a3'2) -> 
 2131   preErrorCheck $ \a4' -> 
 2132   sabrVolSurfaceVolatilitySpreadsForDate'_ a1' a2' a3'1  a3'2 a4' >>
 2133   peekDoubleArray  a3'1  a3'2>>= \a3'' -> 
 2134   errorCheck  a4'>>
 2135   return (a3'')
 2136 
 2137 
 2138 
 2139 -- |the interest rate index this surface was built from (folded in from upstream's
 2140 -- @InterestRateVolSurface@, not given its own hierarchy level here -- see 'SabrVolSurface').
 2141 sabrVolSurfaceIndex :: (SabrVolSurface) -> IO ((InterestRateIndex))
 2142 sabrVolSurfaceIndex a1 =
 2143   withSabrVolSurface a1 $ \a1' -> 
 2144   preErrorCheck $ \a2' -> 
 2145   sabrVolSurfaceIndex'_ a1' a2' >>= \res ->
 2146   peekInterestRateIndex res >>= \res' ->
 2147   errorCheck  a2'>>
 2148   return (res')
 2149 
 2150 
 2151 
 2152 -- |as 'sabrVolSurfaceIndex', converts an option tenor to its option date (folded in from
 2153 -- @InterestRateVolSurface@)
 2154 sabrVolSurfaceOptionDateFromTenor :: (SabrVolSurface) -> ((Word,TimeUnit)) -- ^optionTenor
 2155  -> IO ((Day))
 2156 sabrVolSurfaceOptionDateFromTenor a1 a2 =
 2157   withSabrVolSurface a1 $ \a1' -> 
 2158   let {(a2'1, a2'2) = fromEnumQuantity a2} in 
 2159   preErrorCheck $ \a3' -> 
 2160   sabrVolSurfaceOptionDateFromTenor'_ a1' a2'1  a2'2 a3' >>= \res ->
 2161   let {res' = toDay res} in
 2162   errorCheck  a3'>>
 2163   return (res')
 2164 
 2165 
 2166 
 2167 -- |A 'SwaptionVolatilityStructure' whose volatility at every point is @source@'s plus @spread@
 2168 -- (which may change over time, since it's a live 'GenQuote' rather than a fixed number)
 2169 spreadedSwaptionVolatility :: (GenSwaptionVolatilityStructure sv) -> (GenQuote q) -> IO ((SwaptionVolatilityStructure))
 2170 spreadedSwaptionVolatility a1 a2 =
 2171   withSwaptionVolatilityStructure a1 $ \a1' -> 
 2172   withQuote a2 $ \a2' -> 
 2173   preErrorCheck $ \a3' -> 
 2174   spreadedSwaptionVolatility'_ a1' a2' a3' >>= \res ->
 2175   peekSwaptionVolatilityStructure res >>= \res' ->
 2176   errorCheck  a3'>>
 2177   return (res')
 2178 
 2179 
 2180 
 2181 -- |as 'spreadedSwaptionVolatility', for 'OptionletVolatilityStructure' rather than
 2182 -- 'SwaptionVolatilityStructure'
 2183 spreadedOptionletVol :: (GenOptionletVolatilityStructure ov) -> (GenQuote q) -> IO ((OptionletVolatilityStructure))
 2184 spreadedOptionletVol a1 a2 =
 2185   withOptionletVolatilityStructure a1 $ \a1' -> 
 2186   withQuote a2 $ \a2' -> 
 2187   preErrorCheck $ \a3' -> 
 2188   spreadedOptionletVol'_ a1' a2' a3' >>= \res ->
 2189   peekOptionletVolatilityStructure res >>= \res' ->
 2190   errorCheck  a3'>>
 2191   return (res')
 2192 
 2193 
 2194 
 2195 -- |A swaption vol surface behind a relinkable handle. The result /is/ a
 2196 -- 'SwaptionVolatilityStructure': pass it anywhere one is expected and everything built on it
 2197 -- keeps tracking whatever the handle currently points at, so a later 'linkSwaptionVolTo'
 2198 -- reprices already-constructed instruments without rebuilding them. Mirrors
 2199 -- 'QuantLib.TermStructure.Yield.relinkableYieldTermStructure'.
 2200 relinkableSwaptionVolatilityStructure :: (Maybe (GenSwaptionVolatilityStructure sv)) -> IO ((RelinkableSwaptionVolatilityStructure))
 2201 relinkableSwaptionVolatilityStructure a1 =
 2202   withMaybeSwaptionVolatilityStructure a1 $ \a1' -> 
 2203   preErrorCheck $ \a2' -> 
 2204   relinkableSwaptionVolatilityStructure'_ a1' a2' >>= \res ->
 2205   peekRelinkableSwaptionVolatilityStructure res >>= \res' ->
 2206   errorCheck  a2'>>
 2207   return (res')
 2208 
 2209 
 2210 
 2211 -- |Point a relinkable swaption vol handle at a different surface. Everything already built on
 2212 -- the handle reprices against the new surface, with no engine rebuilt. Named distinctly from
 2213 -- 'QuantLib.TermStructure.Yield.linkTo' and 'linkBlackVolTo' because
 2214 -- 'BlackVolTermStructure'\/'SwaptionVolatilityStructure'\/'OptionletVolatilityStructure' all
 2215 -- live in this one module and a bare 'linkTo' per type would collide with its own siblings,
 2216 -- not just with 'Yield.chs'\/'Quote.chs'.
 2217 linkSwaptionVolTo :: (RelinkableSwaptionVolatilityStructure) -> (GenSwaptionVolatilityStructure sv) -> IO ()
 2218 linkSwaptionVolTo a1 a2 =
 2219   withRelinkableSwaptionVolatilityStructure a1 $ \a1' -> 
 2220   withSwaptionVolatilityStructure a2 $ \a2' -> 
 2221   preErrorCheck $ \a3' -> 
 2222   linkSwaptionVolTo'_ a1' a2' a3' >>
 2223   errorCheck  a3'>>
 2224   return ()
 2225 
 2226 
 2227 
 2228 -- |A constant local volatility, no time-asset dependence -- floating reference date, floating
 2229 -- market data. Local and Black volatility coincide when volatility is at most time dependent, so
 2230 -- this is effectively a proxy for 'blackConstantVol''.
 2231 localConstantVol' :: (Word) -> (Calendar) -> (GenQuote q) -> (DayCounter) -> IO ((LocalVolTermStructure))
 2232 localConstantVol' a1 a2 a3 a4 =
 2233   let {a1' = fromIntegral a1} in 
 2234   withCalendar a2 $ \a2' -> 
 2235   withQuote a3 $ \a3' -> 
 2236   withDayCounter a4 $ \a4' -> 
 2237   preErrorCheck $ \a5' -> 
 2238   localConstantVol''_ a1' a2' a3' a4' a5' >>= \res ->
 2239   peekLocalVolTermStructure res >>= \res' ->
 2240   errorCheck  a5'>>
 2241   return (res')
 2242 
 2243 
 2244 
 2245 -- |as 'localConstantVol\'', but a fixed reference date
 2246 localConstantVol :: (Day) -> (GenQuote q) -> (DayCounter) -> IO ((LocalVolTermStructure))
 2247 localConstantVol a1 a2 a3 =
 2248   withDay a1 $ \a1' -> 
 2249   withQuote a2 $ \a2' -> 
 2250   withDayCounter a3 $ \a3' -> 
 2251   preErrorCheck $ \a4' -> 
 2252   localConstantVol'_ a1' a2' a3' a4' >>= \res ->
 2253   peekLocalVolTermStructure res >>= \res' ->
 2254   errorCheck  a4'>>
 2255   return (res')
 2256 
 2257 
 2258 
 2259 -- |a local vol term structure derived from a 'BlackVarianceCurve' (no strike dependence): local
 2260 -- vol at time @t@ is the derivative of the Black variance curve's total variance
 2261 localVolCurve :: (BlackVarianceCurve) -> IO ((LocalVolTermStructure))
 2262 localVolCurve a1 =
 2263   withBlackVarianceCurve a1 $ \a1' -> 
 2264   preErrorCheck $ \a2' -> 
 2265   localVolCurve'_ a1' a2' >>= \res ->
 2266   peekLocalVolTermStructure res >>= \res' ->
 2267   errorCheck  a2'>>
 2268   return (res')
 2269 
 2270 
 2271 
 2272 -- |@origTS@ re-anchored to a new reference date, tracking @origTS@ for later changes. Only
 2273 -- financially sensible for a time-dependent (not asset-dependent) source structure.
 2274 impliedVolTermStructure :: (GenBlackVolTermStructure bv) -> (Day) -> IO ((BlackVolTermStructure))
 2275 impliedVolTermStructure a1 a2 =
 2276   withBlackVolTermStructure a1 $ \a1' -> 
 2277   withDay a2 $ \a2' -> 
 2278   preErrorCheck $ \a3' -> 
 2279   impliedVolTermStructure'_ a1' a2' a3' >>= \res ->
 2280   peekBlackVolTermStructure res >>= \res' ->
 2281   errorCheck  a3'>>
 2282   return (res')
 2283 
 2284 
 2285 
 2286 -- |fixed reference date, floating market data
 2287 capFloorTermVolCurve' :: Day -> Calendar -> BusinessDayConvention -> [(Word, TimeUnit, GenQuote q)] -> DayCounter -> IO CapFloorTermVolCurve
 2288 capFloorTermVolCurve' d c bd ntq = qlCapFloorTermVolCurve1 d c bd n t q where (n, t, q) = unzip3 ntq
 2289 qlCapFloorTermVolCurve1 :: (Day) -> (Calendar) -> (BusinessDayConvention) -> ([Word]) -> ([TimeUnit]) -> ([GenQuote q]) -> (DayCounter) -> IO ((CapFloorTermVolCurve))
 2290 qlCapFloorTermVolCurve1 a1 a2 a3 a4 a5 a6 a7 =
 2291   withDay a1 $ \a1' -> 
 2292   withCalendar a2 $ \a2' -> 
 2293   let {a3' = fromEnumC a3} in 
 2294   withIntArray a4 $ \(a4'1, a4'2) -> 
 2295   withEnumArray a5 $ \(a5'1, a5'2) -> 
 2296   withQuoteArray a6 $ \(a6'1, a6'2) -> 
 2297   withDayCounter a7 $ \a7' -> 
 2298   preErrorCheck $ \a8' -> 
 2299   qlCapFloorTermVolCurve1'_ a1' a2' a3' a4'1  a4'2 a5'1  a5'2 a6'1  a6'2 a7' a8' >>= \res ->
 2300   peekCapFloorTermVolCurve res >>= \res' ->
 2301   errorCheck  a8'>>
 2302   return (res')
 2303 
 2304 
 2305 
 2306 -- |floating reference date, floating market data
 2307 capFloorTermVolCurve :: Word -> Calendar -> BusinessDayConvention -> [(Word, TimeUnit, GenQuote q)] -> DayCounter -> IO CapFloorTermVolCurve
 2308 capFloorTermVolCurve d c bd ntq = qlCapFloorTermVolCurve d c bd n t q where (n, t, q) = unzip3 ntq
 2309 qlCapFloorTermVolCurve :: (Word) -> (Calendar) -> (BusinessDayConvention) -> ([Word]) -> ([TimeUnit]) -> ([GenQuote q]) -> (DayCounter) -> IO ((CapFloorTermVolCurve))
 2310 qlCapFloorTermVolCurve a1 a2 a3 a4 a5 a6 a7 =
 2311   let {a1' = fromIntegral a1} in 
 2312   withCalendar a2 $ \a2' -> 
 2313   let {a3' = fromEnumC a3} in 
 2314   withIntArray a4 $ \(a4'1, a4'2) -> 
 2315   withEnumArray a5 $ \(a5'1, a5'2) -> 
 2316   withQuoteArray a6 $ \(a6'1, a6'2) -> 
 2317   withDayCounter a7 $ \a7' -> 
 2318   preErrorCheck $ \a8' -> 
 2319   qlCapFloorTermVolCurve'_ a1' a2' a3' a4'1  a4'2 a5'1  a5'2 a6'1  a6'2 a7' a8' >>= \res ->
 2320   peekCapFloorTermVolCurve res >>= \res' ->
 2321   errorCheck  a8'>>
 2322   return (res')
 2323 
 2324 
 2325 
 2326 -- |A Black volatility curve built from time-dependent (ATM) market vols, interpolating on total
 2327 -- variance (linear by default, or the given 'Interpolation') -- no strike dependence; see
 2328 -- 'blackVarianceSurface' for that.
 2329 blackVarianceCurve :: Day -> [(Day, Double)] -> DayCounter -> Bool -- ^forceMonotoneVariance
 2330   -> Maybe Interpolation -> IO BlackVarianceCurve
 2331 blackVarianceCurve d dq dc f i = uncurryNested (qlBlackVarianceCurve d dd q dc f) (qlInterpolation' i) where (dd, q) = unzip dq
 2332 qlBlackVarianceCurve :: (Day) -> ([Day]) -> ([Double]) -> (DayCounter) -> (Bool) -> (Int) -> (Int) -> (Int) -> IO ((BlackVarianceCurve))
 2333 qlBlackVarianceCurve a1 a2 a3 a4 a5 a6 a7 a8 =
 2334   withDay a1 $ \a1' -> 
 2335   withDayArray a2 $ \(a2'1, a2'2) -> 
 2336   withDoubleArray a3 $ \(a3'1, a3'2) -> 
 2337   withDayCounter a4 $ \a4' -> 
 2338   let {a5' = C2HSImp.fromBool a5} in 
 2339   let {a6' = fromIntegral a6} in 
 2340   let {a7' = fromIntegral a7} in 
 2341   let {a8' = fromIntegral a8} in 
 2342   preErrorCheck $ \a9' -> 
 2343   qlBlackVarianceCurve'_ a1' a2'1  a2'2 a3'1  a3'2 a4' a5' a6' a7' a8' a9' >>= \res ->
 2344   peekBlackVarianceCurve res >>= \res' ->
 2345   errorCheck  a9'>>
 2346   return (res')
 2347 
 2348 
 2349 
 2350 -- |The @interpolator@ is applied through @BlackVarianceSurface::setInterpolation@ right after
 2351 -- construction; 'Bilinear' reproduces upstream's default. Both interpolators reproduce
 2352 -- @blackVolMatrix@ exactly at its own (date, strike) nodes -- they only differ between them.
 2353 blackVarianceSurface :: Day -> Calendar -> [Day] -- ^dates
 2354   -> [Double] -- ^strikes
 2355   -> Matrix Double -- ^blackVolMatrix
 2356   -> DayCounter
 2357   -> BlackVarianceSurfaceExtrapolation -- ^lowerExtrapolation
 2358   -> BlackVarianceSurfaceExtrapolation -- ^upperExtrapolation
 2359   -> Interpolation2D -- ^interpolator
 2360   -> IO BlackVolTermStructure
 2361 blackVarianceSurface d c ds s (Matrix mr mc md) = qlBlackVarianceSurface d c ds s mr mc md
 2362 qlBlackVarianceSurface :: (Day) -> (Calendar) -> ([Day]) -> ([Double]) -> (Word) -> (Word) -> ([Double]) -> (DayCounter) -> (BlackVarianceSurfaceExtrapolation) -> (BlackVarianceSurfaceExtrapolation) -> (Interpolation2D) -> IO ((BlackVolTermStructure))
 2363 qlBlackVarianceSurface a1 a2 a3 a4 a5 a6 a7 a8 a9 a10 a11 =
 2364   withDay a1 $ \a1' -> 
 2365   withCalendar a2 $ \a2' -> 
 2366   withDayArray a3 $ \(a3'1, a3'2) -> 
 2367   withDoubleArray a4 $ \(a4'1, a4'2) -> 
 2368   let {a5' = fromIntegral a5} in 
 2369   let {a6' = fromIntegral a6} in 
 2370   withDoubleArrayRaw a7 $ \a7' -> 
 2371   withDayCounter a8 $ \a8' -> 
 2372   let {a9' = (fromIntegral . fromEnum) a9} in 
 2373   let {a10' = (fromIntegral . fromEnum) a10} in 
 2374   let {a11' = fromEnumC a11} in 
 2375   preErrorCheck $ \a12' -> 
 2376   qlBlackVarianceSurface'_ a1' a2' a3'1  a3'2 a4'1  a4'2 a5' a6' a7' a8' a9' a10' a11' a12' >>= \res ->
 2377   peekBlackVolTermStructure res >>= \res' ->
 2378   errorCheck  a12'>>
 2379   return (res')
 2380 
 2381 
 2382 
 2383 -- |Builds a Black volatility surface from a rectangular vol grid via
 2384 -- 'PiecewiseBlackVarianceSurface::makeFromGrid': one interpolated smile section per date
 2385 -- column, linear in total variance between columns -- a fixed interpolation scheme, unlike
 2386 -- 'blackVarianceSurface''s configurable 2-D interpolator.
 2387 piecewiseBlackVarianceSurface :: Day -> [Day] -- ^dates
 2388   -> [Double] -- ^strikes
 2389   -> Matrix Double -- ^blackVols
 2390   -> DayCounter
 2391   -> IO BlackVolTermStructure
 2392 piecewiseBlackVarianceSurface d ds s (Matrix mr mc md) dc = qlPiecewiseBlackVarianceSurface d ds s mr mc md dc
 2393 qlPiecewiseBlackVarianceSurface :: (Day) -> ([Day]) -> ([Double]) -> (Word) -> (Word) -> ([Double]) -> (DayCounter) -> IO ((BlackVolTermStructure))
 2394 qlPiecewiseBlackVarianceSurface a1 a2 a3 a4 a5 a6 a7 =
 2395   withDay a1 $ \a1' -> 
 2396   withDayArray a2 $ \(a2'1, a2'2) -> 
 2397   withDoubleArray a3 $ \(a3'1, a3'2) -> 
 2398   let {a4' = fromIntegral a4} in 
 2399   let {a5' = fromIntegral a5} in 
 2400   withDoubleArrayRaw a6 $ \a6' -> 
 2401   withDayCounter a7 $ \a7' -> 
 2402   preErrorCheck $ \a8' -> 
 2403   qlPiecewiseBlackVarianceSurface'_ a1' a2'1  a2'2 a3'1  a3'2 a4' a5' a6' a7' a8' >>= \res ->
 2404   peekBlackVolTermStructure res >>= \res' ->
 2405   errorCheck  a8'>>
 2406   return (res')
 2407 
 2408 
 2409 
 2410 -- |A Black volatility surface parameterized by market deltas (put\/call deltas and, optionally,
 2411 -- an ATM quote) rather than fixed strikes -- the standard FX vol quoting convention. Constructed
 2412 -- with upstream's own defaults for the trailing options; use 'blackVolatilitySurfaceDeltaFull'
 2413 -- to override them.
 2414 blackVolatilitySurfaceDelta :: Day -> [Day] -- ^dates
 2415   -> [Double] -- ^putDeltas
 2416   -> [Double] -- ^callDeltas
 2417   -> Bool -- ^hasAtm
 2418   -> Matrix Double -- ^blackVolMatrix
 2419   -> DayCounter -> Calendar -> GenQuote q -- ^spot
 2420   -> GenYieldTermStructure y1 -- ^domesticTS
 2421   -> GenYieldTermStructure y2 -- ^foreignTS
 2422   -> IO BlackVolatilitySurfaceDelta
 2423 blackVolatilitySurfaceDelta d ds pd cd hasAtm (Matrix mr mc md) dc cal spot dts fts =
 2424   blackVolatilitySurfaceDelta_ d ds pd cd hasAtm mr mc md dc cal spot dts fts
 2425     Spot AtmDeltaNeutral Nothing SmileLinear False FlatVolatility (0, Days) Fwd AtmDeltaNeutral Nothing
 2426 
 2427 -- |As 'blackVolatilitySurfaceDelta', but takes a 'BlackVolatilitySurfaceDeltaOpts' record for
 2428 -- the trailing options instead of hardcoding upstream's defaults.
 2429 blackVolatilitySurfaceDeltaFull :: Day -> [Day] -> [Double] -> [Double] -> Bool -> Matrix Double
 2430   -> DayCounter -> Calendar -> GenQuote q -> GenYieldTermStructure y1 -> GenYieldTermStructure y2
 2431   -> BlackVolatilitySurfaceDeltaOpts -> IO BlackVolatilitySurfaceDelta
 2432 blackVolatilitySurfaceDeltaFull d ds pd cd hasAtm (Matrix mr mc md) dc cal spot dts fts opts =
 2433   blackVolatilitySurfaceDelta_ d ds pd cd hasAtm mr mc md dc cal spot dts fts
 2434     (bvsdDeltaType opts) (bvsdAtmType opts) (bvsdAtmDeltaType opts)
 2435     (bvsdInterpolationMethod opts) (bvsdFlatStrikeExtrapolation opts) (bvsdTimeExtrapolationType opts)
 2436     (bvsdSwitchTenor opts) (bvsdLongTermDeltaType opts) (bvsdLongTermAtmType opts) (bvsdLongTermAtmDeltaType opts)
 2437 
 2438 blackVolatilitySurfaceDelta_ :: (Day) -> ([Day]) -> ([Double]) -- ^putDeltas
 2439  -> ([Double]) -- ^callDeltas
 2440  -> (Bool) -- ^hasAtm
 2441  -> (Word) -> (Word) -> ([Double]) -- ^blackVolMatrix
 2442  -> (DayCounter) -> (Calendar) -> (GenQuote q) -- ^spot
 2443  -> (GenYieldTermStructure y1) -- ^domesticTS
 2444  -> (GenYieldTermStructure y2) -- ^foreignTS
 2445  -> (DeltaType) -- ^deltaType
 2446  -> (AtmType) -- ^atmType
 2447  -> (Maybe DeltaType) -- ^atmDeltaType
 2448  -> (SmileInterpolationMethod) -- ^interpolationMethod
 2449  -> (Bool) -- ^flatStrikeExtrapolation
 2450  -> (BlackVolTimeExtrapolationType) -- ^timeExtrapolationType
 2451  -> ((Int,TimeUnit)) -- ^switchTenor
 2452  -> (DeltaType) -- ^longTermDeltaType
 2453  -> (AtmType) -- ^longTermAtmType
 2454  -> (Maybe DeltaType) -- ^longTermAtmDeltaType
 2455  -> IO ((BlackVolatilitySurfaceDelta))
 2456 blackVolatilitySurfaceDelta_ a1 a2 a3 a4 a5 a6 a7 a8 a9 a10 a11 a12 a13 a14 a15 a16 a17 a18 a19 a20 a21 a22 a23 =
 2457   withDay a1 $ \a1' -> 
 2458   withDayArray a2 $ \(a2'1, a2'2) -> 
 2459   withDoubleArray a3 $ \(a3'1, a3'2) -> 
 2460   withDoubleArray a4 $ \(a4'1, a4'2) -> 
 2461   let {a5' = C2HSImp.fromBool a5} in 
 2462   let {a6' = fromIntegral a6} in 
 2463   let {a7' = fromIntegral a7} in 
 2464   withDoubleArrayRaw a8 $ \a8' -> 
 2465   withDayCounter a9 $ \a9' -> 
 2466   withCalendar a10 $ \a10' -> 
 2467   withQuote a11 $ \a11' -> 
 2468   withYieldTermStructure a12 $ \a12' -> 
 2469   withYieldTermStructure a13 $ \a13' -> 
 2470   let {a14' = fromEnumC a14} in 
 2471   let {a15' = fromEnumC a15} in 
 2472   let {a16' = fromMaybeEnum a16} in 
 2473   let {a17' = fromEnumC a17} in 
 2474   let {a18' = C2HSImp.fromBool a18} in 
 2475   let {a19' = fromEnumC a19} in 
 2476   let {(a20'1, a20'2) = fromEnumQuantity a20} in 
 2477   let {a21' = fromEnumC a21} in 
 2478   let {a22' = fromEnumC a22} in 
 2479   let {a23' = fromMaybeEnum a23} in 
 2480   preErrorCheck $ \a24' -> 
 2481   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 ->
 2482   peekBlackVolatilitySurfaceDelta res >>= \res' ->
 2483   errorCheck  a24'>>
 2484   return (res')
 2485 
 2486 
 2487 
 2488 -- |The Black vol smile at a given time to expiry (year fraction from the reference date), built
 2489 -- by interpolating\/extrapolating the delta-quoted surface. The returned 'SmileSection' does not
 2490 -- track later changes to the surface's spot\/curve handles -- recreate it if those change.
 2491 blackVolSmile :: (BlackVolatilitySurfaceDelta) -> (Double) -- ^t
 2492  -> IO ((SmileSection))
 2493 blackVolSmile a1 a2 =
 2494   withBlackVolatilitySurfaceDelta a1 $ \a1' -> 
 2495   let {a2' = realToFrac a2} in 
 2496   preErrorCheck $ \a3' -> 
 2497   blackVolSmile'_ a1' a2' a3' >>= \res ->
 2498   peekSmileSection res >>= \res' ->
 2499   errorCheck  a3'>>
 2500   return (res')
 2501 
 2502 
 2503 
 2504 -- |As 'blackVolSmile', for a given expiry 'Day' instead of a year fraction.
 2505 blackVolSmile' :: (BlackVolatilitySurfaceDelta) -> (Day) -- ^d
 2506  -> IO ((SmileSection))
 2507 blackVolSmile' a1 a2 =
 2508   withBlackVolatilitySurfaceDelta a1 $ \a1' -> 
 2509   withDay a2 $ \a2' -> 
 2510   preErrorCheck $ \a3' -> 
 2511   blackVolSmile''_ a1' a2' a3' >>= \res ->
 2512   peekSmileSection res >>= \res' ->
 2513   errorCheck  a3'>>
 2514   return (res')
 2515 
 2516 
 2517 
 2518 -- |floating reference date, floating market data
 2519 capFloorTermVolSurface :: Word -> Calendar -> BusinessDayConvention -> [(Word, TimeUnit)] -- ^optionTenors
 2520   -> [Double] -- ^strikes
 2521   -> Matrix (GenQuote q) -- ^volatilities
 2522   -> DayCounter -> IO CapFloorTermVolSurface
 2523 capFloorTermVolSurface d c bd t s (Matrix mr mc md) = qlCapFloorTermVolSurface d c bd pl pu s mr mc md where (pl, pu) = unzip t
 2524 qlCapFloorTermVolSurface :: (Word) -> (Calendar) -> (BusinessDayConvention) -> ([Word]) -> ([TimeUnit]) -> ([Double]) -> (Word) -> (Word) -> ([GenQuote q]) -> (DayCounter) -> IO ((CapFloorTermVolSurface))
 2525 qlCapFloorTermVolSurface a1 a2 a3 a4 a5 a6 a7 a8 a9 a10 =
 2526   let {a1' = fromIntegral a1} in 
 2527   withCalendar a2 $ \a2' -> 
 2528   let {a3' = fromEnumC a3} in 
 2529   withIntArray a4 $ \(a4'1, a4'2) -> 
 2530   withEnumArray a5 $ \(a5'1, a5'2) -> 
 2531   withDoubleArray a6 $ \(a6'1, a6'2) -> 
 2532   let {a7' = fromIntegral a7} in 
 2533   let {a8' = fromIntegral a8} in 
 2534   withQuoteArrayRaw a9 $ \a9' -> 
 2535   withDayCounter a10 $ \a10' -> 
 2536   preErrorCheck $ \a11' -> 
 2537   qlCapFloorTermVolSurface'_ a1' a2' a3' a4'1  a4'2 a5'1  a5'2 a6'1  a6'2 a7' a8' a9' a10' a11' >>= \res ->
 2538   peekCapFloorTermVolSurface res >>= \res' ->
 2539   errorCheck  a11'>>
 2540   return (res')
 2541 
 2542 
 2543 
 2544 -- |fixed reference date, floating market data
 2545 capFloorTermVolSurface' :: Day -> Calendar -> BusinessDayConvention -> [(Word, TimeUnit)] -- ^optionTenors
 2546   -> [Double] -- ^strikes
 2547   -> Matrix (GenQuote q) -- ^volatilities
 2548   -> DayCounter -> IO CapFloorTermVolSurface
 2549 capFloorTermVolSurface' d c bd t s (Matrix mr mc md) = qlCapFloorTermVolSurface1 d c bd pl pu s mr mc md where (pl, pu) = unzip t
 2550 qlCapFloorTermVolSurface1 :: (Day) -> (Calendar) -> (BusinessDayConvention) -> ([Word]) -> ([TimeUnit]) -> ([Double]) -> (Word) -> (Word) -> ([GenQuote q]) -> (DayCounter) -> IO ((CapFloorTermVolSurface))
 2551 qlCapFloorTermVolSurface1 a1 a2 a3 a4 a5 a6 a7 a8 a9 a10 =
 2552   withDay a1 $ \a1' -> 
 2553   withCalendar a2 $ \a2' -> 
 2554   let {a3' = fromEnumC a3} in 
 2555   withIntArray a4 $ \(a4'1, a4'2) -> 
 2556   withEnumArray a5 $ \(a5'1, a5'2) -> 
 2557   withDoubleArray a6 $ \(a6'1, a6'2) -> 
 2558   let {a7' = fromIntegral a7} in 
 2559   let {a8' = fromIntegral a8} in 
 2560   withQuoteArrayRaw a9 $ \a9' -> 
 2561   withDayCounter a10 $ \a10' -> 
 2562   preErrorCheck $ \a11' -> 
 2563   qlCapFloorTermVolSurface1'_ a1' a2' a3' a4'1  a4'2 a5'1  a5'2 a6'1  a6'2 a7' a8' a9' a10' a11' >>= \res ->
 2564   peekCapFloorTermVolSurface res >>= \res' ->
 2565   errorCheck  a11'>>
 2566   return (res')
 2567 
 2568 
 2569 
 2570 -- |fixed reference date, floating market data. Pass an empty 'Matrix' (@Matrix 0 0 []@) for @shifts@
 2571 -- when no shift is needed -- upstream treats a zero-row shift matrix as all-zero.
 2572 swaptionVolatilityMatrix' :: Day -> Calendar -> BusinessDayConvention
 2573   -> [(Word, TimeUnit)] -- ^optionTenors
 2574   -> [(Word, TimeUnit)] -- ^swapTenors
 2575   -> Matrix (GenQuote q) -- ^volatilities
 2576   -> DayCounter
 2577   -> Bool -- ^flatExtrapolation
 2578   -> VolatilityType
 2579   -> Matrix Double -- ^shifts
 2580   -> IO SwaptionVolatilityStructure
 2581 swaptionVolatilityMatrix' d c bdc ot st (Matrix vr vc vd) dc' fe ty (Matrix sr sc sd) =
 2582   qlSwaptionVolatilityMatrix d c bdc opl opu spl spu vr vc vd dc' fe ty sr sc sd
 2583   where (opl, opu) = unzip ot; (spl, spu) = unzip st
 2584 qlSwaptionVolatilityMatrix :: (Day) -> (Calendar) -> (BusinessDayConvention) -> ([Word]) -> ([TimeUnit]) -> ([Word]) -> ([TimeUnit]) -> (Word) -> (Word) -> ([GenQuote q]) -> (DayCounter) -> (Bool) -> (VolatilityType) -> (Word) -> (Word) -> ([Double]) -> IO ((SwaptionVolatilityStructure))
 2585 qlSwaptionVolatilityMatrix a1 a2 a3 a4 a5 a6 a7 a8 a9 a10 a11 a12 a13 a14 a15 a16 =
 2586   withDay a1 $ \a1' -> 
 2587   withCalendar a2 $ \a2' -> 
 2588   let {a3' = fromEnumC a3} in 
 2589   withIntArray a4 $ \(a4'1, a4'2) -> 
 2590   withEnumArray a5 $ \(a5'1, a5'2) -> 
 2591   withIntArray a6 $ \(a6'1, a6'2) -> 
 2592   withEnumArray a7 $ \(a7'1, a7'2) -> 
 2593   let {a8' = fromIntegral a8} in 
 2594   let {a9' = fromIntegral a9} in 
 2595   withQuoteArrayRaw a10 $ \a10' -> 
 2596   withDayCounter a11 $ \a11' -> 
 2597   let {a12' = C2HSImp.fromBool a12} in 
 2598   let {a13' = (fromIntegral . fromEnum) a13} in 
 2599   let {a14' = fromIntegral a14} in 
 2600   let {a15' = fromIntegral a15} in 
 2601   withDoubleArrayRaw a16 $ \a16' -> 
 2602   preErrorCheck $ \a17' -> 
 2603   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 ->
 2604   peekSwaptionVolatilityStructure res >>= \res' ->
 2605   errorCheck  a17'>>
 2606   return (res')
 2607 
 2608 
 2609 
 2610 -- |floating reference date, floating market data. See 'swaptionVolatilityMatrix\'' for the
 2611 -- @shifts@ convention (@Matrix 0 0 []@ for "no shift").
 2612 swaptionVolatilityMatrix :: Calendar -> BusinessDayConvention
 2613   -> [(Word, TimeUnit)] -- ^optionTenors
 2614   -> [(Word, TimeUnit)] -- ^swapTenors
 2615   -> Matrix (GenQuote q) -- ^volatilities
 2616   -> DayCounter
 2617   -> Bool -- ^flatExtrapolation
 2618   -> VolatilityType
 2619   -> Matrix Double -- ^shifts
 2620   -> IO SwaptionVolatilityStructure
 2621 swaptionVolatilityMatrix c bdc ot st (Matrix vr vc vd) dc' fe ty (Matrix sr sc sd) =
 2622   qlSwaptionVolatilityMatrix1 c bdc opl opu spl spu vr vc vd dc' fe ty sr sc sd
 2623   where (opl, opu) = unzip ot; (spl, spu) = unzip st
 2624 qlSwaptionVolatilityMatrix1 :: (Calendar) -> (BusinessDayConvention) -> ([Word]) -> ([TimeUnit]) -> ([Word]) -> ([TimeUnit]) -> (Word) -> (Word) -> ([GenQuote q]) -> (DayCounter) -> (Bool) -> (VolatilityType) -> (Word) -> (Word) -> ([Double]) -> IO ((SwaptionVolatilityStructure))
 2625 qlSwaptionVolatilityMatrix1 a1 a2 a3 a4 a5 a6 a7 a8 a9 a10 a11 a12 a13 a14 a15 =
 2626   withCalendar a1 $ \a1' -> 
 2627   let {a2' = fromEnumC a2} in 
 2628   withIntArray a3 $ \(a3'1, a3'2) -> 
 2629   withEnumArray a4 $ \(a4'1, a4'2) -> 
 2630   withIntArray a5 $ \(a5'1, a5'2) -> 
 2631   withEnumArray a6 $ \(a6'1, a6'2) -> 
 2632   let {a7' = fromIntegral a7} in 
 2633   let {a8' = fromIntegral a8} in 
 2634   withQuoteArrayRaw a9 $ \a9' -> 
 2635   withDayCounter a10 $ \a10' -> 
 2636   let {a11' = C2HSImp.fromBool a11} in 
 2637   let {a12' = (fromIntegral . fromEnum) a12} in 
 2638   let {a13' = fromIntegral a13} in 
 2639   let {a14' = fromIntegral a14} in 
 2640   withDoubleArrayRaw a15 $ \a15' -> 
 2641   preErrorCheck $ \a16' -> 
 2642   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 ->
 2643   peekSwaptionVolatilityStructure res >>= \res' ->
 2644   errorCheck  a16'>>
 2645   return (res')
 2646 
 2647 
 2648 
 2649 -- |A SABR-calibrated swaption volatility cube: fits a SABR smile at every (option tenor, swap
 2650 -- tenor) node from an ATM surface plus a grid of vol spreads. The result /is/ a
 2651 -- 'SwaptionVolatilityStructure' -- pass it anywhere one is expected (pricing engines,
 2652 -- 'smileSection'\/'volatilityForPeriod''\/etc.) -- but its own extra getters
 2653 -- ('sparseSabrParameters', 'denseSabrParameters', 'marketVolCube', 'volCubeAtmCalibrated',
 2654 -- 'sabrSwaptionVolatilityCubeAtmStrike'\/'\'') only accept this concrete type, not the generic one.
 2655 --
 2656 -- @endCriteria@\/@optMethod@ default to 'Nothing', which falls back to upstream's own internal
 2657 -- Levenberg-Marquardt\/EndCriteria defaults at every calibrated node. A caller-supplied
 2658 -- 'EndCriteria'\/'OptimizationMethod' is safe here since both are @shared_ptr@-boxed on the C++
 2659 -- side (see the qlaux.h comment above the QlEndCriteria\/QlOptimizationMethod typedefs) -- the
 2660 -- copy 'SabrSwaptionVolatilityCube' keeps as its own @shared_ptr@ member survives regardless of
 2661 -- when Haskell's own handle is collected, same as 'sabrInterpolatedSmileSection' and
 2662 -- 'QuantLib.TermStructure.Yield.fittedBondDiscountCurve''s fitting methods.
 2663 --
 2664 -- @volSpreads@ and @parametersGuess@ are both flattened over the (optionTenor x swapTenor)
 2665 -- product as the *outer* index (row = j*nSwapTenors+k, j over @optionTenors@, k over
 2666 -- @swapTenors@) -- not one row per @optionTenor@ the way 'swaptionVolatilityMatrix'''s grid is:
 2667 -- @matrixRows == length optionTenors * length swapTenors@ for both. @volSpreads@'s columns are
 2668 -- one per @strikeSpreads@ entry; @parametersGuess@'s columns are always exactly 4, in order
 2669 -- alpha\/beta\/nu\/rho.
 2670 --
 2671 -- Calibration is lazy: unlike 'sabrInterpolatedSmileSection', construction here does /not/ force
 2672 -- an eager fit, so this call can succeed even for inputs that will later fail to calibrate -- the
 2673 -- error only surfaces on the first 'smileSection'\/'volatilityForPeriod''\/diagnostic call.
 2674 sabrSwaptionVolatilityCube :: GenSwaptionVolatilityStructure sv -- ^atmVolStructure
 2675   -> [(Word, TimeUnit)] -- ^optionTenors
 2676   -> [(Word, TimeUnit)] -- ^swapTenors
 2677   -> [Double] -- ^strikeSpreads
 2678   -> Matrix (GenQuote q1) -- ^volSpreads
 2679   -> GenSwapIndex sidx1 -- ^swapIndexBase
 2680   -> GenSwapIndex sidx2 -- ^shortSwapIndexBase
 2681   -> Bool -- ^vegaWeightedSmileFit
 2682   -> Matrix (GenQuote q2) -- ^parametersGuess (alpha, beta, nu, rho per node)
 2683   -> Bool -- ^isAlphaFixed
 2684   -> Bool -- ^isBetaFixed
 2685   -> Bool -- ^isNuFixed
 2686   -> Bool -- ^isRhoFixed
 2687   -> Bool -- ^isAtmCalibrated: if 'True', @atmVolStructure@ must be a discrete grid structure
 2688   -- (e.g. 'swaptionVolatilityMatrix'' or another cube) -- upstream's ATM-recalibration path
 2689   -- ('denseSabrParameters'\/one branch of 'volCubeAtmCalibrated') downcasts it to
 2690   -- @SwaptionVolatilityDiscrete@ and dereferences the result unchecked, which crashes given a
 2691   -- flat 'constantSwaptionVolatility'\/'\''.
 2692   -> Maybe Double -- ^maxErrorTolerance
 2693   -> Maybe Double -- ^errorAccept
 2694   -> Bool -- ^useMaxError
 2695   -> Word -- ^maxGuesses
 2696   -> Bool -- ^backwardFlat
 2697   -> Double -- ^cutoffStrike
 2698   -> Maybe EndCriteria -- ^endCriteria
 2699   -> Maybe OptimizationMethod -- ^optMethod
 2700   -> IO SabrSwaptionVolatilityCube
 2701 sabrSwaptionVolatilityCube atm ot st ss (Matrix vr vc vd) sidx1 sidx2 vw (Matrix pr pc pd)
 2702   iaf ibf inf irf iac met eat ume mg bf cs ec om =
 2703   qlSabrSwaptionVolatilityCube atm opl opu spl spu ss vr vc vd sidx1 sidx2 vw pr pc pd
 2704     iaf ibf inf irf iac ec om met eat ume mg bf cs
 2705   where (opl, opu) = unzip ot; (spl, spu) = unzip st
 2706 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) -> IO ((SabrSwaptionVolatilityCube))
 2707 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 =
 2708   withSwaptionVolatilityStructure a1 $ \a1' -> 
 2709   withIntArray a2 $ \(a2'1, a2'2) -> 
 2710   withEnumArray a3 $ \(a3'1, a3'2) -> 
 2711   withIntArray a4 $ \(a4'1, a4'2) -> 
 2712   withEnumArray a5 $ \(a5'1, a5'2) -> 
 2713   withDoubleArray a6 $ \(a6'1, a6'2) -> 
 2714   let {a7' = fromIntegral a7} in 
 2715   let {a8' = fromIntegral a8} in 
 2716   withQuoteArrayRaw a9 $ \a9' -> 
 2717   withSwapIndex a10 $ \a10' -> 
 2718   withSwapIndex a11 $ \a11' -> 
 2719   let {a12' = C2HSImp.fromBool a12} in 
 2720   let {a13' = fromIntegral a13} in 
 2721   let {a14' = fromIntegral a14} in 
 2722   withQuoteArrayRaw a15 $ \a15' -> 
 2723   let {a16' = C2HSImp.fromBool a16} in 
 2724   let {a17' = C2HSImp.fromBool a17} in 
 2725   let {a18' = C2HSImp.fromBool a18} in 
 2726   let {a19' = C2HSImp.fromBool a19} in 
 2727   let {a20' = C2HSImp.fromBool a20} in 
 2728   withMaybeEndCriteria a21 $ \a21' -> 
 2729   withMaybeOptimizationMethod a22 $ \a22' -> 
 2730   let {a23' = fromMaybeDouble a23} in 
 2731   let {a24' = fromMaybeDouble a24} in 
 2732   let {a25' = C2HSImp.fromBool a25} in 
 2733   let {a26' = fromIntegral a26} in 
 2734   let {a27' = C2HSImp.fromBool a27} in 
 2735   let {a28' = realToFrac a28} in 
 2736   preErrorCheck $ \a29' -> 
 2737   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' >>= \res ->
 2738   peekSabrSwaptionVolatilityCube res >>= \res' ->
 2739   errorCheck  a29'>>
 2740   return (res')
 2741 
 2742 
 2743 
 2744 -- |The non-SABR, linear-interpolation swaption volatility cube: interpolates the given
 2745 -- @volSpreads@ rather than calibrating a smile model. No 'EndCriteria'\/'OptimizationMethod'
 2746 -- hazard here -- this class never calibrates anything. See 'sabrSwaptionVolatilityCube' for the
 2747 -- @volSpreads@ flattening convention (identical here, minus @parametersGuess@).
 2748 interpolatedSwaptionVolatilityCube :: GenSwaptionVolatilityStructure sv -- ^atmVolStructure
 2749   -> [(Word, TimeUnit)] -- ^optionTenors
 2750   -> [(Word, TimeUnit)] -- ^swapTenors
 2751   -> [Double] -- ^strikeSpreads
 2752   -> Matrix (GenQuote q) -- ^volSpreads
 2753   -> GenSwapIndex sidx1 -- ^swapIndexBase
 2754   -> GenSwapIndex sidx2 -- ^shortSwapIndexBase
 2755   -> Bool -- ^vegaWeightedSmileFit
 2756   -> IO InterpolatedSwaptionVolatilityCube
 2757 interpolatedSwaptionVolatilityCube atm ot st ss (Matrix vr vc vd) sidx1 sidx2 vw =
 2758   qlInterpolatedSwaptionVolatilityCube atm opl opu spl spu ss vr vc vd sidx1 sidx2 vw
 2759   where (opl, opu) = unzip ot; (spl, spu) = unzip st
 2760 qlInterpolatedSwaptionVolatilityCube :: (GenSwaptionVolatilityStructure sv) -> ([Word]) -> ([TimeUnit]) -> ([Word]) -> ([TimeUnit]) -> ([Double]) -> (Word) -> (Word) -> ([GenQuote q]) -> (GenSwapIndex sidx1) -> (GenSwapIndex sidx2) -> (Bool) -> IO ((InterpolatedSwaptionVolatilityCube))
 2761 qlInterpolatedSwaptionVolatilityCube a1 a2 a3 a4 a5 a6 a7 a8 a9 a10 a11 a12 =
 2762   withSwaptionVolatilityStructure a1 $ \a1' -> 
 2763   withIntArray a2 $ \(a2'1, a2'2) -> 
 2764   withEnumArray a3 $ \(a3'1, a3'2) -> 
 2765   withIntArray a4 $ \(a4'1, a4'2) -> 
 2766   withEnumArray a5 $ \(a5'1, a5'2) -> 
 2767   withDoubleArray a6 $ \(a6'1, a6'2) -> 
 2768   let {a7' = fromIntegral a7} in 
 2769   let {a8' = fromIntegral a8} in 
 2770   withQuoteArrayRaw a9 $ \a9' -> 
 2771   withSwapIndex a10 $ \a10' -> 
 2772   withSwapIndex a11 $ \a11' -> 
 2773   let {a12' = C2HSImp.fromBool a12} in 
 2774   preErrorCheck $ \a13' -> 
 2775   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 ->
 2776   peekInterpolatedSwaptionVolatilityCube res >>= \res' ->
 2777   errorCheck  a13'>>
 2778   return (res')
 2779 
 2780 
 2781 
 2782 toMatrixDouble :: (Word, Word, [Double]) -> Matrix Double
 2783 toMatrixDouble (r, c, d) = Matrix r c d
 2784 
 2785 -- |Per-node calibrated SABR parameters (alpha, beta, nu, rho columns) before ATM recalibration.
 2786 sparseSabrParameters :: SabrSwaptionVolatilityCube -> IO (Matrix Double)
 2787 sparseSabrParameters sv = toMatrixDouble <$> qlSabrSwaptionVolatilityCubeSparseSabrParameters sv
 2788 qlSabrSwaptionVolatilityCubeSparseSabrParameters :: (SabrSwaptionVolatilityCube) -> IO ((Word), (Word), ([Double]))
 2789 qlSabrSwaptionVolatilityCubeSparseSabrParameters a1 =
 2790   withSabrSwaptionVolatilityCube a1 $ \a1' -> 
 2791   prePtr $ \a2' -> 
 2792   prePtr $ \a3' -> 
 2793   preArray $ \(a4'1, a4'2) -> 
 2794   preErrorCheck $ \a5' -> 
 2795   qlSabrSwaptionVolatilityCubeSparseSabrParameters'_ a1' a2' a3' a4'1  a4'2 a5' >>
 2796   peekWord  a2'>>= \a2'' -> 
 2797   peekWord  a3'>>= \a3'' -> 
 2798   peekDoubleArray  a4'1  a4'2>>= \a4'' -> 
 2799   errorCheck  a5'>>
 2800   return (a2'', a3'', a4'')
 2801 
 2802 
 2803 
 2804 -- |Per-node calibrated SABR parameters, meaningfully populated only when the cube was built with
 2805 -- @isAtmCalibrated = True@ (see 'sabrSwaptionVolatilityCube').
 2806 denseSabrParameters :: SabrSwaptionVolatilityCube -> IO (Matrix Double)
 2807 denseSabrParameters sv = toMatrixDouble <$> qlSabrSwaptionVolatilityCubeDenseSabrParameters sv
 2808 qlSabrSwaptionVolatilityCubeDenseSabrParameters :: (SabrSwaptionVolatilityCube) -> IO ((Word), (Word), ([Double]))
 2809 qlSabrSwaptionVolatilityCubeDenseSabrParameters a1 =
 2810   withSabrSwaptionVolatilityCube a1 $ \a1' -> 
 2811   prePtr $ \a2' -> 
 2812   prePtr $ \a3' -> 
 2813   preArray $ \(a4'1, a4'2) -> 
 2814   preErrorCheck $ \a5' -> 
 2815   qlSabrSwaptionVolatilityCubeDenseSabrParameters'_ a1' a2' a3' a4'1  a4'2 a5' >>
 2816   peekWord  a2'>>= \a2'' -> 
 2817   peekWord  a3'>>= \a3'' -> 
 2818   peekDoubleArray  a4'1  a4'2>>= \a4'' -> 
 2819   errorCheck  a5'>>
 2820   return (a2'', a3'', a4'')
 2821 
 2822 
 2823 
 2824 -- |The raw market vol grid the cube's SABR fit targets: ATM vol (interpolated from
 2825 -- @atmVolStructure@ at each node) plus @volSpreads@.
 2826 marketVolCube :: SabrSwaptionVolatilityCube -> IO (Matrix Double)
 2827 marketVolCube sv = toMatrixDouble <$> qlSabrSwaptionVolatilityCubeMarketVolCube sv
 2828 qlSabrSwaptionVolatilityCubeMarketVolCube :: (SabrSwaptionVolatilityCube) -> IO ((Word), (Word), ([Double]))
 2829 qlSabrSwaptionVolatilityCubeMarketVolCube a1 =
 2830   withSabrSwaptionVolatilityCube a1 $ \a1' -> 
 2831   prePtr $ \a2' -> 
 2832   prePtr $ \a3' -> 
 2833   preArray $ \(a4'1, a4'2) -> 
 2834   preErrorCheck $ \a5' -> 
 2835   qlSabrSwaptionVolatilityCubeMarketVolCube'_ a1' a2' a3' a4'1  a4'2 a5' >>
 2836   peekWord  a2'>>= \a2'' -> 
 2837   peekWord  a3'>>= \a3'' -> 
 2838   peekDoubleArray  a4'1  a4'2>>= \a4'' -> 
 2839   errorCheck  a5'>>
 2840   return (a2'', a3'', a4'')
 2841 
 2842 
 2843 
 2844 -- |Like 'marketVolCube', adjusted so the cube's own ATM row is consistent with @atmVolStructure@;
 2845 -- meaningfully populated only when the cube was built with @isAtmCalibrated = True@.
 2846 volCubeAtmCalibrated :: SabrSwaptionVolatilityCube -> IO (Matrix Double)
 2847 volCubeAtmCalibrated sv = toMatrixDouble <$> qlSabrSwaptionVolatilityCubeVolCubeAtmCalibrated sv
 2848 qlSabrSwaptionVolatilityCubeVolCubeAtmCalibrated :: (SabrSwaptionVolatilityCube) -> IO ((Word), (Word), ([Double]))
 2849 qlSabrSwaptionVolatilityCubeVolCubeAtmCalibrated a1 =
 2850   withSabrSwaptionVolatilityCube a1 $ \a1' -> 
 2851   prePtr $ \a2' -> 
 2852   prePtr $ \a3' -> 
 2853   preArray $ \(a4'1, a4'2) -> 
 2854   preErrorCheck $ \a5' -> 
 2855   qlSabrSwaptionVolatilityCubeVolCubeAtmCalibrated'_ a1' a2' a3' a4'1  a4'2 a5' >>
 2856   peekWord  a2'>>= \a2'' -> 
 2857   peekWord  a3'>>= \a3'' -> 
 2858   peekDoubleArray  a4'1  a4'2>>= \a4'' -> 
 2859   errorCheck  a5'>>
 2860   return (a2'', a3'', a4'')
 2861 
 2862 
 2863 
 2864 -- |ATM strike at a given (option date, swap tenor) node.
 2865 sabrSwaptionVolatilityCubeAtmStrike' :: (SabrSwaptionVolatilityCube) -> (Day) -- ^optionDate
 2866  -> ((Word,TimeUnit)) -- ^swapTenor
 2867  -> IO ((Double))
 2868 sabrSwaptionVolatilityCubeAtmStrike' a1 a2 a3 =
 2869   withSabrSwaptionVolatilityCube a1 $ \a1' -> 
 2870   withDay a2 $ \a2' -> 
 2871   let {(a3'1, a3'2) = fromEnumQuantity a3} in 
 2872   preErrorCheck $ \a4' -> 
 2873   sabrSwaptionVolatilityCubeAtmStrike''_ a1' a2' a3'1  a3'2 a4' >>= \res ->
 2874   let {res' = realToFrac res} in
 2875   errorCheck  a4'>>
 2876   return (res')
 2877 
 2878 
 2879 
 2880 -- |ATM strike at a given (option tenor, swap tenor) node, see 'sabrSwaptionVolatilityCubeAtmStrike\''
 2881 sabrSwaptionVolatilityCubeAtmStrike :: (SabrSwaptionVolatilityCube) -> ((Word,TimeUnit)) -- ^optionTenor
 2882  -> ((Word,TimeUnit)) -- ^swapTenor
 2883  -> IO ((Double))
 2884 sabrSwaptionVolatilityCubeAtmStrike a1 a2 a3 =
 2885   withSabrSwaptionVolatilityCube a1 $ \a1' -> 
 2886   let {(a2'1, a2'2) = fromEnumQuantity a2} in 
 2887   let {(a3'1, a3'2) = fromEnumQuantity a3} in 
 2888   preErrorCheck $ \a4' -> 
 2889   sabrSwaptionVolatilityCubeAtmStrike'_ a1' a2'1  a2'2 a3'1  a3'2 a4' >>= \res ->
 2890   let {res' = realToFrac res} in
 2891   errorCheck  a4'>>
 2892   return (res')
 2893 
 2894 
 2895 
 2896 -- |ATM strike at a given (option date, swap tenor) node.
 2897 interpolatedSwaptionVolatilityCubeAtmStrike' :: (InterpolatedSwaptionVolatilityCube) -> (Day) -- ^optionDate
 2898  -> ((Word,TimeUnit)) -- ^swapTenor
 2899  -> IO ((Double))
 2900 interpolatedSwaptionVolatilityCubeAtmStrike' a1 a2 a3 =
 2901   withInterpolatedSwaptionVolatilityCube a1 $ \a1' -> 
 2902   withDay a2 $ \a2' -> 
 2903   let {(a3'1, a3'2) = fromEnumQuantity a3} in 
 2904   preErrorCheck $ \a4' -> 
 2905   interpolatedSwaptionVolatilityCubeAtmStrike''_ a1' a2' a3'1  a3'2 a4' >>= \res ->
 2906   let {res' = realToFrac res} in
 2907   errorCheck  a4'>>
 2908   return (res')
 2909 
 2910 
 2911 
 2912 -- |ATM strike at a given (option tenor, swap tenor) node, see
 2913 -- 'interpolatedSwaptionVolatilityCubeAtmStrike\''
 2914 interpolatedSwaptionVolatilityCubeAtmStrike :: (InterpolatedSwaptionVolatilityCube) -> ((Word,TimeUnit)) -- ^optionTenor
 2915  -> ((Word,TimeUnit)) -- ^swapTenor
 2916  -> IO ((Double))
 2917 interpolatedSwaptionVolatilityCubeAtmStrike a1 a2 a3 =
 2918   withInterpolatedSwaptionVolatilityCube a1 $ \a1' -> 
 2919   let {(a2'1, a2'2) = fromEnumQuantity a2} in 
 2920   let {(a3'1, a3'2) = fromEnumQuantity a3} in 
 2921   preErrorCheck $ \a4' -> 
 2922   interpolatedSwaptionVolatilityCubeAtmStrike'_ a1' a2'1  a2'2 a3'1  a3'2 a4' >>= \res ->
 2923   let {res' = realToFrac res} in
 2924   errorCheck  a4'>>
 2925   return (res')
 2926 
 2927 
 2928 
 2929 -- vim: set ff=unix ts=8 sts=2 sw=2 et:
 2930 
 2931 foreign import ccall safe "QuantLib/TermStructure/Volatility.chs.h qlLocalVolSurface"
 2932   localVolSurface'_ :: ((C2HSImp.Ptr (CBlackVolTermStructure')) -> ((C2HSImp.Ptr (CYieldTermStructure')) -> ((C2HSImp.Ptr (CYieldTermStructure')) -> ((C2HSImp.Ptr (CQuote')) -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO (C2HSImp.Ptr (CLocalVolTermStructure'))))))))
 2933 
 2934 foreign import ccall safe "QuantLib/TermStructure/Volatility.chs.h qlNoExceptLocalVolSurface"
 2935   noExceptLocalVolSurface'_ :: ((C2HSImp.Ptr (CBlackVolTermStructure')) -> ((C2HSImp.Ptr (CYieldTermStructure')) -> ((C2HSImp.Ptr (CYieldTermStructure')) -> ((C2HSImp.Ptr (CQuote')) -> (C2HSImp.CDouble -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO (C2HSImp.Ptr (CLocalVolTermStructure')))))))))
 2936 
 2937 foreign import ccall safe "QuantLib/TermStructure/Volatility.chs.h qlFixedLocalVolSurface"
 2938   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 C2HSImp.CChar)) -> (IO (C2HSImp.Ptr (CLocalVolTermStructure')))))))))))))))
 2939 
 2940 foreign import ccall safe "QuantLib/TermStructure/Volatility.chs.h qlLocalVolTermStructureLocalVol"
 2941   localVol'_ :: ((C2HSImp.Ptr (CLocalVolTermStructure')) -> (C2HSImp.CInt -> (C2HSImp.CDouble -> (C2HSImp.CInt -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO C2HSImp.CDouble))))))
 2942 
 2943 foreign import ccall safe "QuantLib/TermStructure/Volatility.chs.h qlConstantOptionletVol1"
 2944   constantOptionletVolatility''_ :: (C2HSImp.CUInt -> ((C2HSImp.Ptr (CCalendar)) -> (C2HSImp.CInt -> ((C2HSImp.Ptr (CQuote')) -> ((C2HSImp.Ptr (CDayCounter)) -> (C2HSImp.CInt -> (C2HSImp.CDouble -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO (C2HSImp.Ptr (COptionletVolatilityStructure')))))))))))
 2945 
 2946 foreign import ccall safe "QuantLib/TermStructure/Volatility.chs.h qlConstantOptionletVolatility"
 2947   constantOptionletVolatility'_ :: (C2HSImp.CInt -> ((C2HSImp.Ptr (CCalendar)) -> (C2HSImp.CInt -> ((C2HSImp.Ptr (CQuote')) -> ((C2HSImp.Ptr (CDayCounter)) -> (C2HSImp.CInt -> (C2HSImp.CDouble -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO (C2HSImp.Ptr (COptionletVolatilityStructure')))))))))))
 2948 
 2949 foreign import ccall safe "QuantLib/TermStructure/Volatility.chs.h qlOptionletStripper1"
 2950   optionletStripper1'_ :: ((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 (C2HSImp.Ptr C2HSImp.CChar)) -> (IO (C2HSImp.Ptr (COptionletVolatilityStructure')))))))))))))))
 2951 
 2952 foreign import ccall safe "QuantLib/TermStructure/Volatility.chs.h qlOptionletStripper2"
 2953   optionletStripper2'_ :: ((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.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO (C2HSImp.Ptr (COptionletStripper2))))))))))))))))
 2954 
 2955 foreign import ccall safe "QuantLib/TermStructure/Volatility.chs.h qlOptionletStripper2AsOptionletVolatilityStructure"
 2956   optionletStripper2AsOptionletVolatilityStructure'_ :: ((C2HSImp.Ptr (COptionletStripper2)) -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO (C2HSImp.Ptr (COptionletVolatilityStructure')))))
 2957 
 2958 foreign import ccall safe "QuantLib/TermStructure/Volatility.chs.h qlOptionletStripper2AtmCapFloorStrikes"
 2959   optionletStripper2AtmCapFloorStrikes'_ :: ((C2HSImp.Ptr (COptionletStripper2)) -> ((C2HSImp.Ptr C2HSImp.CUInt) -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CDouble)) -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO ())))))
 2960 
 2961 foreign import ccall safe "QuantLib/TermStructure/Volatility.chs.h qlOptionletStripper2AtmCapFloorPrices"
 2962   optionletStripper2AtmCapFloorPrices'_ :: ((C2HSImp.Ptr (COptionletStripper2)) -> ((C2HSImp.Ptr C2HSImp.CUInt) -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CDouble)) -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO ())))))
 2963 
 2964 foreign import ccall safe "QuantLib/TermStructure/Volatility.chs.h qlOptionletStripper2SpreadsVol"
 2965   optionletStripper2SpreadsVol'_ :: ((C2HSImp.Ptr (COptionletStripper2)) -> ((C2HSImp.Ptr C2HSImp.CUInt) -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CDouble)) -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO ())))))
 2966 
 2967 foreign import ccall safe "QuantLib/TermStructure/Volatility.chs.h qlRelinkableOptionletVolatilityStructure"
 2968   relinkableOptionletVolatilityStructure'_ :: ((C2HSImp.Ptr (COptionletVolatilityStructure')) -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO (C2HSImp.Ptr (CRelinkableOptionletVolatilityStructure')))))
 2969 
 2970 foreign import ccall safe "QuantLib/TermStructure/Volatility.chs.h qlRelinkableOptionletVolatilityStructureLinkTo"
 2971   linkOptionletVolTo'_ :: ((C2HSImp.Ptr (CRelinkableOptionletVolatilityStructure')) -> ((C2HSImp.Ptr (COptionletVolatilityStructure')) -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO ()))))
 2972 
 2973 foreign import ccall safe "QuantLib/TermStructure/Volatility.chs.h qlBlackConstantVol1"
 2974   blackConstantVol''_ :: (C2HSImp.CUInt -> ((C2HSImp.Ptr (CCalendar)) -> ((C2HSImp.Ptr (CQuote')) -> ((C2HSImp.Ptr (CDayCounter)) -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO (C2HSImp.Ptr (CBlackVolTermStructure'))))))))
 2975 
 2976 foreign import ccall safe "QuantLib/TermStructure/Volatility.chs.h qlBlackConstantVol"
 2977   blackConstantVol'_ :: (C2HSImp.CInt -> ((C2HSImp.Ptr (CCalendar)) -> ((C2HSImp.Ptr (CQuote')) -> ((C2HSImp.Ptr (CDayCounter)) -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO (C2HSImp.Ptr (CBlackVolTermStructure'))))))))
 2978 
 2979 foreign import ccall safe "QuantLib/TermStructure/Volatility.chs.h qlRelinkableBlackVolTermStructure"
 2980   relinkableBlackVolTermStructure'_ :: ((C2HSImp.Ptr (CBlackVolTermStructure')) -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO (C2HSImp.Ptr (CRelinkableBlackVolTermStructure')))))
 2981 
 2982 foreign import ccall safe "QuantLib/TermStructure/Volatility.chs.h qlRelinkableBlackVolTermStructureLinkTo"
 2983   linkBlackVolTo'_ :: ((C2HSImp.Ptr (CRelinkableBlackVolTermStructure')) -> ((C2HSImp.Ptr (CBlackVolTermStructure')) -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO ()))))
 2984 
 2985 foreign import ccall safe "QuantLib/TermStructure/Volatility.chs.h qlConstantSwaptionVolatility1"
 2986   constantSwaptionVolatility''_ :: (C2HSImp.CInt -> ((C2HSImp.Ptr (CCalendar)) -> (C2HSImp.CInt -> ((C2HSImp.Ptr (CQuote')) -> ((C2HSImp.Ptr (CDayCounter)) -> (C2HSImp.CInt -> (C2HSImp.CDouble -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO (C2HSImp.Ptr (CSwaptionVolatilityStructure')))))))))))
 2987 
 2988 foreign import ccall safe "QuantLib/TermStructure/Volatility.chs.h qlConstantSwaptionVolatility"
 2989   constantSwaptionVolatility'_ :: (C2HSImp.CUInt -> ((C2HSImp.Ptr (CCalendar)) -> (C2HSImp.CInt -> ((C2HSImp.Ptr (CQuote')) -> ((C2HSImp.Ptr (CDayCounter)) -> (C2HSImp.CInt -> (C2HSImp.CDouble -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO (C2HSImp.Ptr (CSwaptionVolatilityStructure')))))))))))
 2990 
 2991 foreign import ccall safe "QuantLib/TermStructure/Volatility.chs.h qlSwaptionVolatilityStructureBlackVariance1"
 2992   blackVarianceForPeriod''_ :: ((C2HSImp.Ptr (CSwaptionVolatilityStructure')) -> (C2HSImp.CInt -> (C2HSImp.CInt -> (C2HSImp.CInt -> (C2HSImp.CDouble -> (C2HSImp.CInt -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO C2HSImp.CDouble))))))))
 2993 
 2994 foreign import ccall safe "QuantLib/TermStructure/Volatility.chs.h qlSwaptionVolatilityStructureBlackVariance2"
 2995   blackVarianceForPeriod'_ :: ((C2HSImp.Ptr (CSwaptionVolatilityStructure')) -> (C2HSImp.CDouble -> (C2HSImp.CInt -> (C2HSImp.CInt -> (C2HSImp.CDouble -> (C2HSImp.CInt -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO C2HSImp.CDouble))))))))
 2996 
 2997 foreign import ccall safe "QuantLib/TermStructure/Volatility.chs.h qlSwaptionVolatilityStructureBlackVariance3"
 2998   blackVarianceForTenor'_ :: ((C2HSImp.Ptr (CSwaptionVolatilityStructure')) -> (C2HSImp.CInt -> (C2HSImp.CInt -> (C2HSImp.CDouble -> (C2HSImp.CDouble -> (C2HSImp.CInt -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO C2HSImp.CDouble))))))))
 2999 
 3000 foreign import ccall safe "QuantLib/TermStructure/Volatility.chs.h qlSwaptionVolatilityStructureBlackVariance4"
 3001   blackVariance''_ :: ((C2HSImp.Ptr (CSwaptionVolatilityStructure')) -> (C2HSImp.CInt -> (C2HSImp.CDouble -> (C2HSImp.CDouble -> (C2HSImp.CInt -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO C2HSImp.CDouble)))))))
 3002 
 3003 foreign import ccall safe "QuantLib/TermStructure/Volatility.chs.h qlSwaptionVolatilityStructureBlackVariance5"
 3004   blackVariance'_ :: ((C2HSImp.Ptr (CSwaptionVolatilityStructure')) -> (C2HSImp.CDouble -> (C2HSImp.CDouble -> (C2HSImp.CDouble -> (C2HSImp.CInt -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO C2HSImp.CDouble)))))))
 3005 
 3006 foreign import ccall safe "QuantLib/TermStructure/Volatility.chs.h qlSwaptionVolatilityStructureBlackVariance"
 3007   blackVarianceForPeriods'_ :: ((C2HSImp.Ptr (CSwaptionVolatilityStructure')) -> (C2HSImp.CInt -> (C2HSImp.CInt -> (C2HSImp.CInt -> (C2HSImp.CInt -> (C2HSImp.CDouble -> (C2HSImp.CInt -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO C2HSImp.CDouble)))))))))
 3008 
 3009 foreign import ccall safe "QuantLib/TermStructure/Volatility.chs.h qlSwaptionVolatilityStructureMaxSwapLength"
 3010   maxSwapLength'_ :: ((C2HSImp.Ptr (CSwaptionVolatilityStructure')) -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO C2HSImp.CDouble)))
 3011 
 3012 foreign import ccall safe "QuantLib/TermStructure/Volatility.chs.h qlSwaptionVolatilityStructureMaxSwapTenor"
 3013   maxSwapTenor'_ :: ((C2HSImp.Ptr (CSwaptionVolatilityStructure')) -> ((C2HSImp.Ptr C2HSImp.CInt) -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO C2HSImp.CInt))))
 3014 
 3015 foreign import ccall safe "QuantLib/TermStructure/Volatility.chs.h qlSwaptionVolatilityStructureSmileSection1"
 3016   smileSectionForPeriod''_ :: ((C2HSImp.Ptr (CSwaptionVolatilityStructure')) -> (C2HSImp.CInt -> (C2HSImp.CInt -> (C2HSImp.CInt -> (C2HSImp.CInt -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO (C2HSImp.Ptr (CSmileSection)))))))))
 3017 
 3018 foreign import ccall safe "QuantLib/TermStructure/Volatility.chs.h qlSwaptionVolatilityStructureSmileSection2"
 3019   smileSectionForPeriod'_ :: ((C2HSImp.Ptr (CSwaptionVolatilityStructure')) -> (C2HSImp.CDouble -> (C2HSImp.CInt -> (C2HSImp.CInt -> (C2HSImp.CInt -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO (C2HSImp.Ptr (CSmileSection)))))))))
 3020 
 3021 foreign import ccall safe "QuantLib/TermStructure/Volatility.chs.h qlSwaptionVolatilityStructureSmileSection3"
 3022   smileSectionForTenor'_ :: ((C2HSImp.Ptr (CSwaptionVolatilityStructure')) -> (C2HSImp.CInt -> (C2HSImp.CInt -> (C2HSImp.CDouble -> (C2HSImp.CInt -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO (C2HSImp.Ptr (CSmileSection)))))))))
 3023 
 3024 foreign import ccall safe "QuantLib/TermStructure/Volatility.chs.h qlSwaptionVolatilityStructureSmileSection4"
 3025   smileSection''_ :: ((C2HSImp.Ptr (CSwaptionVolatilityStructure')) -> (C2HSImp.CInt -> (C2HSImp.CDouble -> (C2HSImp.CInt -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO (C2HSImp.Ptr (CSmileSection))))))))
 3026 
 3027 foreign import ccall safe "QuantLib/TermStructure/Volatility.chs.h qlSwaptionVolatilityStructureSmileSection5"
 3028   smileSection'_ :: ((C2HSImp.Ptr (CSwaptionVolatilityStructure')) -> (C2HSImp.CDouble -> (C2HSImp.CDouble -> (C2HSImp.CInt -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO (C2HSImp.Ptr (CSmileSection))))))))
 3029 
 3030 foreign import ccall safe "QuantLib/TermStructure/Volatility.chs.h qlSwaptionVolatilityStructureSmileSection"
 3031   smileSectionForPeriods'_ :: ((C2HSImp.Ptr (CSwaptionVolatilityStructure')) -> (C2HSImp.CInt -> (C2HSImp.CInt -> (C2HSImp.CInt -> (C2HSImp.CInt -> (C2HSImp.CInt -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO (C2HSImp.Ptr (CSmileSection))))))))))
 3032 
 3033 foreign import ccall safe "QuantLib/TermStructure/Volatility.chs.h qlSabrSmileSection"
 3034   sabrSmileSection'_ :: (C2HSImp.CDouble -> (C2HSImp.CDouble -> (C2HSImp.CDouble -> (C2HSImp.CDouble -> (C2HSImp.CDouble -> (C2HSImp.CDouble -> (C2HSImp.CDouble -> (C2HSImp.CInt -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO (C2HSImp.Ptr (CSmileSection))))))))))))
 3035 
 3036 foreign import ccall safe "QuantLib/TermStructure/Volatility.chs.h qlSabrSmileSection1"
 3037   sabrSmileSection''_ :: (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 C2HSImp.CChar)) -> (IO (C2HSImp.Ptr (CSmileSection))))))))))))))
 3038 
 3039 foreign import ccall safe "QuantLib/TermStructure/Volatility.chs.h qlNoArbSabrSmileSection"
 3040   noArbSabrSmileSection'_ :: (C2HSImp.CDouble -> (C2HSImp.CDouble -> (C2HSImp.CDouble -> (C2HSImp.CDouble -> (C2HSImp.CDouble -> (C2HSImp.CDouble -> (C2HSImp.CDouble -> (C2HSImp.CInt -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO (C2HSImp.Ptr (CSmileSection))))))))))))
 3041 
 3042 foreign import ccall safe "QuantLib/TermStructure/Volatility.chs.h qlNoArbSabrSmileSection1"
 3043   noArbSabrSmileSection''_ :: (C2HSImp.CInt -> (C2HSImp.CDouble -> (C2HSImp.CDouble -> (C2HSImp.CDouble -> (C2HSImp.CDouble -> (C2HSImp.CDouble -> ((C2HSImp.Ptr (CDayCounter)) -> (C2HSImp.CDouble -> (C2HSImp.CInt -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO (C2HSImp.Ptr (CSmileSection)))))))))))))
 3044 
 3045 foreign import ccall safe "QuantLib/TermStructure/Volatility.chs.h qlSmileSectionVolatility"
 3046   smileSectionVolatility'_ :: ((C2HSImp.Ptr (CSmileSection)) -> (C2HSImp.CDouble -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO C2HSImp.CDouble))))
 3047 
 3048 foreign import ccall safe "QuantLib/TermStructure/Volatility.chs.h qlSmileSectionVariance"
 3049   smileSectionVariance'_ :: ((C2HSImp.Ptr (CSmileSection)) -> (C2HSImp.CDouble -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO C2HSImp.CDouble))))
 3050 
 3051 foreign import ccall safe "QuantLib/TermStructure/Volatility.chs.h qlSmileSectionAtmLevel"
 3052   smileSectionAtmLevel'_ :: ((C2HSImp.Ptr (CSmileSection)) -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO C2HSImp.CDouble)))
 3053 
 3054 foreign import ccall safe "QuantLib/TermStructure/Volatility.chs.h qlSmileSectionOptionPrice"
 3055   smileSectionOptionPrice'_ :: ((C2HSImp.Ptr (CSmileSection)) -> (C2HSImp.CDouble -> (C2HSImp.CInt -> (C2HSImp.CDouble -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO C2HSImp.CDouble))))))
 3056 
 3057 foreign import ccall safe "QuantLib/TermStructure/Volatility.chs.h qlSmileSectionDigitalOptionPrice"
 3058   smileSectionDigitalOptionPrice'_ :: ((C2HSImp.Ptr (CSmileSection)) -> (C2HSImp.CDouble -> (C2HSImp.CInt -> (C2HSImp.CDouble -> (C2HSImp.CDouble -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO C2HSImp.CDouble)))))))
 3059 
 3060 foreign import ccall safe "QuantLib/TermStructure/Volatility.chs.h qlSmileSectionDensity"
 3061   smileSectionDensity'_ :: ((C2HSImp.Ptr (CSmileSection)) -> (C2HSImp.CDouble -> (C2HSImp.CDouble -> (C2HSImp.CDouble -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO C2HSImp.CDouble))))))
 3062 
 3063 foreign import ccall safe "QuantLib/TermStructure/Volatility.chs.h qlFlatSmileSection"
 3064   flatSmileSection'_ :: (C2HSImp.CInt -> (C2HSImp.CDouble -> ((C2HSImp.Ptr (CDayCounter)) -> (C2HSImp.CInt -> (C2HSImp.CDouble -> (C2HSImp.CInt -> (C2HSImp.CDouble -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO (C2HSImp.Ptr (CSmileSection)))))))))))
 3065 
 3066 foreign import ccall safe "QuantLib/TermStructure/Volatility.chs.h qlSpreadedSmileSection"
 3067   spreadedSmileSection'_ :: ((C2HSImp.Ptr (CSmileSection)) -> ((C2HSImp.Ptr (CQuote')) -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO (C2HSImp.Ptr (CSmileSection))))))
 3068 
 3069 foreign import ccall safe "QuantLib/TermStructure/Volatility.chs.h qlAtmSmileSection"
 3070   atmSmileSection'_ :: ((C2HSImp.Ptr (CSmileSection)) -> (C2HSImp.CDouble -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO (C2HSImp.Ptr (CSmileSection))))))
 3071 
 3072 foreign import ccall safe "QuantLib/TermStructure/Volatility.chs.h qlSabrInterpolatedSmileSection"
 3073   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 C2HSImp.CChar)) -> (IO (C2HSImp.Ptr (CSabrInterpolatedSmileSection)))))))))))))))))))))))))
 3074 
 3075 foreign import ccall safe "QuantLib/TermStructure/Volatility.chs.h qlSabrInterpolatedSmileSectionAsSmileSection"
 3076   sabrInterpolatedSmileSectionAsSmileSection'_ :: ((C2HSImp.Ptr (CSabrInterpolatedSmileSection)) -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO (C2HSImp.Ptr (CSmileSection)))))
 3077 
 3078 foreign import ccall safe "QuantLib/TermStructure/Volatility.chs.h qlSabrInterpolatedSmileSectionAlpha"
 3079   sabrInterpolatedSmileSectionAlpha'_ :: ((C2HSImp.Ptr (CSabrInterpolatedSmileSection)) -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO C2HSImp.CDouble)))
 3080 
 3081 foreign import ccall safe "QuantLib/TermStructure/Volatility.chs.h qlSabrInterpolatedSmileSectionBeta"
 3082   sabrInterpolatedSmileSectionBeta'_ :: ((C2HSImp.Ptr (CSabrInterpolatedSmileSection)) -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO C2HSImp.CDouble)))
 3083 
 3084 foreign import ccall safe "QuantLib/TermStructure/Volatility.chs.h qlSabrInterpolatedSmileSectionNu"
 3085   sabrInterpolatedSmileSectionNu'_ :: ((C2HSImp.Ptr (CSabrInterpolatedSmileSection)) -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO C2HSImp.CDouble)))
 3086 
 3087 foreign import ccall safe "QuantLib/TermStructure/Volatility.chs.h qlSabrInterpolatedSmileSectionRho"
 3088   sabrInterpolatedSmileSectionRho'_ :: ((C2HSImp.Ptr (CSabrInterpolatedSmileSection)) -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO C2HSImp.CDouble)))
 3089 
 3090 foreign import ccall safe "QuantLib/TermStructure/Volatility.chs.h qlSabrInterpolatedSmileSectionRmsError"
 3091   sabrInterpolatedSmileSectionRmsError'_ :: ((C2HSImp.Ptr (CSabrInterpolatedSmileSection)) -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO C2HSImp.CDouble)))
 3092 
 3093 foreign import ccall safe "QuantLib/TermStructure/Volatility.chs.h qlSabrInterpolatedSmileSectionMaxError"
 3094   sabrInterpolatedSmileSectionMaxError'_ :: ((C2HSImp.Ptr (CSabrInterpolatedSmileSection)) -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO C2HSImp.CDouble)))
 3095 
 3096 foreign import ccall safe "QuantLib/TermStructure/Volatility.chs.h qlSabrInterpolatedSmileSectionEndCriteria"
 3097   sabrInterpolatedSmileSectionEndCriteria'_ :: ((C2HSImp.Ptr (CSabrInterpolatedSmileSection)) -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO C2HSImp.CInt)))
 3098 
 3099 foreign import ccall safe "QuantLib/TermStructure/Volatility.chs.h qlSwaptionVolatilityStructureSwapLength1"
 3100   swapLength''_ :: ((C2HSImp.Ptr (CSwaptionVolatilityStructure')) -> (C2HSImp.CInt -> (C2HSImp.CInt -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO C2HSImp.CDouble)))))
 3101 
 3102 foreign import ccall safe "QuantLib/TermStructure/Volatility.chs.h qlSwaptionVolatilityStructureSwapLength"
 3103   swapLength'_ :: ((C2HSImp.Ptr (CSwaptionVolatilityStructure')) -> (C2HSImp.CInt -> (C2HSImp.CInt -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO C2HSImp.CDouble)))))
 3104 
 3105 foreign import ccall safe "QuantLib/TermStructure/Volatility.chs.h qlSwaptionVolatilityStructureVolatility1"
 3106   volatilityForPeriod''_ :: ((C2HSImp.Ptr (CSwaptionVolatilityStructure')) -> (C2HSImp.CInt -> (C2HSImp.CInt -> (C2HSImp.CInt -> (C2HSImp.CDouble -> (C2HSImp.CInt -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO C2HSImp.CDouble))))))))
 3107 
 3108 foreign import ccall safe "QuantLib/TermStructure/Volatility.chs.h qlSwaptionVolatilityStructureVolatility2"
 3109   volatilityForPeriod'_ :: ((C2HSImp.Ptr (CSwaptionVolatilityStructure')) -> (C2HSImp.CDouble -> (C2HSImp.CInt -> (C2HSImp.CInt -> (C2HSImp.CDouble -> (C2HSImp.CInt -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO C2HSImp.CDouble))))))))
 3110 
 3111 foreign import ccall safe "QuantLib/TermStructure/Volatility.chs.h qlSwaptionVolatilityStructureVolatility3"
 3112   volatilityForTenor'_ :: ((C2HSImp.Ptr (CSwaptionVolatilityStructure')) -> (C2HSImp.CInt -> (C2HSImp.CInt -> (C2HSImp.CDouble -> (C2HSImp.CDouble -> (C2HSImp.CInt -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO C2HSImp.CDouble))))))))
 3113 
 3114 foreign import ccall safe "QuantLib/TermStructure/Volatility.chs.h qlSwaptionVolatilityStructureVolatility4"
 3115   volatilityForTenor''_ :: ((C2HSImp.Ptr (CSwaptionVolatilityStructure')) -> (C2HSImp.CInt -> (C2HSImp.CDouble -> (C2HSImp.CDouble -> (C2HSImp.CInt -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO C2HSImp.CDouble)))))))
 3116 
 3117 foreign import ccall safe "QuantLib/TermStructure/Volatility.chs.h qlSwaptionVolatilityStructureVolatility5"
 3118   volatility'_ :: ((C2HSImp.Ptr (CSwaptionVolatilityStructure')) -> (C2HSImp.CDouble -> (C2HSImp.CDouble -> (C2HSImp.CDouble -> (C2HSImp.CInt -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO C2HSImp.CDouble)))))))
 3119 
 3120 foreign import ccall safe "QuantLib/TermStructure/Volatility.chs.h qlSwaptionVolatilityStructureVolatility"
 3121   volatilityForPeriods'_ :: ((C2HSImp.Ptr (CSwaptionVolatilityStructure')) -> (C2HSImp.CInt -> (C2HSImp.CInt -> (C2HSImp.CInt -> (C2HSImp.CInt -> (C2HSImp.CDouble -> (C2HSImp.CInt -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO C2HSImp.CDouble)))))))))
 3122 
 3123 foreign import ccall safe "QuantLib/TermStructure/Volatility.chs.h qlCallableBondConstantVolatility1"
 3124   callableBondConstantVolatility''_ :: (C2HSImp.CUInt -> ((C2HSImp.Ptr (CCalendar)) -> ((C2HSImp.Ptr (CQuote')) -> ((C2HSImp.Ptr (CDayCounter)) -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO (C2HSImp.Ptr (CCallableBondVolatilityStructure'))))))))
 3125 
 3126 foreign import ccall safe "QuantLib/TermStructure/Volatility.chs.h qlCallableBondConstantVolatility"
 3127   callableBondConstantVolatility'_ :: (C2HSImp.CInt -> ((C2HSImp.Ptr (CQuote')) -> ((C2HSImp.Ptr (CDayCounter)) -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO (C2HSImp.Ptr (CCallableBondVolatilityStructure')))))))
 3128 
 3129 foreign import ccall safe "QuantLib/TermStructure/Volatility.chs.h qlConstantCapFloorTermVolatility1"
 3130   constantCapFloorTermVolatility''_ :: (C2HSImp.CInt -> ((C2HSImp.Ptr (CCalendar)) -> (C2HSImp.CInt -> ((C2HSImp.Ptr (CQuote')) -> ((C2HSImp.Ptr (CDayCounter)) -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO (C2HSImp.Ptr (CCapFloorTermVolatilityStructure')))))))))
 3131 
 3132 foreign import ccall safe "QuantLib/TermStructure/Volatility.chs.h qlConstantCapFloorTermVolatility"
 3133   constantCapFloorTermVolatility'_ :: (C2HSImp.CUInt -> ((C2HSImp.Ptr (CCalendar)) -> (C2HSImp.CInt -> ((C2HSImp.Ptr (CQuote')) -> ((C2HSImp.Ptr (CDayCounter)) -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO (C2HSImp.Ptr (CCapFloorTermVolatilityStructure')))))))))
 3134 
 3135 foreign import ccall safe "QuantLib/TermStructure/Volatility.chs.h qlCapFloorTermVolatilityStructureVolatilityForPeriod"
 3136   capFloorVolatilityForPeriod'_ :: ((C2HSImp.Ptr (CCapFloorTermVolatilityStructure')) -> (C2HSImp.CInt -> (C2HSImp.CInt -> (C2HSImp.CDouble -> (C2HSImp.CInt -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO C2HSImp.CDouble)))))))
 3137 
 3138 foreign import ccall safe "QuantLib/TermStructure/Volatility.chs.h qlCapFloorTermVolatilityStructureVolatilityForDate"
 3139   capFloorVolatilityForDate'_ :: ((C2HSImp.Ptr (CCapFloorTermVolatilityStructure')) -> (C2HSImp.CInt -> (C2HSImp.CDouble -> (C2HSImp.CInt -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO C2HSImp.CDouble))))))
 3140 
 3141 foreign import ccall safe "QuantLib/TermStructure/Volatility.chs.h qlCapFloorTermVolatilityStructureVolatilityForTime"
 3142   capFloorVolatilityForTime'_ :: ((C2HSImp.Ptr (CCapFloorTermVolatilityStructure')) -> (C2HSImp.CDouble -> (C2HSImp.CDouble -> (C2HSImp.CInt -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO C2HSImp.CDouble))))))
 3143 
 3144 foreign import ccall safe "QuantLib/TermStructure/Volatility.chs.h qlCapFloorTermVolCurveOptionDates"
 3145   capFloorTermVolCurveOptionDates'_ :: ((C2HSImp.Ptr (CCapFloorTermVolCurve')) -> ((C2HSImp.Ptr C2HSImp.CUInt) -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CInt)) -> (IO ()))))
 3146 
 3147 foreign import ccall safe "QuantLib/TermStructure/Volatility.chs.h qlCapFloorTermVolCurveOptionTimes"
 3148   capFloorTermVolCurveOptionTimes'_ :: ((C2HSImp.Ptr (CCapFloorTermVolCurve')) -> ((C2HSImp.Ptr C2HSImp.CUInt) -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CDouble)) -> (IO ()))))
 3149 
 3150 foreign import ccall safe "QuantLib/TermStructure/Volatility.chs.h qlCapFloorTermVolSurfaceOptionDates"
 3151   capFloorTermVolSurfaceOptionDates'_ :: ((C2HSImp.Ptr (CCapFloorTermVolSurface')) -> ((C2HSImp.Ptr C2HSImp.CUInt) -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CInt)) -> (IO ()))))
 3152 
 3153 foreign import ccall safe "QuantLib/TermStructure/Volatility.chs.h qlCapFloorTermVolSurfaceOptionTimes"
 3154   capFloorTermVolSurfaceOptionTimes'_ :: ((C2HSImp.Ptr (CCapFloorTermVolSurface')) -> ((C2HSImp.Ptr C2HSImp.CUInt) -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CDouble)) -> (IO ()))))
 3155 
 3156 foreign import ccall safe "QuantLib/TermStructure/Volatility.chs.h qlBlackAtmVolCurveAtmVolForPeriod"
 3157   atmVolForPeriod'_ :: ((C2HSImp.Ptr (CBlackAtmVolCurve')) -> (C2HSImp.CInt -> (C2HSImp.CInt -> (C2HSImp.CInt -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO C2HSImp.CDouble))))))
 3158 
 3159 foreign import ccall safe "QuantLib/TermStructure/Volatility.chs.h qlBlackAtmVolCurveAtmVolForDate"
 3160   atmVolForDate'_ :: ((C2HSImp.Ptr (CBlackAtmVolCurve')) -> (C2HSImp.CInt -> (C2HSImp.CInt -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO C2HSImp.CDouble)))))
 3161 
 3162 foreign import ccall safe "QuantLib/TermStructure/Volatility.chs.h qlBlackAtmVolCurveAtmVolForTime"
 3163   atmVolForTime'_ :: ((C2HSImp.Ptr (CBlackAtmVolCurve')) -> (C2HSImp.CDouble -> (C2HSImp.CInt -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO C2HSImp.CDouble)))))
 3164 
 3165 foreign import ccall safe "QuantLib/TermStructure/Volatility.chs.h qlBlackAtmVolCurveAtmVarianceForPeriod"
 3166   atmVarianceForPeriod'_ :: ((C2HSImp.Ptr (CBlackAtmVolCurve')) -> (C2HSImp.CInt -> (C2HSImp.CInt -> (C2HSImp.CInt -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO C2HSImp.CDouble))))))
 3167 
 3168 foreign import ccall safe "QuantLib/TermStructure/Volatility.chs.h qlBlackAtmVolCurveAtmVarianceForDate"
 3169   atmVarianceForDate'_ :: ((C2HSImp.Ptr (CBlackAtmVolCurve')) -> (C2HSImp.CInt -> (C2HSImp.CInt -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO C2HSImp.CDouble)))))
 3170 
 3171 foreign import ccall safe "QuantLib/TermStructure/Volatility.chs.h qlBlackAtmVolCurveAtmVarianceForTime"
 3172   atmVarianceForTime'_ :: ((C2HSImp.Ptr (CBlackAtmVolCurve')) -> (C2HSImp.CDouble -> (C2HSImp.CInt -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO C2HSImp.CDouble)))))
 3173 
 3174 foreign import ccall safe "QuantLib/TermStructure/Volatility.chs.h qlBlackVolSurfaceSmileSectionForPeriod"
 3175   blackVolSurfaceSmileSectionForPeriod'_ :: ((C2HSImp.Ptr (CBlackVolSurface')) -> (C2HSImp.CInt -> (C2HSImp.CInt -> (C2HSImp.CInt -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO (C2HSImp.Ptr (CSmileSection))))))))
 3176 
 3177 foreign import ccall safe "QuantLib/TermStructure/Volatility.chs.h qlBlackVolSurfaceSmileSectionForDate"
 3178   blackVolSurfaceSmileSectionForDate'_ :: ((C2HSImp.Ptr (CBlackVolSurface')) -> (C2HSImp.CInt -> (C2HSImp.CInt -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO (C2HSImp.Ptr (CSmileSection)))))))
 3179 
 3180 foreign import ccall safe "QuantLib/TermStructure/Volatility.chs.h qlBlackVolSurfaceSmileSectionForTime"
 3181   blackVolSurfaceSmileSectionForTime'_ :: ((C2HSImp.Ptr (CBlackVolSurface')) -> (C2HSImp.CDouble -> (C2HSImp.CInt -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO (C2HSImp.Ptr (CSmileSection)))))))
 3182 
 3183 foreign import ccall safe "QuantLib/TermStructure/Volatility.chs.h qlAbcdAtmVolCurve"
 3184   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 C2HSImp.CChar)) -> (IO (C2HSImp.Ptr (CAbcdAtmVolCurve'))))))))))))))))
 3185 
 3186 foreign import ccall safe "QuantLib/TermStructure/Volatility.chs.h qlAbcdAtmVolCurveA"
 3187   abcdAtmVolCurveA'_ :: ((C2HSImp.Ptr (CAbcdAtmVolCurve')) -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO C2HSImp.CDouble)))
 3188 
 3189 foreign import ccall safe "QuantLib/TermStructure/Volatility.chs.h qlAbcdAtmVolCurveB"
 3190   abcdAtmVolCurveB'_ :: ((C2HSImp.Ptr (CAbcdAtmVolCurve')) -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO C2HSImp.CDouble)))
 3191 
 3192 foreign import ccall safe "QuantLib/TermStructure/Volatility.chs.h qlAbcdAtmVolCurveC"
 3193   abcdAtmVolCurveC'_ :: ((C2HSImp.Ptr (CAbcdAtmVolCurve')) -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO C2HSImp.CDouble)))
 3194 
 3195 foreign import ccall safe "QuantLib/TermStructure/Volatility.chs.h qlAbcdAtmVolCurveD"
 3196   abcdAtmVolCurveD'_ :: ((C2HSImp.Ptr (CAbcdAtmVolCurve')) -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO C2HSImp.CDouble)))
 3197 
 3198 foreign import ccall safe "QuantLib/TermStructure/Volatility.chs.h qlAbcdAtmVolCurveRmsError"
 3199   abcdAtmVolCurveRmsError'_ :: ((C2HSImp.Ptr (CAbcdAtmVolCurve')) -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO C2HSImp.CDouble)))
 3200 
 3201 foreign import ccall safe "QuantLib/TermStructure/Volatility.chs.h qlAbcdAtmVolCurveMaxError"
 3202   abcdAtmVolCurveMaxError'_ :: ((C2HSImp.Ptr (CAbcdAtmVolCurve')) -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO C2HSImp.CDouble)))
 3203 
 3204 foreign import ccall safe "QuantLib/TermStructure/Volatility.chs.h qlAbcdAtmVolCurveEndCriteria"
 3205   abcdAtmVolCurveEndCriteria'_ :: ((C2HSImp.Ptr (CAbcdAtmVolCurve')) -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO C2HSImp.CInt)))
 3206 
 3207 foreign import ccall safe "QuantLib/TermStructure/Volatility.chs.h qlAbcdAtmVolCurveKAtTime"
 3208   abcdAtmVolCurveKAtTime'_ :: ((C2HSImp.Ptr (CAbcdAtmVolCurve')) -> (C2HSImp.CDouble -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO C2HSImp.CDouble))))
 3209 
 3210 foreign import ccall safe "QuantLib/TermStructure/Volatility.chs.h qlAbcdAtmVolCurveK"
 3211   abcdAtmVolCurveK'_ :: ((C2HSImp.Ptr (CAbcdAtmVolCurve')) -> ((C2HSImp.Ptr C2HSImp.CUInt) -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CDouble)) -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO ())))))
 3212 
 3213 foreign import ccall safe "QuantLib/TermStructure/Volatility.chs.h qlAbcdAtmVolCurveOptionTenors"
 3214   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 C2HSImp.CChar)) -> (IO ())))))))
 3215 
 3216 foreign import ccall safe "QuantLib/TermStructure/Volatility.chs.h qlAbcdAtmVolCurveOptionTenorsInInterpolation"
 3217   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 C2HSImp.CChar)) -> (IO ())))))))
 3218 
 3219 foreign import ccall safe "QuantLib/TermStructure/Volatility.chs.h qlAbcdAtmVolCurveOptionDates"
 3220   abcdAtmVolCurveOptionDates'_ :: ((C2HSImp.Ptr (CAbcdAtmVolCurve')) -> ((C2HSImp.Ptr C2HSImp.CUInt) -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CInt)) -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO ())))))
 3221 
 3222 foreign import ccall safe "QuantLib/TermStructure/Volatility.chs.h qlAbcdAtmVolCurveOptionTimes"
 3223   abcdAtmVolCurveOptionTimes'_ :: ((C2HSImp.Ptr (CAbcdAtmVolCurve')) -> ((C2HSImp.Ptr C2HSImp.CUInt) -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CDouble)) -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO ())))))
 3224 
 3225 foreign import ccall safe "QuantLib/TermStructure/Volatility.chs.h qlSabrVolSurface"
 3226   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 C2HSImp.CChar)) -> (IO (C2HSImp.Ptr (CSabrVolSurface')))))))))))))))
 3227 
 3228 foreign import ccall safe "QuantLib/TermStructure/Volatility.chs.h qlSabrVolSurfaceAtmCurve"
 3229   sabrVolSurfaceAtmCurve'_ :: ((C2HSImp.Ptr (CSabrVolSurface')) -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO (C2HSImp.Ptr (CBlackAtmVolCurve')))))
 3230 
 3231 foreign import ccall safe "QuantLib/TermStructure/Volatility.chs.h qlSabrVolSurfaceVolatilitySpreadsForPeriod"
 3232   sabrVolSurfaceVolatilitySpreadsForPeriod'_ :: ((C2HSImp.Ptr (CSabrVolSurface')) -> (C2HSImp.CInt -> (C2HSImp.CInt -> ((C2HSImp.Ptr C2HSImp.CUInt) -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CDouble)) -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO ())))))))
 3233 
 3234 foreign import ccall safe "QuantLib/TermStructure/Volatility.chs.h qlSabrVolSurfaceVolatilitySpreadsForDate"
 3235   sabrVolSurfaceVolatilitySpreadsForDate'_ :: ((C2HSImp.Ptr (CSabrVolSurface')) -> (C2HSImp.CInt -> ((C2HSImp.Ptr C2HSImp.CUInt) -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CDouble)) -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO ()))))))
 3236 
 3237 foreign import ccall safe "QuantLib/TermStructure/Volatility.chs.h qlSabrVolSurfaceIndex"
 3238   sabrVolSurfaceIndex'_ :: ((C2HSImp.Ptr (CSabrVolSurface')) -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO (C2HSImp.Ptr (CInterestRateIndex')))))
 3239 
 3240 foreign import ccall safe "QuantLib/TermStructure/Volatility.chs.h qlSabrVolSurfaceOptionDateFromTenor"
 3241   sabrVolSurfaceOptionDateFromTenor'_ :: ((C2HSImp.Ptr (CSabrVolSurface')) -> (C2HSImp.CInt -> (C2HSImp.CInt -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO C2HSImp.CInt)))))
 3242 
 3243 foreign import ccall safe "QuantLib/TermStructure/Volatility.chs.h qlSpreadedSwaptionVolatility"
 3244   spreadedSwaptionVolatility'_ :: ((C2HSImp.Ptr (CSwaptionVolatilityStructure')) -> ((C2HSImp.Ptr (CQuote')) -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO (C2HSImp.Ptr (CSwaptionVolatilityStructure'))))))
 3245 
 3246 foreign import ccall safe "QuantLib/TermStructure/Volatility.chs.h qlSpreadedOptionletVolatility"
 3247   spreadedOptionletVol'_ :: ((C2HSImp.Ptr (COptionletVolatilityStructure')) -> ((C2HSImp.Ptr (CQuote')) -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO (C2HSImp.Ptr (COptionletVolatilityStructure'))))))
 3248 
 3249 foreign import ccall safe "QuantLib/TermStructure/Volatility.chs.h qlRelinkableSwaptionVolatilityStructure"
 3250   relinkableSwaptionVolatilityStructure'_ :: ((C2HSImp.Ptr (CSwaptionVolatilityStructure')) -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO (C2HSImp.Ptr (CRelinkableSwaptionVolatilityStructure')))))
 3251 
 3252 foreign import ccall safe "QuantLib/TermStructure/Volatility.chs.h qlRelinkableSwaptionVolatilityStructureLinkTo"
 3253   linkSwaptionVolTo'_ :: ((C2HSImp.Ptr (CRelinkableSwaptionVolatilityStructure')) -> ((C2HSImp.Ptr (CSwaptionVolatilityStructure')) -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO ()))))
 3254 
 3255 foreign import ccall safe "QuantLib/TermStructure/Volatility.chs.h qlLocalConstantVol1"
 3256   localConstantVol''_ :: (C2HSImp.CUInt -> ((C2HSImp.Ptr (CCalendar)) -> ((C2HSImp.Ptr (CQuote')) -> ((C2HSImp.Ptr (CDayCounter)) -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO (C2HSImp.Ptr (CLocalVolTermStructure'))))))))
 3257 
 3258 foreign import ccall safe "QuantLib/TermStructure/Volatility.chs.h qlLocalConstantVol"
 3259   localConstantVol'_ :: (C2HSImp.CInt -> ((C2HSImp.Ptr (CQuote')) -> ((C2HSImp.Ptr (CDayCounter)) -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO (C2HSImp.Ptr (CLocalVolTermStructure')))))))
 3260 
 3261 foreign import ccall safe "QuantLib/TermStructure/Volatility.chs.h qlLocalVolCurve"
 3262   localVolCurve'_ :: ((C2HSImp.Ptr (CBlackVarianceCurve')) -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO (C2HSImp.Ptr (CLocalVolTermStructure')))))
 3263 
 3264 foreign import ccall safe "QuantLib/TermStructure/Volatility.chs.h qlImpliedVolTermStructure"
 3265   impliedVolTermStructure'_ :: ((C2HSImp.Ptr (CBlackVolTermStructure')) -> (C2HSImp.CInt -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO (C2HSImp.Ptr (CBlackVolTermStructure'))))))
 3266 
 3267 foreign import ccall safe "QuantLib/TermStructure/Volatility.chs.h qlCapFloorTermVolCurve1"
 3268   qlCapFloorTermVolCurve1'_ :: (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 C2HSImp.CChar)) -> (IO (C2HSImp.Ptr (CCapFloorTermVolCurve'))))))))))))))
 3269 
 3270 foreign import ccall safe "QuantLib/TermStructure/Volatility.chs.h qlCapFloorTermVolCurve"
 3271   qlCapFloorTermVolCurve'_ :: (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 C2HSImp.CChar)) -> (IO (C2HSImp.Ptr (CCapFloorTermVolCurve'))))))))))))))
 3272 
 3273 foreign import ccall safe "QuantLib/TermStructure/Volatility.chs.h qlBlackVarianceCurve"
 3274   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 C2HSImp.CChar)) -> (IO (C2HSImp.Ptr (CBlackVarianceCurve'))))))))))))))
 3275 
 3276 foreign import ccall safe "QuantLib/TermStructure/Volatility.chs.h qlBlackVarianceSurface"
 3277   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 C2HSImp.CChar)) -> (IO (C2HSImp.Ptr (CBlackVolTermStructure')))))))))))))))))
 3278 
 3279 foreign import ccall safe "QuantLib/TermStructure/Volatility.chs.h qlPiecewiseBlackVarianceSurface"
 3280   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 C2HSImp.CChar)) -> (IO (C2HSImp.Ptr (CBlackVolTermStructure')))))))))))))
 3281 
 3282 foreign import ccall safe "QuantLib/TermStructure/Volatility.chs.h qlBlackVolatilitySurfaceDelta"
 3283   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 C2HSImp.CChar)) -> (IO (C2HSImp.Ptr (CBlackVolatilitySurfaceDelta')))))))))))))))))))))))))))))))
 3284 
 3285 foreign import ccall safe "QuantLib/TermStructure/Volatility.chs.h qlBlackVolatilitySurfaceDeltaSmile1"
 3286   blackVolSmile'_ :: ((C2HSImp.Ptr (CBlackVolatilitySurfaceDelta')) -> (C2HSImp.CDouble -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO (C2HSImp.Ptr (CSmileSection))))))
 3287 
 3288 foreign import ccall safe "QuantLib/TermStructure/Volatility.chs.h qlBlackVolatilitySurfaceDeltaSmile"
 3289   blackVolSmile''_ :: ((C2HSImp.Ptr (CBlackVolatilitySurfaceDelta')) -> (C2HSImp.CInt -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO (C2HSImp.Ptr (CSmileSection))))))
 3290 
 3291 foreign import ccall safe "QuantLib/TermStructure/Volatility.chs.h qlCapFloorTermVolSurface"
 3292   qlCapFloorTermVolSurface'_ :: (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 C2HSImp.CChar)) -> (IO (C2HSImp.Ptr (CCapFloorTermVolSurface')))))))))))))))))
 3293 
 3294 foreign import ccall safe "QuantLib/TermStructure/Volatility.chs.h qlCapFloorTermVolSurface1"
 3295   qlCapFloorTermVolSurface1'_ :: (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 C2HSImp.CChar)) -> (IO (C2HSImp.Ptr (CCapFloorTermVolSurface')))))))))))))))))
 3296 
 3297 foreign import ccall safe "QuantLib/TermStructure/Volatility.chs.h qlSwaptionVolatilityMatrix"
 3298   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 C2HSImp.CChar)) -> (IO (C2HSImp.Ptr (CSwaptionVolatilityStructure'))))))))))))))))))))))))
 3299 
 3300 foreign import ccall safe "QuantLib/TermStructure/Volatility.chs.h qlSwaptionVolatilityMatrix1"
 3301   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 C2HSImp.CChar)) -> (IO (C2HSImp.Ptr (CSwaptionVolatilityStructure')))))))))))))))))))))))
 3302 
 3303 foreign import ccall safe "QuantLib/TermStructure/Volatility.chs.h qlSabrSwaptionVolatilityCube"
 3304   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.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO (C2HSImp.Ptr (CSabrSwaptionVolatilityCube')))))))))))))))))))))))))))))))))))))
 3305 
 3306 foreign import ccall safe "QuantLib/TermStructure/Volatility.chs.h qlInterpolatedSwaptionVolatilityCube"
 3307   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 C2HSImp.CChar)) -> (IO (C2HSImp.Ptr (CInterpolatedSwaptionVolatilityCube')))))))))))))))))))))
 3308 
 3309 foreign import ccall safe "QuantLib/TermStructure/Volatility.chs.h qlSabrSwaptionVolatilityCubeSparseSabrParameters"
 3310   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 C2HSImp.CChar)) -> (IO ())))))))
 3311 
 3312 foreign import ccall safe "QuantLib/TermStructure/Volatility.chs.h qlSabrSwaptionVolatilityCubeDenseSabrParameters"
 3313   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 C2HSImp.CChar)) -> (IO ())))))))
 3314 
 3315 foreign import ccall safe "QuantLib/TermStructure/Volatility.chs.h qlSabrSwaptionVolatilityCubeMarketVolCube"
 3316   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 C2HSImp.CChar)) -> (IO ())))))))
 3317 
 3318 foreign import ccall safe "QuantLib/TermStructure/Volatility.chs.h qlSabrSwaptionVolatilityCubeVolCubeAtmCalibrated"
 3319   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 C2HSImp.CChar)) -> (IO ())))))))
 3320 
 3321 foreign import ccall safe "QuantLib/TermStructure/Volatility.chs.h qlSabrSwaptionVolatilityCubeAtmStrike1"
 3322   sabrSwaptionVolatilityCubeAtmStrike''_ :: ((C2HSImp.Ptr (CSabrSwaptionVolatilityCube')) -> (C2HSImp.CInt -> (C2HSImp.CInt -> (C2HSImp.CInt -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO C2HSImp.CDouble))))))
 3323 
 3324 foreign import ccall safe "QuantLib/TermStructure/Volatility.chs.h qlSabrSwaptionVolatilityCubeAtmStrike"
 3325   sabrSwaptionVolatilityCubeAtmStrike'_ :: ((C2HSImp.Ptr (CSabrSwaptionVolatilityCube')) -> (C2HSImp.CInt -> (C2HSImp.CInt -> (C2HSImp.CInt -> (C2HSImp.CInt -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO C2HSImp.CDouble)))))))
 3326 
 3327 foreign import ccall safe "QuantLib/TermStructure/Volatility.chs.h qlInterpolatedSwaptionVolatilityCubeAtmStrike1"
 3328   interpolatedSwaptionVolatilityCubeAtmStrike''_ :: ((C2HSImp.Ptr (CInterpolatedSwaptionVolatilityCube')) -> (C2HSImp.CInt -> (C2HSImp.CInt -> (C2HSImp.CInt -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO C2HSImp.CDouble))))))
 3329 
 3330 foreign import ccall safe "QuantLib/TermStructure/Volatility.chs.h qlInterpolatedSwaptionVolatilityCubeAtmStrike"
 3331   interpolatedSwaptionVolatilityCubeAtmStrike'_ :: ((C2HSImp.Ptr (CInterpolatedSwaptionVolatilityCube')) -> (C2HSImp.CInt -> (C2HSImp.CInt -> (C2HSImp.CInt -> (C2HSImp.CInt -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO C2HSImp.CDouble)))))))