-- GENERATED by C->Haskell Compiler, version 0.28.8 Switcheroo, 25 November 2017 (Haskell)
-- Edit the ORIGNAL .chs file instead!


{-# LINE 1 "./QuantLib/Model.chs" #-}
{-# LANGUAGE FlexibleInstances #-}
-- |Historical volatility estimators bound here (@ql\/models\/volatility@, @ql\/prices.hpp@) --
-- 'Garch11', GarmanKlass\/Parkinson, 'ConstantEstimator', 'SimpleLocalEstimator' -- are distinct
-- from "QuantLib.TermStructure.Volatility", which covers forward-looking implied-volatility
-- surfaces and smiles. None of these classes have any calculations of their own beyond a single
-- @calculate@ call and are never needed as an argument type elsewhere, so only 'Garch11' --
-- whose calibrated state ('alpha' etc.) is queried repeatedly -- gets a dedicated Haskell type;
-- every GarmanKlass variant, 'ConstantEstimator', and 'SimpleLocalEstimator' are bound as a
-- single construct-and-calculate function each.
module QuantLib.Model
  (
    -- * Types
    -- ** Model hierarchy
    GenCalibratedModel
  , CalibratedModel
  , GenShortRateModel
  , ShortRateModel
  , GenOneFactorAffineModel
  , OneFactorAffineModel
  , HullWhite
  , G2
  , GenHestonModel
  , HestonModel
  , RoughHestonModel
  , PiecewiseTimeDependentHestonModel
  , GenBatesModel
  , BatesModel
  , BatesDetJumpModel
  , GenBatesDoubleExpModel
  , BatesDoubleExpModel
  , BatesDoubleExpDetJumpModel
  , GJRGARCHModel
  , Gaussian1dModel
  , Gsr
  , MarkovFunctional
  , LiborForwardModel
  , HestonSLVMCModel
  , HestonSLVFDMModel
  , AffineModel
  , ShortRateDynamics

    -- ** Historical volatility estimators
  , Garch11
  , Garch11Mode(..)

    -- ** Calibration helpers
  , GenCalibrationHelper
  , CalibrationHelper
  , GenBlackCalibrationHelper
  , BlackCalibrationHelper
  , SwaptionHelper
  , BrownianGeneratorFactory

    -- ** Configuration
  , CalibrationErrorType(..)
  , SobolBrownianOrdering(..)
  , HestonSLVGreensAlgorithm(..)
  , HestonSLVVarianceTransformation(..)
  , HestonSLVFokkerPlanckFdmParams(..)
  , HestonSLVFDMLogEntry(..)
  , LfmHullWhiteParameterization
  , LmCorrelationModel(..)
  , LmVolatilityModel(..)
  , SwaptionSpan(..)

    -- * Constructors
    -- ** Hierarchy and secondary-interface conversion
  , AsAffineModel(..)
  , AsGaussian1dModel(..)
  , asCalibratedModel
  , asHestonModel
  , asShortRateModel
  , asOneFactorAffineModel
  , asBatesModel
  , asBatesDoubleExpModel
  , asCalibrationHelper
  , asBlackCalibrationHelper

    -- ** Model construction
  , batesModel
  , blackKarasinski
  , coxIngersollRoss
  , extendedCoxIngersollRoss
  , g2
  , generalizedHullWhite
  , gjrGarchModel
  , hestonModel
  , roughHestonModel
  , mtBrownianGeneratorFactory
  , sobolBrownianGeneratorFactory
  , hestonSlvMcModel
  , hestonSlvFdmModel
  , hullWhite
  , varianceGammaModel
  , vasicek
  , liborForwardModel
  , lfmHullWhiteParameterization
  , gsr
  , gsrWithReversions
  , markovFunctional
  , markovFunctionalCaplet
  , garch11
  , garch11Calibrated

    -- ** Calibration helpers
  , capHelper
  , hestonModelHelper
  , swaptionHelper

    -- * Mutators
  , setCovarParam
  , calibrate
  , calibrateVolatilitiesIterative
  , calibrateReversionsIterative
  , moveVolatility
  , moveReversion
  , setPricingEngine
  , setParams

    -- * Inspectors
    -- ** Pricing and rate calculations
  , discount
  , discountBond
  , discountBondOption
  , convexityBias
  , numeraire
  , gaussian1dZerobond
  , gaussian1dZerobondOption
  , gaussian1dCompoundedRate
  , gaussian1dForwardRate
  , gaussian1dSwapRate
  , gaussian1dSwapAnnuity
  , gaussian1dYGrid
  , lfmHullWhiteCovariance
  , liborForwardModelS0
  , blackPrice
  , impliedVolatility

    -- ** Model state and calibration
  , roughHestonTheta
  , roughHestonKappa
  , roughHestonSigma
  , roughHestonRho
  , roughHestonV0
  , roughHestonHurst
  , roughHestonProcess
  , HasLeverageFunction(..)
  , HasVolatilities(..)
  , reversions
  , HasHelperUnderlying(..)
  , g2Dynamics
  , shortRate
  , stateProcess
  , hestonSlvFdmLogEntries
  , helperSwaption
  , times
  , fixedReversion
  , params
  , value
  , calibrationError
  , marketValue
  , modelValue
  , volatility

    -- ** Historical volatility
  , forecast
  , calculate
  , garmanKlassSimpleSigma
  , garmanKlassSigma1
  , parkinsonSigma
  , garmanKlassSigma3
  , garmanKlassSigma4
  , garmanKlassSigma5
  , garmanKlassSigma6
  , constantVolatilityEstimator
  , simpleLocalVolatilityEstimator
  , alpha
  , beta
  , omega
  , longTermVolatility
  , logLikelihood
  ) where
import qualified Foreign.C.Types as C2HSImp
import qualified Foreign.ForeignPtr as C2HSImp
import qualified Foreign.Marshal.Utils as C2HSImp
import qualified Foreign.Ptr as C2HSImp
import qualified System.IO.Unsafe as C2HSImp









{-# LINE 189 "./QuantLib/Model.chs" #-}


import QuantLib.Internal
import QuantLib.Time.Schedule(Frequency)
import QuantLib.InterestRate(VolatilityType)
import QuantLib.CashFlow(RateAveragingType)
import QuantLib.Internal.Type
import QuantLib.Internal.Common
import QuantLib.TermStructure(HasHelperUnderlying(..))
import QuantLib.Math(SobolDirectionIntegers)
import Data.List(genericTake)
import Data.List.NonEmpty(NonEmpty, toList)
import Data.Maybe(fromMaybe)

data CalibrationErrorType = RelativePriceError
                          | PriceError
                          | ImpliedVolError
  deriving (Int -> CalibrationErrorType
CalibrationErrorType -> Int
CalibrationErrorType -> [CalibrationErrorType]
CalibrationErrorType -> CalibrationErrorType
CalibrationErrorType
-> CalibrationErrorType -> [CalibrationErrorType]
CalibrationErrorType
-> CalibrationErrorType
-> CalibrationErrorType
-> [CalibrationErrorType]
(CalibrationErrorType -> CalibrationErrorType)
-> (CalibrationErrorType -> CalibrationErrorType)
-> (Int -> CalibrationErrorType)
-> (CalibrationErrorType -> Int)
-> (CalibrationErrorType -> [CalibrationErrorType])
-> (CalibrationErrorType
    -> CalibrationErrorType -> [CalibrationErrorType])
-> (CalibrationErrorType
    -> CalibrationErrorType -> [CalibrationErrorType])
-> (CalibrationErrorType
    -> CalibrationErrorType
    -> CalibrationErrorType
    -> [CalibrationErrorType])
-> Enum CalibrationErrorType
forall a.
(a -> a)
-> (a -> a)
-> (Int -> a)
-> (a -> Int)
-> (a -> [a])
-> (a -> a -> [a])
-> (a -> a -> [a])
-> (a -> a -> a -> [a])
-> Enum a
$csucc :: CalibrationErrorType -> CalibrationErrorType
succ :: CalibrationErrorType -> CalibrationErrorType
$cpred :: CalibrationErrorType -> CalibrationErrorType
pred :: CalibrationErrorType -> CalibrationErrorType
$ctoEnum :: Int -> CalibrationErrorType
toEnum :: Int -> CalibrationErrorType
$cfromEnum :: CalibrationErrorType -> Int
fromEnum :: CalibrationErrorType -> Int
$cenumFrom :: CalibrationErrorType -> [CalibrationErrorType]
enumFrom :: CalibrationErrorType -> [CalibrationErrorType]
$cenumFromThen :: CalibrationErrorType
-> CalibrationErrorType -> [CalibrationErrorType]
enumFromThen :: CalibrationErrorType
-> CalibrationErrorType -> [CalibrationErrorType]
$cenumFromTo :: CalibrationErrorType
-> CalibrationErrorType -> [CalibrationErrorType]
enumFromTo :: CalibrationErrorType
-> CalibrationErrorType -> [CalibrationErrorType]
$cenumFromThenTo :: CalibrationErrorType
-> CalibrationErrorType
-> CalibrationErrorType
-> [CalibrationErrorType]
enumFromThenTo :: CalibrationErrorType
-> CalibrationErrorType
-> CalibrationErrorType
-> [CalibrationErrorType]
Enum,Int -> CalibrationErrorType -> ShowS
[CalibrationErrorType] -> ShowS
CalibrationErrorType -> String
(Int -> CalibrationErrorType -> ShowS)
-> (CalibrationErrorType -> String)
-> ([CalibrationErrorType] -> ShowS)
-> Show CalibrationErrorType
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> CalibrationErrorType -> ShowS
showsPrec :: Int -> CalibrationErrorType -> ShowS
$cshow :: CalibrationErrorType -> String
show :: CalibrationErrorType -> String
$cshowList :: [CalibrationErrorType] -> ShowS
showList :: [CalibrationErrorType] -> ShowS
Show,CalibrationErrorType -> CalibrationErrorType -> Bool
(CalibrationErrorType -> CalibrationErrorType -> Bool)
-> (CalibrationErrorType -> CalibrationErrorType -> Bool)
-> Eq CalibrationErrorType
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: CalibrationErrorType -> CalibrationErrorType -> Bool
== :: CalibrationErrorType -> CalibrationErrorType -> Bool
$c/= :: CalibrationErrorType -> CalibrationErrorType -> Bool
/= :: CalibrationErrorType -> CalibrationErrorType -> Bool
Eq,ReadPrec [CalibrationErrorType]
ReadPrec CalibrationErrorType
Int -> ReadS CalibrationErrorType
ReadS [CalibrationErrorType]
(Int -> ReadS CalibrationErrorType)
-> ReadS [CalibrationErrorType]
-> ReadPrec CalibrationErrorType
-> ReadPrec [CalibrationErrorType]
-> Read CalibrationErrorType
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
$creadsPrec :: Int -> ReadS CalibrationErrorType
readsPrec :: Int -> ReadS CalibrationErrorType
$creadList :: ReadS [CalibrationErrorType]
readList :: ReadS [CalibrationErrorType]
$creadPrec :: ReadPrec CalibrationErrorType
readPrec :: ReadPrec CalibrationErrorType
$creadListPrec :: ReadPrec [CalibrationErrorType]
readListPrec :: ReadPrec [CalibrationErrorType]
Read)

{-# LINE 203 "./QuantLib/Model.chs" #-}

data Garch11Mode = MomentMatchingGuess
                 | GammaGuess
                 | BestOfTwo
                 | DoubleOptimization
  deriving (Int -> Garch11Mode
Garch11Mode -> Int
Garch11Mode -> [Garch11Mode]
Garch11Mode -> Garch11Mode
Garch11Mode -> Garch11Mode -> [Garch11Mode]
Garch11Mode -> Garch11Mode -> Garch11Mode -> [Garch11Mode]
(Garch11Mode -> Garch11Mode)
-> (Garch11Mode -> Garch11Mode)
-> (Int -> Garch11Mode)
-> (Garch11Mode -> Int)
-> (Garch11Mode -> [Garch11Mode])
-> (Garch11Mode -> Garch11Mode -> [Garch11Mode])
-> (Garch11Mode -> Garch11Mode -> [Garch11Mode])
-> (Garch11Mode -> Garch11Mode -> Garch11Mode -> [Garch11Mode])
-> Enum Garch11Mode
forall a.
(a -> a)
-> (a -> a)
-> (Int -> a)
-> (a -> Int)
-> (a -> [a])
-> (a -> a -> [a])
-> (a -> a -> [a])
-> (a -> a -> a -> [a])
-> Enum a
$csucc :: Garch11Mode -> Garch11Mode
succ :: Garch11Mode -> Garch11Mode
$cpred :: Garch11Mode -> Garch11Mode
pred :: Garch11Mode -> Garch11Mode
$ctoEnum :: Int -> Garch11Mode
toEnum :: Int -> Garch11Mode
$cfromEnum :: Garch11Mode -> Int
fromEnum :: Garch11Mode -> Int
$cenumFrom :: Garch11Mode -> [Garch11Mode]
enumFrom :: Garch11Mode -> [Garch11Mode]
$cenumFromThen :: Garch11Mode -> Garch11Mode -> [Garch11Mode]
enumFromThen :: Garch11Mode -> Garch11Mode -> [Garch11Mode]
$cenumFromTo :: Garch11Mode -> Garch11Mode -> [Garch11Mode]
enumFromTo :: Garch11Mode -> Garch11Mode -> [Garch11Mode]
$cenumFromThenTo :: Garch11Mode -> Garch11Mode -> Garch11Mode -> [Garch11Mode]
enumFromThenTo :: Garch11Mode -> Garch11Mode -> Garch11Mode -> [Garch11Mode]
Enum,Int -> Garch11Mode -> ShowS
[Garch11Mode] -> ShowS
Garch11Mode -> String
(Int -> Garch11Mode -> ShowS)
-> (Garch11Mode -> String)
-> ([Garch11Mode] -> ShowS)
-> Show Garch11Mode
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> Garch11Mode -> ShowS
showsPrec :: Int -> Garch11Mode -> ShowS
$cshow :: Garch11Mode -> String
show :: Garch11Mode -> String
$cshowList :: [Garch11Mode] -> ShowS
showList :: [Garch11Mode] -> ShowS
Show,Garch11Mode -> Garch11Mode -> Bool
(Garch11Mode -> Garch11Mode -> Bool)
-> (Garch11Mode -> Garch11Mode -> Bool) -> Eq Garch11Mode
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: Garch11Mode -> Garch11Mode -> Bool
== :: Garch11Mode -> Garch11Mode -> Bool
$c/= :: Garch11Mode -> Garch11Mode -> Bool
/= :: Garch11Mode -> Garch11Mode -> Bool
Eq,ReadPrec [Garch11Mode]
ReadPrec Garch11Mode
Int -> ReadS Garch11Mode
ReadS [Garch11Mode]
(Int -> ReadS Garch11Mode)
-> ReadS [Garch11Mode]
-> ReadPrec Garch11Mode
-> ReadPrec [Garch11Mode]
-> Read Garch11Mode
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
$creadsPrec :: Int -> ReadS Garch11Mode
readsPrec :: Int -> ReadS Garch11Mode
$creadList :: ReadS [Garch11Mode]
readList :: ReadS [Garch11Mode]
$creadPrec :: ReadPrec Garch11Mode
readPrec :: ReadPrec Garch11Mode
$creadListPrec :: ReadPrec [Garch11Mode]
readListPrec :: ReadPrec [Garch11Mode]
Read)

{-# LINE 204 "./QuantLib/Model.chs" #-}


-- |Sobol Brownian-bridge coordinate ordering.
data SobolBrownianOrdering = Factors | Steps | Diagonal deriving (Show, Eq, Read, Enum, Bounded)

-- |Initial-density approximation used by the Heston SLV Fokker--Planck calibrator.
data HestonSLVGreensAlgorithm = ZeroCorrelation | Gaussian | SemiAnalytical deriving (Show, Eq, Read, Enum, Bounded)

-- |Variance-coordinate transformation used by the Heston SLV Fokker--Planck calibrator.
data HestonSLVVarianceTransformation = Plain | Power | Log deriving (Int -> HestonSLVVarianceTransformation -> ShowS
[HestonSLVVarianceTransformation] -> ShowS
HestonSLVVarianceTransformation -> String
(Int -> HestonSLVVarianceTransformation -> ShowS)
-> (HestonSLVVarianceTransformation -> String)
-> ([HestonSLVVarianceTransformation] -> ShowS)
-> Show HestonSLVVarianceTransformation
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> HestonSLVVarianceTransformation -> ShowS
showsPrec :: Int -> HestonSLVVarianceTransformation -> ShowS
$cshow :: HestonSLVVarianceTransformation -> String
show :: HestonSLVVarianceTransformation -> String
$cshowList :: [HestonSLVVarianceTransformation] -> ShowS
showList :: [HestonSLVVarianceTransformation] -> ShowS
Show, HestonSLVVarianceTransformation
-> HestonSLVVarianceTransformation -> Bool
(HestonSLVVarianceTransformation
 -> HestonSLVVarianceTransformation -> Bool)
-> (HestonSLVVarianceTransformation
    -> HestonSLVVarianceTransformation -> Bool)
-> Eq HestonSLVVarianceTransformation
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: HestonSLVVarianceTransformation
-> HestonSLVVarianceTransformation -> Bool
== :: HestonSLVVarianceTransformation
-> HestonSLVVarianceTransformation -> Bool
$c/= :: HestonSLVVarianceTransformation
-> HestonSLVVarianceTransformation -> Bool
/= :: HestonSLVVarianceTransformation
-> HestonSLVVarianceTransformation -> Bool
Eq, ReadPrec [HestonSLVVarianceTransformation]
ReadPrec HestonSLVVarianceTransformation
Int -> ReadS HestonSLVVarianceTransformation
ReadS [HestonSLVVarianceTransformation]
(Int -> ReadS HestonSLVVarianceTransformation)
-> ReadS [HestonSLVVarianceTransformation]
-> ReadPrec HestonSLVVarianceTransformation
-> ReadPrec [HestonSLVVarianceTransformation]
-> Read HestonSLVVarianceTransformation
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
$creadsPrec :: Int -> ReadS HestonSLVVarianceTransformation
readsPrec :: Int -> ReadS HestonSLVVarianceTransformation
$creadList :: ReadS [HestonSLVVarianceTransformation]
readList :: ReadS [HestonSLVVarianceTransformation]
$creadPrec :: ReadPrec HestonSLVVarianceTransformation
readPrec :: ReadPrec HestonSLVVarianceTransformation
$creadListPrec :: ReadPrec [HestonSLVVarianceTransformation]
readListPrec :: ReadPrec [HestonSLVVarianceTransformation]
Read, Int -> HestonSLVVarianceTransformation
HestonSLVVarianceTransformation -> Int
HestonSLVVarianceTransformation
-> [HestonSLVVarianceTransformation]
HestonSLVVarianceTransformation -> HestonSLVVarianceTransformation
HestonSLVVarianceTransformation
-> HestonSLVVarianceTransformation
-> [HestonSLVVarianceTransformation]
HestonSLVVarianceTransformation
-> HestonSLVVarianceTransformation
-> HestonSLVVarianceTransformation
-> [HestonSLVVarianceTransformation]
(HestonSLVVarianceTransformation
 -> HestonSLVVarianceTransformation)
-> (HestonSLVVarianceTransformation
    -> HestonSLVVarianceTransformation)
-> (Int -> HestonSLVVarianceTransformation)
-> (HestonSLVVarianceTransformation -> Int)
-> (HestonSLVVarianceTransformation
    -> [HestonSLVVarianceTransformation])
-> (HestonSLVVarianceTransformation
    -> HestonSLVVarianceTransformation
    -> [HestonSLVVarianceTransformation])
-> (HestonSLVVarianceTransformation
    -> HestonSLVVarianceTransformation
    -> [HestonSLVVarianceTransformation])
-> (HestonSLVVarianceTransformation
    -> HestonSLVVarianceTransformation
    -> HestonSLVVarianceTransformation
    -> [HestonSLVVarianceTransformation])
-> Enum HestonSLVVarianceTransformation
forall a.
(a -> a)
-> (a -> a)
-> (Int -> a)
-> (a -> Int)
-> (a -> [a])
-> (a -> a -> [a])
-> (a -> a -> [a])
-> (a -> a -> a -> [a])
-> Enum a
$csucc :: HestonSLVVarianceTransformation -> HestonSLVVarianceTransformation
succ :: HestonSLVVarianceTransformation -> HestonSLVVarianceTransformation
$cpred :: HestonSLVVarianceTransformation -> HestonSLVVarianceTransformation
pred :: HestonSLVVarianceTransformation -> HestonSLVVarianceTransformation
$ctoEnum :: Int -> HestonSLVVarianceTransformation
toEnum :: Int -> HestonSLVVarianceTransformation
$cfromEnum :: HestonSLVVarianceTransformation -> Int
fromEnum :: HestonSLVVarianceTransformation -> Int
$cenumFrom :: HestonSLVVarianceTransformation
-> [HestonSLVVarianceTransformation]
enumFrom :: HestonSLVVarianceTransformation
-> [HestonSLVVarianceTransformation]
$cenumFromThen :: HestonSLVVarianceTransformation
-> HestonSLVVarianceTransformation
-> [HestonSLVVarianceTransformation]
enumFromThen :: HestonSLVVarianceTransformation
-> HestonSLVVarianceTransformation
-> [HestonSLVVarianceTransformation]
$cenumFromTo :: HestonSLVVarianceTransformation
-> HestonSLVVarianceTransformation
-> [HestonSLVVarianceTransformation]
enumFromTo :: HestonSLVVarianceTransformation
-> HestonSLVVarianceTransformation
-> [HestonSLVVarianceTransformation]
$cenumFromThenTo :: HestonSLVVarianceTransformation
-> HestonSLVVarianceTransformation
-> HestonSLVVarianceTransformation
-> [HestonSLVVarianceTransformation]
enumFromThenTo :: HestonSLVVarianceTransformation
-> HestonSLVVarianceTransformation
-> HestonSLVVarianceTransformation
-> [HestonSLVVarianceTransformation]
Enum, HestonSLVVarianceTransformation
HestonSLVVarianceTransformation
-> HestonSLVVarianceTransformation
-> Bounded HestonSLVVarianceTransformation
forall a. a -> a -> Bounded a
$cminBound :: HestonSLVVarianceTransformation
minBound :: HestonSLVVarianceTransformation
$cmaxBound :: HestonSLVVarianceTransformation
maxBound :: HestonSLVVarianceTransformation
Bounded)

-- |Full numerical configuration for QuantLib's Fokker--Planck SLV calibration.
data HestonSLVFokkerPlanckFdmParams = HestonSLVFokkerPlanckFdmParams
  { HestonSLVFokkerPlanckFdmParams -> Word
hestonSlvXGrid :: !Word, HestonSLVFokkerPlanckFdmParams -> Word
hestonSlvVGrid :: !Word
  , HestonSLVFokkerPlanckFdmParams -> Word
hestonSlvTMaxStepsPerYear :: !Word, HestonSLVFokkerPlanckFdmParams -> Word
hestonSlvTMinStepsPerYear :: !Word, HestonSLVFokkerPlanckFdmParams -> Double
hestonSlvTStepNumberDecay :: !Double
  , HestonSLVFokkerPlanckFdmParams -> Word
hestonSlvNRannacherTimeSteps :: !Word, HestonSLVFokkerPlanckFdmParams -> Word
hestonSlvPredictionCorrectionSteps :: !Word
  , HestonSLVFokkerPlanckFdmParams -> Double
hestonSlvX0Density :: !Double, HestonSLVFokkerPlanckFdmParams -> Double
hestonSlvLocalVolEpsProb :: !Double, HestonSLVFokkerPlanckFdmParams -> Word
hestonSlvMaxIntegrationIterations :: !Word
  , HestonSLVFokkerPlanckFdmParams -> Double
hestonSlvVLowerEps :: !Double, HestonSLVFokkerPlanckFdmParams -> Double
hestonSlvVUpperEps :: !Double, HestonSLVFokkerPlanckFdmParams -> Double
hestonSlvVMin :: !Double
  , HestonSLVFokkerPlanckFdmParams -> Double
hestonSlvV0Density :: !Double, HestonSLVFokkerPlanckFdmParams -> Double
hestonSlvVLowerBoundDensity :: !Double, HestonSLVFokkerPlanckFdmParams -> Double
hestonSlvVUpperBoundDensity :: !Double
  , HestonSLVFokkerPlanckFdmParams -> Double
hestonSlvLeverageFctPropEps :: !Double, HestonSLVFokkerPlanckFdmParams -> HestonSLVGreensAlgorithm
hestonSlvGreensAlgorithm :: !HestonSLVGreensAlgorithm
  , HestonSLVFokkerPlanckFdmParams -> HestonSLVVarianceTransformation
hestonSlvVarianceTransformation :: !HestonSLVVarianceTransformation, HestonSLVFokkerPlanckFdmParams -> FdmScheme
hestonSlvSchemeDesc :: !FdmScheme
  }

-- |A copied FDM diagnostic snapshot. Coordinates are the native mesher coordinates: the spot
-- axis is log-spot and the variance axis follows 'hestonSlvVarianceTransformation'. Density rows
-- correspond to variance coordinates and columns to log-spot coordinates.
data HestonSLVFDMLogEntry = HestonSLVFDMLogEntry
  { HestonSLVFDMLogEntry -> Double
hestonSlvLogTime :: !Double, HestonSLVFDMLogEntry -> RealVector
hestonSlvLogSpotCoordinates :: !RealVector
  , HestonSLVFDMLogEntry -> RealVector
hestonSlvLogVarianceCoordinates :: !RealVector, HestonSLVFDMLogEntry -> RealMatrix
hestonSlvLogDensity :: !RealMatrix
  } deriving (Int -> HestonSLVFDMLogEntry -> ShowS
[HestonSLVFDMLogEntry] -> ShowS
HestonSLVFDMLogEntry -> String
(Int -> HestonSLVFDMLogEntry -> ShowS)
-> (HestonSLVFDMLogEntry -> String)
-> ([HestonSLVFDMLogEntry] -> ShowS)
-> Show HestonSLVFDMLogEntry
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> HestonSLVFDMLogEntry -> ShowS
showsPrec :: Int -> HestonSLVFDMLogEntry -> ShowS
$cshow :: HestonSLVFDMLogEntry -> String
show :: HestonSLVFDMLogEntry -> String
$cshowList :: [HestonSLVFDMLogEntry] -> ShowS
showList :: [HestonSLVFDMLogEntry] -> ShowS
Show, HestonSLVFDMLogEntry -> HestonSLVFDMLogEntry -> Bool
(HestonSLVFDMLogEntry -> HestonSLVFDMLogEntry -> Bool)
-> (HestonSLVFDMLogEntry -> HestonSLVFDMLogEntry -> Bool)
-> Eq HestonSLVFDMLogEntry
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: HestonSLVFDMLogEntry -> HestonSLVFDMLogEntry -> Bool
== :: HestonSLVFDMLogEntry -> HestonSLVFDMLogEntry -> Bool
$c/= :: HestonSLVFDMLogEntry -> HestonSLVFDMLogEntry -> Bool
/= :: HestonSLVFDMLogEntry -> HestonSLVFDMLogEntry -> Bool
Eq)


{-# LINE 235 "./QuantLib/Model.chs" #-}


{-# LINE 236 "./QuantLib/Model.chs" #-}


{-# LINE 237 "./QuantLib/Model.chs" #-}


{-# LINE 238 "./QuantLib/Model.chs" #-}


{-# LINE 239 "./QuantLib/Model.chs" #-}


{-# LINE 240 "./QuantLib/Model.chs" #-}


{-# LINE 241 "./QuantLib/Model.chs" #-}


{-# LINE 242 "./QuantLib/Model.chs" #-}


{-# LINE 243 "./QuantLib/Model.chs" #-}


{-# LINE 244 "./QuantLib/Model.chs" #-}


{-# LINE 245 "./QuantLib/Model.chs" #-}


{-# LINE 246 "./QuantLib/Model.chs" #-}


{-# LINE 247 "./QuantLib/Model.chs" #-}


{-# LINE 248 "./QuantLib/Model.chs" #-}


{-# LINE 249 "./QuantLib/Model.chs" #-}


{-# LINE 250 "./QuantLib/Model.chs" #-}


{-# LINE 251 "./QuantLib/Model.chs" #-}


{-# LINE 252 "./QuantLib/Model.chs" #-}


{-# LINE 253 "./QuantLib/Model.chs" #-}


{-# LINE 254 "./QuantLib/Model.chs" #-}


{-# LINE 255 "./QuantLib/Model.chs" #-}


{-# LINE 256 "./QuantLib/Model.chs" #-}


{-# LINE 257 "./QuantLib/Model.chs" #-}


{-# LINE 258 "./QuantLib/Model.chs" #-}


{-# LINE 259 "./QuantLib/Model.chs" #-}


{-# LINE 260 "./QuantLib/Model.chs" #-}


{-# LINE 261 "./QuantLib/Model.chs" #-}


{-# LINE 262 "./QuantLib/Model.chs" #-}


{-# LINE 263 "./QuantLib/Model.chs" #-}


{-# LINE 264 "./QuantLib/Model.chs" #-}


{-# LINE 265 "./QuantLib/Model.chs" #-}


{-# LINE 266 "./QuantLib/Model.chs" #-}


{-# LINE 267 "./QuantLib/Model.chs" #-}


{-# LINE 268 "./QuantLib/Model.chs" #-}


{-# LINE 269 "./QuantLib/Model.chs" #-}


{-# LINE 270 "./QuantLib/Model.chs" #-}


{-# LINE 271 "./QuantLib/Model.chs" #-}


{-# LINE 272 "./QuantLib/Model.chs" #-}


{-# LINE 273 "./QuantLib/Model.chs" #-}


{-# LINE 274 "./QuantLib/Model.chs" #-}


-- |Bates stochastic-volatility model: extends Heston with jumps in the underlying's return process.
batesModel :: (BatesProcess) -> IO ((BatesModel))
batesModel :: BatesProcess -> IO BatesModel
batesModel BatesProcess
a1 =
  BatesProcess
-> (Ptr CBatesProcess' -> IO BatesModel) -> IO BatesModel
forall b. BatesProcess -> (Ptr CBatesProcess' -> IO b) -> IO b
withBatesProcess BatesProcess
a1 ((Ptr CBatesProcess' -> IO BatesModel) -> IO BatesModel)
-> (Ptr CBatesProcess' -> IO BatesModel) -> IO BatesModel
forall a b. (a -> b) -> a -> b
$ \Ptr CBatesProcess'
a1' -> 
  (Ptr (Ptr ()) -> IO BatesModel) -> IO BatesModel
forall a b. (Ptr (Ptr a) -> IO b) -> IO b
preErrorCheck ((Ptr (Ptr ()) -> IO BatesModel) -> IO BatesModel)
-> (Ptr (Ptr ()) -> IO BatesModel) -> IO BatesModel
forall a b. (a -> b) -> a -> b
$ \Ptr (Ptr ())
a2' -> 
  Ptr CBatesProcess' -> Ptr (Ptr ()) -> IO (Ptr CBatesModel')
batesModel'_ Ptr CBatesProcess'
a1' Ptr (Ptr ())
a2' IO (Ptr CBatesModel')
-> (Ptr CBatesModel' -> IO BatesModel) -> IO BatesModel
forall a b. IO a -> (a -> IO b) -> IO b
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= \Ptr CBatesModel'
res ->
  Ptr CBatesModel' -> IO BatesModel
peekBatesModel Ptr CBatesModel'
res IO BatesModel -> (BatesModel -> IO BatesModel) -> IO BatesModel
forall a b. IO a -> (a -> IO b) -> IO b
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= \BatesModel
res' ->
  Ptr (Ptr ()) -> IO ()
forall a. Ptr (Ptr a) -> IO ()
errorCheck  Ptr (Ptr ())
a2'IO () -> IO BatesModel -> IO BatesModel
forall a b. IO a -> IO b -> IO b
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>>
  BatesModel -> IO BatesModel
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return (BatesModel
res')

{-# LINE 277 "./QuantLib/Model.chs" #-}


-- |Black-Karasinski short-rate model: d(ln r) = (theta(t) - a ln r) dt + sigma dW, with constant reversion @a@ and volatility @sigma@.
blackKarasinski :: (GenYieldTermStructure y) -> (Double) -- ^y
 -> (Double) -- ^sigma
 -> IO ((ShortRateModel))
blackKarasinski a1 a2 a3 =
  withYieldTermStructure a1 $ \a1' -> 
  let {a2' = realToFrac a2} in 
  let {a3' = realToFrac a3} in 
  preErrorCheck $ \a4' -> 
  blackKarasinski'_ a1' a2' a3' a4' >>= \res ->
  peekShortRateModel res >>= \res' ->
  errorCheck  a4'>>
  return (res')

{-# LINE 282 "./QuantLib/Model.chs" #-}


-- |Cox-Ingersoll-Ross short-rate model: dr = k(theta - r) dt + sigma sqrt(r) dW.
coxIngersollRoss :: (Double) -- ^r0
 -> (Double) -- ^theta
 -> (Double) -- ^k
 -> (Double) -- ^sigma
 -> (Bool) -- ^withFellerConstraint
 -> IO ((OneFactorAffineModel))
coxIngersollRoss a1 a2 a3 a4 a5 =
  let {a1' = realToFrac a1} in 
  let {a2' = realToFrac a2} in 
  let {a3' = realToFrac a3} in 
  let {a4' = realToFrac a4} in 
  let {a5' = C2HSImp.fromBool a5} in 
  preErrorCheck $ \a6' -> 
  coxIngersollRoss'_ a1' a2' a3' a4' a5' a6' >>= \res ->
  peekOneFactorAffineModel res >>= \res' ->
  errorCheck  a6'>>
  return (res')

{-# LINE 290 "./QuantLib/Model.chs" #-}


-- |Extended CIR model: adds a deterministic term-structure-fitting shift to a standard Cox-Ingersoll-Ross process.
extendedCoxIngersollRoss :: (GenYieldTermStructure y) -> (Double) -- ^theta
 -> (Double) -- ^k
 -> (Double) -- ^sigma
 -> (Double) -- ^x0
 -> (Bool) -- ^withFellerConstraint
 -> IO ((OneFactorAffineModel))
extendedCoxIngersollRoss a1 a2 a3 a4 a5 a6 =
  withYieldTermStructure a1 $ \a1' -> 
  let {a2' = realToFrac a2} in 
  let {a3' = realToFrac a3} in 
  let {a4' = realToFrac a4} in 
  let {a5' = realToFrac a5} in 
  let {a6' = C2HSImp.fromBool a6} in 
  preErrorCheck $ \a7' -> 
  extendedCoxIngersollRoss'_ a1' a2' a3' a4' a5' a6' a7' >>= \res ->
  peekOneFactorAffineModel res >>= \res' ->
  errorCheck  a7'>>
  return (res')

{-# LINE 298 "./QuantLib/Model.chs" #-}


-- |Two-additive-factor Gaussian (G2) short-rate model: the sum of two correlated Ornstein-Uhlenbeck factors.
g2 :: (GenYieldTermStructure y) -> (Double) -- ^y
 -> (Double) -- ^sigma
 -> (Double) -- ^b
 -> (Double) -- ^eta
 -> (Double) -- ^rho
 -> IO ((G2))
g2 a1 a2 a3 a4 a5 a6 =
  withYieldTermStructure a1 $ \a1' -> 
  let {a2' = realToFrac a2} in 
  let {a3' = realToFrac a3} in 
  let {a4' = realToFrac a4} in 
  let {a5' = realToFrac a5} in 
  let {a6' = realToFrac a6} in 
  preErrorCheck $ \a7' -> 
  g2'_ a1' a2' a3' a4' a5' a6' a7' >>= \res ->
  peekG2 res >>= \res' ->
  errorCheck  a7'>>
  return (res')

{-# LINE 306 "./QuantLib/Model.chs" #-}


-- |The two-factor short-rate dynamics underlying a 'G2' model (@TwoFactorModel::dynamics()@).
g2Dynamics :: (G2) -> IO ((ShortRateDynamics))
g2Dynamics a1 =
  withG2 a1 $ \a1' -> 
  preErrorCheck $ \a2' -> 
  g2Dynamics'_ a1' a2' >>= \res ->
  peekStandalone res >>= \res' ->
  errorCheck  a2'>>
  return (res')

{-# LINE 309 "./QuantLib/Model.chs" #-}


-- |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)@.
shortRate :: (ShortRateDynamics) -> (Double) -- ^t
 -> (Double) -- ^x
 -> (Double) -- ^y
 -> IO ((Double))
shortRate a1 a2 a3 a4 =
  withStandalone a1 $ \a1' -> 
  let {a2' = realToFrac a2} in 
  let {a3' = realToFrac a3} in 
  let {a4' = realToFrac a4} in 
  preErrorCheck $ \a5' -> 
  shortRate'_ a1' a2' a3' a4' a5' >>= \res ->
  let {res' = realToFrac res} in
  errorCheck  a5'>>
  return (res')

{-# LINE 316 "./QuantLib/Model.chs" #-}


-- |Generalized Hull-White model: like 'hullWhite', but reversion and volatility are piecewise-linear functions of time given at @speedstructure@/@volstructure@ dates.
generalizedHullWhite :: GenYieldTermStructure y -> NonEmpty (Day, Double) -- ^speedstructure
  -> NonEmpty (Day, Double) -- ^volstructure
  -> IO ShortRateModel
generalizedHullWhite ts s v = qlGeneralizedHullWhite ts sd vd sq vq where {(sd, sq) = unzip (toList s); (vd, vq) = unzip (toList v)}
qlGeneralizedHullWhite :: (GenYieldTermStructure y) -> ([Day]) -> ([Day]) -> ([Double]) -> ([Double]) -> IO ((ShortRateModel))
qlGeneralizedHullWhite a1 a2 a3 a4 a5 =
  withYieldTermStructure a1 $ \a1' -> 
  withDayArray a2 $ \(a2'1, a2'2) -> 
  withDayArray a3 $ \(a3'1, a3'2) -> 
  withDoubleArray a4 $ \(a4'1, a4'2) -> 
  withDoubleArray a5 $ \(a5'1, a5'2) -> 
  preErrorCheck $ \a6' -> 
  qlGeneralizedHullWhite'_ a1' a2'1  a2'2 a3'1  a3'2 a4'1  a4'2 a5'1  a5'2 a6' >>= \res ->
  peekShortRateModel res >>= \res' ->
  errorCheck  a6'>>
  return (res')

{-# LINE 323 "./QuantLib/Model.chs" #-}


-- |GJR-GARCH stochastic-volatility model, extending GARCH(1,1) with an asymmetric response to negative return shocks.
gjrGarchModel :: (GJRGARCHProcess) -> IO ((GJRGARCHModel))
gjrGarchModel a1 =
  withGenStochasticProcess a1 $ \a1' -> 
  preErrorCheck $ \a2' -> 
  gjrGarchModel'_ a1' a2' >>= \res ->
  peekGJRGARCHModel res >>= \res' ->
  errorCheck  a2'>>
  return (res')

{-# LINE 326 "./QuantLib/Model.chs" #-}


-- |Heston stochastic-volatility model, calibrated from a 'HestonProcess'.
hestonModel :: (GenHestonProcess hp) -> IO ((HestonModel))
hestonModel a1 =
  withHestonProcess a1 $ \a1' -> 
  preErrorCheck $ \a2' -> 
  hestonModel'_ a1' a2' >>= \res ->
  peekHestonModel res >>= \res' ->
  errorCheck  a2'>>
  return (res')

{-# LINE 329 "./QuantLib/Model.chs" #-}


-- |Pseudo-random Mersenne-Twister Brownian increments for SLV Monte-Carlo calibration. Use a
-- fixed nonzero @seed@ for reproducible calibration output; QuantLib treats zero as entropy.
mtBrownianGeneratorFactory :: (Word) -- ^seed
 -> IO ((BrownianGeneratorFactory))
mtBrownianGeneratorFactory a1 =
  let {a1' = fromIntegral a1} in 
  preErrorCheck $ \a2' -> 
  mtBrownianGeneratorFactory'_ a1' a2' >>= \res ->
  peekBrownianGeneratorFactory res >>= \res' ->
  errorCheck  a2'>>
  return (res')

{-# LINE 334 "./QuantLib/Model.chs" #-}


-- |Low-discrepancy Sobol Brownian increments for SLV Monte-Carlo calibration. Supply a fixed
-- nonzero @seed@ to make the resulting leverage function reproducible.
sobolBrownianGeneratorFactory :: (SobolBrownianOrdering) -- ^ordering
 -> (Word) -- ^seed
 -> (SobolDirectionIntegers) -- ^directionIntegers
 -> IO ((BrownianGeneratorFactory))
sobolBrownianGeneratorFactory a1 a2 a3 =
  let {a1' = fromEnumC a1} in 
  let {a2' = fromIntegral a2} in 
  let {a3' = fromEnumC a3} in 
  preErrorCheck $ \a4' -> 
  sobolBrownianGeneratorFactory'_ a1' a2' a3' a4' >>= \res ->
  peekBrownianGeneratorFactory res >>= \res' ->
  errorCheck  a4'>>
  return (res')

{-# LINE 341 "./QuantLib/Model.chs" #-}


-- |Monte-Carlo calibration of a Heston stochastic-local-volatility leverage function. The
-- trailing arguments mirror QuantLib's defaults explicitly; @mandatoryDates@ are inserted into
-- the calibration time grid.
hestonSlvMcModel :: (GenLocalVolTermStructure lv) -- ^localVol
 -> (GenHestonModel hm) -- ^hestonModel
 -> (BrownianGeneratorFactory) -- ^brownianGeneratorFactory
 -> (Day) -- ^endDate
 -> (Word) -- ^timeStepsPerYear
 -> (Word) -- ^nBins
 -> (Word) -- ^calibrationPaths
 -> ([Day]) -- ^mandatoryDates
 -> (Double) -- ^mixingFactor
 -> IO ((HestonSLVMCModel))
hestonSlvMcModel :: forall lv hm.
GenLocalVolTermStructure lv
-> GenHestonModel hm
-> BrownianGeneratorFactory
-> Day
-> Word
-> Word
-> Word
-> [Day]
-> Double
-> IO HestonSLVMCModel
hestonSlvMcModel GenLocalVolTermStructure lv
a1 GenHestonModel hm
a2 BrownianGeneratorFactory
a3 Day
a4 Word
a5 Word
a6 Word
a7 [Day]
a8 Double
a9 =
  GenLocalVolTermStructure lv
-> (Ptr CLocalVolTermStructure' -> IO HestonSLVMCModel)
-> IO HestonSLVMCModel
forall lv b.
GenLocalVolTermStructure lv
-> (Ptr CLocalVolTermStructure' -> IO b) -> IO b
withGenLocalVolTermStructure GenLocalVolTermStructure lv
a1 ((Ptr CLocalVolTermStructure' -> IO HestonSLVMCModel)
 -> IO HestonSLVMCModel)
-> (Ptr CLocalVolTermStructure' -> IO HestonSLVMCModel)
-> IO HestonSLVMCModel
forall a b. (a -> b) -> a -> b
$ \Ptr CLocalVolTermStructure'
a1' -> 
  GenHestonModel hm
-> (Ptr CHestonModel' -> IO HestonSLVMCModel)
-> IO HestonSLVMCModel
forall hm b.
GenHestonModel hm -> (Ptr CHestonModel' -> IO b) -> IO b
withHestonModel GenHestonModel hm
a2 ((Ptr CHestonModel' -> IO HestonSLVMCModel) -> IO HestonSLVMCModel)
-> (Ptr CHestonModel' -> IO HestonSLVMCModel)
-> IO HestonSLVMCModel
forall a b. (a -> b) -> a -> b
$ \Ptr CHestonModel'
a2' -> 
  BrownianGeneratorFactory
-> (Ptr CBrownianGeneratorFactory' -> IO HestonSLVMCModel)
-> IO HestonSLVMCModel
forall b.
BrownianGeneratorFactory
-> (Ptr CBrownianGeneratorFactory' -> IO b) -> IO b
withBrownianGeneratorFactory BrownianGeneratorFactory
a3 ((Ptr CBrownianGeneratorFactory' -> IO HestonSLVMCModel)
 -> IO HestonSLVMCModel)
-> (Ptr CBrownianGeneratorFactory' -> IO HestonSLVMCModel)
-> IO HestonSLVMCModel
forall a b. (a -> b) -> a -> b
$ \Ptr CBrownianGeneratorFactory'
a3' -> 
  Day -> (CInt -> IO HestonSLVMCModel) -> IO HestonSLVMCModel
forall a. Day -> (CInt -> IO a) -> IO a
withDay Day
a4 ((CInt -> IO HestonSLVMCModel) -> IO HestonSLVMCModel)
-> (CInt -> IO HestonSLVMCModel) -> IO HestonSLVMCModel
forall a b. (a -> b) -> a -> b
$ \CInt
a4' -> 
  let {a5' :: CUInt
a5' = Word -> CUInt
forall a b. (Integral a, Num b) => a -> b
fromIntegral a5} in 
  let {a6' = fromIntegral a6} in 
  let {a7' = fromIntegral a7} in 
  withDayArray a8 $ \(a8'1, a8'2) -> 
  let {a9' = realToFrac a9} in 
  preErrorCheck $ \a10' -> 
  hestonSlvMcModel'_ a1' a2' a3' a4' a5' a6' a7' a8'1  a8'2 a9' a10' >>= \res ->
  peekHestonSLVMCModel res >>= \res' ->
  errorCheck  a10'>>
  return (res')

{-# LINE 355 "./QuantLib/Model.chs" #-}


-- |Forces MC calibration if necessary and returns its local-volatility leverage function.
qlHestonSLVMCModelLeverageFunction :: (HestonSLVMCModel) -- ^model
 -> IO ((LocalVolTermStructure))
qlHestonSLVMCModelLeverageFunction a1 =
  withHestonSLVMCModel a1 $ \a1' -> 
  preErrorCheck $ \a2' -> 
  qlHestonSLVMCModelLeverageFunction'_ a1' a2' >>= \res ->
  peekLocalVolTermStructure res >>= \res' ->
  errorCheck  a2'>>
  return (res')

{-# LINE 359 "./QuantLib/Model.chs" #-}


-- |Fokker--Planck finite-difference calibration of a Heston stochastic-local-volatility
-- leverage function. @logging@ retains diagnostic density snapshots for
-- 'hestonSlvFdmLogEntries'; @mandatoryDates@ are added to its adaptive time grid.
hestonSlvFdmModel :: GenLocalVolTermStructure lv -> GenHestonModel hm -> Day
  -> HestonSLVFokkerPlanckFdmParams -> Bool -> [Day] -> Double -> IO HestonSLVFDMModel
hestonSlvFdmModel localVol model endDate p logging mandatoryDates mixingFactor =
  hestonSlvFdmModelRaw localVol model endDate
    (hestonSlvXGrid p) (hestonSlvVGrid p) (hestonSlvTMaxStepsPerYear p) (hestonSlvTMinStepsPerYear p)
    (hestonSlvTStepNumberDecay p) (hestonSlvNRannacherTimeSteps p) (hestonSlvPredictionCorrectionSteps p)
    (hestonSlvX0Density p) (hestonSlvLocalVolEpsProb p) (hestonSlvMaxIntegrationIterations p)
    (hestonSlvVLowerEps p) (hestonSlvVUpperEps p) (hestonSlvVMin p) (hestonSlvV0Density p)
    (hestonSlvVLowerBoundDensity p) (hestonSlvVUpperBoundDensity p) (hestonSlvLeverageFctPropEps p)
    (hestonSlvGreensAlgorithm p) (hestonSlvVarianceTransformation p) (hestonSlvSchemeDesc p)
    logging mandatoryDates mixingFactor
hestonSlvFdmModelRaw :: (GenLocalVolTermStructure lv) -- ^localVol
 -> (GenHestonModel hm) -- ^hestonModel
 -> (Day) -- ^endDate
 -> (Word) -- ^xGrid
 -> (Word) -- ^vGrid
 -> (Word) -- ^tMaxStepsPerYear
 -> (Word) -- ^tMinStepsPerYear
 -> (Double) -- ^tStepNumberDecay
 -> (Word) -- ^nRannacherTimeSteps
 -> (Word) -- ^predictionCorrectionSteps
 -> (Double) -- ^x0Density
 -> (Double) -- ^localVolEpsProb
 -> (Word) -- ^maxIntegrationIterations
 -> (Double) -- ^vLowerEps
 -> (Double) -- ^vUpperEps
 -> (Double) -- ^vMin
 -> (Double) -- ^v0Density
 -> (Double) -- ^vLowerBoundDensity
 -> (Double) -- ^vUpperBoundDensity
 -> (Double) -- ^leverageFctPropEps
 -> (HestonSLVGreensAlgorithm) -- ^greensAlgorithm
 -> (HestonSLVVarianceTransformation) -- ^trafoType
 -> (FdmScheme) -- ^schemeDesc
 -> (Bool) -- ^logging
 -> ([Day]) -- ^mandatoryDates
 -> (Double) -- ^mixingFactor
 -> IO ((HestonSLVFDMModel))
hestonSlvFdmModelRaw :: forall lv hm.
GenLocalVolTermStructure lv
-> GenHestonModel hm
-> Day
-> Word
-> Word
-> Word
-> Word
-> Double
-> Word
-> Word
-> Double
-> Double
-> Word
-> Double
-> Double
-> Double
-> Double
-> Double
-> Double
-> Double
-> HestonSLVGreensAlgorithm
-> HestonSLVVarianceTransformation
-> FdmScheme
-> Bool
-> [Day]
-> Double
-> IO HestonSLVFDMModel
hestonSlvFdmModelRaw GenLocalVolTermStructure lv
a1 GenHestonModel hm
a2 Day
a3 Word
a4 Word
a5 Word
a6 Word
a7 Double
a8 Word
a9 Word
a10 Double
a11 Double
a12 Word
a13 Double
a14 Double
a15 Double
a16 Double
a17 Double
a18 Double
a19 Double
a20 HestonSLVGreensAlgorithm
a21 HestonSLVVarianceTransformation
a22 FdmScheme
a23 Bool
a24 [Day]
a25 Double
a26 =
  GenLocalVolTermStructure lv
-> (Ptr CLocalVolTermStructure' -> IO HestonSLVFDMModel)
-> IO HestonSLVFDMModel
forall lv b.
GenLocalVolTermStructure lv
-> (Ptr CLocalVolTermStructure' -> IO b) -> IO b
withGenLocalVolTermStructure GenLocalVolTermStructure lv
a1 ((Ptr CLocalVolTermStructure' -> IO HestonSLVFDMModel)
 -> IO HestonSLVFDMModel)
-> (Ptr CLocalVolTermStructure' -> IO HestonSLVFDMModel)
-> IO HestonSLVFDMModel
forall a b. (a -> b) -> a -> b
$ \Ptr CLocalVolTermStructure'
a1' -> 
  GenHestonModel hm
-> (Ptr CHestonModel' -> IO HestonSLVFDMModel)
-> IO HestonSLVFDMModel
forall hm b.
GenHestonModel hm -> (Ptr CHestonModel' -> IO b) -> IO b
withHestonModel GenHestonModel hm
a2 ((Ptr CHestonModel' -> IO HestonSLVFDMModel)
 -> IO HestonSLVFDMModel)
-> (Ptr CHestonModel' -> IO HestonSLVFDMModel)
-> IO HestonSLVFDMModel
forall a b. (a -> b) -> a -> b
$ \Ptr CHestonModel'
a2' -> 
  Day -> (CInt -> IO HestonSLVFDMModel) -> IO HestonSLVFDMModel
forall a. Day -> (CInt -> IO a) -> IO a
withDay Day
a3 ((CInt -> IO HestonSLVFDMModel) -> IO HestonSLVFDMModel)
-> (CInt -> IO HestonSLVFDMModel) -> IO HestonSLVFDMModel
forall a b. (a -> b) -> a -> b
$ \CInt
a3' -> 
  let {a4' :: CUInt
a4' = Word -> CUInt
forall a b. (Integral a, Num b) => a -> b
fromIntegral Word
a4} in 
  let {a5' :: CUInt
a5' = Word -> CUInt
forall a b. (Integral a, Num b) => a -> b
fromIntegral Word
a5} in 
  let {a6' = fromIntegral a6} in 
  let {a7' = fromIntegral a7} in 
  let {a8' = realToFrac a8} in 
  let {a9' = fromIntegral a9} in 
  let {a10' = fromIntegral a10} in 
  let {a11' = realToFrac a11} in 
  let {a12' = realToFrac a12} in 
  let {a13' = fromIntegral a13} in 
  let {a14' = realToFrac a14} in 
  let {a15' = realToFrac a15} in 
  let {a16' = realToFrac a16} in 
  let {a17' = realToFrac a17} in 
  let {a18' = realToFrac a18} in 
  let {a19' = realToFrac a19} in 
  let {a20' = realToFrac a20} in 
  let {a21' = fromEnumC a21} in 
  let {a22' = fromEnumC a22} in 
  withFdmSchemeDesc a23 $ \a23' -> 
  let {a24' = C2HSImp.fromBool a24} in 
  withDayArray a25 $ \(a25'1, a25'2) -> 
  let {a26' = realToFrac a26} in 
  preErrorCheck $ \a27' -> 
  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 ->
  peekHestonSLVFDMModel res >>= \res' ->
  errorCheck  a27'>>
  return (res')

{-# LINE 401 "./QuantLib/Model.chs" #-}


-- |Forces FDM calibration if necessary and returns its local-volatility leverage function.
qlHestonSLVFDMModelLeverageFunction :: (HestonSLVFDMModel) -- ^model
 -> IO ((LocalVolTermStructure))
qlHestonSLVFDMModelLeverageFunction a1 =
  withHestonSLVFDMModel a1 $ \a1' -> 
  preErrorCheck $ \a2' -> 
  qlHestonSLVFDMModelLeverageFunction'_ a1' a2' >>= \res ->
  peekLocalVolTermStructure res >>= \res' ->
  errorCheck  a2'>>
  return (res')

{-# LINE 405 "./QuantLib/Model.chs" #-}


-- |Copies retained FDM density diagnostics. Returns @[]@ when the model was built with
-- @logging = False@. Calling this makes one fresh QuantLib diagnostic calculation, then decodes
-- its owned snapshot without retaining the model's mesh objects.
hestonSlvFdmLogEntries :: HestonSLVFDMModel -> IO [HestonSLVFDMLogEntry]
hestonSlvFdmLogEntries model = do
  snapshot <- hestonSlvFdmLogEntriesSnapshot model
  let n = hestonSlvFdmLogEntriesSize snapshot
  mapM (hestonSlvFdmLogEntry snapshot) (genericTake n [0 ..])

hestonSlvFdmLogEntry :: HestonSLVFDMLogEntries -> Word -> IO HestonSLVFDMLogEntry
hestonSlvFdmLogEntry snapshot i = do
  t <- hestonSlvFdmLogEntriesTime snapshot i
  x <- hestonSlvFdmLogEntriesSpotGrid snapshot i
  v <- hestonSlvFdmLogEntriesVarianceGrid snapshot i
  (r, c, d) <- hestonSlvFdmLogEntriesDensity snapshot i
  pure $ HestonSLVFDMLogEntry t x v (RealMatrix r c d)

hestonSlvFdmLogEntriesSnapshot :: (HestonSLVFDMModel) -> IO ((HestonSLVFDMLogEntries))
hestonSlvFdmLogEntriesSnapshot a1 =
  withHestonSLVFDMModel a1 $ \a1' -> 
  preErrorCheck $ \a2' -> 
  hestonSlvFdmLogEntriesSnapshot'_ a1' a2' >>= \res ->
  peekHestonSLVFDMLogEntries res >>= \res' ->
  errorCheck  a2'>>
  return (res')

{-# LINE 424 "./QuantLib/Model.chs" #-}

hestonSlvFdmLogEntriesSize :: (HestonSLVFDMLogEntries) -> (Word)
hestonSlvFdmLogEntriesSize a1 =
  C2HSImp.unsafePerformIO $
  withHestonSLVFDMLogEntries a1 $ \a1' -> 
  hestonSlvFdmLogEntriesSize'_ a1' >>= \res ->
  let {res' = fromIntegral res} in
  return (res')

{-# LINE 425 "./QuantLib/Model.chs" #-}

hestonSlvFdmLogEntriesTime :: (HestonSLVFDMLogEntries) -> (Word) -> IO ((Double))
hestonSlvFdmLogEntriesTime a1 a2 =
  withHestonSLVFDMLogEntries a1 $ \a1' -> 
  let {a2' = fromIntegral a2} in 
  preErrorCheck $ \a3' -> 
  hestonSlvFdmLogEntriesTime'_ a1' a2' a3' >>= \res ->
  let {res' = realToFrac res} in
  errorCheck  a3'>>
  return (res')

{-# LINE 426 "./QuantLib/Model.chs" #-}

hestonSlvFdmLogEntriesSpotGrid :: (HestonSLVFDMLogEntries) -> (Word) -> IO ((RealVector))
hestonSlvFdmLogEntriesSpotGrid a1 a2 =
  withHestonSLVFDMLogEntries a1 $ \a1' -> 
  let {a2' = fromIntegral a2} in 
  preDoubleArray $ \(a3'1, a3'2) -> 
  preErrorCheck $ \a4' -> 
  hestonSlvFdmLogEntriesSpotGrid'_ a1' a2' a3'1  a3'2 a4' >>
  peekRealVector  a3'1  a3'2>>= \a3'' -> 
  errorCheck  a4'>>
  return (a3'')

{-# LINE 427 "./QuantLib/Model.chs" #-}

hestonSlvFdmLogEntriesVarianceGrid :: (HestonSLVFDMLogEntries) -> (Word) -> IO ((RealVector))
hestonSlvFdmLogEntriesVarianceGrid a1 a2 =
  withHestonSLVFDMLogEntries a1 $ \a1' -> 
  let {a2' = fromIntegral a2} in 
  preDoubleArray $ \(a3'1, a3'2) -> 
  preErrorCheck $ \a4' -> 
  hestonSlvFdmLogEntriesVarianceGrid'_ a1' a2' a3'1  a3'2 a4' >>
  peekRealVector  a3'1  a3'2>>= \a3'' -> 
  errorCheck  a4'>>
  return (a3'')

{-# LINE 428 "./QuantLib/Model.chs" #-}

hestonSlvFdmLogEntriesDensity :: (HestonSLVFDMLogEntries) -> (Word) -> IO ((Word), (Word), (RealVector))
hestonSlvFdmLogEntriesDensity a1 a2 =
  withHestonSLVFDMLogEntries a1 $ \a1' -> 
  let {a2' = fromIntegral a2} in 
  prePtr $ \a3' -> 
  prePtr $ \a4' -> 
  preDoubleArray $ \(a5'1, a5'2) -> 
  preErrorCheck $ \a6' -> 
  hestonSlvFdmLogEntriesDensity'_ a1' a2' a3' a4' a5'1  a5'2 a6' >>
  peekWord  a3'>>= \a3'' -> 
  peekWord  a4'>>= \a4'' -> 
  peekRealVector  a5'1  a5'2>>= \a5'' -> 
  errorCheck  a6'>>
  return (a3'', a4'', a5'')

{-# LINE 429 "./QuantLib/Model.chs" #-}


-- |Single-factor Hull-White (extended Vasicek) short-rate model: dr = (theta(t) - a r) dt + sigma dW, fitted to the given term structure.
hullWhite :: (GenYieldTermStructure y) -> (Double) -- ^a (mean reversion)
 -> (Double) -- ^sigma
 -> IO ((HullWhite))
hullWhite a1 a2 a3 =
  withYieldTermStructure a1 $ \a1' -> 
  let {a2' = realToFrac a2} in 
  let {a3' = realToFrac a3} in 
  preErrorCheck $ \a4' -> 
  hullWhite'_ a1' a2' a3' a4' >>= \res ->
  peekHullWhite res >>= \res' ->
  errorCheck  a4'>>
  return (res')

{-# LINE 434 "./QuantLib/Model.chs" #-}


-- |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.
-- Not 'pure': 'HullWhite.convexityBias' can throw ('QL_REQUIRE' on its inputs), and letting a C++
-- exception unwind across the FFI boundary from an 'unsafePerformIO'-backed pure binding is undefined
-- behavior, so this needs the same 'char **e'/'preErrorCheck' error channel as any other throwing call.
convexityBias :: (Double) -- ^futurePrice
 -> (Double) -- ^t
 -> (Double) -- ^T
 -> (Double) -- ^sigma
 -> (Double) -- ^a
 -> IO ((Double))
convexityBias :: Double -> Double -> Double -> Double -> Double -> IO Double
convexityBias Double
a1 Double
a2 Double
a3 Double
a4 Double
a5 =
  let {a1' :: CDouble
a1' = Double -> CDouble
forall a b. (Real a, Fractional b) => a -> b
realToFrac Double
a1} in 
  let {a2' :: CDouble
a2' = Double -> CDouble
forall a b. (Real a, Fractional b) => a -> b
realToFrac Double
a2} in 
  let {a3' = realToFrac a3} in 
  let {a4' = realToFrac a4} in 
  let {a5' = realToFrac a5} in 
  preErrorCheck $ \a6' -> 
  convexityBias'_ a1' a2' a3' a4' a5' a6' >>= \res ->
  let {res' = realToFrac res} in
  errorCheck  a6'>>
  return (res')

{-# LINE 445 "./QuantLib/Model.chs" #-}


-- |Marks the reversion (@a@) fixed and volatility (@sigma@) free for 'calibrate''s @fixParameters@ argument. Mirrors @HullWhite::FixedReversion()@.
fixedReversion :: [Bool]
fixedReversion = [True, False]

-- |One-factor GSR model (formulated in the forward measure), with an initial volatility and
-- piecewise-constant changes at the given dates, plus a single constant reversion.
gsr :: GenYieldTermStructure y -> GenQuote q1 -> [(Day, GenQuote q1)] -> GenQuote q2 -> Double -> IO Gsr
gsr ts initialVol subsequentVols reversion horizon =
  qlGsr ts dates (initialVol : vols) [reversion] horizon
  where (dates, vols) = unzip subsequentVols

-- |One-factor GSR model with a piecewise-constant reversion as well as volatility: the initial
-- (volatility, reversion) pair holds until the first step date, and each step date starts a new
-- pair. 'calibrateReversionsIterative' needs this form, one reversion per calibration helper.
gsrWithReversions :: GenYieldTermStructure y -> (GenQuote q1, GenQuote q2) -> [(Day, (GenQuote q1, GenQuote q2))]
  -> Double -> IO Gsr
gsrWithReversions :: forall y q1 q2.
GenYieldTermStructure y
-> (GenQuote q1, GenQuote q2)
-> [(Day, (GenQuote q1, GenQuote q2))]
-> Double
-> IO Gsr
gsrWithReversions GenYieldTermStructure y
ts (GenQuote q1
initialVol, GenQuote q2
initialReversion) [(Day, (GenQuote q1, GenQuote q2))]
steps Double
horizon =
  GenYieldTermStructure y
-> [Day] -> [GenQuote q1] -> [GenQuote q2] -> Double -> IO Gsr
forall y q1 q2.
GenYieldTermStructure y
-> [Day] -> [GenQuote q1] -> [GenQuote q2] -> Double -> IO Gsr
qlGsr GenYieldTermStructure y
ts [Day]
dates (GenQuote q1
initialVol GenQuote q1 -> [GenQuote q1] -> [GenQuote q1]
forall a. a -> [a] -> [a]
: [GenQuote q1]
vols) (GenQuote q2
initialReversion GenQuote q2 -> [GenQuote q2] -> [GenQuote q2]
forall a. a -> [a] -> [a]
: [GenQuote q2]
reversions') Double
horizon
  where ([Day]
dates, [(GenQuote q1, GenQuote q2)]
pairs) = [(Day, (GenQuote q1, GenQuote q2))]
-> ([Day], [(GenQuote q1, GenQuote q2)])
forall a b. [(a, b)] -> ([a], [b])
unzip [(Day, (GenQuote q1, GenQuote q2))]
steps
        ([GenQuote q1]
vols, [GenQuote q2]
reversions') = [(GenQuote q1, GenQuote q2)] -> ([GenQuote q1], [GenQuote q2])
forall a b. [(a, b)] -> ([a], [b])
unzip [(GenQuote q1, GenQuote q2)]
pairs

qlGsr :: (GenYieldTermStructure y) -> ([Day]) -- ^volstepdates
 -> ([GenQuote q1]) -- ^volatilities
 -> ([GenQuote q2]) -- ^reversions: one, or one per volatility
 -> (Double) -- ^T
 -> IO ((Gsr))
qlGsr :: forall y q1 q2.
GenYieldTermStructure y
-> [Day] -> [GenQuote q1] -> [GenQuote q2] -> Double -> IO Gsr
qlGsr GenYieldTermStructure y
a1 [Day]
a2 [GenQuote q1]
a3 [GenQuote q2]
a4 Double
a5 =
  GenYieldTermStructure y
-> (Ptr CYieldTermStructure' -> IO Gsr) -> IO Gsr
forall y b.
GenYieldTermStructure y
-> (Ptr CYieldTermStructure' -> IO b) -> IO b
withYieldTermStructure GenYieldTermStructure y
a1 ((Ptr CYieldTermStructure' -> IO Gsr) -> IO Gsr)
-> (Ptr CYieldTermStructure' -> IO Gsr) -> IO Gsr
forall a b. (a -> b) -> a -> b
$ \Ptr CYieldTermStructure'
a1' -> 
  [Day] -> ((CUInt, Ptr CInt) -> IO Gsr) -> IO Gsr
forall b. [Day] -> ((CUInt, Ptr CInt) -> IO b) -> IO b
withDayArray [Day]
a2 (((CUInt, Ptr CInt) -> IO Gsr) -> IO Gsr)
-> ((CUInt, Ptr CInt) -> IO Gsr) -> IO Gsr
forall a b. (a -> b) -> a -> b
$ \(CUInt
a2'1, Ptr CInt
a2'2) -> 
  withQuoteArray a3 $ \(a3'1, a3'2) -> 
  withQuoteArray a4 $ \(a4'1, a4'2) -> 
  let {a5' = realToFrac a5} in 
  preErrorCheck $ \a6' -> 
  qlGsr'_ a1' a2'1  a2'2 a3'1  a3'2 a4'1  a4'2 a5' a6' >>= \res ->
  peekGsr res >>= \res' ->
  errorCheck  a6'>>
  return (res')

{-# LINE 472 "./QuantLib/Model.chs" #-}


-- |Volatility step values, as calibrated so far.
qlGsrVolatility :: (Gsr) -> IO (([Double]))
qlGsrVolatility a1 =
  withGenCalibratedModel a1 $ \a1' -> 
  preDoubleArray $ \(a2'1, a2'2) -> 
  preErrorCheck $ \a3' -> 
  qlGsrVolatility'_ a1' a2'1  a2'2 a3' >>
  peekDoubleArray  a2'1  a2'2>>= \a2'' -> 
  errorCheck  a3'>>
  return (a2'')

{-# LINE 475 "./QuantLib/Model.chs" #-}


-- |Reversion values, as calibrated so far: one for a constant reversion, otherwise one per
-- volatility step.
reversions :: (Gsr) -> IO (([Double]))
reversions a1 =
  withGenCalibratedModel a1 $ \a1' -> 
  preDoubleArray $ \(a2'1, a2'2) -> 
  preErrorCheck $ \a3' -> 
  reversions'_ a1' a2'1  a2'2 a3' >>
  peekDoubleArray  a2'1  a2'2>>= \a2'' -> 
  errorCheck  a3'>>
  return (a2'')

{-# LINE 479 "./QuantLib/Model.chs" #-}


-- |The calibration mask ('calibrate''s @fixParameters@) that fixes every model parameter except
-- the volatility at step index @i@ (0-based) -- a ready-made @fixParameters@ argument for
-- calibrating that one volatility in isolation.
moveVolatility :: (Gsr) -> (Word) -- ^i
 -> IO (([Bool]))
moveVolatility a1 a2 =
  withGenCalibratedModel a1 $ \a1' -> 
  let {a2' = fromIntegral a2} in 
  preIntArray $ \(a3'1, a3'2) -> 
  preErrorCheck $ \a4' -> 
  moveVolatility'_ a1' a2' a3'1  a3'2 a4' >>
  peekBoolArray  a3'1  a3'2>>= \a3'' -> 
  errorCheck  a4'>>
  return (a3'')

{-# LINE 486 "./QuantLib/Model.chs" #-}


-- |The calibration mask that fixes every model parameter except the reversion at index @i@
-- (0-based) -- the reversion counterpart of 'moveVolatility'. Only index 0 exists unless the model
-- was built by 'gsrWithReversions'.
moveReversion :: (Gsr) -> (Word) -- ^i
 -> IO (([Bool]))
moveReversion a1 a2 =
  withGenCalibratedModel a1 $ \a1' -> 
  let {a2' = fromIntegral a2} in 
  preIntArray $ \(a3'1, a3'2) -> 
  preErrorCheck $ \a4' -> 
  moveReversion'_ a1' a2' a3'1  a3'2 a4' >>
  peekBoolArray  a3'1  a3'2>>= \a3'' -> 
  errorCheck  a4'>>
  return (a3'')

{-# LINE 493 "./QuantLib/Model.chs" #-}


-- |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).
calibrateVolatilitiesIterative :: (Gsr) -> ([GenBlackCalibrationHelper bch]) -> (OptimizationMethod) -> (EndCriteria) -> (Maybe Constraint) -> ([Double]) -> IO ()
calibrateVolatilitiesIterative a1 a2 a3 a4 a5 a6 =
  withGenCalibratedModel a1 $ \a1' -> 
  withBlackCalibrationHelperArray a2 $ \(a2'1, a2'2) -> 
  withOptimizationMethod a3 $ \a3' -> 
  withEndCriteria a4 $ \a4' -> 
  withMaybeConstraint a5 $ \a5' -> 
  withDoubleArray a6 $ \(a6'1, a6'2) -> 
  preErrorCheck $ \a7' -> 
  calibrateVolatilitiesIterative'_ a1' a2'1  a2'2 a3' a4' a5' a6'1  a6'2 a7' >>
  errorCheck  a7'>>
  return ()

{-# LINE 499 "./QuantLib/Model.chs" #-}


-- |Iteratively calibrates the reversions, one at a time: reversion @i@ is fitted to helper @i@
-- with every other parameter held. The model needs one reversion per helper at least, so build
-- it with 'gsrWithReversions'. The end criteria reflect only the last calibration.
--
-- A swaption's price depends on the reversion over its swap's life, so helper @i@ should exercise
-- inside reversion interval @i@ and span it. Helpers expiring at the volatility step dates leave
-- the fit ill-conditioned, and alternating with 'calibrateVolatilitiesIterative' can diverge.
calibrateReversionsIterative :: (Gsr) -> ([GenBlackCalibrationHelper bch]) -> (OptimizationMethod) -> (EndCriteria) -> (Maybe Constraint) -> ([Double]) -> IO ()
calibrateReversionsIterative a1 a2 a3 a4 a5 a6 =
  withGenCalibratedModel a1 $ \a1' -> 
  withBlackCalibrationHelperArray a2 $ \(a2'1, a2'2) -> 
  withOptimizationMethod a3 $ \a3' -> 
  withEndCriteria a4 $ \a4' -> 
  withMaybeConstraint a5 $ \a5' -> 
  withDoubleArray a6 $ \(a6'1, a6'2) -> 
  preErrorCheck $ \a7' -> 
  calibrateReversionsIterative'_ a1' a2'1  a2'2 a3' a4' a5' a6'1  a6'2 a7' >>
  errorCheck  a7'>>
  return ()

{-# LINE 511 "./QuantLib/Model.chs" #-}


-- |Markov-functional interest-rate model, calibrated to a swaption volatility cube against @swapIndexBase@.
markovFunctional :: GenYieldTermStructure y -> Double -- ^reversion
  -> Double -- ^initial volatility
  -> [(Day, Double)] -- ^subsequent volatility steps
  -> GenSwaptionVolatilityStructure sv
  -> NonEmpty (Day, (Word, TimeUnit)) -- ^swaption expiry/tenor calibration points
  -> GenSwapIndex sidx -- ^swapIndexBase
  -> Word -- ^yGridPoints
  -> IO MarkovFunctional
markovFunctional :: forall y sv sidx.
GenYieldTermStructure y
-> Double
-> Double
-> [(Day, Double)]
-> GenSwaptionVolatilityStructure sv
-> NonEmpty (Day, (Word, TimeUnit))
-> GenSwapIndex sidx
-> Word
-> IO MarkovFunctional
markovFunctional GenYieldTermStructure y
ts Double
reversion Double
initialVol [(Day, Double)]
steps GenSwaptionVolatilityStructure sv
svol NonEmpty (Day, (Word, TimeUnit))
points = GenYieldTermStructure y
-> Double
-> [Day]
-> [Double]
-> GenSwaptionVolatilityStructure sv
-> [Day]
-> [Word]
-> [TimeUnit]
-> GenSwapIndex sidx
-> Word
-> IO MarkovFunctional
forall y sv sidx.
GenYieldTermStructure y
-> Double
-> [Day]
-> [Double]
-> GenSwaptionVolatilityStructure sv
-> [Day]
-> [Word]
-> [TimeUnit]
-> GenSwapIndex sidx
-> Word
-> IO MarkovFunctional
qlMarkovFunctional GenYieldTermStructure y
ts Double
reversion [Day]
dates (Double
initialVol Double -> [Double] -> [Double]
forall a. a -> [a] -> [a]
: [Double]
vols) GenSwaptionVolatilityStructure sv
svol [Day]
expiries [Word]
tq [TimeUnit]
tu
  where ([Day]
dates, [Double]
vols) = [(Day, Double)] -> ([Day], [Double])
forall a b. [(a, b)] -> ([a], [b])
unzip [(Day, Double)]
steps
        ([Day]
expiries, [(Word, TimeUnit)]
tenors) = [(Day, (Word, TimeUnit))] -> ([Day], [(Word, TimeUnit)])
forall a b. [(a, b)] -> ([a], [b])
unzip (NonEmpty (Day, (Word, TimeUnit)) -> [(Day, (Word, TimeUnit))]
forall a. NonEmpty a -> [a]
toList NonEmpty (Day, (Word, TimeUnit))
points)
        ([Word]
tq, [TimeUnit]
tu) = [(Word, TimeUnit)] -> ([Word], [TimeUnit])
forall a b. [(a, b)] -> ([a], [b])
unzip [(Word, TimeUnit)]
tenors
qlMarkovFunctional :: (GenYieldTermStructure y) -> (Double) -> ([Day]) -> ([Double]) -> (GenSwaptionVolatilityStructure sv) -> ([Day]) -> ([Word]) -> ([TimeUnit]) -> (GenSwapIndex sidx) -> (Word) -> IO ((MarkovFunctional))
qlMarkovFunctional :: forall y sv sidx.
GenYieldTermStructure y
-> Double
-> [Day]
-> [Double]
-> GenSwaptionVolatilityStructure sv
-> [Day]
-> [Word]
-> [TimeUnit]
-> GenSwapIndex sidx
-> Word
-> IO MarkovFunctional
qlMarkovFunctional GenYieldTermStructure y
a1 Double
a2 [Day]
a3 [Double]
a4 GenSwaptionVolatilityStructure sv
a5 [Day]
a6 [Word]
a7 [TimeUnit]
a8 GenSwapIndex sidx
a9 Word
a10 =
  GenYieldTermStructure y
-> (Ptr CYieldTermStructure' -> IO MarkovFunctional)
-> IO MarkovFunctional
forall y b.
GenYieldTermStructure y
-> (Ptr CYieldTermStructure' -> IO b) -> IO b
withYieldTermStructure GenYieldTermStructure y
a1 ((Ptr CYieldTermStructure' -> IO MarkovFunctional)
 -> IO MarkovFunctional)
-> (Ptr CYieldTermStructure' -> IO MarkovFunctional)
-> IO MarkovFunctional
forall a b. (a -> b) -> a -> b
$ \Ptr CYieldTermStructure'
a1' -> 
  let {a2' :: CDouble
a2' = Double -> CDouble
forall a b. (Real a, Fractional b) => a -> b
realToFrac Double
a2} in 
  [Day]
-> ((CUInt, Ptr CInt) -> IO MarkovFunctional)
-> IO MarkovFunctional
forall b. [Day] -> ((CUInt, Ptr CInt) -> IO b) -> IO b
withDayArray [Day]
a3 (((CUInt, Ptr CInt) -> IO MarkovFunctional) -> IO MarkovFunctional)
-> ((CUInt, Ptr CInt) -> IO MarkovFunctional)
-> IO MarkovFunctional
forall a b. (a -> b) -> a -> b
$ \(CUInt
a3'1, Ptr CInt
a3'2) -> 
  [Double]
-> ((CUInt, Ptr CDouble) -> IO MarkovFunctional)
-> IO MarkovFunctional
forall b. [Double] -> ((CUInt, Ptr CDouble) -> IO b) -> IO b
withDoubleArray [Double]
a4 (((CUInt, Ptr CDouble) -> IO MarkovFunctional)
 -> IO MarkovFunctional)
-> ((CUInt, Ptr CDouble) -> IO MarkovFunctional)
-> IO MarkovFunctional
forall a b. (a -> b) -> a -> b
$ \(CUInt
a4'1, Ptr CDouble
a4'2) -> 
  GenSwaptionVolatilityStructure sv
-> (Ptr CSwaptionVolatilityStructure' -> IO MarkovFunctional)
-> IO MarkovFunctional
forall sv b.
GenSwaptionVolatilityStructure sv
-> (Ptr CSwaptionVolatilityStructure' -> IO b) -> IO b
withSwaptionVolatilityStructure GenSwaptionVolatilityStructure sv
a5 ((Ptr CSwaptionVolatilityStructure' -> IO MarkovFunctional)
 -> IO MarkovFunctional)
-> (Ptr CSwaptionVolatilityStructure' -> IO MarkovFunctional)
-> IO MarkovFunctional
forall a b. (a -> b) -> a -> b
$ \Ptr CSwaptionVolatilityStructure'
a5' -> 
  [Day]
-> ((CUInt, Ptr CInt) -> IO MarkovFunctional)
-> IO MarkovFunctional
forall b. [Day] -> ((CUInt, Ptr CInt) -> IO b) -> IO b
withDayArray [Day]
a6 (((CUInt, Ptr CInt) -> IO MarkovFunctional) -> IO MarkovFunctional)
-> ((CUInt, Ptr CInt) -> IO MarkovFunctional)
-> IO MarkovFunctional
forall a b. (a -> b) -> a -> b
$ \(CUInt
a6'1, Ptr CInt
a6'2) -> 
  [Word]
-> ((CUInt, Ptr CInt) -> IO MarkovFunctional)
-> IO MarkovFunctional
forall a n b.
(Integral a, Num n, Storable n) =>
[a] -> ((CUInt, Ptr n) -> IO b) -> IO b
withIntArray [Word]
a7 (((CUInt, Ptr CInt) -> IO MarkovFunctional) -> IO MarkovFunctional)
-> ((CUInt, Ptr CInt) -> IO MarkovFunctional)
-> IO MarkovFunctional
forall a b. (a -> b) -> a -> b
$ \(CUInt
a7'1, Ptr CInt
a7'2) -> 
  [TimeUnit]
-> ((CUInt, Ptr CInt) -> IO MarkovFunctional)
-> IO MarkovFunctional
forall a b. Enum a => [a] -> ((CUInt, Ptr CInt) -> IO b) -> IO b
withEnumArray [TimeUnit]
a8 (((CUInt, Ptr CInt) -> IO MarkovFunctional) -> IO MarkovFunctional)
-> ((CUInt, Ptr CInt) -> IO MarkovFunctional)
-> IO MarkovFunctional
forall a b. (a -> b) -> a -> b
$ \(CUInt
a8'1, Ptr CInt
a8'2) -> 
  GenSwapIndex sidx
-> (Ptr CSwapIndex' -> IO MarkovFunctional) -> IO MarkovFunctional
forall sidx b.
GenSwapIndex sidx -> (Ptr CSwapIndex' -> IO b) -> IO b
withSwapIndex GenSwapIndex sidx
a9 ((Ptr CSwapIndex' -> IO MarkovFunctional) -> IO MarkovFunctional)
-> (Ptr CSwapIndex' -> IO MarkovFunctional) -> IO MarkovFunctional
forall a b. (a -> b) -> a -> b
$ \Ptr CSwapIndex'
a9' -> 
  let {a10' :: CUInt
a10' = Word -> CUInt
forall a b. (Integral a, Num b) => a -> b
fromIntegral Word
a10} in 
  (Ptr (Ptr ()) -> IO MarkovFunctional) -> IO MarkovFunctional
forall a b. (Ptr (Ptr a) -> IO b) -> IO b
preErrorCheck ((Ptr (Ptr ()) -> IO MarkovFunctional) -> IO MarkovFunctional)
-> (Ptr (Ptr ()) -> IO MarkovFunctional) -> IO MarkovFunctional
forall a b. (a -> b) -> a -> b
$ \Ptr (Ptr ())
a11' -> 
  Ptr CYieldTermStructure'
-> CDouble
-> CUInt
-> Ptr CInt
-> CUInt
-> Ptr CDouble
-> Ptr CSwaptionVolatilityStructure'
-> CUInt
-> Ptr CInt
-> CUInt
-> Ptr CInt
-> CUInt
-> Ptr CInt
-> Ptr CSwapIndex'
-> CUInt
-> Ptr (Ptr ())
-> IO (Ptr CMarkovFunctional')
qlMarkovFunctional'_ Ptr CYieldTermStructure'
a1' CDouble
a2' CUInt
a3'1  Ptr CInt
a3'2 CUInt
a4'1  Ptr CDouble
a4'2 Ptr CSwaptionVolatilityStructure'
a5' CUInt
a6'1  Ptr CInt
a6'2 CUInt
a7'1  Ptr CInt
a7'2 CUInt
a8'1  Ptr CInt
a8'2 Ptr CSwapIndex'
a9' CUInt
a10' Ptr (Ptr ())
a11' IO (Ptr CMarkovFunctional')
-> (Ptr CMarkovFunctional' -> IO MarkovFunctional)
-> IO MarkovFunctional
forall a b. IO a -> (a -> IO b) -> IO b
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= \Ptr CMarkovFunctional'
res ->
  Ptr CMarkovFunctional' -> IO MarkovFunctional
peekMarkovFunctional Ptr CMarkovFunctional'
res IO MarkovFunctional
-> (MarkovFunctional -> IO MarkovFunctional) -> IO MarkovFunctional
forall a b. IO a -> (a -> IO b) -> IO b
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= \MarkovFunctional
res' ->
  Ptr (Ptr ()) -> IO ()
forall a. Ptr (Ptr a) -> IO ()
errorCheck  Ptr (Ptr ())
a11'IO () -> IO MarkovFunctional -> IO MarkovFunctional
forall a b. IO a -> IO b -> IO b
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>>
  MarkovFunctional -> IO MarkovFunctional
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return (MarkovFunctional
res')

{-# LINE 533 "./QuantLib/Model.chs" #-}


-- |Markov-functional interest-rate model, calibrated to a caplet volatility structure against @iborIndex@.
markovFunctionalCaplet :: GenYieldTermStructure y -> Double -> Double -> [(Day, Double)]
  -> GenOptionletVolatilityStructure ov -> NonEmpty Day -> GenIborIndex ibor -> Word -> IO MarkovFunctional
markovFunctionalCaplet ts reversion initialVol steps capletVol expiries ibor gridPoints =
  qlMarkovFunctionalCaplet ts reversion dates (initialVol : vols) capletVol (toList expiries) ibor gridPoints
  where (dates, vols) = unzip steps
qlMarkovFunctionalCaplet :: (GenYieldTermStructure y) -> (Double) -- ^reversion
 -> ([Day]) -- ^volstepdates
 -> ([Double]) -- ^volatilities
 -> (GenOptionletVolatilityStructure ov) -- ^capletVol
 -> ([Day]) -- ^capletExpiries
 -> (GenIborIndex ibor) -- ^iborIndex
 -> (Word) -- ^yGridPoints
 -> IO ((MarkovFunctional))
qlMarkovFunctionalCaplet :: forall y ov ibor.
GenYieldTermStructure y
-> Double
-> [Day]
-> [Double]
-> GenOptionletVolatilityStructure ov
-> [Day]
-> GenIborIndex ibor
-> Word
-> IO MarkovFunctional
qlMarkovFunctionalCaplet GenYieldTermStructure y
a1 Double
a2 [Day]
a3 [Double]
a4 GenOptionletVolatilityStructure ov
a5 [Day]
a6 GenIborIndex ibor
a7 Word
a8 =
  GenYieldTermStructure y
-> (Ptr CYieldTermStructure' -> IO MarkovFunctional)
-> IO MarkovFunctional
forall y b.
GenYieldTermStructure y
-> (Ptr CYieldTermStructure' -> IO b) -> IO b
withYieldTermStructure GenYieldTermStructure y
a1 ((Ptr CYieldTermStructure' -> IO MarkovFunctional)
 -> IO MarkovFunctional)
-> (Ptr CYieldTermStructure' -> IO MarkovFunctional)
-> IO MarkovFunctional
forall a b. (a -> b) -> a -> b
$ \Ptr CYieldTermStructure'
a1' -> 
  let {a2' :: CDouble
a2' = Double -> CDouble
forall a b. (Real a, Fractional b) => a -> b
realToFrac Double
a2} in 
  [Day]
-> ((CUInt, Ptr CInt) -> IO MarkovFunctional)
-> IO MarkovFunctional
forall b. [Day] -> ((CUInt, Ptr CInt) -> IO b) -> IO b
withDayArray [Day]
a3 (((CUInt, Ptr CInt) -> IO MarkovFunctional) -> IO MarkovFunctional)
-> ((CUInt, Ptr CInt) -> IO MarkovFunctional)
-> IO MarkovFunctional
forall a b. (a -> b) -> a -> b
$ \(CUInt
a3'1, Ptr CInt
a3'2) -> 
  [Double]
-> ((CUInt, Ptr CDouble) -> IO MarkovFunctional)
-> IO MarkovFunctional
forall b. [Double] -> ((CUInt, Ptr CDouble) -> IO b) -> IO b
withDoubleArray [Double]
a4 (((CUInt, Ptr CDouble) -> IO MarkovFunctional)
 -> IO MarkovFunctional)
-> ((CUInt, Ptr CDouble) -> IO MarkovFunctional)
-> IO MarkovFunctional
forall a b. (a -> b) -> a -> b
$ \(CUInt
a4'1, Ptr CDouble
a4'2) -> 
  GenOptionletVolatilityStructure ov
-> (Ptr COptionletVolatilityStructure' -> IO MarkovFunctional)
-> IO MarkovFunctional
forall ov b.
GenOptionletVolatilityStructure ov
-> (Ptr COptionletVolatilityStructure' -> IO b) -> IO b
withOptionletVolatilityStructure GenOptionletVolatilityStructure ov
a5 ((Ptr COptionletVolatilityStructure' -> IO MarkovFunctional)
 -> IO MarkovFunctional)
-> (Ptr COptionletVolatilityStructure' -> IO MarkovFunctional)
-> IO MarkovFunctional
forall a b. (a -> b) -> a -> b
$ \Ptr COptionletVolatilityStructure'
a5' -> 
  [Day]
-> ((CUInt, Ptr CInt) -> IO MarkovFunctional)
-> IO MarkovFunctional
forall b. [Day] -> ((CUInt, Ptr CInt) -> IO b) -> IO b
withDayArray [Day]
a6 (((CUInt, Ptr CInt) -> IO MarkovFunctional) -> IO MarkovFunctional)
-> ((CUInt, Ptr CInt) -> IO MarkovFunctional)
-> IO MarkovFunctional
forall a b. (a -> b) -> a -> b
$ \(CUInt
a6'1, Ptr CInt
a6'2) -> 
  GenIborIndex ibor
-> (Ptr CIborIndex' -> IO MarkovFunctional) -> IO MarkovFunctional
forall ibor b.
GenIborIndex ibor -> (Ptr CIborIndex' -> IO b) -> IO b
withIborIndex GenIborIndex ibor
a7 ((Ptr CIborIndex' -> IO MarkovFunctional) -> IO MarkovFunctional)
-> (Ptr CIborIndex' -> IO MarkovFunctional) -> IO MarkovFunctional
forall a b. (a -> b) -> a -> b
$ \a7' -> 
  let {a8' = fromIntegral a8} in 
  (Ptr (Ptr ()) -> IO MarkovFunctional) -> IO MarkovFunctional
forall a b. (Ptr (Ptr a) -> IO b) -> IO b
preErrorCheck ((Ptr (Ptr ()) -> IO MarkovFunctional) -> IO MarkovFunctional)
-> (Ptr (Ptr ()) -> IO MarkovFunctional) -> IO MarkovFunctional
forall a b. (a -> b) -> a -> b
$ \Ptr (Ptr ())
a9' -> 
  qlMarkovFunctionalCaplet'_ a1' CDouble
a2' CUInt
a3'1  Ptr CInt
a3'2 CUInt
a4'1  Ptr CDouble
a4'2 Ptr COptionletVolatilityStructure'
a5' CUInt
a6'1  Ptr CInt
a6'2 Ptr CIborIndex'
a7' CUInt
a8' Ptr (Ptr ())
a9' IO (Ptr CMarkovFunctional')
-> (Ptr CMarkovFunctional' -> IO MarkovFunctional)
-> IO MarkovFunctional
forall a b. IO a -> (a -> IO b) -> IO b
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= \Ptr CMarkovFunctional'
res ->
  Ptr CMarkovFunctional' -> IO MarkovFunctional
peekMarkovFunctional Ptr CMarkovFunctional'
res IO MarkovFunctional
-> (MarkovFunctional -> IO MarkovFunctional) -> IO MarkovFunctional
forall a b. IO a -> (a -> IO b) -> IO b
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= \MarkovFunctional
res' ->
  Ptr (Ptr ()) -> IO ()
forall a. Ptr (Ptr a) -> IO ()
errorCheck  Ptr (Ptr ())
a9'IO () -> IO MarkovFunctional -> IO MarkovFunctional
forall a b. IO a -> IO b -> IO b
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>>
  MarkovFunctional -> IO MarkovFunctional
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return (MarkovFunctional
res')

{-# LINE 548 "./QuantLib/Model.chs" #-}


-- |Volatility step values, as calibrated so far.
qlMarkovFunctionalVolatility :: (MarkovFunctional) -> IO (([Double]))
qlMarkovFunctionalVolatility a1 =
  withGenCalibratedModel a1 $ \a1' -> 
  preDoubleArray $ \(a2'1, a2'2) -> 
  preErrorCheck $ \a3' -> 
  qlMarkovFunctionalVolatility'_ a1' a2'1  a2'2 a3' >>
  peekDoubleArray  a2'1  a2'2>>= \a2'' -> 
  errorCheck  a3'>>
  return (a2'')

{-# LINE 551 "./QuantLib/Model.chs" #-}


-- |Discount factor at time @t@ under the model's own fitted curve -- @AffineModel::discount@.
-- Not 'pure': depends on the model's 'YieldTermStructure' handle, which can be relinked after
-- construction (see 'discountBond' below for the same caveat).
discount :: (AffineModel) -> (Double) -- ^t
 -> IO ((Double))
discount a1 a2 =
  withStandalone a1 $ \a1' -> 
  let {a2' = realToFrac a2} in 
  preErrorCheck $ \a3' -> 
  discount'_ a1' a2' a3' >>= \res ->
  let {res' = realToFrac res} in
  errorCheck  a3'>>
  return (res')

{-# LINE 558 "./QuantLib/Model.chs" #-}


-- |Price of a discount bond paying 1 at @maturity@, given the model's state @factors@ at time
-- @now@ -- @AffineModel::discountBond(Time,Time,Array)@. @factors@ is model-specific: a
-- one-element list of the short rate for 'OneFactorAffineModel'\/'HullWhite', a two-element list
-- for G2, or ignored by 'LiborForwardModel'. Not 'pure' for the same relinkable-curve reason as
-- 'discount'.
discountBond :: (AffineModel) -> (Double) -- ^now
 -> (Double) -- ^maturity
 -> ([Double]) -- ^factors
 -> IO ((Double))
discountBond :: AffineModel -> Double -> Double -> [Double] -> IO Double
discountBond AffineModel
a1 Double
a2 Double
a3 [Double]
a4 =
  AffineModel -> (Ptr CAffineModel' -> IO Double) -> IO Double
forall a b. Standalone a -> (Ptr a -> IO b) -> IO b
withStandalone AffineModel
a1 ((Ptr CAffineModel' -> IO Double) -> IO Double)
-> (Ptr CAffineModel' -> IO Double) -> IO Double
forall a b. (a -> b) -> a -> b
$ \Ptr CAffineModel'
a1' -> 
  let {a2' :: CDouble
a2' = Double -> CDouble
forall a b. (Real a, Fractional b) => a -> b
realToFrac Double
a2} in 
  let {a3' :: CDouble
a3' = Double -> CDouble
forall a b. (Real a, Fractional b) => a -> b
realToFrac Double
a3} in 
  [Double] -> ((CUInt, Ptr CDouble) -> IO Double) -> IO Double
forall b. [Double] -> ((CUInt, Ptr CDouble) -> IO b) -> IO b
withDoubleArray [Double]
a4 (((CUInt, Ptr CDouble) -> IO Double) -> IO Double)
-> ((CUInt, Ptr CDouble) -> IO Double) -> IO Double
forall a b. (a -> b) -> a -> b
$ \(CUInt
a4'1, Ptr CDouble
a4'2) -> 
  (Ptr (Ptr ()) -> IO Double) -> IO Double
forall a b. (Ptr (Ptr a) -> IO b) -> IO b
preErrorCheck ((Ptr (Ptr ()) -> IO Double) -> IO Double)
-> (Ptr (Ptr ()) -> IO Double) -> IO Double
forall a b. (a -> b) -> a -> b
$ \Ptr (Ptr ())
a5' -> 
  Ptr CAffineModel'
-> CDouble
-> CDouble
-> CUInt
-> Ptr CDouble
-> Ptr (Ptr ())
-> IO CDouble
discountBond'_ Ptr CAffineModel'
a1' CDouble
a2' CDouble
a3' CUInt
a4'1  Ptr CDouble
a4'2 Ptr (Ptr ())
a5' IO CDouble -> (CDouble -> IO Double) -> IO Double
forall a b. IO a -> (a -> IO b) -> IO b
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= \CDouble
res ->
  let {res' :: Double
res' = CDouble -> Double
forall a b. (Real a, Fractional b) => a -> b
realToFrac CDouble
res} in
  Ptr (Ptr ()) -> IO ()
forall a. Ptr (Ptr a) -> IO ()
errorCheck  Ptr (Ptr ())
a5'IO () -> IO Double -> IO Double
forall a b. IO a -> IO b -> IO b
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>>
  Double -> IO Double
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return (Double
res')

{-# LINE 569 "./QuantLib/Model.chs" #-}


discountBondOption_ :: (AffineModel) -> (OptionType) -- ^type
 -> (Double) -- ^strike
 -> (Double) -- ^maturity
 -> (Bool) -- ^haveBondStart
 -> (Double) -- ^bondStart
 -> (Double) -- ^bondMaturity
 -> IO ((Double))
discountBondOption_ a1 a2 a3 a4 a5 a6 a7 =
  withStandalone a1 $ \a1' -> 
  let {a2' = fromEnumC a2} in 
  let {a3' = realToFrac a3} in 
  let {a4' = realToFrac a4} in 
  let {a5' = C2HSImp.fromBool a5} in 
  let {a6' = realToFrac a6} in 
  let {a7' = realToFrac a7} in 
  preErrorCheck $ \a8' -> 
  discountBondOption_'_ a1' a2' a3' a4' a5' a6' a7' a8' >>= \res ->
  let {res' = realToFrac res} in
  errorCheck  a8'>>
  return (res')

{-# LINE 578 "./QuantLib/Model.chs" #-}


-- |Analytic price of a European option on a discount bond paying 1 at @bondMaturity@. 'Nothing'
-- starts the bond at option expiry; 'Just' supplies a distinct bond start. Only 'HullWhite'
-- distinguishes the two upstream overloads.
discountBondOption :: AffineModel -> OptionType -> Double -> Double -> Maybe Double -> Double -> IO Double
discountBondOption model typ strike maturity bondStart bondMaturity =
  discountBondOption_ model typ strike maturity (maybe False (const True) bondStart) (fromMaybe 0 bondStart) bondMaturity

-- |Numeraire value at @referenceDate@, conditional on the standardized state variable @y@
-- (0 = the model's expected path). @yts@ overrides the model's own term structure for
-- discounting when given, otherwise the model's own curve is used.
numeraire :: (Gaussian1dModel) -> (Day) -- ^referenceDate
 -> (Double) -- ^y
 -> (Maybe (GenYieldTermStructure y)) -- ^yts
 -> IO ((Double))
numeraire :: forall y.
Gaussian1dModel
-> Day -> Double -> Maybe (GenYieldTermStructure y) -> IO Double
numeraire Gaussian1dModel
a1 Day
a2 Double
a3 Maybe (GenYieldTermStructure y)
a4 =
  Gaussian1dModel
-> (Ptr CGaussian1dModel' -> IO Double) -> IO Double
forall a b. Standalone a -> (Ptr a -> IO b) -> IO b
withStandalone Gaussian1dModel
a1 ((Ptr CGaussian1dModel' -> IO Double) -> IO Double)
-> (Ptr CGaussian1dModel' -> IO Double) -> IO Double
forall a b. (a -> b) -> a -> b
$ \Ptr CGaussian1dModel'
a1' -> 
  Day -> (CInt -> IO Double) -> IO Double
forall a. Day -> (CInt -> IO a) -> IO a
withDay Day
a2 ((CInt -> IO Double) -> IO Double)
-> (CInt -> IO Double) -> IO Double
forall a b. (a -> b) -> a -> b
$ \CInt
a2' -> 
  let {a3' :: CDouble
a3' = Double -> CDouble
forall a b. (Real a, Fractional b) => a -> b
realToFrac Double
a3} in 
  Maybe (GenYieldTermStructure y)
-> (Ptr CYieldTermStructure' -> IO Double) -> IO Double
forall y b.
Maybe (GenYieldTermStructure y)
-> (Ptr CYieldTermStructure' -> IO b) -> IO b
withMaybeYieldTermStructure Maybe (GenYieldTermStructure y)
a4 ((Ptr CYieldTermStructure' -> IO Double) -> IO Double)
-> (Ptr CYieldTermStructure' -> IO Double) -> IO Double
forall a b. (a -> b) -> a -> b
$ \Ptr CYieldTermStructure'
a4' -> 
  (Ptr (Ptr ()) -> IO Double) -> IO Double
forall a b. (Ptr (Ptr a) -> IO b) -> IO b
preErrorCheck ((Ptr (Ptr ()) -> IO Double) -> IO Double)
-> (Ptr (Ptr ()) -> IO Double) -> IO Double
forall a b. (a -> b) -> a -> b
$ \Ptr (Ptr ())
a5' -> 
  Ptr CGaussian1dModel'
-> CInt
-> CDouble
-> Ptr CYieldTermStructure'
-> Ptr (Ptr ())
-> IO CDouble
numeraire'_ Ptr CGaussian1dModel'
a1' CInt
a2' CDouble
a3' Ptr CYieldTermStructure'
a4' Ptr (Ptr ())
a5' IO CDouble -> (CDouble -> IO Double) -> IO Double
forall a b. IO a -> (a -> IO b) -> IO b
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= \CDouble
res ->
  let {res' :: Double
res' = CDouble -> Double
forall a b. (Real a, Fractional b) => a -> b
realToFrac CDouble
res} in
  Ptr (Ptr ()) -> IO ()
forall a. Ptr (Ptr a) -> IO ()
errorCheck  Ptr (Ptr ())
a5'IO () -> IO Double -> IO Double
forall a b. IO a -> IO b -> IO b
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>>
  Double -> IO Double
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return (Double
res')

{-# LINE 594 "./QuantLib/Model.chs" #-}


-- |Price at @referenceDate@ (default: the evaluation date) of a zero-coupon bond paying 1 at
-- @maturity@, conditional on the standardized state variable @y@ (0 = the model's expected
-- path). @yts@ overrides the model's own term structure for discounting when given.
gaussian1dZerobond :: (Gaussian1dModel) -> (Day) -- ^maturity
 -> (Maybe Day) -- ^referenceDate
 -> (Double) -- ^y
 -> (Maybe (GenYieldTermStructure y)) -- ^yts
 -> IO ((Double))
gaussian1dZerobond a1 a2 a3 a4 a5 =
  withStandalone a1 $ \a1' -> 
  withDay a2 $ \a2' -> 
  withMaybeDay a3 $ \a3' -> 
  let {a4' = realToFrac a4} in 
  withMaybeYieldTermStructure a5 $ \a5' -> 
  preErrorCheck $ \a6' -> 
  gaussian1dZerobond'_ a1' a2' a3' a4' a5' a6' >>= \res ->
  let {res' = realToFrac res} in
  errorCheck  a6'>>
  return (res')

{-# LINE 604 "./QuantLib/Model.chs" #-}


-- |Price of a European option of @type@, expiring at @expiry@ with @strike@, on a zero-coupon
-- bond that itself pays 1 at @maturity@ and settles at @valueDate@, conditional on the
-- standardized state variable @y@ at @referenceDate@ (default: the evaluation date). @yts@
-- overrides the model's own discounting curve when given. The option payoff is evaluated on a
-- grid of @yGridPoints@ points spanning @yStdDevs@ standard deviations of @y@;
-- @extrapolatePayoff@\/@flatPayoffExtrapolation@ control payoff extrapolation beyond the grid.
gaussian1dZerobondOption :: (Gaussian1dModel) -> (OptionType) -- ^type
 -> (Day) -- ^expiry
 -> (Day) -- ^valueDate
 -> (Day) -- ^maturity
 -> (Double) -- ^strike
 -> (Maybe Day) -- ^referenceDate
 -> (Double) -- ^y
 -> (Maybe (GenYieldTermStructure y)) -- ^yts
 -> (Double) -- ^yStdDevs
 -> (Word) -- ^yGridPoints
 -> (Bool) -- ^extrapolatePayoff
 -> (Bool) -- ^flatPayoffExtrapolation
 -> IO ((Double))
gaussian1dZerobondOption :: forall y.
Gaussian1dModel
-> OptionType
-> Day
-> Day
-> Day
-> Double
-> Maybe Day
-> Double
-> Maybe (GenYieldTermStructure y)
-> Double
-> Word
-> Bool
-> Bool
-> IO Double
gaussian1dZerobondOption Gaussian1dModel
a1 OptionType
a2 Day
a3 Day
a4 Day
a5 Double
a6 Maybe Day
a7 Double
a8 Maybe (GenYieldTermStructure y)
a9 Double
a10 Word
a11 Bool
a12 Bool
a13 =
  Gaussian1dModel
-> (Ptr CGaussian1dModel' -> IO Double) -> IO Double
forall a b. Standalone a -> (Ptr a -> IO b) -> IO b
withStandalone Gaussian1dModel
a1 ((Ptr CGaussian1dModel' -> IO Double) -> IO Double)
-> (Ptr CGaussian1dModel' -> IO Double) -> IO Double
forall a b. (a -> b) -> a -> b
$ \Ptr CGaussian1dModel'
a1' -> 
  let {a2' :: CInt
a2' = OptionType -> CInt
forall a b. (Enum a, Integral b) => a -> b
fromEnumC OptionType
a2} in 
  Day -> (CInt -> IO Double) -> IO Double
forall a. Day -> (CInt -> IO a) -> IO a
withDay Day
a3 ((CInt -> IO Double) -> IO Double)
-> (CInt -> IO Double) -> IO Double
forall a b. (a -> b) -> a -> b
$ \CInt
a3' -> 
  Day -> (CInt -> IO Double) -> IO Double
forall a. Day -> (CInt -> IO a) -> IO a
withDay Day
a4 ((CInt -> IO Double) -> IO Double)
-> (CInt -> IO Double) -> IO Double
forall a b. (a -> b) -> a -> b
$ \CInt
a4' -> 
  Day -> (CInt -> IO Double) -> IO Double
forall a. Day -> (CInt -> IO a) -> IO a
withDay Day
a5 ((CInt -> IO Double) -> IO Double)
-> (CInt -> IO Double) -> IO Double
forall a b. (a -> b) -> a -> b
$ \CInt
a5' -> 
  let {a6' :: CDouble
a6' = Double -> CDouble
forall a b. (Real a, Fractional b) => a -> b
realToFrac Double
a6} in 
  Maybe Day -> (CInt -> IO Double) -> IO Double
forall a. Maybe Day -> (CInt -> IO a) -> IO a
withMaybeDay Maybe Day
a7 ((CInt -> IO Double) -> IO Double)
-> (CInt -> IO Double) -> IO Double
forall a b. (a -> b) -> a -> b
$ \CInt
a7' -> 
  let {a8' :: CDouble
a8' = Double -> CDouble
forall a b. (Real a, Fractional b) => a -> b
realToFrac Double
a8} in 
  Maybe (GenYieldTermStructure y)
-> (Ptr CYieldTermStructure' -> IO Double) -> IO Double
forall y b.
Maybe (GenYieldTermStructure y)
-> (Ptr CYieldTermStructure' -> IO b) -> IO b
withMaybeYieldTermStructure Maybe (GenYieldTermStructure y)
a9 ((Ptr CYieldTermStructure' -> IO Double) -> IO Double)
-> (Ptr CYieldTermStructure' -> IO Double) -> IO Double
forall a b. (a -> b) -> a -> b
$ \Ptr CYieldTermStructure'
a9' -> 
  let {a10' :: CDouble
a10' = Double -> CDouble
forall a b. (Real a, Fractional b) => a -> b
realToFrac Double
a10} in 
  let {a11' :: CUInt
a11' = Word -> CUInt
forall a b. (Integral a, Num b) => a -> b
fromIntegral Word
a11} in 
  let {a12' :: CInt
a12' = Bool -> CInt
forall a. Num a => Bool -> a
C2HSImp.fromBool Bool
a12} in 
  let {a13' :: CInt
a13' = Bool -> CInt
forall a. Num a => Bool -> a
C2HSImp.fromBool Bool
a13} in 
  (Ptr (Ptr ()) -> IO Double) -> IO Double
forall a b. (Ptr (Ptr a) -> IO b) -> IO b
preErrorCheck ((Ptr (Ptr ()) -> IO Double) -> IO Double)
-> (Ptr (Ptr ()) -> IO Double) -> IO Double
forall a b. (a -> b) -> a -> b
$ \Ptr (Ptr ())
a14' -> 
  Ptr CGaussian1dModel'
-> CInt
-> CInt
-> CInt
-> CInt
-> CDouble
-> CInt
-> CDouble
-> Ptr CYieldTermStructure'
-> CDouble
-> CUInt
-> CInt
-> CInt
-> Ptr (Ptr ())
-> IO CDouble
gaussian1dZerobondOption'_ Ptr CGaussian1dModel'
a1' CInt
a2' CInt
a3' CInt
a4' CInt
a5' CDouble
a6' CInt
a7' CDouble
a8' Ptr CYieldTermStructure'
a9' CDouble
a10' CUInt
a11' CInt
a12' CInt
a13' Ptr (Ptr ())
a14' IO CDouble -> (CDouble -> IO Double) -> IO Double
forall a b. IO a -> (a -> IO b) -> IO b
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= \CDouble
res ->
  let {res' :: Double
res' = CDouble -> Double
forall a b. (Real a, Fractional b) => a -> b
realToFrac CDouble
res} in
  Ptr (Ptr ()) -> IO ()
forall a. Ptr (Ptr a) -> IO ()
errorCheck  Ptr (Ptr ())
a14'IO () -> IO Double -> IO Double
forall a b. IO a -> IO b -> IO b
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>>
  Double -> IO Double
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return (Double
res')

{-# LINE 625 "./QuantLib/Model.chs" #-}


-- |Forward rate for @iborIdx@ fixing on @fixing@, conditional on the standardized state
-- variable @y@ at @referenceDate@ (default: the evaluation date). @iborIdx@ defaults to the
-- model's own term structure's natural index when omitted.
gaussian1dForwardRate :: (Gaussian1dModel) -> (Day) -- ^fixing
 -> (Maybe Day) -- ^referenceDate
 -> (Double) -- ^y
 -> (Maybe (GenIborIndex ibor)) -- ^iborIdx
 -> IO ((Double))
gaussian1dForwardRate a1 a2 a3 a4 a5 =
  withStandalone a1 $ \a1' -> 
  withDay a2 $ \a2' -> 
  withMaybeDay a3 $ \a3' -> 
  let {a4' = realToFrac a4} in 
  withMaybeIborIndex a5 $ \a5' -> 
  preErrorCheck $ \a6' -> 
  gaussian1dForwardRate'_ a1' a2' a3' a4' a5' a6' >>= \res ->
  let {res' = realToFrac res} in
  errorCheck  a6'>>
  return (res')

{-# LINE 635 "./QuantLib/Model.chs" #-}


-- |Fair swap rate for a swap on @swapIdx@ fixing on @fixing@ with tenor @tenor@, conditional on
-- the standardized state variable @y@ at @referenceDate@ (default: the evaluation date).
gaussian1dSwapRate :: (Gaussian1dModel) -> (Day) -- ^fixing
 -> ((Int,TimeUnit)) -- ^tenor
 -> (Maybe Day) -- ^referenceDate
 -> (Double) -- ^y
 -> (Maybe (GenSwapIndex sidx)) -- ^swapIdx
 -> IO ((Double))
gaussian1dSwapRate a1 a2 a3 a4 a5 a6 =
  withStandalone a1 $ \a1' -> 
  withDay a2 $ \a2' -> 
  let {(a3'1, a3'2) = fromEnumQuantity a3} in 
  withMaybeDay a4 $ \a4' -> 
  let {a5' = realToFrac a5} in 
  withMaybeSwapIndex a6 $ \a6' -> 
  preErrorCheck $ \a7' -> 
  gaussian1dSwapRate'_ a1' a2' a3'1  a3'2 a4' a5' a6' a7' >>= \res ->
  let {res' = realToFrac res} in
  errorCheck  a7'>>
  return (res')

{-# LINE 645 "./QuantLib/Model.chs" #-}


-- |Annuity (present value of a 1bp fixed leg) of a swap on @swapIdx@ fixing on @fixing@ with
-- tenor @tenor@, conditional on the standardized state variable @y@ at @referenceDate@
-- (default: the evaluation date).
gaussian1dSwapAnnuity :: (Gaussian1dModel) -> (Day) -- ^fixing
 -> ((Int,TimeUnit)) -- ^tenor
 -> (Maybe Day) -- ^referenceDate
 -> (Double) -- ^y
 -> (Maybe (GenSwapIndex sidx)) -- ^swapIdx
 -> IO ((Double))
gaussian1dSwapAnnuity a1 a2 a3 a4 a5 a6 =
  withStandalone a1 $ \a1' -> 
  withDay a2 $ \a2' -> 
  let {(a3'1, a3'2) = fromEnumQuantity a3} in 
  withMaybeDay a4 $ \a4' -> 
  let {a5' = realToFrac a5} in 
  withMaybeSwapIndex a6 $ \a6' -> 
  preErrorCheck $ \a7' -> 
  gaussian1dSwapAnnuity'_ a1' a2' a3'1  a3'2 a4' a5' a6' a7' >>= \res ->
  let {res' = realToFrac res} in
  errorCheck  a7'>>
  return (res')

{-# LINE 656 "./QuantLib/Model.chs" #-}


-- |Grid of values for the standardized state variable at time @T@, conditional on the
-- variable being @y@ at time @t@, spanning @yStdDevs@ standard deviations with
-- @2*gridPoints+1@ points.
gaussian1dYGrid :: (Gaussian1dModel) -> (Double) -- ^yStdDevs
 -> (Int) -- ^gridPoints
 -> (Double) -- ^bigT
 -> (Double) -- ^t
 -> (Double) -- ^y
 -> IO ((RealVector))
gaussian1dYGrid a1 a2 a3 a4 a5 a6 =
  withStandalone a1 $ \a1' -> 
  let {a2' = realToFrac a2} in 
  let {a3' = fromIntegral a3} in 
  let {a4' = realToFrac a4} in 
  let {a5' = realToFrac a5} in 
  let {a6' = realToFrac a6} in 
  preDoubleArray $ \(a7'1, a7'2) -> 
  preErrorCheck $ \a8' -> 
  gaussian1dYGrid'_ a1' a2' a3' a4' a5' a6' a7'1  a7'2 a8' >>
  peekRealVector  a7'1  a7'2>>= \a7'' -> 
  errorCheck  a8'>>
  return (a7'')

{-# LINE 668 "./QuantLib/Model.chs" #-}


-- |The model's own state process. Throws if the model was constructed without one set.
stateProcess :: (Gaussian1dModel) -> IO ((StochasticProcess1D))
stateProcess a1 =
  withStandalone a1 $ \a1' -> 
  preErrorCheck $ \a2' -> 
  stateProcess'_ a1' a2' >>= \res ->
  peekStochasticProcess1D res >>= \res' ->
  errorCheck  a2'>>
  return (res')

{-# LINE 671 "./QuantLib/Model.chs" #-}


-- |Models that expose a calibrated local-volatility leverage function.
class HasLeverageFunction a where
  leverageFunction :: a -> IO LocalVolTermStructure
instance HasLeverageFunction HestonSLVMCModel where
  leverageFunction = qlHestonSLVMCModelLeverageFunction
instance HasLeverageFunction HestonSLVFDMModel where
  leverageFunction = qlHestonSLVFDMModelLeverageFunction

-- |Models that expose their calibrated volatility step values.
class HasVolatilities a where
  volatilities :: a -> IO [Double]
instance HasVolatilities Gsr where
  volatilities :: Gsr -> IO [Double]
volatilities = Gsr -> IO [Double]
qlGsrVolatility
instance HasVolatilities MarkovFunctional where
  volatilities :: MarkovFunctional -> IO [Double]
volatilities = MarkovFunctional -> IO [Double]
qlMarkovFunctionalVolatility

-- |Variance Gamma model for the underlying's log-return process (Madan-Carr-Chang).
varianceGammaModel :: (VarianceGammaProcess) -> IO ((CalibratedModel))
varianceGammaModel :: VarianceGammaProcess -> IO CalibratedModel
varianceGammaModel VarianceGammaProcess
a1 =
  VarianceGammaProcess
-> (Ptr CVarianceGammaProcess' -> IO CalibratedModel)
-> IO CalibratedModel
forall p1d b.
GenStochasticProcess1D (ForeignPtr p1d)
-> (Ptr p1d -> IO b) -> IO b
withGenStochasticProcess1D VarianceGammaProcess
a1 ((Ptr CVarianceGammaProcess' -> IO CalibratedModel)
 -> IO CalibratedModel)
-> (Ptr CVarianceGammaProcess' -> IO CalibratedModel)
-> IO CalibratedModel
forall a b. (a -> b) -> a -> b
$ \Ptr CVarianceGammaProcess'
a1' -> 
  (Ptr (Ptr ()) -> IO CalibratedModel) -> IO CalibratedModel
forall a b. (Ptr (Ptr a) -> IO b) -> IO b
preErrorCheck ((Ptr (Ptr ()) -> IO CalibratedModel) -> IO CalibratedModel)
-> (Ptr (Ptr ()) -> IO CalibratedModel) -> IO CalibratedModel
forall a b. (a -> b) -> a -> b
$ \Ptr (Ptr ())
a2' -> 
  Ptr CVarianceGammaProcess'
-> Ptr (Ptr ()) -> IO (Ptr CCalibratedModel')
varianceGammaModel'_ Ptr CVarianceGammaProcess'
a1' Ptr (Ptr ())
a2' IO (Ptr CCalibratedModel')
-> (Ptr CCalibratedModel' -> IO CalibratedModel)
-> IO CalibratedModel
forall a b. IO a -> (a -> IO b) -> IO b
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= \Ptr CCalibratedModel'
res ->
  Ptr CCalibratedModel' -> IO CalibratedModel
peekCalibratedModel Ptr CCalibratedModel'
res IO CalibratedModel
-> (CalibratedModel -> IO CalibratedModel) -> IO CalibratedModel
forall a b. IO a -> (a -> IO b) -> IO b
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= \CalibratedModel
res' ->
  Ptr (Ptr ()) -> IO ()
forall a. Ptr (Ptr a) -> IO ()
errorCheck  Ptr (Ptr ())
a2'IO () -> IO CalibratedModel -> IO CalibratedModel
forall a b. IO a -> IO b -> IO b
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>>
  CalibratedModel -> IO CalibratedModel
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return (CalibratedModel
res')

{-# LINE 690 "./QuantLib/Model.chs" #-}


-- |Vasicek short-rate model: dr = a(b - r) dt + sigma dW, with an optional risk premium @lambda@.
vasicek :: (Double) -- ^r0
 -> (Double) -- ^a
 -> (Double) -- ^b
 -> (Double) -- ^sigma
 -> (Double) -- ^lambda
 -> IO ((OneFactorAffineModel))
vasicek :: Double
-> Double -> Double -> Double -> Double -> IO OneFactorAffineModel
vasicek Double
a1 Double
a2 Double
a3 Double
a4 Double
a5 =
  let {a1' :: CDouble
a1' = Double -> CDouble
forall a b. (Real a, Fractional b) => a -> b
realToFrac Double
a1} in 
  let {a2' :: CDouble
a2' = Double -> CDouble
forall a b. (Real a, Fractional b) => a -> b
realToFrac Double
a2} in 
  let {a3' :: CDouble
a3' = Double -> CDouble
forall a b. (Real a, Fractional b) => a -> b
realToFrac Double
LmCorrelationModel
a3 :: Double
a3 :: LmCorrelationModel
a3} in 
  let {a4' :: CDouble
a4' = Double -> CDouble
forall a b. (Real a, Fractional b) => a -> b
realToFrac Double
a4} in 
  let {a5' :: CDouble
a5' = Double -> CDouble
forall a b. (Real a, Fractional b) => a -> b
realToFrac Double
a5} in 
  (Ptr (Ptr ()) -> IO OneFactorAffineModel)
-> IO OneFactorAffineModel
forall a b. (Ptr (Ptr a) -> IO b) -> IO b
preErrorCheck ((Ptr (Ptr ()) -> IO OneFactorAffineModel)
 -> IO OneFactorAffineModel)
-> (Ptr (Ptr ()) -> IO OneFactorAffineModel)
-> IO OneFactorAffineModel
forall a b. (a -> b) -> a -> b
$ \Ptr (Ptr ())
a6' -> 
  CDouble
-> CDouble
-> CDouble
-> CDouble
-> CDouble
-> Ptr (Ptr ())
-> IO (Ptr COneFactorAffineModel')
vasicek'_ CDouble
a1' CDouble
a2' CDouble
a3' CDouble
a4' CDouble
a5' Ptr (Ptr ())
a6' IO (Ptr COneFactorAffineModel')
-> (Ptr COneFactorAffineModel' -> IO OneFactorAffineModel)
-> IO OneFactorAffineModel
forall a b. IO a -> (a -> IO b) -> IO b
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= \Ptr COneFactorAffineModel'
res ->
  Ptr COneFactorAffineModel' -> IO OneFactorAffineModel
peekOneFactorAffineModel res >>= \OneFactorAffineModel
res' ->
  Ptr (Ptr ()) -> IO ()
forall a. Ptr (Ptr a) -> IO ()
errorCheck  Ptr (Ptr ())
a6'IO () -> IO OneFactorAffineModel -> IO OneFactorAffineModel
forall a b. IO a -> IO b -> IO b
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>>
  OneFactorAffineModel -> IO OneFactorAffineModel
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return (OneFactorAffineModel
res')

{-# LINE 698 "./QuantLib/Model.chs" #-}


-- |Libor market (BGM) forward-rate model, built from a 'LiborForwardModelProcess' plus volatility and correlation models.
liborForwardModel :: (LiborForwardModelProcess) -> (LmVolatilityModel) -> (LmCorrelationModel) -> IO ((LiborForwardModel))
liborForwardModel a1 a2 a3 =
  withGenStochasticProcess a1 $ \a1' -> 
  withLmVolatilityModel a2 $ \a2' -> 
  withLmCorrelationModel a3 $ \a3' -> 
  preErrorCheck $ \a4' -> 
  liborForwardModel'_ a1' a2' a3' a4' >>= \res ->
  peekLiborForwardModel res >>= \res' ->
  errorCheck  a4'>>
  return (res')

{-# LINE 701 "./QuantLib/Model.chs" #-}


-- |Initial value of the discrete forward rate indexed by /alpha/, as seen from time index /beta/
-- (both indices into the process's tenor structure): the model's calibration input @S_0(alpha,beta)@.
liborForwardModelS0 :: (LiborForwardModel) -> (Word) -- ^alpha
 -> (Word) -- ^beta
 -> IO ((Double))
liborForwardModelS0 a1 a2 a3 =
  withGenCalibratedModel a1 $ \a1' -> 
  let {a2' = fromIntegral a2} in 
  let {a3' = fromIntegral a3} in 
  preErrorCheck $ \a4' -> 
  liborForwardModelS0'_ a1' a2' a3' a4' >>= \res ->
  let {res' = realToFrac res} in
  errorCheck  a4'>>
  return (res')

{-# LINE 708 "./QuantLib/Model.chs" #-}


-- |Hull-White caplet-volatility parameterization for a Libor forward model. The correlation
-- matrix and factor count are explicit, mirroring QuantLib's defaulted constructor arguments;
-- pass an empty matrix and @1@ for its standard one-factor default.
lfmHullWhiteParameterization :: LiborForwardModelProcess -> GenOptionletVolatilityStructure ov
  -> Matrix Double -- ^correlation
  -> Word -- ^factors
  -> IO LfmHullWhiteParameterization
lfmHullWhiteParameterization process capletVol (Matrix rows cols values) factors = qlLfmHullWhiteParameterization process capletVol rows cols values factors
qlLfmHullWhiteParameterization :: (LiborForwardModelProcess) -- ^process
 -> (GenOptionletVolatilityStructure ov) -- ^capletVol
 -> (Word) -- ^correlationRows
 -> (Word) -- ^correlationColumns
 -> ([Double]) -- ^correlation
 -> (Word) -- ^factors
 -> IO ((LfmHullWhiteParameterization))
qlLfmHullWhiteParameterization :: forall ov.
LiborForwardModelProcess
-> GenOptionletVolatilityStructure ov
-> Word
-> Word
-> [Double]
-> Word
-> IO LfmHullWhiteParameterization
qlLfmHullWhiteParameterization LiborForwardModelProcess
a1 GenOptionletVolatilityStructure ov
a2 Word
a3 Word
a4 [Double]
a5 Word
a6 =
  LiborForwardModelProcess
-> (Ptr CLiborForwardModelProcess'
    -> IO LfmHullWhiteParameterization)
-> IO LfmHullWhiteParameterization
forall p b.
GenStochasticProcess (ForeignPtr p) -> (Ptr p -> IO b) -> IO b
withGenStochasticProcess LiborForwardModelProcess
a1 ((Ptr CLiborForwardModelProcess'
  -> IO LfmHullWhiteParameterization)
 -> IO LfmHullWhiteParameterization)
-> (Ptr CLiborForwardModelProcess'
    -> IO LfmHullWhiteParameterization)
-> IO LfmHullWhiteParameterization
forall a b. (a -> b) -> a -> b
$ \Ptr CLiborForwardModelProcess'
a1' -> 
  GenOptionletVolatilityStructure ov
-> (Ptr COptionletVolatilityStructure'
    -> IO LfmHullWhiteParameterization)
-> IO LfmHullWhiteParameterization
forall ov b.
GenOptionletVolatilityStructure ov
-> (Ptr COptionletVolatilityStructure' -> IO b) -> IO b
withOptionletVolatilityStructure GenOptionletVolatilityStructure ov
a2 ((Ptr COptionletVolatilityStructure'
  -> IO LfmHullWhiteParameterization)
 -> IO LfmHullWhiteParameterization)
-> (Ptr COptionletVolatilityStructure'
    -> IO LfmHullWhiteParameterization)
-> IO LfmHullWhiteParameterization
forall a b. (a -> b) -> a -> b
$ \Ptr COptionletVolatilityStructure'
a2' -> 
  let {a3' :: CUInt
a3' = Word -> CUInt
forall a b. (Integral a, Num b) => a -> b
fromIntegral Word
a3} in 
  let {a4' :: CUInt
a4' = Word -> CUInt
forall a b. (Integral a, Num b) => a -> b
fromIntegral Word
a4} in 
  [Double]
-> (Ptr CDouble -> IO LfmHullWhiteParameterization)
-> IO LfmHullWhiteParameterization
forall b. [Double] -> (Ptr CDouble -> IO b) -> IO b
withDoubleArrayRaw [Double]
a5 ((Ptr CDouble -> IO LfmHullWhiteParameterization)
 -> IO LfmHullWhiteParameterization)
-> (Ptr CDouble -> IO LfmHullWhiteParameterization)
-> IO LfmHullWhiteParameterization
forall a b. (a -> b) -> a -> b
$ \Ptr CDouble
a5' -> 
  let {a6' :: CUInt
a6' = Word -> CUInt
forall a b. (Integral a, Num b) => a -> b
fromIntegral Word
a6} in 
  (Ptr (Ptr ()) -> IO LfmHullWhiteParameterization)
-> IO LfmHullWhiteParameterization
forall a b. (Ptr (Ptr a) -> IO b) -> IO b
preErrorCheck ((Ptr (Ptr ()) -> IO LfmHullWhiteParameterization)
 -> IO LfmHullWhiteParameterization)
-> (Ptr (Ptr ()) -> IO LfmHullWhiteParameterization)
-> IO LfmHullWhiteParameterization
forall a b. (a -> b) -> a -> b
$ \Ptr (Ptr ())
a7' -> 
  Ptr CLiborForwardModelProcess'
-> Ptr COptionletVolatilityStructure'
-> CUInt
-> CUInt
-> Ptr CDouble
-> CUInt
-> Ptr (Ptr ())
-> IO (Ptr CLfmHullWhiteParameterization)
qlLfmHullWhiteParameterization'_ Ptr CLiborForwardModelProcess'
a1' Ptr COptionletVolatilityStructure'
a2' CUInt
a3' CUInt
a4' Ptr CDouble
a5' CUInt
a6' Ptr (Ptr ())
a7' IO (Ptr CLfmHullWhiteParameterization)
-> (Ptr CLfmHullWhiteParameterization
    -> IO LfmHullWhiteParameterization)
-> IO LfmHullWhiteParameterization
forall a b. IO a -> (a -> IO b) -> IO b
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= \Ptr CLfmHullWhiteParameterization
res ->
  Ptr CLfmHullWhiteParameterization
-> IO LfmHullWhiteParameterization
peekLfmHullWhiteParameterization Ptr CLfmHullWhiteParameterization
res IO LfmHullWhiteParameterization
-> (LfmHullWhiteParameterization
    -> IO LfmHullWhiteParameterization)
-> IO LfmHullWhiteParameterization
forall a b. IO a -> (a -> IO b) -> IO b
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= \LfmHullWhiteParameterization
res' ->
  Ptr (Ptr ()) -> IO ()
forall a. Ptr (Ptr a) -> IO ()
errorCheck  Ptr (Ptr ())
a7'IO ()
-> IO LfmHullWhiteParameterization
-> IO LfmHullWhiteParameterization
forall a b. IO a -> IO b -> IO b
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>>
  LfmHullWhiteParameterization -> IO LfmHullWhiteParameterization
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return (LfmHullWhiteParameterization
res')

{-# LINE 724 "./QuantLib/Model.chs" #-}


-- |installs the covariance parameterization a 'LiborForwardModelProcess' evolves under.
--
-- Mandatory before the process is used for anything dynamic: a freshly constructed
-- 'QuantLib.Process.liborForwardModelProcess' holds no parameterization, and
-- 'QuantLib.Process.drift', 'QuantLib.Process.diffusion', 'QuantLib.Process.evolve',
-- 'QuantLib.Process.factors' and 'QuantLib.Method.pathGenerator' all dereference it.
-- 'QuantLib.Process.discountBond', the fixing/accrual times and
-- 'QuantLib.Process.cashFlows' do not, and work without it.
setCovarParam :: (LiborForwardModelProcess) -- ^process
 -> (LfmHullWhiteParameterization) -- ^param
 -> IO ()
setCovarParam a1 a2 =
  withGenStochasticProcess a1 $ \a1' -> 
  withStandalone a2 $ \a2' -> 
  preErrorCheck $ \a3' -> 
  setCovarParam'_ a1' a2' a3' >>
  errorCheck  a3'>>
  return ()

{-# LINE 736 "./QuantLib/Model.chs" #-}


-- |Instantaneous covariance matrix at @t@ for the supplied forward-rate state @x@.
lfmHullWhiteCovariance :: LfmHullWhiteParameterization -> Double -> [Double] -> IO (Matrix Double)
lfmHullWhiteCovariance p t x = toMatrixDouble <$> qlLfmHullWhiteCovariance p t x
  where toMatrixDouble (r, c, d) = Matrix r c d
qlLfmHullWhiteCovariance :: (LfmHullWhiteParameterization) -- ^parameterization
 -> (Double) -- ^t
 -> ([Double]) -- ^x
 -> IO ((Word), (Word), ([Double]))
qlLfmHullWhiteCovariance :: LfmHullWhiteParameterization
-> Double -> [Double] -> IO (Word, Word, [Double])
qlLfmHullWhiteCovariance LfmHullWhiteParameterization
a1 Double
a2 [Double]
a3 =
  LfmHullWhiteParameterization
-> (Ptr CLfmHullWhiteParameterization -> IO (Word, Word, [Double]))
-> IO (Word, Word, [Double])
forall a b. Standalone a -> (Ptr a -> IO b) -> IO b
withStandalone LfmHullWhiteParameterization
a1 ((Ptr CLfmHullWhiteParameterization -> IO (Word, Word, [Double]))
 -> IO (Word, Word, [Double]))
-> (Ptr CLfmHullWhiteParameterization -> IO (Word, Word, [Double]))
-> IO (Word, Word, [Double])
forall a b. (a -> b) -> a -> b
$ \Ptr CLfmHullWhiteParameterization
a1' -> 
  let {a2' :: CDouble
a2' = Double -> CDouble
forall a b. (Real a, Fractional b) => a -> b
realToFrac Double
a2} in 
  [Double]
-> ((CUInt, Ptr CDouble) -> IO (Word, Word, [Double]))
-> IO (Word, Word, [Double])
forall b. [Double] -> ((CUInt, Ptr CDouble) -> IO b) -> IO b
withDoubleArray [Double]
a3 (((CUInt, Ptr CDouble) -> IO (Word, Word, [Double]))
 -> IO (Word, Word, [Double]))
-> ((CUInt, Ptr CDouble) -> IO (Word, Word, [Double]))
-> IO (Word, Word, [Double])
forall a b. (a -> b) -> a -> b
$ \(CUInt
a3'1, Ptr CDouble
a3'2) -> 
  (Ptr CUInt -> IO (Word, Word, [Double]))
-> IO (Word, Word, [Double])
forall a b. Storable a => (Ptr a -> IO b) -> IO b
prePtr ((Ptr CUInt -> IO (Word, Word, [Double]))
 -> IO (Word, Word, [Double]))
-> (Ptr CUInt -> IO (Word, Word, [Double]))
-> IO (Word, Word, [Double])
forall a b. (a -> b) -> a -> b
$ \Ptr CUInt
a4' -> 
  (Ptr CUInt -> IO (Word, Word, [Double]))
-> IO (Word, Word, [Double])
forall a b. Storable a => (Ptr a -> IO b) -> IO b
prePtr ((Ptr CUInt -> IO (Word, Word, [Double]))
 -> IO (Word, Word, [Double]))
-> (Ptr CUInt -> IO (Word, Word, [Double]))
-> IO (Word, Word, [Double])
forall a b. (a -> b) -> a -> b
$ \Ptr CUInt
a5' -> 
  ((Ptr CUInt, Ptr (Ptr CDouble)) -> IO (Word, Word, [Double]))
-> IO (Word, Word, [Double])
forall b. ((Ptr CUInt, Ptr (Ptr CDouble)) -> IO b) -> IO b
preDoubleArray (((Ptr CUInt, Ptr (Ptr CDouble)) -> IO (Word, Word, [Double]))
 -> IO (Word, Word, [Double]))
-> ((Ptr CUInt, Ptr (Ptr CDouble)) -> IO (Word, Word, [Double]))
-> IO (Word, Word, [Double])
forall a b. (a -> b) -> a -> b
$ \(Ptr CUInt
a6'1, Ptr (Ptr CDouble)
a6'2) -> 
  (Ptr (Ptr ()) -> IO (Word, Word, [Double]))
-> IO (Word, Word, [Double])
forall a b. (Ptr (Ptr a) -> IO b) -> IO b
preErrorCheck ((Ptr (Ptr ()) -> IO (Word, Word, [Double]))
 -> IO (Word, Word, [Double]))
-> (Ptr (Ptr ()) -> IO (Word, Word, [Double]))
-> IO (Word, Word, [Double])
forall a b. (a -> b) -> a -> b
$ \Ptr (Ptr ())
a7' -> 
  Ptr CLfmHullWhiteParameterization
-> CDouble
-> CUInt
-> Ptr CDouble
-> Ptr CUInt
-> Ptr CUInt
-> Ptr CUInt
-> Ptr (Ptr CDouble)
-> Ptr (Ptr ())
-> IO ()
qlLfmHullWhiteCovariance'_ Ptr CLfmHullWhiteParameterization
a1' CDouble
a2' CUInt
a3'1  Ptr CDouble
a3'2 Ptr CUInt
a4' Ptr CUInt
a5' Ptr CUInt
a6'1  Ptr (Ptr CDouble)
a6'2 Ptr (Ptr ())
a7' IO () -> IO Word -> IO Word
forall a b. IO a -> IO b -> IO b
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>>
  Ptr CUInt -> IO Word
peekWord  Ptr CUInt
a4'IO Word
-> (Word -> IO (Word, Word, [Double])) -> IO (Word, Word, [Double])
forall a b. IO a -> (a -> IO b) -> IO b
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= \Word
a4'' -> 
  Ptr CUInt -> IO Word
peekWord  Ptr CUInt
a5'IO Word
-> (Word -> IO (Word, Word, [Double])) -> IO (Word, Word, [Double])
forall a b. IO a -> (a -> IO b) -> IO b
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= \Word
a5'' -> 
  Ptr CUInt -> Ptr (Ptr CDouble) -> IO [Double]
peekDoubleArray  Ptr CUInt
a6'1  Ptr (Ptr CDouble)
a6'2IO [Double]
-> ([Double] -> IO (Word, Word, [Double]))
-> IO (Word, Word, [Double])
forall a b. IO a -> (a -> IO b) -> IO b
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= \[Double]
a6'' -> 
  Ptr (Ptr ()) -> IO ()
forall a. Ptr (Ptr a) -> IO ()
errorCheck  Ptr (Ptr ())
a7'IO () -> IO (Word, Word, [Double]) -> IO (Word, Word, [Double])
forall a b. IO a -> IO b -> IO b
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>>
  (Word, Word, [Double]) -> IO (Word, Word, [Double])
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return (Word
a4'', Word
a5'', [Double]
a6'')

{-# LINE 746 "./QuantLib/Model.chs" #-}


-- |Calibrate to a set of market instruments (caps/swaptions)
-- An additional constraint can be passed which must be satisfied in addition to the constraints of the model.
calibrate :: GenCalibratedModel m -> NonEmpty (GenCalibrationHelper ch, Double) -- ^(instrument, weight)
  -> OptimizationMethod -> EndCriteria -> Maybe Constraint
  -> [Bool] -- ^fixParameters, e.g. 'fixedReversion'; @[]@ leaves nothing fixed
  -> IO ()
calibrate m h o e c fp = qlCalibratedModelCalibrate m hh hw o e c fp where (hh, hw) = unzip (toList h)
qlCalibratedModelCalibrate :: (GenCalibratedModel m) -> ([GenCalibrationHelper ch]) -> ([Double]) -> (OptimizationMethod) -> (EndCriteria) -> (Maybe Constraint) -> ([Bool]) -> IO ()
qlCalibratedModelCalibrate a1 a2 a3 a4 a5 a6 a7 =
  withCalibratedModel a1 $ \a1' -> 
  withCalibrationHelperArray a2 $ \(a2'1, a2'2) -> 
  withDoubleArray a3 $ \(a3'1, a3'2) -> 
  withOptimizationMethod a4 $ \a4' -> 
  withEndCriteria a5 $ \a5' -> 
  withMaybeConstraint a6 $ \a6' -> 
  withBoolArray a7 $ \(a7'1, a7'2) -> 
  preErrorCheck $ \a8' -> 
  qlCalibratedModelCalibrate'_ a1' a2'1  a2'2 a3'1  a3'2 a4' a5' a6' a7'1  a7'2 a8' >>
  errorCheck  a8'>>
  return ()

{-# LINE 756 "./QuantLib/Model.chs" #-}


-- |Objective function value at @params@ for the given calibration instruments.
value :: (GenCalibratedModel m) -> ([Double]) -> ([GenCalibrationHelper ch]) -> IO ((Double))
value a1 a2 a3 =
  withCalibratedModel a1 $ \a1' -> 
  withDoubleArray a2 $ \(a2'1, a2'2) -> 
  withCalibrationHelperArray a3 $ \(a3'1, a3'2) -> 
  preErrorCheck $ \a4' -> 
  value'_ a1' a2'1  a2'2 a3'1  a3'2 a4' >>= \res ->
  let {res' = realToFrac res} in
  errorCheck  a4'>>
  return (res')

{-# LINE 759 "./QuantLib/Model.chs" #-}


-- |Calibration helper for an at-the-money interest-rate cap.
capHelper :: ((Word,TimeUnit)) -- ^length
 -> (GenQuote q) -- ^volatility
 -> (GenIborIndex ibor) -> (Frequency) -- ^fixedLegFrequency
 -> (DayCounter) -> (Bool) -- ^includeFirstSwaplet
 -> (GenYieldTermStructure y) -> (CalibrationErrorType) -> (VolatilityType) -- ^type
 -> (Double) -- ^shift
 -> IO ((BlackCalibrationHelper))
capHelper a1 a2 a3 a4 a5 a6 a7 a8 a9 a10 =
  let {(a1'1, a1'2) = fromEnumQuantity a1} in 
  withQuote a2 $ \a2' -> 
  withIborIndex a3 $ \a3' -> 
  let {a4' = (fromIntegral . fromEnum) a4} in 
  withDayCounter a5 $ \a5' -> 
  let {a6' = C2HSImp.fromBool a6} in 
  withYieldTermStructure a7 $ \a7' -> 
  let {a8' = (fromIntegral . fromEnum) a8} in 
  let {a9' = (fromIntegral . fromEnum) a9} in 
  let {a10' = realToFrac a10} in 
  preErrorCheck $ \a11' -> 
  capHelper'_ a1'1  a1'2 a2' a3' a4' a5' a6' a7' a8' a9' a10' a11' >>= \res ->
  peekBlackCalibrationHelper res >>= \res' ->
  errorCheck  a11'>>
  return (res')

{-# LINE 769 "./QuantLib/Model.chs" #-}


-- |Calibration helper for the Heston model, from a European option's market volatility.
hestonModelHelper :: ((Word,TimeUnit)) -- ^maturity
 -> (Calendar) -> (GenQuote q1) -- ^s0
 -> (Double) -- ^strikePrice
 -> (GenQuote q2) -- ^volatility
 -> (GenYieldTermStructure y1) -- ^riskFreeRate
 -> (GenYieldTermStructure y2) -- ^dividendYield
 -> (CalibrationErrorType) -> IO ((BlackCalibrationHelper))
hestonModelHelper a1 a2 a3 a4 a5 a6 a7 a8 =
  let {(a1'1, a1'2) = fromEnumQuantity a1} in 
  withCalendar a2 $ \a2' -> 
  withQuote a3 $ \a3' -> 
  let {a4' = realToFrac a4} in 
  withQuote a5 $ \a5' -> 
  withYieldTermStructure a6 $ \a6' -> 
  withYieldTermStructure a7 $ \a7' -> 
  let {a8' = (fromIntegral . fromEnum) a8} in 
  preErrorCheck $ \a9' -> 
  hestonModelHelper'_ a1'1  a1'2 a2' a3' a4' a5' a6' a7' a8' a9' >>= \res ->
  peekBlackCalibrationHelper res >>= \res' ->
  errorCheck  a9'>>
  return (res')

{-# LINE 778 "./QuantLib/Model.chs" #-}


-- |A swaption helper's exercise and underlying-swap span.
data SwaptionSpan
  = SpanTenors !(Word, TimeUnit) !(Word, TimeUnit) -- ^maturity, length
  | SpanFromDate !Day !(Word, TimeUnit) -- ^exerciseDate, length
  | SpanDates !Day !Day -- ^exerciseDate, endDate
  deriving (Eq, Show)

-- |Calibration helper for a swaption, over the given exercise/underlying span.
swaptionHelper :: SwaptionSpan -> GenQuote q -> GenIborIndex ibor -> (Word, TimeUnit)
  -> DayCounter -> DayCounter -> GenYieldTermStructure y -> CalibrationErrorType
  -> Maybe Double -> Double -> VolatilityType -> Double -> Maybe Word -> RateAveragingType
  -> IO SwaptionHelper
swaptionHelper span' = case span' of
  SpanTenors m l -> swaptionHelperTenorsRaw m l
  SpanFromDate d l -> swaptionHelperFromDateRaw d l
  SpanDates d e -> swaptionHelperFromDatesRaw d e

swaptionHelperTenorsRaw :: ((Word,TimeUnit)) -- ^maturity
 -> ((Word,TimeUnit)) -- ^length
 -> (GenQuote q) -- ^maturity
 -> (GenIborIndex ibor) -> ((Word,TimeUnit)) -- ^fixedLegTenor
 -> (DayCounter) -- ^fixedLegDayCounter
 -> (DayCounter) -- ^floatingLegDayCounter
 -> (GenYieldTermStructure y) -> (CalibrationErrorType) -> (Maybe Double) -- ^strike
 -> (Double) -- ^nominal
 -> (VolatilityType) -- ^type
 -> (Double) -- ^shift
 -> (Maybe Word) -- ^settlementDays
 -> (RateAveragingType) -- ^averagingMethod
 -> IO ((SwaptionHelper))
swaptionHelperTenorsRaw :: forall q ibor y.
(Word, TimeUnit)
-> (Word, TimeUnit)
-> GenQuote q
-> GenIborIndex ibor
-> (Word, TimeUnit)
-> DayCounter
-> DayCounter
-> GenYieldTermStructure y
-> CalibrationErrorType
-> Maybe Double
-> Double
-> VolatilityType
-> Double
-> Maybe Word
-> RateAveragingType
-> IO SwaptionHelper
swaptionHelperTenorsRaw (Word, TimeUnit)
a1 (Word, TimeUnit)
a2 GenQuote q
a3 GenIborIndex ibor
a4 (Word, TimeUnit)
a5 DayCounter
a6 DayCounter
a7 GenYieldTermStructure y
a8 CalibrationErrorType
a9 Maybe Double
a10 Double
a11 VolatilityType
a12 Double
a13 Maybe Word
a14 RateAveragingType
a15 =
  let {(CInt
a1'1, CInt
a1'2) = (Word, TimeUnit) -> (CInt, CInt)
forall a b c.
(Enum a, Integral b, Integral c) =>
(b, a) -> (CInt, c)
fromEnumQuantity (Word, TimeUnit)
a1} in 
  let {(CInt
a2'1, CInt
a2'2) = (Word, TimeUnit) -> (CInt, CInt)
forall a b c.
(Enum a, Integral b, Integral c) =>
(b, a) -> (CInt, c)
fromEnumQuantity (Word, TimeUnit)
a2} in 
  GenQuote q
-> (Ptr CQuote' -> IO SwaptionHelper) -> IO SwaptionHelper
forall q b. GenQuote q -> (Ptr CQuote' -> IO b) -> IO b
withQuote GenQuote q
a3 ((Ptr CQuote' -> IO SwaptionHelper) -> IO SwaptionHelper)
-> (Ptr CQuote' -> IO SwaptionHelper) -> IO SwaptionHelper
forall a b. (a -> b) -> a -> b
$ \Ptr CQuote'
a3' -> 
  GenIborIndex ibor
-> (Ptr CIborIndex' -> IO SwaptionHelper) -> IO SwaptionHelper
forall ibor b.
GenIborIndex ibor -> (Ptr CIborIndex' -> IO b) -> IO b
withIborIndex GenIborIndex ibor
a4 ((Ptr CIborIndex' -> IO SwaptionHelper) -> IO SwaptionHelper)
-> (Ptr CIborIndex' -> IO SwaptionHelper) -> IO SwaptionHelper
forall a b. (a -> b) -> a -> b
$ \Ptr CIborIndex'
a4' -> 
  let {(CInt
a5'1, CInt
a5'2) = (Word, TimeUnit) -> (CInt, CInt)
forall a b c.
(Enum a, Integral b, Integral c) =>
(b, a) -> (CInt, c)
fromEnumQuantity (Word, TimeUnit)
a5} in 
  DayCounter
-> (Ptr CDayCounter -> IO SwaptionHelper) -> IO SwaptionHelper
forall b. DayCounter -> (Ptr CDayCounter -> IO b) -> IO b
withDayCounter DayCounter
a6 ((Ptr CDayCounter -> IO SwaptionHelper) -> IO SwaptionHelper)
-> (Ptr CDayCounter -> IO SwaptionHelper) -> IO SwaptionHelper
forall a b. (a -> b) -> a -> b
$ \Ptr CDayCounter
a6' -> 
  DayCounter
-> (Ptr CDayCounter -> IO SwaptionHelper) -> IO SwaptionHelper
forall b. DayCounter -> (Ptr CDayCounter -> IO b) -> IO b
withDayCounter DayCounter
a7 ((Ptr CDayCounter -> IO SwaptionHelper) -> IO SwaptionHelper)
-> (Ptr CDayCounter -> IO SwaptionHelper) -> IO SwaptionHelper
forall a b. (a -> b) -> a -> b
$ \Ptr CDayCounter
a7' -> 
  GenYieldTermStructure y
-> (Ptr CYieldTermStructure' -> IO SwaptionHelper)
-> IO SwaptionHelper
forall y b.
GenYieldTermStructure y
-> (Ptr CYieldTermStructure' -> IO b) -> IO b
withYieldTermStructure GenYieldTermStructure y
a8 ((Ptr CYieldTermStructure' -> IO SwaptionHelper)
 -> IO SwaptionHelper)
-> (Ptr CYieldTermStructure' -> IO SwaptionHelper)
-> IO SwaptionHelper
forall a b. (a -> b) -> a -> b
$ \Ptr CYieldTermStructure'
a8' -> 
  let {a9' :: CInt
a9' = (Int -> CInt
forall a b. (Integral a, Num b) => a -> b
fromIntegral (Int -> CInt)
-> (CalibrationErrorType -> Int) -> CalibrationErrorType -> CInt
forall b c a. (b -> c) -> (a -> b) -> a -> c
. CalibrationErrorType -> Int
forall a. Enum a => a -> Int
fromEnum) CalibrationErrorType
a9} in 
  let {a10' :: CDouble
a10' = Maybe Double -> CDouble
fromMaybeDouble Maybe Double
a10} in 
  let {a11' :: CDouble
a11' = Double -> CDouble
forall a b. (Real a, Fractional b) => a -> b
realToFrac Double
a11} in 
  let {a12' :: CInt
a12' = (Int -> CInt
forall a b. (Integral a, Num b) => a -> b
fromIntegral (Int -> CInt) -> (VolatilityType -> Int) -> VolatilityType -> CInt
forall b c a. (b -> c) -> (a -> b) -> a -> c
. VolatilityType -> Int
forall a. Enum a => a -> Int
fromEnum) VolatilityType
a12} in 
  let {a13' :: CDouble
a13' = Double -> CDouble
forall a b. (Real a, Fractional b) => a -> b
realToFrac Double
a13} in 
  let {a14' :: CUInt
a14' = Maybe Word -> CUInt
forall a b. (Integral a, Integral b) => Maybe a -> b
fromMaybeInt Maybe Word
a14} in 
  let {a15' :: CInt
a15' = (Int -> CInt
forall a b. (Integral a, Num b) => a -> b
fromIntegral (Int -> CInt)
-> (RateAveragingType -> Int) -> RateAveragingType -> CInt
forall b c a. (b -> c) -> (a -> b) -> a -> c
. RateAveragingType -> Int
forall a. Enum a => a -> Int
fromEnum) RateAveragingType
a15} in 
  (Ptr (Ptr ()) -> IO SwaptionHelper) -> IO SwaptionHelper
forall a b. (Ptr (Ptr a) -> IO b) -> IO b
preErrorCheck ((Ptr (Ptr ()) -> IO SwaptionHelper) -> IO SwaptionHelper)
-> (Ptr (Ptr ()) -> IO SwaptionHelper) -> IO SwaptionHelper
forall a b. (a -> b) -> a -> b
$ \Ptr (Ptr ())
a16' -> 
  CInt
-> CInt
-> CInt
-> CInt
-> Ptr CQuote'
-> Ptr CIborIndex'
-> CInt
-> CInt
-> Ptr CDayCounter
-> Ptr CDayCounter
-> Ptr CYieldTermStructure'
-> CInt
-> CDouble
-> CDouble
-> CInt
-> CDouble
-> CUInt
-> CInt
-> Ptr (Ptr ())
-> IO (Ptr CSwaptionHelper')
swaptionHelperTenorsRaw'_ CInt
a1'1  CInt
a1'2 CInt
a2'1  CInt
a2'2 Ptr CQuote'
a3' Ptr CIborIndex'
a4' CInt
a5'1  CInt
a5'2 Ptr CDayCounter
a6' Ptr CDayCounter
a7' Ptr CYieldTermStructure'
a8' CInt
a9' CDouble
a10' CDouble
a11' CInt
a12' CDouble
a13' CUInt
a14' CInt
a15' Ptr (Ptr ())
a16' IO (Ptr CSwaptionHelper')
-> (Ptr CSwaptionHelper' -> IO SwaptionHelper) -> IO SwaptionHelper
forall a b. IO a -> (a -> IO b) -> IO b
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= \Ptr CSwaptionHelper'
res ->
  Ptr CSwaptionHelper' -> IO SwaptionHelper
peekSwaptionHelper Ptr CSwaptionHelper'
res IO SwaptionHelper
-> (SwaptionHelper -> IO SwaptionHelper) -> IO SwaptionHelper
forall a b. IO a -> (a -> IO b) -> IO b
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= \SwaptionHelper
res' ->
  Ptr (Ptr ()) -> IO ()
forall a. Ptr (Ptr a) -> IO ()
errorCheck  Ptr (Ptr ())
a16'IO () -> IO SwaptionHelper -> IO SwaptionHelper
forall a b. IO a -> IO b -> IO b
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>>
  SwaptionHelper -> IO SwaptionHelper
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return (SwaptionHelper
res')

{-# LINE 810 "./QuantLib/Model.chs" #-}


-- |Like 'swaptionHelper', but the option's exercise is given as an explicit date rather than a maturity 'Period'.
swaptionHelperFromDateRaw :: (Day) -- ^exerciseDate
 -> ((Word,TimeUnit)) -- ^length
 -> (GenQuote q) -- ^maturity
 -> (GenIborIndex ibor) -> ((Word,TimeUnit)) -- ^fixedLegTenor
 -> (DayCounter) -- ^fixedLegDayCounter
 -> (DayCounter) -- ^floatingLegDayCounter
 -> (GenYieldTermStructure y) -> (CalibrationErrorType) -> (Maybe Double) -- ^strike
 -> (Double) -- ^nominal
 -> (VolatilityType) -- ^type
 -> (Double) -- ^shift
 -> (Maybe Word) -- ^settlementDays
 -> (RateAveragingType) -- ^averagingMethod
 -> IO ((SwaptionHelper))
swaptionHelperFromDateRaw a1 a2 a3 a4 a5 a6 a7 a8 a9 a10 a11 a12 a13 a14 a15 =
  withDay a1 $ \a1' -> 
  let {(a2'1, a2'2) = fromEnumQuantity a2} in 
  withQuote a3 $ \a3' -> 
  withIborIndex a4 $ \a4' -> 
  let {(a5'1, a5'2) = fromEnumQuantity a5} in 
  withDayCounter a6 $ \a6' -> 
  withDayCounter a7 $ \a7' -> 
  withYieldTermStructure a8 $ \a8' -> 
  let {a9' = (fromIntegral . fromEnum) a9} in 
  let {a10' = fromMaybeDouble a10} in 
  let {a11' = realToFrac a11} in 
  let {a12' = (fromIntegral . fromEnum) a12} in 
  let {a13' = realToFrac a13} in 
  let {a14' = fromMaybeInt a14} in 
  let {a15' = (fromIntegral . fromEnum) a15} in 
  preErrorCheck $ \a16' -> 
  swaptionHelperFromDateRaw'_ a1' a2'1  a2'2 a3' a4' a5'1  a5'2 a6' a7' a8' a9' a10' a11' a12' a13' a14' a15' a16' >>= \res ->
  peekSwaptionHelper res >>= \res' ->
  errorCheck  a16'>>
  return (res')

{-# LINE 826 "./QuantLib/Model.chs" #-}


-- |Like 'swaptionHelper', but both the option's exercise and the underlying swap's end are given as explicit dates.
swaptionHelperFromDatesRaw :: (Day) -- ^exerciseDate
 -> (Day) -- ^endDate
 -> (GenQuote q) -- ^maturity
 -> (GenIborIndex ibor) -> ((Word,TimeUnit)) -- ^fixedLegTenor
 -> (DayCounter) -- ^fixedLegDayCounter
 -> (DayCounter) -- ^floatingLegDayCounter
 -> (GenYieldTermStructure y) -> (CalibrationErrorType) -> (Maybe Double) -- ^strike
 -> (Double) -- ^nominal
 -> (VolatilityType) -- ^type
 -> (Double) -- ^shift
 -> (Maybe Word) -- ^settlementDays
 -> (RateAveragingType) -- ^averagingMethod
 -> IO ((SwaptionHelper))
swaptionHelperFromDatesRaw a1 a2 a3 a4 a5 a6 a7 a8 a9 a10 a11 a12 a13 a14 a15 =
  withDay a1 $ \a1' -> 
  withDay a2 $ \a2' -> 
  withQuote a3 $ \a3' -> 
  withIborIndex a4 $ \a4' -> 
  let {(a5'1, a5'2) = fromEnumQuantity a5} in 
  withDayCounter a6 $ \a6' -> 
  withDayCounter a7 $ \a7' -> 
  withYieldTermStructure a8 $ \a8' -> 
  let {a9' = (fromIntegral . fromEnum) a9} in 
  let {a10' = fromMaybeDouble a10} in 
  let {a11' = realToFrac a11} in 
  let {a12' = (fromIntegral . fromEnum) a12} in 
  let {a13' = realToFrac a13} in 
  let {a14' = fromMaybeInt a14} in 
  let {a15' = (fromIntegral . fromEnum) a15} in 
  preErrorCheck $ \a16' -> 
  swaptionHelperFromDatesRaw'_ a1' a2' a3' a4' a5'1  a5'2 a6' a7' a8' a9' a10' a11' a12' a13' a14' a15' a16' >>= \res ->
  peekSwaptionHelper res >>= \res' ->
  errorCheck  a16'>>
  return (res')

{-# LINE 842 "./QuantLib/Model.chs" #-}


-- |The 'QuantLib.Instrument.Swap.Swaption' this helper prices internally to compute 'modelValue'.
helperSwaption :: (SwaptionHelper) -> IO ((Swaption))
helperSwaption a1 =
  withSwaptionHelper a1 $ \a1' -> 
  preErrorCheck $ \a2' -> 
  helperSwaption'_ a1' a2' >>= \res ->
  peekSwaption res >>= \res' ->
  errorCheck  a2'>>
  return (res')

{-# LINE 845 "./QuantLib/Model.chs" #-}


-- |Times relevant to pricing this calibration helper's instrument, to be added to the model's evolution time grid.
times :: (GenBlackCalibrationHelper bch) -> IO (([Double]))
times a1 =
  withBlackCalibrationHelper a1 $ \a1' -> 
  preDoubleArray $ \(a2'1, a2'2) -> 
  preErrorCheck $ \a3' -> 
  times'_ a1' a2'1  a2'2 a3' >>
  peekDoubleArray  a2'1  a2'2>>= \a2'' -> 
  errorCheck  a3'>>
  return (a2'')

{-# LINE 848 "./QuantLib/Model.chs" #-}


-- |Returns array of arguments on which calibration is done.
params :: (GenCalibratedModel m) -> IO (([Double]))
params a1 =
  withCalibratedModel a1 $ \a1' -> 
  preDoubleArray $ \(a2'1, a2'2) -> 
  preErrorCheck $ \a3' -> 
  params'_ a1' a2'1  a2'2 a3' >>
  peekDoubleArray  a2'1  a2'2>>= \a2'' -> 
  errorCheck  a3'>>
  return (a2'')

{-# LINE 851 "./QuantLib/Model.chs" #-}


-- |Replace the arguments on which calibration is done, in the order 'params' returns them, and
-- notify the model's observers, so engines on it reprice. An array whose length differs from
-- 'params'' throws and leaves the model unchanged; the model's constraint is not checked. A later
-- 'calibrate' starts from these values.
setParams :: (GenCalibratedModel m) -> ([Double]) -- ^params
 -> IO ()
setParams a1 a2 =
  withCalibratedModel a1 $ \a1' -> 
  withDoubleArray a2 $ \(a2'1, a2'2) -> 
  preErrorCheck $ \a3' -> 
  setParams'_ a1' a2'1  a2'2 a3' >>
  errorCheck  a3'>>
  return ()

{-# LINE 859 "./QuantLib/Model.chs" #-}


-- |Black price given a volatility.
blackPrice :: (GenBlackCalibrationHelper bch) -> (Double) -- ^volatility
 -> IO ((Double))
blackPrice a1 a2 =
  withBlackCalibrationHelper a1 $ \a1' -> 
  let {a2' = realToFrac a2} in 
  preErrorCheck $ \a3' -> 
  blackPrice'_ a1' a2' a3' >>= \res ->
  let {res' = realToFrac res} in
  errorCheck  a3'>>
  return (res')

{-# LINE 863 "./QuantLib/Model.chs" #-}


-- |returns the error resulting from the model valuation
calibrationError :: (GenBlackCalibrationHelper bch) -> IO ((Double))
calibrationError a1 =
  withBlackCalibrationHelper a1 $ \a1' -> 
  preErrorCheck $ \a2' -> 
  calibrationError'_ a1' a2' >>= \res ->
  let {res' = realToFrac res} in
  errorCheck  a2'>>
  return (res')

{-# LINE 866 "./QuantLib/Model.chs" #-}


-- |Black volatility implied by the model.
impliedVolatility :: (GenBlackCalibrationHelper bch) -> (Double) -- ^targetValue
 -> (Double) -- ^accuracy
 -> (Word) -- ^maxEvaluations
 -> (Double) -- ^minVol
 -> (Double) -- ^maxVol
 -> IO ((Double))
impliedVolatility :: forall bch.
GenBlackCalibrationHelper bch
-> Double -> Double -> Word -> Double -> Double -> IO Double
impliedVolatility GenBlackCalibrationHelper bch
a1 Double
a2 Double
a3 Word
a4 Double
a5 Double
a6 =
  GenBlackCalibrationHelper bch
-> (Ptr CBlackCalibrationHelper' -> IO Double) -> IO Double
forall bch b.
GenBlackCalibrationHelper bch
-> (Ptr CBlackCalibrationHelper' -> IO b) -> IO b
withBlackCalibrationHelper GenBlackCalibrationHelper bch
a1 ((Ptr CBlackCalibrationHelper' -> IO Double) -> IO Double)
-> (Ptr CBlackCalibrationHelper' -> IO Double) -> IO Double
forall a b. (a -> b) -> a -> b
$ \Ptr CBlackCalibrationHelper'
a1' -> 
  let {a2' :: CDouble
a2' = Double -> CDouble
forall a b. (Real a, Fractional b) => a -> b
realToFrac Double
a2} in 
  let {a3' = realToFrac a3} in 
  let {a4' = fromIntegral a4} in 
  let {a5' = realToFrac a5} in 
  let {a6' = realToFrac a6} in 
  preErrorCheck $ \a7' -> 
  impliedVolatility'_ a1' a2' a3' a4' a5' a6' a7' >>= \res ->
  let {res' = realToFrac res} in
  errorCheck  a7'>>
  return (res')

{-# LINE 874 "./QuantLib/Model.chs" #-}


-- |returns the actual price of the instrument (from volatility)
marketValue :: (GenBlackCalibrationHelper bch) -> IO ((Double))
marketValue a1 =
  withBlackCalibrationHelper a1 $ \a1' -> 
  preErrorCheck $ \a2' -> 
  marketValue'_ a1' a2' >>= \res ->
  let {res' = realToFrac res} in
  errorCheck  a2'>>
  return (res')

{-# LINE 877 "./QuantLib/Model.chs" #-}


-- |returns the price of the instrument according to the model
modelValue :: (GenBlackCalibrationHelper bch) -> IO ((Double))
modelValue a1 =
  withBlackCalibrationHelper a1 $ \a1' -> 
  preErrorCheck $ \a2' -> 
  modelValue'_ a1' a2' >>= \res ->
  let {res' = realToFrac res} in
  errorCheck  a2'>>
  return (res')

{-# LINE 880 "./QuantLib/Model.chs" #-}


-- |The quoted market volatility this helper was built with.
volatility :: (GenBlackCalibrationHelper bch) -> IO ((Quote))
volatility a1 =
  withBlackCalibrationHelper a1 $ \a1' -> 
  preErrorCheck $ \a2' -> 
  volatility'_ a1' a2' >>= \res ->
  peekQuote res >>= \res' ->
  errorCheck  a2'>>
  return (res')

{-# LINE 883 "./QuantLib/Model.chs" #-}


-- |Sets the pricing engine used to compute this calibration helper's model value.
setPricingEngine :: (GenBlackCalibrationHelper bch) -> (GenPricingEngine pe) -> IO ()
setPricingEngine a1 a2 =
  withBlackCalibrationHelper a1 $ \a1' -> 
  withPricingEngine a2 $ \a2' -> 
  preErrorCheck $ \a3' -> 
  setPricingEngine'_ a1' a2' a3' >>
  errorCheck  a3'>>
  return ()

{-# LINE 886 "./QuantLib/Model.chs" #-}


-- |Direct-parameter GARCH(1,1) model: @vl@ is the long-term (unconditional) volatility: the
-- model's persistence @gamma = 1 - alpha - beta@ and @omega = vl * gamma@ are derived from it.
-- Does not calibrate; use 'garch11Calibrated' to fit alpha\/beta\/vl to an observed series.
garch11 :: (Double) -- ^alpha
 -> (Double) -- ^beta
 -> (Double) -- ^vl (long-term volatility)
 -> IO ((Garch11))
garch11 a1 a2 a3 =
  let {a1' = realToFrac a1} in 
  let {a2' = realToFrac a2} in 
  let {a3' = realToFrac a3} in 
  preErrorCheck $ \a4' -> 
  garch11'_ a1' a2' a3' a4' >>= \res ->
  peekGarch11 res >>= \res' ->
  errorCheck  a4'>>
  return (res')

{-# LINE 895 "./QuantLib/Model.chs" #-}


-- |Calibrates a GARCH(1,1) model to an observed return series via maximum likelihood. All four
-- 'Garch11Mode' values converge to the same maximum-likelihood fit for a well-behaved series --
-- they differ only in the initial guess ('MomentMatchingGuess'\/'GammaGuess'), or run both and
-- keep the better ('BestOfTwo', the upstream default) or optimize from each in turn
-- ('DoubleOptimization'). There is no way from Haskell to supply a custom
-- 'OptimizationMethod'\/'EndCriteria' or to re-calibrate an existing model in place (upstream's
-- @calibrate@ overloads are mutators on an already-constructed object); construct a fresh model
-- if a different fit is needed.
garch11Calibrated :: NonEmpty (Day, Double) -- ^observed return series
  -> Garch11Mode -> IO Garch11
garch11Calibrated :: NonEmpty (Day, Double) -> Garch11Mode -> IO Garch11
garch11Calibrated NonEmpty (Day, Double)
series = [Day] -> [Double] -> Garch11Mode -> IO Garch11
qlGarch11Calibrated [Day]
dates [Double]
vals
  where ([Day]
dates, [Double]
vals) = [(Day, Double)] -> ([Day], [Double])
forall a b. [(a, b)] -> ([a], [b])
unzip (NonEmpty (Day, Double) -> [(Day, Double)]
forall a. NonEmpty a -> [a]
toList NonEmpty (Day, Double)
series)
qlGarch11Calibrated :: ([Day]) -> ([Double]) -> (Garch11Mode) -> IO ((Garch11))
qlGarch11Calibrated :: [Day] -> [Double] -> Garch11Mode -> IO Garch11
qlGarch11Calibrated [Day]
a1 [Double]
a2 Garch11Mode
a3 =
  [Day] -> ((CUInt, Ptr CInt) -> IO Garch11) -> IO Garch11
forall b. [Day] -> ((CUInt, Ptr CInt) -> IO b) -> IO b
withDayArray [Day]
a1 (((CUInt, Ptr CInt) -> IO Garch11) -> IO Garch11)
-> ((CUInt, Ptr CInt) -> IO Garch11) -> IO Garch11
forall a b. (a -> b) -> a -> b
$ \(CUInt
a1'1, Ptr CInt
a1'2) -> 
  [Double] -> ((CUInt, Ptr CDouble) -> IO Garch11) -> IO Garch11
forall b. [Double] -> ((CUInt, Ptr CDouble) -> IO b) -> IO b
withDoubleArray [Double]
a2 (((CUInt, Ptr CDouble) -> IO Garch11) -> IO Garch11)
-> ((CUInt, Ptr CDouble) -> IO Garch11) -> IO Garch11
forall a b. (a -> b) -> a -> b
$ \(CUInt
a2'1, Ptr CDouble
a2'2) -> 
  let {a3' :: CInt
a3' = (Int -> CInt
forall a b. (Integral a, Num b) => a -> b
fromIntegral (Int -> CInt) -> (Garch11Mode -> Int) -> Garch11Mode -> CInt
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Garch11Mode -> Int
forall a. Enum a => a -> Int
fromEnum) Garch11Mode
a3} in 
  (Ptr (Ptr ()) -> IO Garch11) -> IO Garch11
forall a b. (Ptr (Ptr a) -> IO b) -> IO b
preErrorCheck ((Ptr (Ptr ()) -> IO Garch11) -> IO Garch11)
-> (Ptr (Ptr ()) -> IO Garch11) -> IO Garch11
forall a b. (a -> b) -> a -> b
$ \Ptr (Ptr ())
a4' -> 
  CUInt
-> Ptr CInt
-> CUInt
-> Ptr CDouble
-> CInt
-> Ptr (Ptr ())
-> IO (Ptr CGarch11)
qlGarch11Calibrated'_ CUInt
a1'1  Ptr CInt
a1'2 CUInt
a2'1  Ptr CDouble
a2'2 CInt
a3' Ptr (Ptr ())
a4' IO (Ptr CGarch11) -> (Ptr CGarch11 -> IO Garch11) -> IO Garch11
forall a b. IO a -> (a -> IO b) -> IO b
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= \Ptr CGarch11
res ->
  Ptr CGarch11 -> IO Garch11
peekGarch11 Ptr CGarch11
res IO Garch11 -> (Garch11 -> IO Garch11) -> IO Garch11
forall a b. IO a -> (a -> IO b) -> IO b
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= \Garch11
res' ->
  Ptr (Ptr ()) -> IO ()
forall a. Ptr (Ptr a) -> IO ()
errorCheck  Ptr (Ptr ())
a4'IO () -> IO Garch11 -> IO Garch11
forall a b. IO a -> IO b -> IO b
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>>
  Garch11 -> IO Garch11
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return (Garch11
res')

{-# LINE 910 "./QuantLib/Model.chs" #-}


-- |the calibrated (or constructor-supplied) alpha coefficient
alpha :: (Garch11) -> (Double)
alpha a1 =
  C2HSImp.unsafePerformIO $
  withGarch11 a1 $ \a1' -> 
  alpha'_ a1' >>= \res ->
  let {res' = realToFrac res} in
  return (res')

{-# LINE 913 "./QuantLib/Model.chs" #-}


-- |the calibrated (or constructor-supplied) beta coefficient
beta :: (Garch11) -> (Double)
beta a1 =
  C2HSImp.unsafePerformIO $
  withGarch11 a1 $ \a1' -> 
  beta'_ a1' >>= \res ->
  let {res' = realToFrac res} in
  return (res')

{-# LINE 916 "./QuantLib/Model.chs" #-}


-- |the calibrated (or derived) omega coefficient, @vl * (1 - alpha - beta)@
omega :: (Garch11) -> (Double)
omega a1 =
  C2HSImp.unsafePerformIO $
  withGarch11 a1 $ \a1' -> 
  omega'_ a1' >>= \res ->
  let {res' = realToFrac res} in
  return (res')

{-# LINE 919 "./QuantLib/Model.chs" #-}


-- |the calibrated (or constructor-supplied) long-term volatility
longTermVolatility :: (Garch11) -> (Double)
longTermVolatility a1 =
  C2HSImp.unsafePerformIO $
  withGarch11 a1 $ \a1' -> 
  longTermVolatility'_ a1' >>= \res ->
  let {res' = realToFrac res} in
  return (res')

{-# LINE 922 "./QuantLib/Model.chs" #-}


-- |the log-likelihood of the calibrated fit; @0@ for a direct-parameter ('garch11') model
logLikelihood :: (Garch11) -> (Double)
logLikelihood a1 =
  C2HSImp.unsafePerformIO $
  withGarch11 a1 $ \a1' -> 
  logLikelihood'_ a1' >>= \res ->
  let {res' = realToFrac res} in
  return (res')

{-# LINE 925 "./QuantLib/Model.chs" #-}


-- |one-step-ahead variance forecast: @gamma*vl + alpha*r^2 + beta*sigma2@, given the latest
-- return @r@ and the previous step's variance @sigma2@.
forecast :: (Garch11) -> (Double) -- ^r
 -> (Double) -- ^sigma2
 -> (Double)
forecast a1 a2 a3 =
  C2HSImp.unsafePerformIO $
  withGarch11 a1 $ \a1' -> 
  let {a2' = realToFrac a2} in 
  let {a3' = realToFrac a3} in 
  forecast'_ a1' a2' a3' >>= \res ->
  let {res' = realToFrac res} in
  return (res')

{-# LINE 932 "./QuantLib/Model.chs" #-}


-- |Runs the model's calibrated (or constructor-supplied) alpha\/beta\/omega recursion forward
-- over a return series. The output series is offset by one from the input: the first input
-- point has nothing to forecast from, so it is dropped, and one extra point is extrapolated one
-- step past the input series' last date -- an @n@-point input still produces an @n@-point
-- output, just shifted forward by one date.
calculate :: Garch11 -> NonEmpty (Day, Double) -- ^return series
  -> IO [(Day, Double)]
calculate g series = do
  (ds, vs) <- qlGarch11Calculate g dates vals
  return $ zip ds vs
  where (dates, vals) = unzip (toList series)
qlGarch11Calculate :: (Garch11) -> ([Day]) -> ([Double]) -> IO (([Day]), ([Double]))
qlGarch11Calculate :: Garch11 -> [Day] -> [Double] -> IO ([Day], [Double])
qlGarch11Calculate Garch11
a1 [Day]
a2 [Double]
a3 =
  Garch11
-> (Ptr CGarch11 -> IO ([Day], [Double])) -> IO ([Day], [Double])
forall b. Garch11 -> (Ptr CGarch11 -> IO b) -> IO b
withGarch11 Garch11
a1 ((Ptr CGarch11 -> IO ([Day], [Double])) -> IO ([Day], [Double]))
-> (Ptr CGarch11 -> IO ([Day], [Double])) -> IO ([Day], [Double])
forall a b. (a -> b) -> a -> b
$ \Ptr CGarch11
a1' -> 
  [Day]
-> ((CUInt, Ptr CInt) -> IO ([Day], [Double]))
-> IO ([Day], [Double])
forall b. [Day] -> ((CUInt, Ptr CInt) -> IO b) -> IO b
withDayArray [Day]
a2 (((CUInt, Ptr CInt) -> IO ([Day], [Double]))
 -> IO ([Day], [Double]))
-> ((CUInt, Ptr CInt) -> IO ([Day], [Double]))
-> IO ([Day], [Double])
forall a b. (a -> b) -> a -> b
$ \(CUInt
a2'1, Ptr CInt
a2'2) -> 
  [Double]
-> ((CUInt, Ptr CDouble) -> IO ([Day], [Double]))
-> IO ([Day], [Double])
forall b. [Double] -> ((CUInt, Ptr CDouble) -> IO b) -> IO b
withDoubleArray [Double]
a3 (((CUInt, Ptr CDouble) -> IO ([Day], [Double]))
 -> IO ([Day], [Double]))
-> ((CUInt, Ptr CDouble) -> IO ([Day], [Double]))
-> IO ([Day], [Double])
forall a b. (a -> b) -> a -> b
$ \(CUInt
a3'1, Ptr CDouble
a3'2) -> 
  ((Ptr CUInt, Ptr (Ptr CInt)) -> IO ([Day], [Double]))
-> IO ([Day], [Double])
forall b. ((Ptr CUInt, Ptr (Ptr CInt)) -> IO b) -> IO b
preIntArray (((Ptr CUInt, Ptr (Ptr CInt)) -> IO ([Day], [Double]))
 -> IO ([Day], [Double]))
-> ((Ptr CUInt, Ptr (Ptr CInt)) -> IO ([Day], [Double]))
-> IO ([Day], [Double])
forall a b. (a -> b) -> a -> b
$ \(Ptr CUInt
a4'1, Ptr (Ptr CInt)
a4'2) -> 
  ((Ptr CUInt, Ptr (Ptr CDouble)) -> IO ([Day], [Double]))
-> IO ([Day], [Double])
forall b. ((Ptr CUInt, Ptr (Ptr CDouble)) -> IO b) -> IO b
preDoubleArray (((Ptr CUInt, Ptr (Ptr CDouble)) -> IO ([Day], [Double]))
 -> IO ([Day], [Double]))
-> ((Ptr CUInt, Ptr (Ptr CDouble)) -> IO ([Day], [Double]))
-> IO ([Day], [Double])
forall a b. (a -> b) -> a -> b
$ \(Ptr CUInt
a5'1, Ptr (Ptr CDouble)
a5'2) -> 
  (Ptr (Ptr ()) -> IO ([Day], [Double])) -> IO ([Day], [Double])
forall a b. (Ptr (Ptr a) -> IO b) -> IO b
preErrorCheck ((Ptr (Ptr ()) -> IO ([Day], [Double])) -> IO ([Day], [Double]))
-> (Ptr (Ptr ()) -> IO ([Day], [Double])) -> IO ([Day], [Double])
forall a b. (a -> b) -> a -> b
$ \Ptr (Ptr ())
a6' -> 
  Ptr CGarch11
-> CUInt
-> Ptr CInt
-> CUInt
-> Ptr CDouble
-> Ptr CUInt
-> Ptr (Ptr CInt)
-> Ptr CUInt
-> Ptr (Ptr CDouble)
-> Ptr (Ptr ())
-> IO ()
qlGarch11Calculate'_ Ptr CGarch11
a1' CUInt
a2'1  Ptr CInt
a2'2 CUInt
a3'1  Ptr CDouble
a3'2 Ptr CUInt
a4'1  Ptr (Ptr CInt)
a4'2 Ptr CUInt
a5'1  Ptr (Ptr CDouble)
a5'2 Ptr (Ptr ())
a6' IO () -> IO [Day] -> IO [Day]
forall a b. IO a -> IO b -> IO b
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>>
  Ptr CUInt -> Ptr (Ptr CInt) -> IO [Day]
peekDayArray  Ptr CUInt
a4'1  Ptr (Ptr CInt)
a4'2IO [Day] -> ([Day] -> IO ([Day], [Double])) -> IO ([Day], [Double])
forall a b. IO a -> (a -> IO b) -> IO b
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= \[Day]
a4'' -> 
  Ptr CUInt -> Ptr (Ptr CDouble) -> IO [Double]
peekDoubleArray  Ptr CUInt
a5'1  Ptr (Ptr CDouble)
a5'2IO [Double]
-> ([Double] -> IO ([Day], [Double])) -> IO ([Day], [Double])
forall a b. IO a -> (a -> IO b) -> IO b
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= \[Double]
a5'' -> 
  Ptr (Ptr ()) -> IO ()
forall a. Ptr (Ptr a) -> IO ()
errorCheck  Ptr (Ptr ())
a6'IO () -> IO ([Day], [Double]) -> IO ([Day], [Double])
forall a b. IO a -> IO b -> IO b
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>>
  ([Day], [Double]) -> IO ([Day], [Double])
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return ([Day]
a4'', [Double]
a5'')

{-# LINE 947 "./QuantLib/Model.chs" #-}


-- |Garman-Klass (1980) simple estimator: @sigma^2 = ln(close\/open)^2@, scaled by @yearFraction@.
-- Input bars are @(date, open, close, high, low)@; only open\/close are used here.
garmanKlassSimpleSigma :: Double -- ^yearFraction
  -> NonEmpty (Day, Double, Double, Double, Double) -- ^(date, open, close, high, low) price bars
  -> IO [(Day, Double)]
garmanKlassSimpleSigma yearFraction bars = do
  (ds, vs) <- qlGarmanKlassSimpleSigma yearFraction dates opens closes highs lows
  return $ zip ds vs
  where (dates, opens, closes, highs, lows) = unzipBars bars
qlGarmanKlassSimpleSigma :: (Double) -> ([Day]) -> ([Double]) -> ([Double]) -> ([Double]) -> ([Double]) -> IO (([Day]), ([Double]))
qlGarmanKlassSimpleSigma :: Double
-> [Day]
-> [Double]
-> [Double]
-> [Double]
-> [Double]
-> IO ([Day], [Double])
qlGarmanKlassSimpleSigma Double
a1 [Day]
a2 [Double]
a3 [Double]
a4 [Double]
a5 [Double]
a6 =
  let {a1' :: CDouble
a1' = Double -> CDouble
forall a b. (Real a, Fractional b) => a -> b
realToFrac Double
a1} in 
  [Day]
-> ((CUInt, Ptr CInt) -> IO ([Day], [Double]))
-> IO ([Day], [Double])
forall b. [Day] -> ((CUInt, Ptr CInt) -> IO b) -> IO b
withDayArray [Day]
a2 (((CUInt, Ptr CInt) -> IO ([Day], [Double]))
 -> IO ([Day], [Double]))
-> ((CUInt, Ptr CInt) -> IO ([Day], [Double]))
-> IO ([Day], [Double])
forall a b. (a -> b) -> a -> b
$ \(CUInt
a2'1, Ptr CInt
a2'2) -> 
  [Double]
-> ((CUInt, Ptr CDouble) -> IO ([Day], [Double]))
-> IO ([Day], [Double])
forall b. [Double] -> ((CUInt, Ptr CDouble) -> IO b) -> IO b
withDoubleArray [Double]
a3 (((CUInt, Ptr CDouble) -> IO ([Day], [Double]))
 -> IO ([Day], [Double]))
-> ((CUInt, Ptr CDouble) -> IO ([Day], [Double]))
-> IO ([Day], [Double])
forall a b. (a -> b) -> a -> b
$ \(CUInt
a3'1, Ptr CDouble
a3'2) -> 
  [Double]
-> ((CUInt, Ptr CDouble) -> IO ([Day], [Double]))
-> IO ([Day], [Double])
forall b. [Double] -> ((CUInt, Ptr CDouble) -> IO b) -> IO b
withDoubleArray [Double]
a4 (((CUInt, Ptr CDouble) -> IO ([Day], [Double]))
 -> IO ([Day], [Double]))
-> ((CUInt, Ptr CDouble) -> IO ([Day], [Double]))
-> IO ([Day], [Double])
forall a b. (a -> b) -> a -> b
$ \(CUInt
a4'1, Ptr CDouble
a4'2) -> 
  [Double]
-> ((CUInt, Ptr CDouble) -> IO ([Day], [Double]))
-> IO ([Day], [Double])
forall b. [Double] -> ((CUInt, Ptr CDouble) -> IO b) -> IO b
withDoubleArray [Double]
a5 (((CUInt, Ptr CDouble) -> IO ([Day], [Double]))
 -> IO ([Day], [Double]))
-> ((CUInt, Ptr CDouble) -> IO ([Day], [Double]))
-> IO ([Day], [Double])
forall a b. (a -> b) -> a -> b
$ \(CUInt
a5'1, Ptr CDouble
a5'2) -> 
  [Double]
-> ((CUInt, Ptr CDouble) -> IO ([Day], [Double]))
-> IO ([Day], [Double])
forall b. [Double] -> ((CUInt, Ptr CDouble) -> IO b) -> IO b
withDoubleArray [Double]
a6 (((CUInt, Ptr CDouble) -> IO ([Day], [Double]))
 -> IO ([Day], [Double]))
-> ((CUInt, Ptr CDouble) -> IO ([Day], [Double]))
-> IO ([Day], [Double])
forall a b. (a -> b) -> a -> b
$ \(CUInt
a6'1, Ptr CDouble
a6'2) -> 
  ((Ptr CUInt, Ptr (Ptr CInt)) -> IO ([Day], [Double]))
-> IO ([Day], [Double])
forall b. ((Ptr CUInt, Ptr (Ptr CInt)) -> IO b) -> IO b
preIntArray (((Ptr CUInt, Ptr (Ptr CInt)) -> IO ([Day], [Double]))
 -> IO ([Day], [Double]))
-> ((Ptr CUInt, Ptr (Ptr CInt)) -> IO ([Day], [Double]))
-> IO ([Day], [Double])
forall a b. (a -> b) -> a -> b
$ \(Ptr CUInt
a7'1, Ptr (Ptr CInt)
a7'2) -> 
  ((Ptr CUInt, Ptr (Ptr CDouble)) -> IO ([Day], [Double]))
-> IO ([Day], [Double])
forall b. ((Ptr CUInt, Ptr (Ptr CDouble)) -> IO b) -> IO b
preDoubleArray (((Ptr CUInt, Ptr (Ptr CDouble)) -> IO ([Day], [Double]))
 -> IO ([Day], [Double]))
-> ((Ptr CUInt, Ptr (Ptr CDouble)) -> IO ([Day], [Double]))
-> IO ([Day], [Double])
forall a b. (a -> b) -> a -> b
$ \(Ptr CUInt
a8'1, Ptr (Ptr CDouble)
a8'2) -> 
  (Ptr (Ptr ()) -> IO ([Day], [Double])) -> IO ([Day], [Double])
forall a b. (Ptr (Ptr a) -> IO b) -> IO b
preErrorCheck ((Ptr (Ptr ()) -> IO ([Day], [Double])) -> IO ([Day], [Double]))
-> (Ptr (Ptr ()) -> IO ([Day], [Double])) -> IO ([Day], [Double])
forall a b. (a -> b) -> a -> b
$ \Ptr (Ptr ())
a9' -> 
  CDouble
-> CUInt
-> Ptr CInt
-> CUInt
-> Ptr CDouble
-> CUInt
-> Ptr CDouble
-> CUInt
-> Ptr CDouble
-> CUInt
-> Ptr CDouble
-> Ptr CUInt
-> Ptr (Ptr CInt)
-> Ptr CUInt
-> Ptr (Ptr CDouble)
-> Ptr (Ptr ())
-> IO ()
qlGarmanKlassSimpleSigma'_ CDouble
a1' CUInt
a2'1  Ptr CInt
a2'2 CUInt
a3'1  Ptr CDouble
a3'2 CUInt
a4'1  Ptr CDouble
a4'2 CUInt
a5'1  Ptr CDouble
a5'2 CUInt
a6'1  Ptr CDouble
a6'2 Ptr CUInt
a7'1  Ptr (Ptr CInt)
a7'2 Ptr CUInt
a8'1  Ptr (Ptr CDouble)
a8'2 Ptr (Ptr ())
a9' IO () -> IO [Day] -> IO [Day]
forall a b. IO a -> IO b -> IO b
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>>
  Ptr CUInt -> Ptr (Ptr CInt) -> IO [Day]
peekDayArray  Ptr CUInt
a7'1  Ptr (Ptr CInt)
a7'2IO [Day] -> ([Day] -> IO ([Day], [Double])) -> IO ([Day], [Double])
forall a b. IO a -> (a -> IO b) -> IO b
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= \[Day]
a7'' -> 
  Ptr CUInt -> Ptr (Ptr CDouble) -> IO [Double]
peekDoubleArray  Ptr CUInt
a8'1  Ptr (Ptr CDouble)
a8'2IO [Double]
-> ([Double] -> IO ([Day], [Double])) -> IO ([Day], [Double])
forall a b. IO a -> (a -> IO b) -> IO b
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= \[Double]
a8'' -> 
  Ptr (Ptr ()) -> IO ()
forall a. Ptr (Ptr a) -> IO ()
errorCheck  Ptr (Ptr ())
a9'IO () -> IO ([Day], [Double]) -> IO ([Day], [Double])
forall a b. IO a -> IO b -> IO b
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>>
  ([Day], [Double]) -> IO ([Day], [Double])
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return ([Day]
a7'', [Double]
a8'')

{-# LINE 961 "./QuantLib/Model.chs" #-}


-- |Garman-Klass Sigma1: blends 'garmanKlassSimpleSigma' with the overnight (previous close to
-- today's open) jump, weighted by @marketOpenFraction@ (the fraction of the trading day the
-- market is open). Drops the series' first bar (needs a previous close).
garmanKlassSigma1 :: Double -- ^yearFraction
  -> Double -- ^marketOpenFraction
  -> NonEmpty (Day, Double, Double, Double, Double) -- ^(date, open, close, high, low) price bars
  -> IO [(Day, Double)]
garmanKlassSigma1 yearFraction marketOpenFraction bars = do
  (ds, vs) <- qlGarmanKlassSigma1 yearFraction marketOpenFraction dates opens closes highs lows
  return $ zip ds vs
  where (dates, opens, closes, highs, lows) = unzipBars bars
qlGarmanKlassSigma1 :: (Double) -> (Double) -> ([Day]) -> ([Double]) -> ([Double]) -> ([Double]) -> ([Double]) -> IO (([Day]), ([Double]))
qlGarmanKlassSigma1 :: Double
-> Double
-> [Day]
-> [Double]
-> [Double]
-> [Double]
-> [Double]
-> IO ([Day], [Double])
qlGarmanKlassSigma1 Double
a1 Double
a2 [Day]
a3 [Double]
a4 [Double]
a5 [Double]
a6 [Double]
a7 =
  let {a1' :: CDouble
a1' = Double -> CDouble
forall a b. (Real a, Fractional b) => a -> b
realToFrac Double
a1} in 
  let {a2' :: CDouble
a2' = Double -> CDouble
forall a b. (Real a, Fractional b) => a -> b
realToFrac Double
a2} in 
  [Day]
-> ((CUInt, Ptr CInt) -> IO ([Day], [Double]))
-> IO ([Day], [Double])
forall b. [Day] -> ((CUInt, Ptr CInt) -> IO b) -> IO b
withDayArray [Day]
a3 (((CUInt, Ptr CInt) -> IO ([Day], [Double]))
 -> IO ([Day], [Double]))
-> ((CUInt, Ptr CInt) -> IO ([Day], [Double]))
-> IO ([Day], [Double])
forall a b. (a -> b) -> a -> b
$ \(CUInt
a3'1, Ptr CInt
a3'2) -> 
  [Double]
-> ((CUInt, Ptr CDouble) -> IO ([Day], [Double]))
-> IO ([Day], [Double])
forall b. [Double] -> ((CUInt, Ptr CDouble) -> IO b) -> IO b
withDoubleArray [Double]
a4 (((CUInt, Ptr CDouble) -> IO ([Day], [Double]))
 -> IO ([Day], [Double]))
-> ((CUInt, Ptr CDouble) -> IO ([Day], [Double]))
-> IO ([Day], [Double])
forall a b. (a -> b) -> a -> b
$ \(CUInt
a4'1, Ptr CDouble
a4'2) -> 
  [Double]
-> ((CUInt, Ptr CDouble) -> IO ([Day], [Double]))
-> IO ([Day], [Double])
forall b. [Double] -> ((CUInt, Ptr CDouble) -> IO b) -> IO b
withDoubleArray [Double]
a5 (((CUInt, Ptr CDouble) -> IO ([Day], [Double]))
 -> IO ([Day], [Double]))
-> ((CUInt, Ptr CDouble) -> IO ([Day], [Double]))
-> IO ([Day], [Double])
forall a b. (a -> b) -> a -> b
$ \(CUInt
a5'1, Ptr CDouble
a5'2) -> 
  [Double]
-> ((CUInt, Ptr CDouble) -> IO ([Day], [Double]))
-> IO ([Day], [Double])
forall b. [Double] -> ((CUInt, Ptr CDouble) -> IO b) -> IO b
withDoubleArray [Double]
a6 (((CUInt, Ptr CDouble) -> IO ([Day], [Double]))
 -> IO ([Day], [Double]))
-> ((CUInt, Ptr CDouble) -> IO ([Day], [Double]))
-> IO ([Day], [Double])
forall a b. (a -> b) -> a -> b
$ \(CUInt
a6'1, Ptr CDouble
a6'2) -> 
  [Double]
-> ((CUInt, Ptr CDouble) -> IO ([Day], [Double]))
-> IO ([Day], [Double])
forall b. [Double] -> ((CUInt, Ptr CDouble) -> IO b) -> IO b
withDoubleArray [Double]
a7 (((CUInt, Ptr CDouble) -> IO ([Day], [Double]))
 -> IO ([Day], [Double]))
-> ((CUInt, Ptr CDouble) -> IO ([Day], [Double]))
-> IO ([Day], [Double])
forall a b. (a -> b) -> a -> b
$ \(CUInt
a7'1, Ptr CDouble
a7'2) -> 
  ((Ptr CUInt, Ptr (Ptr CInt)) -> IO ([Day], [Double]))
-> IO ([Day], [Double])
forall b. ((Ptr CUInt, Ptr (Ptr CInt)) -> IO b) -> IO b
preIntArray (((Ptr CUInt, Ptr (Ptr CInt)) -> IO ([Day], [Double]))
 -> IO ([Day], [Double]))
-> ((Ptr CUInt, Ptr (Ptr CInt)) -> IO ([Day], [Double]))
-> IO ([Day], [Double])
forall a b. (a -> b) -> a -> b
$ \(Ptr CUInt
a8'1, Ptr (Ptr CInt)
a8'2) -> 
  ((Ptr CUInt, Ptr (Ptr CDouble)) -> IO ([Day], [Double]))
-> IO ([Day], [Double])
forall b. ((Ptr CUInt, Ptr (Ptr CDouble)) -> IO b) -> IO b
preDoubleArray (((Ptr CUInt, Ptr (Ptr CDouble)) -> IO ([Day], [Double]))
 -> IO ([Day], [Double]))
-> ((Ptr CUInt, Ptr (Ptr CDouble)) -> IO ([Day], [Double]))
-> IO ([Day], [Double])
forall a b. (a -> b) -> a -> b
$ \(Ptr CUInt
a9'1, Ptr (Ptr CDouble)
a9'2) -> 
  (Ptr (Ptr ()) -> IO ([Day], [Double])) -> IO ([Day], [Double])
forall a b. (Ptr (Ptr a) -> IO b) -> IO b
preErrorCheck ((Ptr (Ptr ()) -> IO ([Day], [Double])) -> IO ([Day], [Double]))
-> (Ptr (Ptr ()) -> IO ([Day], [Double])) -> IO ([Day], [Double])
forall a b. (a -> b) -> a -> b
$ \Ptr (Ptr ())
a10' -> 
  CDouble
-> CDouble
-> CUInt
-> Ptr CInt
-> CUInt
-> Ptr CDouble
-> CUInt
-> Ptr CDouble
-> CUInt
-> Ptr CDouble
-> CUInt
-> Ptr CDouble
-> Ptr CUInt
-> Ptr (Ptr CInt)
-> Ptr CUInt
-> Ptr (Ptr CDouble)
-> Ptr (Ptr ())
-> IO ()
qlGarmanKlassSigma1'_ CDouble
a1' CDouble
a2' CUInt
a3'1  Ptr CInt
a3'2 CUInt
a4'1  Ptr CDouble
a4'2 CUInt
a5'1  Ptr CDouble
a5'2 CUInt
a6'1  Ptr CDouble
a6'2 CUInt
a7'1  Ptr CDouble
a7'2 Ptr CUInt
a8'1  Ptr (Ptr CInt)
a8'2 Ptr CUInt
a9'1  Ptr (Ptr CDouble)
a9'2 Ptr (Ptr ())
a10' IO () -> IO [Day] -> IO [Day]
forall a b. IO a -> IO b -> IO b
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>>
  Ptr CUInt -> Ptr (Ptr CInt) -> IO [Day]
peekDayArray  Ptr CUInt
a8'1  Ptr (Ptr CInt)
a8'2IO [Day] -> ([Day] -> IO ([Day], [Double])) -> IO ([Day], [Double])
forall a b. IO a -> (a -> IO b) -> IO b
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= \[Day]
a8'' -> 
  Ptr CUInt -> Ptr (Ptr CDouble) -> IO [Double]
peekDoubleArray  Ptr CUInt
a9'1  Ptr (Ptr CDouble)
a9'2IO [Double]
-> ([Double] -> IO ([Day], [Double])) -> IO ([Day], [Double])
forall a b. IO a -> (a -> IO b) -> IO b
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= \[Double]
a9'' -> 
  Ptr (Ptr ()) -> IO ()
forall a. Ptr (Ptr a) -> IO ()
errorCheck  Ptr (Ptr ())
a10'IO () -> IO ([Day], [Double]) -> IO ([Day], [Double])
forall a b. IO a -> IO b -> IO b
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>>
  ([Day], [Double]) -> IO ([Day], [Double])
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return ([Day]
a8'', [Double]
a9'')

{-# LINE 977 "./QuantLib/Model.chs" #-}


-- |Parkinson (1980) high-low estimator: @sigma^2 = ln(high\/low)^2 \/ (4 ln 2)@, scaled by
-- @yearFraction@. Input bars are @(date, open, close, high, low)@; only high\/low are used here.
parkinsonSigma :: Double -- ^yearFraction
  -> NonEmpty (Day, Double, Double, Double, Double) -- ^(date, open, close, high, low) price bars
  -> IO [(Day, Double)]
parkinsonSigma yearFraction bars = do
  (ds, vs) <- qlParkinsonSigma yearFraction dates opens closes highs lows
  return $ zip ds vs
  where (dates, opens, closes, highs, lows) = unzipBars bars
qlParkinsonSigma :: (Double) -> ([Day]) -> ([Double]) -> ([Double]) -> ([Double]) -> ([Double]) -> IO (([Day]), ([Double]))
qlParkinsonSigma a1 a2 a3 a4 a5 a6 =
  let {a1' = realToFrac a1} in 
  withDayArray a2 $ \(a2'1, a2'2) -> 
  withDoubleArray a3 $ \(a3'1, a3'2) -> 
  withDoubleArray a4 $ \(a4'1, a4'2) -> 
  withDoubleArray a5 $ \(a5'1, a5'2) -> 
  withDoubleArray a6 $ \(a6'1, a6'2) -> 
  preIntArray $ \(a7'1, a7'2) -> 
  preDoubleArray $ \(a8'1, a8'2) -> 
  preErrorCheck $ \a9' -> 
  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' >>
  peekDayArray  a7'1  a7'2>>= \a7'' -> 
  peekDoubleArray  a8'1  a8'2>>= \a8'' -> 
  errorCheck  a9'>>
  return (a7'', a8'')

{-# LINE 991 "./QuantLib/Model.chs" #-}


-- |Garman-Klass Sigma3: blends 'parkinsonSigma' with the overnight jump, same
-- @marketOpenFraction@ weighting as 'garmanKlassSigma1'. Drops the series' first bar.
garmanKlassSigma3 :: Double -- ^yearFraction
  -> Double -- ^marketOpenFraction
  -> NonEmpty (Day, Double, Double, Double, Double) -- ^(date, open, close, high, low) price bars
  -> IO [(Day, Double)]
garmanKlassSigma3 yearFraction marketOpenFraction bars = do
  (ds, vs) <- qlGarmanKlassSigma3 yearFraction marketOpenFraction dates opens closes highs lows
  return $ zip ds vs
  where (dates, opens, closes, highs, lows) = unzipBars bars
qlGarmanKlassSigma3 :: (Double) -> (Double) -> ([Day]) -> ([Double]) -> ([Double]) -> ([Double]) -> ([Double]) -> IO (([Day]), ([Double]))
qlGarmanKlassSigma3 a1 a2 a3 a4 a5 a6 a7 =
  let {a1' = realToFrac a1} in 
  let {a2' = realToFrac a2} in 
  withDayArray a3 $ \(a3'1, a3'2) -> 
  withDoubleArray a4 $ \(a4'1, a4'2) -> 
  withDoubleArray a5 $ \(a5'1, a5'2) -> 
  withDoubleArray a6 $ \(a6'1, a6'2) -> 
  withDoubleArray a7 $ \(a7'1, a7'2) -> 
  preIntArray $ \(a8'1, a8'2) -> 
  preDoubleArray $ \(a9'1, a9'2) -> 
  preErrorCheck $ \a10' -> 
  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' >>
  peekDayArray  a8'1  a8'2>>= \a8'' -> 
  peekDoubleArray  a9'1  a9'2>>= \a9'' -> 
  errorCheck  a10'>>
  return (a8'', a9'')

{-# LINE 1006 "./QuantLib/Model.chs" #-}


-- |Garman-Klass (1980) Sigma4 estimator, combining the high-low range with the close-open
-- return via their published coefficients. Input bars are @(date, open, close, high, low)@.
garmanKlassSigma4 :: Double -- ^yearFraction
  -> NonEmpty (Day, Double, Double, Double, Double) -- ^(date, open, close, high, low) price bars
  -> IO [(Day, Double)]
garmanKlassSigma4 yearFraction bars = do
  (ds, vs) <- qlGarmanKlassSigma4 yearFraction dates opens closes highs lows
  return $ zip ds vs
  where (dates, opens, closes, highs, lows) = unzipBars bars
qlGarmanKlassSigma4 :: (Double) -> ([Day]) -> ([Double]) -> ([Double]) -> ([Double]) -> ([Double]) -> IO (([Day]), ([Double]))
qlGarmanKlassSigma4 a1 a2 a3 a4 a5 a6 =
  let {a1' = realToFrac a1} in 
  withDayArray a2 $ \(a2'1, a2'2) -> 
  withDoubleArray a3 $ \(a3'1, a3'2) -> 
  withDoubleArray a4 $ \(a4'1, a4'2) -> 
  withDoubleArray a5 $ \(a5'1, a5'2) -> 
  withDoubleArray a6 $ \(a6'1, a6'2) -> 
  preIntArray $ \(a7'1, a7'2) -> 
  preDoubleArray $ \(a8'1, a8'2) -> 
  preErrorCheck $ \a9' -> 
  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' >>
  peekDayArray  a7'1  a7'2>>= \a7'' -> 
  peekDoubleArray  a8'1  a8'2>>= \a8'' -> 
  errorCheck  a9'>>
  return (a7'', a8'')

{-# LINE 1020 "./QuantLib/Model.chs" #-}


-- |Garman-Klass (1980) Sigma5 estimator: an alternative high-low\/close-open combination to
-- 'garmanKlassSigma4', with different published coefficients.
garmanKlassSigma5 :: Double -- ^yearFraction
  -> NonEmpty (Day, Double, Double, Double, Double) -- ^(date, open, close, high, low) price bars
  -> IO [(Day, Double)]
garmanKlassSigma5 yearFraction bars = do
  (ds, vs) <- qlGarmanKlassSigma5 yearFraction dates opens closes highs lows
  return $ zip ds vs
  where (dates, opens, closes, highs, lows) = unzipBars bars
qlGarmanKlassSigma5 :: (Double) -> ([Day]) -> ([Double]) -> ([Double]) -> ([Double]) -> ([Double]) -> IO (([Day]), ([Double]))
qlGarmanKlassSigma5 a1 a2 a3 a4 a5 a6 =
  let {a1' = realToFrac a1} in 
  withDayArray a2 $ \(a2'1, a2'2) -> 
  withDoubleArray a3 $ \(a3'1, a3'2) -> 
  withDoubleArray a4 $ \(a4'1, a4'2) -> 
  withDoubleArray a5 $ \(a5'1, a5'2) -> 
  withDoubleArray a6 $ \(a6'1, a6'2) -> 
  preIntArray $ \(a7'1, a7'2) -> 
  preDoubleArray $ \(a8'1, a8'2) -> 
  preErrorCheck $ \a9' -> 
  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' >>
  peekDayArray  a7'1  a7'2>>= \a7'' -> 
  peekDoubleArray  a8'1  a8'2>>= \a8'' -> 
  errorCheck  a9'>>
  return (a7'', a8'')

{-# LINE 1034 "./QuantLib/Model.chs" #-}


-- |Garman-Klass Sigma6: blends 'garmanKlassSigma5' with the overnight jump, same
-- @marketOpenFraction@ weighting as 'garmanKlassSigma1'. Drops the series' first bar.
garmanKlassSigma6 :: Double -- ^yearFraction
  -> Double -- ^marketOpenFraction
  -> NonEmpty (Day, Double, Double, Double, Double) -- ^(date, open, close, high, low) price bars
  -> IO [(Day, Double)]
garmanKlassSigma6 yearFraction marketOpenFraction bars = do
  (ds, vs) <- qlGarmanKlassSigma6 yearFraction marketOpenFraction dates opens closes highs lows
  return $ zip ds vs
  where (dates, opens, closes, highs, lows) = unzipBars bars
qlGarmanKlassSigma6 :: (Double) -> (Double) -> ([Day]) -> ([Double]) -> ([Double]) -> ([Double]) -> ([Double]) -> IO (([Day]), ([Double]))
qlGarmanKlassSigma6 a1 a2 a3 a4 a5 a6 a7 =
  let {a1' = realToFrac a1} in 
  let {a2' = realToFrac a2} in 
  withDayArray a3 $ \(a3'1, a3'2) -> 
  withDoubleArray a4 $ \(a4'1, a4'2) -> 
  withDoubleArray a5 $ \(a5'1, a5'2) -> 
  withDoubleArray a6 $ \(a6'1, a6'2) -> 
  withDoubleArray a7 $ \(a7'1, a7'2) -> 
  preIntArray $ \(a8'1, a8'2) -> 
  preDoubleArray $ \(a9'1, a9'2) -> 
  preErrorCheck $ \a10' -> 
  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' >>
  peekDayArray  a8'1  a8'2>>= \a8'' -> 
  peekDoubleArray  a9'1  a9'2>>= \a9'' -> 
  errorCheck  a10'>>
  return (a8'', a9'')

{-# LINE 1049 "./QuantLib/Model.chs" #-}


-- |Smooths an already-computed volatility series with a rolling constant estimate over the
-- trailing @windowSize@ points.
constantVolatilityEstimator :: Word -- ^windowSize
  -> NonEmpty (Day, Double) -- ^volatility series
  -> IO [(Day, Double)]
constantVolatilityEstimator windowSize series = do
  (ds, vs) <- qlConstantVolatilityEstimator windowSize dates vals
  return $ zip ds vs
  where (dates, vals) = unzip (toList series)
qlConstantVolatilityEstimator :: (Word) -> ([Day]) -> ([Double]) -> IO (([Day]), ([Double]))
qlConstantVolatilityEstimator a1 a2 a3 =
  let {a1' = fromIntegral a1} in 
  withDayArray a2 $ \(a2'1, a2'2) -> 
  withDoubleArray a3 $ \(a3'1, a3'2) -> 
  preIntArray $ \(a4'1, a4'2) -> 
  preDoubleArray $ \(a5'1, a5'2) -> 
  preErrorCheck $ \a6' -> 
  qlConstantVolatilityEstimator'_ a1' a2'1  a2'2 a3'1  a3'2 a4'1  a4'2 a5'1  a5'2 a6' >>
  peekDayArray  a4'1  a4'2>>= \a4'' -> 
  peekDoubleArray  a5'1  a5'2>>= \a5'' -> 
  errorCheck  a6'>>
  return (a4'', a5'')

{-# LINE 1062 "./QuantLib/Model.chs" #-}


-- |Local (point-to-point) volatility estimate from a raw price series: @|ln(p_i\/p_{i-1})| \/
-- sqrt(yearFraction)@ for each consecutive pair. Drops the series' first date; an @n@-point
-- input produces an @(n-1)@-point output.
simpleLocalVolatilityEstimator :: Double -- ^yearFraction
  -> NonEmpty (Day, Double) -- ^price series
  -> IO [(Day, Double)]
simpleLocalVolatilityEstimator yearFraction series = do
  (ds, vs) <- qlSimpleLocalVolatilityEstimator yearFraction dates vals
  return $ zip ds vs
  where (dates, vals) = unzip (toList series)
qlSimpleLocalVolatilityEstimator :: (Double) -> ([Day]) -> ([Double]) -> IO (([Day]), ([Double]))
qlSimpleLocalVolatilityEstimator :: Double -> [Day] -> [Double] -> IO ([Day], [Double])
qlSimpleLocalVolatilityEstimator Double
a1 [Day]
a2 [Double]
a3 =
  let {a1' :: CDouble
a1' = Double -> CDouble
forall a b. (Real a, Fractional b) => a -> b
realToFrac Double
a1} in 
  [Day]
-> ((CUInt, Ptr CInt) -> IO ([Day], [Double]))
-> IO ([Day], [Double])
forall b. [Day] -> ((CUInt, Ptr CInt) -> IO b) -> IO b
withDayArray [Day]
a2 (((CUInt, Ptr CInt) -> IO ([Day], [Double]))
 -> IO ([Day], [Double]))
-> ((CUInt, Ptr CInt) -> IO ([Day], [Double]))
-> IO ([Day], [Double])
forall a b. (a -> b) -> a -> b
$ \(CUInt
a2'1, Ptr CInt
a2'2) -> 
  [Double]
-> ((CUInt, Ptr CDouble) -> IO ([Day], [Double]))
-> IO ([Day], [Double])
forall b. [Double] -> ((CUInt, Ptr CDouble) -> IO b) -> IO b
withDoubleArray [Double]
a3 (((CUInt, Ptr CDouble) -> IO ([Day], [Double]))
 -> IO ([Day], [Double]))
-> ((CUInt, Ptr CDouble) -> IO ([Day], [Double]))
-> IO ([Day], [Double])
forall a b. (a -> b) -> a -> b
$ \(CUInt
a3'1, Ptr CDouble
a3'2) -> 
  ((Ptr CUInt, Ptr (Ptr CInt)) -> IO ([Day], [Double]))
-> IO ([Day], [Double])
forall b. ((Ptr CUInt, Ptr (Ptr CInt)) -> IO b) -> IO b
preIntArray (((Ptr CUInt, Ptr (Ptr CInt)) -> IO ([Day], [Double]))
 -> IO ([Day], [Double]))
-> ((Ptr CUInt, Ptr (Ptr CInt)) -> IO ([Day], [Double]))
-> IO ([Day], [Double])
forall a b. (a -> b) -> a -> b
$ \(Ptr CUInt
a4'1, Ptr (Ptr CInt)
a4'2) -> 
  ((Ptr CUInt, Ptr (Ptr CDouble)) -> IO ([Day], [Double]))
-> IO ([Day], [Double])
forall b. ((Ptr CUInt, Ptr (Ptr CDouble)) -> IO b) -> IO b
preDoubleArray (((Ptr CUInt, Ptr (Ptr CDouble)) -> IO ([Day], [Double]))
 -> IO ([Day], [Double]))
-> ((Ptr CUInt, Ptr (Ptr CDouble)) -> IO ([Day], [Double]))
-> IO ([Day], [Double])
forall a b. (a -> b) -> a -> b
$ \(Ptr CUInt
a5'1, Ptr (Ptr CDouble)
a5'2) -> 
  (Ptr (Ptr ()) -> IO ([Day], [Double])) -> IO ([Day], [Double])
forall a b. (Ptr (Ptr a) -> IO b) -> IO b
preErrorCheck ((Ptr (Ptr ()) -> IO ([Day], [Double])) -> IO ([Day], [Double]))
-> (Ptr (Ptr ()) -> IO ([Day], [Double])) -> IO ([Day], [Double])
forall a b. (a -> b) -> a -> b
$ \Ptr (Ptr ())
a6' -> 
  CDouble
-> CUInt
-> Ptr CInt
-> CUInt
-> Ptr CDouble
-> Ptr CUInt
-> Ptr (Ptr CInt)
-> Ptr CUInt
-> Ptr (Ptr CDouble)
-> Ptr (Ptr ())
-> IO ()
qlSimpleLocalVolatilityEstimator'_ CDouble
a1' CUInt
a2'1  Ptr CInt
a2'2 CUInt
a3'1  Ptr CDouble
a3'2 Ptr CUInt
a4'1  Ptr (Ptr CInt)
a4'2 Ptr CUInt
a5'1  Ptr (Ptr CDouble)
a5'2 Ptr (Ptr ())
a6' IO () -> IO [Day] -> IO [Day]
forall a b. IO a -> IO b -> IO b
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>>
  Ptr CUInt -> Ptr (Ptr CInt) -> IO [Day]
peekDayArray  Ptr CUInt
a4'1  Ptr (Ptr CInt)
a4'2IO [Day] -> ([Day] -> IO ([Day], [Double])) -> IO ([Day], [Double])
forall a b. IO a -> (a -> IO b) -> IO b
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= \[Day]
a4'' -> 
  Ptr CUInt -> Ptr (Ptr CDouble) -> IO [Double]
peekDoubleArray  Ptr CUInt
a5'1  Ptr (Ptr CDouble)
a5'2IO [Double]
-> ([Double] -> IO ([Day], [Double])) -> IO ([Day], [Double])
forall a b. IO a -> (a -> IO b) -> IO b
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= \[Double]
a5'' -> 
  Ptr (Ptr ()) -> IO ()
forall a. Ptr (Ptr a) -> IO ()
errorCheck  Ptr (Ptr ())
a6'IO () -> IO ([Day], [Double]) -> IO ([Day], [Double])
forall a b. IO a -> IO b -> IO b
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>>
  ([Day], [Double]) -> IO ([Day], [Double])
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return ([Day]
a4'', [Double]
a5'')

{-# LINE 1076 "./QuantLib/Model.chs" #-}


unzipBars :: NonEmpty (Day, Double, Double, Double, Double) -> ([Day], [Double], [Double], [Double], [Double])
unzipBars bars = (map d5 xs, map o5 xs, map c5 xs, map h5 xs, map l5 xs)
  where
    xs = toList bars
    d5 (d,_,_,_,_) = d
    o5 (_,o,_,_,_) = o
    c5 (_,_,c,_,_) = c
    h5 (_,_,_,h,_) = h
    l5 (_,_,_,_,l) = l

-- |Conditional compounded overnight rate using the coupon's observation dates and index day
-- counter; ignores gearing/spread and historical fixings. Requires QuantLib 1.44.
-- Nothing selects the model reference date or model curve.
gaussian1dCompoundedRate :: (Gaussian1dModel) -- ^model
 -> (OvernightIndexedCoupon) -- ^coupon
 -> (Maybe Day) -- ^referenceDate
 -> (Double) -- ^y
 -> (Maybe (GenYieldTermStructure y)) -- ^curve
 -> IO ((Double))
gaussian1dCompoundedRate :: forall y.
Gaussian1dModel
-> OvernightIndexedCoupon
-> Maybe Day
-> Double
-> Maybe (GenYieldTermStructure y)
-> IO Double
gaussian1dCompoundedRate Gaussian1dModel
a1 OvernightIndexedCoupon
a2 Maybe Day
a3 Double
a4 Maybe (GenYieldTermStructure y)
a5 =
  Gaussian1dModel
-> (Ptr CGaussian1dModel' -> IO Double) -> IO Double
forall a b. Standalone a -> (Ptr a -> IO b) -> IO b
withStandalone Gaussian1dModel
a1 ((Ptr CGaussian1dModel' -> IO Double) -> IO Double)
-> (Ptr CGaussian1dModel' -> IO Double) -> IO Double
forall a b. (a -> b) -> a -> b
$ \Ptr CGaussian1dModel'
a1' -> 
  OvernightIndexedCoupon
-> (Ptr COvernightIndexedCoupon' -> IO Double) -> IO Double
forall b.
OvernightIndexedCoupon
-> (Ptr COvernightIndexedCoupon' -> IO b) -> IO b
withOvernightIndexedCoupon OvernightIndexedCoupon
a2 ((Ptr COvernightIndexedCoupon' -> IO Double) -> IO Double)
-> (Ptr COvernightIndexedCoupon' -> IO Double) -> IO Double
forall a b. (a -> b) -> a -> b
$ \Ptr COvernightIndexedCoupon'
a2' -> 
  Maybe Day -> (CInt -> IO Double) -> IO Double
forall a. Maybe Day -> (CInt -> IO a) -> IO a
withMaybeDay Maybe Day
a3 ((CInt -> IO Double) -> IO Double)
-> (CInt -> IO Double) -> IO Double
forall a b. (a -> b) -> a -> b
$ \CInt
a3' -> 
  let {a4' :: CDouble
a4' = Double -> CDouble
forall a b. (Real a, Fractional b) => a -> b
realToFrac Double
a4} in 
  Maybe (GenYieldTermStructure y)
-> (Ptr CYieldTermStructure' -> IO Double) -> IO Double
forall y b.
Maybe (GenYieldTermStructure y)
-> (Ptr CYieldTermStructure' -> IO b) -> IO b
withMaybeYieldTermStructure Maybe (GenYieldTermStructure y)
a5 ((Ptr CYieldTermStructure' -> IO Double) -> IO Double)
-> (Ptr CYieldTermStructure' -> IO Double) -> IO Double
forall a b. (a -> b) -> a -> b
$ \Ptr CYieldTermStructure'
a5' -> 
  (Ptr (Ptr ()) -> IO Double) -> IO Double
forall a b. (Ptr (Ptr a) -> IO b) -> IO b
preErrorCheck ((Ptr (Ptr ()) -> IO Double) -> IO Double)
-> (Ptr (Ptr ()) -> IO Double) -> IO Double
forall a b. (a -> b) -> a -> b
$ \Ptr (Ptr ())
a6' -> 
  Ptr CGaussian1dModel'
-> Ptr COvernightIndexedCoupon'
-> CInt
-> CDouble
-> Ptr CYieldTermStructure'
-> Ptr (Ptr ())
-> IO CDouble
gaussian1dCompoundedRate'_ Ptr CGaussian1dModel'
a1' Ptr COvernightIndexedCoupon'
a2' CInt
a3' CDouble
a4' Ptr CYieldTermStructure'
a5' Ptr (Ptr ())
a6' IO CDouble -> (CDouble -> IO Double) -> IO Double
forall a b. IO a -> (a -> IO b) -> IO b
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= \CDouble
res ->
  let {res' :: Double
res' = CDouble -> Double
forall a b. (Real a, Fractional b) => a -> b
realToFrac CDouble
res} in
  Ptr (Ptr ()) -> IO ()
forall a. Ptr (Ptr a) -> IO ()
errorCheck  Ptr (Ptr ())
a6'IO () -> IO Double -> IO Double
forall a b. IO a -> IO b -> IO b
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>>
  Double -> IO Double
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return (Double
res')

{-# LINE 1096 "./QuantLib/Model.chs" #-}


-- |Rough Heston volatility model (1.44). Hurst is constrained to [0, 0.5]; 0.5 is classical Heston.
roughHestonModel :: (GenHestonProcess hp) -- ^process
 -> (Double) -- ^hurst
 -> IO ((RoughHestonModel))
roughHestonModel a1 a2 =
  withHestonProcess a1 $ \a1' -> 
  let {a2' = realToFrac a2} in 
  preErrorCheck $ \a3' -> 
  roughHestonModel'_ a1' a2' a3' >>= \res ->
  peekRoughHestonModel res >>= \res' ->
  errorCheck  a3'>>
  return (res')

{-# LINE 1101 "./QuantLib/Model.chs" #-}


-- |Current calibrated theta (1.44).
roughHestonTheta :: (RoughHestonModel) -- ^model
 -> IO ((Double))
roughHestonTheta a1 =
  withRoughHestonModel a1 $ \a1' -> 
  preErrorCheck $ \a2' -> 
  roughHestonTheta'_ a1' a2' >>= \res ->
  let {res' = realToFrac res} in
  errorCheck  a2'>>
  return (res')

{-# LINE 1105 "./QuantLib/Model.chs" #-}


-- |Current calibrated kappa (1.44).
roughHestonKappa :: (RoughHestonModel) -- ^model
 -> IO ((Double))
roughHestonKappa a1 =
  withRoughHestonModel a1 $ \a1' -> 
  preErrorCheck $ \a2' -> 
  roughHestonKappa'_ a1' a2' >>= \res ->
  let {res' = realToFrac res} in
  errorCheck  a2'>>
  return (res')

{-# LINE 1109 "./QuantLib/Model.chs" #-}


-- |Current calibrated sigma (1.44).
roughHestonSigma :: (RoughHestonModel) -- ^model
 -> IO ((Double))
roughHestonSigma a1 =
  withRoughHestonModel a1 $ \a1' -> 
  preErrorCheck $ \a2' -> 
  roughHestonSigma'_ a1' a2' >>= \res ->
  let {res' = realToFrac res} in
  errorCheck  a2'>>
  return (res')

{-# LINE 1113 "./QuantLib/Model.chs" #-}


-- |Current calibrated rho (1.44).
roughHestonRho :: (RoughHestonModel) -- ^model
 -> IO ((Double))
roughHestonRho a1 =
  withRoughHestonModel a1 $ \a1' -> 
  preErrorCheck $ \a2' -> 
  roughHestonRho'_ a1' a2' >>= \res ->
  let {res' = realToFrac res} in
  errorCheck  a2'>>
  return (res')

{-# LINE 1117 "./QuantLib/Model.chs" #-}


-- |Current calibrated v0 (1.44).
roughHestonV0 :: (RoughHestonModel) -- ^model
 -> IO ((Double))
roughHestonV0 a1 =
  withRoughHestonModel a1 $ \a1' -> 
  preErrorCheck $ \a2' -> 
  roughHestonV0'_ a1' a2' >>= \res ->
  let {res' = realToFrac res} in
  errorCheck  a2'>>
  return (res')

{-# LINE 1121 "./QuantLib/Model.chs" #-}


-- |Current calibrated hurst (1.44).
roughHestonHurst :: (RoughHestonModel) -- ^model
 -> IO ((Double))
roughHestonHurst a1 =
  withRoughHestonModel a1 $ \a1' -> 
  preErrorCheck $ \a2' -> 
  roughHestonHurst'_ a1' a2' >>= \res ->
  let {res' = realToFrac res} in
  errorCheck  a2'>>
  return (res')

{-# LINE 1125 "./QuantLib/Model.chs" #-}


-- |Current calibrated process (1.44).
roughHestonProcess :: (RoughHestonModel) -- ^model
 -> IO ((HestonProcess))
roughHestonProcess a1 =
  withRoughHestonModel a1 $ \a1' -> 
  preErrorCheck $ \a2' -> 
  roughHestonProcess'_ a1' a2' >>= \res ->
  peekHestonProcess res >>= \res' ->
  errorCheck  a2'>>
  return (res')

{-# LINE 1129 "./QuantLib/Model.chs" #-}


-- vim: set ff=unix ts=8 sts=2 sw=2 et:

foreign import ccall safe "QuantLib/Model.chs.h qlBatesModel"
  batesModel'_ :: ((C2HSImp.Ptr (CBatesProcess')) -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO (C2HSImp.Ptr (CBatesModel')))))

foreign import ccall safe "QuantLib/Model.chs.h qlBlackKarasinski"
  blackKarasinski'_ :: ((C2HSImp.Ptr (CYieldTermStructure')) -> (C2HSImp.CDouble -> (C2HSImp.CDouble -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO (C2HSImp.Ptr (CShortRateModel')))))))

foreign import ccall safe "QuantLib/Model.chs.h qlCoxIngersollRoss"
  coxIngersollRoss'_ :: (C2HSImp.CDouble -> (C2HSImp.CDouble -> (C2HSImp.CDouble -> (C2HSImp.CDouble -> (C2HSImp.CInt -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO (C2HSImp.Ptr (COneFactorAffineModel')))))))))

foreign import ccall safe "QuantLib/Model.chs.h qlExtendedCoxIngersollRoss"
  extendedCoxIngersollRoss'_ :: ((C2HSImp.Ptr (CYieldTermStructure')) -> (C2HSImp.CDouble -> (C2HSImp.CDouble -> (C2HSImp.CDouble -> (C2HSImp.CDouble -> (C2HSImp.CInt -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO (C2HSImp.Ptr (COneFactorAffineModel'))))))))))

foreign import ccall safe "QuantLib/Model.chs.h qlG2"
  g2'_ :: ((C2HSImp.Ptr (CYieldTermStructure')) -> (C2HSImp.CDouble -> (C2HSImp.CDouble -> (C2HSImp.CDouble -> (C2HSImp.CDouble -> (C2HSImp.CDouble -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO (C2HSImp.Ptr (CG2'))))))))))

foreign import ccall safe "QuantLib/Model.chs.h qlG2Dynamics"
  g2Dynamics'_ :: ((C2HSImp.Ptr (CG2')) -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO (C2HSImp.Ptr (CShortRateDynamics')))))

foreign import ccall safe "QuantLib/Model.chs.h qlShortRateDynamicsShortRate"
  shortRate'_ :: ((C2HSImp.Ptr (CShortRateDynamics')) -> (C2HSImp.CDouble -> (C2HSImp.CDouble -> (C2HSImp.CDouble -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO C2HSImp.CDouble))))))

foreign import ccall safe "QuantLib/Model.chs.h qlGeneralizedHullWhite"
  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')))))))))))))

foreign import ccall safe "QuantLib/Model.chs.h qlGJRGARCHModel"
  gjrGarchModel'_ :: ((C2HSImp.Ptr (CGJRGARCHProcess')) -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO (C2HSImp.Ptr (CGJRGARCHModel')))))

foreign import ccall safe "QuantLib/Model.chs.h qlHestonModel"
  hestonModel'_ :: ((C2HSImp.Ptr (CHestonProcess')) -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO (C2HSImp.Ptr (CHestonModel')))))

foreign import ccall safe "QuantLib/Model.chs.h qlMTBrownianGeneratorFactory"
  mtBrownianGeneratorFactory'_ :: (C2HSImp.CULong -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO (C2HSImp.Ptr (CBrownianGeneratorFactory')))))

foreign import ccall safe "QuantLib/Model.chs.h qlSobolBrownianGeneratorFactory"
  sobolBrownianGeneratorFactory'_ :: (C2HSImp.CInt -> (C2HSImp.CULong -> (C2HSImp.CInt -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO (C2HSImp.Ptr (CBrownianGeneratorFactory')))))))

foreign import ccall safe "QuantLib/Model.chs.h qlHestonSLVMCModel"
  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'))))))))))))))

foreign import ccall safe "QuantLib/Model.chs.h qlHestonSLVMCModelLeverageFunction"
  qlHestonSLVMCModelLeverageFunction'_ :: ((C2HSImp.Ptr (CHestonSLVMCModel')) -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO (C2HSImp.Ptr (CLocalVolTermStructure')))))

foreign import ccall safe "QuantLib/Model.chs.h qlHestonSLVFDMModel"
  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')))))))))))))))))))))))))))))))

foreign import ccall safe "QuantLib/Model.chs.h qlHestonSLVFDMModelLeverageFunction"
  qlHestonSLVFDMModelLeverageFunction'_ :: ((C2HSImp.Ptr (CHestonSLVFDMModel')) -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO (C2HSImp.Ptr (CLocalVolTermStructure')))))

foreign import ccall safe "QuantLib/Model.chs.h qlHestonSLVFDMModelLogEntries"
  hestonSlvFdmLogEntriesSnapshot'_ :: ((C2HSImp.Ptr (CHestonSLVFDMModel')) -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO (C2HSImp.Ptr (CHestonSLVFDMLogEntries)))))

foreign import ccall safe "QuantLib/Model.chs.h qlHestonSLVFDMLogEntriesSize"
  hestonSlvFdmLogEntriesSize'_ :: ((C2HSImp.Ptr (CHestonSLVFDMLogEntries)) -> (IO C2HSImp.CUInt))

foreign import ccall safe "QuantLib/Model.chs.h qlHestonSLVFDMLogEntriesTime"
  hestonSlvFdmLogEntriesTime'_ :: ((C2HSImp.Ptr (CHestonSLVFDMLogEntries)) -> (C2HSImp.CUInt -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO C2HSImp.CDouble))))

foreign import ccall safe "QuantLib/Model.chs.h qlHestonSLVFDMLogEntriesSpotGrid"
  hestonSlvFdmLogEntriesSpotGrid'_ :: ((C2HSImp.Ptr (CHestonSLVFDMLogEntries)) -> (C2HSImp.CUInt -> ((C2HSImp.Ptr C2HSImp.CUInt) -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CDouble)) -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO ()))))))

foreign import ccall safe "QuantLib/Model.chs.h qlHestonSLVFDMLogEntriesVarianceGrid"
  hestonSlvFdmLogEntriesVarianceGrid'_ :: ((C2HSImp.Ptr (CHestonSLVFDMLogEntries)) -> (C2HSImp.CUInt -> ((C2HSImp.Ptr C2HSImp.CUInt) -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CDouble)) -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO ()))))))

foreign import ccall safe "QuantLib/Model.chs.h qlHestonSLVFDMLogEntriesDensity"
  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 ()))))))))

foreign import ccall safe "QuantLib/Model.chs.h qlHullWhite"
  hullWhite'_ :: ((C2HSImp.Ptr (CYieldTermStructure')) -> (C2HSImp.CDouble -> (C2HSImp.CDouble -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO (C2HSImp.Ptr (CHullWhite')))))))

foreign import ccall safe "QuantLib/Model.chs.h qlHullWhiteConvexityBias"
  convexityBias'_ :: (C2HSImp.CDouble -> (C2HSImp.CDouble -> (C2HSImp.CDouble -> (C2HSImp.CDouble -> (C2HSImp.CDouble -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO C2HSImp.CDouble)))))))

foreign import ccall safe "QuantLib/Model.chs.h qlGsr"
  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'))))))))))))

foreign import ccall safe "QuantLib/Model.chs.h qlGsrVolatility"
  qlGsrVolatility'_ :: ((C2HSImp.Ptr (CGsr')) -> ((C2HSImp.Ptr C2HSImp.CUInt) -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CDouble)) -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO ())))))

foreign import ccall safe "QuantLib/Model.chs.h qlGsrReversion"
  reversions'_ :: ((C2HSImp.Ptr (CGsr')) -> ((C2HSImp.Ptr C2HSImp.CUInt) -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CDouble)) -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO ())))))

foreign import ccall safe "QuantLib/Model.chs.h qlGsrMoveVolatility"
  moveVolatility'_ :: ((C2HSImp.Ptr (CGsr')) -> (C2HSImp.CUInt -> ((C2HSImp.Ptr C2HSImp.CUInt) -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CInt)) -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO ()))))))

foreign import ccall safe "QuantLib/Model.chs.h qlGsrMoveReversion"
  moveReversion'_ :: ((C2HSImp.Ptr (CGsr')) -> (C2HSImp.CUInt -> ((C2HSImp.Ptr C2HSImp.CUInt) -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CInt)) -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO ()))))))

foreign import ccall safe "QuantLib/Model.chs.h qlGsrCalibrateVolatilitiesIterative"
  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 ()))))))))))

foreign import ccall safe "QuantLib/Model.chs.h qlGsrCalibrateReversionsIterative"
  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 ()))))))))))

foreign import ccall safe "QuantLib/Model.chs.h qlMarkovFunctional"
  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')))))))))))))))))))

foreign import ccall safe "QuantLib/Model.chs.h qlMarkovFunctionalCaplet"
  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')))))))))))))))

foreign import ccall safe "QuantLib/Model.chs.h qlMarkovFunctionalVolatility"
  qlMarkovFunctionalVolatility'_ :: ((C2HSImp.Ptr (CMarkovFunctional')) -> ((C2HSImp.Ptr C2HSImp.CUInt) -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CDouble)) -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO ())))))

foreign import ccall safe "QuantLib/Model.chs.h qlAffineModelDiscount"
  discount'_ :: ((C2HSImp.Ptr (CAffineModel')) -> (C2HSImp.CDouble -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO C2HSImp.CDouble))))

foreign import ccall safe "QuantLib/Model.chs.h qlAffineModelDiscountBond"
  discountBond'_ :: ((C2HSImp.Ptr (CAffineModel')) -> (C2HSImp.CDouble -> (C2HSImp.CDouble -> (C2HSImp.CUInt -> ((C2HSImp.Ptr C2HSImp.CDouble) -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO C2HSImp.CDouble)))))))

foreign import ccall safe "QuantLib/Model.chs.h qlAffineModelDiscountBondOption"
  discountBondOption_'_ :: ((C2HSImp.Ptr (CAffineModel')) -> (C2HSImp.CInt -> (C2HSImp.CDouble -> (C2HSImp.CDouble -> (C2HSImp.CInt -> (C2HSImp.CDouble -> (C2HSImp.CDouble -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO C2HSImp.CDouble)))))))))

foreign import ccall safe "QuantLib/Model.chs.h qlGaussian1dModelNumeraire"
  numeraire'_ :: ((C2HSImp.Ptr (CGaussian1dModel')) -> (C2HSImp.CInt -> (C2HSImp.CDouble -> ((C2HSImp.Ptr (CYieldTermStructure')) -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO C2HSImp.CDouble))))))

foreign import ccall safe "QuantLib/Model.chs.h qlGaussian1dModelZerobond"
  gaussian1dZerobond'_ :: ((C2HSImp.Ptr (CGaussian1dModel')) -> (C2HSImp.CInt -> (C2HSImp.CInt -> (C2HSImp.CDouble -> ((C2HSImp.Ptr (CYieldTermStructure')) -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO C2HSImp.CDouble)))))))

foreign import ccall safe "QuantLib/Model.chs.h qlGaussian1dModelZerobondOption"
  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)))))))))))))))

foreign import ccall safe "QuantLib/Model.chs.h qlGaussian1dModelForwardRate"
  gaussian1dForwardRate'_ :: ((C2HSImp.Ptr (CGaussian1dModel')) -> (C2HSImp.CInt -> (C2HSImp.CInt -> (C2HSImp.CDouble -> ((C2HSImp.Ptr (CIborIndex')) -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO C2HSImp.CDouble)))))))

foreign import ccall safe "QuantLib/Model.chs.h qlGaussian1dModelSwapRate"
  gaussian1dSwapRate'_ :: ((C2HSImp.Ptr (CGaussian1dModel')) -> (C2HSImp.CInt -> (C2HSImp.CInt -> (C2HSImp.CInt -> (C2HSImp.CInt -> (C2HSImp.CDouble -> ((C2HSImp.Ptr (CSwapIndex')) -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO C2HSImp.CDouble)))))))))

foreign import ccall safe "QuantLib/Model.chs.h qlGaussian1dModelSwapAnnuity"
  gaussian1dSwapAnnuity'_ :: ((C2HSImp.Ptr (CGaussian1dModel')) -> (C2HSImp.CInt -> (C2HSImp.CInt -> (C2HSImp.CInt -> (C2HSImp.CInt -> (C2HSImp.CDouble -> ((C2HSImp.Ptr (CSwapIndex')) -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO C2HSImp.CDouble)))))))))

foreign import ccall safe "QuantLib/Model.chs.h qlGaussian1dModelYGrid"
  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 ()))))))))))

foreign import ccall safe "QuantLib/Model.chs.h qlGaussian1dModelStateProcess"
  stateProcess'_ :: ((C2HSImp.Ptr (CGaussian1dModel')) -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO (C2HSImp.Ptr (CStochasticProcess1D')))))

foreign import ccall safe "QuantLib/Model.chs.h qlVarianceGammaModel"
  varianceGammaModel'_ :: ((C2HSImp.Ptr (CVarianceGammaProcess')) -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO (C2HSImp.Ptr (CCalibratedModel')))))

foreign import ccall safe "QuantLib/Model.chs.h qlVasicek"
  vasicek'_ :: (C2HSImp.CDouble -> (C2HSImp.CDouble -> (C2HSImp.CDouble -> (C2HSImp.CDouble -> (C2HSImp.CDouble -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO (C2HSImp.Ptr (COneFactorAffineModel')))))))))

foreign import ccall safe "QuantLib/Model.chs.h qlLiborForwardModel"
  liborForwardModel'_ :: ((C2HSImp.Ptr (CLiborForwardModelProcess')) -> ((C2HSImp.Ptr (CLmVolatilityModel)) -> ((C2HSImp.Ptr (CLmCorrelationModel)) -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO (C2HSImp.Ptr (CLiborForwardModel')))))))

foreign import ccall safe "QuantLib/Model.chs.h qlLiborForwardModelS0"
  liborForwardModelS0'_ :: ((C2HSImp.Ptr (CLiborForwardModel')) -> (C2HSImp.CUInt -> (C2HSImp.CUInt -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO C2HSImp.CDouble)))))

foreign import ccall safe "QuantLib/Model.chs.h qlLfmHullWhiteParameterization"
  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))))))))))

foreign import ccall safe "QuantLib/Model.chs.h qlLiborForwardModelProcessSetCovarParam"
  setCovarParam'_ :: ((C2HSImp.Ptr (CLiborForwardModelProcess')) -> ((C2HSImp.Ptr (CLfmHullWhiteParameterization)) -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO ()))))

foreign import ccall safe "QuantLib/Model.chs.h qlLfmHullWhiteCovariance"
  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 ()))))))))))

foreign import ccall safe "QuantLib/Model.chs.h qlCalibratedModelCalibrate"
  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 ()))))))))))))

foreign import ccall safe "QuantLib/Model.chs.h qlCalibratedModelValue"
  value'_ :: ((C2HSImp.Ptr (CCalibratedModel')) -> (C2HSImp.CUInt -> ((C2HSImp.Ptr C2HSImp.CDouble) -> (C2HSImp.CUInt -> ((C2HSImp.Ptr (C2HSImp.Ptr (CCalibrationHelper'))) -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO C2HSImp.CDouble)))))))

foreign import ccall safe "QuantLib/Model.chs.h qlCapHelper"
  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')))))))))))))))

foreign import ccall safe "QuantLib/Model.chs.h qlHestonModelHelper"
  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')))))))))))))

foreign import ccall safe "QuantLib/Model.chs.h qlSwaptionHelper"
  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'))))))))))))))))))))))

foreign import ccall safe "QuantLib/Model.chs.h qlSwaptionHelperFromDate"
  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')))))))))))))))))))))

foreign import ccall safe "QuantLib/Model.chs.h qlSwaptionHelperFromDates"
  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'))))))))))))))))))))

foreign import ccall safe "QuantLib/Model.chs.h qlSwaptionHelperSwaption"
  helperSwaption'_ :: ((C2HSImp.Ptr (CSwaptionHelper')) -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO (C2HSImp.Ptr (CSwaption')))))

foreign import ccall safe "QuantLib/Model.chs.h qlBlackCalibrationHelperTimes"
  times'_ :: ((C2HSImp.Ptr (CBlackCalibrationHelper')) -> ((C2HSImp.Ptr C2HSImp.CUInt) -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CDouble)) -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO ())))))

foreign import ccall safe "QuantLib/Model.chs.h qlCalibratedModelParams"
  params'_ :: ((C2HSImp.Ptr (CCalibratedModel')) -> ((C2HSImp.Ptr C2HSImp.CUInt) -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CDouble)) -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO ())))))

foreign import ccall safe "QuantLib/Model.chs.h qlCalibratedModelSetParams"
  setParams'_ :: ((C2HSImp.Ptr (CCalibratedModel')) -> (C2HSImp.CUInt -> ((C2HSImp.Ptr C2HSImp.CDouble) -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO ())))))

foreign import ccall safe "QuantLib/Model.chs.h qlBlackCalibrationHelperBlackPrice"
  blackPrice'_ :: ((C2HSImp.Ptr (CBlackCalibrationHelper')) -> (C2HSImp.CDouble -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO C2HSImp.CDouble))))

foreign import ccall safe "QuantLib/Model.chs.h qlBlackCalibrationHelperCalibrationError"
  calibrationError'_ :: ((C2HSImp.Ptr (CBlackCalibrationHelper')) -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO C2HSImp.CDouble)))

foreign import ccall safe "QuantLib/Model.chs.h qlBlackCalibrationHelperImpliedVolatility"
  impliedVolatility'_ :: ((C2HSImp.Ptr (CBlackCalibrationHelper')) -> (C2HSImp.CDouble -> (C2HSImp.CDouble -> (C2HSImp.CUInt -> (C2HSImp.CDouble -> (C2HSImp.CDouble -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO C2HSImp.CDouble))))))))

foreign import ccall safe "QuantLib/Model.chs.h qlBlackCalibrationHelperMarketValue"
  marketValue'_ :: ((C2HSImp.Ptr (CBlackCalibrationHelper')) -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO C2HSImp.CDouble)))

foreign import ccall safe "QuantLib/Model.chs.h qlBlackCalibrationHelperModelValue"
  modelValue'_ :: ((C2HSImp.Ptr (CBlackCalibrationHelper')) -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO C2HSImp.CDouble)))

foreign import ccall safe "QuantLib/Model.chs.h qlBlackCalibrationHelperVolatility"
  volatility'_ :: ((C2HSImp.Ptr (CBlackCalibrationHelper')) -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO (C2HSImp.Ptr (CQuote')))))

foreign import ccall safe "QuantLib/Model.chs.h qlBlackCalibrationHelperSetPricingEngine"
  setPricingEngine'_ :: ((C2HSImp.Ptr (CBlackCalibrationHelper')) -> ((C2HSImp.Ptr (CPricingEngine')) -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO ()))))

foreign import ccall safe "QuantLib/Model.chs.h qlGarch11"
  garch11'_ :: (C2HSImp.CDouble -> (C2HSImp.CDouble -> (C2HSImp.CDouble -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO (C2HSImp.Ptr (CGarch11)))))))

foreign import ccall safe "QuantLib/Model.chs.h qlGarch11Calibrated"
  qlGarch11Calibrated'_ :: (C2HSImp.CUInt -> ((C2HSImp.Ptr C2HSImp.CInt) -> (C2HSImp.CUInt -> ((C2HSImp.Ptr C2HSImp.CDouble) -> (C2HSImp.CInt -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO (C2HSImp.Ptr (CGarch11)))))))))

foreign import ccall safe "QuantLib/Model.chs.h qlGarch11Alpha"
  alpha'_ :: ((C2HSImp.Ptr (CGarch11)) -> (IO C2HSImp.CDouble))

foreign import ccall safe "QuantLib/Model.chs.h qlGarch11Beta"
  beta'_ :: ((C2HSImp.Ptr (CGarch11)) -> (IO C2HSImp.CDouble))

foreign import ccall safe "QuantLib/Model.chs.h qlGarch11Omega"
  omega'_ :: ((C2HSImp.Ptr (CGarch11)) -> (IO C2HSImp.CDouble))

foreign import ccall safe "QuantLib/Model.chs.h qlGarch11LtVol"
  longTermVolatility'_ :: ((C2HSImp.Ptr (CGarch11)) -> (IO C2HSImp.CDouble))

foreign import ccall safe "QuantLib/Model.chs.h qlGarch11LogLikelihood"
  logLikelihood'_ :: ((C2HSImp.Ptr (CGarch11)) -> (IO C2HSImp.CDouble))

foreign import ccall safe "QuantLib/Model.chs.h qlGarch11Forecast"
  forecast'_ :: ((C2HSImp.Ptr (CGarch11)) -> (C2HSImp.CDouble -> (C2HSImp.CDouble -> (IO C2HSImp.CDouble))))

foreign import ccall safe "QuantLib/Model.chs.h qlGarch11Calculate"
  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 ())))))))))))

foreign import ccall safe "QuantLib/Model.chs.h qlGarmanKlassSimpleSigma"
  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 ())))))))))))))))))

foreign import ccall safe "QuantLib/Model.chs.h qlGarmanKlassSigma1"
  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 ()))))))))))))))))))

foreign import ccall safe "QuantLib/Model.chs.h qlParkinsonSigma"
  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 ())))))))))))))))))

foreign import ccall safe "QuantLib/Model.chs.h qlGarmanKlassSigma3"
  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 ()))))))))))))))))))

foreign import ccall safe "QuantLib/Model.chs.h qlGarmanKlassSigma4"
  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 ())))))))))))))))))

foreign import ccall safe "QuantLib/Model.chs.h qlGarmanKlassSigma5"
  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 ())))))))))))))))))

foreign import ccall safe "QuantLib/Model.chs.h qlGarmanKlassSigma6"
  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 ()))))))))))))))))))

foreign import ccall safe "QuantLib/Model.chs.h qlConstantVolatilityEstimator"
  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 ())))))))))))

foreign import ccall safe "QuantLib/Model.chs.h qlSimpleLocalVolatilityEstimator"
  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 ())))))))))))

foreign import ccall safe "QuantLib/Model.chs.h qlGaussian1dModelCompoundedRate"
  gaussian1dCompoundedRate'_ :: ((C2HSImp.Ptr (CGaussian1dModel')) -> ((C2HSImp.Ptr (COvernightIndexedCoupon')) -> (C2HSImp.CInt -> (C2HSImp.CDouble -> ((C2HSImp.Ptr (CYieldTermStructure')) -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO C2HSImp.CDouble)))))))

foreign import ccall safe "QuantLib/Model.chs.h qlRoughHestonModel"
  roughHestonModel'_ :: ((C2HSImp.Ptr (CHestonProcess')) -> (C2HSImp.CDouble -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO (C2HSImp.Ptr (CRoughHestonModel'))))))

foreign import ccall safe "QuantLib/Model.chs.h qlRoughHestonModelTheta"
  roughHestonTheta'_ :: ((C2HSImp.Ptr (CRoughHestonModel')) -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO C2HSImp.CDouble)))

foreign import ccall safe "QuantLib/Model.chs.h qlRoughHestonModelKappa"
  roughHestonKappa'_ :: ((C2HSImp.Ptr (CRoughHestonModel')) -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO C2HSImp.CDouble)))

foreign import ccall safe "QuantLib/Model.chs.h qlRoughHestonModelSigma"
  roughHestonSigma'_ :: ((C2HSImp.Ptr (CRoughHestonModel')) -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO C2HSImp.CDouble)))

foreign import ccall safe "QuantLib/Model.chs.h qlRoughHestonModelRho"
  roughHestonRho'_ :: ((C2HSImp.Ptr (CRoughHestonModel')) -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO C2HSImp.CDouble)))

foreign import ccall safe "QuantLib/Model.chs.h qlRoughHestonModelV0"
  roughHestonV0'_ :: ((C2HSImp.Ptr (CRoughHestonModel')) -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO C2HSImp.CDouble)))

foreign import ccall safe "QuantLib/Model.chs.h qlRoughHestonModelHurst"
  roughHestonHurst'_ :: ((C2HSImp.Ptr (CRoughHestonModel')) -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO C2HSImp.CDouble)))

foreign import ccall safe "QuantLib/Model.chs.h qlRoughHestonModelProcess"
  roughHestonProcess'_ :: ((C2HSImp.Ptr (CRoughHestonModel')) -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO (C2HSImp.Ptr (CHestonProcess')))))