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.Instrument.Option
    7   (
    8     -- * Types
    9     -- ** Option hierarchy
   10     GenOption
   11   , Option
   12   , GenOneAssetOption
   13   , OneAssetOption
   14   , GenMultiAssetOption
   15   , MultiAssetOption
   16   , CdsOption
   17   , BarrierOption
   18   , DoubleBarrierOption
   19   , EverestOption
   20   , MargrabeOption
   21   , QuantoBarrierOption
   22   , QuantoDoubleBarrierOption
   23   , QuantoForwardVanillaOption
   24   , QuantoVanillaOption
   25   , SoftBarrierOption
   26   , VanillaOption
   27 
   28     -- ** Exercises
   29   , ExerciseType(..)
   30   , Exercise(..)
   31   , EuropeanExercise(..)
   32   , BermudanExercise(..)
   33   , SwingExercise(..)
   34 
   35     -- ** Option conventions
   36   , OptionType(..)
   37   , PositionType(..)
   38 
   39     -- ** Payoffs
   40   , StrikedPayoff(..)
   41   , PlainVanillaPayoff(..)
   42   , PercentageStrikePayoff(..)
   43   , BasketPayoff(..)
   44   , Payoff(..)
   45   , TypePayoff(..)
   46 
   47     -- * Constructors
   48     -- ** Hierarchy conversion
   49   , asOption
   50   , asOneAssetOption
   51 
   52     -- ** Payoffs and exercises
   53   , strikedPayoff
   54   , plainVanillaPayoff
   55   , percentageStrikePayoff
   56   , withCustomPayoff
   57   , withCustomStrikedPayoff
   58   , withCustomBasketPayoff
   59   , swingExercise
   60 
   61     -- ** Barrier, chooser and multi-asset options
   62   , barrierOption
   63   , partialTimeBarrierOption
   64   , doubleBarrierOption
   65   , softBarrierOption
   66   , forwardVanillaOption
   67   , compoundOption
   68   , margrabeOption
   69   , simpleChooserOption
   70   , complexChooserOption
   71   , twoAssetCorrelationOption
   72   , writerExtensibleOption
   73   , holderExtensibleOption
   74 
   75     -- ** Vanilla, quanto and path-dependent options
   76   , multiAssetOption
   77   , oneAssetOption
   78   , quantoBarrierOption
   79   , quantoDoubleBarrierOption
   80   , quantoForwardVanillaOption
   81   , quantoVanillaOption
   82   , twoAssetBarrierOption
   83   , vanillaOption
   84   , basketOption
   85   , himalayaOption
   86   , pagodaOption
   87   , cliquetOption
   88   , continuousAveragingAsianOption
   89   , continuousFixedLookbackOption
   90   , continuousFloatingLookbackOption
   91   , continuousPartialFixedLookbackOption
   92   , continuousPartialFloatingLookbackOption
   93   , everestOption
   94   , discreteAveragingAsianOption
   95   , vanillaStorageOption
   96   , vanillaSwingOption
   97   , europeanOption
   98 
   99     -- * Inspectors
  100     -- ** Implied volatility
  101   , HasImpliedVol(..)
  102   , doubleBarrierOptionImpliedVolatility
  103   , softBarrierOptionImpliedVolatility
  104     -- ** Sensitivities and probabilities
  105   , HasGreeks(..)
  106   , HasQuanto(..)
  107   , firstAssetDelta
  108   , secondAssetDelta
  109   , firstAssetGamma
  110   , secondAssetGamma
  111   , deltaForward
  112   , elasticity
  113   , itmCashProbability
  114   , strikeSensitivity
  115   , thetaPerDay
  116   , yield
  117 
  118   ) where
  119 import qualified Foreign.C.Types as C2HSImp
  120 import qualified Foreign.ForeignPtr as C2HSImp
  121 import qualified Foreign.Ptr as C2HSImp
  122 
  123 
  124 
  125 
  126 
  127 
  128 
  129 
  130 import QuantLib.Internal
  131 import QuantLib.Instrument(AverageType, BarrierType, DoubleBarrierType, PartialBarrierRange)
  132 import QuantLib.Internal.Type
  133 import QuantLib.Internal.Common
  134 import Data.List.NonEmpty(NonEmpty, toList)
  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 -- |Quanto version of a forward-starting (strike-resetting) vanilla option.
  188 quantoForwardVanillaOption :: (Double) -- ^moneyness
  189  -> (Day) -- ^resetDate
  190  -> (StrikedPayoff) -> (Exercise) -> IO ((QuantoForwardVanillaOption))
  191 quantoForwardVanillaOption a1 a2 a3 a4 =
  192   let {a1' = realToFrac a1} in 
  193   withDay a2 $ \a2' -> 
  194   withStrikedPayoff a3 $ \a3' -> 
  195   withExercise a4 $ \a4' -> 
  196   preErrorCheck $ \a5' -> 
  197   quantoForwardVanillaOption'_ a1' a2' a3' a4' a5' >>= \res ->
  198   peekQuantoForwardVanillaOption res >>= \res' ->
  199   errorCheck  a5'>>
  200   return (res')
  201 
  202 
  203 
  204 -- |Quanto version of a vanilla option on a single asset.
  205 quantoVanillaOption :: (StrikedPayoff) -> (Exercise) -> IO ((QuantoVanillaOption))
  206 quantoVanillaOption a1 a2 =
  207   withStrikedPayoff a1 $ \a1' -> 
  208   withExercise a2 $ \a2' -> 
  209   preErrorCheck $ \a3' -> 
  210   quantoVanillaOption'_ a1' a2' a3' >>= \res ->
  211   peekQuantoVanillaOption res >>= \res' ->
  212   errorCheck  a3'>>
  213   return (res')
  214 
  215 
  216 
  217 -- |Vanilla option (no discrete dividends, no barriers) on a single asset.
  218 vanillaOption :: (StrikedPayoff) -> (Exercise) -> IO ((VanillaOption))
  219 vanillaOption a1 a2 =
  220   withStrikedPayoff a1 $ \a1' -> 
  221   withExercise a2 $ \a2' -> 
  222   preErrorCheck $ \a3' -> 
  223   vanillaOption'_ a1' a2' a3' >>= \res ->
  224   peekVanillaOption res >>= \res' ->
  225   errorCheck  a3'>>
  226   return (res')
  227 
  228 
  229 
  230 -- |Barrier option on a single asset.
  231 barrierOption :: (BarrierType) -> (Double) -- ^barrier
  232  -> (Double) -- ^rebate
  233  -> (StrikedPayoff) -> (Exercise) -> IO ((BarrierOption))
  234 barrierOption a1 a2 a3 a4 a5 =
  235   let {a1' = (fromIntegral . fromEnum) a1} in 
  236   let {a2' = realToFrac a2} in 
  237   let {a3' = realToFrac a3} in 
  238   withStrikedPayoff a4 $ \a4' -> 
  239   withExercise a5 $ \a5' -> 
  240   preErrorCheck $ \a6' -> 
  241   barrierOption'_ a1' a2' a3' a4' a5' a6' >>= \res ->
  242   peekBarrierOption res >>= \res' ->
  243   errorCheck  a6'>>
  244   return (res')
  245 
  246 
  247 
  248 -- |Barrier option on a single asset that is only monitored for part of its life (a partial-time barrier).
  249 partialTimeBarrierOption :: (BarrierType) -> (PartialBarrierRange) -> (Double) -- ^barrier
  250  -> (Double) -- ^rebate
  251  -> (Day) -- ^coverEventDate
  252  -> (StrikedPayoff) -> (Exercise) -> IO ((OneAssetOption))
  253 partialTimeBarrierOption a1 a2 a3 a4 a5 a6 a7 =
  254   let {a1' = (fromIntegral . fromEnum) a1} in 
  255   let {a2' = (fromIntegral . fromEnum) a2} in 
  256   let {a3' = realToFrac a3} in 
  257   let {a4' = realToFrac a4} in 
  258   withDay a5 $ \a5' -> 
  259   withStrikedPayoff a6 $ \a6' -> 
  260   withExercise a7 $ \a7' -> 
  261   preErrorCheck $ \a8' -> 
  262   partialTimeBarrierOption'_ a1' a2' a3' a4' a5' a6' a7' a8' >>= \res ->
  263   peekOneAssetOption res >>= \res' ->
  264   errorCheck  a8'>>
  265   return (res')
  266 
  267 
  268 
  269 -- |Double-barrier option on a single asset, with a lower and an upper barrier.
  270 doubleBarrierOption :: (DoubleBarrierType) -> (Double) -- ^barrierLo
  271  -> (Double) -- ^barrierHi
  272  -> (Double) -- ^rebate
  273  -> (StrikedPayoff) -> (Exercise) -> IO ((DoubleBarrierOption))
  274 doubleBarrierOption a1 a2 a3 a4 a5 a6 =
  275   let {a1' = (fromIntegral . fromEnum) a1} in 
  276   let {a2' = realToFrac a2} in 
  277   let {a3' = realToFrac a3} in 
  278   let {a4' = realToFrac a4} in 
  279   withStrikedPayoff a5 $ \a5' -> 
  280   withExercise a6 $ \a6' -> 
  281   preErrorCheck $ \a7' -> 
  282   doubleBarrierOption'_ a1' a2' a3' a4' a5' a6' a7' >>= \res ->
  283   peekDoubleBarrierOption res >>= \res' ->
  284   errorCheck  a7'>>
  285   return (res')
  286 
  287 
  288 
  289 -- |Soft barrier option on a single asset: knocked in/out proportionally over a barrier range [barrierLo, barrierHi], rather than in full at a single hard barrier. European exercise only.
  290 softBarrierOption :: (BarrierType) -> (Double) -- ^barrierLo
  291  -> (Double) -- ^barrierHi
  292  -> (StrikedPayoff) -> (Exercise) -> IO ((SoftBarrierOption))
  293 softBarrierOption a1 a2 a3 a4 a5 =
  294   let {a1' = (fromIntegral . fromEnum) a1} in 
  295   let {a2' = realToFrac a2} in 
  296   let {a3' = realToFrac a3} in 
  297   withStrikedPayoff a4 $ \a4' -> 
  298   withExercise a5 $ \a5' -> 
  299   preErrorCheck $ \a6' -> 
  300   softBarrierOption'_ a1' a2' a3' a4' a5' a6' >>= \res ->
  301   peekSoftBarrierOption res >>= \res' ->
  302   errorCheck  a6'>>
  303   return (res')
  304 
  305 
  306 
  307 -- |Implied Black-Scholes volatility that reproduces the given price for a SoftBarrierOption; see VanillaOption's implied-volatility for the caveats on reliability.
  308 softBarrierOptionImpliedVolatility :: (SoftBarrierOption) -> (Double) -- ^price
  309  -> (GenGeneralizedBlackScholesProcess gbs) -> (Double) -- ^accuracy
  310  -> (Word) -- ^maxEvaluations
  311  -> (Double) -- ^minVol
  312  -> (Double) -- ^maxVol
  313  -> IO ((Double))
  314 softBarrierOptionImpliedVolatility a1 a2 a3 a4 a5 a6 a7 =
  315   withSoftBarrierOption a1 $ \a1' -> 
  316   let {a2' = realToFrac a2} in 
  317   withGeneralizedBlackScholesProcess a3 $ \a3' -> 
  318   let {a4' = realToFrac a4} in 
  319   let {a5' = fromIntegral a5} in 
  320   let {a6' = realToFrac a6} in 
  321   let {a7' = realToFrac a7} in 
  322   preErrorCheck $ \a8' -> 
  323   softBarrierOptionImpliedVolatility'_ a1' a2' a3' a4' a5' a6' a7' a8' >>= \res ->
  324   let {res' = realToFrac res} in
  325   errorCheck  a8'>>
  326   return (res')
  327 
  328 
  329 
  330 -- |Forward-starting (strike-resetting) version of a vanilla option.
  331 forwardVanillaOption :: (Double) -- ^moneyness
  332  -> (Day) -- ^resetDate
  333  -> (StrikedPayoff) -> (Exercise) -> IO ((OneAssetOption))
  334 forwardVanillaOption a1 a2 a3 a4 =
  335   let {a1' = realToFrac a1} in 
  336   withDay a2 $ \a2' -> 
  337   withStrikedPayoff a3 $ \a3' -> 
  338   withExercise a4 $ \a4' -> 
  339   preErrorCheck $ \a5' -> 
  340   forwardVanillaOption'_ a1' a2' a3' a4' a5' >>= \res ->
  341   peekOneAssetOption res >>= \res' ->
  342   errorCheck  a5'>>
  343   return (res')
  344 
  345 
  346 
  347 -- |Compound option (an option on another option) on a single asset. The mother option is the compound option itself; the daughter option is its underlying.
  348 compoundOption :: (StrikedPayoff) -- ^motherPayoff
  349  -> (Exercise) -- ^motherExercise
  350  -> (StrikedPayoff) -- ^daughterPayoff
  351  -> (Exercise) -- ^daughterExercise
  352  -> IO ((OneAssetOption))
  353 compoundOption a1 a2 a3 a4 =
  354   withStrikedPayoff a1 $ \a1' -> 
  355   withExercise a2 $ \a2' -> 
  356   withStrikedPayoff a3 $ \a3' -> 
  357   withExercise a4 $ \a4' -> 
  358   preErrorCheck $ \a5' -> 
  359   compoundOption'_ a1' a2' a3' a4' a5' >>= \res ->
  360   peekOneAssetOption res >>= \res' ->
  361   errorCheck  a5'>>
  362   return (res')
  363 
  364 
  365 
  366 -- |Simple chooser option on a single asset: the holder chooses, on the choosing date, whether the option is a call or a put; both share the same strike and exercise date.
  367 simpleChooserOption :: (Day) -- ^choosingDate
  368  -> (Double) -- ^strike
  369  -> (Exercise) -> IO ((OneAssetOption))
  370 simpleChooserOption a1 a2 a3 =
  371   withDay a1 $ \a1' -> 
  372   let {a2' = realToFrac a2} in 
  373   withExercise a3 $ \a3' -> 
  374   preErrorCheck $ \a4' -> 
  375   simpleChooserOption'_ a1' a2' a3' a4' >>= \res ->
  376   peekOneAssetOption res >>= \res' ->
  377   errorCheck  a4'>>
  378   return (res')
  379 
  380 
  381 
  382 -- |Complex chooser option: on the choosing date the holder selects between a call and a put with independent strikes and exercise dates.
  383 complexChooserOption :: (Day) -- ^choosingDate
  384  -> (Double) -- ^strikeCall
  385  -> (Double) -- ^strikePut
  386  -> (Exercise) -- ^exerciseCall
  387  -> (Exercise) -- ^exercisePut
  388  -> IO ((OneAssetOption))
  389 complexChooserOption a1 a2 a3 a4 a5 =
  390   withDay a1 $ \a1' -> 
  391   let {a2' = realToFrac a2} in 
  392   let {a3' = realToFrac a3} in 
  393   withExercise a4 $ \a4' -> 
  394   withExercise a5 $ \a5' -> 
  395   preErrorCheck $ \a6' -> 
  396   complexChooserOption'_ a1' a2' a3' a4' a5' a6' >>= \res ->
  397   peekOneAssetOption res >>= \res' ->
  398   errorCheck  a6'>>
  399   return (res')
  400 
  401 
  402 
  403 -- |Writer-extensible option on a single asset: if out of the money at the first exercise, it is extended to a second exercise with an amended payoff.
  404 writerExtensibleOption :: (PlainVanillaPayoff) -- ^payoff1
  405  -> (Exercise) -- ^exercise1
  406  -> (PlainVanillaPayoff) -- ^payoff2
  407  -> (Exercise) -- ^exercise2
  408  -> IO ((OneAssetOption))
  409 writerExtensibleOption a1 a2 a3 a4 =
  410   withPlainVanillaPayoff a1 $ \a1' -> 
  411   withExercise a2 $ \a2' -> 
  412   withPlainVanillaPayoff a3 $ \a3' -> 
  413   withExercise a4 $ \a4' -> 
  414   preErrorCheck $ \a5' -> 
  415   writerExtensibleOption'_ a1' a2' a3' a4' a5' >>= \res ->
  416   peekOneAssetOption res >>= \res' ->
  417   errorCheck  a5'>>
  418   return (res')
  419 
  420 
  421 
  422 -- |Holder-extensible option: the holder may pay @premium@ at the first exercise to replace its payoff with an option at @secondExpiryDate@ and @secondStrike@.
  423 holderExtensibleOption :: (OptionType) -- ^type
  424  -> (Double) -- ^premium
  425  -> (Day) -- ^secondExpiryDate
  426  -> (Double) -- ^secondStrike
  427  -> (StrikedPayoff) -- ^payoff
  428  -> (Exercise) -- ^exercise
  429  -> IO ((OneAssetOption))
  430 holderExtensibleOption a1 a2 a3 a4 a5 a6 =
  431   let {a1' = fromEnumC a1} in 
  432   let {a2' = realToFrac a2} in 
  433   withDay a3 $ \a3' -> 
  434   let {a4' = realToFrac a4} in 
  435   withStrikedPayoff a5 $ \a5' -> 
  436   withExercise a6 $ \a6' -> 
  437   preErrorCheck $ \a7' -> 
  438   holderExtensibleOption'_ a1' a2' a3' a4' a5' a6' a7' >>= \res ->
  439   peekOneAssetOption res >>= \res' ->
  440   errorCheck  a7'>>
  441   return (res')
  442 
  443 
  444 
  445 -- |Sensitivity of a MargrabeOption's value to the price of the first asset.
  446 firstAssetDelta :: (MargrabeOption) -> IO ((Double))
  447 firstAssetDelta a1 =
  448   withMargrabeOption a1 $ \a1' -> 
  449   preErrorCheck $ \a2' -> 
  450   firstAssetDelta'_ a1' a2' >>= \res ->
  451   let {res' = realToFrac res} in
  452   errorCheck  a2'>>
  453   return (res')
  454 
  455 
  456 
  457 -- |Sensitivity of a MargrabeOption's value to the price of the second asset.
  458 secondAssetDelta :: (MargrabeOption) -> IO ((Double))
  459 secondAssetDelta a1 =
  460   withMargrabeOption a1 $ \a1' -> 
  461   preErrorCheck $ \a2' -> 
  462   secondAssetDelta'_ a1' a2' >>= \res ->
  463   let {res' = realToFrac res} in
  464   errorCheck  a2'>>
  465   return (res')
  466 
  467 
  468 
  469 -- |Second derivative of a MargrabeOption's value with respect to the price of the first asset.
  470 firstAssetGamma :: (MargrabeOption) -> IO ((Double))
  471 firstAssetGamma a1 =
  472   withMargrabeOption a1 $ \a1' -> 
  473   preErrorCheck $ \a2' -> 
  474   firstAssetGamma'_ a1' a2' >>= \res ->
  475   let {res' = realToFrac res} in
  476   errorCheck  a2'>>
  477   return (res')
  478 
  479 
  480 
  481 -- |Second derivative of a MargrabeOption's value with respect to the price of the second asset.
  482 secondAssetGamma :: (MargrabeOption) -> IO ((Double))
  483 secondAssetGamma a1 =
  484   withMargrabeOption a1 $ \a1' -> 
  485   preErrorCheck $ \a2' -> 
  486   secondAssetGamma'_ a1' a2' >>= \res ->
  487   let {res' = realToFrac res} in
  488   errorCheck  a2'>>
  489   return (res')
  490 
  491 
  492 
  493 -- |Sensitivity of the option's value to the forward price of the underlying.
  494 deltaForward :: (GenOneAssetOption oo) -> IO ((Double))
  495 deltaForward a1 =
  496   withOneAssetOption a1 $ \a1' -> 
  497   preErrorCheck $ \a2' -> 
  498   deltaForward'_ a1' a2' >>= \res ->
  499   let {res' = realToFrac res} in
  500   errorCheck  a2'>>
  501   return (res')
  502 
  503 
  504 
  505 -- |Percentage change in the option's value per percentage change in the underlying price.
  506 elasticity :: (GenOneAssetOption oo) -> IO ((Double))
  507 elasticity a1 =
  508   withOneAssetOption a1 $ \a1' -> 
  509   preErrorCheck $ \a2' -> 
  510   elasticity'_ a1' a2' >>= \res ->
  511   let {res' = realToFrac res} in
  512   errorCheck  a2'>>
  513   return (res')
  514 
  515 
  516 
  517 -- |Sensitivity of the option's value to the strike price.
  518 strikeSensitivity :: (GenOneAssetOption oo) -> IO ((Double))
  519 strikeSensitivity a1 =
  520   withOneAssetOption a1 $ \a1' -> 
  521   preErrorCheck $ \a2' -> 
  522   strikeSensitivity'_ a1' a2' >>= \res ->
  523   let {res' = realToFrac res} in
  524   errorCheck  a2'>>
  525   return (res')
  526 
  527 
  528 
  529 -- |Theta divided by the number of days elapsed per day (as opposed to per year).
  530 thetaPerDay :: (GenOneAssetOption oo) -> IO ((Double))
  531 thetaPerDay a1 =
  532   withOneAssetOption a1 $ \a1' -> 
  533   preErrorCheck $ \a2' -> 
  534   thetaPerDay'_ a1' a2' >>= \res ->
  535   let {res' = realToFrac res} in
  536   errorCheck  a2'>>
  537   return (res')
  538 
  539 
  540 
  541 -- |Margrabe option on two assets: the right to exchange Q2 units of the second asset for Q1 units of the first at expiration.
  542 margrabeOption :: (Int) -- ^Q1
  543  -> (Int) -- ^Q2
  544  -> (Exercise) -> IO ((MargrabeOption))
  545 margrabeOption a1 a2 a3 =
  546   let {a1' = fromIntegral a1} in 
  547   let {a2' = fromIntegral a2} in 
  548   withExercise a3 $ \a3' -> 
  549   preErrorCheck $ \a4' -> 
  550   margrabeOption'_ a1' a2' a3' a4' >>= \res ->
  551   peekMargrabeOption res >>= \res' ->
  552   errorCheck  a4'>>
  553   return (res')
  554 
  555 
  556 
  557 -- |Barrier option on two assets: the first asset's value is compared to the strike to determine the payoff, while the second asset's value is monitored against the barrier.
  558 twoAssetBarrierOption :: (BarrierType) -> (Double) -- ^barrier
  559  -> (StrikedPayoff) -> (Exercise) -> IO ((Instrument))
  560 twoAssetBarrierOption a1 a2 a3 a4 =
  561   let {a1' = (fromIntegral . fromEnum) a1} in 
  562   let {a2' = realToFrac a2} in 
  563   withStrikedPayoff a3 $ \a3' -> 
  564   withExercise a4 $ \a4' -> 
  565   preErrorCheck $ \a5' -> 
  566   twoAssetBarrierOption'_ a1' a2' a3' a4' a5' >>= \res ->
  567   peekInstrument res >>= \res' ->
  568   errorCheck  a5'>>
  569   return (res')
  570 
  571 
  572 
  573 -- |Base construction for an option on multiple assets.
  574 multiAssetOption :: (Payoff) -> (Exercise) -> IO ((MultiAssetOption))
  575 multiAssetOption a1 a2 =
  576   withPayoff a1 $ \a1' -> 
  577   withExercise a2 $ \a2' -> 
  578   preErrorCheck $ \a3' -> 
  579   multiAssetOption'_ a1' a2' a3' >>= \res ->
  580   peekMultiAssetOption res >>= \res' ->
  581   errorCheck  a3'>>
  582   return (res')
  583 
  584 
  585 
  586 -- |Two-asset correlation option: pays a payoff based on the second asset's value against strike2 at exercise, but only if the first asset is also in the money against strike1; otherwise pays 0.
  587 twoAssetCorrelationOption :: (OptionType) -- ^type
  588  -> (Double) -- ^strike1
  589  -> (Double) -- ^strike2
  590  -> (Exercise) -> IO ((MultiAssetOption))
  591 twoAssetCorrelationOption a1 a2 a3 a4 =
  592   let {a1' = fromEnumC a1} in 
  593   let {a2' = realToFrac a2} in 
  594   let {a3' = realToFrac a3} in 
  595   withExercise a4 $ \a4' -> 
  596   preErrorCheck $ \a5' -> 
  597   twoAssetCorrelationOption'_ a1' a2' a3' a4' a5' >>= \res ->
  598   peekMultiAssetOption res >>= \res' ->
  599   errorCheck  a5'>>
  600   return (res')
  601 
  602 
  603 
  604 -- |Probability of the option expiring in-the-money in a cash-or-nothing sense.
  605 itmCashProbability :: (GenOneAssetOption oo) -> IO ((Double))
  606 itmCashProbability a1 =
  607   withOneAssetOption a1 $ \a1' -> 
  608   preErrorCheck $ \a2' -> 
  609   itmCashProbability'_ a1' a2' >>= \res ->
  610   let {res' = realToFrac res} in
  611   errorCheck  a2'>>
  612   return (res')
  613 
  614 
  615 
  616 -- |Base construction for an option on a single asset.
  617 oneAssetOption :: (Payoff) -> (Exercise) -> IO ((OneAssetOption))
  618 oneAssetOption a1 a2 =
  619   withPayoff a1 $ \a1' -> 
  620   withExercise a2 $ \a2' -> 
  621   preErrorCheck $ \a3' -> 
  622   oneAssetOption'_ a1' a2' a3' >>= \res ->
  623   peekOneAssetOption res >>= \res' ->
  624   errorCheck  a3'>>
  625   return (res')
  626 
  627 
  628 
  629 -- |Quanto version of a barrier option on a single asset.
  630 quantoBarrierOption :: (BarrierType) -> (Double) -- ^barrier
  631  -> (Double) -- ^rebate
  632  -> (StrikedPayoff) -> (Exercise) -> IO ((QuantoBarrierOption))
  633 quantoBarrierOption a1 a2 a3 a4 a5 =
  634   let {a1' = (fromIntegral . fromEnum) a1} in 
  635   let {a2' = realToFrac a2} in 
  636   let {a3' = realToFrac a3} in 
  637   withStrikedPayoff a4 $ \a4' -> 
  638   withExercise a5 $ \a5' -> 
  639   preErrorCheck $ \a6' -> 
  640   quantoBarrierOption'_ a1' a2' a3' a4' a5' a6' >>= \res ->
  641   peekQuantoBarrierOption res >>= \res' ->
  642   errorCheck  a6'>>
  643   return (res')
  644 
  645 
  646 
  647 -- |Quanto version of a double-barrier option on a single asset, with a lower and an upper barrier.
  648 quantoDoubleBarrierOption :: (DoubleBarrierType) -> (Double) -- ^barrierLo
  649  -> (Double) -- ^barrierHi
  650  -> (Double) -- ^rebate
  651  -> (StrikedPayoff) -> (Exercise) -> IO ((QuantoDoubleBarrierOption))
  652 quantoDoubleBarrierOption a1 a2 a3 a4 a5 a6 =
  653   let {a1' = (fromIntegral . fromEnum) a1} in 
  654   let {a2' = realToFrac a2} in 
  655   let {a3' = realToFrac a3} in 
  656   let {a4' = realToFrac a4} in 
  657   withStrikedPayoff a5 $ \a5' -> 
  658   withExercise a6 $ \a6' -> 
  659   preErrorCheck $ \a7' -> 
  660   quantoDoubleBarrierOption'_ a1' a2' a3' a4' a5' a6' a7' >>= \res ->
  661   peekQuantoDoubleBarrierOption res >>= \res' ->
  662   errorCheck  a7'>>
  663   return (res')
  664 
  665 
  666 
  667 -- |Basket option on a number of assets, combined by the given basket payoff (e.g. min/max/spread/average).
  668 basketOption :: (BasketPayoff) -> (Exercise) -> IO ((MultiAssetOption))
  669 basketOption a1 a2 =
  670   withBasketPayoff a1 $ \a1' -> 
  671   withExercise a2 $ \a2' -> 
  672   preErrorCheck $ \a3' -> 
  673   basketOption'_ a1' a2' a3' >>= \res ->
  674   peekMultiAssetOption res >>= \res' ->
  675   errorCheck  a3'>>
  676   return (res')
  677 
  678 
  679 
  680 -- |Himalaya option: at the end of each of a series of periods, the best-performing asset in the basket is added to the average and dropped from the basket; the payoff is the max of the strike and the final average of best performers.
  681 qlHimalayaOption :: ([Day]) -- ^fixingDates
  682  -> (Double) -- ^strike
  683  -> IO ((MultiAssetOption))
  684 qlHimalayaOption a1 a2 =
  685   withDayArray a1 $ \(a1'1, a1'2) -> 
  686   let {a2' = realToFrac a2} in 
  687   preErrorCheck $ \a3' -> 
  688   qlHimalayaOption'_ a1'1  a1'2 a2' a3' >>= \res ->
  689   peekMultiAssetOption res >>= \res' ->
  690   errorCheck  a3'>>
  691   return (res')
  692 
  693 
  694 
  695 -- |Roofed Asian option on a number of assets: pays the given fraction of the minimum of the roof and the positive portfolio performance, or nothing if the performance is negative.
  696 qlPagodaOption :: ([Day]) -- ^fixingDates
  697  -> (Double) -- ^roof
  698  -> (Double) -- ^fraction
  699  -> IO ((MultiAssetOption))
  700 qlPagodaOption a1 a2 a3 =
  701   withDayArray a1 $ \(a1'1, a1'2) -> 
  702   let {a2' = realToFrac a2} in 
  703   let {a3' = realToFrac a3} in 
  704   preErrorCheck $ \a4' -> 
  705   qlPagodaOption'_ a1'1  a1'2 a2' a3' a4' >>= \res ->
  706   peekMultiAssetOption res >>= \res' ->
  707   errorCheck  a4'>>
  708   return (res')
  709 
  710 
  711 
  712 himalayaOption :: NonEmpty Day -> Double -> IO MultiAssetOption
  713 himalayaOption dates strike = qlHimalayaOption (toList dates) strike
  714 
  715 pagodaOption :: NonEmpty Day -> Double -> Double -> IO MultiAssetOption
  716 pagodaOption dates roof fraction = qlPagodaOption (toList dates) roof fraction
  717 
  718 -- |Cliquet (ratchet) option: a series of forward-starting options where each period's strike is set to a fixed percentage of the spot price at the start of that period.
  719 cliquetOption :: (PercentageStrikePayoff) -> (EuropeanExercise) -- ^maturity
  720  -> ([Day]) -- ^resetDates
  721  -> IO ((OneAssetOption))
  722 cliquetOption a1 a2 a3 =
  723   withPercentageStrikePayoff a1 $ \a1' -> 
  724   withEuropeanExercise a2 $ \a2' -> 
  725   withDayArray a3 $ \(a3'1, a3'2) -> 
  726   preErrorCheck $ \a4' -> 
  727   cliquetOption'_ a1' a2' a3'1  a3'2 a4' >>= \res ->
  728   peekOneAssetOption res >>= \res' ->
  729   errorCheck  a4'>>
  730   return (res')
  731 
  732 
  733 
  734 -- |Continuous-averaging Asian option on a single asset, for an unseasoned (fresh) option where averaging has not yet started.
  735 continuousAveragingAsianOption :: (AverageType) -> (StrikedPayoff) -> (Exercise) -> IO ((OneAssetOption))
  736 continuousAveragingAsianOption a1 a2 a3 =
  737   let {a1' = (fromIntegral . fromEnum) a1} in 
  738   withStrikedPayoff a2 $ \a2' -> 
  739   withExercise a3 $ \a3' -> 
  740   preErrorCheck $ \a4' -> 
  741   continuousAveragingAsianOption'_ a1' a2' a3' a4' >>= \res ->
  742   peekOneAssetOption res >>= \res' ->
  743   errorCheck  a4'>>
  744   return (res')
  745 
  746 
  747 
  748 -- |Continuous-fixed lookback option: the payoff uses the fixed strike against the minimum/maximum price observed over the option's life.
  749 continuousFixedLookbackOption :: (Double) -- ^currentMinmax
  750  -> (StrikedPayoff) -> (Exercise) -> IO ((OneAssetOption))
  751 continuousFixedLookbackOption a1 a2 a3 =
  752   let {a1' = realToFrac a1} in 
  753   withStrikedPayoff a2 $ \a2' -> 
  754   withExercise a3 $ \a3' -> 
  755   preErrorCheck $ \a4' -> 
  756   continuousFixedLookbackOption'_ a1' a2' a3' a4' >>= \res ->
  757   peekOneAssetOption res >>= \res' ->
  758   errorCheck  a4'>>
  759   return (res')
  760 
  761 
  762 
  763 -- |Continuous-floating lookback option: the strike is set to the minimum/maximum price observed over the option's life.
  764 continuousFloatingLookbackOption :: (Double) -- ^currentMinmax
  765  -> (TypePayoff) -> (Exercise) -> IO ((OneAssetOption))
  766 continuousFloatingLookbackOption a1 a2 a3 =
  767   let {a1' = realToFrac a1} in 
  768   withTypePayoff a2 $ \a2' -> 
  769   withExercise a3 $ \a3' -> 
  770   preErrorCheck $ \a4' -> 
  771   continuousFloatingLookbackOption'_ a1' a2' a3' a4' >>= \res ->
  772   peekOneAssetOption res >>= \res' ->
  773   errorCheck  a4'>>
  774   return (res')
  775 
  776 
  777 
  778 -- |Partial-time floating-strike lookback option: the lookback period runs from inception to @lookbackPeriodEnd@, cheaper than a full floating lookback. @lambda@ scales the strike relative to the observed extremum. Priced analytically by Heynen and Kat (1994).
  779 continuousPartialFloatingLookbackOption :: (Double) -- ^currentMinmax
  780  -> (Double) -- ^lambda
  781  -> (Day) -- ^lookbackPeriodEnd
  782  -> (TypePayoff) -> (Exercise) -> IO ((OneAssetOption))
  783 continuousPartialFloatingLookbackOption a1 a2 a3 a4 a5 =
  784   let {a1' = realToFrac a1} in 
  785   let {a2' = realToFrac a2} in 
  786   withDay a3 $ \a3' -> 
  787   withTypePayoff a4 $ \a4' -> 
  788   withExercise a5 $ \a5' -> 
  789   preErrorCheck $ \a6' -> 
  790   continuousPartialFloatingLookbackOption'_ a1' a2' a3' a4' a5' a6' >>= \res ->
  791   peekOneAssetOption res >>= \res' ->
  792   errorCheck  a6'>>
  793   return (res')
  794 
  795 
  796 
  797 -- |Partial-time fixed-strike lookback option: the lookback period runs from @lookbackPeriodStart@ to expiry, cheaper than a full fixed lookback. Priced analytically by Heynen and Kat (1994).
  798 continuousPartialFixedLookbackOption :: (Day) -- ^lookbackPeriodStart
  799  -> (StrikedPayoff) -> (Exercise) -> IO ((OneAssetOption))
  800 continuousPartialFixedLookbackOption a1 a2 a3 =
  801   withDay a1 $ \a1' -> 
  802   withStrikedPayoff a2 $ \a2' -> 
  803   withExercise a3 $ \a3' -> 
  804   preErrorCheck $ \a4' -> 
  805   continuousPartialFixedLookbackOption'_ a1' a2' a3' a4' >>= \res ->
  806   peekOneAssetOption res >>= \res' ->
  807   errorCheck  a4'>>
  808   return (res')
  809 
  810 
  811 
  812 -- |The excess return over @guarantee@, realized on the worst-performing of a basket of assets and paid out on @notional@ at exercise.
  813 everestOption :: (Double) -- ^notional
  814  -> (Double) -- ^guarantee
  815  -> (Exercise) -> IO ((EverestOption))
  816 everestOption a1 a2 a3 =
  817   let {a1' = realToFrac a1} in 
  818   let {a2' = realToFrac a2} in 
  819   withExercise a3 $ \a3' -> 
  820   preErrorCheck $ \a4' -> 
  821   everestOption'_ a1' a2' a3' a4' >>= \res ->
  822   peekEverestOption res >>= \res' ->
  823   errorCheck  a4'>>
  824   return (res')
  825 
  826 
  827 
  828 -- |The realized yield on the notional, i.e. NPV\/(notional*discount) - 1.
  829 yield :: (EverestOption) -> IO ((Double))
  830 yield a1 =
  831   withEverestOption a1 $ \a1' -> 
  832   preErrorCheck $ \a2' -> 
  833   yield'_ a1' a2' >>= \res ->
  834   let {res' = realToFrac res} in
  835   errorCheck  a2'>>
  836   return (res')
  837 
  838 
  839 
  840 -- |Discrete-averaging Asian option on a single asset, taking the running sum/product of past fixings plus a list of future fixing dates.
  841 discreteAveragingAsianOption :: (AverageType) -> (Double) -- ^runningAccumulator, the running sum or products of past fixings
  842  -> (Word) -- ^pastFixings
  843  -> ([Day]) -- ^fixingDates
  844  -> (StrikedPayoff) -> (Exercise) -> IO ((OneAssetOption))
  845 discreteAveragingAsianOption a1 a2 a3 a4 a5 a6 =
  846   let {a1' = (fromIntegral . fromEnum) a1} in 
  847   let {a2' = realToFrac a2} in 
  848   let {a3' = fromIntegral a3} in 
  849   withDayArray a4 $ \(a4'1, a4'2) -> 
  850   withStrikedPayoff a5 $ \a5' -> 
  851   withExercise a6 $ \a6' -> 
  852   preErrorCheck $ \a7' -> 
  853   discreteAveragingAsianOption'_ a1' a2' a3' a4'1  a4'2 a5' a6' a7' >>= \res ->
  854   peekOneAssetOption res >>= \res' ->
  855   errorCheck  a7'>>
  856   return (res')
  857 
  858 
  859 
  860 -- |Storage option (e.g. a gas storage facility): a payoff-free instrument exercisable on a Bermudan schedule, with a maximum capacity, load/withdrawal rate, and per-period rate of change.
  861 vanillaStorageOption :: (BermudanExercise) -> (Double) -- capacity
  862  -> (Double) -- ^load
  863  -> (Double) -- ^changeRate
  864  -> IO ((OneAssetOption))
  865 vanillaStorageOption a1 a2 a3 a4 =
  866   withBermudanExercise a1 $ \a1' -> 
  867   let {a2' = realToFrac a2} in 
  868   let {a3' = realToFrac a3} in 
  869   let {a4' = realToFrac a4} in 
  870   preErrorCheck $ \a5' -> 
  871   vanillaStorageOption'_ a1' a2' a3' a4' a5' >>= \res ->
  872   peekOneAssetOption res >>= \res' ->
  873   errorCheck  a5'>>
  874   return (res')
  875 
  876 
  877 
  878 -- |Swing option: a payoff exercisable a bounded number of times (between minExerciseRights and maxExerciseRights) at the dates of a SwingExercise.
  879 vanillaSwingOption :: (StrikedPayoff) -> (SwingExercise) -> (Word) -- ^minExerciseRights
  880  -> (Word) -- ^maxExerciseRights
  881  -> IO ((OneAssetOption))
  882 vanillaSwingOption a1 a2 a3 a4 =
  883   withStrikedPayoff a1 $ \a1' -> 
  884   withSwingExercise a2 $ \a2' -> 
  885   let {a3' = fromIntegral a3} in 
  886   let {a4' = fromIntegral a4} in 
  887   preErrorCheck $ \a5' -> 
  888   vanillaSwingOption'_ a1' a2' a3' a4' a5' >>= \res ->
  889   peekOneAssetOption res >>= \res' ->
  890   errorCheck  a5'>>
  891   return (res')
  892 
  893 
  894 
  895 -- |European (single-exercise-date) vanilla option on a single asset.
  896 europeanOption :: (StrikedPayoff) -> (Exercise) -> IO ((VanillaOption))
  897 europeanOption a1 a2 =
  898   withStrikedPayoff a1 $ \a1' -> 
  899   withExercise a2 $ \a2' -> 
  900   preErrorCheck $ \a3' -> 
  901   europeanOption'_ a1' a2' a3' >>= \res ->
  902   peekVanillaOption res >>= \res' ->
  903   errorCheck  a3'>>
  904   return (res')
  905 
  906 
  907 
  908 class HasGreeks a where
  909   delta :: a -> IO Double
  910   gamma :: a -> IO Double
  911   rho :: a -> IO Double
  912   theta :: a -> IO Double
  913   vega :: a -> IO Double
  914   dividendRho :: a -> IO Double
  915 
  916 instance HasGreeks MultiAssetOption where
  917   delta = qlMultiAssetOptionDelta
  918   gamma = qlMultiAssetOptionGamma
  919   rho = qlMultiAssetOptionRho
  920   theta = qlMultiAssetOptionTheta
  921   vega = qlMultiAssetOptionVega
  922   dividendRho = qlMultiAssetOptionDividendRho
  923 
  924 instance HasGreeks OneAssetOption where
  925   delta = qlOneAssetOptionDelta
  926   gamma = qlOneAssetOptionGamma
  927   rho = qlOneAssetOptionRho
  928   theta = qlOneAssetOptionTheta
  929   vega = qlOneAssetOptionVega
  930   dividendRho = qlOneAssetOptionDividendRho
  931 
  932 -- |Sensitivity of a multi-asset option's value to the price of its underlying assets.
  933 qlMultiAssetOptionDelta :: (GenMultiAssetOption mo) -> IO ((Double))
  934 qlMultiAssetOptionDelta a1 =
  935   withMultiAssetOption a1 $ \a1' -> 
  936   preErrorCheck $ \a2' -> 
  937   qlMultiAssetOptionDelta'_ a1' a2' >>= \res ->
  938   let {res' = realToFrac res} in
  939   errorCheck  a2'>>
  940   return (res')
  941 
  942 
  943 
  944 -- |Sensitivity of a multi-asset option's value to the dividend yield of its underlying assets.
  945 qlMultiAssetOptionDividendRho :: (GenMultiAssetOption mo) -> IO ((Double))
  946 qlMultiAssetOptionDividendRho a1 =
  947   withMultiAssetOption a1 $ \a1' -> 
  948   preErrorCheck $ \a2' -> 
  949   qlMultiAssetOptionDividendRho'_ a1' a2' >>= \res ->
  950   let {res' = realToFrac res} in
  951   errorCheck  a2'>>
  952   return (res')
  953 
  954 
  955 
  956 -- |Second derivative of a multi-asset option's value with respect to the price of its underlying assets.
  957 qlMultiAssetOptionGamma :: (GenMultiAssetOption mo) -> IO ((Double))
  958 qlMultiAssetOptionGamma a1 =
  959   withMultiAssetOption a1 $ \a1' -> 
  960   preErrorCheck $ \a2' -> 
  961   qlMultiAssetOptionGamma'_ a1' a2' >>= \res ->
  962   let {res' = realToFrac res} in
  963   errorCheck  a2'>>
  964   return (res')
  965 
  966 
  967 
  968 -- |Sensitivity of a multi-asset option's value to the risk-free interest rate.
  969 qlMultiAssetOptionRho :: (GenMultiAssetOption mo) -> IO ((Double))
  970 qlMultiAssetOptionRho a1 =
  971   withMultiAssetOption a1 $ \a1' -> 
  972   preErrorCheck $ \a2' -> 
  973   qlMultiAssetOptionRho'_ a1' a2' >>= \res ->
  974   let {res' = realToFrac res} in
  975   errorCheck  a2'>>
  976   return (res')
  977 
  978 
  979 
  980 -- |Sensitivity of a multi-asset option's value to the passage of time.
  981 qlMultiAssetOptionTheta :: (GenMultiAssetOption mo) -> IO ((Double))
  982 qlMultiAssetOptionTheta a1 =
  983   withMultiAssetOption a1 $ \a1' -> 
  984   preErrorCheck $ \a2' -> 
  985   qlMultiAssetOptionTheta'_ a1' a2' >>= \res ->
  986   let {res' = realToFrac res} in
  987   errorCheck  a2'>>
  988   return (res')
  989 
  990 
  991 
  992 -- |Sensitivity of a multi-asset option's value to the volatility of its underlying assets.
  993 qlMultiAssetOptionVega :: (GenMultiAssetOption mo) -> IO ((Double))
  994 qlMultiAssetOptionVega a1 =
  995   withMultiAssetOption a1 $ \a1' -> 
  996   preErrorCheck $ \a2' -> 
  997   qlMultiAssetOptionVega'_ a1' a2' >>= \res ->
  998   let {res' = realToFrac res} in
  999   errorCheck  a2'>>
 1000   return (res')
 1001 
 1002 
 1003 
 1004 -- |Sensitivity of a single-asset option's value to the price of its underlying.
 1005 qlOneAssetOptionDelta :: (GenOneAssetOption oo) -> IO ((Double))
 1006 qlOneAssetOptionDelta a1 =
 1007   withOneAssetOption a1 $ \a1' -> 
 1008   preErrorCheck $ \a2' -> 
 1009   qlOneAssetOptionDelta'_ a1' a2' >>= \res ->
 1010   let {res' = realToFrac res} in
 1011   errorCheck  a2'>>
 1012   return (res')
 1013 
 1014 
 1015 
 1016 -- |Sensitivity of a single-asset option's value to the dividend yield of its underlying.
 1017 qlOneAssetOptionDividendRho :: (GenOneAssetOption oo) -> IO ((Double))
 1018 qlOneAssetOptionDividendRho a1 =
 1019   withOneAssetOption a1 $ \a1' -> 
 1020   preErrorCheck $ \a2' -> 
 1021   qlOneAssetOptionDividendRho'_ a1' a2' >>= \res ->
 1022   let {res' = realToFrac res} in
 1023   errorCheck  a2'>>
 1024   return (res')
 1025 
 1026 
 1027 
 1028 -- |Second derivative of a single-asset option's value with respect to the price of its underlying.
 1029 qlOneAssetOptionGamma :: (GenOneAssetOption oo) -> IO ((Double))
 1030 qlOneAssetOptionGamma a1 =
 1031   withOneAssetOption a1 $ \a1' -> 
 1032   preErrorCheck $ \a2' -> 
 1033   qlOneAssetOptionGamma'_ a1' a2' >>= \res ->
 1034   let {res' = realToFrac res} in
 1035   errorCheck  a2'>>
 1036   return (res')
 1037 
 1038 
 1039 
 1040 -- |Sensitivity of a single-asset option's value to the risk-free interest rate.
 1041 qlOneAssetOptionRho :: (GenOneAssetOption oo) -> IO ((Double))
 1042 qlOneAssetOptionRho a1 =
 1043   withOneAssetOption a1 $ \a1' -> 
 1044   preErrorCheck $ \a2' -> 
 1045   qlOneAssetOptionRho'_ a1' a2' >>= \res ->
 1046   let {res' = realToFrac res} in
 1047   errorCheck  a2'>>
 1048   return (res')
 1049 
 1050 
 1051 
 1052 -- |Sensitivity of a single-asset option's value to the passage of time.
 1053 qlOneAssetOptionTheta :: (GenOneAssetOption oo) -> IO ((Double))
 1054 qlOneAssetOptionTheta a1 =
 1055   withOneAssetOption a1 $ \a1' -> 
 1056   preErrorCheck $ \a2' -> 
 1057   qlOneAssetOptionTheta'_ a1' a2' >>= \res ->
 1058   let {res' = realToFrac res} in
 1059   errorCheck  a2'>>
 1060   return (res')
 1061 
 1062 
 1063 
 1064 -- |Sensitivity of a single-asset option's value to the volatility of its underlying.
 1065 qlOneAssetOptionVega :: (GenOneAssetOption oo) -> IO ((Double))
 1066 qlOneAssetOptionVega a1 =
 1067   withOneAssetOption a1 $ \a1' -> 
 1068   preErrorCheck $ \a2' -> 
 1069   qlOneAssetOptionVega'_ a1' a2' >>= \res ->
 1070   let {res' = realToFrac res} in
 1071   errorCheck  a2'>>
 1072   return (res')
 1073 
 1074 
 1075 
 1076 class HasQuanto a where
 1077   qrho :: a -> IO Double
 1078   qvega :: a -> IO Double
 1079   qlambda :: a -> IO Double
 1080 instance HasQuanto QuantoBarrierOption where
 1081   qrho = qlQuantoBarrierOptionQrho
 1082   qvega = qlQuantoBarrierOptionQvega
 1083   qlambda = qlQuantoBarrierOptionQlambda
 1084 instance HasQuanto QuantoDoubleBarrierOption where
 1085   qrho = qlQuantoDoubleBarrierOptionQrho
 1086   qvega = qlQuantoDoubleBarrierOptionQvega
 1087   qlambda = qlQuantoDoubleBarrierOptionQlambda
 1088 instance HasQuanto QuantoForwardVanillaOption where
 1089   qrho = qlQuantoForwardVanillaOptionQrho
 1090   qvega = qlQuantoForwardVanillaOptionQvega
 1091   qlambda = qlQuantoForwardVanillaOptionQlambda
 1092 instance HasQuanto QuantoVanillaOption where
 1093   qrho = qlQuantoVanillaOptionQrho
 1094   qvega = qlQuantoVanillaOptionQvega
 1095   qlambda = qlQuantoVanillaOptionQlambda
 1096 
 1097 class HasImpliedVol a where
 1098 -- /Warning/ currently, this method returns the Black-Scholes implied volatility using analytic formulas for European options and a finite-difference method for American and Bermudan options. It will give unconsistent results if the pricing was performed with any other methods (such as jump-diffusion models.)Warningoptions with a gamma that changes sign (e.g., binary options) have values that are not monotonic in the volatility. In these cases, the calculation can fail and the result (if any) is almost meaningless. Another possible source of failure is to have a target value that is not attainable with any volatility, e.g., a target value lower than the intrinsic value in the case of American options.
 1099   impliedVolatility :: a
 1100     -> Double -- ^price
 1101     -> GenGeneralizedBlackScholesProcess gbs -- ^process
 1102     -> [Dividend] -- ^dividends
 1103     -> Double -- ^accuracy
 1104     -> Word -- ^maxEvaluations
 1105     -> Double -- ^minVol
 1106     -> Double -- ^maxVol
 1107     -> IO Double
 1108 instance HasImpliedVol VanillaOption where
 1109   impliedVolatility = qlVanillaOptionImpliedVolatility
 1110 instance HasImpliedVol BarrierOption where
 1111   impliedVolatility = qlBarrierOptionImpliedVolatility
 1112 
 1113 -- |Sensitivity of a QuantoBarrierOption's value to the correlation-driven quanto adjustment's foreign rate.
 1114 qlQuantoBarrierOptionQrho :: (QuantoBarrierOption) -> IO ((Double))
 1115 qlQuantoBarrierOptionQrho a1 =
 1116   withQuantoBarrierOption a1 $ \a1' -> 
 1117   preErrorCheck $ \a2' -> 
 1118   qlQuantoBarrierOptionQrho'_ a1' a2' >>= \res ->
 1119   let {res' = realToFrac res} in
 1120   errorCheck  a2'>>
 1121   return (res')
 1122 
 1123 
 1124 
 1125 -- |Sensitivity of a QuantoBarrierOption's value to the exchange-rate volatility.
 1126 qlQuantoBarrierOptionQvega :: (QuantoBarrierOption) -> IO ((Double))
 1127 qlQuantoBarrierOptionQvega a1 =
 1128   withQuantoBarrierOption a1 $ \a1' -> 
 1129   preErrorCheck $ \a2' -> 
 1130   qlQuantoBarrierOptionQvega'_ a1' a2' >>= \res ->
 1131   let {res' = realToFrac res} in
 1132   errorCheck  a2'>>
 1133   return (res')
 1134 
 1135 
 1136 
 1137 -- |Sensitivity of a QuantoBarrierOption's value to the correlation between the underlying and the exchange rate.
 1138 qlQuantoBarrierOptionQlambda :: (QuantoBarrierOption) -> IO ((Double))
 1139 qlQuantoBarrierOptionQlambda a1 =
 1140   withQuantoBarrierOption a1 $ \a1' -> 
 1141   preErrorCheck $ \a2' -> 
 1142   qlQuantoBarrierOptionQlambda'_ a1' a2' >>= \res ->
 1143   let {res' = realToFrac res} in
 1144   errorCheck  a2'>>
 1145   return (res')
 1146 
 1147 
 1148 
 1149 -- |Sensitivity of a QuantoDoubleBarrierOption's value to the correlation-driven quanto adjustment's foreign rate.
 1150 qlQuantoDoubleBarrierOptionQrho :: (QuantoDoubleBarrierOption) -> IO ((Double))
 1151 qlQuantoDoubleBarrierOptionQrho a1 =
 1152   withQuantoDoubleBarrierOption a1 $ \a1' -> 
 1153   preErrorCheck $ \a2' -> 
 1154   qlQuantoDoubleBarrierOptionQrho'_ a1' a2' >>= \res ->
 1155   let {res' = realToFrac res} in
 1156   errorCheck  a2'>>
 1157   return (res')
 1158 
 1159 
 1160 
 1161 -- |Sensitivity of a QuantoDoubleBarrierOption's value to the exchange-rate volatility.
 1162 qlQuantoDoubleBarrierOptionQvega :: (QuantoDoubleBarrierOption) -> IO ((Double))
 1163 qlQuantoDoubleBarrierOptionQvega a1 =
 1164   withQuantoDoubleBarrierOption a1 $ \a1' -> 
 1165   preErrorCheck $ \a2' -> 
 1166   qlQuantoDoubleBarrierOptionQvega'_ a1' a2' >>= \res ->
 1167   let {res' = realToFrac res} in
 1168   errorCheck  a2'>>
 1169   return (res')
 1170 
 1171 
 1172 
 1173 -- |Sensitivity of a QuantoDoubleBarrierOption's value to the correlation between the underlying and the exchange rate.
 1174 qlQuantoDoubleBarrierOptionQlambda :: (QuantoDoubleBarrierOption) -> IO ((Double))
 1175 qlQuantoDoubleBarrierOptionQlambda a1 =
 1176   withQuantoDoubleBarrierOption a1 $ \a1' -> 
 1177   preErrorCheck $ \a2' -> 
 1178   qlQuantoDoubleBarrierOptionQlambda'_ a1' a2' >>= \res ->
 1179   let {res' = realToFrac res} in
 1180   errorCheck  a2'>>
 1181   return (res')
 1182 
 1183 
 1184 
 1185 -- |Sensitivity of a QuantoForwardVanillaOption's value to the correlation-driven quanto adjustment's foreign rate.
 1186 qlQuantoForwardVanillaOptionQrho :: (QuantoForwardVanillaOption) -> IO ((Double))
 1187 qlQuantoForwardVanillaOptionQrho a1 =
 1188   withQuantoForwardVanillaOption a1 $ \a1' -> 
 1189   preErrorCheck $ \a2' -> 
 1190   qlQuantoForwardVanillaOptionQrho'_ a1' a2' >>= \res ->
 1191   let {res' = realToFrac res} in
 1192   errorCheck  a2'>>
 1193   return (res')
 1194 
 1195 
 1196 
 1197 -- |Sensitivity of a QuantoForwardVanillaOption's value to the exchange-rate volatility.
 1198 qlQuantoForwardVanillaOptionQvega :: (QuantoForwardVanillaOption) -> IO ((Double))
 1199 qlQuantoForwardVanillaOptionQvega a1 =
 1200   withQuantoForwardVanillaOption a1 $ \a1' -> 
 1201   preErrorCheck $ \a2' -> 
 1202   qlQuantoForwardVanillaOptionQvega'_ a1' a2' >>= \res ->
 1203   let {res' = realToFrac res} in
 1204   errorCheck  a2'>>
 1205   return (res')
 1206 
 1207 
 1208 
 1209 -- |Sensitivity of a QuantoForwardVanillaOption's value to the correlation between the underlying and the exchange rate.
 1210 qlQuantoForwardVanillaOptionQlambda :: (QuantoForwardVanillaOption) -> IO ((Double))
 1211 qlQuantoForwardVanillaOptionQlambda a1 =
 1212   withQuantoForwardVanillaOption a1 $ \a1' -> 
 1213   preErrorCheck $ \a2' -> 
 1214   qlQuantoForwardVanillaOptionQlambda'_ a1' a2' >>= \res ->
 1215   let {res' = realToFrac res} in
 1216   errorCheck  a2'>>
 1217   return (res')
 1218 
 1219 
 1220 
 1221 -- |Sensitivity of a QuantoVanillaOption's value to the correlation-driven quanto adjustment's foreign rate.
 1222 qlQuantoVanillaOptionQrho :: (QuantoVanillaOption) -> IO ((Double))
 1223 qlQuantoVanillaOptionQrho a1 =
 1224   withQuantoVanillaOption a1 $ \a1' -> 
 1225   preErrorCheck $ \a2' -> 
 1226   qlQuantoVanillaOptionQrho'_ a1' a2' >>= \res ->
 1227   let {res' = realToFrac res} in
 1228   errorCheck  a2'>>
 1229   return (res')
 1230 
 1231 
 1232 
 1233 -- |Sensitivity of a QuantoVanillaOption's value to the exchange-rate volatility.
 1234 qlQuantoVanillaOptionQvega :: (QuantoVanillaOption) -> IO ((Double))
 1235 qlQuantoVanillaOptionQvega a1 =
 1236   withQuantoVanillaOption a1 $ \a1' -> 
 1237   preErrorCheck $ \a2' -> 
 1238   qlQuantoVanillaOptionQvega'_ a1' a2' >>= \res ->
 1239   let {res' = realToFrac res} in
 1240   errorCheck  a2'>>
 1241   return (res')
 1242 
 1243 
 1244 
 1245 -- |Sensitivity of a QuantoVanillaOption's value to the correlation between the underlying and the exchange rate.
 1246 qlQuantoVanillaOptionQlambda :: (QuantoVanillaOption) -> IO ((Double))
 1247 qlQuantoVanillaOptionQlambda a1 =
 1248   withQuantoVanillaOption a1 $ \a1' -> 
 1249   preErrorCheck $ \a2' -> 
 1250   qlQuantoVanillaOptionQlambda'_ a1' a2' >>= \res ->
 1251   let {res' = realToFrac res} in
 1252   errorCheck  a2'>>
 1253   return (res')
 1254 
 1255 
 1256 
 1257 -- |Implied Black-Scholes volatility that reproduces the given price for a VanillaOption, computed analytically for European exercise and by finite differences for American/Bermudan; may be unreliable for a gamma that changes sign or a price unattainable at any volatility.
 1258 qlVanillaOptionImpliedVolatility :: (VanillaOption) -> (Double) -- ^price
 1259  -> (GenGeneralizedBlackScholesProcess gbs) -> ([Dividend]) -- ^dividends
 1260  -> (Double) -- ^accuracy
 1261  -> (Word) -- ^maxEvaluations
 1262  -> (Double) -- ^minVol
 1263  -> (Double) -- ^maxVol
 1264  -> IO ((Double))
 1265 qlVanillaOptionImpliedVolatility a1 a2 a3 a4 a5 a6 a7 a8 =
 1266   withVanillaOption a1 $ \a1' -> 
 1267   let {a2' = realToFrac a2} in 
 1268   withGeneralizedBlackScholesProcess a3 $ \a3' -> 
 1269   withDividendArray a4 $ \(a4'1, a4'2) -> 
 1270   let {a5' = realToFrac a5} in 
 1271   let {a6' = fromIntegral a6} in 
 1272   let {a7' = realToFrac a7} in 
 1273   let {a8' = realToFrac a8} in 
 1274   preErrorCheck $ \a9' -> 
 1275   qlVanillaOptionImpliedVolatility'_ a1' a2' a3' a4'1  a4'2 a5' a6' a7' a8' a9' >>= \res ->
 1276   let {res' = realToFrac res} in
 1277   errorCheck  a9'>>
 1278   return (res')
 1279 
 1280 
 1281 
 1282 -- |Implied Black-Scholes volatility that reproduces the given price for a BarrierOption; see VanillaOption's implied-volatility for the caveats on reliability.
 1283 qlBarrierOptionImpliedVolatility :: (BarrierOption) -> (Double) -- ^price
 1284  -> (GenGeneralizedBlackScholesProcess gbs) -> ([Dividend]) -- ^dividends
 1285  -> (Double) -- ^accuracy
 1286  -> (Word) -- ^maxEvaluations
 1287  -> (Double) -- ^minVol
 1288  -> (Double) -- ^maxVol
 1289  -> IO ((Double))
 1290 qlBarrierOptionImpliedVolatility a1 a2 a3 a4 a5 a6 a7 a8 =
 1291   withBarrierOption a1 $ \a1' -> 
 1292   let {a2' = realToFrac a2} in 
 1293   withGeneralizedBlackScholesProcess a3 $ \a3' -> 
 1294   withDividendArray a4 $ \(a4'1, a4'2) -> 
 1295   let {a5' = realToFrac a5} in 
 1296   let {a6' = fromIntegral a6} in 
 1297   let {a7' = realToFrac a7} in 
 1298   let {a8' = realToFrac a8} in 
 1299   preErrorCheck $ \a9' -> 
 1300   qlBarrierOptionImpliedVolatility'_ a1' a2' a3' a4'1  a4'2 a5' a6' a7' a8' a9' >>= \res ->
 1301   let {res' = realToFrac res} in
 1302   errorCheck  a9'>>
 1303   return (res')
 1304 
 1305 
 1306 
 1307 -- |Implied Black-Scholes volatility that reproduces the given price for a DoubleBarrierOption; see VanillaOption's implied-volatility for the caveats on reliability.
 1308 doubleBarrierOptionImpliedVolatility :: (DoubleBarrierOption) -> (Double) -- ^price
 1309  -> (GenGeneralizedBlackScholesProcess gbs) -> (Double) -- ^accuracy
 1310  -> (Word) -- ^maxEvaluations
 1311  -> (Double) -- ^minVol
 1312  -> (Double) -- ^maxVol
 1313  -> IO ((Double))
 1314 doubleBarrierOptionImpliedVolatility a1 a2 a3 a4 a5 a6 a7 =
 1315   withDoubleBarrierOption a1 $ \a1' -> 
 1316   let {a2' = realToFrac a2} in 
 1317   withGeneralizedBlackScholesProcess a3 $ \a3' -> 
 1318   let {a4' = realToFrac a4} in 
 1319   let {a5' = fromIntegral a5} in 
 1320   let {a6' = realToFrac a6} in 
 1321   let {a7' = realToFrac a7} in 
 1322   preErrorCheck $ \a8' -> 
 1323   doubleBarrierOptionImpliedVolatility'_ a1' a2' a3' a4' a5' a6' a7' a8' >>= \res ->
 1324   let {res' = realToFrac res} in
 1325   errorCheck  a8'>>
 1326   return (res')
 1327 
 1328 
 1329 
 1330 -- vim: set ff=unix ts=8 sts=2 sw=2 et:
 1331 
 1332 foreign import ccall safe "QuantLib/Instrument/Option.chs.h qlQuantoForwardVanillaOption"
 1333   quantoForwardVanillaOption'_ :: (C2HSImp.CDouble -> (C2HSImp.CInt -> ((QlStrikedTypePayoff) -> ((QlExercise) -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO (C2HSImp.Ptr (CQuantoForwardVanillaOption'))))))))
 1334 
 1335 foreign import ccall safe "QuantLib/Instrument/Option.chs.h qlQuantoVanillaOption"
 1336   quantoVanillaOption'_ :: ((QlStrikedTypePayoff) -> ((QlExercise) -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO (C2HSImp.Ptr (CQuantoVanillaOption'))))))
 1337 
 1338 foreign import ccall safe "QuantLib/Instrument/Option.chs.h qlVanillaOption"
 1339   vanillaOption'_ :: ((QlStrikedTypePayoff) -> ((QlExercise) -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO (C2HSImp.Ptr (CVanillaOption'))))))
 1340 
 1341 foreign import ccall safe "QuantLib/Instrument/Option.chs.h qlBarrierOption"
 1342   barrierOption'_ :: (C2HSImp.CInt -> (C2HSImp.CDouble -> (C2HSImp.CDouble -> ((QlStrikedTypePayoff) -> ((QlExercise) -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO (C2HSImp.Ptr (CBarrierOption')))))))))
 1343 
 1344 foreign import ccall safe "QuantLib/Instrument/Option.chs.h qlPartialTimeBarrierOption"
 1345   partialTimeBarrierOption'_ :: (C2HSImp.CInt -> (C2HSImp.CInt -> (C2HSImp.CDouble -> (C2HSImp.CDouble -> (C2HSImp.CInt -> ((QlStrikedTypePayoff) -> ((QlExercise) -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO (C2HSImp.Ptr (COneAssetOption')))))))))))
 1346 
 1347 foreign import ccall safe "QuantLib/Instrument/Option.chs.h qlDoubleBarrierOption"
 1348   doubleBarrierOption'_ :: (C2HSImp.CInt -> (C2HSImp.CDouble -> (C2HSImp.CDouble -> (C2HSImp.CDouble -> ((QlStrikedTypePayoff) -> ((QlExercise) -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO (C2HSImp.Ptr (CDoubleBarrierOption'))))))))))
 1349 
 1350 foreign import ccall safe "QuantLib/Instrument/Option.chs.h qlSoftBarrierOption"
 1351   softBarrierOption'_ :: (C2HSImp.CInt -> (C2HSImp.CDouble -> (C2HSImp.CDouble -> ((QlStrikedTypePayoff) -> ((QlExercise) -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO (C2HSImp.Ptr (CSoftBarrierOption')))))))))
 1352 
 1353 foreign import ccall safe "QuantLib/Instrument/Option.chs.h qlSoftBarrierOptionImpliedVolatility"
 1354   softBarrierOptionImpliedVolatility'_ :: ((C2HSImp.Ptr (CSoftBarrierOption')) -> (C2HSImp.CDouble -> ((C2HSImp.Ptr (CGeneralizedBlackScholesProcess')) -> (C2HSImp.CDouble -> (C2HSImp.CUInt -> (C2HSImp.CDouble -> (C2HSImp.CDouble -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO C2HSImp.CDouble)))))))))
 1355 
 1356 foreign import ccall safe "QuantLib/Instrument/Option.chs.h qlForwardVanillaOption"
 1357   forwardVanillaOption'_ :: (C2HSImp.CDouble -> (C2HSImp.CInt -> ((QlStrikedTypePayoff) -> ((QlExercise) -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO (C2HSImp.Ptr (COneAssetOption'))))))))
 1358 
 1359 foreign import ccall safe "QuantLib/Instrument/Option.chs.h qlCompoundOption"
 1360   compoundOption'_ :: ((QlStrikedTypePayoff) -> ((QlExercise) -> ((QlStrikedTypePayoff) -> ((QlExercise) -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO (C2HSImp.Ptr (COneAssetOption'))))))))
 1361 
 1362 foreign import ccall safe "QuantLib/Instrument/Option.chs.h qlSimpleChooserOption"
 1363   simpleChooserOption'_ :: (C2HSImp.CInt -> (C2HSImp.CDouble -> ((QlExercise) -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO (C2HSImp.Ptr (COneAssetOption')))))))
 1364 
 1365 foreign import ccall safe "QuantLib/Instrument/Option.chs.h qlComplexChooserOption"
 1366   complexChooserOption'_ :: (C2HSImp.CInt -> (C2HSImp.CDouble -> (C2HSImp.CDouble -> ((QlExercise) -> ((QlExercise) -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO (C2HSImp.Ptr (COneAssetOption')))))))))
 1367 
 1368 foreign import ccall safe "QuantLib/Instrument/Option.chs.h qlWriterExtensibleOption"
 1369   writerExtensibleOption'_ :: ((QlPlainVanillaPayoff) -> ((QlExercise) -> ((QlPlainVanillaPayoff) -> ((QlExercise) -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO (C2HSImp.Ptr (COneAssetOption'))))))))
 1370 
 1371 foreign import ccall safe "QuantLib/Instrument/Option.chs.h qlHolderExtensibleOption"
 1372   holderExtensibleOption'_ :: (C2HSImp.CInt -> (C2HSImp.CDouble -> (C2HSImp.CInt -> (C2HSImp.CDouble -> ((QlStrikedTypePayoff) -> ((QlExercise) -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO (C2HSImp.Ptr (COneAssetOption'))))))))))
 1373 
 1374 foreign import ccall safe "QuantLib/Instrument/Option.chs.h qlMargrabeOptionDelta1"
 1375   firstAssetDelta'_ :: ((C2HSImp.Ptr (CMargrabeOption')) -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO C2HSImp.CDouble)))
 1376 
 1377 foreign import ccall safe "QuantLib/Instrument/Option.chs.h qlMargrabeOptionDelta2"
 1378   secondAssetDelta'_ :: ((C2HSImp.Ptr (CMargrabeOption')) -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO C2HSImp.CDouble)))
 1379 
 1380 foreign import ccall safe "QuantLib/Instrument/Option.chs.h qlMargrabeOptionGamma1"
 1381   firstAssetGamma'_ :: ((C2HSImp.Ptr (CMargrabeOption')) -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO C2HSImp.CDouble)))
 1382 
 1383 foreign import ccall safe "QuantLib/Instrument/Option.chs.h qlMargrabeOptionGamma2"
 1384   secondAssetGamma'_ :: ((C2HSImp.Ptr (CMargrabeOption')) -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO C2HSImp.CDouble)))
 1385 
 1386 foreign import ccall safe "QuantLib/Instrument/Option.chs.h qlOneAssetOptionDeltaForward"
 1387   deltaForward'_ :: ((C2HSImp.Ptr (COneAssetOption')) -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO C2HSImp.CDouble)))
 1388 
 1389 foreign import ccall safe "QuantLib/Instrument/Option.chs.h qlOneAssetOptionElasticity"
 1390   elasticity'_ :: ((C2HSImp.Ptr (COneAssetOption')) -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO C2HSImp.CDouble)))
 1391 
 1392 foreign import ccall safe "QuantLib/Instrument/Option.chs.h qlOneAssetOptionStrikeSensitivity"
 1393   strikeSensitivity'_ :: ((C2HSImp.Ptr (COneAssetOption')) -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO C2HSImp.CDouble)))
 1394 
 1395 foreign import ccall safe "QuantLib/Instrument/Option.chs.h qlOneAssetOptionThetaPerDay"
 1396   thetaPerDay'_ :: ((C2HSImp.Ptr (COneAssetOption')) -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO C2HSImp.CDouble)))
 1397 
 1398 foreign import ccall safe "QuantLib/Instrument/Option.chs.h qlMargrabeOption"
 1399   margrabeOption'_ :: (C2HSImp.CInt -> (C2HSImp.CInt -> ((QlExercise) -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO (C2HSImp.Ptr (CMargrabeOption')))))))
 1400 
 1401 foreign import ccall safe "QuantLib/Instrument/Option.chs.h qlTwoAssetBarrierOption"
 1402   twoAssetBarrierOption'_ :: (C2HSImp.CInt -> (C2HSImp.CDouble -> ((QlStrikedTypePayoff) -> ((QlExercise) -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO (C2HSImp.Ptr (CInstrument'))))))))
 1403 
 1404 foreign import ccall safe "QuantLib/Instrument/Option.chs.h qlMultiAssetOption"
 1405   multiAssetOption'_ :: ((QlPayoff) -> ((QlExercise) -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO (C2HSImp.Ptr (CMultiAssetOption'))))))
 1406 
 1407 foreign import ccall safe "QuantLib/Instrument/Option.chs.h qlTwoAssetCorrelationOption"
 1408   twoAssetCorrelationOption'_ :: (C2HSImp.CInt -> (C2HSImp.CDouble -> (C2HSImp.CDouble -> ((QlExercise) -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO (C2HSImp.Ptr (CMultiAssetOption'))))))))
 1409 
 1410 foreign import ccall safe "QuantLib/Instrument/Option.chs.h qlOneAssetOptionItmCashProbability"
 1411   itmCashProbability'_ :: ((C2HSImp.Ptr (COneAssetOption')) -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO C2HSImp.CDouble)))
 1412 
 1413 foreign import ccall safe "QuantLib/Instrument/Option.chs.h qlOneAssetOption"
 1414   oneAssetOption'_ :: ((QlPayoff) -> ((QlExercise) -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO (C2HSImp.Ptr (COneAssetOption'))))))
 1415 
 1416 foreign import ccall safe "QuantLib/Instrument/Option.chs.h qlQuantoBarrierOption"
 1417   quantoBarrierOption'_ :: (C2HSImp.CInt -> (C2HSImp.CDouble -> (C2HSImp.CDouble -> ((QlStrikedTypePayoff) -> ((QlExercise) -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO (C2HSImp.Ptr (CQuantoBarrierOption')))))))))
 1418 
 1419 foreign import ccall safe "QuantLib/Instrument/Option.chs.h qlQuantoDoubleBarrierOption"
 1420   quantoDoubleBarrierOption'_ :: (C2HSImp.CInt -> (C2HSImp.CDouble -> (C2HSImp.CDouble -> (C2HSImp.CDouble -> ((QlStrikedTypePayoff) -> ((QlExercise) -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO (C2HSImp.Ptr (CQuantoDoubleBarrierOption'))))))))))
 1421 
 1422 foreign import ccall safe "QuantLib/Instrument/Option.chs.h qlBasketOption"
 1423   basketOption'_ :: ((QlBasketPayoff) -> ((QlExercise) -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO (C2HSImp.Ptr (CMultiAssetOption'))))))
 1424 
 1425 foreign import ccall safe "QuantLib/Instrument/Option.chs.h qlHimalayaOption"
 1426   qlHimalayaOption'_ :: (C2HSImp.CUInt -> ((C2HSImp.Ptr C2HSImp.CInt) -> (C2HSImp.CDouble -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO (C2HSImp.Ptr (CMultiAssetOption')))))))
 1427 
 1428 foreign import ccall safe "QuantLib/Instrument/Option.chs.h qlPagodaOption"
 1429   qlPagodaOption'_ :: (C2HSImp.CUInt -> ((C2HSImp.Ptr C2HSImp.CInt) -> (C2HSImp.CDouble -> (C2HSImp.CDouble -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO (C2HSImp.Ptr (CMultiAssetOption'))))))))
 1430 
 1431 foreign import ccall safe "QuantLib/Instrument/Option.chs.h qlCliquetOption"
 1432   cliquetOption'_ :: ((QlPercentageStrikePayoff) -> ((QlEuropeanExercise) -> (C2HSImp.CUInt -> ((C2HSImp.Ptr C2HSImp.CInt) -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO (C2HSImp.Ptr (COneAssetOption'))))))))
 1433 
 1434 foreign import ccall safe "QuantLib/Instrument/Option.chs.h qlContinuousAveragingAsianOption"
 1435   continuousAveragingAsianOption'_ :: (C2HSImp.CInt -> ((QlStrikedTypePayoff) -> ((QlExercise) -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO (C2HSImp.Ptr (COneAssetOption')))))))
 1436 
 1437 foreign import ccall safe "QuantLib/Instrument/Option.chs.h qlContinuousFixedLookbackOption"
 1438   continuousFixedLookbackOption'_ :: (C2HSImp.CDouble -> ((QlStrikedTypePayoff) -> ((QlExercise) -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO (C2HSImp.Ptr (COneAssetOption')))))))
 1439 
 1440 foreign import ccall safe "QuantLib/Instrument/Option.chs.h qlContinuousFloatingLookbackOption"
 1441   continuousFloatingLookbackOption'_ :: (C2HSImp.CDouble -> ((QlTypePayoff) -> ((QlExercise) -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO (C2HSImp.Ptr (COneAssetOption')))))))
 1442 
 1443 foreign import ccall safe "QuantLib/Instrument/Option.chs.h qlContinuousPartialFloatingLookbackOption"
 1444   continuousPartialFloatingLookbackOption'_ :: (C2HSImp.CDouble -> (C2HSImp.CDouble -> (C2HSImp.CInt -> ((QlTypePayoff) -> ((QlExercise) -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO (C2HSImp.Ptr (COneAssetOption')))))))))
 1445 
 1446 foreign import ccall safe "QuantLib/Instrument/Option.chs.h qlContinuousPartialFixedLookbackOption"
 1447   continuousPartialFixedLookbackOption'_ :: (C2HSImp.CInt -> ((QlStrikedTypePayoff) -> ((QlExercise) -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO (C2HSImp.Ptr (COneAssetOption')))))))
 1448 
 1449 foreign import ccall safe "QuantLib/Instrument/Option.chs.h qlEverestOption"
 1450   everestOption'_ :: (C2HSImp.CDouble -> (C2HSImp.CDouble -> ((QlExercise) -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO (C2HSImp.Ptr (CEverestOption')))))))
 1451 
 1452 foreign import ccall safe "QuantLib/Instrument/Option.chs.h qlEverestOptionYield"
 1453   yield'_ :: ((C2HSImp.Ptr (CEverestOption')) -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO C2HSImp.CDouble)))
 1454 
 1455 foreign import ccall safe "QuantLib/Instrument/Option.chs.h qlDiscreteAveragingAsianOption"
 1456   discreteAveragingAsianOption'_ :: (C2HSImp.CInt -> (C2HSImp.CDouble -> (C2HSImp.CUInt -> (C2HSImp.CUInt -> ((C2HSImp.Ptr C2HSImp.CInt) -> ((QlStrikedTypePayoff) -> ((QlExercise) -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO (C2HSImp.Ptr (COneAssetOption')))))))))))
 1457 
 1458 foreign import ccall safe "QuantLib/Instrument/Option.chs.h qlVanillaStorageOption"
 1459   vanillaStorageOption'_ :: ((QlBermudanExercise) -> (C2HSImp.CDouble -> (C2HSImp.CDouble -> (C2HSImp.CDouble -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO (C2HSImp.Ptr (COneAssetOption'))))))))
 1460 
 1461 foreign import ccall safe "QuantLib/Instrument/Option.chs.h qlVanillaSwingOption"
 1462   vanillaSwingOption'_ :: ((QlStrikedTypePayoff) -> ((QlSwingExercise) -> (C2HSImp.CUInt -> (C2HSImp.CUInt -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO (C2HSImp.Ptr (COneAssetOption'))))))))
 1463 
 1464 foreign import ccall safe "QuantLib/Instrument/Option.chs.h qlEuropeanOption"
 1465   europeanOption'_ :: ((QlStrikedTypePayoff) -> ((QlExercise) -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO (C2HSImp.Ptr (CVanillaOption'))))))
 1466 
 1467 foreign import ccall safe "QuantLib/Instrument/Option.chs.h qlMultiAssetOptionDelta"
 1468   qlMultiAssetOptionDelta'_ :: ((C2HSImp.Ptr (CMultiAssetOption')) -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO C2HSImp.CDouble)))
 1469 
 1470 foreign import ccall safe "QuantLib/Instrument/Option.chs.h qlMultiAssetOptionDividendRho"
 1471   qlMultiAssetOptionDividendRho'_ :: ((C2HSImp.Ptr (CMultiAssetOption')) -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO C2HSImp.CDouble)))
 1472 
 1473 foreign import ccall safe "QuantLib/Instrument/Option.chs.h qlMultiAssetOptionGamma"
 1474   qlMultiAssetOptionGamma'_ :: ((C2HSImp.Ptr (CMultiAssetOption')) -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO C2HSImp.CDouble)))
 1475 
 1476 foreign import ccall safe "QuantLib/Instrument/Option.chs.h qlMultiAssetOptionRho"
 1477   qlMultiAssetOptionRho'_ :: ((C2HSImp.Ptr (CMultiAssetOption')) -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO C2HSImp.CDouble)))
 1478 
 1479 foreign import ccall safe "QuantLib/Instrument/Option.chs.h qlMultiAssetOptionTheta"
 1480   qlMultiAssetOptionTheta'_ :: ((C2HSImp.Ptr (CMultiAssetOption')) -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO C2HSImp.CDouble)))
 1481 
 1482 foreign import ccall safe "QuantLib/Instrument/Option.chs.h qlMultiAssetOptionVega"
 1483   qlMultiAssetOptionVega'_ :: ((C2HSImp.Ptr (CMultiAssetOption')) -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO C2HSImp.CDouble)))
 1484 
 1485 foreign import ccall safe "QuantLib/Instrument/Option.chs.h qlOneAssetOptionDelta"
 1486   qlOneAssetOptionDelta'_ :: ((C2HSImp.Ptr (COneAssetOption')) -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO C2HSImp.CDouble)))
 1487 
 1488 foreign import ccall safe "QuantLib/Instrument/Option.chs.h qlOneAssetOptionDividendRho"
 1489   qlOneAssetOptionDividendRho'_ :: ((C2HSImp.Ptr (COneAssetOption')) -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO C2HSImp.CDouble)))
 1490 
 1491 foreign import ccall safe "QuantLib/Instrument/Option.chs.h qlOneAssetOptionGamma"
 1492   qlOneAssetOptionGamma'_ :: ((C2HSImp.Ptr (COneAssetOption')) -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO C2HSImp.CDouble)))
 1493 
 1494 foreign import ccall safe "QuantLib/Instrument/Option.chs.h qlOneAssetOptionRho"
 1495   qlOneAssetOptionRho'_ :: ((C2HSImp.Ptr (COneAssetOption')) -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO C2HSImp.CDouble)))
 1496 
 1497 foreign import ccall safe "QuantLib/Instrument/Option.chs.h qlOneAssetOptionTheta"
 1498   qlOneAssetOptionTheta'_ :: ((C2HSImp.Ptr (COneAssetOption')) -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO C2HSImp.CDouble)))
 1499 
 1500 foreign import ccall safe "QuantLib/Instrument/Option.chs.h qlOneAssetOptionVega"
 1501   qlOneAssetOptionVega'_ :: ((C2HSImp.Ptr (COneAssetOption')) -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO C2HSImp.CDouble)))
 1502 
 1503 foreign import ccall safe "QuantLib/Instrument/Option.chs.h qlQuantoBarrierOptionQrho"
 1504   qlQuantoBarrierOptionQrho'_ :: ((C2HSImp.Ptr (CQuantoBarrierOption')) -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO C2HSImp.CDouble)))
 1505 
 1506 foreign import ccall safe "QuantLib/Instrument/Option.chs.h qlQuantoBarrierOptionQvega"
 1507   qlQuantoBarrierOptionQvega'_ :: ((C2HSImp.Ptr (CQuantoBarrierOption')) -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO C2HSImp.CDouble)))
 1508 
 1509 foreign import ccall safe "QuantLib/Instrument/Option.chs.h qlQuantoBarrierOptionQlambda"
 1510   qlQuantoBarrierOptionQlambda'_ :: ((C2HSImp.Ptr (CQuantoBarrierOption')) -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO C2HSImp.CDouble)))
 1511 
 1512 foreign import ccall safe "QuantLib/Instrument/Option.chs.h qlQuantoDoubleBarrierOptionQrho"
 1513   qlQuantoDoubleBarrierOptionQrho'_ :: ((C2HSImp.Ptr (CQuantoDoubleBarrierOption')) -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO C2HSImp.CDouble)))
 1514 
 1515 foreign import ccall safe "QuantLib/Instrument/Option.chs.h qlQuantoDoubleBarrierOptionQvega"
 1516   qlQuantoDoubleBarrierOptionQvega'_ :: ((C2HSImp.Ptr (CQuantoDoubleBarrierOption')) -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO C2HSImp.CDouble)))
 1517 
 1518 foreign import ccall safe "QuantLib/Instrument/Option.chs.h qlQuantoDoubleBarrierOptionQlambda"
 1519   qlQuantoDoubleBarrierOptionQlambda'_ :: ((C2HSImp.Ptr (CQuantoDoubleBarrierOption')) -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO C2HSImp.CDouble)))
 1520 
 1521 foreign import ccall safe "QuantLib/Instrument/Option.chs.h qlQuantoForwardVanillaOptionQrho"
 1522   qlQuantoForwardVanillaOptionQrho'_ :: ((C2HSImp.Ptr (CQuantoForwardVanillaOption')) -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO C2HSImp.CDouble)))
 1523 
 1524 foreign import ccall safe "QuantLib/Instrument/Option.chs.h qlQuantoForwardVanillaOptionQvega"
 1525   qlQuantoForwardVanillaOptionQvega'_ :: ((C2HSImp.Ptr (CQuantoForwardVanillaOption')) -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO C2HSImp.CDouble)))
 1526 
 1527 foreign import ccall safe "QuantLib/Instrument/Option.chs.h qlQuantoForwardVanillaOptionQlambda"
 1528   qlQuantoForwardVanillaOptionQlambda'_ :: ((C2HSImp.Ptr (CQuantoForwardVanillaOption')) -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO C2HSImp.CDouble)))
 1529 
 1530 foreign import ccall safe "QuantLib/Instrument/Option.chs.h qlQuantoVanillaOptionQrho"
 1531   qlQuantoVanillaOptionQrho'_ :: ((C2HSImp.Ptr (CQuantoVanillaOption')) -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO C2HSImp.CDouble)))
 1532 
 1533 foreign import ccall safe "QuantLib/Instrument/Option.chs.h qlQuantoVanillaOptionQvega"
 1534   qlQuantoVanillaOptionQvega'_ :: ((C2HSImp.Ptr (CQuantoVanillaOption')) -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO C2HSImp.CDouble)))
 1535 
 1536 foreign import ccall safe "QuantLib/Instrument/Option.chs.h qlQuantoVanillaOptionQlambda"
 1537   qlQuantoVanillaOptionQlambda'_ :: ((C2HSImp.Ptr (CQuantoVanillaOption')) -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO C2HSImp.CDouble)))
 1538 
 1539 foreign import ccall safe "QuantLib/Instrument/Option.chs.h qlVanillaOptionImpliedVolatility"
 1540   qlVanillaOptionImpliedVolatility'_ :: ((C2HSImp.Ptr (CVanillaOption')) -> (C2HSImp.CDouble -> ((C2HSImp.Ptr (CGeneralizedBlackScholesProcess')) -> (C2HSImp.CUInt -> ((C2HSImp.Ptr (C2HSImp.Ptr (CDividend))) -> (C2HSImp.CDouble -> (C2HSImp.CUInt -> (C2HSImp.CDouble -> (C2HSImp.CDouble -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO C2HSImp.CDouble)))))))))))
 1541 
 1542 foreign import ccall safe "QuantLib/Instrument/Option.chs.h qlBarrierOptionImpliedVolatility"
 1543   qlBarrierOptionImpliedVolatility'_ :: ((C2HSImp.Ptr (CBarrierOption')) -> (C2HSImp.CDouble -> ((C2HSImp.Ptr (CGeneralizedBlackScholesProcess')) -> (C2HSImp.CUInt -> ((C2HSImp.Ptr (C2HSImp.Ptr (CDividend))) -> (C2HSImp.CDouble -> (C2HSImp.CUInt -> (C2HSImp.CDouble -> (C2HSImp.CDouble -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO C2HSImp.CDouble)))))))))))
 1544 
 1545 foreign import ccall safe "QuantLib/Instrument/Option.chs.h qlDoubleBarrierOptionImpliedVolatility"
 1546   doubleBarrierOptionImpliedVolatility'_ :: ((C2HSImp.Ptr (CDoubleBarrierOption')) -> (C2HSImp.CDouble -> ((C2HSImp.Ptr (CGeneralizedBlackScholesProcess')) -> (C2HSImp.CDouble -> (C2HSImp.CUInt -> (C2HSImp.CDouble -> (C2HSImp.CDouble -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO C2HSImp.CDouble)))))))))