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 module QuantLib.Model
    6   (
    7     CalibrationErrorType(..)
    8   , GJRGARCHModel
    9   , HestonModel
   10   , GenHestonModel
   11   , BatesModel
   12   , GenBatesModel
   13   , PiecewiseTimeDependentHestonModel
   14   , ShortRateModel
   15   , GenShortRateModel
   16   , AffineModel
   17   , Gaussian1dModel
   18   , OneFactorAffineModel
   19   , GenOneFactorAffineModel
   20   , LiborForwardModel
   21   , HullWhite
   22   , Gsr
   23   , MarkovFunctional
   24   , CalibratedModel
   25   , GenCalibratedModel
   26   , G2
   27   , ShortRateDynamics
   28   , g2Dynamics
   29   , shortRate
   30   , BatesDetJumpModel
   31   , BatesDoubleExpDetJumpModel
   32   , BatesDoubleExpModel
   33   , GenBatesDoubleExpModel
   34   , LmCorrelationModel(..)
   35   , LmVolatilityModel(..)
   36   , CalibrationHelper
   37   , BlackCalibrationHelper
   38   , GenBlackCalibrationHelper
   39   , SwaptionHelper
   40   , GenCalibrationHelper
   41   , asCalibrationHelper
   42   , asBlackCalibrationHelper
   43 
   44   , asCalibratedModel
   45   , asHestonModel
   46   , asShortRateModel
   47   , asOneFactorAffineModel
   48   , asBatesModel
   49   , asBatesDoubleExpModel
   50   , hullWhiteAsAffineModel
   51   , g2AsAffineModel
   52   , oneFactorAffineModelAsAffineModel
   53   , liborForwardModelAsAffineModel
   54   , gsrAsGaussian1dModel
   55   , markovFunctionalAsGaussian1dModel
   56 
   57   , batesModel
   58   , blackKarasinski
   59   , coxIngersollRoss
   60   , extendedCoxIngersollRoss
   61   , g2
   62   , generalizedHullWhite
   63   , gJRGARCHModel
   64   , hestonModel
   65   , hullWhite
   66   , varianceGammaModel
   67   , vasicek
   68   , liborForwardModel
   69   , gsr
   70   , markovFunctional
   71   , markovFunctionalCaplet
   72 
   73   , calibrate
   74   , calibrateVolatilitiesIterative
   75   , capHelper
   76   , hestonModelHelper
   77   , swaptionHelper
   78   , swaptionHelperFromDate
   79   , swaptionHelperFromDates
   80   , swaptionHelperUnderlying
   81   , swaptionHelperSwaption
   82   , times
   83 
   84   , discountBond
   85   , convexityBias
   86   , fixedReversion
   87   , gsrVolatility
   88   , markovFunctionalVolatility
   89   , params
   90   , value
   91   , blackPrice
   92   , calibrationError
   93   , impliedVolatility
   94   , marketValue
   95   , modelValue
   96   , volatility
   97   , setPricingEngine
   98   ) where
   99 import qualified Foreign.C.Types as C2HSImp
  100 import qualified Foreign.ForeignPtr as C2HSImp
  101 import qualified Foreign.Marshal.Utils as C2HSImp
  102 import qualified Foreign.Ptr as C2HSImp
  103 
  104 
  105 
  106 
  107 
  108 
  109 
  110 
  111 
  112 import QuantLib.Internal
  113 import QuantLib.Time.Schedule(Frequency)
  114 import QuantLib.InterestRate(VolatilityType)
  115 import QuantLib.CashFlow(RateAveragingType)
  116 import QuantLib.Internal.Type
  117 import QuantLib.Internal.Common
  118 
  119 data CalibrationErrorType = RelativePriceError
  120                           | PriceError
  121                           | ImpliedVolError
  122   deriving (Enum,Show,Eq,Read)
  123 
  124 
  125 
  126 
  127 
  128 
  129 
  130 
  131 
  132 
  133 
  134 
  135 
  136 
  137 
  138 
  139 
  140 
  141 
  142 
  143 
  144 
  145 
  146 
  147 
  148 
  149 
  150 
  151 
  152 
  153 
  154 
  155 
  156 
  157 
  158 
  159 
  160 
  161 
  162 
  163 
  164 
  165 
  166 
  167 
  168 
  169 
  170 
  171 
  172 
  173 
  174 
  175 
  176 
  177 
  178 
  179 
  180 
  181 
  182 
  183 
  184 
  185 
  186 
  187 
  188 
  189 
  190 
  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 -- |Bates stochastic-volatility model: extends Heston with jumps in the underlying's return process.
  229 batesModel :: (BatesProcess) -> IO ((BatesModel))
  230 batesModel a1 =
  231   withBatesProcess a1 $ \a1' -> 
  232   preErrorCheck $ \a2' -> 
  233   batesModel'_ a1' a2' >>= \res ->
  234   peekBatesModel res >>= \res' ->
  235   errorCheck  a2'>>
  236   return (res')
  237 
  238 
  239 
  240 -- |Black-Karasinski short-rate model: d(ln r) = (theta(t) - a ln r) dt + sigma dW, with constant reversion @a@ and volatility @sigma@.
  241 blackKarasinski :: (GenYieldTermStructure y) -> (Double) -- ^y
  242  -> (Double) -- ^sigma
  243  -> IO ((ShortRateModel))
  244 blackKarasinski a1 a2 a3 =
  245   withYieldTermStructure a1 $ \a1' -> 
  246   let {a2' = realToFrac a2} in 
  247   let {a3' = realToFrac a3} in 
  248   preErrorCheck $ \a4' -> 
  249   blackKarasinski'_ a1' a2' a3' a4' >>= \res ->
  250   peekShortRateModel res >>= \res' ->
  251   errorCheck  a4'>>
  252   return (res')
  253 
  254 
  255 
  256 -- |Cox-Ingersoll-Ross short-rate model: dr = k(theta - r) dt + sigma sqrt(r) dW.
  257 coxIngersollRoss :: (Double) -- ^r0
  258  -> (Double) -- ^theta
  259  -> (Double) -- ^k
  260  -> (Double) -- ^sigma
  261  -> (Bool) -- ^withFellerConstraint
  262  -> IO ((OneFactorAffineModel))
  263 coxIngersollRoss a1 a2 a3 a4 a5 =
  264   let {a1' = realToFrac a1} in 
  265   let {a2' = realToFrac a2} in 
  266   let {a3' = realToFrac a3} in 
  267   let {a4' = realToFrac a4} in 
  268   let {a5' = C2HSImp.fromBool a5} in 
  269   preErrorCheck $ \a6' -> 
  270   coxIngersollRoss'_ a1' a2' a3' a4' a5' a6' >>= \res ->
  271   peekOneFactorAffineModel res >>= \res' ->
  272   errorCheck  a6'>>
  273   return (res')
  274 
  275 
  276 
  277 -- |Extended CIR model: adds a deterministic term-structure-fitting shift to a standard Cox-Ingersoll-Ross process.
  278 extendedCoxIngersollRoss :: (GenYieldTermStructure y) -> (Double) -- ^theta
  279  -> (Double) -- ^k
  280  -> (Double) -- ^sigma
  281  -> (Double) -- ^x0
  282  -> (Bool) -- ^withFellerConstraint
  283  -> IO ((OneFactorAffineModel))
  284 extendedCoxIngersollRoss a1 a2 a3 a4 a5 a6 =
  285   withYieldTermStructure a1 $ \a1' -> 
  286   let {a2' = realToFrac a2} in 
  287   let {a3' = realToFrac a3} in 
  288   let {a4' = realToFrac a4} in 
  289   let {a5' = realToFrac a5} in 
  290   let {a6' = C2HSImp.fromBool a6} in 
  291   preErrorCheck $ \a7' -> 
  292   extendedCoxIngersollRoss'_ a1' a2' a3' a4' a5' a6' a7' >>= \res ->
  293   peekOneFactorAffineModel res >>= \res' ->
  294   errorCheck  a7'>>
  295   return (res')
  296 
  297 
  298 
  299 -- |Price of a discount bond paying 1 at @maturity@, given the short rate @rate@ at time @now@.
  300 -- Not 'pure': the model's short-rate fitting function depends on its 'YieldTermStructure' handle,
  301 -- which can be relinked after construction, so the result at fixed arguments can change between
  302 -- two calls -- a genuine 'IO' action, not a value fixed at construction time like the other
  303 -- @{#fun pure ...#}@ bindings in this codebase.
  304 discountBond :: (GenOneFactorAffineModel om) -> (Double) -- ^now
  305  -> (Double) -- ^maturity
  306  -> (Double) -- ^rate
  307  -> IO ((Double))
  308 discountBond a1 a2 a3 a4 =
  309   withOneFactorAffineModel a1 $ \a1' -> 
  310   let {a2' = realToFrac a2} in 
  311   let {a3' = realToFrac a3} in 
  312   let {a4' = realToFrac a4} in 
  313   preErrorCheck $ \a5' -> 
  314   discountBond'_ a1' a2' a3' a4' a5' >>= \res ->
  315   let {res' = realToFrac res} in
  316   errorCheck  a5'>>
  317   return (res')
  318 
  319 
  320 
  321 -- |Two-additive-factor Gaussian (G2) short-rate model: the sum of two correlated Ornstein-Uhlenbeck factors.
  322 g2 :: (GenYieldTermStructure y) -> (Double) -- ^y
  323  -> (Double) -- ^sigma
  324  -> (Double) -- ^b
  325  -> (Double) -- ^eta
  326  -> (Double) -- ^rho
  327  -> IO ((G2))
  328 g2 a1 a2 a3 a4 a5 a6 =
  329   withYieldTermStructure a1 $ \a1' -> 
  330   let {a2' = realToFrac a2} in 
  331   let {a3' = realToFrac a3} in 
  332   let {a4' = realToFrac a4} in 
  333   let {a5' = realToFrac a5} in 
  334   let {a6' = realToFrac a6} in 
  335   preErrorCheck $ \a7' -> 
  336   g2'_ a1' a2' a3' a4' a5' a6' a7' >>= \res ->
  337   peekG2 res >>= \res' ->
  338   errorCheck  a7'>>
  339   return (res')
  340 
  341 
  342 
  343 -- |The two-factor short-rate dynamics underlying a 'G2' model (@TwoFactorModel::dynamics()@).
  344 g2Dynamics :: (G2) -> IO ((ShortRateDynamics))
  345 g2Dynamics a1 =
  346   withG2 a1 $ \a1' -> 
  347   preErrorCheck $ \a2' -> 
  348   g2Dynamics'_ a1' a2' >>= \res ->
  349   peekStandalone res >>= \res' ->
  350   errorCheck  a2'>>
  351   return (res')
  352 
  353 
  354 
  355 -- |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)@.
  356 shortRate :: (ShortRateDynamics) -> (Double) -- ^t
  357  -> (Double) -- ^x
  358  -> (Double) -- ^y
  359  -> IO ((Double))
  360 shortRate a1 a2 a3 a4 =
  361   withStandalone a1 $ \a1' -> 
  362   let {a2' = realToFrac a2} in 
  363   let {a3' = realToFrac a3} in 
  364   let {a4' = realToFrac a4} in 
  365   preErrorCheck $ \a5' -> 
  366   shortRate'_ a1' a2' a3' a4' a5' >>= \res ->
  367   let {res' = realToFrac res} in
  368   errorCheck  a5'>>
  369   return (res')
  370 
  371 
  372 
  373 -- |Generalized Hull-White model: like 'hullWhite', but reversion and volatility are piecewise-linear functions of time given at @speedstructure@/@volstructure@ dates.
  374 generalizedHullWhite :: GenYieldTermStructure y -> [(Day, Double)] -- ^speedstructure
  375   -> [(Day, Double)] -- ^volstructure
  376   -> IO ShortRateModel
  377 generalizedHullWhite ts s v = qlGeneralizedHullWhite ts sd vd sq vq where {(sd, sq) = unzip s; (vd, vq) = unzip v}
  378 qlGeneralizedHullWhite :: (GenYieldTermStructure y) -> ([Day]) -> ([Day]) -> ([Double]) -> ([Double]) -> IO ((ShortRateModel))
  379 qlGeneralizedHullWhite a1 a2 a3 a4 a5 =
  380   withYieldTermStructure a1 $ \a1' -> 
  381   withDayArray a2 $ \(a2'1, a2'2) -> 
  382   withDayArray a3 $ \(a3'1, a3'2) -> 
  383   withDoubleArray a4 $ \(a4'1, a4'2) -> 
  384   withDoubleArray a5 $ \(a5'1, a5'2) -> 
  385   preErrorCheck $ \a6' -> 
  386   qlGeneralizedHullWhite'_ a1' a2'1  a2'2 a3'1  a3'2 a4'1  a4'2 a5'1  a5'2 a6' >>= \res ->
  387   peekShortRateModel res >>= \res' ->
  388   errorCheck  a6'>>
  389   return (res')
  390 
  391 
  392 
  393 -- |GJR-GARCH stochastic-volatility model, extending GARCH(1,1) with an asymmetric response to negative return shocks.
  394 gJRGARCHModel :: (GJRGARCHProcess) -> IO ((GJRGARCHModel))
  395 gJRGARCHModel a1 =
  396   withGenStochasticProcess a1 $ \a1' -> 
  397   preErrorCheck $ \a2' -> 
  398   gJRGARCHModel'_ a1' a2' >>= \res ->
  399   peekGJRGARCHModel res >>= \res' ->
  400   errorCheck  a2'>>
  401   return (res')
  402 
  403 
  404 
  405 -- |Heston stochastic-volatility model, calibrated from a 'HestonProcess'.
  406 hestonModel :: (GenHestonProcess hp) -> IO ((HestonModel))
  407 hestonModel a1 =
  408   withHestonProcess a1 $ \a1' -> 
  409   preErrorCheck $ \a2' -> 
  410   hestonModel'_ a1' a2' >>= \res ->
  411   peekHestonModel res >>= \res' ->
  412   errorCheck  a2'>>
  413   return (res')
  414 
  415 
  416 
  417 -- |Single-factor Hull-White (extended Vasicek) short-rate model: dr = (theta(t) - a r) dt + sigma dW, fitted to the given term structure.
  418 hullWhite :: (GenYieldTermStructure y) -> (Double) -- ^y
  419  -> (Double) -- ^sigma
  420  -> IO ((HullWhite))
  421 hullWhite a1 a2 a3 =
  422   withYieldTermStructure a1 $ \a1' -> 
  423   let {a2' = realToFrac a2} in 
  424   let {a3' = realToFrac a3} in 
  425   preErrorCheck $ \a4' -> 
  426   hullWhite'_ a1' a2' a3' a4' >>= \res ->
  427   peekHullWhite res >>= \res' ->
  428   errorCheck  a4'>>
  429   return (res')
  430 
  431 
  432 
  433 -- |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.
  434 -- Not 'pure': 'HullWhite.convexityBias' can throw ('QL_REQUIRE' on its inputs), and letting a C++
  435 -- exception unwind across the FFI boundary from an 'unsafePerformIO'-backed pure binding is undefined
  436 -- behavior, so this needs the same 'char **e'/'preErrorCheck' error channel as any other throwing call.
  437 convexityBias :: (Double) -- ^futurePrice
  438  -> (Double) -- ^t
  439  -> (Double) -- ^T
  440  -> (Double) -- ^sigma
  441  -> (Double) -- ^a
  442  -> IO ((Double))
  443 convexityBias a1 a2 a3 a4 a5 =
  444   let {a1' = realToFrac a1} in 
  445   let {a2' = realToFrac a2} in 
  446   let {a3' = realToFrac a3} in 
  447   let {a4' = realToFrac a4} in 
  448   let {a5' = realToFrac a5} in 
  449   preErrorCheck $ \a6' -> 
  450   convexityBias'_ a1' a2' a3' a4' a5' a6' >>= \res ->
  451   let {res' = realToFrac res} in
  452   errorCheck  a6'>>
  453   return (res')
  454 
  455 
  456 
  457 -- |Marks the reversion (@a@) fixed and volatility (@sigma@) free for 'calibrate''s @fixParameters@ argument. Mirrors @HullWhite::FixedReversion()@.
  458 fixedReversion :: [Bool]
  459 fixedReversion = [True, False]
  460 -- |One-factor GSR model (formulated in the forward measure), with piecewise-constant volatility steps at @volstepdates@ and a single constant reversion.
  461 gsr :: (GenYieldTermStructure y) -> ([Day]) -- ^volstepdates
  462  -> ([GenQuote q1]) -- ^volatilities
  463  -> (GenQuote q2) -- ^reversion
  464  -> (Double) -- ^T
  465  -> IO ((Gsr))
  466 gsr a1 a2 a3 a4 a5 =
  467   withYieldTermStructure a1 $ \a1' -> 
  468   withDayArray a2 $ \(a2'1, a2'2) -> 
  469   withQuoteArray a3 $ \(a3'1, a3'2) -> 
  470   withQuote a4 $ \a4' -> 
  471   let {a5' = realToFrac a5} in 
  472   preErrorCheck $ \a6' -> 
  473   gsr'_ a1' a2'1  a2'2 a3'1  a3'2 a4' a5' a6' >>= \res ->
  474   peekGsr res >>= \res' ->
  475   errorCheck  a6'>>
  476   return (res')
  477 
  478 
  479 
  480 -- |Volatility step values, as calibrated so far.
  481 gsrVolatility :: (Gsr) -> IO (([Double]))
  482 gsrVolatility a1 =
  483   withGenCalibratedModel a1 $ \a1' -> 
  484   preArray $ \(a2'1, a2'2) -> 
  485   preErrorCheck $ \a3' -> 
  486   gsrVolatility'_ a1' a2'1  a2'2 a3' >>
  487   peekDoubleArray  a2'1  a2'2>>= \a2'' -> 
  488   errorCheck  a3'>>
  489   return (a2'')
  490 
  491 
  492 
  493 -- |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).
  494 calibrateVolatilitiesIterative :: (Gsr) -> ([GenBlackCalibrationHelper bch]) -> (OptimizationMethod) -> (EndCriteria) -> (Maybe Constraint) -> ([Double]) -> IO ()
  495 calibrateVolatilitiesIterative a1 a2 a3 a4 a5 a6 =
  496   withGenCalibratedModel a1 $ \a1' -> 
  497   withBlackCalibrationHelperArray a2 $ \(a2'1, a2'2) -> 
  498   withOptimizationMethod a3 $ \a3' -> 
  499   withEndCriteria a4 $ \a4' -> 
  500   withMaybeConstraint a5 $ \a5' -> 
  501   withDoubleArray a6 $ \(a6'1, a6'2) -> 
  502   preErrorCheck $ \a7' -> 
  503   calibrateVolatilitiesIterative'_ a1' a2'1  a2'2 a3' a4' a5' a6'1  a6'2 a7' >>
  504   errorCheck  a7'>>
  505   return ()
  506 
  507 
  508 
  509 -- |Markov-functional interest-rate model, calibrated to a swaption volatility cube against @swapIndexBase@.
  510 markovFunctional :: GenYieldTermStructure y -> Double -- ^reversion
  511   -> [Day] -- ^volstepdates
  512   -> [Double] -- ^volatilities
  513   -> SwaptionVolatilityStructure
  514   -> [Day] -- ^swaptionExpiries
  515   -> [(Word, TimeUnit)] -- ^swaptionTenors
  516   -> GenSwapIndex sidx -- ^swapIndexBase
  517   -> Word -- ^yGridPoints
  518   -> IO MarkovFunctional
  519 markovFunctional ts reversion vsd vs svol se tenors = qlMarkovFunctional ts reversion vsd vs svol se tq tu
  520   where (tq, tu) = unzip tenors
  521 qlMarkovFunctional :: (GenYieldTermStructure y) -> (Double) -> ([Day]) -> ([Double]) -> (GenSwaptionVolatilityStructure sv) -> ([Day]) -> ([Word]) -> ([TimeUnit]) -> (GenSwapIndex sidx) -> (Word) -> IO ((MarkovFunctional))
  522 qlMarkovFunctional a1 a2 a3 a4 a5 a6 a7 a8 a9 a10 =
  523   withYieldTermStructure a1 $ \a1' -> 
  524   let {a2' = realToFrac a2} in 
  525   withDayArray a3 $ \(a3'1, a3'2) -> 
  526   withDoubleArray a4 $ \(a4'1, a4'2) -> 
  527   withSwaptionVolatilityStructure a5 $ \a5' -> 
  528   withDayArray a6 $ \(a6'1, a6'2) -> 
  529   withIntArray a7 $ \(a7'1, a7'2) -> 
  530   withEnumArray a8 $ \(a8'1, a8'2) -> 
  531   withSwapIndex a9 $ \a9' -> 
  532   let {a10' = fromIntegral a10} in 
  533   preErrorCheck $ \a11' -> 
  534   qlMarkovFunctional'_ a1' a2' a3'1  a3'2 a4'1  a4'2 a5' a6'1  a6'2 a7'1  a7'2 a8'1  a8'2 a9' a10' a11' >>= \res ->
  535   peekMarkovFunctional res >>= \res' ->
  536   errorCheck  a11'>>
  537   return (res')
  538 
  539 
  540 
  541 -- |Markov-functional interest-rate model, calibrated to a caplet volatility structure against @iborIndex@.
  542 markovFunctionalCaplet :: (GenYieldTermStructure y) -> (Double) -- ^reversion
  543  -> ([Day]) -- ^volstepdates
  544  -> ([Double]) -- ^volatilities
  545  -> (OptionletVolatilityStructure) -- ^capletVol
  546  -> ([Day]) -- ^capletExpiries
  547  -> (GenIborIndex ibor) -- ^iborIndex
  548  -> (Word) -- ^yGridPoints
  549  -> IO ((MarkovFunctional))
  550 markovFunctionalCaplet a1 a2 a3 a4 a5 a6 a7 a8 =
  551   withYieldTermStructure a1 $ \a1' -> 
  552   let {a2' = realToFrac a2} in 
  553   withDayArray a3 $ \(a3'1, a3'2) -> 
  554   withDoubleArray a4 $ \(a4'1, a4'2) -> 
  555   withOptionletVolatilityStructure a5 $ \a5' -> 
  556   withDayArray a6 $ \(a6'1, a6'2) -> 
  557   withIborIndex a7 $ \a7' -> 
  558   let {a8' = fromIntegral a8} in 
  559   preErrorCheck $ \a9' -> 
  560   markovFunctionalCaplet'_ a1' a2' a3'1  a3'2 a4'1  a4'2 a5' a6'1  a6'2 a7' a8' a9' >>= \res ->
  561   peekMarkovFunctional res >>= \res' ->
  562   errorCheck  a9'>>
  563   return (res')
  564 
  565 
  566 
  567 -- |Volatility step values, as calibrated so far.
  568 markovFunctionalVolatility :: (MarkovFunctional) -> IO (([Double]))
  569 markovFunctionalVolatility a1 =
  570   withGenCalibratedModel a1 $ \a1' -> 
  571   preArray $ \(a2'1, a2'2) -> 
  572   preErrorCheck $ \a3' -> 
  573   markovFunctionalVolatility'_ a1' a2'1  a2'2 a3' >>
  574   peekDoubleArray  a2'1  a2'2>>= \a2'' -> 
  575   errorCheck  a3'>>
  576   return (a2'')
  577 
  578 
  579 
  580 -- |Variance Gamma model for the underlying's log-return process (Madan-Carr-Chang).
  581 varianceGammaModel :: (VarianceGammaProcess) -> IO ((CalibratedModel))
  582 varianceGammaModel a1 =
  583   withGenStochasticProcess1D a1 $ \a1' -> 
  584   preErrorCheck $ \a2' -> 
  585   varianceGammaModel'_ a1' a2' >>= \res ->
  586   peekCalibratedModel res >>= \res' ->
  587   errorCheck  a2'>>
  588   return (res')
  589 
  590 
  591 
  592 -- |Vasicek short-rate model: dr = a(b - r) dt + sigma dW, with an optional risk premium @lambda@.
  593 vasicek :: (Double) -- ^r0
  594  -> (Double) -- ^a
  595  -> (Double) -- ^b
  596  -> (Double) -- ^sigma
  597  -> (Double) -- ^lambda
  598  -> IO ((OneFactorAffineModel))
  599 vasicek a1 a2 a3 a4 a5 =
  600   let {a1' = realToFrac a1} in 
  601   let {a2' = realToFrac a2} in 
  602   let {a3' = realToFrac a3} in 
  603   let {a4' = realToFrac a4} in 
  604   let {a5' = realToFrac a5} in 
  605   preErrorCheck $ \a6' -> 
  606   vasicek'_ a1' a2' a3' a4' a5' a6' >>= \res ->
  607   peekOneFactorAffineModel res >>= \res' ->
  608   errorCheck  a6'>>
  609   return (res')
  610 
  611 
  612 
  613 -- |Libor market (BGM) forward-rate model, built from a 'LiborForwardModelProcess' plus volatility and correlation models.
  614 liborForwardModel :: (LiborForwardModelProcess) -> (LmVolatilityModel) -> (LmCorrelationModel) -> IO ((LiborForwardModel))
  615 liborForwardModel a1 a2 a3 =
  616   withGenStochasticProcess a1 $ \a1' -> 
  617   withLmVolatilityModel a2 $ \a2' -> 
  618   withLmCorrelationModel a3 $ \a3' -> 
  619   preErrorCheck $ \a4' -> 
  620   liborForwardModel'_ a1' a2' a3' a4' >>= \res ->
  621   peekLiborForwardModel res >>= \res' ->
  622   errorCheck  a4'>>
  623   return (res')
  624 
  625 
  626 
  627 -- |Calibrate to a set of market instruments (caps/swaptions)
  628 -- An additional constraint can be passed which must be satisfied in addition to the constraints of the model.
  629 calibrate :: GenCalibratedModel m -> [(GenCalibrationHelper ch, Double)] -- ^(instrument, weight)
  630   -> OptimizationMethod -> EndCriteria -> Maybe Constraint
  631   -> [Bool] -- ^fixParameters, e.g. 'fixedReversion'; @[]@ leaves nothing fixed
  632   -> IO ()
  633 calibrate m h o e c fp = qlCalibratedModelCalibrate m hh hw o e c fp where (hh, hw) = unzip h
  634 qlCalibratedModelCalibrate :: (GenCalibratedModel m) -> ([GenCalibrationHelper ch]) -> ([Double]) -> (OptimizationMethod) -> (EndCriteria) -> (Maybe Constraint) -> ([Bool]) -> IO ()
  635 qlCalibratedModelCalibrate a1 a2 a3 a4 a5 a6 a7 =
  636   withCalibratedModel a1 $ \a1' -> 
  637   withCalibrationHelperArray a2 $ \(a2'1, a2'2) -> 
  638   withDoubleArray a3 $ \(a3'1, a3'2) -> 
  639   withOptimizationMethod a4 $ \a4' -> 
  640   withEndCriteria a5 $ \a5' -> 
  641   withMaybeConstraint a6 $ \a6' -> 
  642   withBoolArray a7 $ \(a7'1, a7'2) -> 
  643   preErrorCheck $ \a8' -> 
  644   qlCalibratedModelCalibrate'_ a1' a2'1  a2'2 a3'1  a3'2 a4' a5' a6' a7'1  a7'2 a8' >>
  645   errorCheck  a8'>>
  646   return ()
  647 
  648 
  649 
  650 -- |Objective function value at @params@ for the given calibration instruments.
  651 value :: (GenCalibratedModel m) -> ([Double]) -> ([GenCalibrationHelper ch]) -> IO ((Double))
  652 value a1 a2 a3 =
  653   withCalibratedModel a1 $ \a1' -> 
  654   withDoubleArray a2 $ \(a2'1, a2'2) -> 
  655   withCalibrationHelperArray a3 $ \(a3'1, a3'2) -> 
  656   preErrorCheck $ \a4' -> 
  657   value'_ a1' a2'1  a2'2 a3'1  a3'2 a4' >>= \res ->
  658   let {res' = realToFrac res} in
  659   errorCheck  a4'>>
  660   return (res')
  661 
  662 
  663 
  664 -- |Calibration helper for an at-the-money interest-rate cap.
  665 capHelper :: ((Word,TimeUnit)) -- ^length
  666  -> (GenQuote q) -- ^volatility
  667  -> (GenIborIndex ibor) -> (Frequency) -- ^fixedLegFrequency
  668  -> (DayCounter) -> (Bool) -- ^includeFirstSwaplet
  669  -> (GenYieldTermStructure y) -> (CalibrationErrorType) -> (VolatilityType) -- ^type
  670  -> (Double) -- ^shift
  671  -> IO ((BlackCalibrationHelper))
  672 capHelper a1 a2 a3 a4 a5 a6 a7 a8 a9 a10 =
  673   let {(a1'1, a1'2) = fromEnumQuantity a1} in 
  674   withQuote a2 $ \a2' -> 
  675   withIborIndex a3 $ \a3' -> 
  676   let {a4' = (fromIntegral . fromEnum) a4} in 
  677   withDayCounter a5 $ \a5' -> 
  678   let {a6' = C2HSImp.fromBool a6} in 
  679   withYieldTermStructure a7 $ \a7' -> 
  680   let {a8' = (fromIntegral . fromEnum) a8} in 
  681   let {a9' = (fromIntegral . fromEnum) a9} in 
  682   let {a10' = realToFrac a10} in 
  683   preErrorCheck $ \a11' -> 
  684   capHelper'_ a1'1  a1'2 a2' a3' a4' a5' a6' a7' a8' a9' a10' a11' >>= \res ->
  685   peekBlackCalibrationHelper res >>= \res' ->
  686   errorCheck  a11'>>
  687   return (res')
  688 
  689 
  690 
  691 -- |Calibration helper for the Heston model, from a European option's market volatility.
  692 hestonModelHelper :: ((Word,TimeUnit)) -- ^maturity
  693  -> (Calendar) -> (GenQuote q1) -- ^s0
  694  -> (Double) -- ^strikePrice
  695  -> (GenQuote q2) -- ^volatility
  696  -> (GenYieldTermStructure y1) -- ^riskFreeRate
  697  -> (GenYieldTermStructure y2) -- ^dividendYield
  698  -> (CalibrationErrorType) -> IO ((BlackCalibrationHelper))
  699 hestonModelHelper a1 a2 a3 a4 a5 a6 a7 a8 =
  700   let {(a1'1, a1'2) = fromEnumQuantity a1} in 
  701   withCalendar a2 $ \a2' -> 
  702   withQuote a3 $ \a3' -> 
  703   let {a4' = realToFrac a4} in 
  704   withQuote a5 $ \a5' -> 
  705   withYieldTermStructure a6 $ \a6' -> 
  706   withYieldTermStructure a7 $ \a7' -> 
  707   let {a8' = (fromIntegral . fromEnum) a8} in 
  708   preErrorCheck $ \a9' -> 
  709   hestonModelHelper'_ a1'1  a1'2 a2' a3' a4' a5' a6' a7' a8' a9' >>= \res ->
  710   peekBlackCalibrationHelper res >>= \res' ->
  711   errorCheck  a9'>>
  712   return (res')
  713 
  714 
  715 
  716 -- |Calibration helper for a European swaption, with the exercise given as a maturity 'Period' from today.
  717 swaptionHelper :: ((Word,TimeUnit)) -- ^maturity
  718  -> ((Word,TimeUnit)) -- ^length
  719  -> (GenQuote q) -- ^maturity
  720  -> (GenIborIndex ibor) -> ((Word,TimeUnit)) -- ^fixedLegTenor
  721  -> (DayCounter) -- ^fixedLegDayCounter
  722  -> (DayCounter) -- ^floatingLegDayCounter
  723  -> (GenYieldTermStructure y) -> (CalibrationErrorType) -> (Maybe Double) -- ^strike
  724  -> (Double) -- ^nominal
  725  -> (VolatilityType) -- ^type
  726  -> (Double) -- ^shift
  727  -> (Maybe Word) -- ^settlementDays
  728  -> (RateAveragingType) -- ^averagingMethod
  729  -> IO ((SwaptionHelper))
  730 swaptionHelper a1 a2 a3 a4 a5 a6 a7 a8 a9 a10 a11 a12 a13 a14 a15 =
  731   let {(a1'1, a1'2) = fromEnumQuantity a1} in 
  732   let {(a2'1, a2'2) = fromEnumQuantity a2} in 
  733   withQuote a3 $ \a3' -> 
  734   withIborIndex a4 $ \a4' -> 
  735   let {(a5'1, a5'2) = fromEnumQuantity a5} in 
  736   withDayCounter a6 $ \a6' -> 
  737   withDayCounter a7 $ \a7' -> 
  738   withYieldTermStructure a8 $ \a8' -> 
  739   let {a9' = (fromIntegral . fromEnum) a9} in 
  740   let {a10' = fromMaybeDouble a10} in 
  741   let {a11' = realToFrac a11} in 
  742   let {a12' = (fromIntegral . fromEnum) a12} in 
  743   let {a13' = realToFrac a13} in 
  744   let {a14' = fromMaybeInt a14} in 
  745   let {a15' = (fromIntegral . fromEnum) a15} in 
  746   preErrorCheck $ \a16' -> 
  747   swaptionHelper'_ a1'1  a1'2 a2'1  a2'2 a3' a4' a5'1  a5'2 a6' a7' a8' a9' a10' a11' a12' a13' a14' a15' a16' >>= \res ->
  748   peekSwaptionHelper res >>= \res' ->
  749   errorCheck  a16'>>
  750   return (res')
  751 
  752 
  753 
  754 -- |Like 'swaptionHelper', but the option's exercise is given as an explicit date rather than a maturity 'Period'.
  755 swaptionHelperFromDate :: (Day) -- ^exerciseDate
  756  -> ((Word,TimeUnit)) -- ^length
  757  -> (GenQuote q) -- ^maturity
  758  -> (GenIborIndex ibor) -> ((Word,TimeUnit)) -- ^fixedLegTenor
  759  -> (DayCounter) -- ^fixedLegDayCounter
  760  -> (DayCounter) -- ^floatingLegDayCounter
  761  -> (GenYieldTermStructure y) -> (CalibrationErrorType) -> (Maybe Double) -- ^strike
  762  -> (Double) -- ^nominal
  763  -> (VolatilityType) -- ^type
  764  -> (Double) -- ^shift
  765  -> (Maybe Word) -- ^settlementDays
  766  -> (RateAveragingType) -- ^averagingMethod
  767  -> IO ((SwaptionHelper))
  768 swaptionHelperFromDate a1 a2 a3 a4 a5 a6 a7 a8 a9 a10 a11 a12 a13 a14 a15 =
  769   withDay a1 $ \a1' -> 
  770   let {(a2'1, a2'2) = fromEnumQuantity a2} in 
  771   withQuote a3 $ \a3' -> 
  772   withIborIndex a4 $ \a4' -> 
  773   let {(a5'1, a5'2) = fromEnumQuantity a5} in 
  774   withDayCounter a6 $ \a6' -> 
  775   withDayCounter a7 $ \a7' -> 
  776   withYieldTermStructure a8 $ \a8' -> 
  777   let {a9' = (fromIntegral . fromEnum) a9} in 
  778   let {a10' = fromMaybeDouble a10} in 
  779   let {a11' = realToFrac a11} in 
  780   let {a12' = (fromIntegral . fromEnum) a12} in 
  781   let {a13' = realToFrac a13} in 
  782   let {a14' = fromMaybeInt a14} in 
  783   let {a15' = (fromIntegral . fromEnum) a15} in 
  784   preErrorCheck $ \a16' -> 
  785   swaptionHelperFromDate'_ a1' a2'1  a2'2 a3' a4' a5'1  a5'2 a6' a7' a8' a9' a10' a11' a12' a13' a14' a15' a16' >>= \res ->
  786   peekSwaptionHelper res >>= \res' ->
  787   errorCheck  a16'>>
  788   return (res')
  789 
  790 
  791 
  792 -- |Like 'swaptionHelper', but both the option's exercise and the underlying swap's end are given as explicit dates.
  793 swaptionHelperFromDates :: (Day) -- ^exerciseDate
  794  -> (Day) -- ^endDate
  795  -> (GenQuote q) -- ^maturity
  796  -> (GenIborIndex ibor) -> ((Word,TimeUnit)) -- ^fixedLegTenor
  797  -> (DayCounter) -- ^fixedLegDayCounter
  798  -> (DayCounter) -- ^floatingLegDayCounter
  799  -> (GenYieldTermStructure y) -> (CalibrationErrorType) -> (Maybe Double) -- ^strike
  800  -> (Double) -- ^nominal
  801  -> (VolatilityType) -- ^type
  802  -> (Double) -- ^shift
  803  -> (Maybe Word) -- ^settlementDays
  804  -> (RateAveragingType) -- ^averagingMethod
  805  -> IO ((SwaptionHelper))
  806 swaptionHelperFromDates a1 a2 a3 a4 a5 a6 a7 a8 a9 a10 a11 a12 a13 a14 a15 =
  807   withDay a1 $ \a1' -> 
  808   withDay a2 $ \a2' -> 
  809   withQuote a3 $ \a3' -> 
  810   withIborIndex a4 $ \a4' -> 
  811   let {(a5'1, a5'2) = fromEnumQuantity a5} in 
  812   withDayCounter a6 $ \a6' -> 
  813   withDayCounter a7 $ \a7' -> 
  814   withYieldTermStructure a8 $ \a8' -> 
  815   let {a9' = (fromIntegral . fromEnum) a9} in 
  816   let {a10' = fromMaybeDouble a10} in 
  817   let {a11' = realToFrac a11} in 
  818   let {a12' = (fromIntegral . fromEnum) a12} in 
  819   let {a13' = realToFrac a13} in 
  820   let {a14' = fromMaybeInt a14} in 
  821   let {a15' = (fromIntegral . fromEnum) a15} in 
  822   preErrorCheck $ \a16' -> 
  823   swaptionHelperFromDates'_ a1' a2' a3' a4' a5'1  a5'2 a6' a7' a8' a9' a10' a11' a12' a13' a14' a15' a16' >>= \res ->
  824   peekSwaptionHelper res >>= \res' ->
  825   errorCheck  a16'>>
  826   return (res')
  827 
  828 
  829 
  830 -- |Upstream's own vanilla swap underlying this helper's swaption.
  831 swaptionHelperUnderlying :: (SwaptionHelper) -> IO ((FixedVsFloatingSwap))
  832 swaptionHelperUnderlying a1 =
  833   withSwaptionHelper a1 $ \a1' -> 
  834   preErrorCheck $ \a2' -> 
  835   swaptionHelperUnderlying'_ a1' a2' >>= \res ->
  836   peekFixedVsFloatingSwap res >>= \res' ->
  837   errorCheck  a2'>>
  838   return (res')
  839 
  840 
  841 
  842 -- |The 'QuantLib.Instrument.Swap.Swaption' this helper prices internally to compute 'modelValue'.
  843 swaptionHelperSwaption :: (SwaptionHelper) -> IO ((Swaption))
  844 swaptionHelperSwaption a1 =
  845   withSwaptionHelper a1 $ \a1' -> 
  846   preErrorCheck $ \a2' -> 
  847   swaptionHelperSwaption'_ a1' a2' >>= \res ->
  848   peekSwaption res >>= \res' ->
  849   errorCheck  a2'>>
  850   return (res')
  851 
  852 
  853 
  854 -- |Times relevant to pricing this calibration helper's instrument, to be added to the model's evolution time grid.
  855 times :: (GenBlackCalibrationHelper bch) -> IO (([Double]))
  856 times a1 =
  857   withBlackCalibrationHelper a1 $ \a1' -> 
  858   preArray $ \(a2'1, a2'2) -> 
  859   preErrorCheck $ \a3' -> 
  860   times'_ a1' a2'1  a2'2 a3' >>
  861   peekDoubleArray  a2'1  a2'2>>= \a2'' -> 
  862   errorCheck  a3'>>
  863   return (a2'')
  864 
  865 
  866 
  867 -- |Returns array of arguments on which calibration is done.
  868 params :: (GenCalibratedModel m) -> IO (([Double]))
  869 params a1 =
  870   withCalibratedModel a1 $ \a1' -> 
  871   preArray $ \(a2'1, a2'2) -> 
  872   preErrorCheck $ \a3' -> 
  873   params'_ a1' a2'1  a2'2 a3' >>
  874   peekDoubleArray  a2'1  a2'2>>= \a2'' -> 
  875   errorCheck  a3'>>
  876   return (a2'')
  877 
  878 
  879 
  880 -- |Black price given a volatility.
  881 blackPrice :: (GenBlackCalibrationHelper bch) -> (Double) -- ^volatility
  882  -> IO ((Double))
  883 blackPrice a1 a2 =
  884   withBlackCalibrationHelper a1 $ \a1' -> 
  885   let {a2' = realToFrac a2} in 
  886   preErrorCheck $ \a3' -> 
  887   blackPrice'_ a1' a2' a3' >>= \res ->
  888   let {res' = realToFrac res} in
  889   errorCheck  a3'>>
  890   return (res')
  891 
  892 
  893 
  894 -- |returns the error resulting from the model valuation
  895 calibrationError :: (GenBlackCalibrationHelper bch) -> IO ((Double))
  896 calibrationError a1 =
  897   withBlackCalibrationHelper a1 $ \a1' -> 
  898   preErrorCheck $ \a2' -> 
  899   calibrationError'_ a1' a2' >>= \res ->
  900   let {res' = realToFrac res} in
  901   errorCheck  a2'>>
  902   return (res')
  903 
  904 
  905 
  906 -- |Black volatility implied by the model.
  907 impliedVolatility :: (GenBlackCalibrationHelper bch) -> (Double) -- ^targetValue
  908  -> (Double) -- ^accuracy
  909  -> (Word) -- ^maxEvaluations
  910  -> (Double) -- ^minVol
  911  -> (Double) -- ^maxVol
  912  -> IO ((Double))
  913 impliedVolatility a1 a2 a3 a4 a5 a6 =
  914   withBlackCalibrationHelper a1 $ \a1' -> 
  915   let {a2' = realToFrac a2} in 
  916   let {a3' = realToFrac a3} in 
  917   let {a4' = fromIntegral a4} in 
  918   let {a5' = realToFrac a5} in 
  919   let {a6' = realToFrac a6} in 
  920   preErrorCheck $ \a7' -> 
  921   impliedVolatility'_ a1' a2' a3' a4' a5' a6' a7' >>= \res ->
  922   let {res' = realToFrac res} in
  923   errorCheck  a7'>>
  924   return (res')
  925 
  926 
  927 
  928 -- |returns the actual price of the instrument (from volatility)
  929 marketValue :: (GenBlackCalibrationHelper bch) -> IO ((Double))
  930 marketValue a1 =
  931   withBlackCalibrationHelper a1 $ \a1' -> 
  932   preErrorCheck $ \a2' -> 
  933   marketValue'_ a1' a2' >>= \res ->
  934   let {res' = realToFrac res} in
  935   errorCheck  a2'>>
  936   return (res')
  937 
  938 
  939 
  940 -- |returns the price of the instrument according to the model
  941 modelValue :: (GenBlackCalibrationHelper bch) -> IO ((Double))
  942 modelValue a1 =
  943   withBlackCalibrationHelper a1 $ \a1' -> 
  944   preErrorCheck $ \a2' -> 
  945   modelValue'_ a1' a2' >>= \res ->
  946   let {res' = realToFrac res} in
  947   errorCheck  a2'>>
  948   return (res')
  949 
  950 
  951 
  952 -- |The quoted market volatility this helper was built with.
  953 volatility :: (GenBlackCalibrationHelper bch) -> IO ((Quote))
  954 volatility a1 =
  955   withBlackCalibrationHelper a1 $ \a1' -> 
  956   preErrorCheck $ \a2' -> 
  957   volatility'_ a1' a2' >>= \res ->
  958   peekQuote res >>= \res' ->
  959   errorCheck  a2'>>
  960   return (res')
  961 
  962 
  963 
  964 -- |Sets the pricing engine used to compute this calibration helper's model value.
  965 setPricingEngine :: (GenBlackCalibrationHelper bch) -> (PricingEngine) -> IO ()
  966 setPricingEngine a1 a2 =
  967   withBlackCalibrationHelper a1 $ \a1' -> 
  968   withPricingEngine a2 $ \a2' -> 
  969   preErrorCheck $ \a3' -> 
  970   setPricingEngine'_ a1' a2' a3' >>
  971   errorCheck  a3'>>
  972   return ()
  973 
  974 
  975 
  976 -- vim: set ff=unix ts=8 sts=2 sw=2 et:
  977 
  978 foreign import ccall safe "QuantLib/Model.chs.h qlBatesModel"
  979   batesModel'_ :: ((C2HSImp.Ptr (CBatesProcess')) -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO (C2HSImp.Ptr (CBatesModel')))))
  980 
  981 foreign import ccall safe "QuantLib/Model.chs.h qlBlackKarasinski"
  982   blackKarasinski'_ :: ((C2HSImp.Ptr (CYieldTermStructure')) -> (C2HSImp.CDouble -> (C2HSImp.CDouble -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO (C2HSImp.Ptr (CShortRateModel')))))))
  983 
  984 foreign import ccall safe "QuantLib/Model.chs.h qlCoxIngersollRoss"
  985   coxIngersollRoss'_ :: (C2HSImp.CDouble -> (C2HSImp.CDouble -> (C2HSImp.CDouble -> (C2HSImp.CDouble -> (C2HSImp.CInt -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO (C2HSImp.Ptr (COneFactorAffineModel')))))))))
  986 
  987 foreign import ccall safe "QuantLib/Model.chs.h qlExtendedCoxIngersollRoss"
  988   extendedCoxIngersollRoss'_ :: ((C2HSImp.Ptr (CYieldTermStructure')) -> (C2HSImp.CDouble -> (C2HSImp.CDouble -> (C2HSImp.CDouble -> (C2HSImp.CDouble -> (C2HSImp.CInt -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO (C2HSImp.Ptr (COneFactorAffineModel'))))))))))
  989 
  990 foreign import ccall safe "QuantLib/Model.chs.h qlOneFactorAffineModelDiscountBond"
  991   discountBond'_ :: ((C2HSImp.Ptr (COneFactorAffineModel')) -> (C2HSImp.CDouble -> (C2HSImp.CDouble -> (C2HSImp.CDouble -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO C2HSImp.CDouble))))))
  992 
  993 foreign import ccall safe "QuantLib/Model.chs.h qlG2"
  994   g2'_ :: ((C2HSImp.Ptr (CYieldTermStructure')) -> (C2HSImp.CDouble -> (C2HSImp.CDouble -> (C2HSImp.CDouble -> (C2HSImp.CDouble -> (C2HSImp.CDouble -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO (C2HSImp.Ptr (CG2'))))))))))
  995 
  996 foreign import ccall safe "QuantLib/Model.chs.h qlG2Dynamics"
  997   g2Dynamics'_ :: ((C2HSImp.Ptr (CG2')) -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO (C2HSImp.Ptr (CShortRateDynamics')))))
  998 
  999 foreign import ccall safe "QuantLib/Model.chs.h qlShortRateDynamicsShortRate"
 1000   shortRate'_ :: ((C2HSImp.Ptr (CShortRateDynamics')) -> (C2HSImp.CDouble -> (C2HSImp.CDouble -> (C2HSImp.CDouble -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO C2HSImp.CDouble))))))
 1001 
 1002 foreign import ccall safe "QuantLib/Model.chs.h qlGeneralizedHullWhite"
 1003   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 C2HSImp.CChar)) -> (IO (C2HSImp.Ptr (CShortRateModel')))))))))))))
 1004 
 1005 foreign import ccall safe "QuantLib/Model.chs.h qlGJRGARCHModel"
 1006   gJRGARCHModel'_ :: ((C2HSImp.Ptr (CGJRGARCHProcess')) -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO (C2HSImp.Ptr (CGJRGARCHModel')))))
 1007 
 1008 foreign import ccall safe "QuantLib/Model.chs.h qlHestonModel"
 1009   hestonModel'_ :: ((C2HSImp.Ptr (CHestonProcess')) -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO (C2HSImp.Ptr (CHestonModel')))))
 1010 
 1011 foreign import ccall safe "QuantLib/Model.chs.h qlHullWhite"
 1012   hullWhite'_ :: ((C2HSImp.Ptr (CYieldTermStructure')) -> (C2HSImp.CDouble -> (C2HSImp.CDouble -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO (C2HSImp.Ptr (CHullWhite')))))))
 1013 
 1014 foreign import ccall safe "QuantLib/Model.chs.h qlHullWhiteConvexityBias"
 1015   convexityBias'_ :: (C2HSImp.CDouble -> (C2HSImp.CDouble -> (C2HSImp.CDouble -> (C2HSImp.CDouble -> (C2HSImp.CDouble -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO C2HSImp.CDouble)))))))
 1016 
 1017 foreign import ccall safe "QuantLib/Model.chs.h qlGsr"
 1018   gsr'_ :: ((C2HSImp.Ptr (CYieldTermStructure')) -> (C2HSImp.CUInt -> ((C2HSImp.Ptr C2HSImp.CInt) -> (C2HSImp.CUInt -> ((C2HSImp.Ptr (C2HSImp.Ptr (CQuote'))) -> ((C2HSImp.Ptr (CQuote')) -> (C2HSImp.CDouble -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO (C2HSImp.Ptr (CGsr')))))))))))
 1019 
 1020 foreign import ccall safe "QuantLib/Model.chs.h qlGsrVolatility"
 1021   gsrVolatility'_ :: ((C2HSImp.Ptr (CGsr')) -> ((C2HSImp.Ptr C2HSImp.CUInt) -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CDouble)) -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO ())))))
 1022 
 1023 foreign import ccall safe "QuantLib/Model.chs.h qlGsrCalibrateVolatilitiesIterative"
 1024   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 C2HSImp.CChar)) -> (IO ()))))))))))
 1025 
 1026 foreign import ccall safe "QuantLib/Model.chs.h qlMarkovFunctional"
 1027   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 C2HSImp.CChar)) -> (IO (C2HSImp.Ptr (CMarkovFunctional')))))))))))))))))))
 1028 
 1029 foreign import ccall safe "QuantLib/Model.chs.h qlMarkovFunctionalCaplet"
 1030   markovFunctionalCaplet'_ :: ((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 C2HSImp.CChar)) -> (IO (C2HSImp.Ptr (CMarkovFunctional')))))))))))))))
 1031 
 1032 foreign import ccall safe "QuantLib/Model.chs.h qlMarkovFunctionalVolatility"
 1033   markovFunctionalVolatility'_ :: ((C2HSImp.Ptr (CMarkovFunctional')) -> ((C2HSImp.Ptr C2HSImp.CUInt) -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CDouble)) -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO ())))))
 1034 
 1035 foreign import ccall safe "QuantLib/Model.chs.h qlVarianceGammaModel"
 1036   varianceGammaModel'_ :: ((C2HSImp.Ptr (CVarianceGammaProcess')) -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO (C2HSImp.Ptr (CCalibratedModel')))))
 1037 
 1038 foreign import ccall safe "QuantLib/Model.chs.h qlVasicek"
 1039   vasicek'_ :: (C2HSImp.CDouble -> (C2HSImp.CDouble -> (C2HSImp.CDouble -> (C2HSImp.CDouble -> (C2HSImp.CDouble -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO (C2HSImp.Ptr (COneFactorAffineModel')))))))))
 1040 
 1041 foreign import ccall safe "QuantLib/Model.chs.h qlLiborForwardModel"
 1042   liborForwardModel'_ :: ((C2HSImp.Ptr (CLiborForwardModelProcess')) -> ((C2HSImp.Ptr (CLmVolatilityModel)) -> ((C2HSImp.Ptr (CLmCorrelationModel)) -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO (C2HSImp.Ptr (CLiborForwardModel')))))))
 1043 
 1044 foreign import ccall safe "QuantLib/Model.chs.h qlCalibratedModelCalibrate"
 1045   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 C2HSImp.CChar)) -> (IO ()))))))))))))
 1046 
 1047 foreign import ccall safe "QuantLib/Model.chs.h qlCalibratedModelValue"
 1048   value'_ :: ((C2HSImp.Ptr (CCalibratedModel')) -> (C2HSImp.CUInt -> ((C2HSImp.Ptr C2HSImp.CDouble) -> (C2HSImp.CUInt -> ((C2HSImp.Ptr (C2HSImp.Ptr (CCalibrationHelper'))) -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO C2HSImp.CDouble)))))))
 1049 
 1050 foreign import ccall safe "QuantLib/Model.chs.h qlCapHelper"
 1051   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 C2HSImp.CChar)) -> (IO (C2HSImp.Ptr (CBlackCalibrationHelper')))))))))))))))
 1052 
 1053 foreign import ccall safe "QuantLib/Model.chs.h qlHestonModelHelper"
 1054   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 C2HSImp.CChar)) -> (IO (C2HSImp.Ptr (CBlackCalibrationHelper')))))))))))))
 1055 
 1056 foreign import ccall safe "QuantLib/Model.chs.h qlSwaptionHelper"
 1057   swaptionHelper'_ :: (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 C2HSImp.CChar)) -> (IO (C2HSImp.Ptr (CSwaptionHelper'))))))))))))))))))))))
 1058 
 1059 foreign import ccall safe "QuantLib/Model.chs.h qlSwaptionHelperFromDate"
 1060   swaptionHelperFromDate'_ :: (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 C2HSImp.CChar)) -> (IO (C2HSImp.Ptr (CSwaptionHelper')))))))))))))))))))))
 1061 
 1062 foreign import ccall safe "QuantLib/Model.chs.h qlSwaptionHelperFromDates"
 1063   swaptionHelperFromDates'_ :: (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 C2HSImp.CChar)) -> (IO (C2HSImp.Ptr (CSwaptionHelper'))))))))))))))))))))
 1064 
 1065 foreign import ccall safe "QuantLib/Model.chs.h qlSwaptionHelperUnderlying"
 1066   swaptionHelperUnderlying'_ :: ((C2HSImp.Ptr (CSwaptionHelper')) -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO (C2HSImp.Ptr (CFixedVsFloatingSwap')))))
 1067 
 1068 foreign import ccall safe "QuantLib/Model.chs.h qlSwaptionHelperSwaption"
 1069   swaptionHelperSwaption'_ :: ((C2HSImp.Ptr (CSwaptionHelper')) -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO (C2HSImp.Ptr (CSwaption')))))
 1070 
 1071 foreign import ccall safe "QuantLib/Model.chs.h qlBlackCalibrationHelperTimes"
 1072   times'_ :: ((C2HSImp.Ptr (CBlackCalibrationHelper')) -> ((C2HSImp.Ptr C2HSImp.CUInt) -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CDouble)) -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO ())))))
 1073 
 1074 foreign import ccall safe "QuantLib/Model.chs.h qlCalibratedModelParams"
 1075   params'_ :: ((C2HSImp.Ptr (CCalibratedModel')) -> ((C2HSImp.Ptr C2HSImp.CUInt) -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CDouble)) -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO ())))))
 1076 
 1077 foreign import ccall safe "QuantLib/Model.chs.h qlBlackCalibrationHelperBlackPrice"
 1078   blackPrice'_ :: ((C2HSImp.Ptr (CBlackCalibrationHelper')) -> (C2HSImp.CDouble -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO C2HSImp.CDouble))))
 1079 
 1080 foreign import ccall safe "QuantLib/Model.chs.h qlBlackCalibrationHelperCalibrationError"
 1081   calibrationError'_ :: ((C2HSImp.Ptr (CBlackCalibrationHelper')) -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO C2HSImp.CDouble)))
 1082 
 1083 foreign import ccall safe "QuantLib/Model.chs.h qlBlackCalibrationHelperImpliedVolatility"
 1084   impliedVolatility'_ :: ((C2HSImp.Ptr (CBlackCalibrationHelper')) -> (C2HSImp.CDouble -> (C2HSImp.CDouble -> (C2HSImp.CUInt -> (C2HSImp.CDouble -> (C2HSImp.CDouble -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO C2HSImp.CDouble))))))))
 1085 
 1086 foreign import ccall safe "QuantLib/Model.chs.h qlBlackCalibrationHelperMarketValue"
 1087   marketValue'_ :: ((C2HSImp.Ptr (CBlackCalibrationHelper')) -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO C2HSImp.CDouble)))
 1088 
 1089 foreign import ccall safe "QuantLib/Model.chs.h qlBlackCalibrationHelperModelValue"
 1090   modelValue'_ :: ((C2HSImp.Ptr (CBlackCalibrationHelper')) -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO C2HSImp.CDouble)))
 1091 
 1092 foreign import ccall safe "QuantLib/Model.chs.h qlBlackCalibrationHelperVolatility"
 1093   volatility'_ :: ((C2HSImp.Ptr (CBlackCalibrationHelper')) -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO (C2HSImp.Ptr (CQuote')))))
 1094 
 1095 foreign import ccall safe "QuantLib/Model.chs.h qlBlackCalibrationHelperSetPricingEngine"
 1096   setPricingEngine'_ :: ((C2HSImp.Ptr (CBlackCalibrationHelper')) -> ((C2HSImp.Ptr (CPricingEngine)) -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO ()))))