never executed always true always false
    1 -- GENERATED by C->Haskell Compiler, version 0.28.8 Switcheroo, 25 November 2017 (Haskell)
    2 -- Edit the ORIGNAL .chs file instead!
    3 
    4 
    5 {-# LANGUAGE FlexibleInstances #-}
    6 module QuantLib.Process
    7   (
    8     -- * Types
    9     -- ** Process hierarchy
   10     GenStochasticProcess
   11   , StochasticProcess
   12   , GenStochasticProcess1D
   13   , StochasticProcess1D
   14   , GenGeneralizedBlackScholesProcess
   15   , GeneralizedBlackScholesProcess
   16   , BlackProcess
   17   , ExtOUWithJumpsProcess
   18   , ExtendedOrnsteinUhlenbeckProcess
   19   , GJRGARCHProcess
   20   , GenHestonProcess
   21   , HestonProcess
   22   , HestonSLVProcess
   23   , BatesProcess
   24   , G2Process
   25   , G2ForwardProcess
   26   , HybridHestonHullWhiteProcess
   27   , KlugeExtOUProcess
   28   , LiborForwardModelProcess
   29   , StochasticProcessArray
   30   , VarianceGammaProcess
   31   , Merton76Process
   32   , HullWhiteProcess
   33   , HullWhiteForwardProcess
   34 
   35     -- ** Discretization schemes
   36   , ProcessDiscretization(..)
   37   , ExtendedBlackScholesMertonProcessDiscretization(..)
   38   , ExtendedOrnsteinUhlenbeckProcessDiscretization(..)
   39   , HestonProcessDiscretization(..)
   40   , GJRGARCHProcessDiscretization(..)
   41   , HybridHestonHullWhiteProcessDiscretization(..)
   42 
   43     -- * Constructors
   44     -- ** Hierarchy conversion
   45   , asStochasticProcess
   46   , asStochasticProcess1D
   47   , asGeneralizedBlackScholesProcess
   48   , asHestonProcess
   49 
   50     -- ** Black-Scholes processes
   51   , blackProcess
   52   , blackScholesMertonProcess
   53   , blackScholesProcess
   54   , extendedBlackScholesMertonProcess
   55   , garmanKohlhagenProcess
   56   , generalizedBlackScholesProcess
   57   , squareRootProcess
   58   , vegaStressedBlackScholesProcess
   59 
   60     -- ** Other processes
   61   , batesProcess
   62   , extOuWithJumpsProcess
   63   , g2ForwardProcess
   64   , g2Process
   65   , gemanRoncoroniProcess
   66   , geometricBrownianMotionProcess
   67   , gjrGarchProcess
   68   , hestonProcess
   69   , hestonSlvProcess
   70   , hullWhiteForwardProcess
   71   , hullWhiteProcess
   72   , hybridHestonHullWhiteProcess
   73   , klugeExtOuProcess
   74   , withExtendedOrnsteinUhlenbeckProcess
   75   , linearSeasonalOrnsteinUhlenbeckProcess
   76   , liborForwardModelProcess
   77   , merton76Process
   78   , ornsteinUhlenbeckProcess
   79   , varianceGammaProcess
   80   , stochasticProcessArray
   81 
   82     -- * Mutators
   83   , HasForwardMeasureTime(..)
   84 
   85     -- * Inspectors
   86     -- ** Process dynamics
   87   , apply
   88   , covariance
   89   , diffusion
   90   , drift
   91   , evolve
   92   , expectation
   93   , stdDeviation
   94   , pdf
   95   , discountBond
   96     -- ** Process state
   97   , factors
   98   , initialValues
   99   , fixingDates
  100   , fixingTimes
  101   , cashFlows
  102   , index
  103   , accrualTimes
  104     -- ** Short-rate and forward-measure quantities
  105   , HasPhi(..)
  106   , HasShortRate(..)
  107   , HasAlpha(..)
  108   , bFunction
  109   , mFunction
  110   , numeraire
  111 
  112   , thetaAt
  113   ) where
  114 import qualified Foreign.C.Types as C2HSImp
  115 import qualified Foreign.ForeignPtr as C2HSImp
  116 import qualified Foreign.Marshal.Utils as C2HSImp
  117 import qualified Foreign.Ptr as C2HSImp
  118 import qualified System.IO.Unsafe as C2HSImp
  119 
  120 
  121 
  122 
  123 
  124 
  125 
  126 import QuantLib.Internal
  127 import QuantLib.Internal.Type
  128 import Data.List.NonEmpty(NonEmpty, toList)
  129 
  130 data ProcessDiscretization = EulerDiscretization
  131                            | EndEulerDiscretization
  132   deriving (Show,Eq,Read)
  133 instance Enum ProcessDiscretization where
  134   succ EulerDiscretization = EndEulerDiscretization
  135   succ EndEulerDiscretization = error "ProcessDiscretization.succ: EndEulerDiscretization has no successor"
  136 
  137   pred EndEulerDiscretization = EulerDiscretization
  138   pred EulerDiscretization = error "ProcessDiscretization.pred: EulerDiscretization has no predecessor"
  139 
  140   enumFromTo from to = go from
  141     where
  142       end = fromEnum to
  143       go v = case compare (fromEnum v) end of
  144                  LT -> v : go (succ v)
  145                  EQ -> [v]
  146                  GT -> []
  147 
  148   enumFrom from = enumFromTo from EndEulerDiscretization
  149 
  150   fromEnum EulerDiscretization = 0
  151   fromEnum EndEulerDiscretization = 1
  152 
  153   toEnum 0 = EulerDiscretization
  154   toEnum 1 = EndEulerDiscretization
  155   toEnum unmatched = error ("ProcessDiscretization.toEnum: Cannot match " ++ show unmatched)
  156 
  157 
  158 data ExtendedBlackScholesMertonProcessDiscretization = ExtendedBSMEuler
  159                                                      | Milstein
  160                                                      | PredictorCorrector
  161   deriving (Enum,Show,Eq,Read)
  162 
  163 
  164 data ExtendedOrnsteinUhlenbeckProcessDiscretization = MidPoint
  165                                                     | Trapezodial
  166                                                     | GaussLobatto
  167   deriving (Enum,Show,Eq,Read)
  168 
  169 
  170 data HestonProcessDiscretization = HestonPartialTruncation
  171                                  | HestonFullTruncation
  172                                  | HestonReflection
  173                                  | NonCentralChiSquareVariance
  174                                  | QuadraticExponential
  175                                  | QuadraticExponentialMartingale
  176                                  | BroadieKayaExactSchemeLobatto
  177                                  | BroadieKayaExactSchemeLaguerre
  178                                  | BroadieKayaExactSchemeTrapezoidal
  179   deriving (Enum,Show,Eq,Read)
  180 
  181 
  182 data GJRGARCHProcessDiscretization = GJRGARCHPartialTruncation
  183                                    | GJRGARCHFullTruncation
  184                                    | GJRGARCHReflection
  185   deriving (Enum,Show,Eq,Read)
  186 
  187 
  188 data HybridHestonHullWhiteProcessDiscretization = HybridHestonHullWhiteEuler
  189                                                 | BSMHullWhite
  190   deriving (Enum,Show,Eq,Read)
  191 
  192 
  193 
  194 
  195 
  196 
  197 
  198 
  199 
  200 
  201 
  202 
  203 
  204 
  205 
  206 
  207 
  208 
  209 
  210 
  211 
  212 
  213 
  214 
  215 
  216 
  217 
  218 
  219 
  220 
  221 
  222 
  223 
  224 
  225 
  226 
  227 
  228 
  229 
  230 
  231 
  232 
  233 
  234 
  235 
  236 
  237 
  238 
  239 
  240 
  241 
  242 
  243 
  244 
  245 
  246 
  247 -- |Black (1976) process for a forward or futures contract: d(ln S) = -sigma^2\/2 dt + sigma dW.
  248 blackProcess :: (GenQuote q) -- ^x0
  249  -> (GenYieldTermStructure y) -- ^riskFreeTS
  250  -> (GenBlackVolTermStructure bv) -- ^blackVolTS
  251  -> (ProcessDiscretization) -> (Bool) -- ^forceDiscretization
  252  -> IO ((BlackProcess))
  253 blackProcess a1 a2 a3 a4 a5 =
  254   withQuote a1 $ \a1' -> 
  255   withYieldTermStructure a2 $ \a2' -> 
  256   withBlackVolTermStructure a3 $ \a3' -> 
  257   let {a4' = (fromIntegral . fromEnum) a4} in 
  258   let {a5' = C2HSImp.fromBool a5} in 
  259   preErrorCheck $ \a6' -> 
  260   blackProcess'_ a1' a2' a3' a4' a5' a6' >>= \res ->
  261   peekBlackProcess res >>= \res' ->
  262   errorCheck  a6'>>
  263   return (res')
  264 
  265 
  266 
  267 -- |Merton (1973) extension of Black-Scholes for a continuous-dividend-paying stock:
  268 -- d(ln S) = (r - q - sigma^2\/2) dt + sigma dW.
  269 blackScholesMertonProcess :: (GenQuote q) -- ^x0
  270  -> (GenYieldTermStructure y1) -- ^dividendTS
  271  -> (GenYieldTermStructure y2) -- ^riskFreeTS
  272  -> (GenBlackVolTermStructure bv) -- ^blackVolTS
  273  -> (ProcessDiscretization) -> (Bool) -- ^forceDiscretization
  274  -> IO ((GeneralizedBlackScholesProcess))
  275 blackScholesMertonProcess a1 a2 a3 a4 a5 a6 =
  276   withQuote a1 $ \a1' -> 
  277   withYieldTermStructure a2 $ \a2' -> 
  278   withYieldTermStructure a3 $ \a3' -> 
  279   withBlackVolTermStructure a4 $ \a4' -> 
  280   let {a5' = (fromIntegral . fromEnum) a5} in 
  281   let {a6' = C2HSImp.fromBool a6} in 
  282   preErrorCheck $ \a7' -> 
  283   blackScholesMertonProcess'_ a1' a2' a3' a4' a5' a6' a7' >>= \res ->
  284   peekGeneralizedBlackScholesProcess res >>= \res' ->
  285   errorCheck  a7'>>
  286   return (res')
  287 
  288 
  289 
  290 -- |Black-Scholes (1973) process for a stock: d(ln S) = (r - sigma^2\/2) dt + sigma dW.
  291 blackScholesProcess :: (GenQuote q) -- ^x0
  292  -> (GenYieldTermStructure y) -- ^riskFreeTS
  293  -> (GenBlackVolTermStructure bv) -- ^blackVolTS
  294  -> (ProcessDiscretization) -> (Bool) -- ^forceDiscretization
  295  -> IO ((GeneralizedBlackScholesProcess))
  296 blackScholesProcess a1 a2 a3 a4 a5 =
  297   withQuote a1 $ \a1' -> 
  298   withYieldTermStructure a2 $ \a2' -> 
  299   withBlackVolTermStructure a3 $ \a3' -> 
  300   let {a4' = (fromIntegral . fromEnum) a4} in 
  301   let {a5' = C2HSImp.fromBool a5} in 
  302   preErrorCheck $ \a6' -> 
  303   blackScholesProcess'_ a1' a2' a3' a4' a5' a6' >>= \res ->
  304   peekGeneralizedBlackScholesProcess res >>= \res' ->
  305   errorCheck  a6'>>
  306   return (res')
  307 
  308 
  309 
  310 -- |'blackScholesMertonProcess' with a choice of evolution scheme (Euler\/Milstein\/predictor-corrector)
  311 -- on top of the discretization argument.
  312 extendedBlackScholesMertonProcess :: (GenQuote q) -- ^x0
  313  -> (GenYieldTermStructure y1) -- ^dividendTS
  314  -> (GenYieldTermStructure y2) -- ^riskFreeTS
  315  -> (GenBlackVolTermStructure bv) -- ^blackVolTS
  316  -> (ProcessDiscretization) -> (ExtendedBlackScholesMertonProcessDiscretization) -> IO ((GeneralizedBlackScholesProcess))
  317 extendedBlackScholesMertonProcess a1 a2 a3 a4 a5 a6 =
  318   withQuote a1 $ \a1' -> 
  319   withYieldTermStructure a2 $ \a2' -> 
  320   withYieldTermStructure a3 $ \a3' -> 
  321   withBlackVolTermStructure a4 $ \a4' -> 
  322   let {a5' = (fromIntegral . fromEnum) a5} in 
  323   let {a6' = (fromIntegral . fromEnum) a6} in 
  324   preErrorCheck $ \a7' -> 
  325   extendedBlackScholesMertonProcess'_ a1' a2' a3' a4' a5' a6' a7' >>= \res ->
  326   peekGeneralizedBlackScholesProcess res >>= \res' ->
  327   errorCheck  a7'>>
  328   return (res')
  329 
  330 
  331 
  332 -- |Garman-Kohlhagen (1983) process for an exchange rate: d(ln S) = (r - r_f - sigma^2\/2) dt + sigma dW.
  333 garmanKohlhagenProcess :: (GenQuote q) -- ^x0
  334  -> (GenYieldTermStructure y1) -- ^foreignRiskFreeTS
  335  -> (GenYieldTermStructure y2) -- ^domesticRiskFreeTS
  336  -> (GenBlackVolTermStructure bv) -- ^blackVolTS
  337  -> (ProcessDiscretization) -> (Bool) -- ^forceDiscretization
  338  -> IO ((GeneralizedBlackScholesProcess))
  339 garmanKohlhagenProcess a1 a2 a3 a4 a5 a6 =
  340   withQuote a1 $ \a1' -> 
  341   withYieldTermStructure a2 $ \a2' -> 
  342   withYieldTermStructure a3 $ \a3' -> 
  343   withBlackVolTermStructure a4 $ \a4' -> 
  344   let {a5' = (fromIntegral . fromEnum) a5} in 
  345   let {a6' = C2HSImp.fromBool a6} in 
  346   preErrorCheck $ \a7' -> 
  347   garmanKohlhagenProcess'_ a1' a2' a3' a4' a5' a6' a7' >>= \res ->
  348   peekGeneralizedBlackScholesProcess res >>= \res' ->
  349   errorCheck  a7'>>
  350   return (res')
  351 
  352 
  353 
  354 -- |Generalized Black-Scholes process with separate dividend and risk-free curves:
  355 -- d(ln S) = (r - q - sigma^2\/2) dt + sigma dW.
  356 generalizedBlackScholesProcess :: (GenQuote q) -- ^x0
  357  -> (GenYieldTermStructure y1) -- ^dividendTS
  358  -> (GenYieldTermStructure y2) -- ^riskFreeTS
  359  -> (GenBlackVolTermStructure bv) -- ^blackVolTS
  360  -> (ProcessDiscretization) -> (Bool) -- ^forceDiscretization
  361  -> IO ((GeneralizedBlackScholesProcess))
  362 generalizedBlackScholesProcess a1 a2 a3 a4 a5 a6 =
  363   withQuote a1 $ \a1' -> 
  364   withYieldTermStructure a2 $ \a2' -> 
  365   withYieldTermStructure a3 $ \a3' -> 
  366   withBlackVolTermStructure a4 $ \a4' -> 
  367   let {a5' = (fromIntegral . fromEnum) a5} in 
  368   let {a6' = C2HSImp.fromBool a6} in 
  369   preErrorCheck $ \a7' -> 
  370   generalizedBlackScholesProcess'_ a1' a2' a3' a4' a5' a6' a7' >>= \res ->
  371   peekGeneralizedBlackScholesProcess res >>= \res' ->
  372   errorCheck  a7'>>
  373   return (res')
  374 
  375 
  376 
  377 -- |square-root process: dx = a (b - x) dt + sigma sqrt(x) dW.
  378 squareRootProcess :: (Double) -- ^b
  379  -> (Double) -- ^a
  380  -> (Double) -- ^sigma
  381  -> (Double) -- ^x0
  382  -> (ProcessDiscretization) -> IO ((StochasticProcess1D))
  383 squareRootProcess a1 a2 a3 a4 a5 =
  384   let {a1' = realToFrac a1} in 
  385   let {a2' = realToFrac a2} in 
  386   let {a3' = realToFrac a3} in 
  387   let {a4' = realToFrac a4} in 
  388   let {a5' = (fromIntegral . fromEnum) a5} in 
  389   preErrorCheck $ \a6' -> 
  390   squareRootProcess'_ a1' a2' a3' a4' a5' a6' >>= \res ->
  391   peekStochasticProcess1D res >>= \res' ->
  392   errorCheck  a6'>>
  393   return (res')
  394 
  395 
  396 
  397 -- |'blackScholesMertonProcess' variant supporting local vega stress tests over a given
  398 -- time\/asset border and stress level.
  399 vegaStressedBlackScholesProcess :: (GenQuote q) -- ^x0
  400  -> (GenYieldTermStructure y1) -- ^dividendTS
  401  -> (GenYieldTermStructure y2) -- ^riskFreeTS
  402  -> (GenBlackVolTermStructure bv) -- ^blackVolTS
  403  -> (Double) -- ^lowerTimeBorderForStressTest
  404  -> (Double) -- ^upperTimeBorderForStressTest
  405  -> (Double) -- ^lowerAssetBorderForStressTest
  406  -> (Double) -- ^upperAssetBorderForStressTest
  407  -> (Double) -- ^stressLevel
  408  -> (ProcessDiscretization) -> IO ((GeneralizedBlackScholesProcess))
  409 vegaStressedBlackScholesProcess a1 a2 a3 a4 a5 a6 a7 a8 a9 a10 =
  410   withQuote a1 $ \a1' -> 
  411   withYieldTermStructure a2 $ \a2' -> 
  412   withYieldTermStructure a3 $ \a3' -> 
  413   withBlackVolTermStructure a4 $ \a4' -> 
  414   let {a5' = realToFrac a5} in 
  415   let {a6' = realToFrac a6} in 
  416   let {a7' = realToFrac a7} in 
  417   let {a8' = realToFrac a8} in 
  418   let {a9' = realToFrac a9} in 
  419   let {a10' = (fromIntegral . fromEnum) a10} in 
  420   preErrorCheck $ \a11' -> 
  421   vegaStressedBlackScholesProcess'_ a1' a2' a3' a4' a5' a6' a7' a8' a9' a10' a11' >>= \res ->
  422   peekGeneralizedBlackScholesProcess res >>= \res' ->
  423   errorCheck  a11'>>
  424   return (res')
  425 
  426 
  427 
  428 -- |square-root stochastic-volatility Bates process: a Heston process plus a compound Poisson
  429 -- jump component with log-normally distributed jump size.
  430 batesProcess :: (GenYieldTermStructure y1) -- ^riskFreeTS
  431  -> (GenYieldTermStructure y2) -- ^dividendYield
  432  -> (GenQuote q) -- ^s0
  433  -> (Double) -- ^v0
  434  -> (Double) -- ^kappa
  435  -> (Double) -- ^theta
  436  -> (Double) -- ^sigma
  437  -> (Double) -- ^rho
  438  -> (Double) -- ^lambda
  439  -> (Double) -- ^nu
  440  -> (Double) -- ^delta
  441  -> (HestonProcessDiscretization) -> IO ((BatesProcess))
  442 batesProcess a1 a2 a3 a4 a5 a6 a7 a8 a9 a10 a11 a12 =
  443   withYieldTermStructure a1 $ \a1' -> 
  444   withYieldTermStructure a2 $ \a2' -> 
  445   withQuote a3 $ \a3' -> 
  446   let {a4' = realToFrac a4} in 
  447   let {a5' = realToFrac a5} in 
  448   let {a6' = realToFrac a6} in 
  449   let {a7' = realToFrac a7} in 
  450   let {a8' = realToFrac a8} in 
  451   let {a9' = realToFrac a9} in 
  452   let {a10' = realToFrac a10} in 
  453   let {a11' = realToFrac a11} in 
  454   let {a12' = (fromIntegral . fromEnum) a12} in 
  455   preErrorCheck $ \a13' -> 
  456   batesProcess'_ a1' a2' a3' a4' a5' a6' a7' a8' a9' a10' a11' a12' a13' >>= \res ->
  457   peekBatesProcess res >>= \res' ->
  458   errorCheck  a13'>>
  459   return (res')
  460 
  461 
  462 
  463 qlExtendedOrnsteinUhlenbeckProcess :: (Double) -- ^speed
  464  -> (Double) -- ^sigma (volatility)
  465  -> (Double) -- ^x0
  466  -> (Callback) -> (ExtendedOrnsteinUhlenbeckProcessDiscretization) -> (Double) -- ^intEps
  467  -> IO ((ExtendedOrnsteinUhlenbeckProcess))
  468 qlExtendedOrnsteinUhlenbeckProcess a1 a2 a3 a4 a5 a6 =
  469   let {a1' = realToFrac a1} in 
  470   let {a2' = realToFrac a2} in 
  471   let {a3' = realToFrac a3} in 
  472   withCallbackPtr a4 $ \a4' -> 
  473   let {a5' = (fromIntegral . fromEnum) a5} in 
  474   let {a6' = realToFrac a6} in 
  475   preErrorCheck $ \a7' -> 
  476   qlExtendedOrnsteinUhlenbeckProcess'_ a1' a2' a3' a4' a5' a6' a7' >>= \res ->
  477   peekExtendedOrnsteinUhlenbeckProcess res >>= \res' ->
  478   errorCheck  a7'>>
  479   return (res')
  480 
  481 
  482 
  483 -- |An extended Ornstein-Uhlenbeck process @dx = speed*(b(t) - x)dt + sigma*dW@ with an arbitrary
  484 -- deterministic mean-reversion level @b@, usable with 'QuantLib.Method.pathGenerator'. The
  485 -- process and its native dependents retain @b@ after the continuation returns.
  486 -- Callback exceptions are rethrown by the enclosing Haskell call.
  487 withExtendedOrnsteinUhlenbeckProcess :: Double -- ^speed
  488   -> Double -- ^sigma
  489   -> Double -- ^x0
  490   -> (Double -> Double) -- ^b(t)
  491   -> ExtendedOrnsteinUhlenbeckProcessDiscretization
  492   -> Double -- ^intEps
  493   -> (ExtendedOrnsteinUhlenbeckProcess -> IO a) -> IO a
  494 withExtendedOrnsteinUhlenbeckProcess speed sigma x0 b d intEps k =
  495   withPayoffFun b (\fp -> qlExtendedOrnsteinUhlenbeckProcess speed sigma x0 fp d intEps >>= k)
  496 
  497 -- |An extended Ornstein-Uhlenbeck process with the Lucia-Schwartz-style level
  498 -- @b(t) = a + k*t + c*sin(2*pi*t + phase)@, computed natively. Setting @k = c = 0@ gives a
  499 -- constant level and @c = 0@ gives a linear trend.
  500 linearSeasonalOrnsteinUhlenbeckProcess :: (Double) -- ^speed
  501  -> (Double) -- ^sigma (volatility)
  502  -> (Double) -- ^x0
  503  -> (Double) -- ^a
  504  -> (Double) -- ^k (linear trend)
  505  -> (Double) -- ^c (seasonal amplitude)
  506  -> (Double) -- ^phase
  507  -> (ExtendedOrnsteinUhlenbeckProcessDiscretization) -> (Double) -- ^intEps
  508  -> IO ((ExtendedOrnsteinUhlenbeckProcess))
  509 linearSeasonalOrnsteinUhlenbeckProcess a1 a2 a3 a4 a5 a6 a7 a8 a9 =
  510   let {a1' = realToFrac a1} in 
  511   let {a2' = realToFrac a2} in 
  512   let {a3' = realToFrac a3} in 
  513   let {a4' = realToFrac a4} in 
  514   let {a5' = realToFrac a5} in 
  515   let {a6' = realToFrac a6} in 
  516   let {a7' = realToFrac a7} in 
  517   let {a8' = (fromIntegral . fromEnum) a8} in 
  518   let {a9' = realToFrac a9} in 
  519   preErrorCheck $ \a10' -> 
  520   linearSeasonalOrnsteinUhlenbeckProcess'_ a1' a2' a3' a4' a5' a6' a7' a8' a9' a10' >>= \res ->
  521   peekExtendedOrnsteinUhlenbeckProcess res >>= \res' ->
  522   errorCheck  a10'>>
  523   return (res')
  524 
  525 
  526 
  527 -- |Kluge model: an extended Ornstein-Uhlenbeck process plus an exponential-jump component,
  528 -- S = exp(X + Y) with dX = alpha (mu(t) - X) dt + sigma dW and dY = -beta Y dt + J dN. When the
  529 -- extended process is callback-backed, this result retains its callback.
  530 extOuWithJumpsProcess :: (ExtendedOrnsteinUhlenbeckProcess) -> (Double) -- ^Y0
  531  -> (Double) -- ^beta
  532  -> (Double) -- ^jumpIntensity
  533  -> (Double) -- ^eta
  534  -> IO ((ExtOUWithJumpsProcess))
  535 extOuWithJumpsProcess a1 a2 a3 a4 a5 =
  536   withGenStochasticProcess1D a1 $ \a1' -> 
  537   let {a2' = realToFrac a2} in 
  538   let {a3' = realToFrac a3} in 
  539   let {a4' = realToFrac a4} in 
  540   let {a5' = realToFrac a5} in 
  541   preErrorCheck $ \a6' -> 
  542   extOuWithJumpsProcess'_ a1' a2' a3' a4' a5' a6' >>= \res ->
  543   peekExtOUWithJumpsProcess res >>= \res' ->
  544   errorCheck  a6'>>
  545   return (res')
  546 
  547 
  548 
  549 -- |T-forward-measure counterpart of 'g2Process': the two-factor G2++ short-rate model, with
  550 -- the simulated state again shifted so its components sum to the short rate.
  551 g2ForwardProcess :: (Double) -- ^a
  552  -> (Double) -- ^sigma
  553  -> (Double) -- ^b
  554  -> (Double) -- ^eta
  555  -> (Double) -- ^rho
  556  -> (Maybe (GenYieldTermStructure y)) -- ^termStructure
  557  -> IO ((G2ForwardProcess))
  558 g2ForwardProcess a1 a2 a3 a4 a5 a6 =
  559   let {a1' = realToFrac a1} in 
  560   let {a2' = realToFrac a2} in 
  561   let {a3' = realToFrac a3} in 
  562   let {a4' = realToFrac a4} in 
  563   let {a5' = realToFrac a5} in 
  564   withMaybeYieldTermStructure a6 $ \a6' -> 
  565   preErrorCheck $ \a7' -> 
  566   g2ForwardProcess'_ a1' a2' a3' a4' a5' a6' a7' >>= \res ->
  567   peekG2ForwardProcess res >>= \res' ->
  568   errorCheck  a7'>>
  569   return (res')
  570 
  571 
  572 
  573 -- |two-factor G2++ short-rate process, state shifted so its two OU components sum to the
  574 -- short rate; degenerates to a pair of zero-mean OU processes if no term structure is given.
  575 g2Process :: (Double) -- ^a
  576  -> (Double) -- ^sigma
  577  -> (Double) -- ^b
  578  -> (Double) -- ^eta
  579  -> (Double) -- ^rho
  580  -> (Maybe (GenYieldTermStructure y)) -- ^termStructure
  581  -> IO ((G2Process))
  582 g2Process a1 a2 a3 a4 a5 a6 =
  583   let {a1' = realToFrac a1} in 
  584   let {a2' = realToFrac a2} in 
  585   let {a3' = realToFrac a3} in 
  586   let {a4' = realToFrac a4} in 
  587   let {a5' = realToFrac a5} in 
  588   withMaybeYieldTermStructure a6 $ \a6' -> 
  589   preErrorCheck $ \a7' -> 
  590   g2Process'_ a1' a2' a3' a4' a5' a6' a7' >>= \res ->
  591   peekG2Process res >>= \res' ->
  592   errorCheck  a7'>>
  593   return (res')
  594 
  595 
  596 
  597 -- |the deterministic offset phi(t) that fits 'g2Process''s initial term structure -- throws if
  598 -- the process was constructed with no term structure.
  599 qlG2ProcessPhi :: (G2Process) -> (Double) -- ^t
  600  -> IO ((Double))
  601 qlG2ProcessPhi a1 a2 =
  602   withGenStochasticProcess a1 $ \a1' -> 
  603   let {a2' = realToFrac a2} in 
  604   preErrorCheck $ \a3' -> 
  605   qlG2ProcessPhi'_ a1' a2' a3' >>= \res ->
  606   let {res' = realToFrac res} in
  607   errorCheck  a3'>>
  608   return (res')
  609 
  610 
  611 
  612 -- |the short rate implied by a simulated 'g2Process' state @(z1, z2)@ at time /t/: just
  613 -- @z1 + z2@, since 'phi''s offset is already baked into the first simulated component.
  614 qlG2ProcessShortRate :: (G2Process) -> (Double) -- ^t
  615  -> (Double) -- ^z1
  616  -> (Double) -- ^z2
  617  -> (Double)
  618 qlG2ProcessShortRate a1 a2 a3 a4 =
  619   C2HSImp.unsafePerformIO $
  620   withGenStochasticProcess a1 $ \a1' -> 
  621   let {a2' = realToFrac a2} in 
  622   let {a3' = realToFrac a3} in 
  623   let {a4' = realToFrac a4} in 
  624   qlG2ProcessShortRate'_ a1' a2' a3' a4' >>= \res ->
  625   let {res' = realToFrac res} in
  626   return (res')
  627 
  628 
  629 
  630 -- |the deterministic offset phi(t) that fits 'g2ForwardProcess''s initial term structure --
  631 -- throws if the process was constructed with no term structure.
  632 qlG2ForwardProcessPhi :: (G2ForwardProcess) -> (Double) -- ^t
  633  -> IO ((Double))
  634 qlG2ForwardProcessPhi a1 a2 =
  635   withGenStochasticProcess a1 $ \a1' -> 
  636   let {a2' = realToFrac a2} in 
  637   preErrorCheck $ \a3' -> 
  638   qlG2ForwardProcessPhi'_ a1' a2' a3' >>= \res ->
  639   let {res' = realToFrac res} in
  640   errorCheck  a3'>>
  641   return (res')
  642 
  643 
  644 
  645 -- |the short rate implied by a simulated 'g2ForwardProcess' state @(z1, z2)@ at time /t/: just
  646 -- @z1 + z2@, since 'phi''s offset is already baked into the first simulated component.
  647 qlG2ForwardProcessShortRate :: (G2ForwardProcess) -> (Double) -- ^t
  648  -> (Double) -- ^z1
  649  -> (Double) -- ^z2
  650  -> (Double)
  651 qlG2ForwardProcessShortRate a1 a2 a3 a4 =
  652   C2HSImp.unsafePerformIO $
  653   withGenStochasticProcess a1 $ \a1' -> 
  654   let {a2' = realToFrac a2} in 
  655   let {a3' = realToFrac a3} in 
  656   let {a4' = realToFrac a4} in 
  657   qlG2ForwardProcessShortRate'_ a1' a2' a3' a4' >>= \res ->
  658   let {res' = realToFrac res} in
  659   return (res')
  660 
  661 
  662 
  663 -- |Two-factor short-rate processes with the same deterministic curve-fitting offset.
  664 class HasPhi a where
  665   phi :: a -> Double -> IO Double
  666 instance HasPhi G2Process where
  667   phi = qlG2ProcessPhi
  668 instance HasPhi G2ForwardProcess where
  669   phi = qlG2ForwardProcessPhi
  670 
  671 -- |Two-factor processes whose simulated state maps to the short rate in the same way.
  672 class HasShortRate a where
  673   shortRate :: a -> Double -> Double -> Double -> Double
  674 instance HasShortRate G2Process where
  675   shortRate = qlG2ProcessShortRate
  676 instance HasShortRate G2ForwardProcess where
  677   shortRate = qlG2ForwardProcessShortRate
  678 
  679 -- |Forward-measure processes that require a maturity time before simulation.
  680 class HasForwardMeasureTime a where
  681   setForwardMeasureTime :: a -> Double -> IO ()
  682 instance HasForwardMeasureTime HullWhiteForwardProcess where
  683   setForwardMeasureTime = qlHullWhiteForwardProcessSetForwardMeasureTime
  684 instance HasForwardMeasureTime G2ForwardProcess where
  685   setForwardMeasureTime = qlG2ForwardProcessSetForwardMeasureTime
  686 
  687 -- |Hull--White processes exposing the deterministic curve-fitting offset.
  688 class HasAlpha a where
  689   alpha :: a -> Double -> IO Double
  690 instance HasAlpha HullWhiteProcess where
  691   alpha = qlHullWhiteProcessAlpha
  692 instance HasAlpha HullWhiteForwardProcess where
  693   alpha = qlHullWhiteForwardProcessAlpha
  694 
  695 -- |the number of independent Brownian factors driving a stochastic process -- e.g. 2 for
  696 -- 'g2Process', matching its state size; used to size a 'QuantLib.Method.pathGenerator''s
  697 -- underlying sequence generator (@process->factors() * steps@, mirroring upstream's own usage).
  698 factors :: (GenStochasticProcess p) -> IO ((Word))
  699 factors a1 =
  700   withStochasticProcess a1 $ \a1' -> 
  701   preErrorCheck $ \a2' -> 
  702   factors'_ a1' a2' >>= \res ->
  703   let {res' = fromIntegral res} in
  704   errorCheck  a2'>>
  705   return (res')
  706 
  707 
  708 
  709 -- |the process's state at time 0, e.g. @(0, 0)@ for a curveless 'g2Process' or
  710 -- @(phi(0), 0)@ once a term structure is given.
  711 initialValues :: (GenStochasticProcess p) -> IO (([Double]))
  712 initialValues a1 =
  713   withStochasticProcess a1 $ \a1' -> 
  714   preDoubleArray $ \(a2'1, a2'2) -> 
  715   preErrorCheck $ \a3' -> 
  716   initialValues'_ a1' a2'1  a2'2 a3' >>
  717   peekDoubleArray  a2'1  a2'2>>= \a2'' -> 
  718   errorCheck  a3'>>
  719   return (a2'')
  720 
  721 
  722 
  723 -- |the drift part of the process's SDE at state /x/ and time /t/, i.e. @mu(t, x_t)@ in
  724 -- @dx_t = mu(t, x_t) dt + sigma(t, x_t) dW_t@.
  725 drift :: (GenStochasticProcess p) -> (Double) -- ^t
  726  -> ([Double]) -- ^x
  727  -> IO (([Double]))
  728 drift a1 a2 a3 =
  729   withStochasticProcess a1 $ \a1' -> 
  730   let {a2' = realToFrac a2} in 
  731   withDoubleArray a3 $ \(a3'1, a3'2) -> 
  732   preDoubleArray $ \(a4'1, a4'2) -> 
  733   preErrorCheck $ \a5' -> 
  734   drift'_ a1' a2' a3'1  a3'2 a4'1  a4'2 a5' >>
  735   peekDoubleArray  a4'1  a4'2>>= \a4'' -> 
  736   errorCheck  a5'>>
  737   return (a4'')
  738 
  739 
  740 
  741 toMatrixDouble :: (Word, Word, [Double]) -> Matrix Double
  742 toMatrixDouble (r, c, d) = Matrix r c d
  743 
  744 -- |the diffusion part of the process's SDE at state /x/ and time /t/, i.e. @sigma(t, x_t)@ in
  745 -- @dx_t = mu(t, x_t) dt + sigma(t, x_t) dW_t@.
  746 diffusion :: GenStochasticProcess p -> Double -> [Double] -> IO (Matrix Double)
  747 diffusion p t x = toMatrixDouble <$> qlStochasticProcessDiffusion p t x
  748 qlStochasticProcessDiffusion :: (GenStochasticProcess p) -> (Double) -- ^t
  749  -> ([Double]) -- ^x
  750  -> IO ((Word), (Word), ([Double]))
  751 qlStochasticProcessDiffusion a1 a2 a3 =
  752   withStochasticProcess a1 $ \a1' -> 
  753   let {a2' = realToFrac a2} in 
  754   withDoubleArray a3 $ \(a3'1, a3'2) -> 
  755   prePtr $ \a4' -> 
  756   prePtr $ \a5' -> 
  757   preDoubleArray $ \(a6'1, a6'2) -> 
  758   preErrorCheck $ \a7' -> 
  759   qlStochasticProcessDiffusion'_ a1' a2' a3'1  a3'2 a4' a5' a6'1  a6'2 a7' >>
  760   peekWord  a4'>>= \a4'' -> 
  761   peekWord  a5'>>= \a5'' -> 
  762   peekDoubleArray  a6'1  a6'2>>= \a6'' -> 
  763   errorCheck  a7'>>
  764   return (a4'', a5'', a6'')
  765 
  766 
  767 
  768 -- |E[x_(t0+dt) | x_t0 = x0], the expected state at /t0+dt/ given state /x0/ at time /t0/.
  769 expectation :: (GenStochasticProcess p) -> (Double) -- ^t0
  770  -> ([Double]) -- ^x0
  771  -> (Double) -- ^dt
  772  -> IO (([Double]))
  773 expectation a1 a2 a3 a4 =
  774   withStochasticProcess a1 $ \a1' -> 
  775   let {a2' = realToFrac a2} in 
  776   withDoubleArray a3 $ \(a3'1, a3'2) -> 
  777   let {a4' = realToFrac a4} in 
  778   preDoubleArray $ \(a5'1, a5'2) -> 
  779   preErrorCheck $ \a6' -> 
  780   expectation'_ a1' a2' a3'1  a3'2 a4' a5'1  a5'2 a6' >>
  781   peekDoubleArray  a5'1  a5'2>>= \a5'' -> 
  782   errorCheck  a6'>>
  783   return (a5'')
  784 
  785 
  786 
  787 -- |the standard deviation matrix of the process over /dt/ given state /x0/ at time /t0/, i.e.
  788 -- a square root of 'covariance' -- the factor a simulated normal draw is multiplied by in one
  789 -- exact-scheme step. Pairs with 'expectation': @x_(t0+dt) = expectation + stdDeviation \* dw@
  790 -- for a process whose discretization is exact in that sense.
  791 stdDeviation :: GenStochasticProcess p -> Double -> [Double] -> Double -> IO (Matrix Double)
  792 stdDeviation p t0 x0 dt = toMatrixDouble <$> qlStochasticProcessStdDeviation p t0 x0 dt
  793 qlStochasticProcessStdDeviation :: (GenStochasticProcess p) -> (Double) -- ^t0
  794  -> ([Double]) -- ^x0
  795  -> (Double) -- ^dt
  796  -> IO ((Word), (Word), ([Double]))
  797 qlStochasticProcessStdDeviation a1 a2 a3 a4 =
  798   withStochasticProcess a1 $ \a1' -> 
  799   let {a2' = realToFrac a2} in 
  800   withDoubleArray a3 $ \(a3'1, a3'2) -> 
  801   let {a4' = realToFrac a4} in 
  802   prePtr $ \a5' -> 
  803   prePtr $ \a6' -> 
  804   preDoubleArray $ \(a7'1, a7'2) -> 
  805   preErrorCheck $ \a8' -> 
  806   qlStochasticProcessStdDeviation'_ a1' a2' a3'1  a3'2 a4' a5' a6' a7'1  a7'2 a8' >>
  807   peekWord  a5'>>= \a5'' -> 
  808   peekWord  a6'>>= \a6'' -> 
  809   peekDoubleArray  a7'1  a7'2>>= \a7'' -> 
  810   errorCheck  a8'>>
  811   return (a5'', a6'', a7'')
  812 
  813 
  814 
  815 -- |the covariance matrix of the process over /dt/ given state /x0/ at time /t0/; equals
  816 -- @stdDeviation \* transpose stdDeviation@.
  817 covariance :: GenStochasticProcess p -> Double -> [Double] -> Double -> IO (Matrix Double)
  818 covariance p t0 x0 dt = toMatrixDouble <$> qlStochasticProcessCovariance p t0 x0 dt
  819 qlStochasticProcessCovariance :: (GenStochasticProcess p) -> (Double) -- ^t0
  820  -> ([Double]) -- ^x0
  821  -> (Double) -- ^dt
  822  -> IO ((Word), (Word), ([Double]))
  823 qlStochasticProcessCovariance a1 a2 a3 a4 =
  824   withStochasticProcess a1 $ \a1' -> 
  825   let {a2' = realToFrac a2} in 
  826   withDoubleArray a3 $ \(a3'1, a3'2) -> 
  827   let {a4' = realToFrac a4} in 
  828   prePtr $ \a5' -> 
  829   prePtr $ \a6' -> 
  830   preDoubleArray $ \(a7'1, a7'2) -> 
  831   preErrorCheck $ \a8' -> 
  832   qlStochasticProcessCovariance'_ a1' a2' a3'1  a3'2 a4' a5' a6' a7'1  a7'2 a8' >>
  833   peekWord  a5'>>= \a5'' -> 
  834   peekWord  a6'>>= \a6'' -> 
  835   peekDoubleArray  a7'1  a7'2>>= \a7'' -> 
  836   errorCheck  a8'>>
  837   return (a5'', a6'', a7'')
  838 
  839 
  840 
  841 -- |applies an increment /dx/ to a state /x0/ in the process's own state space -- not always
  842 -- plain addition (a log-variable process exponentiates, for instance), which is why it is a
  843 -- method rather than a caller-side @zipWith (+)@.
  844 apply :: (GenStochasticProcess p) -> ([Double]) -- ^x0
  845  -> ([Double]) -- ^dx
  846  -> IO (([Double]))
  847 apply a1 a2 a3 =
  848   withStochasticProcess a1 $ \a1' -> 
  849   withDoubleArray a2 $ \(a2'1, a2'2) -> 
  850   withDoubleArray a3 $ \(a3'1, a3'2) -> 
  851   preDoubleArray $ \(a4'1, a4'2) -> 
  852   preErrorCheck $ \a5' -> 
  853   apply'_ a1' a2'1  a2'2 a3'1  a3'2 a4'1  a4'2 a5' >>
  854   peekDoubleArray  a4'1  a4'2>>= \a4'' -> 
  855   errorCheck  a5'>>
  856   return (a4'')
  857 
  858 
  859 
  860 -- |one discretized step of the process: the state at /t0+dt/ given state /x0/ at /t0/ and the
  861 -- standard-normal draws /dw/ (one per 'factors').
  862 --
  863 -- This crosses the FFI boundary once per timestep, so it is not the way to generate many paths --
  864 -- use 'QuantLib.Method.pathGenerator' for that, which drives the same @evolve@ entirely inside
  865 -- QuantLib. Reach for this when Haskell has to own the path logic (path-dependent state,
  866 -- early termination, a custom draw source via 'QuantLib.Method.gaussianRsg') while QuantLib
  867 -- keeps owning the process's discretization scheme.
  868 evolve :: (GenStochasticProcess p) -> (Double) -- ^t0
  869  -> ([Double]) -- ^x0
  870  -> (Double) -- ^dt
  871  -> ([Double]) -- ^dw
  872  -> IO (([Double]))
  873 evolve a1 a2 a3 a4 a5 =
  874   withStochasticProcess a1 $ \a1' -> 
  875   let {a2' = realToFrac a2} in 
  876   withDoubleArray a3 $ \(a3'1, a3'2) -> 
  877   let {a4' = realToFrac a4} in 
  878   withDoubleArray a5 $ \(a5'1, a5'2) -> 
  879   preDoubleArray $ \(a6'1, a6'2) -> 
  880   preErrorCheck $ \a7' -> 
  881   evolve'_ a1' a2' a3'1  a3'2 a4' a5'1  a5'2 a6'1  a6'2 a7' >>
  882   peekDoubleArray  a6'1  a6'2>>= \a6'' -> 
  883   errorCheck  a7'>>
  884   return (a6'')
  885 
  886 
  887 
  888 -- |Geman-Roncoroni process, a mean-reverting jump-diffusion model for electricity spot prices
  889 -- with a seasonal deterministic mean and an asymmetric jump term.
  890 gemanRoncoroniProcess :: (Double) -- ^x0
  891  -> (Double) -- ^alpha
  892  -> (Double) -- ^beta
  893  -> (Double) -- ^gamma
  894  -> (Double) -- ^delta
  895  -> (Double) -- ^eps
  896  -> (Double) -- ^zeta
  897  -> (Double) -- ^d
  898  -> (Double) -- ^k
  899  -> (Double) -- ^tau
  900  -> (Double) -- ^sig2
  901  -> (Double) -- ^a
  902  -> (Double) -- ^b
  903  -> (Double) -- ^theta1
  904  -> (Double) -- ^theta2
  905  -> (Double) -- ^theta3
  906  -> (Double) -- ^psi
  907  -> IO ((StochasticProcess1D))
  908 gemanRoncoroniProcess a1 a2 a3 a4 a5 a6 a7 a8 a9 a10 a11 a12 a13 a14 a15 a16 a17 =
  909   let {a1' = realToFrac a1} in 
  910   let {a2' = realToFrac a2} in 
  911   let {a3' = realToFrac a3} in 
  912   let {a4' = realToFrac a4} in 
  913   let {a5' = realToFrac a5} in 
  914   let {a6' = realToFrac a6} in 
  915   let {a7' = realToFrac a7} in 
  916   let {a8' = realToFrac a8} in 
  917   let {a9' = realToFrac a9} in 
  918   let {a10' = realToFrac a10} in 
  919   let {a11' = realToFrac a11} in 
  920   let {a12' = realToFrac a12} in 
  921   let {a13' = realToFrac a13} in 
  922   let {a14' = realToFrac a14} in 
  923   let {a15' = realToFrac a15} in 
  924   let {a16' = realToFrac a16} in 
  925   let {a17' = realToFrac a17} in 
  926   preErrorCheck $ \a18' -> 
  927   gemanRoncoroniProcess'_ a1' a2' a3' a4' a5' a6' a7' a8' a9' a10' a11' a12' a13' a14' a15' a16' a17' a18' >>= \res ->
  928   peekStochasticProcess1D res >>= \res' ->
  929   errorCheck  a18'>>
  930   return (res')
  931 
  932 
  933 
  934 -- |geometric Brownian motion process: dS = mue S dt + sigma S dW.
  935 geometricBrownianMotionProcess :: (Double) -- ^initialValue
  936  -> (Double) -- ^mue
  937  -> (Double) -- ^sigma
  938  -> IO ((StochasticProcess1D))
  939 geometricBrownianMotionProcess a1 a2 a3 =
  940   let {a1' = realToFrac a1} in 
  941   let {a2' = realToFrac a2} in 
  942   let {a3' = realToFrac a3} in 
  943   preErrorCheck $ \a4' -> 
  944   geometricBrownianMotionProcess'_ a1' a2' a3' a4' >>= \res ->
  945   peekStochasticProcess1D res >>= \res' ->
  946   errorCheck  a4'>>
  947   return (res')
  948 
  949 
  950 
  951 -- |stochastic-volatility GJR-GARCH(1,1) process; parameters are supplied as daily constants
  952 -- and annualized internally via daysPerYear.
  953 gjrGarchProcess :: (GenYieldTermStructure y1) -- ^riskFreeRate
  954  -> (GenYieldTermStructure y2) -- ^dividendYield
  955  -> (GenQuote q) -- ^s0
  956  -> (Double) -- ^v0
  957  -> (Double) -- ^omega
  958  -> (Double) -- ^alpha
  959  -> (Double) -- ^beta
  960  -> (Double) -- ^gamma
  961  -> (Double) -- ^lambda
  962  -> (Double) -- ^daysPerYear
  963  -> (GJRGARCHProcessDiscretization) -> IO ((GJRGARCHProcess))
  964 gjrGarchProcess a1 a2 a3 a4 a5 a6 a7 a8 a9 a10 a11 =
  965   withYieldTermStructure a1 $ \a1' -> 
  966   withYieldTermStructure a2 $ \a2' -> 
  967   withQuote a3 $ \a3' -> 
  968   let {a4' = realToFrac a4} in 
  969   let {a5' = realToFrac a5} in 
  970   let {a6' = realToFrac a6} in 
  971   let {a7' = realToFrac a7} in 
  972   let {a8' = realToFrac a8} in 
  973   let {a9' = realToFrac a9} in 
  974   let {a10' = realToFrac a10} in 
  975   let {a11' = (fromIntegral . fromEnum) a11} in 
  976   preErrorCheck $ \a12' -> 
  977   gjrGarchProcess'_ a1' a2' a3' a4' a5' a6' a7' a8' a9' a10' a11' a12' >>= \res ->
  978   peekGJRGARCHProcess res >>= \res' ->
  979   errorCheck  a12'>>
  980   return (res')
  981 
  982 
  983 
  984 -- |/dividendYield/ may be 'Nothing' (an empty term-structure handle) -- required e.g. by
  985 -- 'QuantLib.PricingEngine.integralHestonVarianceOptionEngine', which rejects a process with a
  986 -- non-empty dividend handle.
  987 hestonProcess :: (GenYieldTermStructure y1) -- ^riskFreeRate
  988  -> (Maybe (GenYieldTermStructure y2)) -- ^dividendYield
  989  -> (GenQuote q) -- ^s0
  990  -> (Double) -- ^v0
  991  -> (Double) -- ^kappa
  992  -> (Double) -- ^theta
  993  -> (Double) -- ^sigma
  994  -> (Double) -- ^rho
  995  -> (HestonProcessDiscretization) -> IO ((HestonProcess))
  996 hestonProcess a1 a2 a3 a4 a5 a6 a7 a8 a9 =
  997   withYieldTermStructure a1 $ \a1' -> 
  998   withMaybeYieldTermStructure a2 $ \a2' -> 
  999   withQuote a3 $ \a3' -> 
 1000   let {a4' = realToFrac a4} in 
 1001   let {a5' = realToFrac a5} in 
 1002   let {a6' = realToFrac a6} in 
 1003   let {a7' = realToFrac a7} in 
 1004   let {a8' = realToFrac a8} in 
 1005   let {a9' = (fromIntegral . fromEnum) a9} in 
 1006   preErrorCheck $ \a10' -> 
 1007   hestonProcess'_ a1' a2' a3' a4' a5' a6' a7' a8' a9' a10' >>= \res ->
 1008   peekHestonProcess res >>= \res' ->
 1009   errorCheck  a10'>>
 1010   return (res')
 1011 
 1012 
 1013 
 1014 -- |Probability density of @(x = ln S, v)@ at time /t/, evaluated via the Heston
 1015 -- characteristic-function inversion (the same machinery as 'QuantLib.PricingEngine.analyticPDFHestonEngine').
 1016 -- /eps/ is the requested integration accuracy.
 1017 pdf :: (GenHestonProcess hp) -- ^process
 1018  -> (Double) -- ^x
 1019  -> (Double) -- ^v
 1020  -> (Double) -- ^t
 1021  -> (Double) -- ^eps
 1022  -> IO ((Double))
 1023 pdf a1 a2 a3 a4 a5 =
 1024   withHestonProcess a1 $ \a1' -> 
 1025   let {a2' = realToFrac a2} in 
 1026   let {a3' = realToFrac a3} in 
 1027   let {a4' = realToFrac a4} in 
 1028   let {a5' = realToFrac a5} in 
 1029   preErrorCheck $ \a6' -> 
 1030   pdf'_ a1' a2' a3' a4' a5' a6' >>= \res ->
 1031   let {res' = realToFrac res} in
 1032   errorCheck  a6'>>
 1033   return (res')
 1034 
 1035 
 1036 
 1037 -- |Two-factor Heston stochastic-local-volatility process using the supplied calibrated leverage
 1038 -- function. It is a generic 'StochasticProcess', so it composes with path generators and the
 1039 -- existing drift/diffusion operations.
 1040 hestonSlvProcess :: (GenHestonProcess hp) -- ^hestonProcess
 1041  -> (GenLocalVolTermStructure lv) -- ^leverageFct
 1042  -> (Double) -- ^mixingFactor
 1043  -> IO ((HestonSLVProcess))
 1044 hestonSlvProcess a1 a2 a3 =
 1045   withHestonProcess a1 $ \a1' -> 
 1046   withGenLocalVolTermStructure a2 $ \a2' -> 
 1047   let {a3' = realToFrac a3} in 
 1048   preErrorCheck $ \a4' -> 
 1049   hestonSlvProcess'_ a1' a2' a3' a4' >>= \res ->
 1050   peekHestonSLVProcess res >>= \res' ->
 1051   errorCheck  a4'>>
 1052   return (res')
 1053 
 1054 
 1055 
 1056 -- |T-forward-measure counterpart of 'hullWhiteProcess'.
 1057 hullWhiteForwardProcess :: (GenYieldTermStructure y) -- ^h
 1058  -> (Double) -- ^y
 1059  -> (Double) -- ^sigma
 1060  -> IO ((HullWhiteForwardProcess))
 1061 hullWhiteForwardProcess a1 a2 a3 =
 1062   withYieldTermStructure a1 $ \a1' -> 
 1063   let {a2' = realToFrac a2} in 
 1064   let {a3' = realToFrac a3} in 
 1065   preErrorCheck $ \a4' -> 
 1066   hullWhiteForwardProcess'_ a1' a2' a3' a4' >>= \res ->
 1067   peekHullWhiteForwardProcess res >>= \res' ->
 1068   errorCheck  a4'>>
 1069   return (res')
 1070 
 1071 
 1072 
 1073 -- |sets the T-forward measure's maturity time: a required post-construction call before a
 1074 -- 'hullWhiteForwardProcess' can be used for forward-measure pricing. Call it as soon as the
 1075 -- pricing horizon is known and, when the process is the short-rate leg of a
 1076 -- 'hybridHestonHullWhiteProcess', /before/ that process is constructed -- the joint process
 1077 -- reads this time once, at construction, and a later change does not reach it.
 1078 qlHullWhiteForwardProcessSetForwardMeasureTime :: (HullWhiteForwardProcess) -> (Double) -- ^t
 1079  -> IO ()
 1080 qlHullWhiteForwardProcessSetForwardMeasureTime a1 a2 =
 1081   withGenStochasticProcess1D a1 $ \a1' -> 
 1082   let {a2' = realToFrac a2} in 
 1083   preErrorCheck $ \a3' -> 
 1084   qlHullWhiteForwardProcessSetForwardMeasureTime'_ a1' a2' a3' >>
 1085   errorCheck  a3'>>
 1086   return ()
 1087 
 1088 
 1089 
 1090 -- |the T-forward-measure time /T/ of a 'g2ForwardProcess', the multi-factor counterpart of
 1091 -- 'setForwardMeasureTime'.
 1092 --
 1093 -- Mandatory before the process is simulated or its 'drift' read: @G2ForwardProcess@'s
 1094 -- constructor leaves the inherited /T/ default-initialized, and 'drift' (hence 'evolve' and
 1095 -- 'expectation') adds a measure correction computed from it, so without this call those read
 1096 -- an indeterminate value. 'phi' and 'shortRate' do not depend on /T/ and are
 1097 -- unaffected.
 1098 qlG2ForwardProcessSetForwardMeasureTime :: (G2ForwardProcess) -> (Double) -- ^t
 1099  -> IO ()
 1100 qlG2ForwardProcessSetForwardMeasureTime a1 a2 =
 1101   withGenStochasticProcess a1 $ \a1' -> 
 1102   let {a2' = realToFrac a2} in 
 1103   preErrorCheck $ \a3' -> 
 1104   qlG2ForwardProcessSetForwardMeasureTime'_ a1' a2' a3' >>
 1105   errorCheck  a3'>>
 1106   return ()
 1107 
 1108 
 1109 
 1110 -- |the deterministic drift offset alpha(t) that fits 'hullWhiteProcess''s initial term
 1111 -- structure; the simulated state /x/ is the short rate itself, so this is the piece to
 1112 -- subtract to recover the zero-mean OU factor.
 1113 qlHullWhiteProcessAlpha :: (HullWhiteProcess) -> (Double) -- ^t
 1114  -> IO ((Double))
 1115 qlHullWhiteProcessAlpha a1 a2 =
 1116   withGenStochasticProcess1D a1 $ \a1' -> 
 1117   let {a2' = realToFrac a2} in 
 1118   preErrorCheck $ \a3' -> 
 1119   qlHullWhiteProcessAlpha'_ a1' a2' a3' >>= \res ->
 1120   let {res' = realToFrac res} in
 1121   errorCheck  a3'>>
 1122   return (res')
 1123 
 1124 
 1125 
 1126 -- |'alpha' for a 'hullWhiteForwardProcess', i.e. under its T-forward measure.
 1127 qlHullWhiteForwardProcessAlpha :: (HullWhiteForwardProcess) -> (Double) -- ^t
 1128  -> IO ((Double))
 1129 qlHullWhiteForwardProcessAlpha a1 a2 =
 1130   withGenStochasticProcess1D a1 $ \a1' -> 
 1131   let {a2' = realToFrac a2} in 
 1132   preErrorCheck $ \a3' -> 
 1133   qlHullWhiteForwardProcessAlpha'_ a1' a2' a3' >>= \res ->
 1134   let {res' = realToFrac res} in
 1135   errorCheck  a3'>>
 1136   return (res')
 1137 
 1138 
 1139 
 1140 -- |the Hull-White B(t, T) = (1 - exp(-a (T - t))) \/ a factor of the affine discount-bond
 1141 -- formula P(t, T) = A(t, T) exp(-B(t, T) r_t).
 1142 bFunction :: (HullWhiteForwardProcess) -> (Double) -- ^t
 1143  -> (Double) -- ^T
 1144  -> IO ((Double))
 1145 bFunction a1 a2 a3 =
 1146   withGenStochasticProcess1D a1 $ \a1' -> 
 1147   let {a2' = realToFrac a2} in 
 1148   let {a3' = realToFrac a3} in 
 1149   preErrorCheck $ \a4' -> 
 1150   bFunction'_ a1' a2' a3' a4' >>= \res ->
 1151   let {res' = realToFrac res} in
 1152   errorCheck  a4'>>
 1153   return (res')
 1154 
 1155 
 1156 
 1157 -- |the T-forward-measure drift adjustment M_T(s, t, T) the process applies between /s/ and
 1158 -- /t/ when the numeraire is the /T/-maturity zero bond.
 1159 mFunction :: (HullWhiteForwardProcess) -> (Double) -- ^s
 1160  -> (Double) -- ^t
 1161  -> (Double) -- ^T
 1162  -> IO ((Double))
 1163 mFunction a1 a2 a3 a4 =
 1164   withGenStochasticProcess1D a1 $ \a1' -> 
 1165   let {a2' = realToFrac a2} in 
 1166   let {a3' = realToFrac a3} in 
 1167   let {a4' = realToFrac a4} in 
 1168   preErrorCheck $ \a5' -> 
 1169   mFunction'_ a1' a2' a3' a4' a5' >>= \res ->
 1170   let {res' = realToFrac res} in
 1171   errorCheck  a5'>>
 1172   return (res')
 1173 
 1174 
 1175 
 1176 -- |the T-forward-measure numeraire of a 'hybridHestonHullWhiteProcess' at time /t/ in state
 1177 -- /x/: @P(t, T, x!!2) \/ P(0, T)@, where /T/ is the process's forward-measure time and P is
 1178 -- the Hull-White discount bond implied by the simulated short-rate factor.
 1179 --
 1180 -- The state is @[S, v, r]@ -- spot, variance and the Hull-White factor, in the order
 1181 -- 'initialValues' returns -- and only @x!!2@ is read. This is /not/ a bank account: to turn a
 1182 -- simulated time-/t/ payoff into a present value, divide it by this numeraire and multiply by
 1183 -- the curve's own @discount ts T@.
 1184 --
 1185 -- /T/ is captured when the hybrid process is /constructed/, from the
 1186 -- 'hullWhiteForwardProcess''s forward-measure time -- so 'setForwardMeasureTime' must be
 1187 -- called on that process /before/ 'hybridHestonHullWhiteProcess', not after.
 1188 numeraire :: (HybridHestonHullWhiteProcess) -> (Double) -- ^t
 1189  -> ([Double]) -- ^x
 1190  -> IO ((Double))
 1191 numeraire a1 a2 a3 =
 1192   withGenStochasticProcess a1 $ \a1' -> 
 1193   let {a2' = realToFrac a2} in 
 1194   withDoubleArray a3 $ \(a3'1, a3'2) -> 
 1195   preErrorCheck $ \a4' -> 
 1196   numeraire'_ a1' a2' a3'1  a3'2 a4' >>= \res ->
 1197   let {res' = realToFrac res} in
 1198   errorCheck  a4'>>
 1199   return (res')
 1200 
 1201 
 1202 
 1203 -- |Hull-White one-factor short-rate process, fitted to the given initial term structure.
 1204 hullWhiteProcess :: (GenYieldTermStructure y) -- ^h
 1205  -> (Double) -- ^y
 1206  -> (Double) -- ^sigma
 1207  -> IO ((HullWhiteProcess))
 1208 hullWhiteProcess a1 a2 a3 =
 1209   withYieldTermStructure a1 $ \a1' -> 
 1210   let {a2' = realToFrac a2} in 
 1211   let {a3' = realToFrac a3} in 
 1212   preErrorCheck $ \a4' -> 
 1213   hullWhiteProcess'_ a1' a2' a3' a4' >>= \res ->
 1214   peekHullWhiteProcess res >>= \res' ->
 1215   errorCheck  a4'>>
 1216   return (res')
 1217 
 1218 
 1219 
 1220 -- |three-factor hybrid model combining a Heston equity process with a Hull-White short-rate
 1221 -- process, correlated via corrEquityShortRate.
 1222 hybridHestonHullWhiteProcess :: (GenHestonProcess hp) -> (HullWhiteForwardProcess) -> (Double) -- ^corrEquityShortRate
 1223  -> (HybridHestonHullWhiteProcessDiscretization) -> IO ((HybridHestonHullWhiteProcess))
 1224 hybridHestonHullWhiteProcess a1 a2 a3 a4 =
 1225   withHestonProcess a1 $ \a1' -> 
 1226   withGenStochasticProcess1D a2 $ \a2' -> 
 1227   let {a3' = realToFrac a3} in 
 1228   let {a4' = (fromIntegral . fromEnum) a4} in 
 1229   preErrorCheck $ \a5' -> 
 1230   hybridHestonHullWhiteProcess'_ a1' a2' a3' a4' a5' >>= \res ->
 1231   peekHybridHestonHullWhiteProcess res >>= \res' ->
 1232   errorCheck  a5'>>
 1233   return (res')
 1234 
 1235 
 1236 
 1237 -- |Joint correlated Kluge ('extOuWithJumpsProcess') and extended Ornstein-Uhlenbeck process. When
 1238 -- either input retains a Haskell callback, this result must remain inside that callback's scope.
 1239 klugeExtOuProcess :: (Double) -- ^rho
 1240  -> (ExtOUWithJumpsProcess) -> (ExtendedOrnsteinUhlenbeckProcess) -> IO ((KlugeExtOUProcess))
 1241 klugeExtOuProcess a1 a2 a3 =
 1242   let {a1' = realToFrac a1} in 
 1243   withGenStochasticProcess a2 $ \a2' -> 
 1244   withGenStochasticProcess1D a3 $ \a3' -> 
 1245   preErrorCheck $ \a4' -> 
 1246   klugeExtOuProcess'_ a1' a2' a3' a4' >>= \res ->
 1247   peekKlugeExtOUProcess res >>= \res' ->
 1248   errorCheck  a4'>>
 1249   return (res')
 1250 
 1251 
 1252 
 1253 -- |Libor market model process, evolving /size/ forward rates of /index/ under the rolling
 1254 -- forward measure with a predictor-corrector step.
 1255 liborForwardModelProcess :: (Word) -- ^size
 1256  -> (GenIborIndex ibor) -> IO ((LiborForwardModelProcess))
 1257 liborForwardModelProcess a1 a2 =
 1258   let {a1' = fromIntegral a1} in 
 1259   withIborIndex a2 $ \a2' -> 
 1260   preErrorCheck $ \a3' -> 
 1261   liborForwardModelProcess'_ a1' a2' a3' >>= \res ->
 1262   peekLiborForwardModelProcess res >>= \res' ->
 1263   errorCheck  a3'>>
 1264   return (res')
 1265 
 1266 
 1267 
 1268 -- |the reset (fixing) dates of the forward rates this process evolves
 1269 fixingDates :: (LiborForwardModelProcess) -> IO (([Day]))
 1270 fixingDates a1 =
 1271   withGenStochasticProcess a1 $ \a1' -> 
 1272   preIntArray $ \(a2'1, a2'2) -> 
 1273   preErrorCheck $ \a3' -> 
 1274   fixingDates'_ a1' a2'1  a2'2 a3' >>
 1275   peekDayArray  a2'1  a2'2>>= \a2'' -> 
 1276   errorCheck  a3'>>
 1277   return (a2'')
 1278 
 1279 
 1280 
 1281 -- |the reset (fixing) times of the forward rates this process evolves, in the process's own
 1282 -- day count fraction from the evaluation date
 1283 fixingTimes :: (LiborForwardModelProcess) -> IO (([Double]))
 1284 fixingTimes a1 =
 1285   withGenStochasticProcess a1 $ \a1' -> 
 1286   preDoubleArray $ \(a2'1, a2'2) -> 
 1287   preErrorCheck $ \a3' -> 
 1288   fixingTimes'_ a1' a2'1  a2'2 a3' >>
 1289   peekDoubleArray  a2'1  a2'2>>= \a2'' -> 
 1290   errorCheck  a3'>>
 1291   return (a2'')
 1292 
 1293 
 1294 
 1295 -- |the leg of Ibor coupons (notional @amount@ each) this process's forward rates reset -- used
 1296 -- e.g. to build the 'QuantLib.Instrument.CapFloor.cap' this process prices via 'liborForwardModel'
 1297 cashFlows :: (LiborForwardModelProcess) -> (Double) -- ^amount
 1298  -> IO ((Leg))
 1299 cashFlows a1 a2 =
 1300   withGenStochasticProcess a1 $ \a1' -> 
 1301   let {a2' = realToFrac a2} in 
 1302   preErrorCheck $ \a3' -> 
 1303   cashFlows'_ a1' a2' a3' >>= \res ->
 1304   peekLeg res >>= \res' ->
 1305   errorCheck  a3'>>
 1306   return (res')
 1307 
 1308 
 1309 
 1310 -- |the underlying 'IborIndex' this process was constructed with
 1311 index :: (LiborForwardModelProcess) -> IO ((IborIndex))
 1312 index a1 =
 1313   withGenStochasticProcess a1 $ \a1' -> 
 1314   preErrorCheck $ \a2' -> 
 1315   index'_ a1' a2' >>= \res ->
 1316   peekIborIndex res >>= \res' ->
 1317   errorCheck  a2'>>
 1318   return (res')
 1319 
 1320 
 1321 
 1322 -- |the /cumulative/ discount factors implied by one simulated vector of forward rates: element
 1323 -- /i/ discounts from the end of accrual period /i/ back to the process's start, i.e.
 1324 -- @scanl1 (*) [1 \/ (1 + r_i tau_i)]@ over 'accrualTimes' -- not the
 1325 -- individual one-period factors.
 1326 discountBond :: (LiborForwardModelProcess) -> ([Double]) -- ^rates
 1327  -> IO (([Double]))
 1328 discountBond a1 a2 =
 1329   withGenStochasticProcess a1 $ \a1' -> 
 1330   withDoubleArray a2 $ \(a2'1, a2'2) -> 
 1331   preDoubleArray $ \(a3'1, a3'2) -> 
 1332   preErrorCheck $ \a4' -> 
 1333   discountBond'_ a1' a2'1  a2'2 a3'1  a3'2 a4' >>
 1334   peekDoubleArray  a3'1  a3'2>>= \a3'' -> 
 1335   errorCheck  a4'>>
 1336   return (a3'')
 1337 
 1338 
 1339 
 1340 -- |the @(start, end)@ accrual times of the forward rates this process evolves, in its own day
 1341 -- count fraction from the evaluation date; their difference is the accrual period a caplet
 1342 -- payoff is scaled by.
 1343 accrualTimes :: LiborForwardModelProcess -> IO [(Double, Double)]
 1344 accrualTimes p = uncurry zip <$> qlLiborForwardModelProcessAccrualTimes p
 1345 qlLiborForwardModelProcessAccrualTimes :: (LiborForwardModelProcess) -> IO (([Double]), ([Double]))
 1346 qlLiborForwardModelProcessAccrualTimes a1 =
 1347   withGenStochasticProcess a1 $ \a1' -> 
 1348   preDoubleArray $ \(a2'1, a2'2) -> 
 1349   preDoubleArray $ \(a3'1, a3'2) -> 
 1350   preErrorCheck $ \a4' -> 
 1351   qlLiborForwardModelProcessAccrualTimes'_ a1' a2'1  a2'2 a3'1  a3'2 a4' >>
 1352   peekDoubleArray  a2'1  a2'2>>= \a2'' -> 
 1353   peekDoubleArray  a3'1  a3'2>>= \a3'' -> 
 1354   errorCheck  a4'>>
 1355   return (a2'', a3'')
 1356 
 1357 
 1358 
 1359 -- |Merton (1976) jump-diffusion process: a Black-Scholes process plus a log-normal jump
 1360 -- component with Poisson jump intensity jumpInt.
 1361 merton76Process :: (GenQuote q1) -- ^stateVariable
 1362  -> (GenYieldTermStructure y1) -- ^dividendTS
 1363  -> (GenYieldTermStructure y2) -- ^riskFreeTS
 1364  -> (GenBlackVolTermStructure bv) -- ^blackVolTS
 1365  -> (GenQuote q2) -- ^jumpInt
 1366  -> (GenQuote q3) -- ^logJMean
 1367  -> (GenQuote q4) -- ^logJVol
 1368  -> (ProcessDiscretization) -> IO ((Merton76Process))
 1369 merton76Process a1 a2 a3 a4 a5 a6 a7 a8 =
 1370   withQuote a1 $ \a1' -> 
 1371   withYieldTermStructure a2 $ \a2' -> 
 1372   withYieldTermStructure a3 $ \a3' -> 
 1373   withBlackVolTermStructure a4 $ \a4' -> 
 1374   withQuote a5 $ \a5' -> 
 1375   withQuote a6 $ \a6' -> 
 1376   withQuote a7 $ \a7' -> 
 1377   let {a8' = (fromIntegral . fromEnum) a8} in 
 1378   preErrorCheck $ \a9' -> 
 1379   merton76Process'_ a1' a2' a3' a4' a5' a6' a7' a8' a9' >>= \res ->
 1380   peekMerton76Process res >>= \res' ->
 1381   errorCheck  a9'>>
 1382   return (res')
 1383 
 1384 
 1385 
 1386 -- |Ornstein-Uhlenbeck process: dx = a (level - x) dt + sigma dW.
 1387 ornsteinUhlenbeckProcess :: (Double) -- ^speed
 1388  -> (Double) -- ^vol
 1389  -> (Double) -- ^x0
 1390  -> (Double) -- ^level
 1391  -> IO ((StochasticProcess1D))
 1392 ornsteinUhlenbeckProcess a1 a2 a3 a4 =
 1393   let {a1' = realToFrac a1} in 
 1394   let {a2' = realToFrac a2} in 
 1395   let {a3' = realToFrac a3} in 
 1396   let {a4' = realToFrac a4} in 
 1397   preErrorCheck $ \a5' -> 
 1398   ornsteinUhlenbeckProcess'_ a1' a2' a3' a4' a5' >>= \res ->
 1399   peekStochasticProcess1D res >>= \res' ->
 1400   errorCheck  a5'>>
 1401   return (res')
 1402 
 1403 
 1404 
 1405 -- |Variance Gamma process: a Brownian motion db = theta dt + sigma dW time-changed by an
 1406 -- independent Gamma process with mean 1 and variance rate nu.
 1407 varianceGammaProcess :: (GenQuote q) -- ^s0
 1408  -> (GenYieldTermStructure y1) -- ^dividendYield
 1409  -> (GenYieldTermStructure y2) -- ^riskFreeRate
 1410  -> (Double) -- ^sigma
 1411  -> (Double) -- ^nu
 1412  -> (Double) -- ^theta
 1413  -> IO ((VarianceGammaProcess))
 1414 varianceGammaProcess a1 a2 a3 a4 a5 a6 =
 1415   withQuote a1 $ \a1' -> 
 1416   withYieldTermStructure a2 $ \a2' -> 
 1417   withYieldTermStructure a3 $ \a3' -> 
 1418   let {a4' = realToFrac a4} in 
 1419   let {a5' = realToFrac a5} in 
 1420   let {a6' = realToFrac a6} in 
 1421   preErrorCheck $ \a7' -> 
 1422   varianceGammaProcess'_ a1' a2' a3' a4' a5' a6' a7' >>= \res ->
 1423   peekVarianceGammaProcess res >>= \res' ->
 1424   errorCheck  a7'>>
 1425   return (res')
 1426 
 1427 
 1428 
 1429 -- |array of correlated 1-D stochastic processes, driven by a joint correlation matrix.
 1430 stochasticProcessArray :: NonEmpty (GenStochasticProcess1D p1d) -> Matrix Double -- ^correlation
 1431   -> IO StochasticProcessArray
 1432 stochasticProcessArray a (Matrix mr mc md) = qlStochasticProcessArray (toList a) mr mc md
 1433 qlStochasticProcessArray :: ([GenStochasticProcess1D p1d]) -> (Word) -> (Word) -> ([Double]) -> IO ((StochasticProcessArray))
 1434 qlStochasticProcessArray a1 a2 a3 a4 =
 1435   withStochasticProcess1DArray a1 $ \(a1'1, a1'2) -> 
 1436   let {a2' = fromIntegral a2} in 
 1437   let {a3' = fromIntegral a3} in 
 1438   withDoubleArrayRaw a4 $ \a4' -> 
 1439   preErrorCheck $ \a5' -> 
 1440   qlStochasticProcessArray'_ a1'1  a1'2 a2' a3' a4' a5' >>= \res ->
 1441   peekStochasticProcessArray res >>= \res' ->
 1442   errorCheck  a5'>>
 1443   return (res')
 1444 
 1445 
 1446 
 1447 -- |default theta calculation for Black-Scholes options
 1448 thetaAt :: (GenGeneralizedBlackScholesProcess gbs) -> (Double) -- ^value
 1449  -> (Double) -- ^delta
 1450  -> (Double) -- ^gamma
 1451  -> IO ((Double))
 1452 thetaAt a1 a2 a3 a4 =
 1453   withGeneralizedBlackScholesProcess a1 $ \a1' -> 
 1454   let {a2' = realToFrac a2} in 
 1455   let {a3' = realToFrac a3} in 
 1456   let {a4' = realToFrac a4} in 
 1457   preErrorCheck $ \a5' -> 
 1458   thetaAt'_ a1' a2' a3' a4' a5' >>= \res ->
 1459   let {res' = realToFrac res} in
 1460   errorCheck  a5'>>
 1461   return (res')
 1462 
 1463 
 1464 
 1465 -- vim: set ff=unix ts=8 sts=2 sw=2 et:
 1466 
 1467 foreign import ccall safe "QuantLib/Process.chs.h qlBlackProcess"
 1468   blackProcess'_ :: ((C2HSImp.Ptr (CQuote')) -> ((C2HSImp.Ptr (CYieldTermStructure')) -> ((C2HSImp.Ptr (CBlackVolTermStructure')) -> (C2HSImp.CInt -> (C2HSImp.CInt -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO (C2HSImp.Ptr (CBlackProcess')))))))))
 1469 
 1470 foreign import ccall safe "QuantLib/Process.chs.h qlBlackScholesMertonProcess"
 1471   blackScholesMertonProcess'_ :: ((C2HSImp.Ptr (CQuote')) -> ((C2HSImp.Ptr (CYieldTermStructure')) -> ((C2HSImp.Ptr (CYieldTermStructure')) -> ((C2HSImp.Ptr (CBlackVolTermStructure')) -> (C2HSImp.CInt -> (C2HSImp.CInt -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO (C2HSImp.Ptr (CGeneralizedBlackScholesProcess'))))))))))
 1472 
 1473 foreign import ccall safe "QuantLib/Process.chs.h qlBlackScholesProcess"
 1474   blackScholesProcess'_ :: ((C2HSImp.Ptr (CQuote')) -> ((C2HSImp.Ptr (CYieldTermStructure')) -> ((C2HSImp.Ptr (CBlackVolTermStructure')) -> (C2HSImp.CInt -> (C2HSImp.CInt -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO (C2HSImp.Ptr (CGeneralizedBlackScholesProcess')))))))))
 1475 
 1476 foreign import ccall safe "QuantLib/Process.chs.h qlExtendedBlackScholesMertonProcess"
 1477   extendedBlackScholesMertonProcess'_ :: ((C2HSImp.Ptr (CQuote')) -> ((C2HSImp.Ptr (CYieldTermStructure')) -> ((C2HSImp.Ptr (CYieldTermStructure')) -> ((C2HSImp.Ptr (CBlackVolTermStructure')) -> (C2HSImp.CInt -> (C2HSImp.CInt -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO (C2HSImp.Ptr (CGeneralizedBlackScholesProcess'))))))))))
 1478 
 1479 foreign import ccall safe "QuantLib/Process.chs.h qlGarmanKohlhagenProcess"
 1480   garmanKohlhagenProcess'_ :: ((C2HSImp.Ptr (CQuote')) -> ((C2HSImp.Ptr (CYieldTermStructure')) -> ((C2HSImp.Ptr (CYieldTermStructure')) -> ((C2HSImp.Ptr (CBlackVolTermStructure')) -> (C2HSImp.CInt -> (C2HSImp.CInt -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO (C2HSImp.Ptr (CGeneralizedBlackScholesProcess'))))))))))
 1481 
 1482 foreign import ccall safe "QuantLib/Process.chs.h qlGeneralizedBlackScholesProcess"
 1483   generalizedBlackScholesProcess'_ :: ((C2HSImp.Ptr (CQuote')) -> ((C2HSImp.Ptr (CYieldTermStructure')) -> ((C2HSImp.Ptr (CYieldTermStructure')) -> ((C2HSImp.Ptr (CBlackVolTermStructure')) -> (C2HSImp.CInt -> (C2HSImp.CInt -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO (C2HSImp.Ptr (CGeneralizedBlackScholesProcess'))))))))))
 1484 
 1485 foreign import ccall safe "QuantLib/Process.chs.h qlSquareRootProcess"
 1486   squareRootProcess'_ :: (C2HSImp.CDouble -> (C2HSImp.CDouble -> (C2HSImp.CDouble -> (C2HSImp.CDouble -> (C2HSImp.CInt -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO (C2HSImp.Ptr (CStochasticProcess1D')))))))))
 1487 
 1488 foreign import ccall safe "QuantLib/Process.chs.h qlVegaStressedBlackScholesProcess"
 1489   vegaStressedBlackScholesProcess'_ :: ((C2HSImp.Ptr (CQuote')) -> ((C2HSImp.Ptr (CYieldTermStructure')) -> ((C2HSImp.Ptr (CYieldTermStructure')) -> ((C2HSImp.Ptr (CBlackVolTermStructure')) -> (C2HSImp.CDouble -> (C2HSImp.CDouble -> (C2HSImp.CDouble -> (C2HSImp.CDouble -> (C2HSImp.CDouble -> (C2HSImp.CInt -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO (C2HSImp.Ptr (CGeneralizedBlackScholesProcess'))))))))))))))
 1490 
 1491 foreign import ccall safe "QuantLib/Process.chs.h qlBatesProcess"
 1492   batesProcess'_ :: ((C2HSImp.Ptr (CYieldTermStructure')) -> ((C2HSImp.Ptr (CYieldTermStructure')) -> ((C2HSImp.Ptr (CQuote')) -> (C2HSImp.CDouble -> (C2HSImp.CDouble -> (C2HSImp.CDouble -> (C2HSImp.CDouble -> (C2HSImp.CDouble -> (C2HSImp.CDouble -> (C2HSImp.CDouble -> (C2HSImp.CDouble -> (C2HSImp.CInt -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO (C2HSImp.Ptr (CBatesProcess'))))))))))))))))
 1493 
 1494 foreign import ccall safe "QuantLib/Process.chs.h qlExtendedOrnsteinUhlenbeckProcess"
 1495   qlExtendedOrnsteinUhlenbeckProcess'_ :: (C2HSImp.CDouble -> (C2HSImp.CDouble -> (C2HSImp.CDouble -> ((C2HSImp.Ptr ()) -> (C2HSImp.CInt -> (C2HSImp.CDouble -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO (C2HSImp.Ptr (CExtendedOrnsteinUhlenbeckProcess'))))))))))
 1496 
 1497 foreign import ccall safe "QuantLib/Process.chs.h qlLinearSeasonalOrnsteinUhlenbeckProcess"
 1498   linearSeasonalOrnsteinUhlenbeckProcess'_ :: (C2HSImp.CDouble -> (C2HSImp.CDouble -> (C2HSImp.CDouble -> (C2HSImp.CDouble -> (C2HSImp.CDouble -> (C2HSImp.CDouble -> (C2HSImp.CDouble -> (C2HSImp.CInt -> (C2HSImp.CDouble -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO (C2HSImp.Ptr (CExtendedOrnsteinUhlenbeckProcess')))))))))))))
 1499 
 1500 foreign import ccall safe "QuantLib/Process.chs.h qlExtOUWithJumpsProcess"
 1501   extOuWithJumpsProcess'_ :: ((C2HSImp.Ptr (CExtendedOrnsteinUhlenbeckProcess')) -> (C2HSImp.CDouble -> (C2HSImp.CDouble -> (C2HSImp.CDouble -> (C2HSImp.CDouble -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO (C2HSImp.Ptr (CExtOUWithJumpsProcess')))))))))
 1502 
 1503 foreign import ccall safe "QuantLib/Process.chs.h qlG2ForwardProcess"
 1504   g2ForwardProcess'_ :: (C2HSImp.CDouble -> (C2HSImp.CDouble -> (C2HSImp.CDouble -> (C2HSImp.CDouble -> (C2HSImp.CDouble -> ((C2HSImp.Ptr (CYieldTermStructure')) -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO (C2HSImp.Ptr (CG2ForwardProcess'))))))))))
 1505 
 1506 foreign import ccall safe "QuantLib/Process.chs.h qlG2Process"
 1507   g2Process'_ :: (C2HSImp.CDouble -> (C2HSImp.CDouble -> (C2HSImp.CDouble -> (C2HSImp.CDouble -> (C2HSImp.CDouble -> ((C2HSImp.Ptr (CYieldTermStructure')) -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO (C2HSImp.Ptr (CG2Process'))))))))))
 1508 
 1509 foreign import ccall safe "QuantLib/Process.chs.h qlG2ProcessPhi"
 1510   qlG2ProcessPhi'_ :: ((C2HSImp.Ptr (CG2Process')) -> (C2HSImp.CDouble -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO C2HSImp.CDouble))))
 1511 
 1512 foreign import ccall safe "QuantLib/Process.chs.h qlG2ProcessShortRate"
 1513   qlG2ProcessShortRate'_ :: ((C2HSImp.Ptr (CG2Process')) -> (C2HSImp.CDouble -> (C2HSImp.CDouble -> (C2HSImp.CDouble -> (IO C2HSImp.CDouble)))))
 1514 
 1515 foreign import ccall safe "QuantLib/Process.chs.h qlG2ForwardProcessPhi"
 1516   qlG2ForwardProcessPhi'_ :: ((C2HSImp.Ptr (CG2ForwardProcess')) -> (C2HSImp.CDouble -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO C2HSImp.CDouble))))
 1517 
 1518 foreign import ccall safe "QuantLib/Process.chs.h qlG2ForwardProcessShortRate"
 1519   qlG2ForwardProcessShortRate'_ :: ((C2HSImp.Ptr (CG2ForwardProcess')) -> (C2HSImp.CDouble -> (C2HSImp.CDouble -> (C2HSImp.CDouble -> (IO C2HSImp.CDouble)))))
 1520 
 1521 foreign import ccall safe "QuantLib/Process.chs.h qlStochasticProcessFactors"
 1522   factors'_ :: ((C2HSImp.Ptr (CStochasticProcess')) -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO C2HSImp.CUInt)))
 1523 
 1524 foreign import ccall safe "QuantLib/Process.chs.h qlStochasticProcessInitialValues"
 1525   initialValues'_ :: ((C2HSImp.Ptr (CStochasticProcess')) -> ((C2HSImp.Ptr C2HSImp.CUInt) -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CDouble)) -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO ())))))
 1526 
 1527 foreign import ccall safe "QuantLib/Process.chs.h qlStochasticProcessDrift"
 1528   drift'_ :: ((C2HSImp.Ptr (CStochasticProcess')) -> (C2HSImp.CDouble -> (C2HSImp.CUInt -> ((C2HSImp.Ptr C2HSImp.CDouble) -> ((C2HSImp.Ptr C2HSImp.CUInt) -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CDouble)) -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO ()))))))))
 1529 
 1530 foreign import ccall safe "QuantLib/Process.chs.h qlStochasticProcessDiffusion"
 1531   qlStochasticProcessDiffusion'_ :: ((C2HSImp.Ptr (CStochasticProcess')) -> (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 ()))))))))))
 1532 
 1533 foreign import ccall safe "QuantLib/Process.chs.h qlStochasticProcessExpectation"
 1534   expectation'_ :: ((C2HSImp.Ptr (CStochasticProcess')) -> (C2HSImp.CDouble -> (C2HSImp.CUInt -> ((C2HSImp.Ptr C2HSImp.CDouble) -> (C2HSImp.CDouble -> ((C2HSImp.Ptr C2HSImp.CUInt) -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CDouble)) -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO ())))))))))
 1535 
 1536 foreign import ccall safe "QuantLib/Process.chs.h qlStochasticProcessStdDeviation"
 1537   qlStochasticProcessStdDeviation'_ :: ((C2HSImp.Ptr (CStochasticProcess')) -> (C2HSImp.CDouble -> (C2HSImp.CUInt -> ((C2HSImp.Ptr C2HSImp.CDouble) -> (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 ())))))))))))
 1538 
 1539 foreign import ccall safe "QuantLib/Process.chs.h qlStochasticProcessCovariance"
 1540   qlStochasticProcessCovariance'_ :: ((C2HSImp.Ptr (CStochasticProcess')) -> (C2HSImp.CDouble -> (C2HSImp.CUInt -> ((C2HSImp.Ptr C2HSImp.CDouble) -> (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 ())))))))))))
 1541 
 1542 foreign import ccall safe "QuantLib/Process.chs.h qlStochasticProcessApply"
 1543   apply'_ :: ((C2HSImp.Ptr (CStochasticProcess')) -> (C2HSImp.CUInt -> ((C2HSImp.Ptr C2HSImp.CDouble) -> (C2HSImp.CUInt -> ((C2HSImp.Ptr C2HSImp.CDouble) -> ((C2HSImp.Ptr C2HSImp.CUInt) -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CDouble)) -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO ())))))))))
 1544 
 1545 foreign import ccall safe "QuantLib/Process.chs.h qlStochasticProcessEvolve"
 1546   evolve'_ :: ((C2HSImp.Ptr (CStochasticProcess')) -> (C2HSImp.CDouble -> (C2HSImp.CUInt -> ((C2HSImp.Ptr C2HSImp.CDouble) -> (C2HSImp.CDouble -> (C2HSImp.CUInt -> ((C2HSImp.Ptr C2HSImp.CDouble) -> ((C2HSImp.Ptr C2HSImp.CUInt) -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CDouble)) -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO ())))))))))))
 1547 
 1548 foreign import ccall safe "QuantLib/Process.chs.h qlGemanRoncoroniProcess"
 1549   gemanRoncoroniProcess'_ :: (C2HSImp.CDouble -> (C2HSImp.CDouble -> (C2HSImp.CDouble -> (C2HSImp.CDouble -> (C2HSImp.CDouble -> (C2HSImp.CDouble -> (C2HSImp.CDouble -> (C2HSImp.CDouble -> (C2HSImp.CDouble -> (C2HSImp.CDouble -> (C2HSImp.CDouble -> (C2HSImp.CDouble -> (C2HSImp.CDouble -> (C2HSImp.CDouble -> (C2HSImp.CDouble -> (C2HSImp.CDouble -> (C2HSImp.CDouble -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO (C2HSImp.Ptr (CStochasticProcess1D')))))))))))))))))))))
 1550 
 1551 foreign import ccall safe "QuantLib/Process.chs.h qlGeometricBrownianMotionProcess"
 1552   geometricBrownianMotionProcess'_ :: (C2HSImp.CDouble -> (C2HSImp.CDouble -> (C2HSImp.CDouble -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO (C2HSImp.Ptr (CStochasticProcess1D')))))))
 1553 
 1554 foreign import ccall safe "QuantLib/Process.chs.h qlGJRGARCHProcess"
 1555   gjrGarchProcess'_ :: ((C2HSImp.Ptr (CYieldTermStructure')) -> ((C2HSImp.Ptr (CYieldTermStructure')) -> ((C2HSImp.Ptr (CQuote')) -> (C2HSImp.CDouble -> (C2HSImp.CDouble -> (C2HSImp.CDouble -> (C2HSImp.CDouble -> (C2HSImp.CDouble -> (C2HSImp.CDouble -> (C2HSImp.CDouble -> (C2HSImp.CInt -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO (C2HSImp.Ptr (CGJRGARCHProcess')))))))))))))))
 1556 
 1557 foreign import ccall safe "QuantLib/Process.chs.h qlHestonProcess"
 1558   hestonProcess'_ :: ((C2HSImp.Ptr (CYieldTermStructure')) -> ((C2HSImp.Ptr (CYieldTermStructure')) -> ((C2HSImp.Ptr (CQuote')) -> (C2HSImp.CDouble -> (C2HSImp.CDouble -> (C2HSImp.CDouble -> (C2HSImp.CDouble -> (C2HSImp.CDouble -> (C2HSImp.CInt -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO (C2HSImp.Ptr (CHestonProcess')))))))))))))
 1559 
 1560 foreign import ccall safe "QuantLib/Process.chs.h qlHestonProcessPdf"
 1561   pdf'_ :: ((C2HSImp.Ptr (CHestonProcess')) -> (C2HSImp.CDouble -> (C2HSImp.CDouble -> (C2HSImp.CDouble -> (C2HSImp.CDouble -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO C2HSImp.CDouble)))))))
 1562 
 1563 foreign import ccall safe "QuantLib/Process.chs.h qlHestonSLVProcess"
 1564   hestonSlvProcess'_ :: ((C2HSImp.Ptr (CHestonProcess')) -> ((C2HSImp.Ptr (CLocalVolTermStructure')) -> (C2HSImp.CDouble -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO (C2HSImp.Ptr (CHestonSLVProcess')))))))
 1565 
 1566 foreign import ccall safe "QuantLib/Process.chs.h qlHullWhiteForwardProcess"
 1567   hullWhiteForwardProcess'_ :: ((C2HSImp.Ptr (CYieldTermStructure')) -> (C2HSImp.CDouble -> (C2HSImp.CDouble -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO (C2HSImp.Ptr (CHullWhiteForwardProcess')))))))
 1568 
 1569 foreign import ccall safe "QuantLib/Process.chs.h qlHullWhiteForwardProcessSetForwardMeasureTime"
 1570   qlHullWhiteForwardProcessSetForwardMeasureTime'_ :: ((C2HSImp.Ptr (CHullWhiteForwardProcess')) -> (C2HSImp.CDouble -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO ()))))
 1571 
 1572 foreign import ccall safe "QuantLib/Process.chs.h qlG2ForwardProcessSetForwardMeasureTime"
 1573   qlG2ForwardProcessSetForwardMeasureTime'_ :: ((C2HSImp.Ptr (CG2ForwardProcess')) -> (C2HSImp.CDouble -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO ()))))
 1574 
 1575 foreign import ccall safe "QuantLib/Process.chs.h qlHullWhiteProcessAlpha"
 1576   qlHullWhiteProcessAlpha'_ :: ((C2HSImp.Ptr (CHullWhiteProcess')) -> (C2HSImp.CDouble -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO C2HSImp.CDouble))))
 1577 
 1578 foreign import ccall safe "QuantLib/Process.chs.h qlHullWhiteForwardProcessAlpha"
 1579   qlHullWhiteForwardProcessAlpha'_ :: ((C2HSImp.Ptr (CHullWhiteForwardProcess')) -> (C2HSImp.CDouble -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO C2HSImp.CDouble))))
 1580 
 1581 foreign import ccall safe "QuantLib/Process.chs.h qlHullWhiteForwardProcessB"
 1582   bFunction'_ :: ((C2HSImp.Ptr (CHullWhiteForwardProcess')) -> (C2HSImp.CDouble -> (C2HSImp.CDouble -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO C2HSImp.CDouble)))))
 1583 
 1584 foreign import ccall safe "QuantLib/Process.chs.h qlHullWhiteForwardProcessMT"
 1585   mFunction'_ :: ((C2HSImp.Ptr (CHullWhiteForwardProcess')) -> (C2HSImp.CDouble -> (C2HSImp.CDouble -> (C2HSImp.CDouble -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO C2HSImp.CDouble))))))
 1586 
 1587 foreign import ccall safe "QuantLib/Process.chs.h qlHybridHestonHullWhiteProcessNumeraire"
 1588   numeraire'_ :: ((C2HSImp.Ptr (CHybridHestonHullWhiteProcess')) -> (C2HSImp.CDouble -> (C2HSImp.CUInt -> ((C2HSImp.Ptr C2HSImp.CDouble) -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO C2HSImp.CDouble))))))
 1589 
 1590 foreign import ccall safe "QuantLib/Process.chs.h qlHullWhiteProcess"
 1591   hullWhiteProcess'_ :: ((C2HSImp.Ptr (CYieldTermStructure')) -> (C2HSImp.CDouble -> (C2HSImp.CDouble -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO (C2HSImp.Ptr (CHullWhiteProcess')))))))
 1592 
 1593 foreign import ccall safe "QuantLib/Process.chs.h qlHybridHestonHullWhiteProcess"
 1594   hybridHestonHullWhiteProcess'_ :: ((C2HSImp.Ptr (CHestonProcess')) -> ((C2HSImp.Ptr (CHullWhiteForwardProcess')) -> (C2HSImp.CDouble -> (C2HSImp.CInt -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO (C2HSImp.Ptr (CHybridHestonHullWhiteProcess'))))))))
 1595 
 1596 foreign import ccall safe "QuantLib/Process.chs.h qlKlugeExtOUProcess"
 1597   klugeExtOuProcess'_ :: (C2HSImp.CDouble -> ((C2HSImp.Ptr (CExtOUWithJumpsProcess')) -> ((C2HSImp.Ptr (CExtendedOrnsteinUhlenbeckProcess')) -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO (C2HSImp.Ptr (CKlugeExtOUProcess')))))))
 1598 
 1599 foreign import ccall safe "QuantLib/Process.chs.h qlLiborForwardModelProcess"
 1600   liborForwardModelProcess'_ :: (C2HSImp.CUInt -> ((C2HSImp.Ptr (CIborIndex')) -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO (C2HSImp.Ptr (CLiborForwardModelProcess'))))))
 1601 
 1602 foreign import ccall safe "QuantLib/Process.chs.h qlLiborForwardModelProcessFixingDates"
 1603   fixingDates'_ :: ((C2HSImp.Ptr (CLiborForwardModelProcess')) -> ((C2HSImp.Ptr C2HSImp.CUInt) -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CInt)) -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO ())))))
 1604 
 1605 foreign import ccall safe "QuantLib/Process.chs.h qlLiborForwardModelProcessFixingTimes"
 1606   fixingTimes'_ :: ((C2HSImp.Ptr (CLiborForwardModelProcess')) -> ((C2HSImp.Ptr C2HSImp.CUInt) -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CDouble)) -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO ())))))
 1607 
 1608 foreign import ccall safe "QuantLib/Process.chs.h qlLiborForwardModelProcessCashFlows"
 1609   cashFlows'_ :: ((C2HSImp.Ptr (CLiborForwardModelProcess')) -> (C2HSImp.CDouble -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO (C2HSImp.Ptr (CLeg'))))))
 1610 
 1611 foreign import ccall safe "QuantLib/Process.chs.h qlLiborForwardModelProcessIndex"
 1612   index'_ :: ((C2HSImp.Ptr (CLiborForwardModelProcess')) -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO (C2HSImp.Ptr (CIborIndex')))))
 1613 
 1614 foreign import ccall safe "QuantLib/Process.chs.h qlLiborForwardModelProcessDiscountBond"
 1615   discountBond'_ :: ((C2HSImp.Ptr (CLiborForwardModelProcess')) -> (C2HSImp.CUInt -> ((C2HSImp.Ptr C2HSImp.CDouble) -> ((C2HSImp.Ptr C2HSImp.CUInt) -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CDouble)) -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO ())))))))
 1616 
 1617 foreign import ccall safe "QuantLib/Process.chs.h qlLiborForwardModelProcessAccrualTimes"
 1618   qlLiborForwardModelProcessAccrualTimes'_ :: ((C2HSImp.Ptr (CLiborForwardModelProcess')) -> ((C2HSImp.Ptr C2HSImp.CUInt) -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CDouble)) -> ((C2HSImp.Ptr C2HSImp.CUInt) -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CDouble)) -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO ())))))))
 1619 
 1620 foreign import ccall safe "QuantLib/Process.chs.h qlMerton76Process"
 1621   merton76Process'_ :: ((C2HSImp.Ptr (CQuote')) -> ((C2HSImp.Ptr (CYieldTermStructure')) -> ((C2HSImp.Ptr (CYieldTermStructure')) -> ((C2HSImp.Ptr (CBlackVolTermStructure')) -> ((C2HSImp.Ptr (CQuote')) -> ((C2HSImp.Ptr (CQuote')) -> ((C2HSImp.Ptr (CQuote')) -> (C2HSImp.CInt -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO (C2HSImp.Ptr (CMerton76Process'))))))))))))
 1622 
 1623 foreign import ccall safe "QuantLib/Process.chs.h qlOrnsteinUhlenbeckProcess"
 1624   ornsteinUhlenbeckProcess'_ :: (C2HSImp.CDouble -> (C2HSImp.CDouble -> (C2HSImp.CDouble -> (C2HSImp.CDouble -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO (C2HSImp.Ptr (CStochasticProcess1D'))))))))
 1625 
 1626 foreign import ccall safe "QuantLib/Process.chs.h qlVarianceGammaProcess"
 1627   varianceGammaProcess'_ :: ((C2HSImp.Ptr (CQuote')) -> ((C2HSImp.Ptr (CYieldTermStructure')) -> ((C2HSImp.Ptr (CYieldTermStructure')) -> (C2HSImp.CDouble -> (C2HSImp.CDouble -> (C2HSImp.CDouble -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO (C2HSImp.Ptr (CVarianceGammaProcess'))))))))))
 1628 
 1629 foreign import ccall safe "QuantLib/Process.chs.h qlStochasticProcessArray"
 1630   qlStochasticProcessArray'_ :: (C2HSImp.CUInt -> ((C2HSImp.Ptr (C2HSImp.Ptr (CStochasticProcess1D'))) -> (C2HSImp.CUInt -> (C2HSImp.CUInt -> ((C2HSImp.Ptr C2HSImp.CDouble) -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO (C2HSImp.Ptr (CStochasticProcessArray')))))))))
 1631 
 1632 foreign import ccall safe "QuantLib/Process.chs.h qlQuantLibBlackScholesTheta"
 1633   thetaAt'_ :: ((C2HSImp.Ptr (CGeneralizedBlackScholesProcess')) -> (C2HSImp.CDouble -> (C2HSImp.CDouble -> (C2HSImp.CDouble -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO C2HSImp.CDouble))))))