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 FlexibleInstances #-}
    6 -- |Historical volatility estimators bound here (@ql\/models\/volatility@, @ql\/prices.hpp@) --
    7 -- 'Garch11', GarmanKlass\/Parkinson, 'ConstantEstimator', 'SimpleLocalEstimator' -- are distinct
    8 -- from "QuantLib.TermStructure.Volatility", which covers forward-looking implied-volatility
    9 -- surfaces and smiles. None of these classes have any calculations of their own beyond a single
   10 -- @calculate@ call and are never needed as an argument type elsewhere, so only 'Garch11' --
   11 -- whose calibrated state ('alpha' etc.) is queried repeatedly -- gets a dedicated Haskell type;
   12 -- every GarmanKlass variant, 'ConstantEstimator', and 'SimpleLocalEstimator' are bound as a
   13 -- single construct-and-calculate function each.
   14 module QuantLib.Model
   15   (
   16     -- * Types
   17     -- ** Model hierarchy
   18     GenCalibratedModel
   19   , CalibratedModel
   20   , GenShortRateModel
   21   , ShortRateModel
   22   , GenOneFactorAffineModel
   23   , OneFactorAffineModel
   24   , HullWhite
   25   , G2
   26   , GenHestonModel
   27   , HestonModel
   28   , RoughHestonModel
   29   , PiecewiseTimeDependentHestonModel
   30   , GenBatesModel
   31   , BatesModel
   32   , BatesDetJumpModel
   33   , GenBatesDoubleExpModel
   34   , BatesDoubleExpModel
   35   , BatesDoubleExpDetJumpModel
   36   , GJRGARCHModel
   37   , Gaussian1dModel
   38   , Gsr
   39   , MarkovFunctional
   40   , LiborForwardModel
   41   , HestonSLVMCModel
   42   , HestonSLVFDMModel
   43   , AffineModel
   44   , ShortRateDynamics
   45 
   46     -- ** Historical volatility estimators
   47   , Garch11
   48   , Garch11Mode(..)
   49 
   50     -- ** Calibration helpers
   51   , GenCalibrationHelper
   52   , CalibrationHelper
   53   , GenBlackCalibrationHelper
   54   , BlackCalibrationHelper
   55   , SwaptionHelper
   56   , BrownianGeneratorFactory
   57 
   58     -- ** Configuration
   59   , CalibrationErrorType(..)
   60   , SobolBrownianOrdering(..)
   61   , HestonSLVGreensAlgorithm(..)
   62   , HestonSLVVarianceTransformation(..)
   63   , HestonSLVFokkerPlanckFdmParams(..)
   64   , HestonSLVFDMLogEntry(..)
   65   , LfmHullWhiteParameterization
   66   , LmCorrelationModel(..)
   67   , LmVolatilityModel(..)
   68   , SwaptionSpan(..)
   69 
   70     -- * Constructors
   71     -- ** Hierarchy and secondary-interface conversion
   72   , AsAffineModel(..)
   73   , AsGaussian1dModel(..)
   74   , asCalibratedModel
   75   , asHestonModel
   76   , asShortRateModel
   77   , asOneFactorAffineModel
   78   , asBatesModel
   79   , asBatesDoubleExpModel
   80   , asCalibrationHelper
   81   , asBlackCalibrationHelper
   82 
   83     -- ** Model construction
   84   , batesModel
   85   , blackKarasinski
   86   , coxIngersollRoss
   87   , extendedCoxIngersollRoss
   88   , g2
   89   , generalizedHullWhite
   90   , gjrGarchModel
   91   , hestonModel
   92   , roughHestonModel
   93   , mtBrownianGeneratorFactory
   94   , sobolBrownianGeneratorFactory
   95   , hestonSlvMcModel
   96   , hestonSlvFdmModel
   97   , hullWhite
   98   , varianceGammaModel
   99   , vasicek
  100   , liborForwardModel
  101   , lfmHullWhiteParameterization
  102   , gsr
  103   , gsrWithReversions
  104   , markovFunctional
  105   , markovFunctionalCaplet
  106   , garch11
  107   , garch11Calibrated
  108 
  109     -- ** Calibration helpers
  110   , capHelper
  111   , hestonModelHelper
  112   , swaptionHelper
  113 
  114     -- * Mutators
  115   , setCovarParam
  116   , calibrate
  117   , calibrateVolatilitiesIterative
  118   , calibrateReversionsIterative
  119   , moveVolatility
  120   , moveReversion
  121   , setPricingEngine
  122   , setParams
  123 
  124     -- * Inspectors
  125     -- ** Pricing and rate calculations
  126   , discount
  127   , discountBond
  128   , discountBondOption
  129   , convexityBias
  130   , numeraire
  131   , gaussian1dZerobond
  132   , gaussian1dZerobondOption
  133   , gaussian1dCompoundedRate
  134   , gaussian1dForwardRate
  135   , gaussian1dSwapRate
  136   , gaussian1dSwapAnnuity
  137   , gaussian1dYGrid
  138   , lfmHullWhiteCovariance
  139   , liborForwardModelS0
  140   , blackPrice
  141   , impliedVolatility
  142 
  143     -- ** Model state and calibration
  144   , roughHestonTheta
  145   , roughHestonKappa
  146   , roughHestonSigma
  147   , roughHestonRho
  148   , roughHestonV0
  149   , roughHestonHurst
  150   , roughHestonProcess
  151   , HasLeverageFunction(..)
  152   , HasVolatilities(..)
  153   , reversions
  154   , HasHelperUnderlying(..)
  155   , g2Dynamics
  156   , shortRate
  157   , stateProcess
  158   , hestonSlvFdmLogEntries
  159   , helperSwaption
  160   , times
  161   , fixedReversion
  162   , params
  163   , value
  164   , calibrationError
  165   , marketValue
  166   , modelValue
  167   , volatility
  168 
  169     -- ** Historical volatility
  170   , forecast
  171   , calculate
  172   , garmanKlassSimpleSigma
  173   , garmanKlassSigma1
  174   , parkinsonSigma
  175   , garmanKlassSigma3
  176   , garmanKlassSigma4
  177   , garmanKlassSigma5
  178   , garmanKlassSigma6
  179   , constantVolatilityEstimator
  180   , simpleLocalVolatilityEstimator
  181   , alpha
  182   , beta
  183   , omega
  184   , longTermVolatility
  185   , logLikelihood
  186   ) where
  187 import qualified Foreign.C.Types as C2HSImp
  188 import qualified Foreign.ForeignPtr as C2HSImp
  189 import qualified Foreign.Marshal.Utils as C2HSImp
  190 import qualified Foreign.Ptr as C2HSImp
  191 import qualified System.IO.Unsafe as C2HSImp
  192 
  193 
  194 
  195 
  196 
  197 
  198 
  199 
  200 
  201 
  202 
  203 import QuantLib.Internal
  204 import QuantLib.Time.Schedule(Frequency)
  205 import QuantLib.InterestRate(VolatilityType)
  206 import QuantLib.CashFlow(RateAveragingType)
  207 import QuantLib.Internal.Type
  208 import QuantLib.Internal.Common
  209 import QuantLib.TermStructure(HasHelperUnderlying(..))
  210 import QuantLib.Math(SobolDirectionIntegers)
  211 import Data.List(genericTake)
  212 import Data.List.NonEmpty(NonEmpty, toList)
  213 import Data.Maybe(fromMaybe)
  214 
  215 data CalibrationErrorType = RelativePriceError
  216                           | PriceError
  217                           | ImpliedVolError
  218   deriving (Enum,Show,Eq,Read)
  219 
  220 
  221 data Garch11Mode = MomentMatchingGuess
  222                  | GammaGuess
  223                  | BestOfTwo
  224                  | DoubleOptimization
  225   deriving (Enum,Show,Eq,Read)
  226 
  227 
  228 
  229 -- |Sobol Brownian-bridge coordinate ordering.
  230 data SobolBrownianOrdering = Factors | Steps | Diagonal deriving (Show, Eq, Read, Enum, Bounded)
  231 
  232 -- |Initial-density approximation used by the Heston SLV Fokker--Planck calibrator.
  233 data HestonSLVGreensAlgorithm = ZeroCorrelation | Gaussian | SemiAnalytical deriving (Show, Eq, Read, Enum, Bounded)
  234 
  235 -- |Variance-coordinate transformation used by the Heston SLV Fokker--Planck calibrator.
  236 data HestonSLVVarianceTransformation = Plain | Power | Log deriving (Show, Eq, Read, Enum, Bounded)
  237 
  238 -- |Full numerical configuration for QuantLib's Fokker--Planck SLV calibration.
  239 data HestonSLVFokkerPlanckFdmParams = HestonSLVFokkerPlanckFdmParams
  240   { hestonSlvXGrid :: !Word, hestonSlvVGrid :: !Word
  241   , hestonSlvTMaxStepsPerYear :: !Word, hestonSlvTMinStepsPerYear :: !Word, hestonSlvTStepNumberDecay :: !Double
  242   , hestonSlvNRannacherTimeSteps :: !Word, hestonSlvPredictionCorrectionSteps :: !Word
  243   , hestonSlvX0Density :: !Double, hestonSlvLocalVolEpsProb :: !Double, hestonSlvMaxIntegrationIterations :: !Word
  244   , hestonSlvVLowerEps :: !Double, hestonSlvVUpperEps :: !Double, hestonSlvVMin :: !Double
  245   , hestonSlvV0Density :: !Double, hestonSlvVLowerBoundDensity :: !Double, hestonSlvVUpperBoundDensity :: !Double
  246   , hestonSlvLeverageFctPropEps :: !Double, hestonSlvGreensAlgorithm :: !HestonSLVGreensAlgorithm
  247   , hestonSlvVarianceTransformation :: !HestonSLVVarianceTransformation, hestonSlvSchemeDesc :: !FdmScheme
  248   }
  249 
  250 -- |A copied FDM diagnostic snapshot. Coordinates are the native mesher coordinates: the spot
  251 -- axis is log-spot and the variance axis follows 'hestonSlvVarianceTransformation'. Density rows
  252 -- correspond to variance coordinates and columns to log-spot coordinates.
  253 data HestonSLVFDMLogEntry = HestonSLVFDMLogEntry
  254   { hestonSlvLogTime :: !Double, hestonSlvLogSpotCoordinates :: !RealVector
  255   , hestonSlvLogVarianceCoordinates :: !RealVector, hestonSlvLogDensity :: !RealMatrix
  256   } deriving (Show, Eq)
  257 
  258 
  259 
  260 
  261 
  262 
  263 
  264 
  265 
  266 
  267 
  268 
  269 
  270 
  271 
  272 
  273 
  274 
  275 
  276 
  277 
  278 
  279 
  280 
  281 
  282 
  283 
  284 
  285 
  286 
  287 
  288 
  289 
  290 
  291 
  292 
  293 
  294 
  295 
  296 
  297 
  298 
  299 
  300 
  301 
  302 
  303 
  304 
  305 
  306 
  307 
  308 
  309 
  310 
  311 
  312 
  313 
  314 
  315 
  316 
  317 
  318 
  319 
  320 
  321 
  322 
  323 
  324 
  325 
  326 
  327 
  328 
  329 
  330 
  331 
  332 
  333 
  334 
  335 
  336 
  337 
  338 
  339 -- |Bates stochastic-volatility model: extends Heston with jumps in the underlying's return process.
  340 batesModel :: (BatesProcess) -> IO ((BatesModel))
  341 batesModel a1 =
  342   withBatesProcess a1 $ \a1' -> 
  343   preErrorCheck $ \a2' -> 
  344   batesModel'_ a1' a2' >>= \res ->
  345   peekBatesModel res >>= \res' ->
  346   errorCheck  a2'>>
  347   return (res')
  348 
  349 
  350 
  351 -- |Black-Karasinski short-rate model: d(ln r) = (theta(t) - a ln r) dt + sigma dW, with constant reversion @a@ and volatility @sigma@.
  352 blackKarasinski :: (GenYieldTermStructure y) -> (Double) -- ^y
  353  -> (Double) -- ^sigma
  354  -> IO ((ShortRateModel))
  355 blackKarasinski a1 a2 a3 =
  356   withYieldTermStructure a1 $ \a1' -> 
  357   let {a2' = realToFrac a2} in 
  358   let {a3' = realToFrac a3} in 
  359   preErrorCheck $ \a4' -> 
  360   blackKarasinski'_ a1' a2' a3' a4' >>= \res ->
  361   peekShortRateModel res >>= \res' ->
  362   errorCheck  a4'>>
  363   return (res')
  364 
  365 
  366 
  367 -- |Cox-Ingersoll-Ross short-rate model: dr = k(theta - r) dt + sigma sqrt(r) dW.
  368 coxIngersollRoss :: (Double) -- ^r0
  369  -> (Double) -- ^theta
  370  -> (Double) -- ^k
  371  -> (Double) -- ^sigma
  372  -> (Bool) -- ^withFellerConstraint
  373  -> IO ((OneFactorAffineModel))
  374 coxIngersollRoss a1 a2 a3 a4 a5 =
  375   let {a1' = realToFrac a1} in 
  376   let {a2' = realToFrac a2} in 
  377   let {a3' = realToFrac a3} in 
  378   let {a4' = realToFrac a4} in 
  379   let {a5' = C2HSImp.fromBool a5} in 
  380   preErrorCheck $ \a6' -> 
  381   coxIngersollRoss'_ a1' a2' a3' a4' a5' a6' >>= \res ->
  382   peekOneFactorAffineModel res >>= \res' ->
  383   errorCheck  a6'>>
  384   return (res')
  385 
  386 
  387 
  388 -- |Extended CIR model: adds a deterministic term-structure-fitting shift to a standard Cox-Ingersoll-Ross process.
  389 extendedCoxIngersollRoss :: (GenYieldTermStructure y) -> (Double) -- ^theta
  390  -> (Double) -- ^k
  391  -> (Double) -- ^sigma
  392  -> (Double) -- ^x0
  393  -> (Bool) -- ^withFellerConstraint
  394  -> IO ((OneFactorAffineModel))
  395 extendedCoxIngersollRoss a1 a2 a3 a4 a5 a6 =
  396   withYieldTermStructure a1 $ \a1' -> 
  397   let {a2' = realToFrac a2} in 
  398   let {a3' = realToFrac a3} in 
  399   let {a4' = realToFrac a4} in 
  400   let {a5' = realToFrac a5} in 
  401   let {a6' = C2HSImp.fromBool a6} in 
  402   preErrorCheck $ \a7' -> 
  403   extendedCoxIngersollRoss'_ a1' a2' a3' a4' a5' a6' a7' >>= \res ->
  404   peekOneFactorAffineModel res >>= \res' ->
  405   errorCheck  a7'>>
  406   return (res')
  407 
  408 
  409 
  410 -- |Two-additive-factor Gaussian (G2) short-rate model: the sum of two correlated Ornstein-Uhlenbeck factors.
  411 g2 :: (GenYieldTermStructure y) -> (Double) -- ^y
  412  -> (Double) -- ^sigma
  413  -> (Double) -- ^b
  414  -> (Double) -- ^eta
  415  -> (Double) -- ^rho
  416  -> IO ((G2))
  417 g2 a1 a2 a3 a4 a5 a6 =
  418   withYieldTermStructure a1 $ \a1' -> 
  419   let {a2' = realToFrac a2} in 
  420   let {a3' = realToFrac a3} in 
  421   let {a4' = realToFrac a4} in 
  422   let {a5' = realToFrac a5} in 
  423   let {a6' = realToFrac a6} in 
  424   preErrorCheck $ \a7' -> 
  425   g2'_ a1' a2' a3' a4' a5' a6' a7' >>= \res ->
  426   peekG2 res >>= \res' ->
  427   errorCheck  a7'>>
  428   return (res')
  429 
  430 
  431 
  432 -- |The two-factor short-rate dynamics underlying a 'G2' model (@TwoFactorModel::dynamics()@).
  433 g2Dynamics :: (G2) -> IO ((ShortRateDynamics))
  434 g2Dynamics a1 =
  435   withG2 a1 $ \a1' -> 
  436   preErrorCheck $ \a2' -> 
  437   g2Dynamics'_ a1' a2' >>= \res ->
  438   peekStandalone res >>= \res' ->
  439   errorCheck  a2'>>
  440   return (res')
  441 
  442 
  443 
  444 -- |Short rate implied by a 'ShortRateDynamics''s two state variables x, y at time t: @fitting_(t) + x + y@. At @x = y = 0@ this collapses to the model's fitting parameter @phi(t)@.
  445 shortRate :: (ShortRateDynamics) -> (Double) -- ^t
  446  -> (Double) -- ^x
  447  -> (Double) -- ^y
  448  -> IO ((Double))
  449 shortRate a1 a2 a3 a4 =
  450   withStandalone a1 $ \a1' -> 
  451   let {a2' = realToFrac a2} in 
  452   let {a3' = realToFrac a3} in 
  453   let {a4' = realToFrac a4} in 
  454   preErrorCheck $ \a5' -> 
  455   shortRate'_ a1' a2' a3' a4' a5' >>= \res ->
  456   let {res' = realToFrac res} in
  457   errorCheck  a5'>>
  458   return (res')
  459 
  460 
  461 
  462 -- |Generalized Hull-White model: like 'hullWhite', but reversion and volatility are piecewise-linear functions of time given at @speedstructure@/@volstructure@ dates.
  463 generalizedHullWhite :: GenYieldTermStructure y -> NonEmpty (Day, Double) -- ^speedstructure
  464   -> NonEmpty (Day, Double) -- ^volstructure
  465   -> IO ShortRateModel
  466 generalizedHullWhite ts s v = qlGeneralizedHullWhite ts sd vd sq vq where {(sd, sq) = unzip (toList s); (vd, vq) = unzip (toList v)}
  467 qlGeneralizedHullWhite :: (GenYieldTermStructure y) -> ([Day]) -> ([Day]) -> ([Double]) -> ([Double]) -> IO ((ShortRateModel))
  468 qlGeneralizedHullWhite a1 a2 a3 a4 a5 =
  469   withYieldTermStructure a1 $ \a1' -> 
  470   withDayArray a2 $ \(a2'1, a2'2) -> 
  471   withDayArray a3 $ \(a3'1, a3'2) -> 
  472   withDoubleArray a4 $ \(a4'1, a4'2) -> 
  473   withDoubleArray a5 $ \(a5'1, a5'2) -> 
  474   preErrorCheck $ \a6' -> 
  475   qlGeneralizedHullWhite'_ a1' a2'1  a2'2 a3'1  a3'2 a4'1  a4'2 a5'1  a5'2 a6' >>= \res ->
  476   peekShortRateModel res >>= \res' ->
  477   errorCheck  a6'>>
  478   return (res')
  479 
  480 
  481 
  482 -- |GJR-GARCH stochastic-volatility model, extending GARCH(1,1) with an asymmetric response to negative return shocks.
  483 gjrGarchModel :: (GJRGARCHProcess) -> IO ((GJRGARCHModel))
  484 gjrGarchModel a1 =
  485   withGenStochasticProcess a1 $ \a1' -> 
  486   preErrorCheck $ \a2' -> 
  487   gjrGarchModel'_ a1' a2' >>= \res ->
  488   peekGJRGARCHModel res >>= \res' ->
  489   errorCheck  a2'>>
  490   return (res')
  491 
  492 
  493 
  494 -- |Heston stochastic-volatility model, calibrated from a 'HestonProcess'.
  495 hestonModel :: (GenHestonProcess hp) -> IO ((HestonModel))
  496 hestonModel a1 =
  497   withHestonProcess a1 $ \a1' -> 
  498   preErrorCheck $ \a2' -> 
  499   hestonModel'_ a1' a2' >>= \res ->
  500   peekHestonModel res >>= \res' ->
  501   errorCheck  a2'>>
  502   return (res')
  503 
  504 
  505 
  506 -- |Pseudo-random Mersenne-Twister Brownian increments for SLV Monte-Carlo calibration. Use a
  507 -- fixed nonzero @seed@ for reproducible calibration output; QuantLib treats zero as entropy.
  508 mtBrownianGeneratorFactory :: (Word) -- ^seed
  509  -> IO ((BrownianGeneratorFactory))
  510 mtBrownianGeneratorFactory a1 =
  511   let {a1' = fromIntegral a1} in 
  512   preErrorCheck $ \a2' -> 
  513   mtBrownianGeneratorFactory'_ a1' a2' >>= \res ->
  514   peekBrownianGeneratorFactory res >>= \res' ->
  515   errorCheck  a2'>>
  516   return (res')
  517 
  518 
  519 
  520 -- |Low-discrepancy Sobol Brownian increments for SLV Monte-Carlo calibration. Supply a fixed
  521 -- nonzero @seed@ to make the resulting leverage function reproducible.
  522 sobolBrownianGeneratorFactory :: (SobolBrownianOrdering) -- ^ordering
  523  -> (Word) -- ^seed
  524  -> (SobolDirectionIntegers) -- ^directionIntegers
  525  -> IO ((BrownianGeneratorFactory))
  526 sobolBrownianGeneratorFactory a1 a2 a3 =
  527   let {a1' = fromEnumC a1} in 
  528   let {a2' = fromIntegral a2} in 
  529   let {a3' = fromEnumC a3} in 
  530   preErrorCheck $ \a4' -> 
  531   sobolBrownianGeneratorFactory'_ a1' a2' a3' a4' >>= \res ->
  532   peekBrownianGeneratorFactory res >>= \res' ->
  533   errorCheck  a4'>>
  534   return (res')
  535 
  536 
  537 
  538 -- |Monte-Carlo calibration of a Heston stochastic-local-volatility leverage function. The
  539 -- trailing arguments mirror QuantLib's defaults explicitly; @mandatoryDates@ are inserted into
  540 -- the calibration time grid.
  541 hestonSlvMcModel :: (GenLocalVolTermStructure lv) -- ^localVol
  542  -> (GenHestonModel hm) -- ^hestonModel
  543  -> (BrownianGeneratorFactory) -- ^brownianGeneratorFactory
  544  -> (Day) -- ^endDate
  545  -> (Word) -- ^timeStepsPerYear
  546  -> (Word) -- ^nBins
  547  -> (Word) -- ^calibrationPaths
  548  -> ([Day]) -- ^mandatoryDates
  549  -> (Double) -- ^mixingFactor
  550  -> IO ((HestonSLVMCModel))
  551 hestonSlvMcModel a1 a2 a3 a4 a5 a6 a7 a8 a9 =
  552   withGenLocalVolTermStructure a1 $ \a1' -> 
  553   withHestonModel a2 $ \a2' -> 
  554   withBrownianGeneratorFactory a3 $ \a3' -> 
  555   withDay a4 $ \a4' -> 
  556   let {a5' = fromIntegral a5} in 
  557   let {a6' = fromIntegral a6} in 
  558   let {a7' = fromIntegral a7} in 
  559   withDayArray a8 $ \(a8'1, a8'2) -> 
  560   let {a9' = realToFrac a9} in 
  561   preErrorCheck $ \a10' -> 
  562   hestonSlvMcModel'_ a1' a2' a3' a4' a5' a6' a7' a8'1  a8'2 a9' a10' >>= \res ->
  563   peekHestonSLVMCModel res >>= \res' ->
  564   errorCheck  a10'>>
  565   return (res')
  566 
  567 
  568 
  569 -- |Forces MC calibration if necessary and returns its local-volatility leverage function.
  570 qlHestonSLVMCModelLeverageFunction :: (HestonSLVMCModel) -- ^model
  571  -> IO ((LocalVolTermStructure))
  572 qlHestonSLVMCModelLeverageFunction a1 =
  573   withHestonSLVMCModel a1 $ \a1' -> 
  574   preErrorCheck $ \a2' -> 
  575   qlHestonSLVMCModelLeverageFunction'_ a1' a2' >>= \res ->
  576   peekLocalVolTermStructure res >>= \res' ->
  577   errorCheck  a2'>>
  578   return (res')
  579 
  580 
  581 
  582 -- |Fokker--Planck finite-difference calibration of a Heston stochastic-local-volatility
  583 -- leverage function. @logging@ retains diagnostic density snapshots for
  584 -- 'hestonSlvFdmLogEntries'; @mandatoryDates@ are added to its adaptive time grid.
  585 hestonSlvFdmModel :: GenLocalVolTermStructure lv -> GenHestonModel hm -> Day
  586   -> HestonSLVFokkerPlanckFdmParams -> Bool -> [Day] -> Double -> IO HestonSLVFDMModel
  587 hestonSlvFdmModel localVol model endDate p logging mandatoryDates mixingFactor =
  588   hestonSlvFdmModelRaw localVol model endDate
  589     (hestonSlvXGrid p) (hestonSlvVGrid p) (hestonSlvTMaxStepsPerYear p) (hestonSlvTMinStepsPerYear p)
  590     (hestonSlvTStepNumberDecay p) (hestonSlvNRannacherTimeSteps p) (hestonSlvPredictionCorrectionSteps p)
  591     (hestonSlvX0Density p) (hestonSlvLocalVolEpsProb p) (hestonSlvMaxIntegrationIterations p)
  592     (hestonSlvVLowerEps p) (hestonSlvVUpperEps p) (hestonSlvVMin p) (hestonSlvV0Density p)
  593     (hestonSlvVLowerBoundDensity p) (hestonSlvVUpperBoundDensity p) (hestonSlvLeverageFctPropEps p)
  594     (hestonSlvGreensAlgorithm p) (hestonSlvVarianceTransformation p) (hestonSlvSchemeDesc p)
  595     logging mandatoryDates mixingFactor
  596 hestonSlvFdmModelRaw :: (GenLocalVolTermStructure lv) -- ^localVol
  597  -> (GenHestonModel hm) -- ^hestonModel
  598  -> (Day) -- ^endDate
  599  -> (Word) -- ^xGrid
  600  -> (Word) -- ^vGrid
  601  -> (Word) -- ^tMaxStepsPerYear
  602  -> (Word) -- ^tMinStepsPerYear
  603  -> (Double) -- ^tStepNumberDecay
  604  -> (Word) -- ^nRannacherTimeSteps
  605  -> (Word) -- ^predictionCorrectionSteps
  606  -> (Double) -- ^x0Density
  607  -> (Double) -- ^localVolEpsProb
  608  -> (Word) -- ^maxIntegrationIterations
  609  -> (Double) -- ^vLowerEps
  610  -> (Double) -- ^vUpperEps
  611  -> (Double) -- ^vMin
  612  -> (Double) -- ^v0Density
  613  -> (Double) -- ^vLowerBoundDensity
  614  -> (Double) -- ^vUpperBoundDensity
  615  -> (Double) -- ^leverageFctPropEps
  616  -> (HestonSLVGreensAlgorithm) -- ^greensAlgorithm
  617  -> (HestonSLVVarianceTransformation) -- ^trafoType
  618  -> (FdmScheme) -- ^schemeDesc
  619  -> (Bool) -- ^logging
  620  -> ([Day]) -- ^mandatoryDates
  621  -> (Double) -- ^mixingFactor
  622  -> IO ((HestonSLVFDMModel))
  623 hestonSlvFdmModelRaw 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 =
  624   withGenLocalVolTermStructure a1 $ \a1' -> 
  625   withHestonModel a2 $ \a2' -> 
  626   withDay a3 $ \a3' -> 
  627   let {a4' = fromIntegral a4} in 
  628   let {a5' = fromIntegral a5} in 
  629   let {a6' = fromIntegral a6} in 
  630   let {a7' = fromIntegral a7} in 
  631   let {a8' = realToFrac a8} in 
  632   let {a9' = fromIntegral a9} in 
  633   let {a10' = fromIntegral a10} in 
  634   let {a11' = realToFrac a11} in 
  635   let {a12' = realToFrac a12} in 
  636   let {a13' = fromIntegral a13} in 
  637   let {a14' = realToFrac a14} in 
  638   let {a15' = realToFrac a15} in 
  639   let {a16' = realToFrac a16} in 
  640   let {a17' = realToFrac a17} in 
  641   let {a18' = realToFrac a18} in 
  642   let {a19' = realToFrac a19} in 
  643   let {a20' = realToFrac a20} in 
  644   let {a21' = fromEnumC a21} in 
  645   let {a22' = fromEnumC a22} in 
  646   withFdmSchemeDesc a23 $ \a23' -> 
  647   let {a24' = C2HSImp.fromBool a24} in 
  648   withDayArray a25 $ \(a25'1, a25'2) -> 
  649   let {a26' = realToFrac a26} in 
  650   preErrorCheck $ \a27' -> 
  651   hestonSlvFdmModelRaw'_ 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'1  a25'2 a26' a27' >>= \res ->
  652   peekHestonSLVFDMModel res >>= \res' ->
  653   errorCheck  a27'>>
  654   return (res')
  655 
  656 
  657 
  658 -- |Forces FDM calibration if necessary and returns its local-volatility leverage function.
  659 qlHestonSLVFDMModelLeverageFunction :: (HestonSLVFDMModel) -- ^model
  660  -> IO ((LocalVolTermStructure))
  661 qlHestonSLVFDMModelLeverageFunction a1 =
  662   withHestonSLVFDMModel a1 $ \a1' -> 
  663   preErrorCheck $ \a2' -> 
  664   qlHestonSLVFDMModelLeverageFunction'_ a1' a2' >>= \res ->
  665   peekLocalVolTermStructure res >>= \res' ->
  666   errorCheck  a2'>>
  667   return (res')
  668 
  669 
  670 
  671 -- |Copies retained FDM density diagnostics. Returns @[]@ when the model was built with
  672 -- @logging = False@. Calling this makes one fresh QuantLib diagnostic calculation, then decodes
  673 -- its owned snapshot without retaining the model's mesh objects.
  674 hestonSlvFdmLogEntries :: HestonSLVFDMModel -> IO [HestonSLVFDMLogEntry]
  675 hestonSlvFdmLogEntries model = do
  676   snapshot <- hestonSlvFdmLogEntriesSnapshot model
  677   let n = hestonSlvFdmLogEntriesSize snapshot
  678   mapM (hestonSlvFdmLogEntry snapshot) (genericTake n [0 ..])
  679 
  680 hestonSlvFdmLogEntry :: HestonSLVFDMLogEntries -> Word -> IO HestonSLVFDMLogEntry
  681 hestonSlvFdmLogEntry snapshot i = do
  682   t <- hestonSlvFdmLogEntriesTime snapshot i
  683   x <- hestonSlvFdmLogEntriesSpotGrid snapshot i
  684   v <- hestonSlvFdmLogEntriesVarianceGrid snapshot i
  685   (r, c, d) <- hestonSlvFdmLogEntriesDensity snapshot i
  686   pure $ HestonSLVFDMLogEntry t x v (RealMatrix r c d)
  687 
  688 hestonSlvFdmLogEntriesSnapshot :: (HestonSLVFDMModel) -> IO ((HestonSLVFDMLogEntries))
  689 hestonSlvFdmLogEntriesSnapshot a1 =
  690   withHestonSLVFDMModel a1 $ \a1' -> 
  691   preErrorCheck $ \a2' -> 
  692   hestonSlvFdmLogEntriesSnapshot'_ a1' a2' >>= \res ->
  693   peekHestonSLVFDMLogEntries res >>= \res' ->
  694   errorCheck  a2'>>
  695   return (res')
  696 
  697 
  698 hestonSlvFdmLogEntriesSize :: (HestonSLVFDMLogEntries) -> (Word)
  699 hestonSlvFdmLogEntriesSize a1 =
  700   C2HSImp.unsafePerformIO $
  701   withHestonSLVFDMLogEntries a1 $ \a1' -> 
  702   hestonSlvFdmLogEntriesSize'_ a1' >>= \res ->
  703   let {res' = fromIntegral res} in
  704   return (res')
  705 
  706 
  707 hestonSlvFdmLogEntriesTime :: (HestonSLVFDMLogEntries) -> (Word) -> IO ((Double))
  708 hestonSlvFdmLogEntriesTime a1 a2 =
  709   withHestonSLVFDMLogEntries a1 $ \a1' -> 
  710   let {a2' = fromIntegral a2} in 
  711   preErrorCheck $ \a3' -> 
  712   hestonSlvFdmLogEntriesTime'_ a1' a2' a3' >>= \res ->
  713   let {res' = realToFrac res} in
  714   errorCheck  a3'>>
  715   return (res')
  716 
  717 
  718 hestonSlvFdmLogEntriesSpotGrid :: (HestonSLVFDMLogEntries) -> (Word) -> IO ((RealVector))
  719 hestonSlvFdmLogEntriesSpotGrid a1 a2 =
  720   withHestonSLVFDMLogEntries a1 $ \a1' -> 
  721   let {a2' = fromIntegral a2} in 
  722   preDoubleArray $ \(a3'1, a3'2) -> 
  723   preErrorCheck $ \a4' -> 
  724   hestonSlvFdmLogEntriesSpotGrid'_ a1' a2' a3'1  a3'2 a4' >>
  725   peekRealVector  a3'1  a3'2>>= \a3'' -> 
  726   errorCheck  a4'>>
  727   return (a3'')
  728 
  729 
  730 hestonSlvFdmLogEntriesVarianceGrid :: (HestonSLVFDMLogEntries) -> (Word) -> IO ((RealVector))
  731 hestonSlvFdmLogEntriesVarianceGrid a1 a2 =
  732   withHestonSLVFDMLogEntries a1 $ \a1' -> 
  733   let {a2' = fromIntegral a2} in 
  734   preDoubleArray $ \(a3'1, a3'2) -> 
  735   preErrorCheck $ \a4' -> 
  736   hestonSlvFdmLogEntriesVarianceGrid'_ a1' a2' a3'1  a3'2 a4' >>
  737   peekRealVector  a3'1  a3'2>>= \a3'' -> 
  738   errorCheck  a4'>>
  739   return (a3'')
  740 
  741 
  742 hestonSlvFdmLogEntriesDensity :: (HestonSLVFDMLogEntries) -> (Word) -> IO ((Word), (Word), (RealVector))
  743 hestonSlvFdmLogEntriesDensity a1 a2 =
  744   withHestonSLVFDMLogEntries a1 $ \a1' -> 
  745   let {a2' = fromIntegral a2} in 
  746   prePtr $ \a3' -> 
  747   prePtr $ \a4' -> 
  748   preDoubleArray $ \(a5'1, a5'2) -> 
  749   preErrorCheck $ \a6' -> 
  750   hestonSlvFdmLogEntriesDensity'_ a1' a2' a3' a4' a5'1  a5'2 a6' >>
  751   peekWord  a3'>>= \a3'' -> 
  752   peekWord  a4'>>= \a4'' -> 
  753   peekRealVector  a5'1  a5'2>>= \a5'' -> 
  754   errorCheck  a6'>>
  755   return (a3'', a4'', a5'')
  756 
  757 
  758 
  759 -- |Single-factor Hull-White (extended Vasicek) short-rate model: dr = (theta(t) - a r) dt + sigma dW, fitted to the given term structure.
  760 hullWhite :: (GenYieldTermStructure y) -> (Double) -- ^a (mean reversion)
  761  -> (Double) -- ^sigma
  762  -> IO ((HullWhite))
  763 hullWhite a1 a2 a3 =
  764   withYieldTermStructure a1 $ \a1' -> 
  765   let {a2' = realToFrac a2} in 
  766   let {a3' = realToFrac a3} in 
  767   preErrorCheck $ \a4' -> 
  768   hullWhite'_ a1' a2' a3' a4' >>= \res ->
  769   peekHullWhite res >>= \res' ->
  770   errorCheck  a4'>>
  771   return (res')
  772 
  773 
  774 
  775 -- |Futures convexity bias (difference between futures implied rate and forward rate), per G. Kirikos, D. Novak, \"Convexity Conundrums\", Risk Magazine, March 1997. @t@/@T@ are in yearfraction using the deposit day counter, @futurePrice@ is the futures' market price.
  776 -- Not 'pure': 'HullWhite.convexityBias' can throw ('QL_REQUIRE' on its inputs), and letting a C++
  777 -- exception unwind across the FFI boundary from an 'unsafePerformIO'-backed pure binding is undefined
  778 -- behavior, so this needs the same 'char **e'/'preErrorCheck' error channel as any other throwing call.
  779 convexityBias :: (Double) -- ^futurePrice
  780  -> (Double) -- ^t
  781  -> (Double) -- ^T
  782  -> (Double) -- ^sigma
  783  -> (Double) -- ^a
  784  -> IO ((Double))
  785 convexityBias a1 a2 a3 a4 a5 =
  786   let {a1' = realToFrac a1} in 
  787   let {a2' = realToFrac a2} in 
  788   let {a3' = realToFrac a3} in 
  789   let {a4' = realToFrac a4} in 
  790   let {a5' = realToFrac a5} in 
  791   preErrorCheck $ \a6' -> 
  792   convexityBias'_ a1' a2' a3' a4' a5' a6' >>= \res ->
  793   let {res' = realToFrac res} in
  794   errorCheck  a6'>>
  795   return (res')
  796 
  797 
  798 
  799 -- |Marks the reversion (@a@) fixed and volatility (@sigma@) free for 'calibrate''s @fixParameters@ argument. Mirrors @HullWhite::FixedReversion()@.
  800 fixedReversion :: [Bool]
  801 fixedReversion = [True, False]
  802 
  803 -- |One-factor GSR model (formulated in the forward measure), with an initial volatility and
  804 -- piecewise-constant changes at the given dates, plus a single constant reversion.
  805 gsr :: GenYieldTermStructure y -> GenQuote q1 -> [(Day, GenQuote q1)] -> GenQuote q2 -> Double -> IO Gsr
  806 gsr ts initialVol subsequentVols reversion horizon =
  807   qlGsr ts dates (initialVol : vols) [reversion] horizon
  808   where (dates, vols) = unzip subsequentVols
  809 
  810 -- |One-factor GSR model with a piecewise-constant reversion as well as volatility: the initial
  811 -- (volatility, reversion) pair holds until the first step date, and each step date starts a new
  812 -- pair. 'calibrateReversionsIterative' needs this form, one reversion per calibration helper.
  813 gsrWithReversions :: GenYieldTermStructure y -> (GenQuote q1, GenQuote q2) -> [(Day, (GenQuote q1, GenQuote q2))]
  814   -> Double -> IO Gsr
  815 gsrWithReversions ts (initialVol, initialReversion) steps horizon =
  816   qlGsr ts dates (initialVol : vols) (initialReversion : reversions') horizon
  817   where (dates, pairs) = unzip steps
  818         (vols, reversions') = unzip pairs
  819 
  820 qlGsr :: (GenYieldTermStructure y) -> ([Day]) -- ^volstepdates
  821  -> ([GenQuote q1]) -- ^volatilities
  822  -> ([GenQuote q2]) -- ^reversions: one, or one per volatility
  823  -> (Double) -- ^T
  824  -> IO ((Gsr))
  825 qlGsr a1 a2 a3 a4 a5 =
  826   withYieldTermStructure a1 $ \a1' -> 
  827   withDayArray a2 $ \(a2'1, a2'2) -> 
  828   withQuoteArray a3 $ \(a3'1, a3'2) -> 
  829   withQuoteArray a4 $ \(a4'1, a4'2) -> 
  830   let {a5' = realToFrac a5} in 
  831   preErrorCheck $ \a6' -> 
  832   qlGsr'_ a1' a2'1  a2'2 a3'1  a3'2 a4'1  a4'2 a5' a6' >>= \res ->
  833   peekGsr res >>= \res' ->
  834   errorCheck  a6'>>
  835   return (res')
  836 
  837 
  838 
  839 -- |Volatility step values, as calibrated so far.
  840 qlGsrVolatility :: (Gsr) -> IO (([Double]))
  841 qlGsrVolatility a1 =
  842   withGenCalibratedModel a1 $ \a1' -> 
  843   preDoubleArray $ \(a2'1, a2'2) -> 
  844   preErrorCheck $ \a3' -> 
  845   qlGsrVolatility'_ a1' a2'1  a2'2 a3' >>
  846   peekDoubleArray  a2'1  a2'2>>= \a2'' -> 
  847   errorCheck  a3'>>
  848   return (a2'')
  849 
  850 
  851 
  852 -- |Reversion values, as calibrated so far: one for a constant reversion, otherwise one per
  853 -- volatility step.
  854 reversions :: (Gsr) -> IO (([Double]))
  855 reversions a1 =
  856   withGenCalibratedModel a1 $ \a1' -> 
  857   preDoubleArray $ \(a2'1, a2'2) -> 
  858   preErrorCheck $ \a3' -> 
  859   reversions'_ a1' a2'1  a2'2 a3' >>
  860   peekDoubleArray  a2'1  a2'2>>= \a2'' -> 
  861   errorCheck  a3'>>
  862   return (a2'')
  863 
  864 
  865 
  866 -- |The calibration mask ('calibrate''s @fixParameters@) that fixes every model parameter except
  867 -- the volatility at step index @i@ (0-based) -- a ready-made @fixParameters@ argument for
  868 -- calibrating that one volatility in isolation.
  869 moveVolatility :: (Gsr) -> (Word) -- ^i
  870  -> IO (([Bool]))
  871 moveVolatility a1 a2 =
  872   withGenCalibratedModel a1 $ \a1' -> 
  873   let {a2' = fromIntegral a2} in 
  874   preIntArray $ \(a3'1, a3'2) -> 
  875   preErrorCheck $ \a4' -> 
  876   moveVolatility'_ a1' a2' a3'1  a3'2 a4' >>
  877   peekBoolArray  a3'1  a3'2>>= \a3'' -> 
  878   errorCheck  a4'>>
  879   return (a3'')
  880 
  881 
  882 
  883 -- |The calibration mask that fixes every model parameter except the reversion at index @i@
  884 -- (0-based) -- the reversion counterpart of 'moveVolatility'. Only index 0 exists unless the model
  885 -- was built by 'gsrWithReversions'.
  886 moveReversion :: (Gsr) -> (Word) -- ^i
  887  -> IO (([Bool]))
  888 moveReversion a1 a2 =
  889   withGenCalibratedModel a1 $ \a1' -> 
  890   let {a2' = fromIntegral a2} in 
  891   preIntArray $ \(a3'1, a3'2) -> 
  892   preErrorCheck $ \a4' -> 
  893   moveReversion'_ a1' a2' a3'1  a3'2 a4' >>
  894   peekBoolArray  a3'1  a3'2>>= \a3'' -> 
  895   errorCheck  a4'>>
  896   return (a3'')
  897 
  898 
  899 
  900 -- |Iteratively calibrates the volatility step values, one at a time, to the given helpers (assumed to have step dates matching the model's volatility step dates).
  901 calibrateVolatilitiesIterative :: (Gsr) -> ([GenBlackCalibrationHelper bch]) -> (OptimizationMethod) -> (EndCriteria) -> (Maybe Constraint) -> ([Double]) -> IO ()
  902 calibrateVolatilitiesIterative a1 a2 a3 a4 a5 a6 =
  903   withGenCalibratedModel a1 $ \a1' -> 
  904   withBlackCalibrationHelperArray a2 $ \(a2'1, a2'2) -> 
  905   withOptimizationMethod a3 $ \a3' -> 
  906   withEndCriteria a4 $ \a4' -> 
  907   withMaybeConstraint a5 $ \a5' -> 
  908   withDoubleArray a6 $ \(a6'1, a6'2) -> 
  909   preErrorCheck $ \a7' -> 
  910   calibrateVolatilitiesIterative'_ a1' a2'1  a2'2 a3' a4' a5' a6'1  a6'2 a7' >>
  911   errorCheck  a7'>>
  912   return ()
  913 
  914 
  915 
  916 -- |Iteratively calibrates the reversions, one at a time: reversion @i@ is fitted to helper @i@
  917 -- with every other parameter held. The model needs one reversion per helper at least, so build
  918 -- it with 'gsrWithReversions'. The end criteria reflect only the last calibration.
  919 --
  920 -- A swaption's price depends on the reversion over its swap's life, so helper @i@ should exercise
  921 -- inside reversion interval @i@ and span it. Helpers expiring at the volatility step dates leave
  922 -- the fit ill-conditioned, and alternating with 'calibrateVolatilitiesIterative' can diverge.
  923 calibrateReversionsIterative :: (Gsr) -> ([GenBlackCalibrationHelper bch]) -> (OptimizationMethod) -> (EndCriteria) -> (Maybe Constraint) -> ([Double]) -> IO ()
  924 calibrateReversionsIterative a1 a2 a3 a4 a5 a6 =
  925   withGenCalibratedModel a1 $ \a1' -> 
  926   withBlackCalibrationHelperArray a2 $ \(a2'1, a2'2) -> 
  927   withOptimizationMethod a3 $ \a3' -> 
  928   withEndCriteria a4 $ \a4' -> 
  929   withMaybeConstraint a5 $ \a5' -> 
  930   withDoubleArray a6 $ \(a6'1, a6'2) -> 
  931   preErrorCheck $ \a7' -> 
  932   calibrateReversionsIterative'_ a1' a2'1  a2'2 a3' a4' a5' a6'1  a6'2 a7' >>
  933   errorCheck  a7'>>
  934   return ()
  935 
  936 
  937 
  938 -- |Markov-functional interest-rate model, calibrated to a swaption volatility cube against @swapIndexBase@.
  939 markovFunctional :: GenYieldTermStructure y -> Double -- ^reversion
  940   -> Double -- ^initial volatility
  941   -> [(Day, Double)] -- ^subsequent volatility steps
  942   -> GenSwaptionVolatilityStructure sv
  943   -> NonEmpty (Day, (Word, TimeUnit)) -- ^swaption expiry/tenor calibration points
  944   -> GenSwapIndex sidx -- ^swapIndexBase
  945   -> Word -- ^yGridPoints
  946   -> IO MarkovFunctional
  947 markovFunctional ts reversion initialVol steps svol points = qlMarkovFunctional ts reversion dates (initialVol : vols) svol expiries tq tu
  948   where (dates, vols) = unzip steps
  949         (expiries, tenors) = unzip (toList points)
  950         (tq, tu) = unzip tenors
  951 qlMarkovFunctional :: (GenYieldTermStructure y) -> (Double) -> ([Day]) -> ([Double]) -> (GenSwaptionVolatilityStructure sv) -> ([Day]) -> ([Word]) -> ([TimeUnit]) -> (GenSwapIndex sidx) -> (Word) -> IO ((MarkovFunctional))
  952 qlMarkovFunctional a1 a2 a3 a4 a5 a6 a7 a8 a9 a10 =
  953   withYieldTermStructure a1 $ \a1' -> 
  954   let {a2' = realToFrac a2} in 
  955   withDayArray a3 $ \(a3'1, a3'2) -> 
  956   withDoubleArray a4 $ \(a4'1, a4'2) -> 
  957   withSwaptionVolatilityStructure a5 $ \a5' -> 
  958   withDayArray a6 $ \(a6'1, a6'2) -> 
  959   withIntArray a7 $ \(a7'1, a7'2) -> 
  960   withEnumArray a8 $ \(a8'1, a8'2) -> 
  961   withSwapIndex a9 $ \a9' -> 
  962   let {a10' = fromIntegral a10} in 
  963   preErrorCheck $ \a11' -> 
  964   qlMarkovFunctional'_ a1' a2' a3'1  a3'2 a4'1  a4'2 a5' a6'1  a6'2 a7'1  a7'2 a8'1  a8'2 a9' a10' a11' >>= \res ->
  965   peekMarkovFunctional res >>= \res' ->
  966   errorCheck  a11'>>
  967   return (res')
  968 
  969 
  970 
  971 -- |Markov-functional interest-rate model, calibrated to a caplet volatility structure against @iborIndex@.
  972 markovFunctionalCaplet :: GenYieldTermStructure y -> Double -> Double -> [(Day, Double)]
  973   -> GenOptionletVolatilityStructure ov -> NonEmpty Day -> GenIborIndex ibor -> Word -> IO MarkovFunctional
  974 markovFunctionalCaplet ts reversion initialVol steps capletVol expiries ibor gridPoints =
  975   qlMarkovFunctionalCaplet ts reversion dates (initialVol : vols) capletVol (toList expiries) ibor gridPoints
  976   where (dates, vols) = unzip steps
  977 qlMarkovFunctionalCaplet :: (GenYieldTermStructure y) -> (Double) -- ^reversion
  978  -> ([Day]) -- ^volstepdates
  979  -> ([Double]) -- ^volatilities
  980  -> (GenOptionletVolatilityStructure ov) -- ^capletVol
  981  -> ([Day]) -- ^capletExpiries
  982  -> (GenIborIndex ibor) -- ^iborIndex
  983  -> (Word) -- ^yGridPoints
  984  -> IO ((MarkovFunctional))
  985 qlMarkovFunctionalCaplet a1 a2 a3 a4 a5 a6 a7 a8 =
  986   withYieldTermStructure a1 $ \a1' -> 
  987   let {a2' = realToFrac a2} in 
  988   withDayArray a3 $ \(a3'1, a3'2) -> 
  989   withDoubleArray a4 $ \(a4'1, a4'2) -> 
  990   withOptionletVolatilityStructure a5 $ \a5' -> 
  991   withDayArray a6 $ \(a6'1, a6'2) -> 
  992   withIborIndex a7 $ \a7' -> 
  993   let {a8' = fromIntegral a8} in 
  994   preErrorCheck $ \a9' -> 
  995   qlMarkovFunctionalCaplet'_ a1' a2' a3'1  a3'2 a4'1  a4'2 a5' a6'1  a6'2 a7' a8' a9' >>= \res ->
  996   peekMarkovFunctional res >>= \res' ->
  997   errorCheck  a9'>>
  998   return (res')
  999 
 1000 
 1001 
 1002 -- |Volatility step values, as calibrated so far.
 1003 qlMarkovFunctionalVolatility :: (MarkovFunctional) -> IO (([Double]))
 1004 qlMarkovFunctionalVolatility a1 =
 1005   withGenCalibratedModel a1 $ \a1' -> 
 1006   preDoubleArray $ \(a2'1, a2'2) -> 
 1007   preErrorCheck $ \a3' -> 
 1008   qlMarkovFunctionalVolatility'_ a1' a2'1  a2'2 a3' >>
 1009   peekDoubleArray  a2'1  a2'2>>= \a2'' -> 
 1010   errorCheck  a3'>>
 1011   return (a2'')
 1012 
 1013 
 1014 
 1015 -- |Discount factor at time @t@ under the model's own fitted curve -- @AffineModel::discount@.
 1016 -- Not 'pure': depends on the model's 'YieldTermStructure' handle, which can be relinked after
 1017 -- construction (see 'discountBond' below for the same caveat).
 1018 discount :: (AffineModel) -> (Double) -- ^t
 1019  -> IO ((Double))
 1020 discount a1 a2 =
 1021   withStandalone a1 $ \a1' -> 
 1022   let {a2' = realToFrac a2} in 
 1023   preErrorCheck $ \a3' -> 
 1024   discount'_ a1' a2' a3' >>= \res ->
 1025   let {res' = realToFrac res} in
 1026   errorCheck  a3'>>
 1027   return (res')
 1028 
 1029 
 1030 
 1031 -- |Price of a discount bond paying 1 at @maturity@, given the model's state @factors@ at time
 1032 -- @now@ -- @AffineModel::discountBond(Time,Time,Array)@. @factors@ is model-specific: a
 1033 -- one-element list of the short rate for 'OneFactorAffineModel'\/'HullWhite', a two-element list
 1034 -- for G2, or ignored by 'LiborForwardModel'. Not 'pure' for the same relinkable-curve reason as
 1035 -- 'discount'.
 1036 discountBond :: (AffineModel) -> (Double) -- ^now
 1037  -> (Double) -- ^maturity
 1038  -> ([Double]) -- ^factors
 1039  -> IO ((Double))
 1040 discountBond a1 a2 a3 a4 =
 1041   withStandalone a1 $ \a1' -> 
 1042   let {a2' = realToFrac a2} in 
 1043   let {a3' = realToFrac a3} in 
 1044   withDoubleArray a4 $ \(a4'1, a4'2) -> 
 1045   preErrorCheck $ \a5' -> 
 1046   discountBond'_ a1' a2' a3' a4'1  a4'2 a5' >>= \res ->
 1047   let {res' = realToFrac res} in
 1048   errorCheck  a5'>>
 1049   return (res')
 1050 
 1051 
 1052 
 1053 discountBondOption_ :: (AffineModel) -> (OptionType) -- ^type
 1054  -> (Double) -- ^strike
 1055  -> (Double) -- ^maturity
 1056  -> (Bool) -- ^haveBondStart
 1057  -> (Double) -- ^bondStart
 1058  -> (Double) -- ^bondMaturity
 1059  -> IO ((Double))
 1060 discountBondOption_ a1 a2 a3 a4 a5 a6 a7 =
 1061   withStandalone a1 $ \a1' -> 
 1062   let {a2' = fromEnumC a2} in 
 1063   let {a3' = realToFrac a3} in 
 1064   let {a4' = realToFrac a4} in 
 1065   let {a5' = C2HSImp.fromBool a5} in 
 1066   let {a6' = realToFrac a6} in 
 1067   let {a7' = realToFrac a7} in 
 1068   preErrorCheck $ \a8' -> 
 1069   discountBondOption_'_ a1' a2' a3' a4' a5' a6' a7' a8' >>= \res ->
 1070   let {res' = realToFrac res} in
 1071   errorCheck  a8'>>
 1072   return (res')
 1073 
 1074 
 1075 
 1076 -- |Analytic price of a European option on a discount bond paying 1 at @bondMaturity@. 'Nothing'
 1077 -- starts the bond at option expiry; 'Just' supplies a distinct bond start. Only 'HullWhite'
 1078 -- distinguishes the two upstream overloads.
 1079 discountBondOption :: AffineModel -> OptionType -> Double -> Double -> Maybe Double -> Double -> IO Double
 1080 discountBondOption model typ strike maturity bondStart bondMaturity =
 1081   discountBondOption_ model typ strike maturity (maybe False (const True) bondStart) (fromMaybe 0 bondStart) bondMaturity
 1082 
 1083 -- |Numeraire value at @referenceDate@, conditional on the standardized state variable @y@
 1084 -- (0 = the model's expected path). @yts@ overrides the model's own term structure for
 1085 -- discounting when given, otherwise the model's own curve is used.
 1086 numeraire :: (Gaussian1dModel) -> (Day) -- ^referenceDate
 1087  -> (Double) -- ^y
 1088  -> (Maybe (GenYieldTermStructure y)) -- ^yts
 1089  -> IO ((Double))
 1090 numeraire a1 a2 a3 a4 =
 1091   withStandalone a1 $ \a1' -> 
 1092   withDay a2 $ \a2' -> 
 1093   let {a3' = realToFrac a3} in 
 1094   withMaybeYieldTermStructure a4 $ \a4' -> 
 1095   preErrorCheck $ \a5' -> 
 1096   numeraire'_ a1' a2' a3' a4' a5' >>= \res ->
 1097   let {res' = realToFrac res} in
 1098   errorCheck  a5'>>
 1099   return (res')
 1100 
 1101 
 1102 
 1103 -- |Price at @referenceDate@ (default: the evaluation date) of a zero-coupon bond paying 1 at
 1104 -- @maturity@, conditional on the standardized state variable @y@ (0 = the model's expected
 1105 -- path). @yts@ overrides the model's own term structure for discounting when given.
 1106 gaussian1dZerobond :: (Gaussian1dModel) -> (Day) -- ^maturity
 1107  -> (Maybe Day) -- ^referenceDate
 1108  -> (Double) -- ^y
 1109  -> (Maybe (GenYieldTermStructure y)) -- ^yts
 1110  -> IO ((Double))
 1111 gaussian1dZerobond a1 a2 a3 a4 a5 =
 1112   withStandalone a1 $ \a1' -> 
 1113   withDay a2 $ \a2' -> 
 1114   withMaybeDay a3 $ \a3' -> 
 1115   let {a4' = realToFrac a4} in 
 1116   withMaybeYieldTermStructure a5 $ \a5' -> 
 1117   preErrorCheck $ \a6' -> 
 1118   gaussian1dZerobond'_ a1' a2' a3' a4' a5' a6' >>= \res ->
 1119   let {res' = realToFrac res} in
 1120   errorCheck  a6'>>
 1121   return (res')
 1122 
 1123 
 1124 
 1125 -- |Price of a European option of @type@, expiring at @expiry@ with @strike@, on a zero-coupon
 1126 -- bond that itself pays 1 at @maturity@ and settles at @valueDate@, conditional on the
 1127 -- standardized state variable @y@ at @referenceDate@ (default: the evaluation date). @yts@
 1128 -- overrides the model's own discounting curve when given. The option payoff is evaluated on a
 1129 -- grid of @yGridPoints@ points spanning @yStdDevs@ standard deviations of @y@;
 1130 -- @extrapolatePayoff@\/@flatPayoffExtrapolation@ control payoff extrapolation beyond the grid.
 1131 gaussian1dZerobondOption :: (Gaussian1dModel) -> (OptionType) -- ^type
 1132  -> (Day) -- ^expiry
 1133  -> (Day) -- ^valueDate
 1134  -> (Day) -- ^maturity
 1135  -> (Double) -- ^strike
 1136  -> (Maybe Day) -- ^referenceDate
 1137  -> (Double) -- ^y
 1138  -> (Maybe (GenYieldTermStructure y)) -- ^yts
 1139  -> (Double) -- ^yStdDevs
 1140  -> (Word) -- ^yGridPoints
 1141  -> (Bool) -- ^extrapolatePayoff
 1142  -> (Bool) -- ^flatPayoffExtrapolation
 1143  -> IO ((Double))
 1144 gaussian1dZerobondOption a1 a2 a3 a4 a5 a6 a7 a8 a9 a10 a11 a12 a13 =
 1145   withStandalone a1 $ \a1' -> 
 1146   let {a2' = fromEnumC a2} in 
 1147   withDay a3 $ \a3' -> 
 1148   withDay a4 $ \a4' -> 
 1149   withDay a5 $ \a5' -> 
 1150   let {a6' = realToFrac a6} in 
 1151   withMaybeDay a7 $ \a7' -> 
 1152   let {a8' = realToFrac a8} in 
 1153   withMaybeYieldTermStructure a9 $ \a9' -> 
 1154   let {a10' = realToFrac a10} in 
 1155   let {a11' = fromIntegral a11} in 
 1156   let {a12' = C2HSImp.fromBool a12} in 
 1157   let {a13' = C2HSImp.fromBool a13} in 
 1158   preErrorCheck $ \a14' -> 
 1159   gaussian1dZerobondOption'_ a1' a2' a3' a4' a5' a6' a7' a8' a9' a10' a11' a12' a13' a14' >>= \res ->
 1160   let {res' = realToFrac res} in
 1161   errorCheck  a14'>>
 1162   return (res')
 1163 
 1164 
 1165 
 1166 -- |Forward rate for @iborIdx@ fixing on @fixing@, conditional on the standardized state
 1167 -- variable @y@ at @referenceDate@ (default: the evaluation date). @iborIdx@ defaults to the
 1168 -- model's own term structure's natural index when omitted.
 1169 gaussian1dForwardRate :: (Gaussian1dModel) -> (Day) -- ^fixing
 1170  -> (Maybe Day) -- ^referenceDate
 1171  -> (Double) -- ^y
 1172  -> (Maybe (GenIborIndex ibor)) -- ^iborIdx
 1173  -> IO ((Double))
 1174 gaussian1dForwardRate a1 a2 a3 a4 a5 =
 1175   withStandalone a1 $ \a1' -> 
 1176   withDay a2 $ \a2' -> 
 1177   withMaybeDay a3 $ \a3' -> 
 1178   let {a4' = realToFrac a4} in 
 1179   withMaybeIborIndex a5 $ \a5' -> 
 1180   preErrorCheck $ \a6' -> 
 1181   gaussian1dForwardRate'_ a1' a2' a3' a4' a5' a6' >>= \res ->
 1182   let {res' = realToFrac res} in
 1183   errorCheck  a6'>>
 1184   return (res')
 1185 
 1186 
 1187 
 1188 -- |Fair swap rate for a swap on @swapIdx@ fixing on @fixing@ with tenor @tenor@, conditional on
 1189 -- the standardized state variable @y@ at @referenceDate@ (default: the evaluation date).
 1190 gaussian1dSwapRate :: (Gaussian1dModel) -> (Day) -- ^fixing
 1191  -> ((Int,TimeUnit)) -- ^tenor
 1192  -> (Maybe Day) -- ^referenceDate
 1193  -> (Double) -- ^y
 1194  -> (Maybe (GenSwapIndex sidx)) -- ^swapIdx
 1195  -> IO ((Double))
 1196 gaussian1dSwapRate a1 a2 a3 a4 a5 a6 =
 1197   withStandalone a1 $ \a1' -> 
 1198   withDay a2 $ \a2' -> 
 1199   let {(a3'1, a3'2) = fromEnumQuantity a3} in 
 1200   withMaybeDay a4 $ \a4' -> 
 1201   let {a5' = realToFrac a5} in 
 1202   withMaybeSwapIndex a6 $ \a6' -> 
 1203   preErrorCheck $ \a7' -> 
 1204   gaussian1dSwapRate'_ a1' a2' a3'1  a3'2 a4' a5' a6' a7' >>= \res ->
 1205   let {res' = realToFrac res} in
 1206   errorCheck  a7'>>
 1207   return (res')
 1208 
 1209 
 1210 
 1211 -- |Annuity (present value of a 1bp fixed leg) of a swap on @swapIdx@ fixing on @fixing@ with
 1212 -- tenor @tenor@, conditional on the standardized state variable @y@ at @referenceDate@
 1213 -- (default: the evaluation date).
 1214 gaussian1dSwapAnnuity :: (Gaussian1dModel) -> (Day) -- ^fixing
 1215  -> ((Int,TimeUnit)) -- ^tenor
 1216  -> (Maybe Day) -- ^referenceDate
 1217  -> (Double) -- ^y
 1218  -> (Maybe (GenSwapIndex sidx)) -- ^swapIdx
 1219  -> IO ((Double))
 1220 gaussian1dSwapAnnuity a1 a2 a3 a4 a5 a6 =
 1221   withStandalone a1 $ \a1' -> 
 1222   withDay a2 $ \a2' -> 
 1223   let {(a3'1, a3'2) = fromEnumQuantity a3} in 
 1224   withMaybeDay a4 $ \a4' -> 
 1225   let {a5' = realToFrac a5} in 
 1226   withMaybeSwapIndex a6 $ \a6' -> 
 1227   preErrorCheck $ \a7' -> 
 1228   gaussian1dSwapAnnuity'_ a1' a2' a3'1  a3'2 a4' a5' a6' a7' >>= \res ->
 1229   let {res' = realToFrac res} in
 1230   errorCheck  a7'>>
 1231   return (res')
 1232 
 1233 
 1234 
 1235 -- |Grid of values for the standardized state variable at time @T@, conditional on the
 1236 -- variable being @y@ at time @t@, spanning @yStdDevs@ standard deviations with
 1237 -- @2*gridPoints+1@ points.
 1238 gaussian1dYGrid :: (Gaussian1dModel) -> (Double) -- ^yStdDevs
 1239  -> (Int) -- ^gridPoints
 1240  -> (Double) -- ^bigT
 1241  -> (Double) -- ^t
 1242  -> (Double) -- ^y
 1243  -> IO ((RealVector))
 1244 gaussian1dYGrid a1 a2 a3 a4 a5 a6 =
 1245   withStandalone a1 $ \a1' -> 
 1246   let {a2' = realToFrac a2} in 
 1247   let {a3' = fromIntegral a3} in 
 1248   let {a4' = realToFrac a4} in 
 1249   let {a5' = realToFrac a5} in 
 1250   let {a6' = realToFrac a6} in 
 1251   preDoubleArray $ \(a7'1, a7'2) -> 
 1252   preErrorCheck $ \a8' -> 
 1253   gaussian1dYGrid'_ a1' a2' a3' a4' a5' a6' a7'1  a7'2 a8' >>
 1254   peekRealVector  a7'1  a7'2>>= \a7'' -> 
 1255   errorCheck  a8'>>
 1256   return (a7'')
 1257 
 1258 
 1259 
 1260 -- |The model's own state process. Throws if the model was constructed without one set.
 1261 stateProcess :: (Gaussian1dModel) -> IO ((StochasticProcess1D))
 1262 stateProcess a1 =
 1263   withStandalone a1 $ \a1' -> 
 1264   preErrorCheck $ \a2' -> 
 1265   stateProcess'_ a1' a2' >>= \res ->
 1266   peekStochasticProcess1D res >>= \res' ->
 1267   errorCheck  a2'>>
 1268   return (res')
 1269 
 1270 
 1271 
 1272 -- |Models that expose a calibrated local-volatility leverage function.
 1273 class HasLeverageFunction a where
 1274   leverageFunction :: a -> IO LocalVolTermStructure
 1275 instance HasLeverageFunction HestonSLVMCModel where
 1276   leverageFunction = qlHestonSLVMCModelLeverageFunction
 1277 instance HasLeverageFunction HestonSLVFDMModel where
 1278   leverageFunction = qlHestonSLVFDMModelLeverageFunction
 1279 
 1280 -- |Models that expose their calibrated volatility step values.
 1281 class HasVolatilities a where
 1282   volatilities :: a -> IO [Double]
 1283 instance HasVolatilities Gsr where
 1284   volatilities = qlGsrVolatility
 1285 instance HasVolatilities MarkovFunctional where
 1286   volatilities = qlMarkovFunctionalVolatility
 1287 
 1288 -- |Variance Gamma model for the underlying's log-return process (Madan-Carr-Chang).
 1289 varianceGammaModel :: (VarianceGammaProcess) -> IO ((CalibratedModel))
 1290 varianceGammaModel a1 =
 1291   withGenStochasticProcess1D a1 $ \a1' -> 
 1292   preErrorCheck $ \a2' -> 
 1293   varianceGammaModel'_ a1' a2' >>= \res ->
 1294   peekCalibratedModel res >>= \res' ->
 1295   errorCheck  a2'>>
 1296   return (res')
 1297 
 1298 
 1299 
 1300 -- |Vasicek short-rate model: dr = a(b - r) dt + sigma dW, with an optional risk premium @lambda@.
 1301 vasicek :: (Double) -- ^r0
 1302  -> (Double) -- ^a
 1303  -> (Double) -- ^b
 1304  -> (Double) -- ^sigma
 1305  -> (Double) -- ^lambda
 1306  -> IO ((OneFactorAffineModel))
 1307 vasicek a1 a2 a3 a4 a5 =
 1308   let {a1' = realToFrac a1} in 
 1309   let {a2' = realToFrac a2} in 
 1310   let {a3' = realToFrac a3} in 
 1311   let {a4' = realToFrac a4} in 
 1312   let {a5' = realToFrac a5} in 
 1313   preErrorCheck $ \a6' -> 
 1314   vasicek'_ a1' a2' a3' a4' a5' a6' >>= \res ->
 1315   peekOneFactorAffineModel res >>= \res' ->
 1316   errorCheck  a6'>>
 1317   return (res')
 1318 
 1319 
 1320 
 1321 -- |Libor market (BGM) forward-rate model, built from a 'LiborForwardModelProcess' plus volatility and correlation models.
 1322 liborForwardModel :: (LiborForwardModelProcess) -> (LmVolatilityModel) -> (LmCorrelationModel) -> IO ((LiborForwardModel))
 1323 liborForwardModel a1 a2 a3 =
 1324   withGenStochasticProcess a1 $ \a1' -> 
 1325   withLmVolatilityModel a2 $ \a2' -> 
 1326   withLmCorrelationModel a3 $ \a3' -> 
 1327   preErrorCheck $ \a4' -> 
 1328   liborForwardModel'_ a1' a2' a3' a4' >>= \res ->
 1329   peekLiborForwardModel res >>= \res' ->
 1330   errorCheck  a4'>>
 1331   return (res')
 1332 
 1333 
 1334 
 1335 -- |Initial value of the discrete forward rate indexed by /alpha/, as seen from time index /beta/
 1336 -- (both indices into the process's tenor structure): the model's calibration input @S_0(alpha,beta)@.
 1337 liborForwardModelS0 :: (LiborForwardModel) -> (Word) -- ^alpha
 1338  -> (Word) -- ^beta
 1339  -> IO ((Double))
 1340 liborForwardModelS0 a1 a2 a3 =
 1341   withGenCalibratedModel a1 $ \a1' -> 
 1342   let {a2' = fromIntegral a2} in 
 1343   let {a3' = fromIntegral a3} in 
 1344   preErrorCheck $ \a4' -> 
 1345   liborForwardModelS0'_ a1' a2' a3' a4' >>= \res ->
 1346   let {res' = realToFrac res} in
 1347   errorCheck  a4'>>
 1348   return (res')
 1349 
 1350 
 1351 
 1352 -- |Hull-White caplet-volatility parameterization for a Libor forward model. The correlation
 1353 -- matrix and factor count are explicit, mirroring QuantLib's defaulted constructor arguments;
 1354 -- pass an empty matrix and @1@ for its standard one-factor default.
 1355 lfmHullWhiteParameterization :: LiborForwardModelProcess -> GenOptionletVolatilityStructure ov
 1356   -> Matrix Double -- ^correlation
 1357   -> Word -- ^factors
 1358   -> IO LfmHullWhiteParameterization
 1359 lfmHullWhiteParameterization process capletVol (Matrix rows cols values) factors = qlLfmHullWhiteParameterization process capletVol rows cols values factors
 1360 qlLfmHullWhiteParameterization :: (LiborForwardModelProcess) -- ^process
 1361  -> (GenOptionletVolatilityStructure ov) -- ^capletVol
 1362  -> (Word) -- ^correlationRows
 1363  -> (Word) -- ^correlationColumns
 1364  -> ([Double]) -- ^correlation
 1365  -> (Word) -- ^factors
 1366  -> IO ((LfmHullWhiteParameterization))
 1367 qlLfmHullWhiteParameterization a1 a2 a3 a4 a5 a6 =
 1368   withGenStochasticProcess a1 $ \a1' -> 
 1369   withOptionletVolatilityStructure a2 $ \a2' -> 
 1370   let {a3' = fromIntegral a3} in 
 1371   let {a4' = fromIntegral a4} in 
 1372   withDoubleArrayRaw a5 $ \a5' -> 
 1373   let {a6' = fromIntegral a6} in 
 1374   preErrorCheck $ \a7' -> 
 1375   qlLfmHullWhiteParameterization'_ a1' a2' a3' a4' a5' a6' a7' >>= \res ->
 1376   peekLfmHullWhiteParameterization res >>= \res' ->
 1377   errorCheck  a7'>>
 1378   return (res')
 1379 
 1380 
 1381 
 1382 -- |installs the covariance parameterization a 'LiborForwardModelProcess' evolves under.
 1383 --
 1384 -- Mandatory before the process is used for anything dynamic: a freshly constructed
 1385 -- 'QuantLib.Process.liborForwardModelProcess' holds no parameterization, and
 1386 -- 'QuantLib.Process.drift', 'QuantLib.Process.diffusion', 'QuantLib.Process.evolve',
 1387 -- 'QuantLib.Process.factors' and 'QuantLib.Method.pathGenerator' all dereference it.
 1388 -- 'QuantLib.Process.discountBond', the fixing/accrual times and
 1389 -- 'QuantLib.Process.cashFlows' do not, and work without it.
 1390 setCovarParam :: (LiborForwardModelProcess) -- ^process
 1391  -> (LfmHullWhiteParameterization) -- ^param
 1392  -> IO ()
 1393 setCovarParam a1 a2 =
 1394   withGenStochasticProcess a1 $ \a1' -> 
 1395   withStandalone a2 $ \a2' -> 
 1396   preErrorCheck $ \a3' -> 
 1397   setCovarParam'_ a1' a2' a3' >>
 1398   errorCheck  a3'>>
 1399   return ()
 1400 
 1401 
 1402 
 1403 -- |Instantaneous covariance matrix at @t@ for the supplied forward-rate state @x@.
 1404 lfmHullWhiteCovariance :: LfmHullWhiteParameterization -> Double -> [Double] -> IO (Matrix Double)
 1405 lfmHullWhiteCovariance p t x = toMatrixDouble <$> qlLfmHullWhiteCovariance p t x
 1406   where toMatrixDouble (r, c, d) = Matrix r c d
 1407 qlLfmHullWhiteCovariance :: (LfmHullWhiteParameterization) -- ^parameterization
 1408  -> (Double) -- ^t
 1409  -> ([Double]) -- ^x
 1410  -> IO ((Word), (Word), ([Double]))
 1411 qlLfmHullWhiteCovariance a1 a2 a3 =
 1412   withStandalone a1 $ \a1' -> 
 1413   let {a2' = realToFrac a2} in 
 1414   withDoubleArray a3 $ \(a3'1, a3'2) -> 
 1415   prePtr $ \a4' -> 
 1416   prePtr $ \a5' -> 
 1417   preDoubleArray $ \(a6'1, a6'2) -> 
 1418   preErrorCheck $ \a7' -> 
 1419   qlLfmHullWhiteCovariance'_ a1' a2' a3'1  a3'2 a4' a5' a6'1  a6'2 a7' >>
 1420   peekWord  a4'>>= \a4'' -> 
 1421   peekWord  a5'>>= \a5'' -> 
 1422   peekDoubleArray  a6'1  a6'2>>= \a6'' -> 
 1423   errorCheck  a7'>>
 1424   return (a4'', a5'', a6'')
 1425 
 1426 
 1427 
 1428 -- |Calibrate to a set of market instruments (caps/swaptions)
 1429 -- An additional constraint can be passed which must be satisfied in addition to the constraints of the model.
 1430 calibrate :: GenCalibratedModel m -> NonEmpty (GenCalibrationHelper ch, Double) -- ^(instrument, weight)
 1431   -> OptimizationMethod -> EndCriteria -> Maybe Constraint
 1432   -> [Bool] -- ^fixParameters, e.g. 'fixedReversion'; @[]@ leaves nothing fixed
 1433   -> IO ()
 1434 calibrate m h o e c fp = qlCalibratedModelCalibrate m hh hw o e c fp where (hh, hw) = unzip (toList h)
 1435 qlCalibratedModelCalibrate :: (GenCalibratedModel m) -> ([GenCalibrationHelper ch]) -> ([Double]) -> (OptimizationMethod) -> (EndCriteria) -> (Maybe Constraint) -> ([Bool]) -> IO ()
 1436 qlCalibratedModelCalibrate a1 a2 a3 a4 a5 a6 a7 =
 1437   withCalibratedModel a1 $ \a1' -> 
 1438   withCalibrationHelperArray a2 $ \(a2'1, a2'2) -> 
 1439   withDoubleArray a3 $ \(a3'1, a3'2) -> 
 1440   withOptimizationMethod a4 $ \a4' -> 
 1441   withEndCriteria a5 $ \a5' -> 
 1442   withMaybeConstraint a6 $ \a6' -> 
 1443   withBoolArray a7 $ \(a7'1, a7'2) -> 
 1444   preErrorCheck $ \a8' -> 
 1445   qlCalibratedModelCalibrate'_ a1' a2'1  a2'2 a3'1  a3'2 a4' a5' a6' a7'1  a7'2 a8' >>
 1446   errorCheck  a8'>>
 1447   return ()
 1448 
 1449 
 1450 
 1451 -- |Objective function value at @params@ for the given calibration instruments.
 1452 value :: (GenCalibratedModel m) -> ([Double]) -> ([GenCalibrationHelper ch]) -> IO ((Double))
 1453 value a1 a2 a3 =
 1454   withCalibratedModel a1 $ \a1' -> 
 1455   withDoubleArray a2 $ \(a2'1, a2'2) -> 
 1456   withCalibrationHelperArray a3 $ \(a3'1, a3'2) -> 
 1457   preErrorCheck $ \a4' -> 
 1458   value'_ a1' a2'1  a2'2 a3'1  a3'2 a4' >>= \res ->
 1459   let {res' = realToFrac res} in
 1460   errorCheck  a4'>>
 1461   return (res')
 1462 
 1463 
 1464 
 1465 -- |Calibration helper for an at-the-money interest-rate cap.
 1466 capHelper :: ((Word,TimeUnit)) -- ^length
 1467  -> (GenQuote q) -- ^volatility
 1468  -> (GenIborIndex ibor) -> (Frequency) -- ^fixedLegFrequency
 1469  -> (DayCounter) -> (Bool) -- ^includeFirstSwaplet
 1470  -> (GenYieldTermStructure y) -> (CalibrationErrorType) -> (VolatilityType) -- ^type
 1471  -> (Double) -- ^shift
 1472  -> IO ((BlackCalibrationHelper))
 1473 capHelper a1 a2 a3 a4 a5 a6 a7 a8 a9 a10 =
 1474   let {(a1'1, a1'2) = fromEnumQuantity a1} in 
 1475   withQuote a2 $ \a2' -> 
 1476   withIborIndex a3 $ \a3' -> 
 1477   let {a4' = (fromIntegral . fromEnum) a4} in 
 1478   withDayCounter a5 $ \a5' -> 
 1479   let {a6' = C2HSImp.fromBool a6} in 
 1480   withYieldTermStructure a7 $ \a7' -> 
 1481   let {a8' = (fromIntegral . fromEnum) a8} in 
 1482   let {a9' = (fromIntegral . fromEnum) a9} in 
 1483   let {a10' = realToFrac a10} in 
 1484   preErrorCheck $ \a11' -> 
 1485   capHelper'_ a1'1  a1'2 a2' a3' a4' a5' a6' a7' a8' a9' a10' a11' >>= \res ->
 1486   peekBlackCalibrationHelper res >>= \res' ->
 1487   errorCheck  a11'>>
 1488   return (res')
 1489 
 1490 
 1491 
 1492 -- |Calibration helper for the Heston model, from a European option's market volatility.
 1493 hestonModelHelper :: ((Word,TimeUnit)) -- ^maturity
 1494  -> (Calendar) -> (GenQuote q1) -- ^s0
 1495  -> (Double) -- ^strikePrice
 1496  -> (GenQuote q2) -- ^volatility
 1497  -> (GenYieldTermStructure y1) -- ^riskFreeRate
 1498  -> (GenYieldTermStructure y2) -- ^dividendYield
 1499  -> (CalibrationErrorType) -> IO ((BlackCalibrationHelper))
 1500 hestonModelHelper a1 a2 a3 a4 a5 a6 a7 a8 =
 1501   let {(a1'1, a1'2) = fromEnumQuantity a1} in 
 1502   withCalendar a2 $ \a2' -> 
 1503   withQuote a3 $ \a3' -> 
 1504   let {a4' = realToFrac a4} in 
 1505   withQuote a5 $ \a5' -> 
 1506   withYieldTermStructure a6 $ \a6' -> 
 1507   withYieldTermStructure a7 $ \a7' -> 
 1508   let {a8' = (fromIntegral . fromEnum) a8} in 
 1509   preErrorCheck $ \a9' -> 
 1510   hestonModelHelper'_ a1'1  a1'2 a2' a3' a4' a5' a6' a7' a8' a9' >>= \res ->
 1511   peekBlackCalibrationHelper res >>= \res' ->
 1512   errorCheck  a9'>>
 1513   return (res')
 1514 
 1515 
 1516 
 1517 -- |A swaption helper's exercise and underlying-swap span.
 1518 data SwaptionSpan
 1519   = SpanTenors !(Word, TimeUnit) !(Word, TimeUnit) -- ^maturity, length
 1520   | SpanFromDate !Day !(Word, TimeUnit) -- ^exerciseDate, length
 1521   | SpanDates !Day !Day -- ^exerciseDate, endDate
 1522   deriving (Eq, Show)
 1523 
 1524 -- |Calibration helper for a swaption, over the given exercise/underlying span.
 1525 swaptionHelper :: SwaptionSpan -> GenQuote q -> GenIborIndex ibor -> (Word, TimeUnit)
 1526   -> DayCounter -> DayCounter -> GenYieldTermStructure y -> CalibrationErrorType
 1527   -> Maybe Double -> Double -> VolatilityType -> Double -> Maybe Word -> RateAveragingType
 1528   -> IO SwaptionHelper
 1529 swaptionHelper span' = case span' of
 1530   SpanTenors m l -> swaptionHelperTenorsRaw m l
 1531   SpanFromDate d l -> swaptionHelperFromDateRaw d l
 1532   SpanDates d e -> swaptionHelperFromDatesRaw d e
 1533 
 1534 swaptionHelperTenorsRaw :: ((Word,TimeUnit)) -- ^maturity
 1535  -> ((Word,TimeUnit)) -- ^length
 1536  -> (GenQuote q) -- ^maturity
 1537  -> (GenIborIndex ibor) -> ((Word,TimeUnit)) -- ^fixedLegTenor
 1538  -> (DayCounter) -- ^fixedLegDayCounter
 1539  -> (DayCounter) -- ^floatingLegDayCounter
 1540  -> (GenYieldTermStructure y) -> (CalibrationErrorType) -> (Maybe Double) -- ^strike
 1541  -> (Double) -- ^nominal
 1542  -> (VolatilityType) -- ^type
 1543  -> (Double) -- ^shift
 1544  -> (Maybe Word) -- ^settlementDays
 1545  -> (RateAveragingType) -- ^averagingMethod
 1546  -> IO ((SwaptionHelper))
 1547 swaptionHelperTenorsRaw a1 a2 a3 a4 a5 a6 a7 a8 a9 a10 a11 a12 a13 a14 a15 =
 1548   let {(a1'1, a1'2) = fromEnumQuantity a1} in 
 1549   let {(a2'1, a2'2) = fromEnumQuantity a2} in 
 1550   withQuote a3 $ \a3' -> 
 1551   withIborIndex a4 $ \a4' -> 
 1552   let {(a5'1, a5'2) = fromEnumQuantity a5} in 
 1553   withDayCounter a6 $ \a6' -> 
 1554   withDayCounter a7 $ \a7' -> 
 1555   withYieldTermStructure a8 $ \a8' -> 
 1556   let {a9' = (fromIntegral . fromEnum) a9} in 
 1557   let {a10' = fromMaybeDouble a10} in 
 1558   let {a11' = realToFrac a11} in 
 1559   let {a12' = (fromIntegral . fromEnum) a12} in 
 1560   let {a13' = realToFrac a13} in 
 1561   let {a14' = fromMaybeInt a14} in 
 1562   let {a15' = (fromIntegral . fromEnum) a15} in 
 1563   preErrorCheck $ \a16' -> 
 1564   swaptionHelperTenorsRaw'_ a1'1  a1'2 a2'1  a2'2 a3' a4' a5'1  a5'2 a6' a7' a8' a9' a10' a11' a12' a13' a14' a15' a16' >>= \res ->
 1565   peekSwaptionHelper res >>= \res' ->
 1566   errorCheck  a16'>>
 1567   return (res')
 1568 
 1569 
 1570 
 1571 -- |Like 'swaptionHelper', but the option's exercise is given as an explicit date rather than a maturity 'Period'.
 1572 swaptionHelperFromDateRaw :: (Day) -- ^exerciseDate
 1573  -> ((Word,TimeUnit)) -- ^length
 1574  -> (GenQuote q) -- ^maturity
 1575  -> (GenIborIndex ibor) -> ((Word,TimeUnit)) -- ^fixedLegTenor
 1576  -> (DayCounter) -- ^fixedLegDayCounter
 1577  -> (DayCounter) -- ^floatingLegDayCounter
 1578  -> (GenYieldTermStructure y) -> (CalibrationErrorType) -> (Maybe Double) -- ^strike
 1579  -> (Double) -- ^nominal
 1580  -> (VolatilityType) -- ^type
 1581  -> (Double) -- ^shift
 1582  -> (Maybe Word) -- ^settlementDays
 1583  -> (RateAveragingType) -- ^averagingMethod
 1584  -> IO ((SwaptionHelper))
 1585 swaptionHelperFromDateRaw a1 a2 a3 a4 a5 a6 a7 a8 a9 a10 a11 a12 a13 a14 a15 =
 1586   withDay a1 $ \a1' -> 
 1587   let {(a2'1, a2'2) = fromEnumQuantity a2} in 
 1588   withQuote a3 $ \a3' -> 
 1589   withIborIndex a4 $ \a4' -> 
 1590   let {(a5'1, a5'2) = fromEnumQuantity a5} in 
 1591   withDayCounter a6 $ \a6' -> 
 1592   withDayCounter a7 $ \a7' -> 
 1593   withYieldTermStructure a8 $ \a8' -> 
 1594   let {a9' = (fromIntegral . fromEnum) a9} in 
 1595   let {a10' = fromMaybeDouble a10} in 
 1596   let {a11' = realToFrac a11} in 
 1597   let {a12' = (fromIntegral . fromEnum) a12} in 
 1598   let {a13' = realToFrac a13} in 
 1599   let {a14' = fromMaybeInt a14} in 
 1600   let {a15' = (fromIntegral . fromEnum) a15} in 
 1601   preErrorCheck $ \a16' -> 
 1602   swaptionHelperFromDateRaw'_ a1' a2'1  a2'2 a3' a4' a5'1  a5'2 a6' a7' a8' a9' a10' a11' a12' a13' a14' a15' a16' >>= \res ->
 1603   peekSwaptionHelper res >>= \res' ->
 1604   errorCheck  a16'>>
 1605   return (res')
 1606 
 1607 
 1608 
 1609 -- |Like 'swaptionHelper', but both the option's exercise and the underlying swap's end are given as explicit dates.
 1610 swaptionHelperFromDatesRaw :: (Day) -- ^exerciseDate
 1611  -> (Day) -- ^endDate
 1612  -> (GenQuote q) -- ^maturity
 1613  -> (GenIborIndex ibor) -> ((Word,TimeUnit)) -- ^fixedLegTenor
 1614  -> (DayCounter) -- ^fixedLegDayCounter
 1615  -> (DayCounter) -- ^floatingLegDayCounter
 1616  -> (GenYieldTermStructure y) -> (CalibrationErrorType) -> (Maybe Double) -- ^strike
 1617  -> (Double) -- ^nominal
 1618  -> (VolatilityType) -- ^type
 1619  -> (Double) -- ^shift
 1620  -> (Maybe Word) -- ^settlementDays
 1621  -> (RateAveragingType) -- ^averagingMethod
 1622  -> IO ((SwaptionHelper))
 1623 swaptionHelperFromDatesRaw a1 a2 a3 a4 a5 a6 a7 a8 a9 a10 a11 a12 a13 a14 a15 =
 1624   withDay a1 $ \a1' -> 
 1625   withDay a2 $ \a2' -> 
 1626   withQuote a3 $ \a3' -> 
 1627   withIborIndex a4 $ \a4' -> 
 1628   let {(a5'1, a5'2) = fromEnumQuantity a5} in 
 1629   withDayCounter a6 $ \a6' -> 
 1630   withDayCounter a7 $ \a7' -> 
 1631   withYieldTermStructure a8 $ \a8' -> 
 1632   let {a9' = (fromIntegral . fromEnum) a9} in 
 1633   let {a10' = fromMaybeDouble a10} in 
 1634   let {a11' = realToFrac a11} in 
 1635   let {a12' = (fromIntegral . fromEnum) a12} in 
 1636   let {a13' = realToFrac a13} in 
 1637   let {a14' = fromMaybeInt a14} in 
 1638   let {a15' = (fromIntegral . fromEnum) a15} in 
 1639   preErrorCheck $ \a16' -> 
 1640   swaptionHelperFromDatesRaw'_ a1' a2' a3' a4' a5'1  a5'2 a6' a7' a8' a9' a10' a11' a12' a13' a14' a15' a16' >>= \res ->
 1641   peekSwaptionHelper res >>= \res' ->
 1642   errorCheck  a16'>>
 1643   return (res')
 1644 
 1645 
 1646 
 1647 -- |The 'QuantLib.Instrument.Swap.Swaption' this helper prices internally to compute 'modelValue'.
 1648 helperSwaption :: (SwaptionHelper) -> IO ((Swaption))
 1649 helperSwaption a1 =
 1650   withSwaptionHelper a1 $ \a1' -> 
 1651   preErrorCheck $ \a2' -> 
 1652   helperSwaption'_ a1' a2' >>= \res ->
 1653   peekSwaption res >>= \res' ->
 1654   errorCheck  a2'>>
 1655   return (res')
 1656 
 1657 
 1658 
 1659 -- |Times relevant to pricing this calibration helper's instrument, to be added to the model's evolution time grid.
 1660 times :: (GenBlackCalibrationHelper bch) -> IO (([Double]))
 1661 times a1 =
 1662   withBlackCalibrationHelper a1 $ \a1' -> 
 1663   preDoubleArray $ \(a2'1, a2'2) -> 
 1664   preErrorCheck $ \a3' -> 
 1665   times'_ a1' a2'1  a2'2 a3' >>
 1666   peekDoubleArray  a2'1  a2'2>>= \a2'' -> 
 1667   errorCheck  a3'>>
 1668   return (a2'')
 1669 
 1670 
 1671 
 1672 -- |Returns array of arguments on which calibration is done.
 1673 params :: (GenCalibratedModel m) -> IO (([Double]))
 1674 params a1 =
 1675   withCalibratedModel a1 $ \a1' -> 
 1676   preDoubleArray $ \(a2'1, a2'2) -> 
 1677   preErrorCheck $ \a3' -> 
 1678   params'_ a1' a2'1  a2'2 a3' >>
 1679   peekDoubleArray  a2'1  a2'2>>= \a2'' -> 
 1680   errorCheck  a3'>>
 1681   return (a2'')
 1682 
 1683 
 1684 
 1685 -- |Replace the arguments on which calibration is done, in the order 'params' returns them, and
 1686 -- notify the model's observers, so engines on it reprice. An array whose length differs from
 1687 -- 'params'' throws and leaves the model unchanged; the model's constraint is not checked. A later
 1688 -- 'calibrate' starts from these values.
 1689 setParams :: (GenCalibratedModel m) -> ([Double]) -- ^params
 1690  -> IO ()
 1691 setParams a1 a2 =
 1692   withCalibratedModel a1 $ \a1' -> 
 1693   withDoubleArray a2 $ \(a2'1, a2'2) -> 
 1694   preErrorCheck $ \a3' -> 
 1695   setParams'_ a1' a2'1  a2'2 a3' >>
 1696   errorCheck  a3'>>
 1697   return ()
 1698 
 1699 
 1700 
 1701 -- |Black price given a volatility.
 1702 blackPrice :: (GenBlackCalibrationHelper bch) -> (Double) -- ^volatility
 1703  -> IO ((Double))
 1704 blackPrice a1 a2 =
 1705   withBlackCalibrationHelper a1 $ \a1' -> 
 1706   let {a2' = realToFrac a2} in 
 1707   preErrorCheck $ \a3' -> 
 1708   blackPrice'_ a1' a2' a3' >>= \res ->
 1709   let {res' = realToFrac res} in
 1710   errorCheck  a3'>>
 1711   return (res')
 1712 
 1713 
 1714 
 1715 -- |returns the error resulting from the model valuation
 1716 calibrationError :: (GenBlackCalibrationHelper bch) -> IO ((Double))
 1717 calibrationError a1 =
 1718   withBlackCalibrationHelper a1 $ \a1' -> 
 1719   preErrorCheck $ \a2' -> 
 1720   calibrationError'_ a1' a2' >>= \res ->
 1721   let {res' = realToFrac res} in
 1722   errorCheck  a2'>>
 1723   return (res')
 1724 
 1725 
 1726 
 1727 -- |Black volatility implied by the model.
 1728 impliedVolatility :: (GenBlackCalibrationHelper bch) -> (Double) -- ^targetValue
 1729  -> (Double) -- ^accuracy
 1730  -> (Word) -- ^maxEvaluations
 1731  -> (Double) -- ^minVol
 1732  -> (Double) -- ^maxVol
 1733  -> IO ((Double))
 1734 impliedVolatility a1 a2 a3 a4 a5 a6 =
 1735   withBlackCalibrationHelper a1 $ \a1' -> 
 1736   let {a2' = realToFrac a2} in 
 1737   let {a3' = realToFrac a3} in 
 1738   let {a4' = fromIntegral a4} in 
 1739   let {a5' = realToFrac a5} in 
 1740   let {a6' = realToFrac a6} in 
 1741   preErrorCheck $ \a7' -> 
 1742   impliedVolatility'_ a1' a2' a3' a4' a5' a6' a7' >>= \res ->
 1743   let {res' = realToFrac res} in
 1744   errorCheck  a7'>>
 1745   return (res')
 1746 
 1747 
 1748 
 1749 -- |returns the actual price of the instrument (from volatility)
 1750 marketValue :: (GenBlackCalibrationHelper bch) -> IO ((Double))
 1751 marketValue a1 =
 1752   withBlackCalibrationHelper a1 $ \a1' -> 
 1753   preErrorCheck $ \a2' -> 
 1754   marketValue'_ a1' a2' >>= \res ->
 1755   let {res' = realToFrac res} in
 1756   errorCheck  a2'>>
 1757   return (res')
 1758 
 1759 
 1760 
 1761 -- |returns the price of the instrument according to the model
 1762 modelValue :: (GenBlackCalibrationHelper bch) -> IO ((Double))
 1763 modelValue a1 =
 1764   withBlackCalibrationHelper a1 $ \a1' -> 
 1765   preErrorCheck $ \a2' -> 
 1766   modelValue'_ a1' a2' >>= \res ->
 1767   let {res' = realToFrac res} in
 1768   errorCheck  a2'>>
 1769   return (res')
 1770 
 1771 
 1772 
 1773 -- |The quoted market volatility this helper was built with.
 1774 volatility :: (GenBlackCalibrationHelper bch) -> IO ((Quote))
 1775 volatility a1 =
 1776   withBlackCalibrationHelper a1 $ \a1' -> 
 1777   preErrorCheck $ \a2' -> 
 1778   volatility'_ a1' a2' >>= \res ->
 1779   peekQuote res >>= \res' ->
 1780   errorCheck  a2'>>
 1781   return (res')
 1782 
 1783 
 1784 
 1785 -- |Sets the pricing engine used to compute this calibration helper's model value.
 1786 setPricingEngine :: (GenBlackCalibrationHelper bch) -> (GenPricingEngine pe) -> IO ()
 1787 setPricingEngine a1 a2 =
 1788   withBlackCalibrationHelper a1 $ \a1' -> 
 1789   withPricingEngine a2 $ \a2' -> 
 1790   preErrorCheck $ \a3' -> 
 1791   setPricingEngine'_ a1' a2' a3' >>
 1792   errorCheck  a3'>>
 1793   return ()
 1794 
 1795 
 1796 
 1797 -- |Direct-parameter GARCH(1,1) model: @vl@ is the long-term (unconditional) volatility: the
 1798 -- model's persistence @gamma = 1 - alpha - beta@ and @omega = vl * gamma@ are derived from it.
 1799 -- Does not calibrate; use 'garch11Calibrated' to fit alpha\/beta\/vl to an observed series.
 1800 garch11 :: (Double) -- ^alpha
 1801  -> (Double) -- ^beta
 1802  -> (Double) -- ^vl (long-term volatility)
 1803  -> IO ((Garch11))
 1804 garch11 a1 a2 a3 =
 1805   let {a1' = realToFrac a1} in 
 1806   let {a2' = realToFrac a2} in 
 1807   let {a3' = realToFrac a3} in 
 1808   preErrorCheck $ \a4' -> 
 1809   garch11'_ a1' a2' a3' a4' >>= \res ->
 1810   peekGarch11 res >>= \res' ->
 1811   errorCheck  a4'>>
 1812   return (res')
 1813 
 1814 
 1815 
 1816 -- |Calibrates a GARCH(1,1) model to an observed return series via maximum likelihood. All four
 1817 -- 'Garch11Mode' values converge to the same maximum-likelihood fit for a well-behaved series --
 1818 -- they differ only in the initial guess ('MomentMatchingGuess'\/'GammaGuess'), or run both and
 1819 -- keep the better ('BestOfTwo', the upstream default) or optimize from each in turn
 1820 -- ('DoubleOptimization'). There is no way from Haskell to supply a custom
 1821 -- 'OptimizationMethod'\/'EndCriteria' or to re-calibrate an existing model in place (upstream's
 1822 -- @calibrate@ overloads are mutators on an already-constructed object); construct a fresh model
 1823 -- if a different fit is needed.
 1824 garch11Calibrated :: NonEmpty (Day, Double) -- ^observed return series
 1825   -> Garch11Mode -> IO Garch11
 1826 garch11Calibrated series = qlGarch11Calibrated dates vals
 1827   where (dates, vals) = unzip (toList series)
 1828 qlGarch11Calibrated :: ([Day]) -> ([Double]) -> (Garch11Mode) -> IO ((Garch11))
 1829 qlGarch11Calibrated a1 a2 a3 =
 1830   withDayArray a1 $ \(a1'1, a1'2) -> 
 1831   withDoubleArray a2 $ \(a2'1, a2'2) -> 
 1832   let {a3' = (fromIntegral . fromEnum) a3} in 
 1833   preErrorCheck $ \a4' -> 
 1834   qlGarch11Calibrated'_ a1'1  a1'2 a2'1  a2'2 a3' a4' >>= \res ->
 1835   peekGarch11 res >>= \res' ->
 1836   errorCheck  a4'>>
 1837   return (res')
 1838 
 1839 
 1840 
 1841 -- |the calibrated (or constructor-supplied) alpha coefficient
 1842 alpha :: (Garch11) -> (Double)
 1843 alpha a1 =
 1844   C2HSImp.unsafePerformIO $
 1845   withGarch11 a1 $ \a1' -> 
 1846   alpha'_ a1' >>= \res ->
 1847   let {res' = realToFrac res} in
 1848   return (res')
 1849 
 1850 
 1851 
 1852 -- |the calibrated (or constructor-supplied) beta coefficient
 1853 beta :: (Garch11) -> (Double)
 1854 beta a1 =
 1855   C2HSImp.unsafePerformIO $
 1856   withGarch11 a1 $ \a1' -> 
 1857   beta'_ a1' >>= \res ->
 1858   let {res' = realToFrac res} in
 1859   return (res')
 1860 
 1861 
 1862 
 1863 -- |the calibrated (or derived) omega coefficient, @vl * (1 - alpha - beta)@
 1864 omega :: (Garch11) -> (Double)
 1865 omega a1 =
 1866   C2HSImp.unsafePerformIO $
 1867   withGarch11 a1 $ \a1' -> 
 1868   omega'_ a1' >>= \res ->
 1869   let {res' = realToFrac res} in
 1870   return (res')
 1871 
 1872 
 1873 
 1874 -- |the calibrated (or constructor-supplied) long-term volatility
 1875 longTermVolatility :: (Garch11) -> (Double)
 1876 longTermVolatility a1 =
 1877   C2HSImp.unsafePerformIO $
 1878   withGarch11 a1 $ \a1' -> 
 1879   longTermVolatility'_ a1' >>= \res ->
 1880   let {res' = realToFrac res} in
 1881   return (res')
 1882 
 1883 
 1884 
 1885 -- |the log-likelihood of the calibrated fit; @0@ for a direct-parameter ('garch11') model
 1886 logLikelihood :: (Garch11) -> (Double)
 1887 logLikelihood a1 =
 1888   C2HSImp.unsafePerformIO $
 1889   withGarch11 a1 $ \a1' -> 
 1890   logLikelihood'_ a1' >>= \res ->
 1891   let {res' = realToFrac res} in
 1892   return (res')
 1893 
 1894 
 1895 
 1896 -- |one-step-ahead variance forecast: @gamma*vl + alpha*r^2 + beta*sigma2@, given the latest
 1897 -- return @r@ and the previous step's variance @sigma2@.
 1898 forecast :: (Garch11) -> (Double) -- ^r
 1899  -> (Double) -- ^sigma2
 1900  -> (Double)
 1901 forecast a1 a2 a3 =
 1902   C2HSImp.unsafePerformIO $
 1903   withGarch11 a1 $ \a1' -> 
 1904   let {a2' = realToFrac a2} in 
 1905   let {a3' = realToFrac a3} in 
 1906   forecast'_ a1' a2' a3' >>= \res ->
 1907   let {res' = realToFrac res} in
 1908   return (res')
 1909 
 1910 
 1911 
 1912 -- |Runs the model's calibrated (or constructor-supplied) alpha\/beta\/omega recursion forward
 1913 -- over a return series. The output series is offset by one from the input: the first input
 1914 -- point has nothing to forecast from, so it is dropped, and one extra point is extrapolated one
 1915 -- step past the input series' last date -- an @n@-point input still produces an @n@-point
 1916 -- output, just shifted forward by one date.
 1917 calculate :: Garch11 -> NonEmpty (Day, Double) -- ^return series
 1918   -> IO [(Day, Double)]
 1919 calculate g series = do
 1920   (ds, vs) <- qlGarch11Calculate g dates vals
 1921   return $ zip ds vs
 1922   where (dates, vals) = unzip (toList series)
 1923 qlGarch11Calculate :: (Garch11) -> ([Day]) -> ([Double]) -> IO (([Day]), ([Double]))
 1924 qlGarch11Calculate a1 a2 a3 =
 1925   withGarch11 a1 $ \a1' -> 
 1926   withDayArray a2 $ \(a2'1, a2'2) -> 
 1927   withDoubleArray a3 $ \(a3'1, a3'2) -> 
 1928   preIntArray $ \(a4'1, a4'2) -> 
 1929   preDoubleArray $ \(a5'1, a5'2) -> 
 1930   preErrorCheck $ \a6' -> 
 1931   qlGarch11Calculate'_ a1' a2'1  a2'2 a3'1  a3'2 a4'1  a4'2 a5'1  a5'2 a6' >>
 1932   peekDayArray  a4'1  a4'2>>= \a4'' -> 
 1933   peekDoubleArray  a5'1  a5'2>>= \a5'' -> 
 1934   errorCheck  a6'>>
 1935   return (a4'', a5'')
 1936 
 1937 
 1938 
 1939 -- |Garman-Klass (1980) simple estimator: @sigma^2 = ln(close\/open)^2@, scaled by @yearFraction@.
 1940 -- Input bars are @(date, open, close, high, low)@; only open\/close are used here.
 1941 garmanKlassSimpleSigma :: Double -- ^yearFraction
 1942   -> NonEmpty (Day, Double, Double, Double, Double) -- ^(date, open, close, high, low) price bars
 1943   -> IO [(Day, Double)]
 1944 garmanKlassSimpleSigma yearFraction bars = do
 1945   (ds, vs) <- qlGarmanKlassSimpleSigma yearFraction dates opens closes highs lows
 1946   return $ zip ds vs
 1947   where (dates, opens, closes, highs, lows) = unzipBars bars
 1948 qlGarmanKlassSimpleSigma :: (Double) -> ([Day]) -> ([Double]) -> ([Double]) -> ([Double]) -> ([Double]) -> IO (([Day]), ([Double]))
 1949 qlGarmanKlassSimpleSigma a1 a2 a3 a4 a5 a6 =
 1950   let {a1' = realToFrac a1} in 
 1951   withDayArray a2 $ \(a2'1, a2'2) -> 
 1952   withDoubleArray a3 $ \(a3'1, a3'2) -> 
 1953   withDoubleArray a4 $ \(a4'1, a4'2) -> 
 1954   withDoubleArray a5 $ \(a5'1, a5'2) -> 
 1955   withDoubleArray a6 $ \(a6'1, a6'2) -> 
 1956   preIntArray $ \(a7'1, a7'2) -> 
 1957   preDoubleArray $ \(a8'1, a8'2) -> 
 1958   preErrorCheck $ \a9' -> 
 1959   qlGarmanKlassSimpleSigma'_ a1' a2'1  a2'2 a3'1  a3'2 a4'1  a4'2 a5'1  a5'2 a6'1  a6'2 a7'1  a7'2 a8'1  a8'2 a9' >>
 1960   peekDayArray  a7'1  a7'2>>= \a7'' -> 
 1961   peekDoubleArray  a8'1  a8'2>>= \a8'' -> 
 1962   errorCheck  a9'>>
 1963   return (a7'', a8'')
 1964 
 1965 
 1966 
 1967 -- |Garman-Klass Sigma1: blends 'garmanKlassSimpleSigma' with the overnight (previous close to
 1968 -- today's open) jump, weighted by @marketOpenFraction@ (the fraction of the trading day the
 1969 -- market is open). Drops the series' first bar (needs a previous close).
 1970 garmanKlassSigma1 :: Double -- ^yearFraction
 1971   -> Double -- ^marketOpenFraction
 1972   -> NonEmpty (Day, Double, Double, Double, Double) -- ^(date, open, close, high, low) price bars
 1973   -> IO [(Day, Double)]
 1974 garmanKlassSigma1 yearFraction marketOpenFraction bars = do
 1975   (ds, vs) <- qlGarmanKlassSigma1 yearFraction marketOpenFraction dates opens closes highs lows
 1976   return $ zip ds vs
 1977   where (dates, opens, closes, highs, lows) = unzipBars bars
 1978 qlGarmanKlassSigma1 :: (Double) -> (Double) -> ([Day]) -> ([Double]) -> ([Double]) -> ([Double]) -> ([Double]) -> IO (([Day]), ([Double]))
 1979 qlGarmanKlassSigma1 a1 a2 a3 a4 a5 a6 a7 =
 1980   let {a1' = realToFrac a1} in 
 1981   let {a2' = realToFrac a2} in 
 1982   withDayArray a3 $ \(a3'1, a3'2) -> 
 1983   withDoubleArray a4 $ \(a4'1, a4'2) -> 
 1984   withDoubleArray a5 $ \(a5'1, a5'2) -> 
 1985   withDoubleArray a6 $ \(a6'1, a6'2) -> 
 1986   withDoubleArray a7 $ \(a7'1, a7'2) -> 
 1987   preIntArray $ \(a8'1, a8'2) -> 
 1988   preDoubleArray $ \(a9'1, a9'2) -> 
 1989   preErrorCheck $ \a10' -> 
 1990   qlGarmanKlassSigma1'_ a1' a2' a3'1  a3'2 a4'1  a4'2 a5'1  a5'2 a6'1  a6'2 a7'1  a7'2 a8'1  a8'2 a9'1  a9'2 a10' >>
 1991   peekDayArray  a8'1  a8'2>>= \a8'' -> 
 1992   peekDoubleArray  a9'1  a9'2>>= \a9'' -> 
 1993   errorCheck  a10'>>
 1994   return (a8'', a9'')
 1995 
 1996 
 1997 
 1998 -- |Parkinson (1980) high-low estimator: @sigma^2 = ln(high\/low)^2 \/ (4 ln 2)@, scaled by
 1999 -- @yearFraction@. Input bars are @(date, open, close, high, low)@; only high\/low are used here.
 2000 parkinsonSigma :: Double -- ^yearFraction
 2001   -> NonEmpty (Day, Double, Double, Double, Double) -- ^(date, open, close, high, low) price bars
 2002   -> IO [(Day, Double)]
 2003 parkinsonSigma yearFraction bars = do
 2004   (ds, vs) <- qlParkinsonSigma yearFraction dates opens closes highs lows
 2005   return $ zip ds vs
 2006   where (dates, opens, closes, highs, lows) = unzipBars bars
 2007 qlParkinsonSigma :: (Double) -> ([Day]) -> ([Double]) -> ([Double]) -> ([Double]) -> ([Double]) -> IO (([Day]), ([Double]))
 2008 qlParkinsonSigma a1 a2 a3 a4 a5 a6 =
 2009   let {a1' = realToFrac a1} in 
 2010   withDayArray a2 $ \(a2'1, a2'2) -> 
 2011   withDoubleArray a3 $ \(a3'1, a3'2) -> 
 2012   withDoubleArray a4 $ \(a4'1, a4'2) -> 
 2013   withDoubleArray a5 $ \(a5'1, a5'2) -> 
 2014   withDoubleArray a6 $ \(a6'1, a6'2) -> 
 2015   preIntArray $ \(a7'1, a7'2) -> 
 2016   preDoubleArray $ \(a8'1, a8'2) -> 
 2017   preErrorCheck $ \a9' -> 
 2018   qlParkinsonSigma'_ a1' a2'1  a2'2 a3'1  a3'2 a4'1  a4'2 a5'1  a5'2 a6'1  a6'2 a7'1  a7'2 a8'1  a8'2 a9' >>
 2019   peekDayArray  a7'1  a7'2>>= \a7'' -> 
 2020   peekDoubleArray  a8'1  a8'2>>= \a8'' -> 
 2021   errorCheck  a9'>>
 2022   return (a7'', a8'')
 2023 
 2024 
 2025 
 2026 -- |Garman-Klass Sigma3: blends 'parkinsonSigma' with the overnight jump, same
 2027 -- @marketOpenFraction@ weighting as 'garmanKlassSigma1'. Drops the series' first bar.
 2028 garmanKlassSigma3 :: Double -- ^yearFraction
 2029   -> Double -- ^marketOpenFraction
 2030   -> NonEmpty (Day, Double, Double, Double, Double) -- ^(date, open, close, high, low) price bars
 2031   -> IO [(Day, Double)]
 2032 garmanKlassSigma3 yearFraction marketOpenFraction bars = do
 2033   (ds, vs) <- qlGarmanKlassSigma3 yearFraction marketOpenFraction dates opens closes highs lows
 2034   return $ zip ds vs
 2035   where (dates, opens, closes, highs, lows) = unzipBars bars
 2036 qlGarmanKlassSigma3 :: (Double) -> (Double) -> ([Day]) -> ([Double]) -> ([Double]) -> ([Double]) -> ([Double]) -> IO (([Day]), ([Double]))
 2037 qlGarmanKlassSigma3 a1 a2 a3 a4 a5 a6 a7 =
 2038   let {a1' = realToFrac a1} in 
 2039   let {a2' = realToFrac a2} in 
 2040   withDayArray a3 $ \(a3'1, a3'2) -> 
 2041   withDoubleArray a4 $ \(a4'1, a4'2) -> 
 2042   withDoubleArray a5 $ \(a5'1, a5'2) -> 
 2043   withDoubleArray a6 $ \(a6'1, a6'2) -> 
 2044   withDoubleArray a7 $ \(a7'1, a7'2) -> 
 2045   preIntArray $ \(a8'1, a8'2) -> 
 2046   preDoubleArray $ \(a9'1, a9'2) -> 
 2047   preErrorCheck $ \a10' -> 
 2048   qlGarmanKlassSigma3'_ a1' a2' a3'1  a3'2 a4'1  a4'2 a5'1  a5'2 a6'1  a6'2 a7'1  a7'2 a8'1  a8'2 a9'1  a9'2 a10' >>
 2049   peekDayArray  a8'1  a8'2>>= \a8'' -> 
 2050   peekDoubleArray  a9'1  a9'2>>= \a9'' -> 
 2051   errorCheck  a10'>>
 2052   return (a8'', a9'')
 2053 
 2054 
 2055 
 2056 -- |Garman-Klass (1980) Sigma4 estimator, combining the high-low range with the close-open
 2057 -- return via their published coefficients. Input bars are @(date, open, close, high, low)@.
 2058 garmanKlassSigma4 :: Double -- ^yearFraction
 2059   -> NonEmpty (Day, Double, Double, Double, Double) -- ^(date, open, close, high, low) price bars
 2060   -> IO [(Day, Double)]
 2061 garmanKlassSigma4 yearFraction bars = do
 2062   (ds, vs) <- qlGarmanKlassSigma4 yearFraction dates opens closes highs lows
 2063   return $ zip ds vs
 2064   where (dates, opens, closes, highs, lows) = unzipBars bars
 2065 qlGarmanKlassSigma4 :: (Double) -> ([Day]) -> ([Double]) -> ([Double]) -> ([Double]) -> ([Double]) -> IO (([Day]), ([Double]))
 2066 qlGarmanKlassSigma4 a1 a2 a3 a4 a5 a6 =
 2067   let {a1' = realToFrac a1} in 
 2068   withDayArray a2 $ \(a2'1, a2'2) -> 
 2069   withDoubleArray a3 $ \(a3'1, a3'2) -> 
 2070   withDoubleArray a4 $ \(a4'1, a4'2) -> 
 2071   withDoubleArray a5 $ \(a5'1, a5'2) -> 
 2072   withDoubleArray a6 $ \(a6'1, a6'2) -> 
 2073   preIntArray $ \(a7'1, a7'2) -> 
 2074   preDoubleArray $ \(a8'1, a8'2) -> 
 2075   preErrorCheck $ \a9' -> 
 2076   qlGarmanKlassSigma4'_ a1' a2'1  a2'2 a3'1  a3'2 a4'1  a4'2 a5'1  a5'2 a6'1  a6'2 a7'1  a7'2 a8'1  a8'2 a9' >>
 2077   peekDayArray  a7'1  a7'2>>= \a7'' -> 
 2078   peekDoubleArray  a8'1  a8'2>>= \a8'' -> 
 2079   errorCheck  a9'>>
 2080   return (a7'', a8'')
 2081 
 2082 
 2083 
 2084 -- |Garman-Klass (1980) Sigma5 estimator: an alternative high-low\/close-open combination to
 2085 -- 'garmanKlassSigma4', with different published coefficients.
 2086 garmanKlassSigma5 :: Double -- ^yearFraction
 2087   -> NonEmpty (Day, Double, Double, Double, Double) -- ^(date, open, close, high, low) price bars
 2088   -> IO [(Day, Double)]
 2089 garmanKlassSigma5 yearFraction bars = do
 2090   (ds, vs) <- qlGarmanKlassSigma5 yearFraction dates opens closes highs lows
 2091   return $ zip ds vs
 2092   where (dates, opens, closes, highs, lows) = unzipBars bars
 2093 qlGarmanKlassSigma5 :: (Double) -> ([Day]) -> ([Double]) -> ([Double]) -> ([Double]) -> ([Double]) -> IO (([Day]), ([Double]))
 2094 qlGarmanKlassSigma5 a1 a2 a3 a4 a5 a6 =
 2095   let {a1' = realToFrac a1} in 
 2096   withDayArray a2 $ \(a2'1, a2'2) -> 
 2097   withDoubleArray a3 $ \(a3'1, a3'2) -> 
 2098   withDoubleArray a4 $ \(a4'1, a4'2) -> 
 2099   withDoubleArray a5 $ \(a5'1, a5'2) -> 
 2100   withDoubleArray a6 $ \(a6'1, a6'2) -> 
 2101   preIntArray $ \(a7'1, a7'2) -> 
 2102   preDoubleArray $ \(a8'1, a8'2) -> 
 2103   preErrorCheck $ \a9' -> 
 2104   qlGarmanKlassSigma5'_ a1' a2'1  a2'2 a3'1  a3'2 a4'1  a4'2 a5'1  a5'2 a6'1  a6'2 a7'1  a7'2 a8'1  a8'2 a9' >>
 2105   peekDayArray  a7'1  a7'2>>= \a7'' -> 
 2106   peekDoubleArray  a8'1  a8'2>>= \a8'' -> 
 2107   errorCheck  a9'>>
 2108   return (a7'', a8'')
 2109 
 2110 
 2111 
 2112 -- |Garman-Klass Sigma6: blends 'garmanKlassSigma5' with the overnight jump, same
 2113 -- @marketOpenFraction@ weighting as 'garmanKlassSigma1'. Drops the series' first bar.
 2114 garmanKlassSigma6 :: Double -- ^yearFraction
 2115   -> Double -- ^marketOpenFraction
 2116   -> NonEmpty (Day, Double, Double, Double, Double) -- ^(date, open, close, high, low) price bars
 2117   -> IO [(Day, Double)]
 2118 garmanKlassSigma6 yearFraction marketOpenFraction bars = do
 2119   (ds, vs) <- qlGarmanKlassSigma6 yearFraction marketOpenFraction dates opens closes highs lows
 2120   return $ zip ds vs
 2121   where (dates, opens, closes, highs, lows) = unzipBars bars
 2122 qlGarmanKlassSigma6 :: (Double) -> (Double) -> ([Day]) -> ([Double]) -> ([Double]) -> ([Double]) -> ([Double]) -> IO (([Day]), ([Double]))
 2123 qlGarmanKlassSigma6 a1 a2 a3 a4 a5 a6 a7 =
 2124   let {a1' = realToFrac a1} in 
 2125   let {a2' = realToFrac a2} in 
 2126   withDayArray a3 $ \(a3'1, a3'2) -> 
 2127   withDoubleArray a4 $ \(a4'1, a4'2) -> 
 2128   withDoubleArray a5 $ \(a5'1, a5'2) -> 
 2129   withDoubleArray a6 $ \(a6'1, a6'2) -> 
 2130   withDoubleArray a7 $ \(a7'1, a7'2) -> 
 2131   preIntArray $ \(a8'1, a8'2) -> 
 2132   preDoubleArray $ \(a9'1, a9'2) -> 
 2133   preErrorCheck $ \a10' -> 
 2134   qlGarmanKlassSigma6'_ a1' a2' a3'1  a3'2 a4'1  a4'2 a5'1  a5'2 a6'1  a6'2 a7'1  a7'2 a8'1  a8'2 a9'1  a9'2 a10' >>
 2135   peekDayArray  a8'1  a8'2>>= \a8'' -> 
 2136   peekDoubleArray  a9'1  a9'2>>= \a9'' -> 
 2137   errorCheck  a10'>>
 2138   return (a8'', a9'')
 2139 
 2140 
 2141 
 2142 -- |Smooths an already-computed volatility series with a rolling constant estimate over the
 2143 -- trailing @windowSize@ points.
 2144 constantVolatilityEstimator :: Word -- ^windowSize
 2145   -> NonEmpty (Day, Double) -- ^volatility series
 2146   -> IO [(Day, Double)]
 2147 constantVolatilityEstimator windowSize series = do
 2148   (ds, vs) <- qlConstantVolatilityEstimator windowSize dates vals
 2149   return $ zip ds vs
 2150   where (dates, vals) = unzip (toList series)
 2151 qlConstantVolatilityEstimator :: (Word) -> ([Day]) -> ([Double]) -> IO (([Day]), ([Double]))
 2152 qlConstantVolatilityEstimator a1 a2 a3 =
 2153   let {a1' = fromIntegral a1} in 
 2154   withDayArray a2 $ \(a2'1, a2'2) -> 
 2155   withDoubleArray a3 $ \(a3'1, a3'2) -> 
 2156   preIntArray $ \(a4'1, a4'2) -> 
 2157   preDoubleArray $ \(a5'1, a5'2) -> 
 2158   preErrorCheck $ \a6' -> 
 2159   qlConstantVolatilityEstimator'_ a1' a2'1  a2'2 a3'1  a3'2 a4'1  a4'2 a5'1  a5'2 a6' >>
 2160   peekDayArray  a4'1  a4'2>>= \a4'' -> 
 2161   peekDoubleArray  a5'1  a5'2>>= \a5'' -> 
 2162   errorCheck  a6'>>
 2163   return (a4'', a5'')
 2164 
 2165 
 2166 
 2167 -- |Local (point-to-point) volatility estimate from a raw price series: @|ln(p_i\/p_{i-1})| \/
 2168 -- sqrt(yearFraction)@ for each consecutive pair. Drops the series' first date; an @n@-point
 2169 -- input produces an @(n-1)@-point output.
 2170 simpleLocalVolatilityEstimator :: Double -- ^yearFraction
 2171   -> NonEmpty (Day, Double) -- ^price series
 2172   -> IO [(Day, Double)]
 2173 simpleLocalVolatilityEstimator yearFraction series = do
 2174   (ds, vs) <- qlSimpleLocalVolatilityEstimator yearFraction dates vals
 2175   return $ zip ds vs
 2176   where (dates, vals) = unzip (toList series)
 2177 qlSimpleLocalVolatilityEstimator :: (Double) -> ([Day]) -> ([Double]) -> IO (([Day]), ([Double]))
 2178 qlSimpleLocalVolatilityEstimator a1 a2 a3 =
 2179   let {a1' = realToFrac a1} in 
 2180   withDayArray a2 $ \(a2'1, a2'2) -> 
 2181   withDoubleArray a3 $ \(a3'1, a3'2) -> 
 2182   preIntArray $ \(a4'1, a4'2) -> 
 2183   preDoubleArray $ \(a5'1, a5'2) -> 
 2184   preErrorCheck $ \a6' -> 
 2185   qlSimpleLocalVolatilityEstimator'_ a1' a2'1  a2'2 a3'1  a3'2 a4'1  a4'2 a5'1  a5'2 a6' >>
 2186   peekDayArray  a4'1  a4'2>>= \a4'' -> 
 2187   peekDoubleArray  a5'1  a5'2>>= \a5'' -> 
 2188   errorCheck  a6'>>
 2189   return (a4'', a5'')
 2190 
 2191 
 2192 
 2193 unzipBars :: NonEmpty (Day, Double, Double, Double, Double) -> ([Day], [Double], [Double], [Double], [Double])
 2194 unzipBars bars = (map d5 xs, map o5 xs, map c5 xs, map h5 xs, map l5 xs)
 2195   where
 2196     xs = toList bars
 2197     d5 (d,_,_,_,_) = d
 2198     o5 (_,o,_,_,_) = o
 2199     c5 (_,_,c,_,_) = c
 2200     h5 (_,_,_,h,_) = h
 2201     l5 (_,_,_,_,l) = l
 2202 
 2203 -- |Conditional compounded overnight rate using the coupon's observation dates and index day
 2204 -- counter; ignores gearing/spread and historical fixings. Requires QuantLib 1.44.
 2205 -- Nothing selects the model reference date or model curve.
 2206 gaussian1dCompoundedRate :: (Gaussian1dModel) -- ^model
 2207  -> (OvernightIndexedCoupon) -- ^coupon
 2208  -> (Maybe Day) -- ^referenceDate
 2209  -> (Double) -- ^y
 2210  -> (Maybe (GenYieldTermStructure y)) -- ^curve
 2211  -> IO ((Double))
 2212 gaussian1dCompoundedRate a1 a2 a3 a4 a5 =
 2213   withStandalone a1 $ \a1' -> 
 2214   withOvernightIndexedCoupon a2 $ \a2' -> 
 2215   withMaybeDay a3 $ \a3' -> 
 2216   let {a4' = realToFrac a4} in 
 2217   withMaybeYieldTermStructure a5 $ \a5' -> 
 2218   preErrorCheck $ \a6' -> 
 2219   gaussian1dCompoundedRate'_ a1' a2' a3' a4' a5' a6' >>= \res ->
 2220   let {res' = realToFrac res} in
 2221   errorCheck  a6'>>
 2222   return (res')
 2223 
 2224 
 2225 
 2226 -- |Rough Heston volatility model (1.44). Hurst is constrained to [0, 0.5]; 0.5 is classical Heston.
 2227 roughHestonModel :: (GenHestonProcess hp) -- ^process
 2228  -> (Double) -- ^hurst
 2229  -> IO ((RoughHestonModel))
 2230 roughHestonModel a1 a2 =
 2231   withHestonProcess a1 $ \a1' -> 
 2232   let {a2' = realToFrac a2} in 
 2233   preErrorCheck $ \a3' -> 
 2234   roughHestonModel'_ a1' a2' a3' >>= \res ->
 2235   peekRoughHestonModel res >>= \res' ->
 2236   errorCheck  a3'>>
 2237   return (res')
 2238 
 2239 
 2240 
 2241 -- |Current calibrated theta (1.44).
 2242 roughHestonTheta :: (RoughHestonModel) -- ^model
 2243  -> IO ((Double))
 2244 roughHestonTheta a1 =
 2245   withRoughHestonModel a1 $ \a1' -> 
 2246   preErrorCheck $ \a2' -> 
 2247   roughHestonTheta'_ a1' a2' >>= \res ->
 2248   let {res' = realToFrac res} in
 2249   errorCheck  a2'>>
 2250   return (res')
 2251 
 2252 
 2253 
 2254 -- |Current calibrated kappa (1.44).
 2255 roughHestonKappa :: (RoughHestonModel) -- ^model
 2256  -> IO ((Double))
 2257 roughHestonKappa a1 =
 2258   withRoughHestonModel a1 $ \a1' -> 
 2259   preErrorCheck $ \a2' -> 
 2260   roughHestonKappa'_ a1' a2' >>= \res ->
 2261   let {res' = realToFrac res} in
 2262   errorCheck  a2'>>
 2263   return (res')
 2264 
 2265 
 2266 
 2267 -- |Current calibrated sigma (1.44).
 2268 roughHestonSigma :: (RoughHestonModel) -- ^model
 2269  -> IO ((Double))
 2270 roughHestonSigma a1 =
 2271   withRoughHestonModel a1 $ \a1' -> 
 2272   preErrorCheck $ \a2' -> 
 2273   roughHestonSigma'_ a1' a2' >>= \res ->
 2274   let {res' = realToFrac res} in
 2275   errorCheck  a2'>>
 2276   return (res')
 2277 
 2278 
 2279 
 2280 -- |Current calibrated rho (1.44).
 2281 roughHestonRho :: (RoughHestonModel) -- ^model
 2282  -> IO ((Double))
 2283 roughHestonRho a1 =
 2284   withRoughHestonModel a1 $ \a1' -> 
 2285   preErrorCheck $ \a2' -> 
 2286   roughHestonRho'_ a1' a2' >>= \res ->
 2287   let {res' = realToFrac res} in
 2288   errorCheck  a2'>>
 2289   return (res')
 2290 
 2291 
 2292 
 2293 -- |Current calibrated v0 (1.44).
 2294 roughHestonV0 :: (RoughHestonModel) -- ^model
 2295  -> IO ((Double))
 2296 roughHestonV0 a1 =
 2297   withRoughHestonModel a1 $ \a1' -> 
 2298   preErrorCheck $ \a2' -> 
 2299   roughHestonV0'_ a1' a2' >>= \res ->
 2300   let {res' = realToFrac res} in
 2301   errorCheck  a2'>>
 2302   return (res')
 2303 
 2304 
 2305 
 2306 -- |Current calibrated hurst (1.44).
 2307 roughHestonHurst :: (RoughHestonModel) -- ^model
 2308  -> IO ((Double))
 2309 roughHestonHurst a1 =
 2310   withRoughHestonModel a1 $ \a1' -> 
 2311   preErrorCheck $ \a2' -> 
 2312   roughHestonHurst'_ a1' a2' >>= \res ->
 2313   let {res' = realToFrac res} in
 2314   errorCheck  a2'>>
 2315   return (res')
 2316 
 2317 
 2318 
 2319 -- |Current calibrated process (1.44).
 2320 roughHestonProcess :: (RoughHestonModel) -- ^model
 2321  -> IO ((HestonProcess))
 2322 roughHestonProcess a1 =
 2323   withRoughHestonModel a1 $ \a1' -> 
 2324   preErrorCheck $ \a2' -> 
 2325   roughHestonProcess'_ a1' a2' >>= \res ->
 2326   peekHestonProcess res >>= \res' ->
 2327   errorCheck  a2'>>
 2328   return (res')
 2329 
 2330 
 2331 
 2332 -- vim: set ff=unix ts=8 sts=2 sw=2 et:
 2333 
 2334 foreign import ccall safe "QuantLib/Model.chs.h qlBatesModel"
 2335   batesModel'_ :: ((C2HSImp.Ptr (CBatesProcess')) -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO (C2HSImp.Ptr (CBatesModel')))))
 2336 
 2337 foreign import ccall safe "QuantLib/Model.chs.h qlBlackKarasinski"
 2338   blackKarasinski'_ :: ((C2HSImp.Ptr (CYieldTermStructure')) -> (C2HSImp.CDouble -> (C2HSImp.CDouble -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO (C2HSImp.Ptr (CShortRateModel')))))))
 2339 
 2340 foreign import ccall safe "QuantLib/Model.chs.h qlCoxIngersollRoss"
 2341   coxIngersollRoss'_ :: (C2HSImp.CDouble -> (C2HSImp.CDouble -> (C2HSImp.CDouble -> (C2HSImp.CDouble -> (C2HSImp.CInt -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO (C2HSImp.Ptr (COneFactorAffineModel')))))))))
 2342 
 2343 foreign import ccall safe "QuantLib/Model.chs.h qlExtendedCoxIngersollRoss"
 2344   extendedCoxIngersollRoss'_ :: ((C2HSImp.Ptr (CYieldTermStructure')) -> (C2HSImp.CDouble -> (C2HSImp.CDouble -> (C2HSImp.CDouble -> (C2HSImp.CDouble -> (C2HSImp.CInt -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO (C2HSImp.Ptr (COneFactorAffineModel'))))))))))
 2345 
 2346 foreign import ccall safe "QuantLib/Model.chs.h qlG2"
 2347   g2'_ :: ((C2HSImp.Ptr (CYieldTermStructure')) -> (C2HSImp.CDouble -> (C2HSImp.CDouble -> (C2HSImp.CDouble -> (C2HSImp.CDouble -> (C2HSImp.CDouble -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO (C2HSImp.Ptr (CG2'))))))))))
 2348 
 2349 foreign import ccall safe "QuantLib/Model.chs.h qlG2Dynamics"
 2350   g2Dynamics'_ :: ((C2HSImp.Ptr (CG2')) -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO (C2HSImp.Ptr (CShortRateDynamics')))))
 2351 
 2352 foreign import ccall safe "QuantLib/Model.chs.h qlShortRateDynamicsShortRate"
 2353   shortRate'_ :: ((C2HSImp.Ptr (CShortRateDynamics')) -> (C2HSImp.CDouble -> (C2HSImp.CDouble -> (C2HSImp.CDouble -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO C2HSImp.CDouble))))))
 2354 
 2355 foreign import ccall safe "QuantLib/Model.chs.h qlGeneralizedHullWhite"
 2356   qlGeneralizedHullWhite'_ :: ((C2HSImp.Ptr (CYieldTermStructure')) -> (C2HSImp.CUInt -> ((C2HSImp.Ptr C2HSImp.CInt) -> (C2HSImp.CUInt -> ((C2HSImp.Ptr C2HSImp.CInt) -> (C2HSImp.CUInt -> ((C2HSImp.Ptr C2HSImp.CDouble) -> (C2HSImp.CUInt -> ((C2HSImp.Ptr C2HSImp.CDouble) -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO (C2HSImp.Ptr (CShortRateModel')))))))))))))
 2357 
 2358 foreign import ccall safe "QuantLib/Model.chs.h qlGJRGARCHModel"
 2359   gjrGarchModel'_ :: ((C2HSImp.Ptr (CGJRGARCHProcess')) -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO (C2HSImp.Ptr (CGJRGARCHModel')))))
 2360 
 2361 foreign import ccall safe "QuantLib/Model.chs.h qlHestonModel"
 2362   hestonModel'_ :: ((C2HSImp.Ptr (CHestonProcess')) -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO (C2HSImp.Ptr (CHestonModel')))))
 2363 
 2364 foreign import ccall safe "QuantLib/Model.chs.h qlMTBrownianGeneratorFactory"
 2365   mtBrownianGeneratorFactory'_ :: (C2HSImp.CULong -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO (C2HSImp.Ptr (CBrownianGeneratorFactory')))))
 2366 
 2367 foreign import ccall safe "QuantLib/Model.chs.h qlSobolBrownianGeneratorFactory"
 2368   sobolBrownianGeneratorFactory'_ :: (C2HSImp.CInt -> (C2HSImp.CULong -> (C2HSImp.CInt -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO (C2HSImp.Ptr (CBrownianGeneratorFactory')))))))
 2369 
 2370 foreign import ccall safe "QuantLib/Model.chs.h qlHestonSLVMCModel"
 2371   hestonSlvMcModel'_ :: ((C2HSImp.Ptr (CLocalVolTermStructure')) -> ((C2HSImp.Ptr (CHestonModel')) -> ((C2HSImp.Ptr (CBrownianGeneratorFactory')) -> (C2HSImp.CInt -> (C2HSImp.CUInt -> (C2HSImp.CUInt -> (C2HSImp.CUInt -> (C2HSImp.CUInt -> ((C2HSImp.Ptr C2HSImp.CInt) -> (C2HSImp.CDouble -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO (C2HSImp.Ptr (CHestonSLVMCModel'))))))))))))))
 2372 
 2373 foreign import ccall safe "QuantLib/Model.chs.h qlHestonSLVMCModelLeverageFunction"
 2374   qlHestonSLVMCModelLeverageFunction'_ :: ((C2HSImp.Ptr (CHestonSLVMCModel')) -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO (C2HSImp.Ptr (CLocalVolTermStructure')))))
 2375 
 2376 foreign import ccall safe "QuantLib/Model.chs.h qlHestonSLVFDMModel"
 2377   hestonSlvFdmModelRaw'_ :: ((C2HSImp.Ptr (CLocalVolTermStructure')) -> ((C2HSImp.Ptr (CHestonModel')) -> (C2HSImp.CInt -> (C2HSImp.CUInt -> (C2HSImp.CUInt -> (C2HSImp.CUInt -> (C2HSImp.CUInt -> (C2HSImp.CDouble -> (C2HSImp.CUInt -> (C2HSImp.CUInt -> (C2HSImp.CDouble -> (C2HSImp.CDouble -> (C2HSImp.CUInt -> (C2HSImp.CDouble -> (C2HSImp.CDouble -> (C2HSImp.CDouble -> (C2HSImp.CDouble -> (C2HSImp.CDouble -> (C2HSImp.CDouble -> (C2HSImp.CDouble -> (C2HSImp.CInt -> (C2HSImp.CInt -> ((C2HSImp.Ptr (CFdmSchemeDesc)) -> (C2HSImp.CInt -> (C2HSImp.CUInt -> ((C2HSImp.Ptr C2HSImp.CInt) -> (C2HSImp.CDouble -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO (C2HSImp.Ptr (CHestonSLVFDMModel')))))))))))))))))))))))))))))))
 2378 
 2379 foreign import ccall safe "QuantLib/Model.chs.h qlHestonSLVFDMModelLeverageFunction"
 2380   qlHestonSLVFDMModelLeverageFunction'_ :: ((C2HSImp.Ptr (CHestonSLVFDMModel')) -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO (C2HSImp.Ptr (CLocalVolTermStructure')))))
 2381 
 2382 foreign import ccall safe "QuantLib/Model.chs.h qlHestonSLVFDMModelLogEntries"
 2383   hestonSlvFdmLogEntriesSnapshot'_ :: ((C2HSImp.Ptr (CHestonSLVFDMModel')) -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO (C2HSImp.Ptr (CHestonSLVFDMLogEntries)))))
 2384 
 2385 foreign import ccall safe "QuantLib/Model.chs.h qlHestonSLVFDMLogEntriesSize"
 2386   hestonSlvFdmLogEntriesSize'_ :: ((C2HSImp.Ptr (CHestonSLVFDMLogEntries)) -> (IO C2HSImp.CUInt))
 2387 
 2388 foreign import ccall safe "QuantLib/Model.chs.h qlHestonSLVFDMLogEntriesTime"
 2389   hestonSlvFdmLogEntriesTime'_ :: ((C2HSImp.Ptr (CHestonSLVFDMLogEntries)) -> (C2HSImp.CUInt -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO C2HSImp.CDouble))))
 2390 
 2391 foreign import ccall safe "QuantLib/Model.chs.h qlHestonSLVFDMLogEntriesSpotGrid"
 2392   hestonSlvFdmLogEntriesSpotGrid'_ :: ((C2HSImp.Ptr (CHestonSLVFDMLogEntries)) -> (C2HSImp.CUInt -> ((C2HSImp.Ptr C2HSImp.CUInt) -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CDouble)) -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO ()))))))
 2393 
 2394 foreign import ccall safe "QuantLib/Model.chs.h qlHestonSLVFDMLogEntriesVarianceGrid"
 2395   hestonSlvFdmLogEntriesVarianceGrid'_ :: ((C2HSImp.Ptr (CHestonSLVFDMLogEntries)) -> (C2HSImp.CUInt -> ((C2HSImp.Ptr C2HSImp.CUInt) -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CDouble)) -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO ()))))))
 2396 
 2397 foreign import ccall safe "QuantLib/Model.chs.h qlHestonSLVFDMLogEntriesDensity"
 2398   hestonSlvFdmLogEntriesDensity'_ :: ((C2HSImp.Ptr (CHestonSLVFDMLogEntries)) -> (C2HSImp.CUInt -> ((C2HSImp.Ptr C2HSImp.CUInt) -> ((C2HSImp.Ptr C2HSImp.CUInt) -> ((C2HSImp.Ptr C2HSImp.CUInt) -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CDouble)) -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO ()))))))))
 2399 
 2400 foreign import ccall safe "QuantLib/Model.chs.h qlHullWhite"
 2401   hullWhite'_ :: ((C2HSImp.Ptr (CYieldTermStructure')) -> (C2HSImp.CDouble -> (C2HSImp.CDouble -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO (C2HSImp.Ptr (CHullWhite')))))))
 2402 
 2403 foreign import ccall safe "QuantLib/Model.chs.h qlHullWhiteConvexityBias"
 2404   convexityBias'_ :: (C2HSImp.CDouble -> (C2HSImp.CDouble -> (C2HSImp.CDouble -> (C2HSImp.CDouble -> (C2HSImp.CDouble -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO C2HSImp.CDouble)))))))
 2405 
 2406 foreign import ccall safe "QuantLib/Model.chs.h qlGsr"
 2407   qlGsr'_ :: ((C2HSImp.Ptr (CYieldTermStructure')) -> (C2HSImp.CUInt -> ((C2HSImp.Ptr C2HSImp.CInt) -> (C2HSImp.CUInt -> ((C2HSImp.Ptr (C2HSImp.Ptr (CQuote'))) -> (C2HSImp.CUInt -> ((C2HSImp.Ptr (C2HSImp.Ptr (CQuote'))) -> (C2HSImp.CDouble -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO (C2HSImp.Ptr (CGsr'))))))))))))
 2408 
 2409 foreign import ccall safe "QuantLib/Model.chs.h qlGsrVolatility"
 2410   qlGsrVolatility'_ :: ((C2HSImp.Ptr (CGsr')) -> ((C2HSImp.Ptr C2HSImp.CUInt) -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CDouble)) -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO ())))))
 2411 
 2412 foreign import ccall safe "QuantLib/Model.chs.h qlGsrReversion"
 2413   reversions'_ :: ((C2HSImp.Ptr (CGsr')) -> ((C2HSImp.Ptr C2HSImp.CUInt) -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CDouble)) -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO ())))))
 2414 
 2415 foreign import ccall safe "QuantLib/Model.chs.h qlGsrMoveVolatility"
 2416   moveVolatility'_ :: ((C2HSImp.Ptr (CGsr')) -> (C2HSImp.CUInt -> ((C2HSImp.Ptr C2HSImp.CUInt) -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CInt)) -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO ()))))))
 2417 
 2418 foreign import ccall safe "QuantLib/Model.chs.h qlGsrMoveReversion"
 2419   moveReversion'_ :: ((C2HSImp.Ptr (CGsr')) -> (C2HSImp.CUInt -> ((C2HSImp.Ptr C2HSImp.CUInt) -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CInt)) -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO ()))))))
 2420 
 2421 foreign import ccall safe "QuantLib/Model.chs.h qlGsrCalibrateVolatilitiesIterative"
 2422   calibrateVolatilitiesIterative'_ :: ((C2HSImp.Ptr (CGsr')) -> (C2HSImp.CUInt -> ((C2HSImp.Ptr (C2HSImp.Ptr (CBlackCalibrationHelper'))) -> ((C2HSImp.Ptr (COptimizationMethod)) -> ((C2HSImp.Ptr (CEndCriteria)) -> ((C2HSImp.Ptr (CConstraint)) -> (C2HSImp.CUInt -> ((C2HSImp.Ptr C2HSImp.CDouble) -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO ()))))))))))
 2423 
 2424 foreign import ccall safe "QuantLib/Model.chs.h qlGsrCalibrateReversionsIterative"
 2425   calibrateReversionsIterative'_ :: ((C2HSImp.Ptr (CGsr')) -> (C2HSImp.CUInt -> ((C2HSImp.Ptr (C2HSImp.Ptr (CBlackCalibrationHelper'))) -> ((C2HSImp.Ptr (COptimizationMethod)) -> ((C2HSImp.Ptr (CEndCriteria)) -> ((C2HSImp.Ptr (CConstraint)) -> (C2HSImp.CUInt -> ((C2HSImp.Ptr C2HSImp.CDouble) -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO ()))))))))))
 2426 
 2427 foreign import ccall safe "QuantLib/Model.chs.h qlMarkovFunctional"
 2428   qlMarkovFunctional'_ :: ((C2HSImp.Ptr (CYieldTermStructure')) -> (C2HSImp.CDouble -> (C2HSImp.CUInt -> ((C2HSImp.Ptr C2HSImp.CInt) -> (C2HSImp.CUInt -> ((C2HSImp.Ptr C2HSImp.CDouble) -> ((C2HSImp.Ptr (CSwaptionVolatilityStructure')) -> (C2HSImp.CUInt -> ((C2HSImp.Ptr C2HSImp.CInt) -> (C2HSImp.CUInt -> ((C2HSImp.Ptr C2HSImp.CInt) -> (C2HSImp.CUInt -> ((C2HSImp.Ptr C2HSImp.CInt) -> ((C2HSImp.Ptr (CSwapIndex')) -> (C2HSImp.CUInt -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO (C2HSImp.Ptr (CMarkovFunctional')))))))))))))))))))
 2429 
 2430 foreign import ccall safe "QuantLib/Model.chs.h qlMarkovFunctionalCaplet"
 2431   qlMarkovFunctionalCaplet'_ :: ((C2HSImp.Ptr (CYieldTermStructure')) -> (C2HSImp.CDouble -> (C2HSImp.CUInt -> ((C2HSImp.Ptr C2HSImp.CInt) -> (C2HSImp.CUInt -> ((C2HSImp.Ptr C2HSImp.CDouble) -> ((C2HSImp.Ptr (COptionletVolatilityStructure')) -> (C2HSImp.CUInt -> ((C2HSImp.Ptr C2HSImp.CInt) -> ((C2HSImp.Ptr (CIborIndex')) -> (C2HSImp.CUInt -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO (C2HSImp.Ptr (CMarkovFunctional')))))))))))))))
 2432 
 2433 foreign import ccall safe "QuantLib/Model.chs.h qlMarkovFunctionalVolatility"
 2434   qlMarkovFunctionalVolatility'_ :: ((C2HSImp.Ptr (CMarkovFunctional')) -> ((C2HSImp.Ptr C2HSImp.CUInt) -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CDouble)) -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO ())))))
 2435 
 2436 foreign import ccall safe "QuantLib/Model.chs.h qlAffineModelDiscount"
 2437   discount'_ :: ((C2HSImp.Ptr (CAffineModel')) -> (C2HSImp.CDouble -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO C2HSImp.CDouble))))
 2438 
 2439 foreign import ccall safe "QuantLib/Model.chs.h qlAffineModelDiscountBond"
 2440   discountBond'_ :: ((C2HSImp.Ptr (CAffineModel')) -> (C2HSImp.CDouble -> (C2HSImp.CDouble -> (C2HSImp.CUInt -> ((C2HSImp.Ptr C2HSImp.CDouble) -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO C2HSImp.CDouble)))))))
 2441 
 2442 foreign import ccall safe "QuantLib/Model.chs.h qlAffineModelDiscountBondOption"
 2443   discountBondOption_'_ :: ((C2HSImp.Ptr (CAffineModel')) -> (C2HSImp.CInt -> (C2HSImp.CDouble -> (C2HSImp.CDouble -> (C2HSImp.CInt -> (C2HSImp.CDouble -> (C2HSImp.CDouble -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO C2HSImp.CDouble)))))))))
 2444 
 2445 foreign import ccall safe "QuantLib/Model.chs.h qlGaussian1dModelNumeraire"
 2446   numeraire'_ :: ((C2HSImp.Ptr (CGaussian1dModel')) -> (C2HSImp.CInt -> (C2HSImp.CDouble -> ((C2HSImp.Ptr (CYieldTermStructure')) -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO C2HSImp.CDouble))))))
 2447 
 2448 foreign import ccall safe "QuantLib/Model.chs.h qlGaussian1dModelZerobond"
 2449   gaussian1dZerobond'_ :: ((C2HSImp.Ptr (CGaussian1dModel')) -> (C2HSImp.CInt -> (C2HSImp.CInt -> (C2HSImp.CDouble -> ((C2HSImp.Ptr (CYieldTermStructure')) -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO C2HSImp.CDouble)))))))
 2450 
 2451 foreign import ccall safe "QuantLib/Model.chs.h qlGaussian1dModelZerobondOption"
 2452   gaussian1dZerobondOption'_ :: ((C2HSImp.Ptr (CGaussian1dModel')) -> (C2HSImp.CInt -> (C2HSImp.CInt -> (C2HSImp.CInt -> (C2HSImp.CInt -> (C2HSImp.CDouble -> (C2HSImp.CInt -> (C2HSImp.CDouble -> ((C2HSImp.Ptr (CYieldTermStructure')) -> (C2HSImp.CDouble -> (C2HSImp.CUInt -> (C2HSImp.CInt -> (C2HSImp.CInt -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO C2HSImp.CDouble)))))))))))))))
 2453 
 2454 foreign import ccall safe "QuantLib/Model.chs.h qlGaussian1dModelForwardRate"
 2455   gaussian1dForwardRate'_ :: ((C2HSImp.Ptr (CGaussian1dModel')) -> (C2HSImp.CInt -> (C2HSImp.CInt -> (C2HSImp.CDouble -> ((C2HSImp.Ptr (CIborIndex')) -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO C2HSImp.CDouble)))))))
 2456 
 2457 foreign import ccall safe "QuantLib/Model.chs.h qlGaussian1dModelSwapRate"
 2458   gaussian1dSwapRate'_ :: ((C2HSImp.Ptr (CGaussian1dModel')) -> (C2HSImp.CInt -> (C2HSImp.CInt -> (C2HSImp.CInt -> (C2HSImp.CInt -> (C2HSImp.CDouble -> ((C2HSImp.Ptr (CSwapIndex')) -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO C2HSImp.CDouble)))))))))
 2459 
 2460 foreign import ccall safe "QuantLib/Model.chs.h qlGaussian1dModelSwapAnnuity"
 2461   gaussian1dSwapAnnuity'_ :: ((C2HSImp.Ptr (CGaussian1dModel')) -> (C2HSImp.CInt -> (C2HSImp.CInt -> (C2HSImp.CInt -> (C2HSImp.CInt -> (C2HSImp.CDouble -> ((C2HSImp.Ptr (CSwapIndex')) -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO C2HSImp.CDouble)))))))))
 2462 
 2463 foreign import ccall safe "QuantLib/Model.chs.h qlGaussian1dModelYGrid"
 2464   gaussian1dYGrid'_ :: ((C2HSImp.Ptr (CGaussian1dModel')) -> (C2HSImp.CDouble -> (C2HSImp.CInt -> (C2HSImp.CDouble -> (C2HSImp.CDouble -> (C2HSImp.CDouble -> ((C2HSImp.Ptr C2HSImp.CUInt) -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CDouble)) -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO ()))))))))))
 2465 
 2466 foreign import ccall safe "QuantLib/Model.chs.h qlGaussian1dModelStateProcess"
 2467   stateProcess'_ :: ((C2HSImp.Ptr (CGaussian1dModel')) -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO (C2HSImp.Ptr (CStochasticProcess1D')))))
 2468 
 2469 foreign import ccall safe "QuantLib/Model.chs.h qlVarianceGammaModel"
 2470   varianceGammaModel'_ :: ((C2HSImp.Ptr (CVarianceGammaProcess')) -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO (C2HSImp.Ptr (CCalibratedModel')))))
 2471 
 2472 foreign import ccall safe "QuantLib/Model.chs.h qlVasicek"
 2473   vasicek'_ :: (C2HSImp.CDouble -> (C2HSImp.CDouble -> (C2HSImp.CDouble -> (C2HSImp.CDouble -> (C2HSImp.CDouble -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO (C2HSImp.Ptr (COneFactorAffineModel')))))))))
 2474 
 2475 foreign import ccall safe "QuantLib/Model.chs.h qlLiborForwardModel"
 2476   liborForwardModel'_ :: ((C2HSImp.Ptr (CLiborForwardModelProcess')) -> ((C2HSImp.Ptr (CLmVolatilityModel)) -> ((C2HSImp.Ptr (CLmCorrelationModel)) -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO (C2HSImp.Ptr (CLiborForwardModel')))))))
 2477 
 2478 foreign import ccall safe "QuantLib/Model.chs.h qlLiborForwardModelS0"
 2479   liborForwardModelS0'_ :: ((C2HSImp.Ptr (CLiborForwardModel')) -> (C2HSImp.CUInt -> (C2HSImp.CUInt -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO C2HSImp.CDouble)))))
 2480 
 2481 foreign import ccall safe "QuantLib/Model.chs.h qlLfmHullWhiteParameterization"
 2482   qlLfmHullWhiteParameterization'_ :: ((C2HSImp.Ptr (CLiborForwardModelProcess')) -> ((C2HSImp.Ptr (COptionletVolatilityStructure')) -> (C2HSImp.CUInt -> (C2HSImp.CUInt -> ((C2HSImp.Ptr C2HSImp.CDouble) -> (C2HSImp.CUInt -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO (C2HSImp.Ptr (CLfmHullWhiteParameterization))))))))))
 2483 
 2484 foreign import ccall safe "QuantLib/Model.chs.h qlLiborForwardModelProcessSetCovarParam"
 2485   setCovarParam'_ :: ((C2HSImp.Ptr (CLiborForwardModelProcess')) -> ((C2HSImp.Ptr (CLfmHullWhiteParameterization)) -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO ()))))
 2486 
 2487 foreign import ccall safe "QuantLib/Model.chs.h qlLfmHullWhiteCovariance"
 2488   qlLfmHullWhiteCovariance'_ :: ((C2HSImp.Ptr (CLfmHullWhiteParameterization)) -> (C2HSImp.CDouble -> (C2HSImp.CUInt -> ((C2HSImp.Ptr C2HSImp.CDouble) -> ((C2HSImp.Ptr C2HSImp.CUInt) -> ((C2HSImp.Ptr C2HSImp.CUInt) -> ((C2HSImp.Ptr C2HSImp.CUInt) -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CDouble)) -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO ()))))))))))
 2489 
 2490 foreign import ccall safe "QuantLib/Model.chs.h qlCalibratedModelCalibrate"
 2491   qlCalibratedModelCalibrate'_ :: ((C2HSImp.Ptr (CCalibratedModel')) -> (C2HSImp.CUInt -> ((C2HSImp.Ptr (C2HSImp.Ptr (CCalibrationHelper'))) -> (C2HSImp.CUInt -> ((C2HSImp.Ptr C2HSImp.CDouble) -> ((C2HSImp.Ptr (COptimizationMethod)) -> ((C2HSImp.Ptr (CEndCriteria)) -> ((C2HSImp.Ptr (CConstraint)) -> (C2HSImp.CUInt -> ((C2HSImp.Ptr C2HSImp.CInt) -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO ()))))))))))))
 2492 
 2493 foreign import ccall safe "QuantLib/Model.chs.h qlCalibratedModelValue"
 2494   value'_ :: ((C2HSImp.Ptr (CCalibratedModel')) -> (C2HSImp.CUInt -> ((C2HSImp.Ptr C2HSImp.CDouble) -> (C2HSImp.CUInt -> ((C2HSImp.Ptr (C2HSImp.Ptr (CCalibrationHelper'))) -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO C2HSImp.CDouble)))))))
 2495 
 2496 foreign import ccall safe "QuantLib/Model.chs.h qlCapHelper"
 2497   capHelper'_ :: (C2HSImp.CInt -> (C2HSImp.CInt -> ((C2HSImp.Ptr (CQuote')) -> ((C2HSImp.Ptr (CIborIndex')) -> (C2HSImp.CInt -> ((C2HSImp.Ptr (CDayCounter)) -> (C2HSImp.CInt -> ((C2HSImp.Ptr (CYieldTermStructure')) -> (C2HSImp.CInt -> (C2HSImp.CInt -> (C2HSImp.CDouble -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO (C2HSImp.Ptr (CBlackCalibrationHelper')))))))))))))))
 2498 
 2499 foreign import ccall safe "QuantLib/Model.chs.h qlHestonModelHelper"
 2500   hestonModelHelper'_ :: (C2HSImp.CInt -> (C2HSImp.CInt -> ((C2HSImp.Ptr (CCalendar)) -> ((C2HSImp.Ptr (CQuote')) -> (C2HSImp.CDouble -> ((C2HSImp.Ptr (CQuote')) -> ((C2HSImp.Ptr (CYieldTermStructure')) -> ((C2HSImp.Ptr (CYieldTermStructure')) -> (C2HSImp.CInt -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO (C2HSImp.Ptr (CBlackCalibrationHelper')))))))))))))
 2501 
 2502 foreign import ccall safe "QuantLib/Model.chs.h qlSwaptionHelper"
 2503   swaptionHelperTenorsRaw'_ :: (C2HSImp.CInt -> (C2HSImp.CInt -> (C2HSImp.CInt -> (C2HSImp.CInt -> ((C2HSImp.Ptr (CQuote')) -> ((C2HSImp.Ptr (CIborIndex')) -> (C2HSImp.CInt -> (C2HSImp.CInt -> ((C2HSImp.Ptr (CDayCounter)) -> ((C2HSImp.Ptr (CDayCounter)) -> ((C2HSImp.Ptr (CYieldTermStructure')) -> (C2HSImp.CInt -> (C2HSImp.CDouble -> (C2HSImp.CDouble -> (C2HSImp.CInt -> (C2HSImp.CDouble -> (C2HSImp.CUInt -> (C2HSImp.CInt -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO (C2HSImp.Ptr (CSwaptionHelper'))))))))))))))))))))))
 2504 
 2505 foreign import ccall safe "QuantLib/Model.chs.h qlSwaptionHelperFromDate"
 2506   swaptionHelperFromDateRaw'_ :: (C2HSImp.CInt -> (C2HSImp.CInt -> (C2HSImp.CInt -> ((C2HSImp.Ptr (CQuote')) -> ((C2HSImp.Ptr (CIborIndex')) -> (C2HSImp.CInt -> (C2HSImp.CInt -> ((C2HSImp.Ptr (CDayCounter)) -> ((C2HSImp.Ptr (CDayCounter)) -> ((C2HSImp.Ptr (CYieldTermStructure')) -> (C2HSImp.CInt -> (C2HSImp.CDouble -> (C2HSImp.CDouble -> (C2HSImp.CInt -> (C2HSImp.CDouble -> (C2HSImp.CUInt -> (C2HSImp.CInt -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO (C2HSImp.Ptr (CSwaptionHelper')))))))))))))))))))))
 2507 
 2508 foreign import ccall safe "QuantLib/Model.chs.h qlSwaptionHelperFromDates"
 2509   swaptionHelperFromDatesRaw'_ :: (C2HSImp.CInt -> (C2HSImp.CInt -> ((C2HSImp.Ptr (CQuote')) -> ((C2HSImp.Ptr (CIborIndex')) -> (C2HSImp.CInt -> (C2HSImp.CInt -> ((C2HSImp.Ptr (CDayCounter)) -> ((C2HSImp.Ptr (CDayCounter)) -> ((C2HSImp.Ptr (CYieldTermStructure')) -> (C2HSImp.CInt -> (C2HSImp.CDouble -> (C2HSImp.CDouble -> (C2HSImp.CInt -> (C2HSImp.CDouble -> (C2HSImp.CUInt -> (C2HSImp.CInt -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO (C2HSImp.Ptr (CSwaptionHelper'))))))))))))))))))))
 2510 
 2511 foreign import ccall safe "QuantLib/Model.chs.h qlSwaptionHelperSwaption"
 2512   helperSwaption'_ :: ((C2HSImp.Ptr (CSwaptionHelper')) -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO (C2HSImp.Ptr (CSwaption')))))
 2513 
 2514 foreign import ccall safe "QuantLib/Model.chs.h qlBlackCalibrationHelperTimes"
 2515   times'_ :: ((C2HSImp.Ptr (CBlackCalibrationHelper')) -> ((C2HSImp.Ptr C2HSImp.CUInt) -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CDouble)) -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO ())))))
 2516 
 2517 foreign import ccall safe "QuantLib/Model.chs.h qlCalibratedModelParams"
 2518   params'_ :: ((C2HSImp.Ptr (CCalibratedModel')) -> ((C2HSImp.Ptr C2HSImp.CUInt) -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CDouble)) -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO ())))))
 2519 
 2520 foreign import ccall safe "QuantLib/Model.chs.h qlCalibratedModelSetParams"
 2521   setParams'_ :: ((C2HSImp.Ptr (CCalibratedModel')) -> (C2HSImp.CUInt -> ((C2HSImp.Ptr C2HSImp.CDouble) -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO ())))))
 2522 
 2523 foreign import ccall safe "QuantLib/Model.chs.h qlBlackCalibrationHelperBlackPrice"
 2524   blackPrice'_ :: ((C2HSImp.Ptr (CBlackCalibrationHelper')) -> (C2HSImp.CDouble -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO C2HSImp.CDouble))))
 2525 
 2526 foreign import ccall safe "QuantLib/Model.chs.h qlBlackCalibrationHelperCalibrationError"
 2527   calibrationError'_ :: ((C2HSImp.Ptr (CBlackCalibrationHelper')) -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO C2HSImp.CDouble)))
 2528 
 2529 foreign import ccall safe "QuantLib/Model.chs.h qlBlackCalibrationHelperImpliedVolatility"
 2530   impliedVolatility'_ :: ((C2HSImp.Ptr (CBlackCalibrationHelper')) -> (C2HSImp.CDouble -> (C2HSImp.CDouble -> (C2HSImp.CUInt -> (C2HSImp.CDouble -> (C2HSImp.CDouble -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO C2HSImp.CDouble))))))))
 2531 
 2532 foreign import ccall safe "QuantLib/Model.chs.h qlBlackCalibrationHelperMarketValue"
 2533   marketValue'_ :: ((C2HSImp.Ptr (CBlackCalibrationHelper')) -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO C2HSImp.CDouble)))
 2534 
 2535 foreign import ccall safe "QuantLib/Model.chs.h qlBlackCalibrationHelperModelValue"
 2536   modelValue'_ :: ((C2HSImp.Ptr (CBlackCalibrationHelper')) -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO C2HSImp.CDouble)))
 2537 
 2538 foreign import ccall safe "QuantLib/Model.chs.h qlBlackCalibrationHelperVolatility"
 2539   volatility'_ :: ((C2HSImp.Ptr (CBlackCalibrationHelper')) -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO (C2HSImp.Ptr (CQuote')))))
 2540 
 2541 foreign import ccall safe "QuantLib/Model.chs.h qlBlackCalibrationHelperSetPricingEngine"
 2542   setPricingEngine'_ :: ((C2HSImp.Ptr (CBlackCalibrationHelper')) -> ((C2HSImp.Ptr (CPricingEngine')) -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO ()))))
 2543 
 2544 foreign import ccall safe "QuantLib/Model.chs.h qlGarch11"
 2545   garch11'_ :: (C2HSImp.CDouble -> (C2HSImp.CDouble -> (C2HSImp.CDouble -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO (C2HSImp.Ptr (CGarch11)))))))
 2546 
 2547 foreign import ccall safe "QuantLib/Model.chs.h qlGarch11Calibrated"
 2548   qlGarch11Calibrated'_ :: (C2HSImp.CUInt -> ((C2HSImp.Ptr C2HSImp.CInt) -> (C2HSImp.CUInt -> ((C2HSImp.Ptr C2HSImp.CDouble) -> (C2HSImp.CInt -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO (C2HSImp.Ptr (CGarch11)))))))))
 2549 
 2550 foreign import ccall safe "QuantLib/Model.chs.h qlGarch11Alpha"
 2551   alpha'_ :: ((C2HSImp.Ptr (CGarch11)) -> (IO C2HSImp.CDouble))
 2552 
 2553 foreign import ccall safe "QuantLib/Model.chs.h qlGarch11Beta"
 2554   beta'_ :: ((C2HSImp.Ptr (CGarch11)) -> (IO C2HSImp.CDouble))
 2555 
 2556 foreign import ccall safe "QuantLib/Model.chs.h qlGarch11Omega"
 2557   omega'_ :: ((C2HSImp.Ptr (CGarch11)) -> (IO C2HSImp.CDouble))
 2558 
 2559 foreign import ccall safe "QuantLib/Model.chs.h qlGarch11LtVol"
 2560   longTermVolatility'_ :: ((C2HSImp.Ptr (CGarch11)) -> (IO C2HSImp.CDouble))
 2561 
 2562 foreign import ccall safe "QuantLib/Model.chs.h qlGarch11LogLikelihood"
 2563   logLikelihood'_ :: ((C2HSImp.Ptr (CGarch11)) -> (IO C2HSImp.CDouble))
 2564 
 2565 foreign import ccall safe "QuantLib/Model.chs.h qlGarch11Forecast"
 2566   forecast'_ :: ((C2HSImp.Ptr (CGarch11)) -> (C2HSImp.CDouble -> (C2HSImp.CDouble -> (IO C2HSImp.CDouble))))
 2567 
 2568 foreign import ccall safe "QuantLib/Model.chs.h qlGarch11Calculate"
 2569   qlGarch11Calculate'_ :: ((C2HSImp.Ptr (CGarch11)) -> (C2HSImp.CUInt -> ((C2HSImp.Ptr C2HSImp.CInt) -> (C2HSImp.CUInt -> ((C2HSImp.Ptr C2HSImp.CDouble) -> ((C2HSImp.Ptr C2HSImp.CUInt) -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CInt)) -> ((C2HSImp.Ptr C2HSImp.CUInt) -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CDouble)) -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO ())))))))))))
 2570 
 2571 foreign import ccall safe "QuantLib/Model.chs.h qlGarmanKlassSimpleSigma"
 2572   qlGarmanKlassSimpleSigma'_ :: (C2HSImp.CDouble -> (C2HSImp.CUInt -> ((C2HSImp.Ptr C2HSImp.CInt) -> (C2HSImp.CUInt -> ((C2HSImp.Ptr C2HSImp.CDouble) -> (C2HSImp.CUInt -> ((C2HSImp.Ptr C2HSImp.CDouble) -> (C2HSImp.CUInt -> ((C2HSImp.Ptr C2HSImp.CDouble) -> (C2HSImp.CUInt -> ((C2HSImp.Ptr C2HSImp.CDouble) -> ((C2HSImp.Ptr C2HSImp.CUInt) -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CInt)) -> ((C2HSImp.Ptr C2HSImp.CUInt) -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CDouble)) -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO ())))))))))))))))))
 2573 
 2574 foreign import ccall safe "QuantLib/Model.chs.h qlGarmanKlassSigma1"
 2575   qlGarmanKlassSigma1'_ :: (C2HSImp.CDouble -> (C2HSImp.CDouble -> (C2HSImp.CUInt -> ((C2HSImp.Ptr C2HSImp.CInt) -> (C2HSImp.CUInt -> ((C2HSImp.Ptr C2HSImp.CDouble) -> (C2HSImp.CUInt -> ((C2HSImp.Ptr C2HSImp.CDouble) -> (C2HSImp.CUInt -> ((C2HSImp.Ptr C2HSImp.CDouble) -> (C2HSImp.CUInt -> ((C2HSImp.Ptr C2HSImp.CDouble) -> ((C2HSImp.Ptr C2HSImp.CUInt) -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CInt)) -> ((C2HSImp.Ptr C2HSImp.CUInt) -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CDouble)) -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO ()))))))))))))))))))
 2576 
 2577 foreign import ccall safe "QuantLib/Model.chs.h qlParkinsonSigma"
 2578   qlParkinsonSigma'_ :: (C2HSImp.CDouble -> (C2HSImp.CUInt -> ((C2HSImp.Ptr C2HSImp.CInt) -> (C2HSImp.CUInt -> ((C2HSImp.Ptr C2HSImp.CDouble) -> (C2HSImp.CUInt -> ((C2HSImp.Ptr C2HSImp.CDouble) -> (C2HSImp.CUInt -> ((C2HSImp.Ptr C2HSImp.CDouble) -> (C2HSImp.CUInt -> ((C2HSImp.Ptr C2HSImp.CDouble) -> ((C2HSImp.Ptr C2HSImp.CUInt) -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CInt)) -> ((C2HSImp.Ptr C2HSImp.CUInt) -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CDouble)) -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO ())))))))))))))))))
 2579 
 2580 foreign import ccall safe "QuantLib/Model.chs.h qlGarmanKlassSigma3"
 2581   qlGarmanKlassSigma3'_ :: (C2HSImp.CDouble -> (C2HSImp.CDouble -> (C2HSImp.CUInt -> ((C2HSImp.Ptr C2HSImp.CInt) -> (C2HSImp.CUInt -> ((C2HSImp.Ptr C2HSImp.CDouble) -> (C2HSImp.CUInt -> ((C2HSImp.Ptr C2HSImp.CDouble) -> (C2HSImp.CUInt -> ((C2HSImp.Ptr C2HSImp.CDouble) -> (C2HSImp.CUInt -> ((C2HSImp.Ptr C2HSImp.CDouble) -> ((C2HSImp.Ptr C2HSImp.CUInt) -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CInt)) -> ((C2HSImp.Ptr C2HSImp.CUInt) -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CDouble)) -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO ()))))))))))))))))))
 2582 
 2583 foreign import ccall safe "QuantLib/Model.chs.h qlGarmanKlassSigma4"
 2584   qlGarmanKlassSigma4'_ :: (C2HSImp.CDouble -> (C2HSImp.CUInt -> ((C2HSImp.Ptr C2HSImp.CInt) -> (C2HSImp.CUInt -> ((C2HSImp.Ptr C2HSImp.CDouble) -> (C2HSImp.CUInt -> ((C2HSImp.Ptr C2HSImp.CDouble) -> (C2HSImp.CUInt -> ((C2HSImp.Ptr C2HSImp.CDouble) -> (C2HSImp.CUInt -> ((C2HSImp.Ptr C2HSImp.CDouble) -> ((C2HSImp.Ptr C2HSImp.CUInt) -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CInt)) -> ((C2HSImp.Ptr C2HSImp.CUInt) -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CDouble)) -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO ())))))))))))))))))
 2585 
 2586 foreign import ccall safe "QuantLib/Model.chs.h qlGarmanKlassSigma5"
 2587   qlGarmanKlassSigma5'_ :: (C2HSImp.CDouble -> (C2HSImp.CUInt -> ((C2HSImp.Ptr C2HSImp.CInt) -> (C2HSImp.CUInt -> ((C2HSImp.Ptr C2HSImp.CDouble) -> (C2HSImp.CUInt -> ((C2HSImp.Ptr C2HSImp.CDouble) -> (C2HSImp.CUInt -> ((C2HSImp.Ptr C2HSImp.CDouble) -> (C2HSImp.CUInt -> ((C2HSImp.Ptr C2HSImp.CDouble) -> ((C2HSImp.Ptr C2HSImp.CUInt) -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CInt)) -> ((C2HSImp.Ptr C2HSImp.CUInt) -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CDouble)) -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO ())))))))))))))))))
 2588 
 2589 foreign import ccall safe "QuantLib/Model.chs.h qlGarmanKlassSigma6"
 2590   qlGarmanKlassSigma6'_ :: (C2HSImp.CDouble -> (C2HSImp.CDouble -> (C2HSImp.CUInt -> ((C2HSImp.Ptr C2HSImp.CInt) -> (C2HSImp.CUInt -> ((C2HSImp.Ptr C2HSImp.CDouble) -> (C2HSImp.CUInt -> ((C2HSImp.Ptr C2HSImp.CDouble) -> (C2HSImp.CUInt -> ((C2HSImp.Ptr C2HSImp.CDouble) -> (C2HSImp.CUInt -> ((C2HSImp.Ptr C2HSImp.CDouble) -> ((C2HSImp.Ptr C2HSImp.CUInt) -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CInt)) -> ((C2HSImp.Ptr C2HSImp.CUInt) -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CDouble)) -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO ()))))))))))))))))))
 2591 
 2592 foreign import ccall safe "QuantLib/Model.chs.h qlConstantVolatilityEstimator"
 2593   qlConstantVolatilityEstimator'_ :: (C2HSImp.CUInt -> (C2HSImp.CUInt -> ((C2HSImp.Ptr C2HSImp.CInt) -> (C2HSImp.CUInt -> ((C2HSImp.Ptr C2HSImp.CDouble) -> ((C2HSImp.Ptr C2HSImp.CUInt) -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CInt)) -> ((C2HSImp.Ptr C2HSImp.CUInt) -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CDouble)) -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO ())))))))))))
 2594 
 2595 foreign import ccall safe "QuantLib/Model.chs.h qlSimpleLocalVolatilityEstimator"
 2596   qlSimpleLocalVolatilityEstimator'_ :: (C2HSImp.CDouble -> (C2HSImp.CUInt -> ((C2HSImp.Ptr C2HSImp.CInt) -> (C2HSImp.CUInt -> ((C2HSImp.Ptr C2HSImp.CDouble) -> ((C2HSImp.Ptr C2HSImp.CUInt) -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CInt)) -> ((C2HSImp.Ptr C2HSImp.CUInt) -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CDouble)) -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO ())))))))))))
 2597 
 2598 foreign import ccall safe "QuantLib/Model.chs.h qlGaussian1dModelCompoundedRate"
 2599   gaussian1dCompoundedRate'_ :: ((C2HSImp.Ptr (CGaussian1dModel')) -> ((C2HSImp.Ptr (COvernightIndexedCoupon')) -> (C2HSImp.CInt -> (C2HSImp.CDouble -> ((C2HSImp.Ptr (CYieldTermStructure')) -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO C2HSImp.CDouble)))))))
 2600 
 2601 foreign import ccall safe "QuantLib/Model.chs.h qlRoughHestonModel"
 2602   roughHestonModel'_ :: ((C2HSImp.Ptr (CHestonProcess')) -> (C2HSImp.CDouble -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO (C2HSImp.Ptr (CRoughHestonModel'))))))
 2603 
 2604 foreign import ccall safe "QuantLib/Model.chs.h qlRoughHestonModelTheta"
 2605   roughHestonTheta'_ :: ((C2HSImp.Ptr (CRoughHestonModel')) -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO C2HSImp.CDouble)))
 2606 
 2607 foreign import ccall safe "QuantLib/Model.chs.h qlRoughHestonModelKappa"
 2608   roughHestonKappa'_ :: ((C2HSImp.Ptr (CRoughHestonModel')) -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO C2HSImp.CDouble)))
 2609 
 2610 foreign import ccall safe "QuantLib/Model.chs.h qlRoughHestonModelSigma"
 2611   roughHestonSigma'_ :: ((C2HSImp.Ptr (CRoughHestonModel')) -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO C2HSImp.CDouble)))
 2612 
 2613 foreign import ccall safe "QuantLib/Model.chs.h qlRoughHestonModelRho"
 2614   roughHestonRho'_ :: ((C2HSImp.Ptr (CRoughHestonModel')) -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO C2HSImp.CDouble)))
 2615 
 2616 foreign import ccall safe "QuantLib/Model.chs.h qlRoughHestonModelV0"
 2617   roughHestonV0'_ :: ((C2HSImp.Ptr (CRoughHestonModel')) -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO C2HSImp.CDouble)))
 2618 
 2619 foreign import ccall safe "QuantLib/Model.chs.h qlRoughHestonModelHurst"
 2620   roughHestonHurst'_ :: ((C2HSImp.Ptr (CRoughHestonModel')) -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO C2HSImp.CDouble)))
 2621 
 2622 foreign import ccall safe "QuantLib/Model.chs.h qlRoughHestonModelProcess"
 2623   roughHestonProcess'_ :: ((C2HSImp.Ptr (CRoughHestonModel')) -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO (C2HSImp.Ptr (CHestonProcess')))))