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.Quote
    6   (
    7      Quote
    8    , SimpleQuote
    9    , DeltaVolQuote
   10    , RelinkableQuote
   11    , GenQuote
   12 
   13    , asQuote
   14    , PriceType(..)
   15    , IntervalPriceType(..)
   16    , AtmType(..)
   17    , DeltaType(..)
   18 
   19   , simpleQuote
   20   , deltaVolQuote
   21   , atmVolQuote
   22   , value
   23   , isValid
   24   , setValue
   25   , eurodollarFuturesImpliedStdDevQuote
   26   , forwardSwapQuote
   27   , forwardValueQuote
   28   , futuresConvAdjustmentQuote'
   29   , futuresConvAdjustmentQuote
   30   , impliedStdDevQuote
   31   , lastFixingQuote
   32   , relinkableQuote
   33   , linkTo
   34 
   35   , QuoteOp(..)
   36   , MultiQuoteOp(..)
   37   , derivedQuote
   38   , compositeQuote
   39   , multiCompositeQuote
   40   , withDerivedQuote
   41   , withCompositeQuote
   42   , withMultiCompositeQuote
   43   ) where
   44 import qualified Foreign.C.String as C2HSImp
   45 import qualified Foreign.C.Types as C2HSImp
   46 import qualified Foreign.ForeignPtr as C2HSImp
   47 import qualified Foreign.Marshal.Utils as C2HSImp
   48 import qualified Foreign.Ptr as C2HSImp
   49 
   50 
   51 import Foreign.Ptr(FunPtr)
   52 
   53 import QuantLib.Internal
   54 import QuantLib.Internal.Common
   55 import QuantLib.Internal.Type
   56 
   57 
   58 
   59 
   60 
   61 
   62 
   63 data IntervalPriceType = IntervalPriceOpen
   64                        | IntervalPriceClose
   65                        | IntervalPriceHigh
   66                        | IntervalPriceLow
   67   deriving (Enum,Show,Eq,Read)
   68 
   69 
   70 data AtmType = AtmNull
   71              | AtmSpot
   72              | AtmFwd
   73              | AtmDeltaNeutral
   74              | AtmVegaMax
   75              | AtmGammaMax
   76              | AtmPutCall50
   77   deriving (Enum,Show,Eq,Read)
   78 
   79 
   80 data PriceType = Bid
   81                | Ask
   82                | Last
   83                | Close
   84                | Mid
   85                | MidEquivalent
   86                | MidSafe
   87   deriving (Enum,Show,Eq,Read)
   88 
   89 
   90 data DeltaType = Spot
   91                | Fwd
   92                | PaSpot
   93                | PaFwd
   94   deriving (Enum,Show,Eq,Read)
   95 
   96 
   97 
   98 -- |Which binary operation a catalogue 'derivedQuote'\/'compositeQuote' applies. 'derivedQuote'
   99 -- applies it as @quote \`op\` operand@; 'compositeQuote' as @quote1 \`op\` quote2@. The reversed
  100 -- unary forms (@operand \/ quote@, i.e. an FX inversion) are deliberately absent -- that is what
  101 -- 'withDerivedQuote' is for.
  102 data QuoteOp = QuoteAdd
  103              | QuoteSubtract
  104              | QuoteMultiply
  105              | QuoteDivide
  106   deriving (Show,Eq,Read,Bounded)
  107 instance Enum QuoteOp where
  108   succ QuoteAdd = QuoteSubtract
  109   succ QuoteSubtract = QuoteMultiply
  110   succ QuoteMultiply = QuoteDivide
  111   succ QuoteDivide = error "QuoteOp.succ: QuoteDivide has no successor"
  112 
  113   pred QuoteSubtract = QuoteAdd
  114   pred QuoteMultiply = QuoteSubtract
  115   pred QuoteDivide = QuoteMultiply
  116   pred QuoteAdd = error "QuoteOp.pred: QuoteAdd has no predecessor"
  117 
  118   enumFromTo from to = go from
  119     where
  120       end = fromEnum to
  121       go v = case compare (fromEnum v) end of
  122                  LT -> v : go (succ v)
  123                  EQ -> [v]
  124                  GT -> []
  125 
  126   enumFrom from = enumFromTo from QuoteDivide
  127 
  128   fromEnum QuoteAdd = 0
  129   fromEnum QuoteSubtract = 1
  130   fromEnum QuoteMultiply = 2
  131   fromEnum QuoteDivide = 3
  132 
  133   toEnum 0 = QuoteAdd
  134   toEnum 1 = QuoteSubtract
  135   toEnum 2 = QuoteMultiply
  136   toEnum 3 = QuoteDivide
  137   toEnum unmatched = error ("QuoteOp.toEnum: Cannot match " ++ show unmatched)
  138 
  139 
  140 
  141 -- |Which fold a catalogue 'multiCompositeQuote' applies over its elements.
  142 data MultiQuoteOp = QuoteSum
  143                   | QuoteProduct
  144                   | QuoteNorm2
  145   deriving (Show,Eq,Read,Bounded)
  146 instance Enum MultiQuoteOp where
  147   succ QuoteSum = QuoteProduct
  148   succ QuoteProduct = QuoteNorm2
  149   succ QuoteNorm2 = error "MultiQuoteOp.succ: QuoteNorm2 has no successor"
  150 
  151   pred QuoteProduct = QuoteSum
  152   pred QuoteNorm2 = QuoteProduct
  153   pred QuoteSum = error "MultiQuoteOp.pred: QuoteSum has no predecessor"
  154 
  155   enumFromTo from to = go from
  156     where
  157       end = fromEnum to
  158       go v = case compare (fromEnum v) end of
  159                  LT -> v : go (succ v)
  160                  EQ -> [v]
  161                  GT -> []
  162 
  163   enumFrom from = enumFromTo from QuoteNorm2
  164 
  165   fromEnum QuoteSum = 0
  166   fromEnum QuoteProduct = 1
  167   fromEnum QuoteNorm2 = 2
  168 
  169   toEnum 0 = QuoteSum
  170   toEnum 1 = QuoteProduct
  171   toEnum 2 = QuoteNorm2
  172   toEnum unmatched = error ("MultiQuoteOp.toEnum: Cannot match " ++ show unmatched)
  173 
  174 
  175 
  176 
  177 
  178 
  179 
  180 
  181 
  182 
  183 
  184 
  185 
  186 
  187 
  188 
  189 
  190 
  191 -- |market element returning a stored value
  192 simpleQuote :: (Double) -> IO ((SimpleQuote))
  193 simpleQuote a1 =
  194   let {a1' = realToFrac a1} in 
  195   preErrorCheck $ \a2' -> 
  196   simpleQuote'_ a1' a2' >>= \res ->
  197   peekSimpleQuote res >>= \res' ->
  198   errorCheck  a2'>>
  199   return (res')
  200 
  201 
  202 
  203 -- |quotation of an FX delta vs vol, e.g. a 25-delta risk-reversal/butterfly point
  204 deltaVolQuote :: (Double) -- ^delta
  205  -> (GenQuote q) -- ^vol
  206  -> (Double) -- ^maturity
  207  -> (DeltaType) -> IO ((DeltaVolQuote))
  208 deltaVolQuote a1 a2 a3 a4 =
  209   let {a1' = realToFrac a1} in 
  210   withQuote a2 $ \a2' -> 
  211   let {a3' = realToFrac a3} in 
  212   let {a4' = fromEnumC a4} in 
  213   preErrorCheck $ \a5' -> 
  214   deltaVolQuote'_ a1' a2' a3' a4' a5' >>= \res ->
  215   peekDeltaVolQuote res >>= \res' ->
  216   errorCheck  a5'>>
  217   return (res')
  218 
  219 
  220 
  221 -- |quotation of an FX at-the-money vol point (e.g. ATM straddle)
  222 atmVolQuote :: (GenQuote q) -- ^vol
  223  -> (DeltaType) -> (Double) -- ^maturity
  224  -> (AtmType) -> IO ((DeltaVolQuote))
  225 atmVolQuote a1 a2 a3 a4 =
  226   withQuote a1 $ \a1' -> 
  227   let {a2' = fromEnumC a2} in 
  228   let {a3' = realToFrac a3} in 
  229   let {a4' = fromEnumC a4} in 
  230   preErrorCheck $ \a5' -> 
  231   atmVolQuote'_ a1' a2' a3' a4' a5' >>= \res ->
  232   peekDeltaVolQuote res >>= \res' ->
  233   errorCheck  a5'>>
  234   return (res')
  235 
  236 
  237 
  238 -- |Returns the current value of the given Quote object
  239 value :: (GenQuote q) -> IO ((Double))
  240 value a1 =
  241   withQuote a1 $ \a1' -> 
  242   preErrorCheck $ \a2' -> 
  243   value'_ a1' a2' >>= \res ->
  244   let {res' = realToFrac res} in
  245   errorCheck  a2'>>
  246   return (res')
  247 
  248 
  249 
  250 -- |returns the difference between the new value and the old value
  251 -- /NB/ The change will propagate to all users of the quote
  252 setValue :: (SimpleQuote) -> (Double) -> IO ((Double))
  253 setValue a1 a2 =
  254   withGenQuote a1 $ \a1' -> 
  255   let {a2' = realToFrac a2} in 
  256   preErrorCheck $ \a3' -> 
  257   setValue'_ a1' a2' a3' >>= \res ->
  258   let {res' = realToFrac res} in
  259   errorCheck  a3'>>
  260   return (res')
  261 
  262 
  263 
  264 -- |implied standard deviation of a Eurodollar future's underlying, solved from its call/put prices
  265 eurodollarFuturesImpliedStdDevQuote :: (GenQuote q1) -- ^forward
  266  -> (GenQuote q2) -- ^callPrice
  267  -> (GenQuote q3) -- ^putPrice
  268  -> (Double) -- ^strike
  269  -> (Double) -- ^guess
  270  -> (Double) -- ^accuracy
  271  -> (Word) -- ^maxIter
  272  -> IO ((Quote))
  273 eurodollarFuturesImpliedStdDevQuote a1 a2 a3 a4 a5 a6 a7 =
  274   withQuote a1 $ \a1' -> 
  275   withQuote a2 $ \a2' -> 
  276   withQuote a3 $ \a3' -> 
  277   let {a4' = realToFrac a4} in 
  278   let {a5' = realToFrac a5} in 
  279   let {a6' = realToFrac a6} in 
  280   let {a7' = fromIntegral a7} in 
  281   preErrorCheck $ \a8' -> 
  282   eurodollarFuturesImpliedStdDevQuote'_ a1' a2' a3' a4' a5' a6' a7' a8' >>= \res ->
  283   peekQuote res >>= \res' ->
  284   errorCheck  a8'>>
  285   return (res')
  286 
  287 
  288 
  289 -- |implied rate of a forward-starting swap on the given swap index, offset by a spread quote
  290 forwardSwapQuote :: (GenSwapIndex sidx) -> (GenQuote q) -- ^spread
  291  -> ((Int,TimeUnit)) -- ^fwdStart
  292  -> IO ((Quote))
  293 forwardSwapQuote a1 a2 a3 =
  294   withSwapIndex a1 $ \a1' -> 
  295   withQuote a2 $ \a2' -> 
  296   let {(a3'1, a3'2) = fromEnumQuantity a3} in 
  297   preErrorCheck $ \a4' -> 
  298   forwardSwapQuote'_ a1' a2' a3'1  a3'2 a4' >>= \res ->
  299   peekQuote res >>= \res' ->
  300   errorCheck  a4'>>
  301   return (res')
  302 
  303 
  304 
  305 -- |forward value of an index as of a given fixing date
  306 forwardValueQuote :: (GenIndex idx) -> (Day) -> IO ((Quote))
  307 forwardValueQuote a1 a2 =
  308   withIndex a1 $ \a1' -> 
  309   withDay a2 $ \a2' -> 
  310   preErrorCheck $ \a3' -> 
  311   forwardValueQuote'_ a1' a2' a3' >>= \res ->
  312   peekQuote res >>= \res' ->
  313   errorCheck  a3'>>
  314   return (res')
  315 
  316 
  317 
  318 -- |futures-convexity adjustment for an Ibor future identified by its IMM code
  319 futuresConvAdjustmentQuote' :: (GenIborIndex ibor) -> (String) -- ^immCode
  320  -> (GenQuote q1) -- ^futuresQuote
  321  -> (GenQuote q2) -- ^volatility
  322  -> (GenQuote q3) -- ^meanReversion
  323  -> IO ((Quote))
  324 futuresConvAdjustmentQuote' a1 a2 a3 a4 a5 =
  325   withIborIndex a1 $ \a1' -> 
  326   C2HSImp.withCString a2 $ \a2' -> 
  327   withQuote a3 $ \a3' -> 
  328   withQuote a4 $ \a4' -> 
  329   withQuote a5 $ \a5' -> 
  330   preErrorCheck $ \a6' -> 
  331   futuresConvAdjustmentQuote''_ a1' a2' a3' a4' a5' a6' >>= \res ->
  332   peekQuote res >>= \res' ->
  333   errorCheck  a6'>>
  334   return (res')
  335 
  336 
  337 
  338 -- |futures-convexity adjustment for an Ibor future identified by its futures (IMM) date
  339 futuresConvAdjustmentQuote :: (GenIborIndex ibor) -> (Day) -- ^futuresDate
  340  -> (GenQuote q1) -- ^futuresQuote
  341  -> (GenQuote q2) -- ^volatility
  342  -> (GenQuote q3) -- ^meanReversion
  343  -> IO ((Quote))
  344 futuresConvAdjustmentQuote a1 a2 a3 a4 a5 =
  345   withIborIndex a1 $ \a1' -> 
  346   withDay a2 $ \a2' -> 
  347   withQuote a3 $ \a3' -> 
  348   withQuote a4 $ \a4' -> 
  349   withQuote a5 $ \a5' -> 
  350   preErrorCheck $ \a6' -> 
  351   futuresConvAdjustmentQuote'_ a1' a2' a3' a4' a5' a6' >>= \res ->
  352   peekQuote res >>= \res' ->
  353   errorCheck  a6'>>
  354   return (res')
  355 
  356 
  357 
  358 -- |implied standard deviation of an underlying, solved from its option price at a given strike
  359 impliedStdDevQuote :: (OptionType) -> (GenQuote q1) -- ^forward
  360  -> (GenQuote q2) -- ^price
  361  -> (Double) -- &strike
  362  -> (Double) -- ^guess
  363  -> (Double) -- ^accuracy
  364  -> (Word) -- ^maxIter
  365  -> IO ((Quote))
  366 impliedStdDevQuote a1 a2 a3 a4 a5 a6 a7 =
  367   let {a1' = fromEnumC a1} in 
  368   withQuote a2 $ \a2' -> 
  369   withQuote a3 $ \a3' -> 
  370   let {a4' = realToFrac a4} in 
  371   let {a5' = realToFrac a5} in 
  372   let {a6' = realToFrac a6} in 
  373   let {a7' = fromIntegral a7} in 
  374   preErrorCheck $ \a8' -> 
  375   impliedStdDevQuote'_ a1' a2' a3' a4' a5' a6' a7' a8' >>= \res ->
  376   peekQuote res >>= \res' ->
  377   errorCheck  a8'>>
  378   return (res')
  379 
  380 
  381 
  382 -- |last available fixing of the given index, updating whenever a new fixing is added
  383 lastFixingQuote :: (GenIndex idx) -> IO ((Quote))
  384 lastFixingQuote a1 =
  385   withIndex a1 $ \a1' -> 
  386   preErrorCheck $ \a2' -> 
  387   lastFixingQuote'_ a1' a2' >>= \res ->
  388   peekQuote res >>= \res' ->
  389   errorCheck  a2'>>
  390   return (res')
  391 
  392 
  393 
  394 -- |returns true if the Quote holds a valid value
  395 isValid :: (GenQuote q) -> IO ((Bool))
  396 isValid a1 =
  397   withQuote a1 $ \a1' -> 
  398   preErrorCheck $ \a2' -> 
  399   isValid'_ a1' a2' >>= \res ->
  400   let {res' = C2HSImp.toBool res} in
  401   errorCheck  a2'>>
  402   return (res')
  403 
  404 
  405 
  406 -- |A quote behind a relinkable handle. The result /is/ a 'Quote': pass it to any quote-taking
  407 -- function and everything built on it keeps tracking whatever the handle currently points at,
  408 -- so a later 'linkTo' reprices already-constructed instruments without rebuilding them.
  409 -- 'Nothing' gives an empty handle -- meaningful rather than an error -- but reading a value
  410 -- through one throws until it is linked. Mirrors 'QuantLib.TermStructure.Yield.relinkableYieldTermStructure'.
  411 relinkableQuote :: (Maybe (GenQuote q)) -> IO ((RelinkableQuote))
  412 relinkableQuote a1 =
  413   withMaybeQuote a1 $ \a1' -> 
  414   preErrorCheck $ \a2' -> 
  415   relinkableQuote'_ a1' a2' >>= \res ->
  416   peekRelinkableQuote res >>= \res' ->
  417   errorCheck  a2'>>
  418   return (res')
  419 
  420 
  421 
  422 -- |Point a relinkable handle at a different quote. Everything already built on the handle
  423 -- reprices against the new quote, with no object rebuilt.
  424 --
  425 -- This is the one mutator in the module besides 'setValue'. The API rules here otherwise
  426 -- forbid new setters and prefer constructing a fresh object, but relinking /is/ the capability
  427 -- being bound -- the same justification as 'QuantLib.TermStructure.Yield.linkTo'. Note the
  428 -- narrower payoff versus curves: 'SimpleQuote.setValue' already covers the common bump case,
  429 -- so this buys swapping in a different quote object, not a different value.
  430 linkTo :: (RelinkableQuote) -> (GenQuote q) -> IO ()
  431 linkTo a1 a2 =
  432   withRelinkableQuote a1 $ \a1' -> 
  433   withQuote a2 $ \a2' -> 
  434   preErrorCheck $ \a3' -> 
  435   linkTo'_ a1' a2' a3' >>
  436   errorCheck  a3'>>
  437   return ()
  438 
  439 
  440 
  441 -- The quotes below are the only ones here that are not leaf values: they register with their
  442 -- inputs and notify their own observers when one moves. That is the whole reason they are bound
  443 -- rather than done in Haskell -- a quote hasquant hands out is a live node in QuantLib's observer
  444 -- graph, so a curve or instrument built on one of these keeps tracking its inputs, where a value
  445 -- recomputed on the Haskell side would be a dead snapshot the curve never hears about.
  446 
  447 -- |A quote derived from another by applying @quote \`op\` operand@, live: it recomputes whenever
  448 -- the underlying quote moves, and notifies everything built on it.
  449 --
  450 -- @'derivedQuote' 'QuoteAdd' base 0.0005@ is the "base plus 5bp" spread quote for a rate helper.
  451 -- For anything outside the 'QuoteOp' catalogue -- @1\/x@, a cap, a nonlinear transform -- use
  452 -- 'withDerivedQuote'.
  453 derivedQuote :: (QuoteOp) -> (GenQuote q) -> (Double) -- ^operand
  454  -> IO ((Quote))
  455 derivedQuote a1 a2 a3 =
  456   let {a1' = fromEnumC a1} in 
  457   withQuote a2 $ \a2' -> 
  458   let {a3' = realToFrac a3} in 
  459   preErrorCheck $ \a4' -> 
  460   derivedQuote'_ a1' a2' a3' a4' >>= \res ->
  461   peekQuote res >>= \res' ->
  462   errorCheck  a4'>>
  463   return (res')
  464 
  465 
  466 
  467 -- |A quote combining two others as @quote1 \`op\` quote2@, live in both: it recomputes whenever
  468 -- either moves. Use 'withCompositeQuote' for an operation outside the 'QuoteOp' catalogue.
  469 compositeQuote :: (QuoteOp) -> (GenQuote q1) -> (GenQuote q2) -> IO ((Quote))
  470 compositeQuote a1 a2 a3 =
  471   let {a1' = fromEnumC a1} in 
  472   withQuote a2 $ \a2' -> 
  473   withQuote a3 $ \a3' -> 
  474   preErrorCheck $ \a4' -> 
  475   compositeQuote'_ a1' a2' a3' a4' >>= \res ->
  476   peekQuote res >>= \res' ->
  477   errorCheck  a4'>>
  478   return (res')
  479 
  480 
  481 
  482 -- |A quote folding any number of others, live in all of them. An empty list is accepted and
  483 -- gives the fold's identity (@0@ for 'QuoteSum' and 'QuoteNorm2', @1@ for 'QuoteProduct') --
  484 -- upstream imposes no non-empty requirement. Use 'withMultiCompositeQuote' for a fold outside
  485 -- the 'MultiQuoteOp' catalogue.
  486 multiCompositeQuote :: (MultiQuoteOp) -> ([GenQuote q]) -> IO ((Quote))
  487 multiCompositeQuote a1 a2 =
  488   let {a1' = fromEnumC a1} in 
  489   withQuoteArray a2 $ \(a2'1, a2'2) -> 
  490   preErrorCheck $ \a3' -> 
  491   multiCompositeQuote'_ a1' a2'1  a2'2 a3' >>= \res ->
  492   peekQuote res >>= \res' ->
  493   errorCheck  a3'>>
  494   return (res')
  495 
  496 
  497 
  498 qlDerivedQuoteFromFunction :: (GenQuote q) -> (FunPtr QuoteUnaryFun) -> IO ((Quote))
  499 qlDerivedQuoteFromFunction a1 a2 =
  500   withQuote a1 $ \a1' -> 
  501   let {a2' = id a2} in 
  502   preErrorCheck $ \a3' -> 
  503   qlDerivedQuoteFromFunction'_ a1' a2' a3' >>= \res ->
  504   peekQuote res >>= \res' ->
  505   errorCheck  a3'>>
  506   return (res')
  507 
  508 
  509 qlCompositeQuoteFromFunction :: (GenQuote q1) -> (GenQuote q2) -> (FunPtr QuoteBinaryFun) -> IO ((Quote))
  510 qlCompositeQuoteFromFunction a1 a2 a3 =
  511   withQuote a1 $ \a1' -> 
  512   withQuote a2 $ \a2' -> 
  513   let {a3' = id a3} in 
  514   preErrorCheck $ \a4' -> 
  515   qlCompositeQuoteFromFunction'_ a1' a2' a3' a4' >>= \res ->
  516   peekQuote res >>= \res' ->
  517   errorCheck  a4'>>
  518   return (res')
  519 
  520 
  521 qlMultiCompositeQuoteFromFunction :: ([GenQuote q]) -> (FunPtr QuoteArrayFun) -> IO ((Quote))
  522 qlMultiCompositeQuoteFromFunction a1 a2 =
  523   withQuoteArray a1 $ \(a1'1, a1'2) -> 
  524   let {a2' = id a2} in 
  525   preErrorCheck $ \a3' -> 
  526   qlMultiCompositeQuoteFromFunction'_ a1'1  a1'2 a2' a3' >>= \res ->
  527   peekQuote res >>= \res' ->
  528   errorCheck  a3'>>
  529   return (res')
  530 
  531 
  532 
  533 -- |As 'derivedQuote', but applying an arbitrary Haskell function to the underlying quote's value.
  534 --
  535 -- __The quote is valid only inside the continuation, which must span the whole use -- not just
  536 -- construction.__ QuantLib calls back into @f@ from @Quote::value()@, from wherever the quote was
  537 -- stored, so everything built on it -- every curve, rate helper and instrument, and every pricing
  538 -- call -- must happen before the continuation returns. Leaving it frees the underlying function
  539 -- pointer, and a later read crashes the process. Same rule and same reason as
  540 -- 'QuantLib.Internal.Common.withCustomPayoff'.
  541 --
  542 -- @f@ must be total: an exception thrown inside it propagates out through C++, potentially from
  543 -- the middle of a curve bootstrap. Prefer 'derivedQuote' whenever its 'QuoteOp' catalogue fits --
  544 -- it has neither restriction.
  545 withDerivedQuote :: (Double -> Double) -- ^f(value)
  546   -> GenQuote q -> (Quote -> IO b) -> IO b
  547 withDerivedQuote f q k = withPayoffFun f (\fp -> qlDerivedQuoteFromFunction q fp >>= k)
  548 
  549 -- |As 'compositeQuote', but combining the two quotes with an arbitrary Haskell function. Same
  550 -- continuation-lifetime and totality rules as 'withDerivedQuote'.
  551 withCompositeQuote :: (Double -> Double -> Double) -- ^f(value1, value2)
  552   -> GenQuote q1 -> GenQuote q2 -> (Quote -> IO b) -> IO b
  553 withCompositeQuote f q1 q2 k = withQuoteBinaryFun f (\fp -> qlCompositeQuoteFromFunction q1 q2 fp >>= k)
  554 
  555 -- |As 'multiCompositeQuote', but folding with an arbitrary Haskell function. The whole element
  556 -- vector is passed per evaluation, so this crosses into Haskell once per value, not once per
  557 -- element. Same continuation-lifetime and totality rules as 'withDerivedQuote'.
  558 withMultiCompositeQuote :: ([Double] -> Double) -- ^f(values)
  559   -> [GenQuote q] -> (Quote -> IO b) -> IO b
  560 withMultiCompositeQuote f qs k = withBasketAccumulateFun f (\fp -> qlMultiCompositeQuoteFromFunction qs fp >>= k)
  561 
  562 -- vim: set ff=unix ts=8 sts=2 sw=2 et:
  563 
  564 foreign import ccall safe "QuantLib/Quote.chs.h qlSimpleQuote"
  565   simpleQuote'_ :: (C2HSImp.CDouble -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO (C2HSImp.Ptr (CSimpleQuote')))))
  566 
  567 foreign import ccall safe "QuantLib/Quote.chs.h qlDeltaVolQuote1"
  568   deltaVolQuote'_ :: (C2HSImp.CDouble -> ((C2HSImp.Ptr (CQuote')) -> (C2HSImp.CDouble -> (C2HSImp.CInt -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO (C2HSImp.Ptr (CDeltaVolQuote'))))))))
  569 
  570 foreign import ccall safe "QuantLib/Quote.chs.h qlDeltaVolQuote2"
  571   atmVolQuote'_ :: ((C2HSImp.Ptr (CQuote')) -> (C2HSImp.CInt -> (C2HSImp.CDouble -> (C2HSImp.CInt -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO (C2HSImp.Ptr (CDeltaVolQuote'))))))))
  572 
  573 foreign import ccall safe "QuantLib/Quote.chs.h qlQuoteValue"
  574   value'_ :: ((C2HSImp.Ptr (CQuote')) -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO C2HSImp.CDouble)))
  575 
  576 foreign import ccall safe "QuantLib/Quote.chs.h qlSimpleQuoteSetValue"
  577   setValue'_ :: ((C2HSImp.Ptr (CSimpleQuote')) -> (C2HSImp.CDouble -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO C2HSImp.CDouble))))
  578 
  579 foreign import ccall safe "QuantLib/Quote.chs.h qlEurodollarFuturesImpliedStdDevQuote"
  580   eurodollarFuturesImpliedStdDevQuote'_ :: ((C2HSImp.Ptr (CQuote')) -> ((C2HSImp.Ptr (CQuote')) -> ((C2HSImp.Ptr (CQuote')) -> (C2HSImp.CDouble -> (C2HSImp.CDouble -> (C2HSImp.CDouble -> (C2HSImp.CUInt -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO (C2HSImp.Ptr (CQuote')))))))))))
  581 
  582 foreign import ccall safe "QuantLib/Quote.chs.h qlForwardSwapQuote"
  583   forwardSwapQuote'_ :: ((C2HSImp.Ptr (CSwapIndex')) -> ((C2HSImp.Ptr (CQuote')) -> (C2HSImp.CInt -> (C2HSImp.CInt -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO (C2HSImp.Ptr (CQuote'))))))))
  584 
  585 foreign import ccall safe "QuantLib/Quote.chs.h qlForwardValueQuote"
  586   forwardValueQuote'_ :: ((C2HSImp.Ptr (CIndex')) -> (C2HSImp.CInt -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO (C2HSImp.Ptr (CQuote'))))))
  587 
  588 foreign import ccall safe "QuantLib/Quote.chs.h qlFuturesConvAdjustmentQuote1"
  589   futuresConvAdjustmentQuote''_ :: ((C2HSImp.Ptr (CIborIndex')) -> ((C2HSImp.Ptr C2HSImp.CChar) -> ((C2HSImp.Ptr (CQuote')) -> ((C2HSImp.Ptr (CQuote')) -> ((C2HSImp.Ptr (CQuote')) -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO (C2HSImp.Ptr (CQuote')))))))))
  590 
  591 foreign import ccall safe "QuantLib/Quote.chs.h qlFuturesConvAdjustmentQuote"
  592   futuresConvAdjustmentQuote'_ :: ((C2HSImp.Ptr (CIborIndex')) -> (C2HSImp.CInt -> ((C2HSImp.Ptr (CQuote')) -> ((C2HSImp.Ptr (CQuote')) -> ((C2HSImp.Ptr (CQuote')) -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO (C2HSImp.Ptr (CQuote')))))))))
  593 
  594 foreign import ccall safe "QuantLib/Quote.chs.h qlImpliedStdDevQuote"
  595   impliedStdDevQuote'_ :: (C2HSImp.CInt -> ((C2HSImp.Ptr (CQuote')) -> ((C2HSImp.Ptr (CQuote')) -> (C2HSImp.CDouble -> (C2HSImp.CDouble -> (C2HSImp.CDouble -> (C2HSImp.CUInt -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO (C2HSImp.Ptr (CQuote')))))))))))
  596 
  597 foreign import ccall safe "QuantLib/Quote.chs.h qlLastFixingQuote"
  598   lastFixingQuote'_ :: ((C2HSImp.Ptr (CIndex')) -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO (C2HSImp.Ptr (CQuote')))))
  599 
  600 foreign import ccall safe "QuantLib/Quote.chs.h qlQuoteIsValid"
  601   isValid'_ :: ((C2HSImp.Ptr (CQuote')) -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO C2HSImp.CInt)))
  602 
  603 foreign import ccall safe "QuantLib/Quote.chs.h qlRelinkableQuote"
  604   relinkableQuote'_ :: ((C2HSImp.Ptr (CQuote')) -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO (C2HSImp.Ptr (CRelinkableQuote')))))
  605 
  606 foreign import ccall safe "QuantLib/Quote.chs.h qlRelinkableQuoteLinkTo"
  607   linkTo'_ :: ((C2HSImp.Ptr (CRelinkableQuote')) -> ((C2HSImp.Ptr (CQuote')) -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO ()))))
  608 
  609 foreign import ccall safe "QuantLib/Quote.chs.h qlDerivedQuote"
  610   derivedQuote'_ :: (C2HSImp.CInt -> ((C2HSImp.Ptr (CQuote')) -> (C2HSImp.CDouble -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO (C2HSImp.Ptr (CQuote')))))))
  611 
  612 foreign import ccall safe "QuantLib/Quote.chs.h qlCompositeQuote"
  613   compositeQuote'_ :: (C2HSImp.CInt -> ((C2HSImp.Ptr (CQuote')) -> ((C2HSImp.Ptr (CQuote')) -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO (C2HSImp.Ptr (CQuote')))))))
  614 
  615 foreign import ccall safe "QuantLib/Quote.chs.h qlMultiCompositeQuote"
  616   multiCompositeQuote'_ :: (C2HSImp.CInt -> (C2HSImp.CUInt -> ((C2HSImp.Ptr (C2HSImp.Ptr (CQuote'))) -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO (C2HSImp.Ptr (CQuote')))))))
  617 
  618 foreign import ccall safe "QuantLib/Quote.chs.h qlDerivedQuoteFromFunction"
  619   qlDerivedQuoteFromFunction'_ :: ((C2HSImp.Ptr (CQuote')) -> ((C2HSImp.FunPtr (C2HSImp.CDouble -> (IO C2HSImp.CDouble))) -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO (C2HSImp.Ptr (CQuote'))))))
  620 
  621 foreign import ccall safe "QuantLib/Quote.chs.h qlCompositeQuoteFromFunction"
  622   qlCompositeQuoteFromFunction'_ :: ((C2HSImp.Ptr (CQuote')) -> ((C2HSImp.Ptr (CQuote')) -> ((C2HSImp.FunPtr (C2HSImp.CDouble -> (C2HSImp.CDouble -> (IO C2HSImp.CDouble)))) -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO (C2HSImp.Ptr (CQuote')))))))
  623 
  624 foreign import ccall safe "QuantLib/Quote.chs.h qlMultiCompositeQuoteFromFunction"
  625   qlMultiCompositeQuoteFromFunction'_ :: (C2HSImp.CUInt -> ((C2HSImp.Ptr (C2HSImp.Ptr (CQuote'))) -> ((C2HSImp.FunPtr ((C2HSImp.Ptr C2HSImp.CDouble) -> (C2HSImp.CUInt -> (IO C2HSImp.CDouble)))) -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO (C2HSImp.Ptr (CQuote')))))))