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 TemplateHaskell, FlexibleInstances #-}
    6 module QuantLib.CashFlow
    7   (
    8     -- * Types
    9     -- ** Cash-flow hierarchy
   10     GenCashFlow
   11   , CashFlow
   12   , GenCoupon
   13   , Coupon
   14   , GenFloatingRateCoupon
   15   , FloatingRateCoupon
   16   , GenDigitalCoupon
   17   , DigitalCoupon
   18   , GenIndexedCashFlow
   19   , IndexedCashFlow
   20   , FixedRateCoupon
   21   , IborCoupon
   22   , FxResetCoupon
   23   , FxResetNotionalExchange
   24   , AverageBMACoupon
   25   , StrippedCappedFlooredCoupon
   26   , CmsCoupon
   27   , DigitalCmsCoupon
   28   , DigitalCmsSpreadCoupon
   29   , MultipleResetsCoupon
   30   , OvernightIndexedCoupon
   31   , RangeAccrualFloatersCoupon
   32   , CPICoupon
   33   , YoYInflationCoupon
   34   , ZeroInflationCashFlow
   35   , CPICashFlow
   36   , EquityCashFlow
   37   , Dividend
   38 
   39     -- ** Legs
   40   , GenLeg
   41   , Leg
   42   , CouponLeg
   43 
   44     -- ** Coupon pricers
   45   , GenFloatingRateCouponPricer
   46   , FloatingRateCouponPricer
   47   , CmsCouponPricer
   48   , CPICouponPricer
   49   , YoYInflationCouponPricer
   50   , EquityCashFlowPricer
   51   , FxResetPricer
   52 
   53     -- ** Configuration
   54   , FxReset(..)
   55   , FxResetConvention(..)
   56   , DurationType(..)
   57   , RateAveragingType(..)
   58   , TimingAdjustment(..)
   59   , PositionType(..)
   60   , CPIInterpolationType(..)
   61   , YieldCurveModel(..)
   62   , Discounting(..)
   63   , BpsDiscounting(..)
   64   , ReplicationType(..)
   65   , DigitalReplication
   66   , LinearTsrPricerStrategy(..)
   67   , LinearTsrPricerSettings(..)
   68   , IborLegOpts(..)
   69   , defaultIborLegOpts
   70   , CmsLegOpts(..)
   71   , defaultCmsLegOpts
   72   , DigitalIborLegOpts(..)
   73   , defaultDigitalIborLegOpts
   74   , DigitalCmsLegOpts(..)
   75   , defaultDigitalCmsLegOpts
   76   , DigitalCmsSpreadLegOpts(..)
   77   , defaultDigitalCmsSpreadLegOpts
   78   , MultipleResetsLegOpts(..)
   79   , defaultMultipleResetsLegOpts
   80 
   81   , StubIndexSelection(..)
   82 
   83     -- * Constructors
   84   , stubIborCoupon
   85   , fxResetCoupon
   86   , fxResetNotionalExchange
   87   , discountingFxResetPricer
   88     -- ** Hierarchy conversion
   89   , asLeg
   90   , asCashFlow
   91   , asCoupon
   92   , asFloatingRateCoupon
   93   , asFloatingRateCouponPricer
   94   , toCouponLeg
   95 
   96     -- ** Cash flows and coupons
   97   , leg
   98   , cashFlowLeg
   99   , simpleCashFlow
  100   , indexedCashFlow
  101   , redemption
  102   , amortizingPayment
  103   , fixedRateCoupon
  104   , floatingRateCoupon
  105   , iborCoupon
  106   , averageBmaCoupon
  107   , cappedFlooredCoupon
  108   , strippedCappedFlooredCoupon
  109   , cappedFlooredIborCoupon
  110   , digitalIborCoupon
  111   , digitalCoupon
  112   , multipleResetsCoupon
  113   , rangeAccrualFloatersCoupon
  114   , overnightIndexedCoupon
  115   , cappedFlooredOvernightIndexedCoupon
  116   , cpiCoupon
  117   , cpiCouponFromBaseDate
  118   , cpiCouponWithBaseDate
  119   , yoyInflationCoupon
  120   , zeroInflationCashFlow
  121   , cpiCashFlow
  122   , equityCashFlow
  123 
  124     -- ** CMS coupons and digital replication
  125   , cmsCoupon
  126   , cappedFlooredCmsCoupon
  127   , cmsSpreadCoupon
  128   , cappedFlooredCmsSpreadCoupon
  129   , digitalReplication
  130   , digitalCmsCoupon
  131   , digitalCmsSpreadCoupon
  132 
  133     -- ** Dividends
  134   , fixedDividend
  135   , fractionalDividendWithNominal
  136   , fractionalDividend
  137 
  138     -- ** Coupon legs
  139   , fixedRateLeg
  140   , averageBmaLeg
  141   , iborLeg
  142   , iborLegWithOptions
  143   , digitalIborLeg
  144   , cmsLeg
  145   , cmsLegWithOptions
  146   , cmsSpreadLeg
  147   , digitalCmsLeg
  148   , digitalCmsSpreadLeg
  149   , multipleResetsLeg
  150   , overnightLeg
  151   , rangeAccrualLeg
  152   , cpiLeg
  153   , yoyInflationLeg
  154 
  155     -- ** Coupon pricers
  156   , blackIborCouponPricer
  157   , blackIborQuantoCouponPricer
  158   , analyticHaganPricer
  159   , numericHaganPricer
  160   , linearTsrPricer
  161   , lognormalCmsSpreadPricer
  162   , rangeAccrualPricerByBgm
  163   , averagingMultipleResetsPricer
  164   , compoundingMultipleResetsPricer
  165   , compoundingOvernightIndexedCouponPricer
  166   , arithmeticAveragedOvernightIndexedCouponPricer
  167   , blackCompoundingOvernightIndexedCouponPricer
  168   , blackAveragingOvernightIndexedCouponPricer
  169   , cpiCouponPricer
  170   , cpiCouponPricerWithVol
  171   , blackYoyInflationCouponPricer
  172   , unitDisplacedBlackYoyInflationCouponPricer
  173   , bachelierYoyInflationCouponPricer
  174   , equityQuantoCashFlowPricer
  175 
  176     -- * Mutators
  177   , HasFxResetPricer(..)
  178   , setFxResetLegPricer
  179   , setCpiCouponPricer
  180   , setFloatingRateCouponPricer
  181   , setYoyInflationCouponPricer
  182   , setEquityCashFlowPricer
  183   , setCouponPricer
  184   , setCouponPricers
  185   , setEquityLegPricer
  186 
  187     -- * Inspectors
  188   , fxResetObservation
  189   , fxResetValueDate
  190   , fxResetRate
  191     -- ** Coupon fixings
  192   , HasFixingDates(..)
  193   , fixingDependencies
  194   , HasIndexFixings(..)
  195   , baseFixing
  196   , indexFixing
  197   , adjustedFixing
  198 
  199     -- ** Leg analytics
  200   , amount
  201   , date
  202   , duration
  203   , accrualDays
  204   , accrualEndDate
  205   , accrualPeriod
  206   , accrualStartDate
  207   , accruedAmount
  208   , accruedDays
  209   , accruedPeriod
  210   , atmRate
  211   , basisPointValue
  212   , bps
  213   , convexity
  214   , isExpired
  215   , maturityDate
  216   , startDate
  217   , cashFlows
  218   , nextCashFlows
  219   , nextCashFlowAmount
  220   , nextCashFlowDate
  221   , nextCouponRate
  222   , previousCashFlows
  223   , previousCashFlowAmount
  224   , previousCashFlowDate
  225   , previousCouponRate
  226   , nominal
  227   , npv
  228   , npvBps
  229   , referencePeriodEnd
  230   , referencePeriodStart
  231   , yield
  232   , yieldValueBasisPoint
  233   , zSpread
  234 
  235     -- ** Coupon rates and prices
  236   , coupons
  237   , couponAccrualStartDates
  238   , couponNominal
  239   , couponAccruedAmount
  240   , rate
  241   , price
  242   , interestRate
  243   , indexRatio
  244   , convexityAdjustment
  245   , swapletRate
  246   , swapletPrice
  247   , capletPrice
  248   , capletRate
  249   , floorletPrice
  250   , floorletRate
  251   , replicationType
  252   , gap
  253 
  254     -- ** Capped and floored coupons
  255   , capRate
  256   , floorRate
  257   , effectiveCap
  258   , effectiveFloor
  259   , isCap
  260   , isFloor
  261   , isCollar
  262   , callOptionRate
  263   , putOptionRate
  264   , priceWithoutOptionality
  265   ) where
  266 import qualified Foreign.C.Types as C2HSImp
  267 import qualified Foreign.ForeignPtr as C2HSImp
  268 import qualified Foreign.Marshal.Utils as C2HSImp
  269 import qualified Foreign.Ptr as C2HSImp
  270 import qualified System.IO.Unsafe as C2HSImp
  271 
  272 
  273 import Language.Haskell.TH(mkName, varT)
  274 import QuantLib.Internal
  275 import Foreign.C.Types(CInt)
  276 import Foreign.Ptr(Ptr)
  277 import Foreign.Marshal.Alloc(alloca)
  278 import Foreign.Storable(peek)
  279 import QuantLib.InterestRate(Compounding, VolatilityType)
  280 import QuantLib.Time.Schedule(Frequency)
  281 import QuantLib.Time.Calendar(calendar, CalendarConstructor(..))
  282 import QuantLib.Internal.Type
  283 import QuantLib.Internal.Common
  284 import QuantLib.Internal.Syntax(deriveOptionsRecord)
  285 import Data.Maybe(fromMaybe)
  286 import Data.List.NonEmpty(NonEmpty(..), toList)
  287 
  288 
  289 
  290 
  291 
  292 
  293 
  294 
  295 
  296 
  297 
  298 
  299 
  300 
  301 
  302 
  303 
  304 
  305 
  306 
  307 
  308 
  309 
  310 
  311 
  312 
  313 
  314 
  315 
  316 
  317 
  318 
  319 
  320 
  321 
  322 
  323 
  324 
  325 
  326 
  327 
  328 
  329 
  330 
  331 
  332 
  333 
  334 
  335 
  336 
  337 
  338 
  339 
  340 
  341 
  342 
  343 
  344 
  345 
  346 
  347 
  348 
  349 
  350 
  351 
  352 
  353 
  354 
  355 
  356 
  357 
  358 
  359 
  360 
  361 
  362 
  363 
  364 
  365 
  366 
  367 
  368 
  369 
  370 
  371 
  372 
  373 
  374 
  375 
  376 
  377 
  378 
  379 
  380 
  381 
  382 
  383 
  384 
  385 
  386 
  387 
  388 
  389 
  390 
  391 
  392 
  393 
  394 
  395 
  396 
  397 
  398 
  399 
  400 
  401 data DurationType = Simple
  402                   | Macaulay
  403                   | Modified
  404   deriving (Enum,Show,Eq,Read)
  405 
  406 
  407 data RateAveragingType = AveragingSimple
  408                        | AveragingCompound
  409   deriving (Enum,Show,Eq,Read)
  410 
  411 
  412 data TimingAdjustment = Black76
  413                       | BivariateLognormal
  414   deriving (Enum,Show,Eq,Read)
  415 
  416 
  417 data YieldCurveModel = Standard
  418                      | ExactYield
  419                      | ParallelShifts
  420                      | NonParallelShifts
  421   deriving (Enum,Show,Eq,Read)
  422 
  423 
  424 data ReplicationType = ReplicationSub
  425                      | ReplicationCentral
  426                      | ReplicationSuper
  427   deriving (Show,Eq,Read)
  428 instance Enum ReplicationType where
  429   succ ReplicationSub = ReplicationCentral
  430   succ ReplicationCentral = ReplicationSuper
  431   succ ReplicationSuper = error "ReplicationType.succ: ReplicationSuper has no successor"
  432 
  433   pred ReplicationCentral = ReplicationSub
  434   pred ReplicationSuper = ReplicationCentral
  435   pred ReplicationSub = error "ReplicationType.pred: ReplicationSub has no predecessor"
  436 
  437   enumFromTo from to = go from
  438     where
  439       end = fromEnum to
  440       go v = case compare (fromEnum v) end of
  441                  LT -> v : go (succ v)
  442                  EQ -> [v]
  443                  GT -> []
  444 
  445   enumFrom from = enumFromTo from ReplicationSuper
  446 
  447   fromEnum ReplicationSub = 0
  448   fromEnum ReplicationCentral = 1
  449   fromEnum ReplicationSuper = 2
  450 
  451   toEnum 0 = ReplicationSub
  452   toEnum 1 = ReplicationCentral
  453   toEnum 2 = ReplicationSuper
  454   toEnum unmatched = error ("ReplicationType.toEnum: Cannot match " ++ show unmatched)
  455 
  456 
  457 
  458 -- IborLegOpts/CmsLegOpts bundle every IborLeg/CmsLeg builder-method param beyond
  459 -- iborLeg/cmsLeg's original 12-arg shape, pre-populated with upstream's own defaults via
  460 -- defaultIborLegOpts/defaultCmsLegOpts, overridden through record-update syntax at the
  461 -- call site -- see OISRateHelperOpts (QuantLib.TermStructure.Yield) for the worked
  462 -- example this follows. The Calendar fields are Maybe here (unlike the raw bindings'
  463 -- plain Calendar) since a real Calendar is only obtainable in IO (`calendar Null`) and
  464 -- can't live in a pure default record value -- iborLegWithOptions/cmsLegWithOptions substitute a fresh
  465 -- Null calendar for Nothing. This splice must stay textually before every
  466 -- {#fun#}-generated binding in this file: c2hs always appends its raw foreign-import
  467 -- stubs at the physical end of the generated module regardless of where in the .chs a
  468 -- {#fun#} hook appears, and a top-level TH splice anywhere in between would otherwise
  469 -- split the file into declaration groups that can't see each other, breaking every
  470 -- earlier {#fun#} wrapper's reference to its own (always-last) foreign-import stub.
  471 $(deriveOptionsRecord "IborLegOpts" ["ibor2"]
  472   [ ("ilgPaymentLag", [t|Int|], [|0|])
  473   , ("ilgPaymentCalendar", [t|Maybe Calendar|], [|Nothing|])
  474   , ("ilgExCouponPeriod", [t|(Int, TimeUnit)|], [|(0, Days)|])
  475   , ("ilgExCouponCalendar", [t|Maybe Calendar|], [|Nothing|])
  476   , ("ilgExCouponConvention", [t|BusinessDayConvention|], [|Unadjusted|])
  477   , ("ilgExCouponEndOfMonth", [t|Bool|], [|False|])
  478   , ("ilgFixingConvention", [t|BusinessDayConvention|], [|Preceding|])
  479   , ("ilgUseIndexedCoupons", [t|Maybe Bool|], [|Nothing|])
  480   , ("ilgStubIndexSelection", [t|Maybe (StubIndexSelection $(varT (mkName "ibor2")))|], [|Nothing|])
  481   ])
  482 
  483 -- CmsLegOpts omits the IborLegOpts fields that QuantLib's CmsLeg builder lacks.
  484 $(deriveOptionsRecord "CmsLegOpts" []
  485   [ ("cmslExCouponPeriod", [t|(Int, TimeUnit)|], [|(0, Days)|])
  486   , ("cmslExCouponCalendar", [t|Maybe Calendar|], [|Nothing|])
  487   , ("cmslExCouponConvention", [t|BusinessDayConvention|], [|Unadjusted|])
  488   , ("cmslExCouponEndOfMonth", [t|Bool|], [|False|])
  489   , ("cmslFixingConvention", [t|BusinessDayConvention|], [|Preceding|])
  490   ])
  491 
  492 $(deriveOptionsRecord "DigitalCmsLegOpts" []
  493   [ ("dcmlCallStrikes", [t|[Double]|], [|[]|])
  494   , ("dcmlCallPosition", [t|PositionType|], [|Long|])
  495   , ("dcmlCallAtm", [t|Bool|], [|False|])
  496   , ("dcmlCallPayoffs", [t|[Double]|], [|[]|])
  497   , ("dcmlPutStrikes", [t|[Double]|], [|[]|])
  498   , ("dcmlPutPosition", [t|PositionType|], [|Long|])
  499   , ("dcmlPutAtm", [t|Bool|], [|False|])
  500   , ("dcmlPutPayoffs", [t|[Double]|], [|[]|])
  501   , ("dcmlReplication", [t|Maybe DigitalReplication|], [|Nothing|])
  502   , ("dcmlNakedOption", [t|Bool|], [|False|])
  503   ])
  504 
  505 -- Same shape as DigitalCmsLegOpts -- DigitalCmsSpreadLeg's builder methods (upstream
  506 -- ql/experimental/coupons/digitalcmsspreadcoupon.hpp) are identical to DigitalCmsLeg's, only the
  507 -- index type differs (SwapSpreadIndex, not SwapIndex).
  508 $(deriveOptionsRecord "DigitalCmsSpreadLegOpts" []
  509   [ ("dcmslCallStrikes", [t|[Double]|], [|[]|])
  510   , ("dcmslCallPosition", [t|PositionType|], [|Long|])
  511   , ("dcmslCallAtm", [t|Bool|], [|False|])
  512   , ("dcmslCallPayoffs", [t|[Double]|], [|[]|])
  513   , ("dcmslPutStrikes", [t|[Double]|], [|[]|])
  514   , ("dcmslPutPosition", [t|PositionType|], [|Long|])
  515   , ("dcmslPutAtm", [t|Bool|], [|False|])
  516   , ("dcmslPutPayoffs", [t|[Double]|], [|[]|])
  517   , ("dcmslReplication", [t|Maybe DigitalReplication|], [|Nothing|])
  518   , ("dcmslNakedOption", [t|Bool|], [|False|])
  519   ])
  520 
  521 $(deriveOptionsRecord "DigitalIborLegOpts" []
  522   [ ("dilCallStrikes", [t|[Double]|], [|[]|]), ("dilCallPosition", [t|PositionType|], [|Long|]), ("dilCallAtm", [t|Bool|], [|False|]), ("dilCallPayoffs", [t|[Double]|], [|[]|])
  523   , ("dilPutStrikes", [t|[Double]|], [|[]|]), ("dilPutPosition", [t|PositionType|], [|Long|]), ("dilPutAtm", [t|Bool|], [|False|]), ("dilPutPayoffs", [t|[Double]|], [|[]|])
  524   , ("dilReplication", [t|Maybe DigitalReplication|], [|Nothing|]), ("dilNakedOption", [t|Bool|], [|False|]) ])
  525 
  526 $(deriveOptionsRecord "MultipleResetsLegOpts" []
  527   [ ("mrlNotionals", [t|NonEmpty Double|], [|1.0 :| []|]), ("mrlPaymentCalendar", [t|Maybe Calendar|], [|Nothing|]), ("mrlPaymentLag", [t|Int|], [|0|]), ("mrlFixingDays", [t|[Word]|], [|[]|]), ("mrlGearings", [t|[Double]|], [|[]|]), ("mrlCouponSpreads", [t|[Double]|], [|[]|]), ("mrlRateSpreads", [t|[Double]|], [|[]|]), ("mrlExCouponPeriod", [t|(Int, TimeUnit)|], [|(0, Days)|]), ("mrlExCouponCalendar", [t|Maybe Calendar|], [|Nothing|]), ("mrlExCouponConvention", [t|BusinessDayConvention|], [|Unadjusted|]), ("mrlExCouponEndOfMonth", [t|Bool|], [|False|]), ("mrlAveragingMethod", [t|RateAveragingType|], [|AveragingCompound|]) ])
  528 
  529 -- |Build a 'Leg' of plain, predetermined cash flows from parallel amount\/date arrays.
  530 qlLeg :: ([Double]) -> ([Day]) -> IO ((Leg))
  531 qlLeg a1 a2 =
  532   withDoubleArray a1 $ \(a1'1, a1'2) -> 
  533   withDayPtr a2 $ \a2' -> 
  534   preErrorCheck $ \a3' -> 
  535   qlLeg'_ a1'1  a1'2 a2' a3' >>= \res ->
  536   peekLeg res >>= \res' ->
  537   errorCheck  a3'>>
  538   return (res')
  539 
  540 
  541 
  542 leg :: [(Day, Double)] -- ^amounts and dates
  543   -> IO Leg
  544 leg f = qlLeg fs ds where (ds, fs) = unzip f
  545 
  546 -- |A predetermined payment, suitable for mixing with other cash-flow kinds in
  547 -- 'cashFlowLeg'.  For a leg made entirely of such payments, 'leg' is a more concise API.
  548 simpleCashFlow :: (Double) -- ^amount
  549  -> (Day) -- ^payment date
  550  -> IO ((CashFlow))
  551 simpleCashFlow a1 a2 =
  552   let {a1' = realToFrac a1} in 
  553   withDay a2 $ \a2' -> 
  554   preErrorCheck $ \a3' -> 
  555   simpleCashFlow'_ a1' a2' a3' >>= \res ->
  556   peekCashFlow res >>= \res' ->
  557   errorCheck  a3'>>
  558   return (res')
  559 
  560 
  561 
  562 -- |The undiscounted amount paid by a cash flow on its payment date.
  563 amount :: (GenCashFlow cf) -- ^cashFlow
  564  -> IO ((Double))
  565 amount a1 =
  566   withCashFlow a1 $ \a1' -> 
  567   preErrorCheck $ \a2' -> 
  568   amount'_ a1' a2' >>= \res ->
  569   let {res' = realToFrac res} in
  570   errorCheck  a2'>>
  571   return (res')
  572 
  573 
  574 
  575 -- |The payment date of a cash flow.
  576 date :: (GenCashFlow cf) -- ^cashFlow
  577  -> (Day)
  578 date a1 =
  579   C2HSImp.unsafePerformIO $
  580   withCashFlow a1 $ \a1' -> 
  581   date'_ a1' >>= \res ->
  582   let {res' = toDay res} in
  583   return (res')
  584 
  585 
  586 
  587 -- |A payment of @notional * i(fixingDate) \/ i(baseDate)@, or the same ratio minus one when
  588 -- /growthOnly/ is true.  QuantLib does no date adjustment here; callers supply the already
  589 -- adjusted fixing and payment dates.  This is the generic building block behind the specialized
  590 -- CPI and equity cash flows, and accepts any bound t'GenIndex'.
  591 indexedCashFlow :: (Double) -- ^notional
  592  -> (GenIndex idx) -- ^index
  593  -> (Day) -- ^base date
  594  -> (Day) -- ^fixing date
  595  -> (Day) -- ^payment date
  596  -> (Bool) -- ^growthOnly
  597  -> IO ((IndexedCashFlow))
  598 indexedCashFlow a1 a2 a3 a4 a5 a6 =
  599   let {a1' = realToFrac a1} in 
  600   withIndex a2 $ \a2' -> 
  601   withDay a3 $ \a3' -> 
  602   withDay a4 $ \a4' -> 
  603   withDay a5 $ \a5' -> 
  604   let {a6' = C2HSImp.fromBool a6} in 
  605   preErrorCheck $ \a7' -> 
  606   indexedCashFlow'_ a1' a2' a3' a4' a5' a6' a7' >>= \res ->
  607   peekIndexedCashFlow res >>= \res' ->
  608   errorCheck  a7'>>
  609   return (res')
  610 
  611 
  612 
  613 -- |The fixing used as the base of an indexed cash flow's return ratio.
  614 baseFixing :: (GenIndexedCashFlow icf) -> IO ((Double))
  615 baseFixing a1 =
  616   withIndexedCashFlow a1 $ \a1' -> 
  617   preErrorCheck $ \a2' -> 
  618   baseFixing'_ a1' a2' >>= \res ->
  619   let {res' = realToFrac res} in
  620   errorCheck  a2'>>
  621   return (res')
  622 
  623 
  624 
  625 -- |The fixing used as the numerator of an indexed cash flow's return ratio.
  626 indexFixing :: (GenIndexedCashFlow icf) -> IO ((Double))
  627 indexFixing a1 =
  628   withIndexedCashFlow a1 $ \a1' -> 
  629   preErrorCheck $ \a2' -> 
  630   indexFixing'_ a1' a2' >>= \res ->
  631   let {res' = realToFrac res} in
  632   errorCheck  a2'>>
  633   return (res')
  634 
  635 
  636 
  637 -- |A fixed coupon with explicitly supplied payment, accrual, reference-period, and ex-coupon
  638 -- dates.  'Nothing' for a reference or ex-coupon date passes QuantLib's empty @Date()@. A
  639 -- homogeneous list of fixed coupons can be passed directly to 'cashFlowLeg'; use 'asCashFlow'
  640 -- only when mixing it with other cash-flow types.
  641 fixedRateCoupon :: (Day) -- ^paymentDate
  642  -> (Double) -- ^nominal
  643  -> (Double) -- ^rate
  644  -> (DayCounter) -- ^dayCounter
  645  -> (Day) -- ^accrualStartDate
  646  -> (Day) -- ^accrualEndDate
  647  -> (Maybe Day) -- ^referencePeriodStart
  648  -> (Maybe Day) -- ^referencePeriodEnd
  649  -> (Maybe Day) -- ^exCouponDate
  650  -> IO ((FixedRateCoupon))
  651 fixedRateCoupon a1 a2 a3 a4 a5 a6 a7 a8 a9 =
  652   withDay a1 $ \a1' -> 
  653   let {a2' = realToFrac a2} in 
  654   let {a3' = realToFrac a3} in 
  655   withDayCounter a4 $ \a4' -> 
  656   withDay a5 $ \a5' -> 
  657   withDay a6 $ \a6' -> 
  658   withMaybeDay a7 $ \a7' -> 
  659   withMaybeDay a8 $ \a8' -> 
  660   withMaybeDay a9 $ \a9' -> 
  661   preErrorCheck $ \a10' -> 
  662   fixedRateCoupon'_ a1' a2' a3' a4' a5' a6' a7' a8' a9' a10' >>= \res ->
  663   peekFixedRateCoupon res >>= \res' ->
  664   errorCheck  a10'>>
  665   return (res')
  666 
  667 
  668 
  669 -- |The coupon's own fixed rate, as an 'InterestRate' (rate value plus day counter/compounding/
  670 -- frequency) rather than a bare rate -- distinct from 'rate', which returns a
  671 -- bare @Double@ for the (possibly index-derived) accrual rate.
  672 interestRate :: (FixedRateCoupon) -> IO ((InterestRate))
  673 interestRate a1 =
  674   withFixedRateCoupon a1 $ \a1' -> 
  675   interestRate'_ a1' >>= \res ->
  676   peekInterestRate res >>= \res' ->
  677   return (res')
  678 
  679 
  680 
  681 -- |A generic floating-rate coupon.  Attach a 'FloatingRateCouponPricer' to the resulting leg
  682 -- with 'setCouponPricer' before evaluating a coupon whose rate requires one.  'Nothing' dates
  683 -- pass QuantLib's empty @Date()@; all other constructor parameters are explicit.
  684 floatingRateCoupon :: (Day) -- ^paymentDate
  685  -> (Double) -- ^nominal
  686  -> (Day) -- ^accrualStartDate
  687  -> (Day) -- ^accrualEndDate
  688  -> (Word) -- ^fixingDays
  689  -> (GenInterestRateIndex ridx) -- ^index
  690  -> (Double) -- ^gearing
  691  -> (Double) -- ^spread
  692  -> (Maybe Day) -- ^referencePeriodStart
  693  -> (Maybe Day) -- ^referencePeriodEnd
  694  -> (DayCounter) -- ^dayCounter
  695  -> (Bool) -- ^inArrears
  696  -> (Maybe Day) -- ^exCouponDate
  697  -> (BusinessDayConvention) -- ^fixingConvention
  698  -> IO ((FloatingRateCoupon))
  699 floatingRateCoupon a1 a2 a3 a4 a5 a6 a7 a8 a9 a10 a11 a12 a13 a14 =
  700   withDay a1 $ \a1' -> 
  701   let {a2' = realToFrac a2} in 
  702   withDay a3 $ \a3' -> 
  703   withDay a4 $ \a4' -> 
  704   let {a5' = fromIntegral a5} in 
  705   withInterestRateIndex a6 $ \a6' -> 
  706   let {a7' = realToFrac a7} in 
  707   let {a8' = realToFrac a8} in 
  708   withMaybeDay a9 $ \a9' -> 
  709   withMaybeDay a10 $ \a10' -> 
  710   withDayCounter a11 $ \a11' -> 
  711   let {a12' = C2HSImp.fromBool a12} in 
  712   withMaybeDay a13 $ \a13' -> 
  713   let {a14' = fromEnumC a14} in 
  714   preErrorCheck $ \a15' -> 
  715   floatingRateCoupon'_ a1' a2' a3' a4' a5' a6' a7' a8' a9' a10' a11' a12' a13' a14' a15' >>= \res ->
  716   peekFloatingRateCoupon res >>= \res' ->
  717   errorCheck  a15'>>
  718   return (res')
  719 
  720 
  721 
  722 -- |An Ibor-specific floating coupon.  Prefer this to 'floatingRateCoupon' when the index is
  723 -- Ibor: QuantLib then uses IborCoupon's fixing value/maturity-date logic rather than the base
  724 -- floating-coupon implementation.  Date and pricer handling are as in 'floatingRateCoupon'.
  725 iborCoupon :: (Day) -- ^paymentDate
  726  -> (Double) -- ^nominal
  727  -> (Day) -- ^accrualStartDate
  728  -> (Day) -- ^accrualEndDate
  729  -> (Word) -- ^fixingDays
  730  -> (GenIborIndex ibor) -- ^index
  731  -> (Double) -- ^gearing
  732  -> (Double) -- ^spread
  733  -> (Maybe Day) -- ^referencePeriodStart
  734  -> (Maybe Day) -- ^referencePeriodEnd
  735  -> (DayCounter) -- ^dayCounter
  736  -> (Bool) -- ^inArrears
  737  -> (Maybe Day) -- ^exCouponDate
  738  -> (BusinessDayConvention) -- ^fixingConvention
  739  -> IO ((IborCoupon))
  740 iborCoupon a1 a2 a3 a4 a5 a6 a7 a8 a9 a10 a11 a12 a13 a14 =
  741   withDay a1 $ \a1' -> 
  742   let {a2' = realToFrac a2} in 
  743   withDay a3 $ \a3' -> 
  744   withDay a4 $ \a4' -> 
  745   let {a5' = fromIntegral a5} in 
  746   withIborIndex a6 $ \a6' -> 
  747   let {a7' = realToFrac a7} in 
  748   let {a8' = realToFrac a8} in 
  749   withMaybeDay a9 $ \a9' -> 
  750   withMaybeDay a10 $ \a10' -> 
  751   withDayCounter a11 $ \a11' -> 
  752   let {a12' = C2HSImp.fromBool a12} in 
  753   withMaybeDay a13 $ \a13' -> 
  754   let {a14' = fromEnumC a14} in 
  755   preErrorCheck $ \a15' -> 
  756   iborCoupon'_ a1' a2' a3' a4' a5' a6' a7' a8' a9' a10' a11' a12' a13' a14' a15' >>= \res ->
  757   peekIborCoupon res >>= \res' ->
  758   errorCheck  a15'>>
  759   return (res')
  760 
  761 
  762 
  763 -- |A BMA-index coupon with explicitly supplied accrual and reference dates.
  764 averageBmaCoupon :: (Day) -- ^paymentDate
  765  -> (Double) -- ^nominal
  766  -> (Day) -- ^accrualStartDate
  767  -> (Day) -- ^accrualEndDate
  768  -> (BMAIndex) -- ^index
  769  -> (Double) -- ^gearing
  770  -> (Double) -- ^spread
  771  -> (Maybe Day) -- ^referencePeriodStart
  772  -> (Maybe Day) -- ^referencePeriodEnd
  773  -> (DayCounter) -- ^dayCounter
  774  -> IO ((AverageBMACoupon))
  775 averageBmaCoupon a1 a2 a3 a4 a5 a6 a7 a8 a9 a10 =
  776   withDay a1 $ \a1' -> 
  777   let {a2' = realToFrac a2} in 
  778   withDay a3 $ \a3' -> 
  779   withDay a4 $ \a4' -> 
  780   withBMAIndex a5 $ \a5' -> 
  781   let {a6' = realToFrac a6} in 
  782   let {a7' = realToFrac a7} in 
  783   withMaybeDay a8 $ \a8' -> 
  784   withMaybeDay a9 $ \a9' -> 
  785   withDayCounter a10 $ \a10' -> 
  786   preErrorCheck $ \a11' -> 
  787   averageBmaCoupon'_ a1' a2' a3' a4' a5' a6' a7' a8' a9' a10' a11' >>= \res ->
  788   peekAverageBMACoupon res >>= \res' ->
  789   errorCheck  a11'>>
  790   return (res')
  791 
  792 
  793 
  794 -- |The fixing dates of the individual BMA rates being averaged over this coupon's accrual period.
  795 averageBmaCouponFixingDatesRaw :: (AverageBMACoupon) -> IO (([Day]))
  796 averageBmaCouponFixingDatesRaw a1 =
  797   withAverageBMACoupon a1 $ \a1' -> 
  798   preIntArray $ \(a2'1, a2'2) -> 
  799   preErrorCheck $ \a3' -> 
  800   averageBmaCouponFixingDatesRaw'_ a1' a2'1  a2'2 a3' >>
  801   peekDayArray  a2'1  a2'2>>= \a2'' -> 
  802   errorCheck  a3'>>
  803   return (a2'')
  804 
  805 
  806 
  807 -- |The individual BMA fixings being averaged, in the same order as 'fixingDates'.
  808 averageBmaCouponIndexFixingsRaw :: (AverageBMACoupon) -> IO (([Double]))
  809 averageBmaCouponIndexFixingsRaw a1 =
  810   withAverageBMACoupon a1 $ \a1' -> 
  811   preDoubleArray $ \(a2'1, a2'2) -> 
  812   preErrorCheck $ \a3' -> 
  813   averageBmaCouponIndexFixingsRaw'_ a1' a2'1  a2'2 a3' >>
  814   peekDoubleArray  a2'1  a2'2>>= \a2'' -> 
  815   errorCheck  a3'>>
  816   return (a2'')
  817 
  818 
  819 
  820 -- |Wrap a floating-rate coupon with optional cap and floor rates.
  821 cappedFlooredCoupon :: (GenFloatingRateCoupon frc) -- ^underlying
  822  -> (Maybe Double) -- ^cap
  823  -> (Maybe Double) -- ^floor
  824  -> IO ((FloatingRateCoupon))
  825 cappedFlooredCoupon a1 a2 a3 =
  826   withFloatingRateCoupon a1 $ \a1' -> 
  827   let {a2' = fromMaybeDouble a2} in 
  828   let {a3' = fromMaybeDouble a3} in 
  829   preErrorCheck $ \a4' -> 
  830   cappedFlooredCoupon'_ a1' a2' a3' a4' >>= \res ->
  831   peekFloatingRateCoupon res >>= \res' ->
  832   errorCheck  a4'>>
  833   return (res')
  834 
  835 
  836 
  837 -- |Strip the embedded cap/floor option out of a capped\/floored coupon: builds a
  838 -- 'CappedFlooredCoupon' from /underlying/, /cap/ and /floor/ (as 'cappedFlooredCoupon'
  839 -- does), then wraps it so the option's rate, cap and floor are separately readable.
  840 strippedCappedFlooredCoupon :: (GenFloatingRateCoupon frc) -- ^underlying
  841  -> (Maybe Double) -- ^cap
  842  -> (Maybe Double) -- ^floor
  843  -> IO ((StrippedCappedFlooredCoupon))
  844 strippedCappedFlooredCoupon a1 a2 a3 =
  845   withFloatingRateCoupon a1 $ \a1' -> 
  846   let {a2' = fromMaybeDouble a2} in 
  847   let {a3' = fromMaybeDouble a3} in 
  848   preErrorCheck $ \a4' -> 
  849   strippedCappedFlooredCoupon'_ a1' a2' a3' a4' >>= \res ->
  850   peekStrippedCappedFlooredCoupon res >>= \res' ->
  851   errorCheck  a4'>>
  852   return (res')
  853 
  854 
  855 
  856 -- |The cap actually in effect for this coupon, accounting for the sign of /gearing/;
  857 -- QuantLib's null-rate sentinel means no cap applies.
  858 capRate :: (StrippedCappedFlooredCoupon) -- ^coupon
  859  -> (Double)
  860 capRate a1 =
  861   C2HSImp.unsafePerformIO $
  862   withStrippedCappedFlooredCoupon a1 $ \a1' -> 
  863   capRate'_ a1' >>= \res ->
  864   let {res' = realToFrac res} in
  865   return (res')
  866 
  867 
  868 
  869 -- |The floor actually in effect for this coupon, accounting for the sign of /gearing/;
  870 -- QuantLib's null-rate sentinel means no floor applies.
  871 floorRate :: (StrippedCappedFlooredCoupon) -- ^coupon
  872  -> (Double)
  873 floorRate a1 =
  874   C2HSImp.unsafePerformIO $
  875   withStrippedCappedFlooredCoupon a1 $ \a1' -> 
  876   floorRate'_ a1' >>= \res ->
  877   let {res' = realToFrac res} in
  878   return (res')
  879 
  880 
  881 
  882 -- |The cap rate translated back to the underlying index rate (before gearing\/spread);
  883 -- QuantLib's null-rate sentinel means the coupon is not capped.
  884 effectiveCap :: (StrippedCappedFlooredCoupon) -- ^coupon
  885  -> (Double)
  886 effectiveCap a1 =
  887   C2HSImp.unsafePerformIO $
  888   withStrippedCappedFlooredCoupon a1 $ \a1' -> 
  889   effectiveCap'_ a1' >>= \res ->
  890   let {res' = realToFrac res} in
  891   return (res')
  892 
  893 
  894 
  895 -- |The floor rate translated back to the underlying index rate (before gearing\/spread);
  896 -- QuantLib's null-rate sentinel means the coupon is not floored.
  897 effectiveFloor :: (StrippedCappedFlooredCoupon) -- ^coupon
  898  -> (Double)
  899 effectiveFloor a1 =
  900   C2HSImp.unsafePerformIO $
  901   withStrippedCappedFlooredCoupon a1 $ \a1' -> 
  902   effectiveFloor'_ a1' >>= \res ->
  903   let {res' = realToFrac res} in
  904   return (res')
  905 
  906 
  907 
  908 -- |Whether this coupon has a cap in effect.
  909 isCap :: (StrippedCappedFlooredCoupon) -- ^coupon
  910  -> (Bool)
  911 isCap a1 =
  912   C2HSImp.unsafePerformIO $
  913   withStrippedCappedFlooredCoupon a1 $ \a1' -> 
  914   isCap'_ a1' >>= \res ->
  915   let {res' = C2HSImp.toBool res} in
  916   return (res')
  917 
  918 
  919 
  920 -- |Whether this coupon has a floor in effect.
  921 isFloor :: (StrippedCappedFlooredCoupon) -- ^coupon
  922  -> (Bool)
  923 isFloor a1 =
  924   C2HSImp.unsafePerformIO $
  925   withStrippedCappedFlooredCoupon a1 $ \a1' -> 
  926   isFloor'_ a1' >>= \res ->
  927   let {res' = C2HSImp.toBool res} in
  928   return (res')
  929 
  930 
  931 
  932 -- |Whether this coupon is both capped and floored (a collar).
  933 isCollar :: (StrippedCappedFlooredCoupon) -- ^coupon
  934  -> (Bool)
  935 isCollar a1 =
  936   C2HSImp.unsafePerformIO $
  937   withStrippedCappedFlooredCoupon a1 $ \a1' -> 
  938   isCollar'_ a1' >>= \res ->
  939   let {res' = C2HSImp.toBool res} in
  940   return (res')
  941 
  942 
  943 
  944 -- |Ibor coupon with optional cap and floor rates.
  945 cappedFlooredIborCoupon :: (Day) -- ^paymentDate
  946  -> (Double) -- ^nominal
  947  -> (Day) -- ^accrualStartDate
  948  -> (Day) -- ^accrualEndDate
  949  -> (Word) -- ^fixingDays
  950  -> (GenIborIndex ibor) -- ^index
  951  -> (Double) -- ^gearing
  952  -> (Double) -- ^spread
  953  -> (Maybe Double) -- ^cap
  954  -> (Maybe Double) -- ^floor
  955  -> (Maybe Day) -- ^referencePeriodStart
  956  -> (Maybe Day) -- ^referencePeriodEnd
  957  -> (DayCounter) -- ^dayCounter
  958  -> (Bool) -- ^inArrears
  959  -> (Maybe Day) -- ^exCouponDate
  960  -> (BusinessDayConvention) -- ^fixingConvention
  961  -> IO ((FloatingRateCoupon))
  962 cappedFlooredIborCoupon a1 a2 a3 a4 a5 a6 a7 a8 a9 a10 a11 a12 a13 a14 a15 a16 =
  963   withDay a1 $ \a1' -> 
  964   let {a2' = realToFrac a2} in 
  965   withDay a3 $ \a3' -> 
  966   withDay a4 $ \a4' -> 
  967   let {a5' = fromIntegral a5} in 
  968   withIborIndex a6 $ \a6' -> 
  969   let {a7' = realToFrac a7} in 
  970   let {a8' = realToFrac a8} in 
  971   let {a9' = fromMaybeDouble a9} in 
  972   let {a10' = fromMaybeDouble a10} in 
  973   withMaybeDay a11 $ \a11' -> 
  974   withMaybeDay a12 $ \a12' -> 
  975   withDayCounter a13 $ \a13' -> 
  976   let {a14' = C2HSImp.fromBool a14} in 
  977   withMaybeDay a15 $ \a15' -> 
  978   let {a16' = fromEnumC a16} in 
  979   preErrorCheck $ \a17' -> 
  980   cappedFlooredIborCoupon'_ a1' a2' a3' a4' a5' a6' a7' a8' a9' a10' a11' a12' a13' a14' a15' a16' a17' >>= \res ->
  981   peekFloatingRateCoupon res >>= \res' ->
  982   errorCheck  a17'>>
  983   return (res')
  984 
  985 
  986 
  987 -- |Ibor coupon with embedded digital call and put options.
  988 digitalIborCoupon :: (IborCoupon) -- ^underlying
  989  -> (Maybe Double) -- ^callStrike
  990  -> (PositionType) -- ^callPosition
  991  -> (Bool) -- ^callATM
  992  -> (Maybe Double) -- ^callDigitalPayoff
  993  -> (Maybe Double) -- ^putStrike
  994  -> (PositionType) -- ^putPosition
  995  -> (Bool) -- ^putATM
  996  -> (Maybe Double) -- ^putDigitalPayoff
  997  -> (Maybe DigitalReplication) -- ^replication
  998  -> (Bool) -- ^nakedOption
  999  -> IO ((DigitalCoupon))
 1000 digitalIborCoupon a1 a2 a3 a4 a5 a6 a7 a8 a9 a10 a11 =
 1001   withIborCoupon a1 $ \a1' -> 
 1002   let {a2' = fromMaybeDouble a2} in 
 1003   let {a3' = fromEnumC a3} in 
 1004   let {a4' = C2HSImp.fromBool a4} in 
 1005   let {a5' = fromMaybeDouble a5} in 
 1006   let {a6' = fromMaybeDouble a6} in 
 1007   let {a7' = fromEnumC a7} in 
 1008   let {a8' = C2HSImp.fromBool a8} in 
 1009   let {a9' = fromMaybeDouble a9} in 
 1010   withMaybeDigitalReplication a10 $ \a10' -> 
 1011   let {a11' = C2HSImp.fromBool a11} in 
 1012   preErrorCheck $ \a12' -> 
 1013   digitalIborCoupon'_ a1' a2' a3' a4' a5' a6' a7' a8' a9' a10' a11' a12' >>= \res ->
 1014   peekDigitalCoupon res >>= \res' ->
 1015   errorCheck  a12'>>
 1016   return (res')
 1017 
 1018 
 1019 
 1020 -- |A floating coupon with replicated digital call and put payoffs.  Optional
 1021 -- strikes/payoffs use 'Nothing' for QuantLib's null-rate sentinel.
 1022 digitalCoupon :: (GenFloatingRateCoupon frc) -- ^underlying
 1023  -> (Maybe Double) -> (PositionType) -> (Bool) -> (Maybe Double) -> (Maybe Double) -> (PositionType) -> (Bool) -> (Maybe Double) -> (Maybe DigitalReplication) -> (Bool) -> IO ((DigitalCoupon))
 1024 digitalCoupon a1 a2 a3 a4 a5 a6 a7 a8 a9 a10 a11 =
 1025   withFloatingRateCoupon a1 $ \a1' -> 
 1026   let {a2' = fromMaybeDouble a2} in 
 1027   let {a3' = fromEnumC a3} in 
 1028   let {a4' = C2HSImp.fromBool a4} in 
 1029   let {a5' = fromMaybeDouble a5} in 
 1030   let {a6' = fromMaybeDouble a6} in 
 1031   let {a7' = fromEnumC a7} in 
 1032   let {a8' = C2HSImp.fromBool a8} in 
 1033   let {a9' = fromMaybeDouble a9} in 
 1034   withMaybeDigitalReplication a10 $ \a10' -> 
 1035   let {a11' = C2HSImp.fromBool a11} in 
 1036   preErrorCheck $ \a12' -> 
 1037   digitalCoupon'_ a1' a2' a3' a4' a5' a6' a7' a8' a9' a10' a11' a12' >>= \res ->
 1038   peekDigitalCoupon res >>= \res' ->
 1039   errorCheck  a12'>>
 1040   return (res')
 1041 
 1042 
 1043 callOptionRate :: (GenDigitalCoupon dc) -> IO ((Double))
 1044 callOptionRate a1 =
 1045   withDigitalCoupon a1 $ \a1' -> 
 1046   preErrorCheck $ \a2' -> 
 1047   callOptionRate'_ a1' a2' >>= \res ->
 1048   let {res' = realToFrac res} in
 1049   errorCheck  a2'>>
 1050   return (res')
 1051 
 1052 
 1053 putOptionRate :: (GenDigitalCoupon dc) -> IO ((Double))
 1054 putOptionRate a1 =
 1055   withDigitalCoupon a1 $ \a1' -> 
 1056   preErrorCheck $ \a2' -> 
 1057   putOptionRate'_ a1' a2' >>= \res ->
 1058   let {res' = realToFrac res} in
 1059   errorCheck  a2'>>
 1060   return (res')
 1061 
 1062 
 1063 
 1064 -- |Ibor coupon whose rate averages multiple reset dates in each accrual period.
 1065 multipleResetsCoupon :: (Day) -- ^paymentDate
 1066  -> (Double) -- ^nominal
 1067  -> (Schedule) -- ^fixingSchedule
 1068  -> (Word) -- ^fixingDays
 1069  -> (GenIborIndex ibor) -- ^index
 1070  -> (Double) -- ^gearing
 1071  -> (Double) -- ^couponSpread
 1072  -> (Double) -- ^rateSpread
 1073  -> (Maybe Day) -- ^referencePeriodStart
 1074  -> (Maybe Day) -- ^referencePeriodEnd
 1075  -> (DayCounter) -- ^dayCounter
 1076  -> (Maybe Day) -- ^exCouponDate
 1077  -> IO ((MultipleResetsCoupon))
 1078 multipleResetsCoupon a1 a2 a3 a4 a5 a6 a7 a8 a9 a10 a11 a12 =
 1079   withDay a1 $ \a1' -> 
 1080   let {a2' = realToFrac a2} in 
 1081   withSchedule a3 $ \a3' -> 
 1082   let {a4' = fromIntegral a4} in 
 1083   withIborIndex a5 $ \a5' -> 
 1084   let {a6' = realToFrac a6} in 
 1085   let {a7' = realToFrac a7} in 
 1086   let {a8' = realToFrac a8} in 
 1087   withMaybeDay a9 $ \a9' -> 
 1088   withMaybeDay a10 $ \a10' -> 
 1089   withDayCounter a11 $ \a11' -> 
 1090   withMaybeDay a12 $ \a12' -> 
 1091   preErrorCheck $ \a13' -> 
 1092   multipleResetsCoupon'_ a1' a2' a3' a4' a5' a6' a7' a8' a9' a10' a11' a12' a13' >>= \res ->
 1093   peekMultipleResetsCoupon res >>= \res' ->
 1094   errorCheck  a13'>>
 1095   return (res')
 1096 
 1097 
 1098 
 1099 -- |Fixing dates for the rates being compounded over this coupon's reset schedule.
 1100 multipleResetsCouponFixingDatesRaw :: (MultipleResetsCoupon) -> IO (([Day]))
 1101 multipleResetsCouponFixingDatesRaw a1 =
 1102   withMultipleResetsCoupon a1 $ \a1' -> 
 1103   preIntArray $ \(a2'1, a2'2) -> 
 1104   preErrorCheck $ \a3' -> 
 1105   multipleResetsCouponFixingDatesRaw'_ a1' a2'1  a2'2 a3' >>
 1106   peekDayArray  a2'1  a2'2>>= \a2'' -> 
 1107   errorCheck  a3'>>
 1108   return (a2'')
 1109 
 1110 
 1111 
 1112 -- |A range-accrual coupon.  Attach the existing range-accrual pricer before
 1113 -- asking for its rate; 'priceWithoutOptionality'
 1114 -- needs only a discount curve.
 1115 rangeAccrualFloatersCoupon :: (Day) -> (Double) -> (GenIborIndex ibor) -> (Day) -> (Day) -> (Word) -> (DayCounter) -> (Double) -> (Double) -> (Maybe Day) -> (Maybe Day) -> (Schedule) -> (Double) -> (Double) -> IO ((RangeAccrualFloatersCoupon))
 1116 rangeAccrualFloatersCoupon a1 a2 a3 a4 a5 a6 a7 a8 a9 a10 a11 a12 a13 a14 =
 1117   withDay a1 $ \a1' -> 
 1118   let {a2' = realToFrac a2} in 
 1119   withIborIndex a3 $ \a3' -> 
 1120   withDay a4 $ \a4' -> 
 1121   withDay a5 $ \a5' -> 
 1122   let {a6' = fromIntegral a6} in 
 1123   withDayCounter a7 $ \a7' -> 
 1124   let {a8' = realToFrac a8} in 
 1125   let {a9' = realToFrac a9} in 
 1126   withMaybeDay a10 $ \a10' -> 
 1127   withMaybeDay a11 $ \a11' -> 
 1128   withSchedule a12 $ \a12' -> 
 1129   let {a13' = realToFrac a13} in 
 1130   let {a14' = realToFrac a14} in 
 1131   preErrorCheck $ \a15' -> 
 1132   rangeAccrualFloatersCoupon'_ a1' a2' a3' a4' a5' a6' a7' a8' a9' a10' a11' a12' a13' a14' a15' >>= \res ->
 1133   peekRangeAccrualFloatersCoupon res >>= \res' ->
 1134   errorCheck  a15'>>
 1135   return (res')
 1136 
 1137 
 1138 priceWithoutOptionality :: (RangeAccrualFloatersCoupon) -> (GenYieldTermStructure y) -> IO ((Double))
 1139 priceWithoutOptionality a1 a2 =
 1140   withRangeAccrualFloatersCoupon a1 $ \a1' -> 
 1141   withYieldTermStructure a2 $ \a2' -> 
 1142   preErrorCheck $ \a3' -> 
 1143   priceWithoutOptionality'_ a1' a2' a3' >>= \res ->
 1144   let {res' = realToFrac res} in
 1145   errorCheck  a3'>>
 1146   return (res')
 1147 
 1148 
 1149 
 1150 -- |A year-on-year inflation coupon.  As for 'yoyInflationLeg', attach a
 1151 -- YoY inflation coupon pricer before evaluating the coupon rate.
 1152 yoyInflationCoupon :: (Day) -> (Double) -> (Day) -> (Day) -> (Word) -> (GenYoYInflationIndex yidx) -> ((Int,TimeUnit)) -> (CPIInterpolationType) -> (DayCounter) -> (Double) -> (Double) -> (Maybe Day) -> (Maybe Day) -> IO ((YoYInflationCoupon))
 1153 yoyInflationCoupon a1 a2 a3 a4 a5 a6 a7 a8 a9 a10 a11 a12 a13 =
 1154   withDay a1 $ \a1' -> 
 1155   let {a2' = realToFrac a2} in 
 1156   withDay a3 $ \a3' -> 
 1157   withDay a4 $ \a4' -> 
 1158   let {a5' = fromIntegral a5} in 
 1159   withYoYInflationIndex a6 $ \a6' -> 
 1160   let {(a7'1, a7'2) = fromEnumQuantity a7} in 
 1161   let {a8' = fromEnumC a8} in 
 1162   withDayCounter a9 $ \a9' -> 
 1163   let {a10' = realToFrac a10} in 
 1164   let {a11' = realToFrac a11} in 
 1165   withMaybeDay a12 $ \a12' -> 
 1166   withMaybeDay a13 $ \a13' -> 
 1167   preErrorCheck $ \a14' -> 
 1168   yoyInflationCoupon'_ a1' a2' a3' a4' a5' a6' a7'1  a7'2 a8' a9' a10' a11' a12' a13' a14' >>= \res ->
 1169   peekYoYInflationCoupon res >>= \res' ->
 1170   errorCheck  a14'>>
 1171   return (res')
 1172 
 1173 
 1174 adjustedFixing :: (YoYInflationCoupon) -> IO ((Double))
 1175 adjustedFixing a1 =
 1176   withYoYInflationCoupon a1 $ \a1' -> 
 1177   preErrorCheck $ \a2' -> 
 1178   adjustedFixing'_ a1' a2' >>= \res ->
 1179   let {res' = realToFrac res} in
 1180   errorCheck  a2'>>
 1181   return (res')
 1182 
 1183 
 1184 
 1185 -- |Pricer that arithmetically averages multiple Ibor resets.
 1186 averagingMultipleResetsPricer :: IO ((FloatingRateCouponPricer))
 1187 averagingMultipleResetsPricer =
 1188   preErrorCheck $ \a1' -> 
 1189   averagingMultipleResetsPricer'_ a1' >>= \res ->
 1190   peekFloatingRateCouponPricer res >>= \res' ->
 1191   errorCheck  a1'>>
 1192   return (res')
 1193 
 1194 
 1195 
 1196 -- |Pricer that compounds multiple Ibor resets.
 1197 compoundingMultipleResetsPricer :: IO ((FloatingRateCouponPricer))
 1198 compoundingMultipleResetsPricer =
 1199   preErrorCheck $ \a1' -> 
 1200   compoundingMultipleResetsPricer'_ a1' >>= \res ->
 1201   peekFloatingRateCouponPricer res >>= \res' ->
 1202   errorCheck  a1'>>
 1203   return (res')
 1204 
 1205 
 1206 
 1207 -- |Overnight-index coupon with explicit observation and accrual conventions.
 1208 overnightIndexedCoupon :: (Day) -- ^paymentDate
 1209  -> (Double) -- ^nominal
 1210  -> (Day) -- ^accrualStartDate
 1211  -> (Day) -- ^accrualEndDate
 1212  -> (OvernightIborIndex) -- ^index
 1213  -> (Double) -- ^gearing
 1214  -> (Double) -- ^spread
 1215  -> (Maybe Day) -- ^referencePeriodStart
 1216  -> (Maybe Day) -- ^referencePeriodEnd
 1217  -> (DayCounter) -- ^dayCounter
 1218  -> (Bool) -- ^telescopicValueDates
 1219  -> (RateAveragingType) -- ^averagingMethod
 1220  -> (Word) -- ^lookbackDays
 1221  -> (Word) -- ^lockoutDays
 1222  -> (Bool) -- ^applyObservationShift
 1223  -> (Bool) -- ^includeSpread
 1224  -> (Maybe Day) -- ^rateComputationStartDate
 1225  -> (Maybe Day) -- ^rateComputationEndDate
 1226  -> (Maybe Day) -- ^exCouponDate
 1227  -> (Maybe Int) -- ^rounding
 1228  -> IO ((OvernightIndexedCoupon))
 1229 overnightIndexedCoupon a1 a2 a3 a4 a5 a6 a7 a8 a9 a10 a11 a12 a13 a14 a15 a16 a17 a18 a19 a20 =
 1230   withDay a1 $ \a1' -> 
 1231   let {a2' = realToFrac a2} in 
 1232   withDay a3 $ \a3' -> 
 1233   withDay a4 $ \a4' -> 
 1234   withOvernightIborIndex a5 $ \a5' -> 
 1235   let {a6' = realToFrac a6} in 
 1236   let {a7' = realToFrac a7} in 
 1237   withMaybeDay a8 $ \a8' -> 
 1238   withMaybeDay a9 $ \a9' -> 
 1239   withDayCounter a10 $ \a10' -> 
 1240   let {a11' = C2HSImp.fromBool a11} in 
 1241   let {a12' = fromEnumC a12} in 
 1242   let {a13' = fromIntegral a13} in 
 1243   let {a14' = fromIntegral a14} in 
 1244   let {a15' = C2HSImp.fromBool a15} in 
 1245   let {a16' = C2HSImp.fromBool a16} in 
 1246   withMaybeDay a17 $ \a17' -> 
 1247   withMaybeDay a18 $ \a18' -> 
 1248   withMaybeDay a19 $ \a19' -> 
 1249   let {a20' = fromMaybeInt a20} in 
 1250   preErrorCheck $ \a21' -> 
 1251   overnightIndexedCoupon'_ a1' a2' a3' a4' a5' a6' a7' a8' a9' a10' a11' a12' a13' a14' a15' a16' a17' a18' a19' a20' a21' >>= \res ->
 1252   peekOvernightIndexedCoupon res >>= \res' ->
 1253   errorCheck  a21'>>
 1254   return (res')
 1255 
 1256 
 1257 
 1258 -- |The dates on which the coupon observes the overnight index, one per accrual sub-period.
 1259 overnightIndexedCouponFixingDatesRaw :: (OvernightIndexedCoupon) -> IO (([Day]))
 1260 overnightIndexedCouponFixingDatesRaw a1 =
 1261   withOvernightIndexedCoupon a1 $ \a1' -> 
 1262   preIntArray $ \(a2'1, a2'2) -> 
 1263   preErrorCheck $ \a3' -> 
 1264   overnightIndexedCouponFixingDatesRaw'_ a1' a2'1  a2'2 a3' >>
 1265   peekDayArray  a2'1  a2'2>>= \a2'' -> 
 1266   errorCheck  a3'>>
 1267   return (a2'')
 1268 
 1269 
 1270 
 1271 -- |The index fixing observed at each of 'fixingDates', in the same order.
 1272 -- Requires the underlying overnight index to already have those fixings available (historical or
 1273 -- forecast via a projection curve).
 1274 overnightIndexedCouponIndexFixingsRaw :: (OvernightIndexedCoupon) -> IO (([Double]))
 1275 overnightIndexedCouponIndexFixingsRaw a1 =
 1276   withOvernightIndexedCoupon a1 $ \a1' -> 
 1277   preDoubleArray $ \(a2'1, a2'2) -> 
 1278   preErrorCheck $ \a3' -> 
 1279   overnightIndexedCouponIndexFixingsRaw'_ a1' a2'1  a2'2 a3' >>
 1280   peekDoubleArray  a2'1  a2'2>>= \a2'' -> 
 1281   errorCheck  a3'>>
 1282   return (a2'')
 1283 
 1284 
 1285 
 1286 -- |Capped/floored overnight-index coupon.
 1287 cappedFlooredOvernightIndexedCoupon :: (OvernightIndexedCoupon) -- ^underlying
 1288  -> (Maybe Double) -- ^cap
 1289  -> (Maybe Double) -- ^floor
 1290  -> (Bool) -- ^nakedOption
 1291  -> (Bool) -- ^includeSpread
 1292  -> IO ((FloatingRateCoupon))
 1293 cappedFlooredOvernightIndexedCoupon a1 a2 a3 a4 a5 =
 1294   withOvernightIndexedCoupon a1 $ \a1' -> 
 1295   let {a2' = fromMaybeDouble a2} in 
 1296   let {a3' = fromMaybeDouble a3} in 
 1297   let {a4' = C2HSImp.fromBool a4} in 
 1298   let {a5' = C2HSImp.fromBool a5} in 
 1299   preErrorCheck $ \a6' -> 
 1300   cappedFlooredOvernightIndexedCoupon'_ a1' a2' a3' a4' a5' a6' >>= \res ->
 1301   peekFloatingRateCoupon res >>= \res' ->
 1302   errorCheck  a6'>>
 1303   return (res')
 1304 
 1305 
 1306 
 1307 -- |Compounding overnight-index coupon pricer.
 1308 compoundingOvernightIndexedCouponPricer :: (Maybe (GenOptionletVolatilityStructure ov)) -- ^capletVolatility
 1309  -> (Bool) -- ^byApprox
 1310  -> IO ((FloatingRateCouponPricer))
 1311 compoundingOvernightIndexedCouponPricer a1 a2 =
 1312   withMaybeOptionletVolatilityStructure a1 $ \a1' -> 
 1313   let {a2' = C2HSImp.fromBool a2} in 
 1314   preErrorCheck $ \a3' -> 
 1315   compoundingOvernightIndexedCouponPricer'_ a1' a2' a3' >>= \res ->
 1316   peekFloatingRateCouponPricer res >>= \res' ->
 1317   errorCheck  a3'>>
 1318   return (res')
 1319 
 1320 
 1321 
 1322 -- |Arithmetic-average overnight-index coupon pricer.
 1323 arithmeticAveragedOvernightIndexedCouponPricer :: (Double) -- ^meanReversion
 1324  -> (Double) -- ^volatility
 1325  -> (Bool) -- ^byApprox
 1326  -> (Maybe (GenOptionletVolatilityStructure ov)) -- ^capletVolatility
 1327  -> (Bool) -- ^effective
 1328  -> IO ((FloatingRateCouponPricer))
 1329 arithmeticAveragedOvernightIndexedCouponPricer a1 a2 a3 a4 a5 =
 1330   let {a1' = realToFrac a1} in 
 1331   let {a2' = realToFrac a2} in 
 1332   let {a3' = C2HSImp.fromBool a3} in 
 1333   withMaybeOptionletVolatilityStructure a4 $ \a4' -> 
 1334   let {a5' = C2HSImp.fromBool a5} in 
 1335   preErrorCheck $ \a6' -> 
 1336   arithmeticAveragedOvernightIndexedCouponPricer'_ a1' a2' a3' a4' a5' a6' >>= \res ->
 1337   peekFloatingRateCouponPricer res >>= \res' ->
 1338   errorCheck  a6'>>
 1339   return (res')
 1340 
 1341 
 1342 
 1343 -- |Black-formula compounding overnight-index coupon pricer.
 1344 blackCompoundingOvernightIndexedCouponPricer :: (Maybe (GenOptionletVolatilityStructure ov)) -- ^capletVolatility
 1345  -> (Bool) -- ^effective
 1346  -> IO ((FloatingRateCouponPricer))
 1347 blackCompoundingOvernightIndexedCouponPricer a1 a2 =
 1348   withMaybeOptionletVolatilityStructure a1 $ \a1' -> 
 1349   let {a2' = C2HSImp.fromBool a2} in 
 1350   preErrorCheck $ \a3' -> 
 1351   blackCompoundingOvernightIndexedCouponPricer'_ a1' a2' a3' >>= \res ->
 1352   peekFloatingRateCouponPricer res >>= \res' ->
 1353   errorCheck  a3'>>
 1354   return (res')
 1355 
 1356 
 1357 
 1358 -- |Black-formula arithmetic-average overnight-index coupon pricer.
 1359 blackAveragingOvernightIndexedCouponPricer :: (Maybe (GenOptionletVolatilityStructure ov)) -- ^capletVolatility
 1360  -> (Bool) -- ^effective
 1361  -> IO ((FloatingRateCouponPricer))
 1362 blackAveragingOvernightIndexedCouponPricer a1 a2 =
 1363   withMaybeOptionletVolatilityStructure a1 $ \a1' -> 
 1364   let {a2' = C2HSImp.fromBool a2} in 
 1365   preErrorCheck $ \a3' -> 
 1366   blackAveragingOvernightIndexedCouponPricer'_ a1' a2' a3' >>= \res ->
 1367   peekFloatingRateCouponPricer res >>= \res' ->
 1368   errorCheck  a3'>>
 1369   return (res')
 1370 
 1371 
 1372 
 1373 -- |CPI-linked coupon whose base fixing is supplied directly.
 1374 cpiCoupon :: (Double) -- ^baseCPI
 1375  -> (Day) -- ^paymentDate
 1376  -> (Double) -- ^nominal
 1377  -> (Day) -- ^accrualStartDate
 1378  -> (Day) -- ^accrualEndDate
 1379  -> (GenZeroInflationIndex zidx) -- ^index
 1380  -> ((Int,TimeUnit)) -- ^observationLag
 1381  -> (CPIInterpolationType) -- ^observationInterpolation
 1382  -> (DayCounter) -- ^dayCounter
 1383  -> (Double) -- ^fixedRate
 1384  -> (Maybe Day) -- ^referencePeriodStart
 1385  -> (Maybe Day) -- ^referencePeriodEnd
 1386  -> (Maybe Day) -- ^exCouponDate
 1387  -> IO ((CPICoupon))
 1388 cpiCoupon a1 a2 a3 a4 a5 a6 a7 a8 a9 a10 a11 a12 a13 =
 1389   let {a1' = realToFrac a1} in 
 1390   withDay a2 $ \a2' -> 
 1391   let {a3' = realToFrac a3} in 
 1392   withDay a4 $ \a4' -> 
 1393   withDay a5 $ \a5' -> 
 1394   withZeroInflationIndex a6 $ \a6' -> 
 1395   let {(a7'1, a7'2) = fromEnumQuantity a7} in 
 1396   let {a8' = fromEnumC a8} in 
 1397   withDayCounter a9 $ \a9' -> 
 1398   let {a10' = realToFrac a10} in 
 1399   withMaybeDay a11 $ \a11' -> 
 1400   withMaybeDay a12 $ \a12' -> 
 1401   withMaybeDay a13 $ \a13' -> 
 1402   preErrorCheck $ \a14' -> 
 1403   cpiCoupon'_ a1' a2' a3' a4' a5' a6' a7'1  a7'2 a8' a9' a10' a11' a12' a13' a14' >>= \res ->
 1404   peekCPICoupon res >>= \res' ->
 1405   errorCheck  a14'>>
 1406   return (res')
 1407 
 1408 
 1409 
 1410 -- |CPI-linked coupon whose base fixing is determined by a base date.
 1411 cpiCouponFromBaseDate :: (Day) -- ^baseDate
 1412  -> (Day) -- ^paymentDate
 1413  -> (Double) -- ^nominal
 1414  -> (Day) -- ^accrualStartDate
 1415  -> (Day) -- ^accrualEndDate
 1416  -> (GenZeroInflationIndex zidx) -- ^index
 1417  -> ((Int,TimeUnit)) -- ^observationLag
 1418  -> (CPIInterpolationType) -- ^observationInterpolation
 1419  -> (DayCounter) -- ^dayCounter
 1420  -> (Double) -- ^fixedRate
 1421  -> (Maybe Day) -- ^referencePeriodStart
 1422  -> (Maybe Day) -- ^referencePeriodEnd
 1423  -> (Maybe Day) -- ^exCouponDate
 1424  -> IO ((CPICoupon))
 1425 cpiCouponFromBaseDate a1 a2 a3 a4 a5 a6 a7 a8 a9 a10 a11 a12 a13 =
 1426   withDay a1 $ \a1' -> 
 1427   withDay a2 $ \a2' -> 
 1428   let {a3' = realToFrac a3} in 
 1429   withDay a4 $ \a4' -> 
 1430   withDay a5 $ \a5' -> 
 1431   withZeroInflationIndex a6 $ \a6' -> 
 1432   let {(a7'1, a7'2) = fromEnumQuantity a7} in 
 1433   let {a8' = fromEnumC a8} in 
 1434   withDayCounter a9 $ \a9' -> 
 1435   let {a10' = realToFrac a10} in 
 1436   withMaybeDay a11 $ \a11' -> 
 1437   withMaybeDay a12 $ \a12' -> 
 1438   withMaybeDay a13 $ \a13' -> 
 1439   preErrorCheck $ \a14' -> 
 1440   cpiCouponFromBaseDate'_ a1' a2' a3' a4' a5' a6' a7'1  a7'2 a8' a9' a10' a11' a12' a13' a14' >>= \res ->
 1441   peekCPICoupon res >>= \res' ->
 1442   errorCheck  a14'>>
 1443   return (res')
 1444 
 1445 
 1446 
 1447 -- |CPI-linked coupon with both an explicit base CPI and base date.
 1448 cpiCouponWithBaseDate :: (Double) -- ^baseCPI
 1449  -> (Day) -- ^baseDate
 1450  -> (Day) -- ^paymentDate
 1451  -> (Double) -- ^nominal
 1452  -> (Day) -- ^accrualStartDate
 1453  -> (Day) -- ^accrualEndDate
 1454  -> (GenZeroInflationIndex zidx) -- ^index
 1455  -> ((Int,TimeUnit)) -- ^observationLag
 1456  -> (CPIInterpolationType) -- ^observationInterpolation
 1457  -> (DayCounter) -- ^dayCounter
 1458  -> (Double) -- ^fixedRate
 1459  -> (Maybe Day) -- ^referencePeriodStart
 1460  -> (Maybe Day) -- ^referencePeriodEnd
 1461  -> (Maybe Day) -- ^exCouponDate
 1462  -> IO ((CPICoupon))
 1463 cpiCouponWithBaseDate a1 a2 a3 a4 a5 a6 a7 a8 a9 a10 a11 a12 a13 a14 =
 1464   let {a1' = realToFrac a1} in 
 1465   withDay a2 $ \a2' -> 
 1466   withDay a3 $ \a3' -> 
 1467   let {a4' = realToFrac a4} in 
 1468   withDay a5 $ \a5' -> 
 1469   withDay a6 $ \a6' -> 
 1470   withZeroInflationIndex a7 $ \a7' -> 
 1471   let {(a8'1, a8'2) = fromEnumQuantity a8} in 
 1472   let {a9' = fromEnumC a9} in 
 1473   withDayCounter a10 $ \a10' -> 
 1474   let {a11' = realToFrac a11} in 
 1475   withMaybeDay a12 $ \a12' -> 
 1476   withMaybeDay a13 $ \a13' -> 
 1477   withMaybeDay a14 $ \a14' -> 
 1478   preErrorCheck $ \a15' -> 
 1479   cpiCouponWithBaseDate'_ a1' a2' a3' a4' a5' a6' a7' a8'1  a8'2 a9' a10' a11' a12' a13' a14' a15' >>= \res ->
 1480   peekCPICoupon res >>= \res' ->
 1481   errorCheck  a15'>>
 1482   return (res')
 1483 
 1484 
 1485 
 1486 -- |CPI coupon pricer using an optional nominal yield curve.
 1487 cpiCouponPricer :: (Maybe (GenYieldTermStructure y)) -- ^nominalTermStructure
 1488  -> IO ((CPICouponPricer))
 1489 cpiCouponPricer a1 =
 1490   withMaybeYieldTermStructure a1 $ \a1' -> 
 1491   preErrorCheck $ \a2' -> 
 1492   cpiCouponPricer'_ a1' a2' >>= \res ->
 1493   peekCPICouponPricer res >>= \res' ->
 1494   errorCheck  a2'>>
 1495   return (res')
 1496 
 1497 
 1498 
 1499 -- |CPI coupon pricer using a CPI volatility surface and optional nominal yield curve.
 1500 cpiCouponPricerWithVol :: (CPIVolatilitySurface) -- ^volatilitySurface
 1501  -> (Maybe (GenYieldTermStructure y)) -- ^nominalTermStructure
 1502  -> IO ((CPICouponPricer))
 1503 cpiCouponPricerWithVol a1 a2 =
 1504   withGenVolatilityTermStructure a1 $ \a1' -> 
 1505   withMaybeYieldTermStructure a2 $ \a2' -> 
 1506   preErrorCheck $ \a3' -> 
 1507   cpiCouponPricerWithVol'_ a1' a2' a3' >>= \res ->
 1508   peekCPICouponPricer res >>= \res' ->
 1509   errorCheck  a3'>>
 1510   return (res')
 1511 
 1512 
 1513 
 1514 -- |Attach a CPI coupon pricer to a CPI coupon.
 1515 setCpiCouponPricer :: (CPICoupon) -- ^coupon
 1516  -> (CPICouponPricer) -- ^pricer
 1517  -> IO ()
 1518 setCpiCouponPricer a1 a2 =
 1519   withCPICoupon a1 $ \a1' -> 
 1520   withCPICouponPricer a2 $ \a2' -> 
 1521   preErrorCheck $ \a3' -> 
 1522   setCpiCouponPricer'_ a1' a2' a3' >>
 1523   errorCheck  a3'>>
 1524   return ()
 1525 
 1526 
 1527 
 1528 -- |The ratio of the (possibly interpolated) index value on /d/ to the coupon's base index
 1529 -- value, i.e. the inflation-adjustment factor applied to the coupon's fixed rate.
 1530 indexRatio :: (CPICoupon) -- ^coupon
 1531  -> (Day) -- ^d
 1532  -> IO ((Double))
 1533 indexRatio a1 a2 =
 1534   withCPICoupon a1 $ \a1' -> 
 1535   withDay a2 $ \a2' -> 
 1536   preErrorCheck $ \a3' -> 
 1537   indexRatio'_ a1' a2' a3' >>= \res ->
 1538   let {res' = realToFrac res} in
 1539   errorCheck  a3'>>
 1540   return (res')
 1541 
 1542 
 1543 
 1544 -- |A single redemption payment.
 1545 redemption :: (Double) -- ^amount
 1546  -> (Day) -- ^date
 1547  -> IO ((CashFlow))
 1548 redemption a1 a2 =
 1549   let {a1' = realToFrac a1} in 
 1550   withDay a2 $ \a2' -> 
 1551   preErrorCheck $ \a3' -> 
 1552   redemption'_ a1' a2' a3' >>= \res ->
 1553   peekCashFlow res >>= \res' ->
 1554   errorCheck  a3'>>
 1555   return (res')
 1556 
 1557 
 1558 
 1559 -- |An amortizing principal payment.
 1560 amortizingPayment :: (Double) -- ^amount
 1561  -> (Day) -- ^date
 1562  -> IO ((CashFlow))
 1563 amortizingPayment a1 a2 =
 1564   let {a1' = realToFrac a1} in 
 1565   withDay a2 $ \a2' -> 
 1566   preErrorCheck $ \a3' -> 
 1567   amortizingPayment'_ a1' a2' a3' >>= \res ->
 1568   peekCashFlow res >>= \res' ->
 1569   errorCheck  a3'>>
 1570   return (res')
 1571 
 1572 
 1573 
 1574 -- |Build a 'Leg' from a homogeneous cash-flow subtype, or from explicitly erased 'CashFlow'
 1575 -- values when the elements are heterogeneous. The leg takes shared ownership of each flow, so
 1576 -- it remains valid when the individual values are no longer retained.
 1577 cashFlowLeg :: ([GenCashFlow cf]) -- ^cashFlows
 1578  -> IO ((Leg))
 1579 cashFlowLeg a1 =
 1580   withCashFlowArray a1 $ \(a1'1, a1'2) -> 
 1581   preErrorCheck $ \a2' -> 
 1582   cashFlowLeg'_ a1'1  a1'2 a2' >>= \res ->
 1583   peekLeg res >>= \res' ->
 1584   errorCheck  a2'>>
 1585   return (res')
 1586 
 1587 
 1588 
 1589 -- |Returns the start (i.e. first accrual) date for the given Leg
 1590 startDate :: (GenLeg l) -> IO ((Day))
 1591 startDate a1 =
 1592   withLeg a1 $ \a1' -> 
 1593   preErrorCheck $ \a2' -> 
 1594   startDate'_ a1' a2' >>= \res ->
 1595   let {res' = toDay res} in
 1596   errorCheck  a2'>>
 1597   return (res')
 1598 
 1599 
 1600 
 1601 -- |return cashflows that will occur after /settlementDate/
 1602 nextCashFlows :: (GenLeg l) -> (Bool) -- ^includeSettlementDateFlows
 1603  -> (Maybe Day) -- ^settlementDate
 1604  -> IO ((Leg))
 1605 nextCashFlows a1 a2 a3 =
 1606   withLeg a1 $ \a1' -> 
 1607   let {a2' = C2HSImp.fromBool a2} in 
 1608   withMaybeDay a3 $ \a3' -> 
 1609   preErrorCheck $ \a4' -> 
 1610   nextCashFlows'_ a1' a2' a3' a4' >>= \res ->
 1611   peekLeg res >>= \res' ->
 1612   errorCheck  a4'>>
 1613   return (res')
 1614 
 1615 
 1616 
 1617 -- |return cashflows that occurred before /settlementDate/
 1618 previousCashFlows :: (GenLeg l) -> (Bool) -- ^includeSettlementDateFlows
 1619  -> (Maybe Day) -- ^settlementDate
 1620  -> IO ((Leg))
 1621 previousCashFlows a1 a2 a3 =
 1622   withLeg a1 $ \a1' -> 
 1623   let {a2' = C2HSImp.fromBool a2} in 
 1624   withMaybeDay a3 $ \a3' -> 
 1625   preErrorCheck $ \a4' -> 
 1626   previousCashFlows'_ a1' a2' a3' a4' >>= \res ->
 1627   peekLeg res >>= \res' ->
 1628   errorCheck  a4'>>
 1629   return (res')
 1630 
 1631 
 1632 
 1633 -- |Raw binding for 'cashFlows': dates, amounts, and whether each has occurred as of /settlementDate/.
 1634 qlLegCashFlows :: (GenLeg l) -> (Maybe Bool) -- ^includeSettlementDateFlows
 1635  -> (Maybe Day) -- ^settlementDate
 1636  -> IO (([Double]), ([Day]), ([Bool]))
 1637 qlLegCashFlows a1 a2 a3 =
 1638   withLeg a1 $ \a1' -> 
 1639   let {a2' = fromMaybeBool a2} in 
 1640   withMaybeDay a3 $ \a3' -> 
 1641   preDoubleArray $ \(a4'1, a4'2) -> 
 1642   preIntArray $ \(a5'1, a5'2) -> 
 1643   preIntArray $ \(a6'1, a6'2) -> 
 1644   preErrorCheck $ \a7' -> 
 1645   qlLegCashFlows'_ a1' a2' a3' a4'1  a4'2 a5'1  a5'2 a6'1  a6'2 a7' >>
 1646   peekDoubleArray  a4'1  a4'2>>= \a4'' -> 
 1647   peekDayArray  a5'1  a5'2>>= \a5'' -> 
 1648   peekBoolArray  a6'1  a6'2>>= \a6'' -> 
 1649   errorCheck  a7'>>
 1650   return (a4'', a5'', a6'')
 1651 
 1652 
 1653 
 1654 -- |return cash flows together with an indicator whether they occurred as of /settlementDate/
 1655 cashFlows :: GenLeg l
 1656   -> Maybe Bool -- ^includeSettlementDateFlows
 1657   -> Maybe Day -- ^settlementDate
 1658   -> IO [(Day, Double, Bool)] -- ^date, amount, hasOccurred
 1659 cashFlows l i d = do{(as, ds, hs) <- qlLegCashFlows l i d; return $ zip3 ds as hs}
 1660 
 1661 -- |Cash-flow duration.
 1662 -- The simple duration of a string of cash flows is defined as \[ D_{\mathrm{simple}} = \frac{\sum t_i c_i B(t_i)}{\sum c_i B(t_i)} \] where $ c_i $ is the amount of the $ i $-th cash flow, $ t_i $ is its payment time, and $ B(t_i) $ is the corresponding discount according to the passed yield.The modified duration is defined as \[ D_{\mathrm{modified}} = -\frac{1}{P} \frac{\partial P}{\partial y} \] where $ P $ is the present value of the cash flows according to the given IRR $ y $.The Macaulay duration is defined for a compounded IRR as \[ D_{\mathrm{Macaulay}} = \left( 1 + \frac{y}{N} \right) D_{\mathrm{modified}} \] where $ y $ is the IRR and $ N $ is the number of cash flows per year.
 1663 duration :: (GenLeg l) -> (InterestRate) -- ^yield
 1664  -> (DurationType) -> (Bool) -- ^includeSettlementDateFlows
 1665  -> (Maybe Day) -- ^settlementDate
 1666  -> (Maybe Day) -- ^npvDate
 1667  -> IO ((Double))
 1668 duration a1 a2 a3 a4 a5 a6 =
 1669   withLeg a1 $ \a1' -> 
 1670   withInterestRate a2 $ \a2' -> 
 1671   let {a3' = (fromIntegral . fromEnum) a3} in 
 1672   let {a4' = C2HSImp.fromBool a4} in 
 1673   withMaybeDay a5 $ \a5' -> 
 1674   withMaybeDay a6 $ \a6' -> 
 1675   preErrorCheck $ \a7' -> 
 1676   duration'_ a1' a2' a3' a4' a5' a6' a7' >>= \res ->
 1677   let {res' = realToFrac res} in
 1678   errorCheck  a7'>>
 1679   return (res')
 1680 
 1681 
 1682 
 1683 -- |Number of days in the accrual period of the coupon paying on /settlementDate/.
 1684 accrualDays :: (GenLeg l) -> (Bool) -- ^includeSettlementDateFlows
 1685  -> (Maybe Day) -- ^settlementDate
 1686  -> IO ((Int))
 1687 accrualDays a1 a2 a3 =
 1688   withLeg a1 $ \a1' -> 
 1689   let {a2' = C2HSImp.fromBool a2} in 
 1690   withMaybeDay a3 $ \a3' -> 
 1691   preErrorCheck $ \a4' -> 
 1692   accrualDays'_ a1' a2' a3' a4' >>= \res ->
 1693   let {res' = fromIntegral res} in
 1694   errorCheck  a4'>>
 1695   return (res')
 1696 
 1697 
 1698 
 1699 -- |End of the accrual period of the coupon paying on /settlementDate/.
 1700 accrualEndDate :: (GenLeg l) -> (Bool) -- ^includeSettlementDateFlows
 1701  -> (Maybe Day) -- ^settlementDate
 1702  -> IO ((Maybe Day))
 1703 accrualEndDate a1 a2 a3 =
 1704   withLeg a1 $ \a1' -> 
 1705   let {a2' = C2HSImp.fromBool a2} in 
 1706   withMaybeDay a3 $ \a3' -> 
 1707   preErrorCheck $ \a4' -> 
 1708   accrualEndDate'_ a1' a2' a3' a4' >>= \res ->
 1709   let {res' = toMaybeDay res} in
 1710   errorCheck  a4'>>
 1711   return (res')
 1712 
 1713 
 1714 
 1715 -- |Length, in years, of the accrual period of the coupon paying on /settlementDate/.
 1716 accrualPeriod :: (GenLeg l) -> (Bool) -- ^includeSettlementDateFlows
 1717  -> (Maybe Day) -- ^settlementDate
 1718  -> IO ((Double))
 1719 accrualPeriod a1 a2 a3 =
 1720   withLeg a1 $ \a1' -> 
 1721   let {a2' = C2HSImp.fromBool a2} in 
 1722   withMaybeDay a3 $ \a3' -> 
 1723   preErrorCheck $ \a4' -> 
 1724   accrualPeriod'_ a1' a2' a3' a4' >>= \res ->
 1725   let {res' = realToFrac res} in
 1726   errorCheck  a4'>>
 1727   return (res')
 1728 
 1729 
 1730 
 1731 -- |Start of the accrual period of the coupon paying on /settlementDate/.
 1732 accrualStartDate :: (GenLeg l) -> (Bool) -- ^includeSettlementDateFlows
 1733  -> (Maybe Day) -- ^settlementDate
 1734  -> IO ((Maybe Day))
 1735 accrualStartDate a1 a2 a3 =
 1736   withLeg a1 $ \a1' -> 
 1737   let {a2' = C2HSImp.fromBool a2} in 
 1738   withMaybeDay a3 $ \a3' -> 
 1739   preErrorCheck $ \a4' -> 
 1740   accrualStartDate'_ a1' a2' a3' a4' >>= \res ->
 1741   let {res' = toMaybeDay res} in
 1742   errorCheck  a4'>>
 1743   return (res')
 1744 
 1745 
 1746 
 1747 -- |Accrued amount of the coupon paying on /settlementDate/.
 1748 accruedAmount :: (GenLeg l) -> (Bool) -- ^includeSettlementDateFlows
 1749  -> (Maybe Day) -- ^settlementDate
 1750  -> IO ((Double))
 1751 accruedAmount a1 a2 a3 =
 1752   withLeg a1 $ \a1' -> 
 1753   let {a2' = C2HSImp.fromBool a2} in 
 1754   withMaybeDay a3 $ \a3' -> 
 1755   preErrorCheck $ \a4' -> 
 1756   accruedAmount'_ a1' a2' a3' a4' >>= \res ->
 1757   let {res' = realToFrac res} in
 1758   errorCheck  a4'>>
 1759   return (res')
 1760 
 1761 
 1762 
 1763 -- |Number of days accrued so far on the coupon paying on /settlementDate/.
 1764 accruedDays :: (GenLeg l) -> (Bool) -- ^includeSettlementDateFlows
 1765  -> (Maybe Day) -- ^settlementDate
 1766  -> IO ((Int))
 1767 accruedDays a1 a2 a3 =
 1768   withLeg a1 $ \a1' -> 
 1769   let {a2' = C2HSImp.fromBool a2} in 
 1770   withMaybeDay a3 $ \a3' -> 
 1771   preErrorCheck $ \a4' -> 
 1772   accruedDays'_ a1' a2' a3' a4' >>= \res ->
 1773   let {res' = fromIntegral res} in
 1774   errorCheck  a4'>>
 1775   return (res')
 1776 
 1777 
 1778 
 1779 -- |Fraction of the accrual period elapsed, as of /settlementDate/, for the coupon paying then.
 1780 accruedPeriod :: (GenLeg l) -> (Bool) -- ^includeSettlementDateFlows
 1781  -> (Maybe Day) -- ^settlementDate
 1782  -> IO ((Double))
 1783 accruedPeriod a1 a2 a3 =
 1784   withLeg a1 $ \a1' -> 
 1785   let {a2' = C2HSImp.fromBool a2} in 
 1786   withMaybeDay a3 $ \a3' -> 
 1787   preErrorCheck $ \a4' -> 
 1788   accruedPeriod'_ a1' a2' a3' a4' >>= \res ->
 1789   let {res' = realToFrac res} in
 1790   errorCheck  a4'>>
 1791   return (res')
 1792 
 1793 
 1794 
 1795 -- |Basis-point value.
 1796 -- Obtained by setting dy = 0.0001 in the 2nd-order Taylor series expansion.
 1797 basisPointValue :: (GenLeg l) -> (InterestRate) -> (Bool) -- ^includeSettlementDateFlows
 1798  -> (Maybe Day) -- ^settlementDate
 1799  -> (Maybe Day) -- ^npvDate
 1800  -> IO ((Double))
 1801 basisPointValue a1 a2 a3 a4 a5 =
 1802   withLeg a1 $ \a1' -> 
 1803   withInterestRate a2 $ \a2' -> 
 1804   let {a3' = C2HSImp.fromBool a3} in 
 1805   withMaybeDay a4 $ \a4' -> 
 1806   withMaybeDay a5 $ \a5' -> 
 1807   preErrorCheck $ \a6' -> 
 1808   basisPointValue'_ a1' a2' a3' a4' a5' a6' >>= \res ->
 1809   let {res' = realToFrac res} in
 1810   errorCheck  a6'>>
 1811   return (res')
 1812 
 1813 
 1814 
 1815 -- |Where discount factors come from.
 1816 data Discounting y
 1817   = DiscountingCurve !(GenYieldTermStructure y)
 1818   | DiscountingZSpread !(GenYieldTermStructure y) !Double !Compounding !Frequency -- ^curve, zSpread, compounding, frequency
 1819   | DiscountingYield !InterestRate
 1820 
 1821 -- |'Discounting' restricted to the cases 'bps' supports: upstream has no Z-spreaded bps.
 1822 data BpsDiscounting y
 1823   = BpsDiscountingCurve !(GenYieldTermStructure y)
 1824   | BpsDiscountingYield !InterestRate
 1825 
 1826 -- |Basis-point sensitivity of the cash flows.
 1827 -- The result is the change in NPV due to a uniform 1-basis-point change in the rate paid by the cash flows. The change for each coupon is discounted according to the given constant interest rate. The result is affected by the choice of the interest-rate compounding and the relative frequency and day counter.
 1828 bpsFromYieldRaw :: (GenLeg l) -> (InterestRate) -> (Bool) -- ^includeSettlementDateFlows
 1829  -> (Maybe Day) -- ^settlementDate
 1830  -> (Maybe Day) -- ^npvDate
 1831  -> IO ((Double))
 1832 bpsFromYieldRaw a1 a2 a3 a4 a5 =
 1833   withLeg a1 $ \a1' -> 
 1834   withInterestRate a2 $ \a2' -> 
 1835   let {a3' = C2HSImp.fromBool a3} in 
 1836   withMaybeDay a4 $ \a4' -> 
 1837   withMaybeDay a5 $ \a5' -> 
 1838   preErrorCheck $ \a6' -> 
 1839   bpsFromYieldRaw'_ a1' a2' a3' a4' a5' a6' >>= \res ->
 1840   let {res' = realToFrac res} in
 1841   errorCheck  a6'>>
 1842   return (res')
 1843 
 1844 
 1845 
 1846 -- |Cash-flow convexity.
 1847 -- The convexity of a string of cash flows is defined as \[ C = \frac{1}{P} \frac{\partial^2 P}{\partial y^2} \] where $ P $ is the present value of the cash flows according to the given IRR $ y $.
 1848 convexity :: (GenLeg l) -> (InterestRate) -> (Bool) -- ^includeSettlementDateFlows
 1849  -> (Maybe Day) -- ^settlementDate
 1850  -> (Maybe Day) -- ^npvDate
 1851  -> IO ((Double))
 1852 convexity a1 a2 a3 a4 a5 =
 1853   withLeg a1 $ \a1' -> 
 1854   withInterestRate a2 $ \a2' -> 
 1855   let {a3' = C2HSImp.fromBool a3} in 
 1856   withMaybeDay a4 $ \a4' -> 
 1857   withMaybeDay a5 $ \a5' -> 
 1858   preErrorCheck $ \a6' -> 
 1859   convexity'_ a1' a2' a3' a4' a5' a6' >>= \res ->
 1860   let {res' = realToFrac res} in
 1861   errorCheck  a6'>>
 1862   return (res')
 1863 
 1864 
 1865 
 1866 -- |Whether every cash flow in the leg has occurred as of /settlementDate/.
 1867 isExpired :: (GenLeg l) -> (Bool) -- ^includeSettlementDateFlows
 1868  -> (Maybe Day) -- ^settlementDate
 1869  -> IO ((Bool))
 1870 isExpired a1 a2 a3 =
 1871   withLeg a1 $ \a1' -> 
 1872   let {a2' = C2HSImp.fromBool a2} in 
 1873   withMaybeDay a3 $ \a3' -> 
 1874   preErrorCheck $ \a4' -> 
 1875   isExpired'_ a1' a2' a3' a4' >>= \res ->
 1876   let {res' = C2HSImp.toBool res} in
 1877   errorCheck  a4'>>
 1878   return (res')
 1879 
 1880 
 1881 
 1882 -- |Date of the leg's last cash flow.
 1883 maturityDate :: (GenLeg l) -> IO ((Day))
 1884 maturityDate a1 =
 1885   withLeg a1 $ \a1' -> 
 1886   preErrorCheck $ \a2' -> 
 1887   maturityDate'_ a1' a2' >>= \res ->
 1888   let {res' = toDay res} in
 1889   errorCheck  a2'>>
 1890   return (res')
 1891 
 1892 
 1893 
 1894 -- |Amount of the first cash flow paying after /settlementDate/.
 1895 nextCashFlowAmount :: (GenLeg l) -> (Bool) -- ^includeSettlementDateFlows
 1896  -> (Maybe Day) -- ^settlementDate
 1897  -> IO ((Double))
 1898 nextCashFlowAmount a1 a2 a3 =
 1899   withLeg a1 $ \a1' -> 
 1900   let {a2' = C2HSImp.fromBool a2} in 
 1901   withMaybeDay a3 $ \a3' -> 
 1902   preErrorCheck $ \a4' -> 
 1903   nextCashFlowAmount'_ a1' a2' a3' a4' >>= \res ->
 1904   let {res' = realToFrac res} in
 1905   errorCheck  a4'>>
 1906   return (res')
 1907 
 1908 
 1909 
 1910 -- |Date of the first cash flow paying after /settlementDate/.
 1911 nextCashFlowDate :: (GenLeg l) -> (Bool) -- ^includeSettlementDateFlows
 1912  -> (Maybe Day) -- ^settlementDate
 1913  -> IO (((Maybe Day)))
 1914 nextCashFlowDate a1 a2 a3 =
 1915   withLeg a1 $ \a1' -> 
 1916   let {a2' = C2HSImp.fromBool a2} in 
 1917   withMaybeDay a3 $ \a3' -> 
 1918   preErrorCheck $ \a4' -> 
 1919   nextCashFlowDate'_ a1' a2' a3' a4' >>= \res ->
 1920   let {res' = toMaybeDay res} in
 1921   errorCheck  a4'>>
 1922   return (res')
 1923 
 1924 
 1925 
 1926 -- |Coupon rate of the next cash flow paying after /settlementDate/.
 1927 nextCouponRate :: (GenLeg l) -> (Bool) -- ^includeSettlementDateFlows
 1928  -> (Maybe Day) -- ^settlementDate
 1929  -> IO ((Double))
 1930 nextCouponRate a1 a2 a3 =
 1931   withLeg a1 $ \a1' -> 
 1932   let {a2' = C2HSImp.fromBool a2} in 
 1933   withMaybeDay a3 $ \a3' -> 
 1934   preErrorCheck $ \a4' -> 
 1935   nextCouponRate'_ a1' a2' a3' a4' >>= \res ->
 1936   let {res' = realToFrac res} in
 1937   errorCheck  a4'>>
 1938   return (res')
 1939 
 1940 
 1941 
 1942 -- |Nominal of the coupon paying on /settlementDate/.
 1943 nominal :: (GenLeg l) -> (Bool) -- ^includeSettlementDateFlows
 1944  -> (Maybe Day) -- ^settlementDate
 1945  -> IO ((Double))
 1946 nominal a1 a2 a3 =
 1947   withLeg a1 $ \a1' -> 
 1948   let {a2' = C2HSImp.fromBool a2} in 
 1949   withMaybeDay a3 $ \a3' -> 
 1950   preErrorCheck $ \a4' -> 
 1951   nominal'_ a1' a2' a3' a4' >>= \res ->
 1952   let {res' = realToFrac res} in
 1953   errorCheck  a4'>>
 1954   return (res')
 1955 
 1956 
 1957 
 1958 -- |NPV of the cash flows.
 1959 -- The IRR is the interest rate at which the NPV of the cash flows equals the dirty price.The NPV is the sum of the cash flows, each discounted according to the given constant interest rate. The result is affected by the choice of the interest-rate compounding and the relative frequency and day counter.
 1960 npvFromYieldRaw :: (GenLeg l) -> (InterestRate) -> (Bool) -- ^includeSettlementDateFlows
 1961  -> (Maybe Day) -- ^settlementDate
 1962  -> (Maybe Day) -- ^npvDate
 1963  -> IO ((Double))
 1964 npvFromYieldRaw a1 a2 a3 a4 a5 =
 1965   withLeg a1 $ \a1' -> 
 1966   withInterestRate a2 $ \a2' -> 
 1967   let {a3' = C2HSImp.fromBool a3} in 
 1968   withMaybeDay a4 $ \a4' -> 
 1969   withMaybeDay a5 $ \a5' -> 
 1970   preErrorCheck $ \a6' -> 
 1971   npvFromYieldRaw'_ a1' a2' a3' a4' a5' a6' >>= \res ->
 1972   let {res' = realToFrac res} in
 1973   errorCheck  a6'>>
 1974   return (res')
 1975 
 1976 
 1977 
 1978 -- |At-the-money rate of the cash flows.
 1979 -- The result is the fixed rate for which a fixed rate cash flow vector, equivalent to the input vector, has the required NPV according to the given term structure. If the required NPV is not given, the input cash flow vector's NPV is used instead.
 1980 atmRate :: (GenLeg l) -> (GenYieldTermStructure y) -> (Bool) -- ^includeSettlementDateFlows
 1981  -> (Maybe Day) -- ^settlementDate
 1982  -> (Maybe Day) -- ^npvDate
 1983  -> (Double) -- ^npv
 1984  -> IO ((Double))
 1985 atmRate a1 a2 a3 a4 a5 a6 =
 1986   withLeg a1 $ \a1' -> 
 1987   withYieldTermStructure a2 $ \a2' -> 
 1988   let {a3' = C2HSImp.fromBool a3} in 
 1989   withMaybeDay a4 $ \a4' -> 
 1990   withMaybeDay a5 $ \a5' -> 
 1991   let {a6' = realToFrac a6} in 
 1992   preErrorCheck $ \a7' -> 
 1993   atmRate'_ a1' a2' a3' a4' a5' a6' a7' >>= \res ->
 1994   let {res' = realToFrac res} in
 1995   errorCheck  a7'>>
 1996   return (res')
 1997 
 1998 
 1999 
 2000 -- |Basis-point sensitivity of the cash flows.
 2001 -- The result is the change in NPV due to a uniform 1-basis-point change in the rate paid by the cash flows. The change for each coupon is discounted according to the given term structure.
 2002 bpsFromCurveRaw :: (GenLeg l) -> (GenYieldTermStructure y) -> (Bool) -- ^includeSettlementDateFlows
 2003  -> (Maybe Day) -- ^settlementDate
 2004  -> (Maybe Day) -- ^npvDate
 2005  -> IO ((Double))
 2006 bpsFromCurveRaw a1 a2 a3 a4 a5 =
 2007   withLeg a1 $ \a1' -> 
 2008   withYieldTermStructure a2 $ \a2' -> 
 2009   let {a3' = C2HSImp.fromBool a3} in 
 2010   withMaybeDay a4 $ \a4' -> 
 2011   withMaybeDay a5 $ \a5' -> 
 2012   preErrorCheck $ \a6' -> 
 2013   bpsFromCurveRaw'_ a1' a2' a3' a4' a5' a6' >>= \res ->
 2014   let {res' = realToFrac res} in
 2015   errorCheck  a6'>>
 2016   return (res')
 2017 
 2018 
 2019 
 2020 -- |NPV of the cash flows.
 2021 -- For details on z-spread refer to: "Credit Spreads Explained", Lehman Brothers European Fixed Income Research - March 2004, D. O'KaneThe NPV is the sum of the cash flows, each discounted according to the z-spreaded term structure. The result is affected by the choice of the z-spread compounding and the relative frequency and day counter.
 2022 npvWithZSpreadRaw :: (GenLeg l) -> (GenYieldTermStructure y) -> (Double) -- ^zSpread
 2023  -> (Compounding) -> (Frequency) -> (Bool) -- ^includeSettlementDateFlows
 2024  -> (Maybe Day) -- ^settlementDate
 2025  -> (Maybe Day) -- ^npvDate
 2026  -> IO ((Double))
 2027 npvWithZSpreadRaw a1 a2 a3 a4 a5 a6 a7 a8 =
 2028   withLeg a1 $ \a1' -> 
 2029   withYieldTermStructure a2 $ \a2' -> 
 2030   let {a3' = realToFrac a3} in 
 2031   let {a4' = (fromIntegral . fromEnum) a4} in 
 2032   let {a5' = (fromIntegral . fromEnum) a5} in 
 2033   let {a6' = C2HSImp.fromBool a6} in 
 2034   withMaybeDay a7 $ \a7' -> 
 2035   withMaybeDay a8 $ \a8' -> 
 2036   preErrorCheck $ \a9' -> 
 2037   npvWithZSpreadRaw'_ a1' a2' a3' a4' a5' a6' a7' a8' a9' >>= \res ->
 2038   let {res' = realToFrac res} in
 2039   errorCheck  a9'>>
 2040   return (res')
 2041 
 2042 
 2043 
 2044 -- |NPV of the cash flows.
 2045 -- The NPV is the sum of the cash flows, each discounted according to the given term structure.
 2046 npvFromCurveRaw :: (GenLeg l) -> (GenYieldTermStructure y) -> (Bool) -- ^includeSettlementDateFlows
 2047  -> (Maybe Day) -- ^settlementDate
 2048  -> (Maybe Day) -- ^npvDate
 2049  -> IO ((Double))
 2050 npvFromCurveRaw a1 a2 a3 a4 a5 =
 2051   withLeg a1 $ \a1' -> 
 2052   withYieldTermStructure a2 $ \a2' -> 
 2053   let {a3' = C2HSImp.fromBool a3} in 
 2054   withMaybeDay a4 $ \a4' -> 
 2055   withMaybeDay a5 $ \a5' -> 
 2056   preErrorCheck $ \a6' -> 
 2057   npvFromCurveRaw'_ a1' a2' a3' a4' a5' a6' >>= \res ->
 2058   let {res' = realToFrac res} in
 2059   errorCheck  a6'>>
 2060   return (res')
 2061 
 2062 
 2063 
 2064 -- |NPV of the cash flows under the given discounting.
 2065 npv :: GenLeg l -> Discounting y -> Bool -> Maybe Day -> Maybe Day -> IO Double
 2066 npv cashflows discounting = case discounting of
 2067   DiscountingCurve curve -> npvFromCurveRaw cashflows curve
 2068   DiscountingZSpread curve z comp freq -> npvWithZSpreadRaw cashflows curve z comp freq
 2069   DiscountingYield y -> npvFromYieldRaw cashflows y
 2070 
 2071 -- |Basis-point sensitivity of the cash flows under the given discounting.
 2072 bps :: GenLeg l -> BpsDiscounting y -> Bool -> Maybe Day -> Maybe Day -> IO Double
 2073 bps cashflows discounting = case discounting of
 2074   BpsDiscountingCurve curve -> bpsFromCurveRaw cashflows curve
 2075   BpsDiscountingYield y -> bpsFromYieldRaw cashflows y
 2076 
 2077 -- |NPV and BPS of the cash flows.
 2078 -- The NPV and BPS of the cash flows calculated together for performance reason
 2079 npvBps :: (GenLeg l) -> (GenYieldTermStructure y) -> (Bool) -- ^includeSettlementDateFlows
 2080  -> (Day) -- ^settlementDate
 2081  -> (Day) -- ^npvDate
 2082  -> IO ((Double), (Double))
 2083 npvBps a1 a2 a3 a4 a5 =
 2084   withLeg a1 $ \a1' -> 
 2085   withYieldTermStructure a2 $ \a2' -> 
 2086   let {a3' = C2HSImp.fromBool a3} in 
 2087   withDay a4 $ \a4' -> 
 2088   withDay a5 $ \a5' -> 
 2089   prePtr $ \a6' -> 
 2090   prePtr $ \a7' -> 
 2091   preErrorCheck $ \a8' -> 
 2092   npvBps'_ a1' a2' a3' a4' a5' a6' a7' a8' >>
 2093   peekDouble  a6'>>= \a6'' -> 
 2094   peekDouble  a7'>>= \a7'' -> 
 2095   errorCheck  a8'>>
 2096   return (a6'', a7'')
 2097 
 2098 
 2099 
 2100 -- |implied Z-spread.
 2101 zSpread :: (GenLeg l) -> (Double) -- ^npv
 2102  -> (GenYieldTermStructure y) -> (Compounding) -> (Frequency) -> (Bool) -- ^includeSettlementDateFlows
 2103  -> (Maybe Day) -- ^settlementDate
 2104  -> (Maybe Day) -- ^npvDate
 2105  -> (Double) -- ^accuracy
 2106  -> (Word) -- ^maxIterations
 2107  -> (Double) -- ^guess
 2108  -> IO ((Double))
 2109 zSpread a1 a2 a3 a4 a5 a6 a7 a8 a9 a10 a11 =
 2110   withLeg a1 $ \a1' -> 
 2111   let {a2' = realToFrac a2} in 
 2112   withYieldTermStructure a3 $ \a3' -> 
 2113   let {a4' = (fromIntegral . fromEnum) a4} in 
 2114   let {a5' = (fromIntegral . fromEnum) a5} in 
 2115   let {a6' = C2HSImp.fromBool a6} in 
 2116   withMaybeDay a7 $ \a7' -> 
 2117   withMaybeDay a8 $ \a8' -> 
 2118   let {a9' = realToFrac a9} in 
 2119   let {a10' = fromIntegral a10} in 
 2120   let {a11' = realToFrac a11} in 
 2121   preErrorCheck $ \a12' -> 
 2122   zSpread'_ a1' a2' a3' a4' a5' a6' a7' a8' a9' a10' a11' a12' >>= \res ->
 2123   let {res' = realToFrac res} in
 2124   errorCheck  a12'>>
 2125   return (res')
 2126 
 2127 
 2128 
 2129 -- |Amount of the last cash flow that paid before or at /settlementDate/.
 2130 previousCashFlowAmount :: (GenLeg l) -> (Bool) -- ^includeSettlementDateFlows
 2131  -> (Maybe Day) -- ^settlementDate
 2132  -> IO ((Double))
 2133 previousCashFlowAmount a1 a2 a3 =
 2134   withLeg a1 $ \a1' -> 
 2135   let {a2' = C2HSImp.fromBool a2} in 
 2136   withMaybeDay a3 $ \a3' -> 
 2137   preErrorCheck $ \a4' -> 
 2138   previousCashFlowAmount'_ a1' a2' a3' a4' >>= \res ->
 2139   let {res' = realToFrac res} in
 2140   errorCheck  a4'>>
 2141   return (res')
 2142 
 2143 
 2144 
 2145 -- |Date of the last cash flow that paid before or at /settlementDate/.
 2146 previousCashFlowDate :: (GenLeg l) -> (Bool) -- ^includeSettlementDateFlows
 2147  -> (Maybe Day) -- ^settlementDate
 2148  -> IO ((Maybe Day))
 2149 previousCashFlowDate a1 a2 a3 =
 2150   withLeg a1 $ \a1' -> 
 2151   let {a2' = C2HSImp.fromBool a2} in 
 2152   withMaybeDay a3 $ \a3' -> 
 2153   preErrorCheck $ \a4' -> 
 2154   previousCashFlowDate'_ a1' a2' a3' a4' >>= \res ->
 2155   let {res' = toMaybeDay res} in
 2156   errorCheck  a4'>>
 2157   return (res')
 2158 
 2159 
 2160 
 2161 -- |Coupon rate of the last cash flow that paid before or at /settlementDate/.
 2162 previousCouponRate :: (GenLeg l) -> (Bool) -- ^includeSettlementDateFlows
 2163  -> (Maybe Day) -- ^settlementDate
 2164  -> IO ((Double))
 2165 previousCouponRate a1 a2 a3 =
 2166   withLeg a1 $ \a1' -> 
 2167   let {a2' = C2HSImp.fromBool a2} in 
 2168   withMaybeDay a3 $ \a3' -> 
 2169   preErrorCheck $ \a4' -> 
 2170   previousCouponRate'_ a1' a2' a3' a4' >>= \res ->
 2171   let {res' = realToFrac res} in
 2172   errorCheck  a4'>>
 2173   return (res')
 2174 
 2175 
 2176 
 2177 -- |End of the reference period of the coupon paying on /settlementDate/.
 2178 referencePeriodEnd :: (GenLeg l) -> (Bool) -- ^includeSettlementDateFlows
 2179  -> (Maybe Day) -- ^settlementDate
 2180  -> IO ((Maybe Day))
 2181 referencePeriodEnd a1 a2 a3 =
 2182   withLeg a1 $ \a1' -> 
 2183   let {a2' = C2HSImp.fromBool a2} in 
 2184   withMaybeDay a3 $ \a3' -> 
 2185   preErrorCheck $ \a4' -> 
 2186   referencePeriodEnd'_ a1' a2' a3' a4' >>= \res ->
 2187   let {res' = toMaybeDay res} in
 2188   errorCheck  a4'>>
 2189   return (res')
 2190 
 2191 
 2192 
 2193 -- |Start of the reference period of the coupon paying on /settlementDate/.
 2194 referencePeriodStart :: (GenLeg l) -> (Bool) -- ^includeSettlementDateFlows
 2195  -> (Maybe Day) -- ^settlementDate
 2196  -> IO ((Maybe Day))
 2197 referencePeriodStart a1 a2 a3 =
 2198   withLeg a1 $ \a1' -> 
 2199   let {a2' = C2HSImp.fromBool a2} in 
 2200   withMaybeDay a3 $ \a3' -> 
 2201   preErrorCheck $ \a4' -> 
 2202   referencePeriodStart'_ a1' a2' a3' a4' >>= \res ->
 2203   let {res' = toMaybeDay res} in
 2204   errorCheck  a4'>>
 2205   return (res')
 2206 
 2207 
 2208 
 2209 -- |Implied internal rate of return.
 2210 -- The function verifies the theoretical existance of an IRR and numerically establishes the IRR to the desired precision.
 2211 yield :: (GenLeg l) -> (Double) -- ^npv
 2212  -> (DayCounter) -> (Compounding) -> (Frequency) -> (Bool) -- ^includeSettlementDateFlows
 2213  -> (Maybe Day) -- ^settlementDate
 2214  -> (Maybe Day) -- ^npvDate
 2215  -> (Double) -- ^accuracy
 2216  -> (Word) -- ^maxIterations
 2217  -> (Double) -- ^guess
 2218  -> IO ((Double))
 2219 yield a1 a2 a3 a4 a5 a6 a7 a8 a9 a10 a11 =
 2220   withLeg a1 $ \a1' -> 
 2221   let {a2' = realToFrac a2} in 
 2222   withDayCounter a3 $ \a3' -> 
 2223   let {a4' = (fromIntegral . fromEnum) a4} in 
 2224   let {a5' = (fromIntegral . fromEnum) a5} in 
 2225   let {a6' = C2HSImp.fromBool a6} in 
 2226   withMaybeDay a7 $ \a7' -> 
 2227   withMaybeDay a8 $ \a8' -> 
 2228   let {a9' = realToFrac a9} in 
 2229   let {a10' = fromIntegral a10} in 
 2230   let {a11' = realToFrac a11} in 
 2231   preErrorCheck $ \a12' -> 
 2232   yield'_ a1' a2' a3' a4' a5' a6' a7' a8' a9' a10' a11' a12' >>= \res ->
 2233   let {res' = realToFrac res} in
 2234   errorCheck  a12'>>
 2235   return (res')
 2236 
 2237 
 2238 
 2239 -- |Yield value of a basis point.
 2240 -- The yield value of a one basis point change in price is the derivative of the yield with respect to the price multiplied by 0.01
 2241 yieldValueBasisPoint :: (GenLeg l) -> (InterestRate) -- ^yield
 2242  -> (Bool) -- ^includeSettlementDateFlows
 2243  -> (Maybe Day) -- ^settlementDate
 2244  -> (Maybe Day) -- ^npvDate
 2245  -> IO ((Double))
 2246 yieldValueBasisPoint a1 a2 a3 a4 a5 =
 2247   withLeg a1 $ \a1' -> 
 2248   withInterestRate a2 $ \a2' -> 
 2249   let {a3' = C2HSImp.fromBool a3} in 
 2250   withMaybeDay a4 $ \a4' -> 
 2251   withMaybeDay a5 $ \a5' -> 
 2252   preErrorCheck $ \a6' -> 
 2253   yieldValueBasisPoint'_ a1' a2' a3' a4' a5' a6' >>= \res ->
 2254   let {res' = realToFrac res} in
 2255   errorCheck  a6'>>
 2256   return (res')
 2257 
 2258 
 2259 
 2260 -- |start of the accrual periods for a coupon leg
 2261 couponAccrualStartDates :: (CouponLeg) -> IO (([Day]))
 2262 couponAccrualStartDates a1 =
 2263   withGenLeg a1 $ \a1' -> 
 2264   preIntArray $ \(a2'1, a2'2) -> 
 2265   preErrorCheck $ \a3' -> 
 2266   couponAccrualStartDates'_ a1' a2'1  a2'2 a3' >>
 2267   peekDayArray  a2'1  a2'2>>= \a2'' -> 
 2268   errorCheck  a3'>>
 2269   return (a2'')
 2270 
 2271 
 2272 
 2273 -- |Predetermined cash flow paying a fixed /amount/ at /date/.
 2274 fixedDividend :: (Double) -- ^amount
 2275  -> (Day) -- ^date
 2276  -> IO ((Dividend))
 2277 fixedDividend a1 a2 =
 2278   let {a1' = realToFrac a1} in 
 2279   withDay a2 $ \a2' -> 
 2280   preErrorCheck $ \a3' -> 
 2281   fixedDividend'_ a1' a2' a3' >>= \res ->
 2282   peekDividend res >>= \res' ->
 2283   errorCheck  a3'>>
 2284   return (res')
 2285 
 2286 
 2287 
 2288 -- |Predetermined cash flow paying /rate/ times /nominal/ at /date/.
 2289 fractionalDividendWithNominal :: (Double) -- ^rate
 2290  -> (Double) -- ^nominal
 2291  -> (Day) -- ^date
 2292  -> IO ((Dividend))
 2293 fractionalDividendWithNominal a1 a2 a3 =
 2294   let {a1' = realToFrac a1} in 
 2295   let {a2' = realToFrac a2} in 
 2296   withDay a3 $ \a3' -> 
 2297   preErrorCheck $ \a4' -> 
 2298   fractionalDividendWithNominal'_ a1' a2' a3' a4' >>= \res ->
 2299   peekDividend res >>= \res' ->
 2300   errorCheck  a4'>>
 2301   return (res')
 2302 
 2303 
 2304 
 2305 -- |Predetermined cash flow paying a fractional /rate/ of the underlying's price at /date/.
 2306 fractionalDividend :: (Double) -- ^rate
 2307  -> (Day) -- ^date
 2308  -> IO ((Dividend))
 2309 fractionalDividend a1 a2 =
 2310   let {a1' = realToFrac a1} in 
 2311   withDay a2 $ \a2' -> 
 2312   preErrorCheck $ \a3' -> 
 2313   fractionalDividend'_ a1' a2' a3' >>= \res ->
 2314   peekDividend res >>= \res' ->
 2315   errorCheck  a3'>>
 2316   return (res')
 2317 
 2318 
 2319 
 2320 -- |Build a leg of average-BMA coupons.
 2321 averageBmaLeg :: (Schedule) -> (BMAIndex) -> (NonEmpty Double) -- ^notionals
 2322  -> (DayCounter) -> (BusinessDayConvention) -> ([Double]) -- ^gearings
 2323  -> ([Double]) -- ^spreads
 2324  -> IO ((Leg))
 2325 averageBmaLeg a1 a2 a3 a4 a5 a6 a7 =
 2326   withSchedule a1 $ \a1' -> 
 2327   withBMAIndex a2 $ \a2' -> 
 2328   withNonEmptyDoubleArray a3 $ \(a3'1, a3'2) -> 
 2329   withDayCounter a4 $ \a4' -> 
 2330   let {a5' = fromEnumC a5} in 
 2331   withDoubleArray a6 $ \(a6'1, a6'2) -> 
 2332   withDoubleArray a7 $ \(a7'1, a7'2) -> 
 2333   preErrorCheck $ \a8' -> 
 2334   averageBmaLeg'_ a1' a2' a3'1  a3'2 a4' a5' a6'1  a6'2 a7'1  a7'2 a8' >>= \res ->
 2335   peekLeg res >>= \res' ->
 2336   errorCheck  a8'>>
 2337   return (res')
 2338 
 2339 
 2340 
 2341 -- |Build a leg of fixed-rate coupons.
 2342 fixedRateLeg :: Schedule -> NonEmpty Double -> NonEmpty InterestRate -> BusinessDayConvention -> DayCounter -> Calendar -> IO Leg
 2343 fixedRateLeg schedule notionals rates = fixedRateLeg_ schedule notionals (toList rates)
 2344 fixedRateLeg_ :: (Schedule) -> (NonEmpty Double) -- ^notionals
 2345  -> ([InterestRate]) -- ^couponRates
 2346  -> (BusinessDayConvention) -- ^paymentAdjustment
 2347  -> (DayCounter) -- ^firstPeriodDayCounter
 2348  -> (Calendar) -- ^paymentCalendar
 2349  -> IO ((Leg))
 2350 fixedRateLeg_ a1 a2 a3 a4 a5 a6 =
 2351   withSchedule a1 $ \a1' -> 
 2352   withNonEmptyDoubleArray a2 $ \(a2'1, a2'2) -> 
 2353   withInterestRateArray a3 $ \(a3'1, a3'2) -> 
 2354   let {a4' = fromEnumC a4} in 
 2355   withDayCounter a5 $ \a5' -> 
 2356   withCalendar a6 $ \a6' -> 
 2357   preErrorCheck $ \a7' -> 
 2358   fixedRateLeg_'_ a1' a2'1  a2'2 a3'1  a3'2 a4' a5' a6' a7' >>= \res ->
 2359   peekLeg res >>= \res' ->
 2360   errorCheck  a7'>>
 2361   return (res')
 2362 
 2363 
 2364 
 2365 -- |iborLeg keeps its original 12-arg signature -- existing callers are unaffected -- but
 2366 -- now delegates to iborLeg_, the raw binding widened to IborLeg's full builder surface,
 2367 -- hardcoding upstream's own defaults for the params iborLeg doesn't expose. Use
 2368 -- 'iborLegWithOptions' to reach those (payment lag\/calendar, ex-coupon period, fixing
 2369 -- convention, indexed\/at-par coupons) via 'IborLegOpts'.
 2370 iborLeg :: Schedule -> GenIborIndex ibor -> NonEmpty Double -> DayCounter -> BusinessDayConvention
 2371   -> [Word] -> [Double] -> [Double] -> [Double] -> [Double] -> Bool -> Bool -> IO Leg
 2372 iborLeg schedule idx notionals dc adj fixingDays gearings spreads caps floors inArrears zp = do
 2373   cal <- calendar Null
 2374   iborLeg_ schedule idx notionals dc adj fixingDays gearings spreads caps floors inArrears zp
 2375     (ilgPaymentLag defaultIborLegOpts) cal (ilgExCouponPeriod defaultIborLegOpts) cal
 2376     (ilgExCouponConvention defaultIborLegOpts) (ilgExCouponEndOfMonth defaultIborLegOpts)
 2377     (ilgFixingConvention defaultIborLegOpts) (ilgUseIndexedCoupons defaultIborLegOpts) Nothing
 2378 
 2379 -- |'iborLeg' widened to every 'IborLeg' builder-method param via 'IborLegOpts'.
 2380 iborLegWithOptions :: Schedule -> GenIborIndex ibor -> NonEmpty Double -> DayCounter -> BusinessDayConvention
 2381   -> [Word] -> [Double] -> [Double] -> [Double] -> [Double] -> Bool -> Bool -> IborLegOpts ibor2
 2382   -> IO Leg
 2383 iborLegWithOptions schedule idx notionals dc adj fixingDays gearings spreads caps floors inArrears zp opts = do
 2384   cal <- calendar Null
 2385   iborLeg_ schedule idx notionals dc adj fixingDays gearings spreads caps floors inArrears zp
 2386     (ilgPaymentLag opts) (fromMaybe cal (ilgPaymentCalendar opts)) (ilgExCouponPeriod opts)
 2387     (fromMaybe cal (ilgExCouponCalendar opts)) (ilgExCouponConvention opts)
 2388     (ilgExCouponEndOfMonth opts) (ilgFixingConvention opts) (ilgUseIndexedCoupons opts) (ilgStubIndexSelection opts)
 2389 
 2390 -- |Raw binding for 'iborLeg'\/'iborLegWithOptions': builds a leg of capped\/floored Ibor-rate coupons.
 2391 iborLeg_ :: (Schedule) -> (GenIborIndex ibor) -> (NonEmpty Double) -- ^notionals
 2392  -> (DayCounter) -> (BusinessDayConvention) -- ^paymentAdjustment
 2393  -> ([Word]) -- ^fixingDays
 2394  -> ([Double]) -- ^gearings
 2395  -> ([Double]) -- ^spreads
 2396  -> ([Double]) -- ^caps
 2397  -> ([Double]) -- ^floors
 2398  -> (Bool) -- ^inArrears
 2399  -> (Bool) -- ^zeroPayments
 2400  -> (Int) -- ^paymentLag
 2401  -> (Calendar) -- ^paymentCalendar
 2402  -> ((Int,TimeUnit)) -- ^exCouponPeriod
 2403  -> (Calendar) -- ^exCouponCalendar
 2404  -> (BusinessDayConvention) -- ^exCouponConvention
 2405  -> (Bool) -- ^exCouponEndOfMonth
 2406  -> (BusinessDayConvention) -- ^fixingConvention
 2407  -> (Maybe Bool) -- ^useIndexedCoupons
 2408  -> (Maybe (StubIndexSelection ibor2)) -- ^stubIndexSelection (1.44; QuantLib 1.43 requires 'Nothing')
 2409  -> IO ((Leg))
 2410 iborLeg_ a1 a2 a3 a4 a5 a6 a7 a8 a9 a10 a11 a12 a13 a14 a15 a16 a17 a18 a19 a20 a21 =
 2411   withSchedule a1 $ \a1' -> 
 2412   withIborIndex a2 $ \a2' -> 
 2413   withNonEmptyDoubleArray a3 $ \(a3'1, a3'2) -> 
 2414   withDayCounter a4 $ \a4' -> 
 2415   let {a5' = fromEnumC a5} in 
 2416   withIntArray a6 $ \(a6'1, a6'2) -> 
 2417   withDoubleArray a7 $ \(a7'1, a7'2) -> 
 2418   withDoubleArray a8 $ \(a8'1, a8'2) -> 
 2419   withDoubleArray a9 $ \(a9'1, a9'2) -> 
 2420   withDoubleArray a10 $ \(a10'1, a10'2) -> 
 2421   let {a11' = C2HSImp.fromBool a11} in 
 2422   let {a12' = C2HSImp.fromBool a12} in 
 2423   let {a13' = fromIntegral a13} in 
 2424   withCalendar a14 $ \a14' -> 
 2425   let {(a15'1, a15'2) = fromEnumQuantity a15} in 
 2426   withCalendar a16 $ \a16' -> 
 2427   let {a17' = fromEnumC a17} in 
 2428   let {a18' = C2HSImp.fromBool a18} in 
 2429   let {a19' = fromEnumC a19} in 
 2430   let {a20' = fromMaybeBool a20} in 
 2431   withStubIndexSelection a21 $ \a21' -> 
 2432   preErrorCheck $ \a22' -> 
 2433   iborLeg_'_ a1' a2' a3'1  a3'2 a4' a5' a6'1  a6'2 a7'1  a7'2 a8'1  a8'2 a9'1  a9'2 a10'1  a10'2 a11' a12' a13' a14' a15'1  a15'2 a16' a17' a18' a19' a20' a21' a22' >>= \res ->
 2434   peekLeg res >>= \res' ->
 2435   errorCheck  a22'>>
 2436   return (res')
 2437 
 2438 
 2439 
 2440 -- |CMS leg builder (analog of 'iborLeg'), 12-arg core shape -- same defaults-hardcoding
 2441 -- pattern as 'iborLeg' for the params not in this signature. Use 'cmsLegWithOptions' to reach
 2442 -- them ('CmsLegOpts').
 2443 cmsLeg :: Schedule -> GenSwapIndex sidx -> NonEmpty Double -> DayCounter -> BusinessDayConvention
 2444   -> [Word] -> [Double] -> [Double] -> [Double] -> [Double] -> Bool -> Bool -> IO Leg
 2445 cmsLeg schedule idx notionals dc adj fixingDays gearings spreads caps floors inArrears zp = do
 2446   cal <- calendar Null
 2447   cmsLeg_ schedule idx notionals dc adj fixingDays gearings spreads caps floors inArrears zp
 2448     (cmslExCouponPeriod defaultCmsLegOpts) cal (cmslExCouponConvention defaultCmsLegOpts)
 2449     (cmslExCouponEndOfMonth defaultCmsLegOpts) (cmslFixingConvention defaultCmsLegOpts)
 2450 
 2451 -- |'cmsLeg' widened to every 'CmsLeg' builder-method param via 'CmsLegOpts'.
 2452 cmsLegWithOptions :: Schedule -> GenSwapIndex sidx -> NonEmpty Double -> DayCounter -> BusinessDayConvention
 2453   -> [Word] -> [Double] -> [Double] -> [Double] -> [Double] -> Bool -> Bool -> CmsLegOpts
 2454   -> IO Leg
 2455 cmsLegWithOptions schedule idx notionals dc adj fixingDays gearings spreads caps floors inArrears zp opts = do
 2456   cal <- calendar Null
 2457   cmsLeg_ schedule idx notionals dc adj fixingDays gearings spreads caps floors inArrears zp
 2458     (cmslExCouponPeriod opts) (fromMaybe cal (cmslExCouponCalendar opts))
 2459     (cmslExCouponConvention opts) (cmslExCouponEndOfMonth opts) (cmslFixingConvention opts)
 2460 
 2461 -- |Raw binding for 'cmsLeg'\/'cmsLegWithOptions': builds a leg of capped\/floored CMS-rate coupons.
 2462 cmsLeg_ :: (Schedule) -> (GenSwapIndex sidx) -> (NonEmpty Double) -- ^notionals
 2463  -> (DayCounter) -> (BusinessDayConvention) -- ^paymentAdjustment
 2464  -> ([Word]) -- ^fixingDays
 2465  -> ([Double]) -- ^gearings
 2466  -> ([Double]) -- ^spreads
 2467  -> ([Double]) -- ^caps
 2468  -> ([Double]) -- ^floors
 2469  -> (Bool) -- ^inArrears
 2470  -> (Bool) -- ^zeroPayments
 2471  -> ((Int,TimeUnit)) -- ^exCouponPeriod
 2472  -> (Calendar) -- ^exCouponCalendar
 2473  -> (BusinessDayConvention) -- ^exCouponConvention
 2474  -> (Bool) -- ^exCouponEndOfMonth
 2475  -> (BusinessDayConvention) -- ^fixingConvention
 2476  -> IO ((Leg))
 2477 cmsLeg_ a1 a2 a3 a4 a5 a6 a7 a8 a9 a10 a11 a12 a13 a14 a15 a16 a17 =
 2478   withSchedule a1 $ \a1' -> 
 2479   withSwapIndex a2 $ \a2' -> 
 2480   withNonEmptyDoubleArray a3 $ \(a3'1, a3'2) -> 
 2481   withDayCounter a4 $ \a4' -> 
 2482   let {a5' = fromEnumC a5} in 
 2483   withIntArray a6 $ \(a6'1, a6'2) -> 
 2484   withDoubleArray a7 $ \(a7'1, a7'2) -> 
 2485   withDoubleArray a8 $ \(a8'1, a8'2) -> 
 2486   withDoubleArray a9 $ \(a9'1, a9'2) -> 
 2487   withDoubleArray a10 $ \(a10'1, a10'2) -> 
 2488   let {a11' = C2HSImp.fromBool a11} in 
 2489   let {a12' = C2HSImp.fromBool a12} in 
 2490   let {(a13'1, a13'2) = fromEnumQuantity a13} in 
 2491   withCalendar a14 $ \a14' -> 
 2492   let {a15' = fromEnumC a15} in 
 2493   let {a16' = C2HSImp.fromBool a16} in 
 2494   let {a17' = fromEnumC a17} in 
 2495   preErrorCheck $ \a18' -> 
 2496   cmsLeg_'_ a1' a2' a3'1  a3'2 a4' a5' a6'1  a6'2 a7'1  a7'2 a8'1  a8'2 a9'1  a9'2 a10'1  a10'2 a11' a12' a13'1  a13'2 a14' a15' a16' a17' a18' >>= \res ->
 2497   peekLeg res >>= \res' ->
 2498   errorCheck  a18'>>
 2499   return (res')
 2500 
 2501 
 2502 
 2503 -- |Build a leg of overnight-index coupons.
 2504 overnightLeg :: (Schedule) -> (OvernightIborIndex) -> (NonEmpty Double) -- ^notionals'
 2505  -> (DayCounter) -> (BusinessDayConvention) -> ([Double]) -- ^gearings
 2506  -> ([Double]) -- ^spreads
 2507  -> IO ((Leg))
 2508 overnightLeg a1 a2 a3 a4 a5 a6 a7 =
 2509   withSchedule a1 $ \a1' -> 
 2510   withOvernightIborIndex a2 $ \a2' -> 
 2511   withNonEmptyDoubleArray a3 $ \(a3'1, a3'2) -> 
 2512   withDayCounter a4 $ \a4' -> 
 2513   let {a5' = fromEnumC a5} in 
 2514   withDoubleArray a6 $ \(a6'1, a6'2) -> 
 2515   withDoubleArray a7 $ \(a7'1, a7'2) -> 
 2516   preErrorCheck $ \a8' -> 
 2517   overnightLeg'_ a1' a2' a3'1  a3'2 a4' a5' a6'1  a6'2 a7'1  a7'2 a8' >>= \res ->
 2518   peekLeg res >>= \res' ->
 2519   errorCheck  a8'>>
 2520   return (res')
 2521 
 2522 
 2523 
 2524 -- |Build a leg of range-accrual floating-rate coupons.
 2525 rangeAccrualLeg :: (Schedule) -> (GenIborIndex ibor) -> (NonEmpty Double) -- ^notionals
 2526  -> (DayCounter) -> (BusinessDayConvention) -> ([Word]) -- ^fixingDays
 2527  -> ([Double]) -- ^gearings
 2528  -> ([Double]) -- ^spreads
 2529  -> ([Double]) -- ^lowerTriggers
 2530  -> ([Double]) -- ^upperTriggers
 2531  -> ((Int,TimeUnit)) -- ^observationTenor
 2532  -> (BusinessDayConvention) -> IO ((Leg))
 2533 rangeAccrualLeg a1 a2 a3 a4 a5 a6 a7 a8 a9 a10 a11 a12 =
 2534   withSchedule a1 $ \a1' -> 
 2535   withIborIndex a2 $ \a2' -> 
 2536   withNonEmptyDoubleArray a3 $ \(a3'1, a3'2) -> 
 2537   withDayCounter a4 $ \a4' -> 
 2538   let {a5' = fromEnumC a5} in 
 2539   withIntArray a6 $ \(a6'1, a6'2) -> 
 2540   withDoubleArray a7 $ \(a7'1, a7'2) -> 
 2541   withDoubleArray a8 $ \(a8'1, a8'2) -> 
 2542   withDoubleArray a9 $ \(a9'1, a9'2) -> 
 2543   withDoubleArray a10 $ \(a10'1, a10'2) -> 
 2544   let {(a11'1, a11'2) = fromEnumQuantity a11} in 
 2545   let {a12' = fromEnumC a12} in 
 2546   preErrorCheck $ \a13' -> 
 2547   rangeAccrualLeg'_ a1' a2' a3'1  a3'2 a4' a5' a6'1  a6'2 a7'1  a7'2 a8'1  a8'2 a9'1  a9'2 a10'1  a10'2 a11'1  a11'2 a12' a13' >>= \res ->
 2548   peekLeg res >>= \res' ->
 2549   errorCheck  a13'>>
 2550   return (res')
 2551 
 2552 
 2553 
 2554 -- |Fixed-rate coupons scaled by the ratio of a 'ZeroInflationIndex' fixing to /baseCPI/.
 2555 -- QuantLib 1.43 has no capped or floored CPI coupon variant.
 2556 cpiLeg :: (Schedule) -> (GenZeroInflationIndex zidx) -> (Double) -- ^baseCPI
 2557  -> ((Word,TimeUnit)) -- ^observationLag
 2558  -> (NonEmpty Double) -- ^notionals
 2559  -> (NonEmpty Double) -- ^fixedRates
 2560  -> (DayCounter) -- ^paymentDayCounter
 2561  -> (BusinessDayConvention) -- ^paymentAdjustment
 2562  -> (Calendar) -- ^paymentCalendar
 2563  -> (CPIInterpolationType) -- ^observationInterpolation
 2564  -> (Bool) -- ^subtractInflationNominal
 2565  -> IO ((Leg))
 2566 cpiLeg a1 a2 a3 a4 a5 a6 a7 a8 a9 a10 a11 =
 2567   withSchedule a1 $ \a1' -> 
 2568   withZeroInflationIndex a2 $ \a2' -> 
 2569   let {a3' = realToFrac a3} in 
 2570   let {(a4'1, a4'2) = fromEnumQuantity a4} in 
 2571   withNonEmptyDoubleArray a5 $ \(a5'1, a5'2) -> 
 2572   withNonEmptyDoubleArray a6 $ \(a6'1, a6'2) -> 
 2573   withDayCounter a7 $ \a7' -> 
 2574   let {a8' = fromEnumC a8} in 
 2575   withCalendar a9 $ \a9' -> 
 2576   let {a10' = fromEnumC a10} in 
 2577   let {a11' = C2HSImp.fromBool a11} in 
 2578   preErrorCheck $ \a12' -> 
 2579   cpiLeg'_ a1' a2' a3' a4'1  a4'2 a5'1  a5'2 a6'1  a6'2 a7' a8' a9' a10' a11' a12' >>= \res ->
 2580   peekLeg res >>= \res' ->
 2581   errorCheck  a12'>>
 2582   return (res')
 2583 
 2584 
 2585 
 2586 -- |Year-on-year inflation-linked coupons. Non-empty /caps/\//floors/ build
 2587 -- 'CappedFlooredYoYInflationCoupon's. All coupons need 'setYoyInflationCouponPricer' before
 2588 -- calculating amounts. QuantLib 1.43 has no capped or floored CPI coupon counterpart.
 2589 yoyInflationLeg :: (Schedule) -> (Calendar) -> (GenYoYInflationIndex yidx) -> ((Word,TimeUnit)) -- ^observationLag
 2590  -> (CPIInterpolationType) -- ^interpolation
 2591  -> (NonEmpty Double) -- ^notionals
 2592  -> (DayCounter) -- ^paymentDayCounter
 2593  -> (BusinessDayConvention) -- ^paymentAdjustment
 2594  -> ([Word]) -- ^fixingDays
 2595  -> ([Double]) -- ^gearings
 2596  -> ([Double]) -- ^spreads
 2597  -> ([Double]) -- ^caps
 2598  -> ([Double]) -- ^floors
 2599  -> IO ((Leg))
 2600 yoyInflationLeg a1 a2 a3 a4 a5 a6 a7 a8 a9 a10 a11 a12 a13 =
 2601   withSchedule a1 $ \a1' -> 
 2602   withCalendar a2 $ \a2' -> 
 2603   withYoYInflationIndex a3 $ \a3' -> 
 2604   let {(a4'1, a4'2) = fromEnumQuantity a4} in 
 2605   let {a5' = fromEnumC a5} in 
 2606   withNonEmptyDoubleArray a6 $ \(a6'1, a6'2) -> 
 2607   withDayCounter a7 $ \a7' -> 
 2608   let {a8' = fromEnumC a8} in 
 2609   withIntArray a9 $ \(a9'1, a9'2) -> 
 2610   withDoubleArray a10 $ \(a10'1, a10'2) -> 
 2611   withDoubleArray a11 $ \(a11'1, a11'2) -> 
 2612   withDoubleArray a12 $ \(a12'1, a12'2) -> 
 2613   withDoubleArray a13 $ \(a13'1, a13'2) -> 
 2614   preErrorCheck $ \a14' -> 
 2615   yoyInflationLeg'_ a1' a2' a3' a4'1  a4'2 a5' a6'1  a6'2 a7' a8' a9'1  a9'2 a10'1  a10'2 a11'1  a11'2 a12'1  a12'2 a13'1  a13'2 a14' >>= \res ->
 2616   peekLeg res >>= \res' ->
 2617   errorCheck  a14'>>
 2618   return (res')
 2619 
 2620 
 2621 
 2622 
 2623 
 2624 -- |Cash flow dependent on a 'ZeroInflationIndex' ratio (not a coupon -- no accruals).
 2625 -- The ratio is taken between fixings observed at /startDate/ and /endDate/ minus /observationLag/.
 2626 zeroInflationCashFlow :: (Double) -- ^notional
 2627  -> (GenZeroInflationIndex zidx) -> (CPIInterpolationType) -- ^observationInterpolation
 2628  -> (Day) -- ^startDate
 2629  -> (Day) -- ^endDate
 2630  -> ((Word,TimeUnit)) -- ^observationLag
 2631  -> (Day) -- ^paymentDate
 2632  -> (Bool) -- ^growthOnly
 2633  -> IO ((ZeroInflationCashFlow))
 2634 zeroInflationCashFlow a1 a2 a3 a4 a5 a6 a7 a8 =
 2635   let {a1' = realToFrac a1} in 
 2636   withZeroInflationIndex a2 $ \a2' -> 
 2637   let {a3' = fromEnumC a3} in 
 2638   withDay a4 $ \a4' -> 
 2639   withDay a5 $ \a5' -> 
 2640   let {(a6'1, a6'2) = fromEnumQuantity a6} in 
 2641   withDay a7 $ \a7' -> 
 2642   let {a8' = C2HSImp.fromBool a8} in 
 2643   preErrorCheck $ \a9' -> 
 2644   zeroInflationCashFlow'_ a1' a2' a3' a4' a5' a6'1  a6'2 a7' a8' a9' >>= \res ->
 2645   peekZeroInflationCashFlow res >>= \res' ->
 2646   errorCheck  a9'>>
 2647   return (res')
 2648 
 2649 
 2650 
 2651 -- |CPI-linked cash flow (not a coupon -- no accruals), with an optional explicit /baseFixing/
 2652 -- (pass 'Nothing' to derive it from /baseDate/ instead).
 2653 cpiCashFlow :: (Double) -- ^notional
 2654  -> (GenZeroInflationIndex zidx) -> (Maybe Day) -- ^baseDate
 2655  -> (Maybe Double) -- ^baseFixing
 2656  -> (Day) -- ^observationDate
 2657  -> ((Word,TimeUnit)) -- ^observationLag
 2658  -> (CPIInterpolationType) -- ^interpolation
 2659  -> (Day) -- ^paymentDate
 2660  -> (Bool) -- ^growthOnly
 2661  -> IO ((CPICashFlow))
 2662 cpiCashFlow a1 a2 a3 a4 a5 a6 a7 a8 a9 =
 2663   let {a1' = realToFrac a1} in 
 2664   withZeroInflationIndex a2 $ \a2' -> 
 2665   withMaybeDay a3 $ \a3' -> 
 2666   let {a4' = fromMaybeDouble a4} in 
 2667   withDay a5 $ \a5' -> 
 2668   let {(a6'1, a6'2) = fromEnumQuantity a6} in 
 2669   let {a7' = fromEnumC a7} in 
 2670   withDay a8 $ \a8' -> 
 2671   let {a9' = C2HSImp.fromBool a9} in 
 2672   preErrorCheck $ \a10' -> 
 2673   cpiCashFlow'_ a1' a2' a3' a4' a5' a6'1  a6'2 a7' a8' a9' a10' >>= \res ->
 2674   peekCPICashFlow res >>= \res' ->
 2675   errorCheck  a10'>>
 2676   return (res')
 2677 
 2678 
 2679 
 2680 -- |Cash flow dependent on the total return of an 'QuantLib.Index.Equity.EquityIndex' (not a coupon
 2681 -- -- no accruals): @index(fixingDate)\/index(baseDate)@, or that ratio minus one if /growthOnly/.
 2682 -- If no 'EquityCashFlowPricer' is attached via 'setEquityCashFlowPricer', 'amount'
 2683 -- computes this ratio directly from the index; a pricer (e.g. 'equityQuantoCashFlowPricer') is only
 2684 -- needed to price a quanto-adjusted variant.
 2685 equityCashFlow :: (Double) -- ^notional
 2686  -> (EquityIndex) -> (Day) -- ^baseDate
 2687  -> (Day) -- ^fixingDate
 2688  -> (Day) -- ^paymentDate
 2689  -> (Bool) -- ^growthOnly
 2690  -> IO ((EquityCashFlow))
 2691 equityCashFlow a1 a2 a3 a4 a5 a6 =
 2692   let {a1' = realToFrac a1} in 
 2693   withEquityIndex a2 $ \a2' -> 
 2694   withDay a3 $ \a3' -> 
 2695   withDay a4 $ \a4' -> 
 2696   withDay a5 $ \a5' -> 
 2697   let {a6' = C2HSImp.fromBool a6} in 
 2698   preErrorCheck $ \a7' -> 
 2699   equityCashFlow'_ a1' a2' a3' a4' a5' a6' a7' >>= \res ->
 2700   peekEquityCashFlow res >>= \res' ->
 2701   errorCheck  a7'>>
 2702   return (res')
 2703 
 2704 
 2705 
 2706 -- |Attach a pricer (e.g. from 'equityQuantoCashFlowPricer') to a single 'EquityCashFlow'; see
 2707 -- 'setEquityLegPricer' to attach one to every 'EquityCashFlow' in a leg instead.
 2708 setEquityCashFlowPricer :: (EquityCashFlow) -> (EquityCashFlowPricer) -> IO ()
 2709 setEquityCashFlowPricer a1 a2 =
 2710   withEquityCashFlow a1 $ \a1' -> 
 2711   withEquityCashFlowPricer a2 $ \a2' -> 
 2712   preErrorCheck $ \a3' -> 
 2713   setEquityCashFlowPricer'_ a1' a2' a3' >>
 2714   errorCheck  a3'>>
 2715   return ()
 2716 
 2717 
 2718 
 2719 -- |Quanto-adjusted pricer for an 'EquityCashFlow' whose equity leg is denominated in a currency
 2720 -- other than the swap's payment currency.
 2721 equityQuantoCashFlowPricer :: (GenYieldTermStructure y) -- ^quantoCurrencyTermStructure
 2722  -> (GenBlackVolTermStructure bv1) -- ^equityVolatility
 2723  -> (GenBlackVolTermStructure bv2) -- ^fxVolatility
 2724  -> (GenQuote q) -- ^correlation
 2725  -> IO ((EquityCashFlowPricer))
 2726 equityQuantoCashFlowPricer a1 a2 a3 a4 =
 2727   withYieldTermStructure a1 $ \a1' -> 
 2728   withBlackVolTermStructure a2 $ \a2' -> 
 2729   withBlackVolTermStructure a3 $ \a3' -> 
 2730   withQuote a4 $ \a4' -> 
 2731   preErrorCheck $ \a5' -> 
 2732   equityQuantoCashFlowPricer'_ a1' a2' a3' a4' a5' >>= \res ->
 2733   peekEquityCashFlowPricer res >>= \res' ->
 2734   errorCheck  a5'>>
 2735   return (res')
 2736 
 2737 
 2738 
 2739 -- |Attach a pricer to every 'EquityCashFlow' found in /leg/ (non-'EquityCashFlow' entries are left
 2740 -- untouched); see 'setEquityCashFlowPricer' to attach one to a single cash flow instead.
 2741 setEquityLegPricer :: (GenLeg l) -> (EquityCashFlowPricer) -> IO ()
 2742 setEquityLegPricer a1 a2 =
 2743   withLeg a1 $ \a1' -> 
 2744   withEquityCashFlowPricer a2 $ \a2' -> 
 2745   preErrorCheck $ \a3' -> 
 2746   setEquityLegPricer'_ a1' a2' a3' >>
 2747   errorCheck  a3'>>
 2748   return ()
 2749 
 2750 
 2751 
 2752 -- |try to downcast leg to a coupon leg
 2753 toCouponLeg :: (GenLeg l) -> IO ((CouponLeg))
 2754 toCouponLeg a1 =
 2755   withLeg a1 $ \a1' -> 
 2756   preErrorCheck $ \a2' -> 
 2757   toCouponLeg'_ a1' a2' >>= \res ->
 2758   peekCouponLeg res >>= \res' ->
 2759   errorCheck  a2'>>
 2760   return (res')
 2761 
 2762 
 2763 
 2764 -- |The individual coupons of a coupon leg, e.g. to ask each one its own 'rate' or
 2765 -- 'couponAccruedAmount'.  Pair with 'toCouponLeg' to get here from a 'Leg'.
 2766 coupons :: (CouponLeg) -- ^leg
 2767  -> IO (([Coupon]))
 2768 coupons a1 =
 2769   withGenLeg a1 $ \a1' -> 
 2770   preCouponArray $ \(a2'1, a2'2) -> 
 2771   preErrorCheck $ \a3' -> 
 2772   coupons'_ a1' a2'1  a2'2 a3' >>
 2773   peekCouponArray  a2'1  a2'2>>= \a2'' -> 
 2774   errorCheck  a3'>>
 2775   return (a2'')
 2776 
 2777 
 2778 
 2779 -- |Black-formula pricer for capped/floored Ibor coupons
 2780 blackIborCouponPricer :: (GenOptionletVolatilityStructure ov) -> (TimingAdjustment) -> (Maybe (GenQuote q)) -- ^correlation
 2781  -> (Maybe Bool) -- ^useIndexedCoupon
 2782  -> IO ((FloatingRateCouponPricer))
 2783 blackIborCouponPricer a1 a2 a3 a4 =
 2784   withOptionletVolatilityStructure a1 $ \a1' -> 
 2785   let {a2' = (fromIntegral . fromEnum) a2} in 
 2786   withMaybeQuote a3 $ \a3' -> 
 2787   let {a4' = fromMaybeBool a4} in 
 2788   preErrorCheck $ \a5' -> 
 2789   blackIborCouponPricer'_ a1' a2' a3' a4' a5' >>= \res ->
 2790   peekFloatingRateCouponPricer res >>= \res' ->
 2791   errorCheck  a5'>>
 2792   return (res')
 2793 
 2794 
 2795 
 2796 -- |Experimental quanto-adjusted Black-formula pricer for capped/floored Ibor coupons.
 2797 -- The FX Black volatility and underlying/FX correlation determine the quanto adjustment;
 2798 -- the caplet volatility supplies the ordinary Ibor optionlet pricing inputs.  The three
 2799 -- handles are retained by QuantLib, so relinking their underlying quotes or term structures
 2800 -- updates the pricer in the usual way.
 2801 blackIborQuantoCouponPricer :: (GenBlackVolTermStructure bv) -- ^fxVolatility
 2802  -> (GenQuote q) -- ^underlyingFxCorrelation
 2803  -> (GenOptionletVolatilityStructure ov) -- ^capletVolatility
 2804  -> IO ((FloatingRateCouponPricer))
 2805 blackIborQuantoCouponPricer a1 a2 a3 =
 2806   withBlackVolTermStructure a1 $ \a1' -> 
 2807   withQuote a2 $ \a2' -> 
 2808   withOptionletVolatilityStructure a3 $ \a3' -> 
 2809   preErrorCheck $ \a4' -> 
 2810   blackIborQuantoCouponPricer'_ a1' a2' a3' a4' >>= \res ->
 2811   peekFloatingRateCouponPricer res >>= \res' ->
 2812   errorCheck  a4'>>
 2813   return (res')
 2814 
 2815 
 2816 
 2817 -- |BGM-based pricer for 'RangeAccrualFloatersCoupon's (a 'rangeAccrualLeg')
 2818 rangeAccrualPricerByBgm :: (Double) -- ^correlation
 2819  -> (SmileSection) -- ^smilesOnExpiry
 2820  -> (SmileSection) -- ^smilesOnPayment
 2821  -> (Bool) -- ^withSmile
 2822  -> (Bool) -- ^byCallSpread
 2823  -> IO ((FloatingRateCouponPricer))
 2824 rangeAccrualPricerByBgm a1 a2 a3 a4 a5 =
 2825   let {a1' = realToFrac a1} in 
 2826   withSmileSection a2 $ \a2' -> 
 2827   withSmileSection a3 $ \a3' -> 
 2828   let {a4' = C2HSImp.fromBool a4} in 
 2829   let {a5' = C2HSImp.fromBool a5} in 
 2830   preErrorCheck $ \a6' -> 
 2831   rangeAccrualPricerByBgm'_ a1' a2' a3' a4' a5' a6' >>= \res ->
 2832   peekFloatingRateCouponPricer res >>= \res' ->
 2833   errorCheck  a6'>>
 2834   return (res')
 2835 
 2836 
 2837 
 2838 -- |Black-formula pricer for capped\/floored 'yoyInflationLeg' coupons.
 2839 blackYoyInflationCouponPricer :: (YoYOptionletVolatilitySurface) -> (GenYieldTermStructure y) -- ^nominalTermStructure
 2840  -> IO ((YoYInflationCouponPricer))
 2841 blackYoyInflationCouponPricer a1 a2 =
 2842   withGenVolatilityTermStructure a1 $ \a1' -> 
 2843   withYieldTermStructure a2 $ \a2' -> 
 2844   preErrorCheck $ \a3' -> 
 2845   blackYoyInflationCouponPricer'_ a1' a2' a3' >>= \res ->
 2846   peekYoYInflationCouponPricer res >>= \res' ->
 2847   errorCheck  a3'>>
 2848   return (res')
 2849 
 2850 
 2851 
 2852 -- |Unit-Displaced-Black-formula pricer for capped\/floored 'yoyInflationLeg' coupons.
 2853 unitDisplacedBlackYoyInflationCouponPricer :: (YoYOptionletVolatilitySurface) -> (GenYieldTermStructure y) -- ^nominalTermStructure
 2854  -> IO ((YoYInflationCouponPricer))
 2855 unitDisplacedBlackYoyInflationCouponPricer a1 a2 =
 2856   withGenVolatilityTermStructure a1 $ \a1' -> 
 2857   withYieldTermStructure a2 $ \a2' -> 
 2858   preErrorCheck $ \a3' -> 
 2859   unitDisplacedBlackYoyInflationCouponPricer'_ a1' a2' a3' >>= \res ->
 2860   peekYoYInflationCouponPricer res >>= \res' ->
 2861   errorCheck  a3'>>
 2862   return (res')
 2863 
 2864 
 2865 
 2866 -- |Bachelier-formula pricer for capped\/floored 'yoyInflationLeg' coupons.
 2867 bachelierYoyInflationCouponPricer :: (YoYOptionletVolatilitySurface) -> (GenYieldTermStructure y) -- ^nominalTermStructure
 2868  -> IO ((YoYInflationCouponPricer))
 2869 bachelierYoyInflationCouponPricer a1 a2 =
 2870   withGenVolatilityTermStructure a1 $ \a1' -> 
 2871   withYieldTermStructure a2 $ \a2' -> 
 2872   preErrorCheck $ \a3' -> 
 2873   bachelierYoyInflationCouponPricer'_ a1' a2' a3' >>= \res ->
 2874   peekYoYInflationCouponPricer res >>= \res' ->
 2875   errorCheck  a3'>>
 2876   return (res')
 2877 
 2878 
 2879 
 2880 -- |Set the pricer of every 'QuantLib.Instrument.InflationCapFloor.YoYInflationCapFloor'-ready
 2881 -- 'YoYInflationCoupon'\/'CappedFlooredYoYInflationCoupon' in /leg/. Required before pricing (via
 2882 -- 'QuantLib.CashFlow.npvWithZSpread or an 'QuantLib.Instrument.setPricingEngine'd instrument built on the
 2883 -- leg) any 'yoyInflationLeg' built with non-empty caps\/floors -- 'yoyInflationLeg' auto-attaches
 2884 -- a default (non-vol) pricer only when caps and floors are both empty.
 2885 setYoyInflationCouponPricer :: (GenLeg l) -> (YoYInflationCouponPricer) -> IO ()
 2886 setYoyInflationCouponPricer a1 a2 =
 2887   withLeg a1 $ \a1' -> 
 2888   withYoYInflationCouponPricer a2 $ \a2' -> 
 2889   preErrorCheck $ \a3' -> 
 2890   setYoyInflationCouponPricer'_ a1' a2' a3' >>
 2891   errorCheck  a3'>>
 2892   return ()
 2893 
 2894 
 2895 
 2896 -- |Set the pricer of every floating-rate coupon in /leg/.
 2897 setCouponPricer :: (GenLeg l) -> (GenFloatingRateCouponPricer frcp) -> IO ()
 2898 setCouponPricer a1 a2 =
 2899   withLeg a1 $ \a1' -> 
 2900   withFloatingRateCouponPricer a2 $ \a2' -> 
 2901   preErrorCheck $ \a3' -> 
 2902   setCouponPricer'_ a1' a2' a3' >>
 2903   errorCheck  a3'>>
 2904   return ()
 2905 
 2906 
 2907 
 2908 -- |Set the pricer of every floating-rate coupon in /leg/, picking each coupon's pricer from
 2909 -- /pricers/ by matching coupon type.
 2910 setCouponPricers :: (GenLeg l) -> ([GenFloatingRateCouponPricer frcp]) -> IO ()
 2911 setCouponPricers a1 a2 =
 2912   withLeg a1 $ \a1' -> 
 2913   withFloatingRateCouponPricerArray a2 $ \(a2'1, a2'2) -> 
 2914   preErrorCheck $ \a3' -> 
 2915   setCouponPricers'_ a1' a2'1  a2'2 a3' >>
 2916   errorCheck  a3'>>
 2917   return ()
 2918 
 2919 
 2920 
 2921 -- |Rate for a fully-determined coupon period, with no cap\/floor.
 2922 swapletRate :: (GenFloatingRateCouponPricer frcp) -> IO ((Double))
 2923 swapletRate a1 =
 2924   withFloatingRateCouponPricer a1 $ \a1' -> 
 2925   preErrorCheck $ \a2' -> 
 2926   swapletRate'_ a1' a2' >>= \res ->
 2927   let {res' = realToFrac res} in
 2928   errorCheck  a2'>>
 2929   return (res')
 2930 
 2931 
 2932 
 2933 -- |Price (NPV contribution) for a fully-determined coupon period, with no cap\/floor.  Not
 2934 -- every pricer supports this: e.g. 'CompoundingOvernightIndexedCouponPricer' throws.
 2935 swapletPrice :: (GenFloatingRateCouponPricer frcp) -> IO ((Double))
 2936 swapletPrice a1 =
 2937   withFloatingRateCouponPricer a1 $ \a1' -> 
 2938   preErrorCheck $ \a2' -> 
 2939   swapletPrice'_ a1' a2' >>= \res ->
 2940   let {res' = realToFrac res} in
 2941   errorCheck  a2'>>
 2942   return (res')
 2943 
 2944 
 2945 
 2946 -- |Price of the caplet with the given effective cap rate.  Not every pricer supports this.
 2947 capletPrice :: (GenFloatingRateCouponPricer frcp) -> (Double) -- ^effectiveCap
 2948  -> IO ((Double))
 2949 capletPrice a1 a2 =
 2950   withFloatingRateCouponPricer a1 $ \a1' -> 
 2951   let {a2' = realToFrac a2} in 
 2952   preErrorCheck $ \a3' -> 
 2953   capletPrice'_ a1' a2' a3' >>= \res ->
 2954   let {res' = realToFrac res} in
 2955   errorCheck  a3'>>
 2956   return (res')
 2957 
 2958 
 2959 
 2960 -- |Rate of the caplet with the given effective cap rate.  Not every pricer supports this.
 2961 capletRate :: (GenFloatingRateCouponPricer frcp) -> (Double) -- ^effectiveCap
 2962  -> IO ((Double))
 2963 capletRate a1 a2 =
 2964   withFloatingRateCouponPricer a1 $ \a1' -> 
 2965   let {a2' = realToFrac a2} in 
 2966   preErrorCheck $ \a3' -> 
 2967   capletRate'_ a1' a2' a3' >>= \res ->
 2968   let {res' = realToFrac res} in
 2969   errorCheck  a3'>>
 2970   return (res')
 2971 
 2972 
 2973 
 2974 -- |Price of the floorlet with the given effective floor rate.  Not every pricer supports this.
 2975 floorletPrice :: (GenFloatingRateCouponPricer frcp) -> (Double) -- ^effectiveFloor
 2976  -> IO ((Double))
 2977 floorletPrice a1 a2 =
 2978   withFloatingRateCouponPricer a1 $ \a1' -> 
 2979   let {a2' = realToFrac a2} in 
 2980   preErrorCheck $ \a3' -> 
 2981   floorletPrice'_ a1' a2' a3' >>= \res ->
 2982   let {res' = realToFrac res} in
 2983   errorCheck  a3'>>
 2984   return (res')
 2985 
 2986 
 2987 
 2988 -- |Rate of the floorlet with the given effective floor rate.  Not every pricer supports this.
 2989 floorletRate :: (GenFloatingRateCouponPricer frcp) -> (Double) -- ^effectiveFloor
 2990  -> IO ((Double))
 2991 floorletRate a1 a2 =
 2992   withFloatingRateCouponPricer a1 $ \a1' -> 
 2993   let {a2' = realToFrac a2} in 
 2994   preErrorCheck $ \a3' -> 
 2995   floorletRate'_ a1' a2' a3' >>= \res ->
 2996   let {res' = realToFrac res} in
 2997   errorCheck  a3'>>
 2998   return (res')
 2999 
 3000 
 3001 
 3002 -- |Constant-maturity-swap (CMS) coupon.
 3003 --
 3004 -- The start and end dates are used as supplied: QuantLib performs no business-day adjustment
 3005 -- when constructing this coupon, so callers must supply already adjusted dates.  Attach a CMS
 3006 -- pricer before asking for its rate or amount.
 3007 cmsCoupon :: (Day) -- ^paymentDate
 3008  -> (Double) -- ^nominal
 3009  -> (Day) -- ^accrualStartDate
 3010  -> (Day) -- ^accrualEndDate
 3011  -> (Word) -- ^fixingDays
 3012  -> (GenSwapIndex sidx) -- ^index
 3013  -> (Double) -- ^gearing
 3014  -> (Double) -- ^spread
 3015  -> (Maybe Day) -- ^referencePeriodStart
 3016  -> (Maybe Day) -- ^referencePeriodEnd
 3017  -> (DayCounter) -- ^dayCounter
 3018  -> (Bool) -- ^inArrears
 3019  -> (Maybe Day) -- ^exCouponDate
 3020  -> (BusinessDayConvention) -- ^fixingConvention
 3021  -> IO ((CmsCoupon))
 3022 cmsCoupon a1 a2 a3 a4 a5 a6 a7 a8 a9 a10 a11 a12 a13 a14 =
 3023   withDay a1 $ \a1' -> 
 3024   let {a2' = realToFrac a2} in 
 3025   withDay a3 $ \a3' -> 
 3026   withDay a4 $ \a4' -> 
 3027   let {a5' = fromIntegral a5} in 
 3028   withSwapIndex a6 $ \a6' -> 
 3029   let {a7' = realToFrac a7} in 
 3030   let {a8' = realToFrac a8} in 
 3031   withMaybeDay a9 $ \a9' -> 
 3032   withMaybeDay a10 $ \a10' -> 
 3033   withDayCounter a11 $ \a11' -> 
 3034   let {a12' = C2HSImp.fromBool a12} in 
 3035   withMaybeDay a13 $ \a13' -> 
 3036   let {a14' = fromEnumC a14} in 
 3037   preErrorCheck $ \a15' -> 
 3038   cmsCoupon'_ a1' a2' a3' a4' a5' a6' a7' a8' a9' a10' a11' a12' a13' a14' a15' >>= \res ->
 3039   peekCmsCoupon res >>= \res' ->
 3040   errorCheck  a15'>>
 3041   return (res')
 3042 
 3043 
 3044 
 3045 -- |Constant-maturity-swap-spread coupon.  Its index is the geared difference of two swap rates.
 3046 -- QuantLib does no date adjustment at construction, so callers must provide business dates.
 3047 cmsSpreadCoupon :: (Day) -- ^paymentDate
 3048  -> (Double) -- ^nominal
 3049  -> (Day) -- ^accrualStartDate
 3050  -> (Day) -- ^accrualEndDate
 3051  -> (Word) -- ^fixingDays
 3052  -> (SwapSpreadIndex) -- ^index
 3053  -> (Double) -- ^gearing
 3054  -> (Double) -- ^spread
 3055  -> (Maybe Day) -- ^referencePeriodStart
 3056  -> (Maybe Day) -- ^referencePeriodEnd
 3057  -> (DayCounter) -- ^dayCounter
 3058  -> (Bool) -- ^inArrears
 3059  -> (Maybe Day) -- ^exCouponDate
 3060  -> (BusinessDayConvention) -- ^fixingConvention
 3061  -> IO ((FloatingRateCoupon))
 3062 cmsSpreadCoupon a1 a2 a3 a4 a5 a6 a7 a8 a9 a10 a11 a12 a13 a14 =
 3063   withDay a1 $ \a1' -> 
 3064   let {a2' = realToFrac a2} in 
 3065   withDay a3 $ \a3' -> 
 3066   withDay a4 $ \a4' -> 
 3067   let {a5' = fromIntegral a5} in 
 3068   withSwapSpreadIndex a6 $ \a6' -> 
 3069   let {a7' = realToFrac a7} in 
 3070   let {a8' = realToFrac a8} in 
 3071   withMaybeDay a9 $ \a9' -> 
 3072   withMaybeDay a10 $ \a10' -> 
 3073   withDayCounter a11 $ \a11' -> 
 3074   let {a12' = C2HSImp.fromBool a12} in 
 3075   withMaybeDay a13 $ \a13' -> 
 3076   let {a14' = fromEnumC a14} in 
 3077   preErrorCheck $ \a15' -> 
 3078   cmsSpreadCoupon'_ a1' a2' a3' a4' a5' a6' a7' a8' a9' a10' a11' a12' a13' a14' a15' >>= \res ->
 3079   peekFloatingRateCoupon res >>= \res' ->
 3080   errorCheck  a15'>>
 3081   return (res')
 3082 
 3083 
 3084 
 3085 -- |The coupon rate, at the 'Coupon' level every accruing cash flow shares.  How it is obtained
 3086 -- is the subtype's business: a 'FixedRateCoupon' returns its own rate, a 'CPICoupon' its fixed
 3087 -- rate times the index ratio, and a 'FloatingRateCoupon' requires an attached
 3088 -- 'FloatingRateCouponPricer' and throws without one (see 'setFloatingRateCouponPricer').
 3089 rate :: (GenCoupon c) -- ^coupon
 3090  -> IO ((Double))
 3091 rate a1 =
 3092   withCoupon a1 $ \a1' -> 
 3093   preErrorCheck $ \a2' -> 
 3094   rate'_ a1' a2' >>= \res ->
 3095   let {res' = realToFrac res} in
 3096   errorCheck  a2'>>
 3097   return (res')
 3098 
 3099 
 3100 
 3101 -- |Interest accrued on a single coupon up to the given date -- nominal times 'rate' times the
 3102 -- accrued fraction of the accrual period.  Named apart from the leg-level 'accruedAmount', which
 3103 -- sums a whole 'Leg' and takes settlement-date arguments this does not.
 3104 couponAccruedAmount :: (GenCoupon c) -- ^coupon
 3105  -> (Day) -- ^date
 3106  -> IO ((Double))
 3107 couponAccruedAmount a1 a2 =
 3108   withCoupon a1 $ \a1' -> 
 3109   withDay a2 $ \a2' -> 
 3110   preErrorCheck $ \a3' -> 
 3111   couponAccruedAmount'_ a1' a2' a3' >>= \res ->
 3112   let {res' = realToFrac res} in
 3113   errorCheck  a3'>>
 3114   return (res')
 3115 
 3116 
 3117 
 3118 -- |Set the coupon pricer used to calculate a floating-rate coupon's rate.
 3119 setFloatingRateCouponPricer :: (GenFloatingRateCoupon frc) -- ^coupon
 3120  -> (GenFloatingRateCouponPricer frcp) -- ^pricer
 3121  -> IO ()
 3122 setFloatingRateCouponPricer a1 a2 =
 3123   withFloatingRateCoupon a1 $ \a1' -> 
 3124   withFloatingRateCouponPricer a2 $ \a2' -> 
 3125   preErrorCheck $ \a3' -> 
 3126   setFloatingRateCouponPricer'_ a1' a2' a3' >>
 3127   errorCheck  a3'>>
 3128   return ()
 3129 
 3130 
 3131 
 3132 -- |Net present value of the coupon, i.e. the coupon amount discounted off the given curve.
 3133 -- 'Nothing' uses the coupon's own default discounting (an empty @Handle\<YieldTermStructure\>@).
 3134 price :: (GenFloatingRateCoupon frc) -- ^coupon
 3135  -> (Maybe (GenYieldTermStructure y)) -- ^discountingCurve
 3136  -> IO ((Double))
 3137 price a1 a2 =
 3138   withFloatingRateCoupon a1 $ \a1' -> 
 3139   withMaybeYieldTermStructure a2 $ \a2' -> 
 3140   preErrorCheck $ \a3' -> 
 3141   price'_ a1' a2' a3' >>= \res ->
 3142   let {res' = realToFrac res} in
 3143   errorCheck  a3'>>
 3144   return (res')
 3145 
 3146 
 3147 
 3148 -- |The adjustment (e.g. for coupons that fix in arrears) applied to the plain index fixing to
 3149 -- get the effective, convexity-adjusted fixing used in 'rate'.
 3150 convexityAdjustment :: (GenFloatingRateCoupon frc) -- ^coupon
 3151  -> IO ((Double))
 3152 convexityAdjustment a1 =
 3153   withFloatingRateCoupon a1 $ \a1' -> 
 3154   preErrorCheck $ \a2' -> 
 3155   convexityAdjustment'_ a1' a2' >>= \res ->
 3156   let {res' = realToFrac res} in
 3157   errorCheck  a2'>>
 3158   return (res')
 3159 
 3160 
 3161 
 3162 -- |CMS coupon with optional cap and floor.  This is QuantLib's
 3163 -- @CappedFlooredCmsCoupon@: it wraps a 'CmsCoupon' in a capped/floored coupon and returns it at
 3164 -- the useful 'FloatingRateCoupon' level.  'Nothing' means no cap or floor.
 3165 cappedFlooredCmsCoupon :: (Day) -- ^paymentDate
 3166  -> (Double) -- ^nominal
 3167  -> (Day) -- ^accrualStartDate
 3168  -> (Day) -- ^accrualEndDate
 3169  -> (Word) -- ^fixingDays
 3170  -> (GenSwapIndex sidx) -- ^index
 3171  -> (Double) -- ^gearing
 3172  -> (Double) -- ^spread
 3173  -> (Maybe Double) -- ^cap
 3174  -> (Maybe Double) -- ^floor
 3175  -> (Maybe Day) -- ^referencePeriodStart
 3176  -> (Maybe Day) -- ^referencePeriodEnd
 3177  -> (DayCounter) -- ^dayCounter
 3178  -> (Bool) -- ^inArrears
 3179  -> (Maybe Day) -- ^exCouponDate
 3180  -> (BusinessDayConvention) -- ^fixingConvention
 3181  -> IO ((FloatingRateCoupon))
 3182 cappedFlooredCmsCoupon a1 a2 a3 a4 a5 a6 a7 a8 a9 a10 a11 a12 a13 a14 a15 a16 =
 3183   withDay a1 $ \a1' -> 
 3184   let {a2' = realToFrac a2} in 
 3185   withDay a3 $ \a3' -> 
 3186   withDay a4 $ \a4' -> 
 3187   let {a5' = fromIntegral a5} in 
 3188   withSwapIndex a6 $ \a6' -> 
 3189   let {a7' = realToFrac a7} in 
 3190   let {a8' = realToFrac a8} in 
 3191   let {a9' = fromMaybeDouble a9} in 
 3192   let {a10' = fromMaybeDouble a10} in 
 3193   withMaybeDay a11 $ \a11' -> 
 3194   withMaybeDay a12 $ \a12' -> 
 3195   withDayCounter a13 $ \a13' -> 
 3196   let {a14' = C2HSImp.fromBool a14} in 
 3197   withMaybeDay a15 $ \a15' -> 
 3198   let {a16' = fromEnumC a16} in 
 3199   preErrorCheck $ \a17' -> 
 3200   cappedFlooredCmsCoupon'_ a1' a2' a3' a4' a5' a6' a7' a8' a9' a10' a11' a12' a13' a14' a15' a16' a17' >>= \res ->
 3201   peekFloatingRateCoupon res >>= \res' ->
 3202   errorCheck  a17'>>
 3203   return (res')
 3204 
 3205 
 3206 
 3207 -- |Capped/floored CMS-spread coupon, returned at the useful 'FloatingRateCoupon' level.
 3208 -- 'Nothing' represents QuantLib's absent cap or floor.
 3209 cappedFlooredCmsSpreadCoupon :: (Day) -- ^paymentDate
 3210  -> (Double) -- ^nominal
 3211  -> (Day) -- ^accrualStartDate
 3212  -> (Day) -- ^accrualEndDate
 3213  -> (Word) -- ^fixingDays
 3214  -> (SwapSpreadIndex) -- ^index
 3215  -> (Double) -- ^gearing
 3216  -> (Double) -- ^spread
 3217  -> (Maybe Double) -- ^cap
 3218  -> (Maybe Double) -- ^floor
 3219  -> (Maybe Day) -- ^referencePeriodStart
 3220  -> (Maybe Day) -- ^referencePeriodEnd
 3221  -> (DayCounter) -- ^dayCounter
 3222  -> (Bool) -- ^inArrears
 3223  -> (Maybe Day) -- ^exCouponDate
 3224  -> (BusinessDayConvention) -- ^fixingConvention
 3225  -> IO ((FloatingRateCoupon))
 3226 cappedFlooredCmsSpreadCoupon a1 a2 a3 a4 a5 a6 a7 a8 a9 a10 a11 a12 a13 a14 a15 a16 =
 3227   withDay a1 $ \a1' -> 
 3228   let {a2' = realToFrac a2} in 
 3229   withDay a3 $ \a3' -> 
 3230   withDay a4 $ \a4' -> 
 3231   let {a5' = fromIntegral a5} in 
 3232   withSwapSpreadIndex a6 $ \a6' -> 
 3233   let {a7' = realToFrac a7} in 
 3234   let {a8' = realToFrac a8} in 
 3235   let {a9' = fromMaybeDouble a9} in 
 3236   let {a10' = fromMaybeDouble a10} in 
 3237   withMaybeDay a11 $ \a11' -> 
 3238   withMaybeDay a12 $ \a12' -> 
 3239   withDayCounter a13 $ \a13' -> 
 3240   let {a14' = C2HSImp.fromBool a14} in 
 3241   withMaybeDay a15 $ \a15' -> 
 3242   let {a16' = fromEnumC a16} in 
 3243   preErrorCheck $ \a17' -> 
 3244   cappedFlooredCmsSpreadCoupon'_ a1' a2' a3' a4' a5' a6' a7' a8' a9' a10' a11' a12' a13' a14' a15' a16' a17' >>= \res ->
 3245   peekFloatingRateCoupon res >>= \res' ->
 3246   errorCheck  a17'>>
 3247   return (res')
 3248 
 3249 
 3250 
 3251 -- |CMS-spread leg builder.  Unlike 'CmsLeg', upstream's @CmsSpreadLeg@ has no
 3252 -- ex-coupon-period\/fixing-convention builder methods, so this binds its full builder surface
 3253 -- directly with no accompanying options record.
 3254 cmsSpreadLeg :: (Schedule) -> (SwapSpreadIndex) -- ^swapSpreadIndex
 3255  -> (NonEmpty Double) -- ^notionals
 3256  -> (DayCounter) -> (BusinessDayConvention) -- ^paymentAdjustment
 3257  -> ([Word]) -- ^fixingDays
 3258  -> ([Double]) -- ^gearings
 3259  -> ([Double]) -- ^spreads
 3260  -> ([Double]) -- ^caps
 3261  -> ([Double]) -- ^floors
 3262  -> (Bool) -- ^inArrears
 3263  -> (Bool) -- ^zeroPayments
 3264  -> IO ((Leg))
 3265 cmsSpreadLeg a1 a2 a3 a4 a5 a6 a7 a8 a9 a10 a11 a12 =
 3266   withSchedule a1 $ \a1' -> 
 3267   withSwapSpreadIndex a2 $ \a2' -> 
 3268   withNonEmptyDoubleArray a3 $ \(a3'1, a3'2) -> 
 3269   withDayCounter a4 $ \a4' -> 
 3270   let {a5' = fromEnumC a5} in 
 3271   withIntArray a6 $ \(a6'1, a6'2) -> 
 3272   withDoubleArray a7 $ \(a7'1, a7'2) -> 
 3273   withDoubleArray a8 $ \(a8'1, a8'2) -> 
 3274   withDoubleArray a9 $ \(a9'1, a9'2) -> 
 3275   withDoubleArray a10 $ \(a10'1, a10'2) -> 
 3276   let {a11' = C2HSImp.fromBool a11} in 
 3277   let {a12' = C2HSImp.fromBool a12} in 
 3278   preErrorCheck $ \a13' -> 
 3279   cmsSpreadLeg'_ a1' a2' a3'1  a3'2 a4' a5' a6'1  a6'2 a7'1  a7'2 a8'1  a8'2 a9'1  a9'2 a10'1  a10'2 a11' a12' a13' >>= \res ->
 3280   peekLeg res >>= \res' ->
 3281   errorCheck  a13'>>
 3282   return (res')
 3283 
 3284 
 3285 
 3286 -- |Digital-option replication strategy.  It specifies the sub, central, or super replication
 3287 -- used to price the embedded digital option in a digital coupon; /gap/ is the call/put-spread
 3288 -- width used by that replication.
 3289 digitalReplication :: (ReplicationType) -- ^replicationType
 3290  -> (Double) -- ^gap
 3291  -> IO ((DigitalReplication))
 3292 digitalReplication a1 a2 =
 3293   let {a1' = (fromIntegral . fromEnum) a1} in 
 3294   let {a2' = realToFrac a2} in 
 3295   preErrorCheck $ \a3' -> 
 3296   digitalReplication'_ a1' a2' a3' >>= \res ->
 3297   peekDigitalReplication res >>= \res' ->
 3298   errorCheck  a3'>>
 3299   return (res')
 3300 
 3301 
 3302 replicationType :: (DigitalReplication) -- ^replication
 3303  -> (ReplicationType)
 3304 replicationType a1 =
 3305   C2HSImp.unsafePerformIO $
 3306   withDigitalReplication a1 $ \a1' -> 
 3307   replicationType'_ a1' >>= \res ->
 3308   let {res' = (toEnum . fromIntegral) res} in
 3309   return (res')
 3310 
 3311 
 3312 gap :: (DigitalReplication) -- ^replication
 3313  -> (Double)
 3314 gap a1 =
 3315   C2HSImp.unsafePerformIO $
 3316   withDigitalReplication a1 $ \a1' -> 
 3317   gap'_ a1' >>= \res ->
 3318   let {res' = realToFrac res} in
 3319   return (res')
 3320 
 3321 
 3322 
 3323 -- |CMS-rate coupon with embedded digital call and put options.
 3324 --
 3325 -- QuantLib evaluates the digital options by call/put-spread replication.  A supplied digital
 3326 -- payoff produces a cash-or-nothing option; without one the option is asset-or-nothing.  When
 3327 -- /nakedOption/ is true, the underlying coupon rate is excluded from the payoff.  Optional
 3328 -- strikes and payoffs use 'Nothing' for QuantLib's null-rate sentinel.
 3329 digitalCmsCoupon :: (CmsCoupon) -- ^underlying
 3330  -> (Maybe Double) -- ^callStrike
 3331  -> (PositionType) -- ^callPosition
 3332  -> (Bool) -- ^callATM
 3333  -> (Maybe Double) -- ^callDigitalPayoff
 3334  -> (Maybe Double) -- ^putStrike
 3335  -> (PositionType) -- ^putPosition
 3336  -> (Bool) -- ^putATM
 3337  -> (Maybe Double) -- ^putDigitalPayoff
 3338  -> (Maybe DigitalReplication) -- ^replication
 3339  -> (Bool) -- ^nakedOption
 3340  -> IO ((DigitalCmsCoupon))
 3341 digitalCmsCoupon a1 a2 a3 a4 a5 a6 a7 a8 a9 a10 a11 =
 3342   withCmsCoupon a1 $ \a1' -> 
 3343   let {a2' = fromMaybeDouble a2} in 
 3344   let {a3' = fromEnumC a3} in 
 3345   let {a4' = C2HSImp.fromBool a4} in 
 3346   let {a5' = fromMaybeDouble a5} in 
 3347   let {a6' = fromMaybeDouble a6} in 
 3348   let {a7' = fromEnumC a7} in 
 3349   let {a8' = C2HSImp.fromBool a8} in 
 3350   let {a9' = fromMaybeDouble a9} in 
 3351   withMaybeDigitalReplication a10 $ \a10' -> 
 3352   let {a11' = C2HSImp.fromBool a11} in 
 3353   preErrorCheck $ \a12' -> 
 3354   digitalCmsCoupon'_ a1' a2' a3' a4' a5' a6' a7' a8' a9' a10' a11' a12' >>= \res ->
 3355   peekDigitalCmsCoupon res >>= \res' ->
 3356   errorCheck  a12'>>
 3357   return (res')
 3358 
 3359 
 3360 
 3361 -- |CMS-spread-rate coupon with embedded digital call and put options.  Builds its own
 3362 -- underlying 'CmsSpreadCoupon' from /paymentDate/ through /fixingConvention/ (as
 3363 -- 'cmsSpreadCoupon' does), then wraps it exactly as 'digitalCmsCoupon' wraps a 'CmsCoupon'.
 3364 -- QuantLib does no date adjustment at construction, so callers must provide business dates.
 3365 -- Optional strikes and payoffs use 'Nothing' for QuantLib's null-rate sentinel.
 3366 digitalCmsSpreadCoupon :: (Day) -- ^paymentDate
 3367  -> (Double) -- ^nominal
 3368  -> (Day) -- ^accrualStartDate
 3369  -> (Day) -- ^accrualEndDate
 3370  -> (Word) -- ^fixingDays
 3371  -> (SwapSpreadIndex) -- ^index
 3372  -> (Double) -- ^gearing
 3373  -> (Double) -- ^spread
 3374  -> (Maybe Day) -- ^referencePeriodStart
 3375  -> (Maybe Day) -- ^referencePeriodEnd
 3376  -> (DayCounter) -- ^dayCounter
 3377  -> (Bool) -- ^inArrears
 3378  -> (Maybe Day) -- ^exCouponDate
 3379  -> (BusinessDayConvention) -- ^fixingConvention
 3380  -> (Maybe Double) -- ^callStrike
 3381  -> (PositionType) -- ^callPosition
 3382  -> (Bool) -- ^callATM
 3383  -> (Maybe Double) -- ^callDigitalPayoff
 3384  -> (Maybe Double) -- ^putStrike
 3385  -> (PositionType) -- ^putPosition
 3386  -> (Bool) -- ^putATM
 3387  -> (Maybe Double) -- ^putDigitalPayoff
 3388  -> (Maybe DigitalReplication) -- ^replication
 3389  -> (Bool) -- ^nakedOption
 3390  -> IO ((DigitalCmsSpreadCoupon))
 3391 digitalCmsSpreadCoupon a1 a2 a3 a4 a5 a6 a7 a8 a9 a10 a11 a12 a13 a14 a15 a16 a17 a18 a19 a20 a21 a22 a23 a24 =
 3392   withDay a1 $ \a1' -> 
 3393   let {a2' = realToFrac a2} in 
 3394   withDay a3 $ \a3' -> 
 3395   withDay a4 $ \a4' -> 
 3396   let {a5' = fromIntegral a5} in 
 3397   withSwapSpreadIndex a6 $ \a6' -> 
 3398   let {a7' = realToFrac a7} in 
 3399   let {a8' = realToFrac a8} in 
 3400   withMaybeDay a9 $ \a9' -> 
 3401   withMaybeDay a10 $ \a10' -> 
 3402   withDayCounter a11 $ \a11' -> 
 3403   let {a12' = C2HSImp.fromBool a12} in 
 3404   withMaybeDay a13 $ \a13' -> 
 3405   let {a14' = fromEnumC a14} in 
 3406   let {a15' = fromMaybeDouble a15} in 
 3407   let {a16' = fromEnumC a16} in 
 3408   let {a17' = C2HSImp.fromBool a17} in 
 3409   let {a18' = fromMaybeDouble a18} in 
 3410   let {a19' = fromMaybeDouble a19} in 
 3411   let {a20' = fromEnumC a20} in 
 3412   let {a21' = C2HSImp.fromBool a21} in 
 3413   let {a22' = fromMaybeDouble a22} in 
 3414   withMaybeDigitalReplication a23 $ \a23' -> 
 3415   let {a24' = C2HSImp.fromBool a24} in 
 3416   preErrorCheck $ \a25' -> 
 3417   digitalCmsSpreadCoupon'_ a1' a2' a3' a4' a5' a6' a7' a8' a9' a10' a11' a12' a13' a14' a15' a16' a17' a18' a19' a20' a21' a22' a23' a24' a25' >>= \res ->
 3418   peekDigitalCmsSpreadCoupon res >>= \res' ->
 3419   errorCheck  a25'>>
 3420   return (res')
 3421 
 3422 
 3423 
 3424 -- |Build a sequence of digital CMS-rate coupons.  The options record covers all digital call/put
 3425 -- and replication choices.
 3426 digitalCmsLeg :: Schedule -> GenSwapIndex sidx -> NonEmpty Double -> DayCounter -> BusinessDayConvention -> [Word] -> [Double] -> [Double] -> Bool -> DigitalCmsLegOpts -> IO Leg
 3427 digitalCmsLeg schedule index notionals dc adjustment fixingDays gearings spreads inArrears opts =
 3428   digitalCmsLeg_ schedule index notionals dc adjustment fixingDays gearings spreads inArrears
 3429     (dcmlCallStrikes opts) (dcmlCallPosition opts) (dcmlCallAtm opts) (dcmlCallPayoffs opts)
 3430     (dcmlPutStrikes opts) (dcmlPutPosition opts) (dcmlPutAtm opts) (dcmlPutPayoffs opts)
 3431     (dcmlReplication opts) (dcmlNakedOption opts)
 3432 
 3433 digitalIborLeg :: Schedule -> GenIborIndex ibor -> NonEmpty Double -> DayCounter -> BusinessDayConvention -> [Word] -> [Double] -> [Double] -> Bool -> DigitalIborLegOpts -> IO Leg
 3434 digitalIborLeg schedule index notionals dc adjustment fixingDays gearings spreads inArrears opts =
 3435   digitalIborLeg_ schedule index notionals dc adjustment fixingDays gearings spreads inArrears (dilCallStrikes opts) (dilCallPosition opts) (dilCallAtm opts) (dilCallPayoffs opts) (dilPutStrikes opts) (dilPutPosition opts) (dilPutAtm opts) (dilPutPayoffs opts) (dilReplication opts) (dilNakedOption opts)
 3436 
 3437 -- |Build a sequence of digital CMS-spread-rate coupons.  The options record covers all digital
 3438 -- call/put and replication choices, exactly as 'digitalCmsLeg' does for the plain CMS index case.
 3439 digitalCmsSpreadLeg :: Schedule -> SwapSpreadIndex -> NonEmpty Double -> DayCounter -> BusinessDayConvention -> [Word] -> [Double] -> [Double] -> Bool -> DigitalCmsSpreadLegOpts -> IO Leg
 3440 digitalCmsSpreadLeg schedule index notionals dc adjustment fixingDays gearings spreads inArrears opts =
 3441   digitalCmsSpreadLeg_ schedule index notionals dc adjustment fixingDays gearings spreads inArrears
 3442     (dcmslCallStrikes opts) (dcmslCallPosition opts) (dcmslCallAtm opts) (dcmslCallPayoffs opts)
 3443     (dcmslPutStrikes opts) (dcmslPutPosition opts) (dcmslPutAtm opts) (dcmslPutPayoffs opts)
 3444     (dcmslReplication opts) (dcmslNakedOption opts)
 3445 
 3446 multipleResetsLeg :: Schedule -> GenIborIndex ibor -> Word -> DayCounter -> BusinessDayConvention -> MultipleResetsLegOpts -> IO Leg
 3447 multipleResetsLeg schedule index resets dc adjustment opts = do
 3448   nullCalendar <- calendar Null
 3449   multipleResetsLeg_ schedule index resets (mrlNotionals opts) dc adjustment (fromMaybe nullCalendar (mrlPaymentCalendar opts)) (mrlPaymentLag opts) (mrlFixingDays opts) (mrlGearings opts) (mrlCouponSpreads opts) (mrlRateSpreads opts) (mrlExCouponPeriod opts) (fromMaybe nullCalendar (mrlExCouponCalendar opts)) (mrlExCouponConvention opts) (mrlExCouponEndOfMonth opts) (mrlAveragingMethod opts)
 3450 
 3451 digitalCmsLeg_ :: (Schedule) -> (GenSwapIndex sidx) -> (NonEmpty Double) -> (DayCounter) -> (BusinessDayConvention) -> ([Word]) -> ([Double]) -> ([Double]) -> (Bool) -> ([Double]) -> (PositionType) -> (Bool) -> ([Double]) -> ([Double]) -> (PositionType) -> (Bool) -> ([Double]) -> (Maybe DigitalReplication) -> (Bool) -> IO ((Leg))
 3452 digitalCmsLeg_ a1 a2 a3 a4 a5 a6 a7 a8 a9 a10 a11 a12 a13 a14 a15 a16 a17 a18 a19 =
 3453   withSchedule a1 $ \a1' -> 
 3454   withSwapIndex a2 $ \a2' -> 
 3455   withNonEmptyDoubleArray a3 $ \(a3'1, a3'2) -> 
 3456   withDayCounter a4 $ \a4' -> 
 3457   let {a5' = fromEnumC a5} in 
 3458   withIntArray a6 $ \(a6'1, a6'2) -> 
 3459   withDoubleArray a7 $ \(a7'1, a7'2) -> 
 3460   withDoubleArray a8 $ \(a8'1, a8'2) -> 
 3461   let {a9' = C2HSImp.fromBool a9} in 
 3462   withDoubleArray a10 $ \(a10'1, a10'2) -> 
 3463   let {a11' = fromEnumC a11} in 
 3464   let {a12' = C2HSImp.fromBool a12} in 
 3465   withDoubleArray a13 $ \(a13'1, a13'2) -> 
 3466   withDoubleArray a14 $ \(a14'1, a14'2) -> 
 3467   let {a15' = fromEnumC a15} in 
 3468   let {a16' = C2HSImp.fromBool a16} in 
 3469   withDoubleArray a17 $ \(a17'1, a17'2) -> 
 3470   withMaybeDigitalReplication a18 $ \a18' -> 
 3471   let {a19' = C2HSImp.fromBool a19} in 
 3472   preErrorCheck $ \a20' -> 
 3473   digitalCmsLeg_'_ a1' a2' a3'1  a3'2 a4' a5' a6'1  a6'2 a7'1  a7'2 a8'1  a8'2 a9' a10'1  a10'2 a11' a12' a13'1  a13'2 a14'1  a14'2 a15' a16' a17'1  a17'2 a18' a19' a20' >>= \res ->
 3474   peekLeg res >>= \res' ->
 3475   errorCheck  a20'>>
 3476   return (res')
 3477 
 3478 
 3479 digitalIborLeg_ :: (Schedule) -> (GenIborIndex ibor) -> (NonEmpty Double) -> (DayCounter) -> (BusinessDayConvention) -> ([Word]) -> ([Double]) -> ([Double]) -> (Bool) -> ([Double]) -> (PositionType) -> (Bool) -> ([Double]) -> ([Double]) -> (PositionType) -> (Bool) -> ([Double]) -> (Maybe DigitalReplication) -> (Bool) -> IO ((Leg))
 3480 digitalIborLeg_ a1 a2 a3 a4 a5 a6 a7 a8 a9 a10 a11 a12 a13 a14 a15 a16 a17 a18 a19 =
 3481   withSchedule a1 $ \a1' -> 
 3482   withIborIndex a2 $ \a2' -> 
 3483   withNonEmptyDoubleArray a3 $ \(a3'1, a3'2) -> 
 3484   withDayCounter a4 $ \a4' -> 
 3485   let {a5' = fromEnumC a5} in 
 3486   withIntArray a6 $ \(a6'1, a6'2) -> 
 3487   withDoubleArray a7 $ \(a7'1, a7'2) -> 
 3488   withDoubleArray a8 $ \(a8'1, a8'2) -> 
 3489   let {a9' = C2HSImp.fromBool a9} in 
 3490   withDoubleArray a10 $ \(a10'1, a10'2) -> 
 3491   let {a11' = fromEnumC a11} in 
 3492   let {a12' = C2HSImp.fromBool a12} in 
 3493   withDoubleArray a13 $ \(a13'1, a13'2) -> 
 3494   withDoubleArray a14 $ \(a14'1, a14'2) -> 
 3495   let {a15' = fromEnumC a15} in 
 3496   let {a16' = C2HSImp.fromBool a16} in 
 3497   withDoubleArray a17 $ \(a17'1, a17'2) -> 
 3498   withMaybeDigitalReplication a18 $ \a18' -> 
 3499   let {a19' = C2HSImp.fromBool a19} in 
 3500   preErrorCheck $ \a20' -> 
 3501   digitalIborLeg_'_ a1' a2' a3'1  a3'2 a4' a5' a6'1  a6'2 a7'1  a7'2 a8'1  a8'2 a9' a10'1  a10'2 a11' a12' a13'1  a13'2 a14'1  a14'2 a15' a16' a17'1  a17'2 a18' a19' a20' >>= \res ->
 3502   peekLeg res >>= \res' ->
 3503   errorCheck  a20'>>
 3504   return (res')
 3505 
 3506 
 3507 digitalCmsSpreadLeg_ :: (Schedule) -> (SwapSpreadIndex) -> (NonEmpty Double) -> (DayCounter) -> (BusinessDayConvention) -> ([Word]) -> ([Double]) -> ([Double]) -> (Bool) -> ([Double]) -> (PositionType) -> (Bool) -> ([Double]) -> ([Double]) -> (PositionType) -> (Bool) -> ([Double]) -> (Maybe DigitalReplication) -> (Bool) -> IO ((Leg))
 3508 digitalCmsSpreadLeg_ a1 a2 a3 a4 a5 a6 a7 a8 a9 a10 a11 a12 a13 a14 a15 a16 a17 a18 a19 =
 3509   withSchedule a1 $ \a1' -> 
 3510   withSwapSpreadIndex a2 $ \a2' -> 
 3511   withNonEmptyDoubleArray a3 $ \(a3'1, a3'2) -> 
 3512   withDayCounter a4 $ \a4' -> 
 3513   let {a5' = fromEnumC a5} in 
 3514   withIntArray a6 $ \(a6'1, a6'2) -> 
 3515   withDoubleArray a7 $ \(a7'1, a7'2) -> 
 3516   withDoubleArray a8 $ \(a8'1, a8'2) -> 
 3517   let {a9' = C2HSImp.fromBool a9} in 
 3518   withDoubleArray a10 $ \(a10'1, a10'2) -> 
 3519   let {a11' = fromEnumC a11} in 
 3520   let {a12' = C2HSImp.fromBool a12} in 
 3521   withDoubleArray a13 $ \(a13'1, a13'2) -> 
 3522   withDoubleArray a14 $ \(a14'1, a14'2) -> 
 3523   let {a15' = fromEnumC a15} in 
 3524   let {a16' = C2HSImp.fromBool a16} in 
 3525   withDoubleArray a17 $ \(a17'1, a17'2) -> 
 3526   withMaybeDigitalReplication a18 $ \a18' -> 
 3527   let {a19' = C2HSImp.fromBool a19} in 
 3528   preErrorCheck $ \a20' -> 
 3529   digitalCmsSpreadLeg_'_ a1' a2' a3'1  a3'2 a4' a5' a6'1  a6'2 a7'1  a7'2 a8'1  a8'2 a9' a10'1  a10'2 a11' a12' a13'1  a13'2 a14'1  a14'2 a15' a16' a17'1  a17'2 a18' a19' a20' >>= \res ->
 3530   peekLeg res >>= \res' ->
 3531   errorCheck  a20'>>
 3532   return (res')
 3533 
 3534 
 3535 multipleResetsLeg_ :: (Schedule) -> (GenIborIndex ibor) -> (Word) -> (NonEmpty Double) -> (DayCounter) -> (BusinessDayConvention) -> (Calendar) -> (Int) -> ([Word]) -> ([Double]) -> ([Double]) -> ([Double]) -> ((Int,TimeUnit)) -> (Calendar) -> (BusinessDayConvention) -> (Bool) -> (RateAveragingType) -> IO ((Leg))
 3536 multipleResetsLeg_ a1 a2 a3 a4 a5 a6 a7 a8 a9 a10 a11 a12 a13 a14 a15 a16 a17 =
 3537   withSchedule a1 $ \a1' -> 
 3538   withIborIndex a2 $ \a2' -> 
 3539   let {a3' = fromIntegral a3} in 
 3540   withNonEmptyDoubleArray a4 $ \(a4'1, a4'2) -> 
 3541   withDayCounter a5 $ \a5' -> 
 3542   let {a6' = fromEnumC a6} in 
 3543   withCalendar a7 $ \a7' -> 
 3544   let {a8' = fromIntegral a8} in 
 3545   withIntArray a9 $ \(a9'1, a9'2) -> 
 3546   withDoubleArray a10 $ \(a10'1, a10'2) -> 
 3547   withDoubleArray a11 $ \(a11'1, a11'2) -> 
 3548   withDoubleArray a12 $ \(a12'1, a12'2) -> 
 3549   let {(a13'1, a13'2) = fromEnumQuantity a13} in 
 3550   withCalendar a14 $ \a14' -> 
 3551   let {a15' = fromEnumC a15} in 
 3552   let {a16' = C2HSImp.fromBool a16} in 
 3553   let {a17' = fromEnumC a17} in 
 3554   preErrorCheck $ \a18' -> 
 3555   multipleResetsLeg_'_ a1' a2' a3' a4'1  a4'2 a5' a6' a7' a8' a9'1  a9'2 a10'1  a10'2 a11'1  a11'2 a12'1  a12'2 a13'1  a13'2 a14' a15' a16' a17' a18' >>= \res ->
 3556   peekLeg res >>= \res' ->
 3557   errorCheck  a18'>>
 3558   return (res')
 3559 
 3560 
 3561 
 3562 -- |CMS-coupon pricer via static replication (Hagan's "Conundrums..."), using an analytic
 3563 -- closed-form approximation of the replication integrals.
 3564 analyticHaganPricer :: (GenSwaptionVolatilityStructure sv) -> (YieldCurveModel) -> (GenQuote q) -- ^meanReversion
 3565  -> IO ((CmsCouponPricer))
 3566 analyticHaganPricer a1 a2 a3 =
 3567   withSwaptionVolatilityStructure a1 $ \a1' -> 
 3568   let {a2' = (fromIntegral . fromEnum) a2} in 
 3569   withQuote a3 $ \a3' -> 
 3570   preErrorCheck $ \a4' -> 
 3571   analyticHaganPricer'_ a1' a2' a3' a4' >>= \res ->
 3572   peekCmsCouponPricer res >>= \res' ->
 3573   errorCheck  a4'>>
 3574   return (res')
 3575 
 3576 
 3577 
 3578 -- |CMS-coupon pricer via static replication (Hagan's "Conundrums..."), evaluating the
 3579 -- replication integrals by numerical integration over vanilla swaption prices.
 3580 numericHaganPricer :: (GenSwaptionVolatilityStructure sv) -> (YieldCurveModel) -> (GenQuote q) -- ^meanReversion
 3581  -> (Double) -- ^lowerLimit
 3582  -> (Double) -- ^upperLimit
 3583  -> (Double) -- ^precision
 3584  -> (Double) -- ^hardUpperLimit
 3585  -> IO ((CmsCouponPricer))
 3586 numericHaganPricer a1 a2 a3 a4 a5 a6 a7 =
 3587   withSwaptionVolatilityStructure a1 $ \a1' -> 
 3588   let {a2' = (fromIntegral . fromEnum) a2} in 
 3589   withQuote a3 $ \a3' -> 
 3590   let {a4' = realToFrac a4} in 
 3591   let {a5' = realToFrac a5} in 
 3592   let {a6' = realToFrac a6} in 
 3593   let {a7' = realToFrac a7} in 
 3594   preErrorCheck $ \a8' -> 
 3595   numericHaganPricer'_ a1' a2' a3' a4' a5' a6' a7' a8' >>= \res ->
 3596   peekCmsCouponPricer res >>= \res' ->
 3597   errorCheck  a8'>>
 3598   return (res')
 3599 
 3600 
 3601 
 3602 -- |The strategy 'LinearTsrPricer' uses to pick the integration cut-off strike bounds; each
 3603 -- carries the strategy-specific parameter upstream's corresponding @Settings::withX@ takes
 3604 -- ('LinearTsrRateBound' has none). Pass explicit bounds via 'LinearTsrPricerSettings''
 3605 -- /ltsrBounds/ rather than baking upstream's own default bounds in here, since upstream's
 3606 -- no-explicit-bounds overloads aren't just sugar for those same numbers -- they also flip
 3607 -- @Settings::defaultBounds_@, which under a normal-vol swaption surface adjusts the lower
 3608 -- bound to @min(-upperBound, lowerBound)@ (see @ql/cashflows/lineartsrpricer.cpp@). Passing
 3609 -- 'Nothing' reaches that adjustment; passing explicit bounds via 'Just' does not.
 3610 data LinearTsrPricerStrategy
 3611   = LinearTsrRateBound
 3612   | LinearTsrVegaRatio Double        -- ^vegaRatio
 3613   | LinearTsrPriceThreshold Double   -- ^priceThreshold
 3614   | LinearTsrBSStdDevs Double        -- ^stdDevs
 3615   deriving (Show, Eq)
 3616 
 3617 -- |'ltsrBounds' of 'Nothing' uses upstream's own default lower\/upper rate bounds (and, for a
 3618 -- normal-vol surface, its default-bounds strike adjustment -- see 'LinearTsrPricerStrategy');
 3619 -- @'Just' (lower, upper)@ pins explicit bounds instead.
 3620 data LinearTsrPricerSettings = LinearTsrPricerSettings
 3621   { ltsrStrategy :: LinearTsrPricerStrategy
 3622   , ltsrBounds :: Maybe (Double, Double)
 3623   } deriving (Show, Eq)
 3624 
 3625 -- |CMS-coupon pricer using a linear terminal swap rate model (Andersen\/Piterbarg 16.3.2).
 3626 -- /couponDiscountCurve/ of 'Nothing' uses the coupon's own discount curve, matching upstream's
 3627 -- default empty 'Handle'. The upstream constructor's trailing /integrator/ parameter (an
 3628 -- advanced numerical-integration override) is not exposed; upstream's own default
 3629 -- (@ext::shared_ptr\<Integrator\>()@) is always used.
 3630 linearTsrPricer :: GenSwaptionVolatilityStructure sv -> GenQuote q -> Maybe (GenYieldTermStructure y)
 3631   -> LinearTsrPricerSettings -> IO CmsCouponPricer
 3632 linearTsrPricer swaptionVol meanReversion couponDiscountCurve (LinearTsrPricerSettings strat bounds) =
 3633   linearTsrPricer_ swaptionVol meanReversion couponDiscountCurve strategyTag param
 3634     (maybe False (const True) bounds) lowerBound upperBound
 3635   where
 3636     (strategyTag, param) = case strat of
 3637       LinearTsrRateBound        -> (fromEnum LinearTsrPricerRateBound, 0)
 3638       LinearTsrVegaRatio p      -> (fromEnum LinearTsrPricerVegaRatio, p)
 3639       LinearTsrPriceThreshold p -> (fromEnum LinearTsrPricerPriceThreshold, p)
 3640       LinearTsrBSStdDevs p      -> (fromEnum LinearTsrPricerBSStdDevs, p)
 3641     (lowerBound, upperBound) = fromMaybe (0, 0) bounds
 3642 
 3643 data LinearTsrPricerStrategyTag = LinearTsrPricerRateBound
 3644                                 | LinearTsrPricerVegaRatio
 3645                                 | LinearTsrPricerPriceThreshold
 3646                                 | LinearTsrPricerBSStdDevs
 3647   deriving (Show,Eq,Read)
 3648 instance Enum LinearTsrPricerStrategyTag where
 3649   succ LinearTsrPricerRateBound = LinearTsrPricerVegaRatio
 3650   succ LinearTsrPricerVegaRatio = LinearTsrPricerPriceThreshold
 3651   succ LinearTsrPricerPriceThreshold = LinearTsrPricerBSStdDevs
 3652   succ LinearTsrPricerBSStdDevs = error "LinearTsrPricerStrategyTag.succ: LinearTsrPricerBSStdDevs has no successor"
 3653 
 3654   pred LinearTsrPricerVegaRatio = LinearTsrPricerRateBound
 3655   pred LinearTsrPricerPriceThreshold = LinearTsrPricerVegaRatio
 3656   pred LinearTsrPricerBSStdDevs = LinearTsrPricerPriceThreshold
 3657   pred LinearTsrPricerRateBound = error "LinearTsrPricerStrategyTag.pred: LinearTsrPricerRateBound has no predecessor"
 3658 
 3659   enumFromTo from to = go from
 3660     where
 3661       end = fromEnum to
 3662       go v = case compare (fromEnum v) end of
 3663                  LT -> v : go (succ v)
 3664                  EQ -> [v]
 3665                  GT -> []
 3666 
 3667   enumFrom from = enumFromTo from LinearTsrPricerBSStdDevs
 3668 
 3669   fromEnum LinearTsrPricerRateBound = 0
 3670   fromEnum LinearTsrPricerVegaRatio = 1
 3671   fromEnum LinearTsrPricerPriceThreshold = 2
 3672   fromEnum LinearTsrPricerBSStdDevs = 3
 3673 
 3674   toEnum 0 = LinearTsrPricerRateBound
 3675   toEnum 1 = LinearTsrPricerVegaRatio
 3676   toEnum 2 = LinearTsrPricerPriceThreshold
 3677   toEnum 3 = LinearTsrPricerBSStdDevs
 3678   toEnum unmatched = error ("LinearTsrPricerStrategyTag.toEnum: Cannot match " ++ show unmatched)
 3679 
 3680 
 3681 
 3682 -- |Raw binding for 'linearTsrPricer', taking the 'LinearTsrPricerSettings' unpacked into a
 3683 -- strategy tag\/parameter and an explicit-bounds flag.
 3684 linearTsrPricer_ :: (GenSwaptionVolatilityStructure sv) -> (GenQuote q) -- ^meanReversion
 3685  -> (Maybe (GenYieldTermStructure y)) -- ^couponDiscountCurve
 3686  -> (Int) -- ^strategy tag, see 'LinearTsrPricerStrategyTag'
 3687  -> (Double) -- ^strategy-specific parameter (unused for RateBound)
 3688  -> (Bool) -- ^haveBounds
 3689  -> (Double) -- ^lowerBound (ignored unless haveBounds)
 3690  -> (Double) -- ^upperBound (ignored unless haveBounds)
 3691  -> IO ((CmsCouponPricer))
 3692 linearTsrPricer_ a1 a2 a3 a4 a5 a6 a7 a8 =
 3693   withSwaptionVolatilityStructure a1 $ \a1' -> 
 3694   withQuote a2 $ \a2' -> 
 3695   withMaybeYieldTermStructure a3 $ \a3' -> 
 3696   let {a4' = fromIntegral a4} in 
 3697   let {a5' = realToFrac a5} in 
 3698   let {a6' = C2HSImp.fromBool a6} in 
 3699   let {a7' = realToFrac a7} in 
 3700   let {a8' = realToFrac a8} in 
 3701   preErrorCheck $ \a9' -> 
 3702   linearTsrPricer_'_ a1' a2' a3' a4' a5' a6' a7' a8' a9' >>= \res ->
 3703   peekCmsCouponPricer res >>= \res' ->
 3704   errorCheck  a9'>>
 3705   return (res')
 3706 
 3707 
 3708 
 3709 -- |CMS-spread pricer using the Brigo--Mercurio bivariate model, with extensions for shifted
 3710 -- lognormal and normal dynamics.  /volatilityType/ of 'Nothing' inherits the type and shifts
 3711 -- from the component swaption volatility structures; in that case both shifts must be 'Nothing'.
 3712 lognormalCmsSpreadPricer :: CmsCouponPricer -> GenQuote q -> Maybe (GenYieldTermStructure y) -> Word
 3713   -> Maybe VolatilityType -> Maybe Double -> Maybe Double -> IO FloatingRateCouponPricer
 3714 lognormalCmsSpreadPricer cmsPricer correlation discountCurve integrationPoints volatilityType shift1 shift2 =
 3715   lognormalCmsSpreadPricer_ cmsPricer correlation discountCurve integrationPoints
 3716     (maybe False (const True) volatilityType) (maybe 0 fromEnum volatilityType) shift1 shift2
 3717 
 3718 lognormalCmsSpreadPricer_ :: (CmsCouponPricer) -> (GenQuote q) -> (Maybe (GenYieldTermStructure y)) -> (Word) -> (Bool) -> (Int) -> (Maybe Double) -> (Maybe Double) -> IO ((FloatingRateCouponPricer))
 3719 lognormalCmsSpreadPricer_ a1 a2 a3 a4 a5 a6 a7 a8 =
 3720   withCmsCouponPricer a1 $ \a1' -> 
 3721   withQuote a2 $ \a2' -> 
 3722   withMaybeYieldTermStructure a3 $ \a3' -> 
 3723   let {a4' = fromIntegral a4} in 
 3724   let {a5' = C2HSImp.fromBool a5} in 
 3725   let {a6' = fromIntegral a6} in 
 3726   let {a7' = fromMaybeDouble a7} in 
 3727   let {a8' = fromMaybeDouble a8} in 
 3728   preErrorCheck $ \a9' -> 
 3729   lognormalCmsSpreadPricer_'_ a1' a2' a3' a4' a5' a6' a7' a8' a9' >>= \res ->
 3730   peekFloatingRateCouponPricer res >>= \res' ->
 3731   errorCheck  a9'>>
 3732   return (res')
 3733 
 3734 
 3735 
 3736 -- |Coupon types that expose the dates of their component index fixings.
 3737 -- |Every fixing the cash flows of this leg need, as @(index name, fixing date)@ pairs in leg
 3738 -- order.  QuantLib has no @requiredFixings@ query, so this walks the leg itself, unwrapping
 3739 -- decorating coupons (capped\/floored, stripped, digital) and asking each coupon for its own
 3740 -- fixing dates: one for an Ibor, CMS or CMS-spread coupon, one per averaged date for an
 3741 -- overnight, BMA or multiple-resets coupon, and the fixing and base dates for an index-linked
 3742 -- payment.  An inflation flow reports the dates QuantLib\'s CPI store is read at, which are
 3743 -- period starts (@ZeroInflationIndex::pastFixing@): for a CPI coupon, CPI cash flow or
 3744 -- zero-inflation cash flow, the start of the index period holding each observed date less the
 3745 -- observation lag, and under linear interpolation the next period\'s start too, unless the
 3746 -- observed date is itself a period start (@CPI::laggedFixing@); a base only when no base CPI is
 3747 -- given.  A year-on-year coupon reports its own index\'s period starts, or, for a ratio index, its
 3748 -- underlying zero index a year apart.  A CMS-spread coupon reports its two underlying swap
 3749 -- indexes rather than the spread index, because that is where the fixings are stored.  Names
 3750 -- are 'QuantLib.Index.name', the key QuantLib\'s process-global fixing store uses.  A cash flow
 3751 -- that needs no fixing -- a redemption, a fixed-rate coupon -- contributes nothing.  Duplicates
 3752 -- are not removed: two coupons may fix the same index on the same date.
 3753 fixingDependencies :: GenLeg l -> IO [(String, Day)]
 3754 fixingDependencies l = uncurry zip <$> qlLegFixingDependencies l
 3755 qlLegFixingDependencies :: (GenLeg l) -> IO (([String]), ([Day]))
 3756 qlLegFixingDependencies a1 =
 3757   withLeg a1 $ \a1' -> 
 3758   preCStringArray $ \(a2'1, a2'2) -> 
 3759   preIntArray $ \(a3'1, a3'2) -> 
 3760   preErrorCheck $ \a4' -> 
 3761   qlLegFixingDependencies'_ a1' a2'1  a2'2 a3'1  a3'2 a4' >>
 3762   peekCStringArray  a2'1  a2'2>>= \a2'' -> 
 3763   peekDayArray  a3'1  a3'2>>= \a3'' -> 
 3764   errorCheck  a4'>>
 3765   return (a2'', a3'')
 3766 
 3767 
 3768 
 3769 class HasFixingDates coupon where
 3770   fixingDates :: coupon -> IO [Day]
 3771 
 3772 instance HasFixingDates AverageBMACoupon where
 3773   fixingDates = averageBmaCouponFixingDatesRaw
 3774 instance HasFixingDates MultipleResetsCoupon where
 3775   fixingDates = multipleResetsCouponFixingDatesRaw
 3776 instance HasFixingDates OvernightIndexedCoupon where
 3777   fixingDates = overnightIndexedCouponFixingDatesRaw
 3778 
 3779 -- |Coupon types that expose their component index fixings.
 3780 class HasIndexFixings coupon where
 3781   indexFixings :: coupon -> IO [Double]
 3782 
 3783 instance HasIndexFixings AverageBMACoupon where
 3784   indexFixings = averageBmaCouponIndexFixingsRaw
 3785 instance HasIndexFixings OvernightIndexedCoupon where
 3786   indexFixings = overnightIndexedCouponIndexFixingsRaw
 3787 
 3788 -- |FX observation as fixing date and associated settlement/value date.
 3789 data FxReset = FxReset { fxResetFixingDate :: Day, fxResetSettlementDate :: Day } deriving (Eq, Show, Read)
 3790 -- |FX observation convention: business-day fixing lag and optional calendar.
 3791 -- Nothing uses an empty calendar; it is valid only with zero fixing days.
 3792 data FxResetConvention = FxResetConvention Word (Maybe Calendar)
 3793 withFxReset :: FxReset -> ((CInt, CInt) -> IO r) -> IO r
 3794 withFxReset (FxReset fixing value) f = do
 3795   fixingSerial <- toSerial fixing
 3796   valueSerial <- toSerial value
 3797   f (fixingSerial, valueSerial)
 3798 withMaybeFxReset :: Maybe FxReset -> ((CInt, CInt) -> IO r) -> IO r
 3799 withMaybeFxReset reset f = maybe (f (0, 0)) (`withFxReset` f) reset
 3800 
 3801 -- |Native FX observation calculation.
 3802 fxResetObservationRaw :: (Word) -- ^fixingDays
 3803  -> (Maybe Calendar) -- ^fixingCalendar
 3804  -> (Day) -- ^valueDate
 3805  -> IO ((Day), (Day))
 3806 fxResetObservationRaw a1 a2 a3 =
 3807   let {a1' = fromIntegral a1} in 
 3808   withMaybeCalendar a2 $ \a2' -> 
 3809   withDay a3 $ \a3' -> 
 3810   alloca $ \a4' -> 
 3811   alloca $ \a5' -> 
 3812   preErrorCheck $ \a6' -> 
 3813   fxResetObservationRaw'_ a1' a2' a3' a4' a5' a6' >>
 3814   peekResetDay  a4'>>= \a4'' -> 
 3815   peekResetDay  a5'>>= \a5'' -> 
 3816   errorCheck  a6'>>
 3817   return (a4'', a5'')
 3818 
 3819 
 3820 
 3821 -- |Native FX value-date calculation.
 3822 fxResetValueDateRaw :: (Word) -- ^fixingDays
 3823  -> (Maybe Calendar) -- ^fixingCalendar
 3824  -> (Day) -- ^fixingDate
 3825  -> IO ((Day))
 3826 fxResetValueDateRaw a1 a2 a3 =
 3827   let {a1' = fromIntegral a1} in 
 3828   withMaybeCalendar a2 $ \a2' -> 
 3829   withDay a3 $ \a3' -> 
 3830   preErrorCheck $ \a4' -> 
 3831   fxResetValueDateRaw'_ a1' a2' a3' a4' >>= \res ->
 3832   let {res' = toDay res} in
 3833   errorCheck  a4'>>
 3834   return (res')
 3835 
 3836 
 3837 
 3838 -- |Derive an FX observation from its value date (1.44). Nonzero lag needs a nonempty calendar.
 3839 fxResetObservation :: FxResetConvention -- ^Business-day fixing lag and optional calendar
 3840   -> Day -- ^FX value date
 3841   -> IO FxReset
 3842 fxResetObservation (FxResetConvention days cal) observationDate = do
 3843   (fixing, valueDate) <- fxResetObservationRaw days cal observationDate
 3844   pure (FxReset fixing valueDate)
 3845 -- |Derive the spot value date of a fixing date using business days (1.44).
 3846 fxResetValueDate :: FxResetConvention -- ^Business-day fixing lag and optional calendar
 3847   -> Day -- ^FX fixing date
 3848   -> IO Day
 3849 fxResetValueDate (FxResetConvention days cal) = fxResetValueDateRaw days cal
 3850 
 3851 -- |FX reset projection from spot and two discount curves (1.44).
 3852 -- Returns resettable currency per constant currency; past observations use ExchangeRateManager.
 3853 discountingFxResetPricer :: (Currency) -- ^constantLegCurrency
 3854  -> (Currency) -- ^resettableLegCurrency
 3855  -> (GenYieldTermStructure y1) -- ^constantLegCurve
 3856  -> (GenYieldTermStructure y2) -- ^resettableLegCurve
 3857  -> (GenQuote q) -- ^spotFx
 3858  -> (Bool) -- ^spotIsResettablePerConstant
 3859  -> (Maybe Day) -- ^spotFxSettleDate
 3860  -> IO ((FxResetPricer))
 3861 discountingFxResetPricer a1 a2 a3 a4 a5 a6 a7 =
 3862   withCurrency a1 $ \a1' -> 
 3863   withCurrency a2 $ \a2' -> 
 3864   withYieldTermStructure a3 $ \a3' -> 
 3865   withYieldTermStructure a4 $ \a4' -> 
 3866   withQuote a5 $ \a5' -> 
 3867   let {a6' = C2HSImp.fromBool a6} in 
 3868   withMaybeDay a7 $ \a7' -> 
 3869   preErrorCheck $ \a8' -> 
 3870   discountingFxResetPricer'_ a1' a2' a3' a4' a5' a6' a7' a8' >>= \res ->
 3871   peekStandalone res >>= \res' ->
 3872   errorCheck  a8'>>
 3873   return (res')
 3874 
 3875 
 3876 
 3877 -- |Observed or projected resettable-currency units per constant-currency unit (1.44).
 3878 fxResetRate :: (FxResetPricer) -- ^pricer
 3879  -> (FxReset) -- ^reset
 3880  -> IO ((Double))
 3881 fxResetRate a1 a2 =
 3882   withStandalone a1 $ \a1' -> 
 3883   withFxReset a2 $ \(a2'1, a2'2) -> 
 3884   preErrorCheck $ \a3' -> 
 3885   fxResetRate'_ a1' a2'1  a2'2 a3' >>= \res ->
 3886   let {res' = realToFrac res} in
 3887   errorCheck  a3'>>
 3888   return (res')
 3889 
 3890 
 3891 
 3892 -- |Coupon with FX-reset notional (1.44). Attach an FX reset pricer before querying amount or nominal.
 3893 -- Rate and accrued amount preserve the underlying coupon calculation, including overnight compounding.
 3894 fxResetCoupon :: (GenFloatingRateCoupon frc) -- ^underlying
 3895  -> (Double) -- ^constantLegNotional
 3896  -> (FxReset) -- ^reset
 3897  -> IO ((FxResetCoupon))
 3898 fxResetCoupon a1 a2 a3 =
 3899   withFloatingRateCoupon a1 $ \a1' -> 
 3900   let {a2' = realToFrac a2} in 
 3901   withFxReset a3 $ \(a3'1, a3'2) -> 
 3902   preErrorCheck $ \a4' -> 
 3903   fxResetCoupon'_ a1' a2' a3'1  a3'2 a4' >>= \res ->
 3904   peekFxResetCoupon res >>= \res' ->
 3905   errorCheck  a4'>>
 3906   return (res')
 3907 
 3908 
 3909 
 3910 -- |Netted FX-reset principal exchange (1.44). Missing previous/current resets select inception/final exchanges.
 3911 -- Attach an FX reset pricer before querying amount; native validation rejects two absent resets.
 3912 fxResetNotionalExchange :: (Day) -- ^paymentDate
 3913  -> (Double) -- ^constantLegNotional
 3914  -> (Maybe FxReset) -- ^previousReset
 3915  -> (Maybe FxReset) -- ^currentReset
 3916  -> IO ((FxResetNotionalExchange))
 3917 fxResetNotionalExchange a1 a2 a3 a4 =
 3918   withDay a1 $ \a1' -> 
 3919   let {a2' = realToFrac a2} in 
 3920   withMaybeFxReset a3 $ \(a3'1, a3'2) -> 
 3921   withMaybeFxReset a4 $ \(a4'1, a4'2) -> 
 3922   preErrorCheck $ \a5' -> 
 3923   fxResetNotionalExchange'_ a1' a2' a3'1  a3'2 a4'1  a4'2 a5' >>= \res ->
 3924   peekFxResetNotionalExchange res >>= \res' ->
 3925   errorCheck  a5'>>
 3926   return (res')
 3927 
 3928 
 3929 
 3930 -- |Attach retained FX reset pricing.
 3931 setFxResetCouponPricerRaw :: (FxResetCoupon) -- ^cashFlow
 3932  -> (FxResetPricer) -- ^pricer
 3933  -> IO ()
 3934 setFxResetCouponPricerRaw a1 a2 =
 3935   withFxResetCoupon a1 $ \a1' -> 
 3936   withStandalone a2 $ \a2' -> 
 3937   preErrorCheck $ \a3' -> 
 3938   setFxResetCouponPricerRaw'_ a1' a2' a3' >>
 3939   errorCheck  a3'>>
 3940   return ()
 3941 
 3942 
 3943 
 3944 -- |Attach retained FX reset pricing.
 3945 setFxResetNotionalExchangePricerRaw :: (FxResetNotionalExchange) -- ^cashFlow
 3946  -> (FxResetPricer) -- ^pricer
 3947  -> IO ()
 3948 setFxResetNotionalExchangePricerRaw a1 a2 =
 3949   withFxResetNotionalExchange a1 $ \a1' -> 
 3950   withStandalone a2 $ \a2' -> 
 3951   preErrorCheck $ \a3' -> 
 3952   setFxResetNotionalExchangePricerRaw'_ a1' a2' a3' >>
 3953   errorCheck  a3'>>
 3954   return ()
 3955 
 3956 
 3957 
 3958 -- |Cash flows supporting FX reset pricer wiring.
 3959 class HasFxResetPricer cf where
 3960   -- |Assign a retained FX reset pricer (1.44).
 3961   setFxResetPricer :: cf -> FxResetPricer -> IO ()
 3962 instance HasFxResetPricer FxResetCoupon where
 3963   setFxResetPricer = setFxResetCouponPricerRaw
 3964 instance HasFxResetPricer FxResetNotionalExchange where
 3965   setFxResetPricer = setFxResetNotionalExchangePricerRaw
 3966 
 3967 -- |Assign an FX reset pricer to every reset cash flow in a leg (1.44). Other cash flows are unchanged.
 3968 setFxResetLegPricer :: (GenLeg l) -- ^leg
 3969  -> (FxResetPricer) -- ^pricer
 3970  -> IO ()
 3971 setFxResetLegPricer a1 a2 =
 3972   withLeg a1 $ \a1' -> 
 3973   withStandalone a2 $ \a2' -> 
 3974   preErrorCheck $ \a3' -> 
 3975   setFxResetLegPricer'_ a1' a2' a3' >>
 3976   errorCheck  a3'>>
 3977   return ()
 3978 
 3979 
 3980 
 3981 -- |Broken-period IBOR coupon selecting or interpolating component indexes (1.44).
 3982 -- A nonempty stub selection is required; Nothing passes the native empty selection and fails validation.
 3983 stubIborCoupon :: (Day) -- ^paymentDate
 3984  -> (Double) -- ^nominal
 3985  -> (Day) -- ^startDate
 3986  -> (Day) -- ^endDate
 3987  -> (Word) -- ^fixingDays
 3988  -> (Maybe (StubIndexSelection ibor)) -- ^stubIndexSelection
 3989  -> (Double) -- ^gearing
 3990  -> (Double) -- ^spread
 3991  -> (Maybe Day) -- ^refPeriodStart
 3992  -> (Maybe Day) -- ^refPeriodEnd
 3993  -> (Maybe DayCounter) -- ^dayCounter
 3994  -> (Bool) -- ^isInArrears
 3995  -> (Maybe Day) -- ^exCouponDate
 3996  -> (BusinessDayConvention) -- ^fixingConvention
 3997  -> IO ((IborCoupon))
 3998 stubIborCoupon a1 a2 a3 a4 a5 a6 a7 a8 a9 a10 a11 a12 a13 a14 =
 3999   withDay a1 $ \a1' -> 
 4000   let {a2' = realToFrac a2} in 
 4001   withDay a3 $ \a3' -> 
 4002   withDay a4 $ \a4' -> 
 4003   let {a5' = fromIntegral a5} in 
 4004   withStubIndexSelection a6 $ \a6' -> 
 4005   let {a7' = realToFrac a7} in 
 4006   let {a8' = realToFrac a8} in 
 4007   withMaybeDay a9 $ \a9' -> 
 4008   withMaybeDay a10 $ \a10' -> 
 4009   withMaybeDayCounter a11 $ \a11' -> 
 4010   let {a12' = C2HSImp.fromBool a12} in 
 4011   withMaybeDay a13 $ \a13' -> 
 4012   let {a14' = fromEnumC a14} in 
 4013   preErrorCheck $ \a15' -> 
 4014   stubIborCoupon'_ a1' a2' a3' a4' a5' a6' a7' a8' a9' a10' a11' a12' a13' a14' a15' >>= \res ->
 4015   peekIborCoupon res >>= \res' ->
 4016   errorCheck  a15'>>
 4017   return (res')
 4018 
 4019 
 4020 
 4021 
 4022 peekResetDay :: Ptr CInt -> IO Day
 4023 peekResetDay p = toDay <$> peek p
 4024 
 4025 -- |Current coupon notional. FX reset coupons compute it from the assigned FX reset pricer.
 4026 couponNominal :: (GenCoupon c) -- ^coupon
 4027  -> IO ((Double))
 4028 couponNominal a1 =
 4029   withCoupon a1 $ \a1' -> 
 4030   preErrorCheck $ \a2' -> 
 4031   couponNominal'_ a1' a2' >>= \res ->
 4032   let {res' = realToFrac res} in
 4033   errorCheck  a2'>>
 4034   return (res')
 4035 
 4036 
 4037 
 4038 -- vim: set ff=unix ts=8 sts=2 sw=2 et:
 4039 
 4040 foreign import ccall safe "QuantLib/CashFlow.chs.h qlLeg"
 4041   qlLeg'_ :: (C2HSImp.CUInt -> ((C2HSImp.Ptr C2HSImp.CDouble) -> ((C2HSImp.Ptr C2HSImp.CInt) -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO (C2HSImp.Ptr (CLeg')))))))
 4042 
 4043 foreign import ccall safe "QuantLib/CashFlow.chs.h qlSimpleCashFlow"
 4044   simpleCashFlow'_ :: (C2HSImp.CDouble -> (C2HSImp.CInt -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO (C2HSImp.Ptr (CCashFlow'))))))
 4045 
 4046 foreign import ccall safe "QuantLib/CashFlow.chs.h qlCashFlowAmount"
 4047   amount'_ :: ((C2HSImp.Ptr (CCashFlow')) -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO C2HSImp.CDouble)))
 4048 
 4049 foreign import ccall safe "QuantLib/CashFlow.chs.h qlCashFlowDate"
 4050   date'_ :: ((C2HSImp.Ptr (CCashFlow')) -> (IO C2HSImp.CInt))
 4051 
 4052 foreign import ccall safe "QuantLib/CashFlow.chs.h qlIndexedCashFlow"
 4053   indexedCashFlow'_ :: (C2HSImp.CDouble -> ((C2HSImp.Ptr (CIndex')) -> (C2HSImp.CInt -> (C2HSImp.CInt -> (C2HSImp.CInt -> (C2HSImp.CInt -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO (C2HSImp.Ptr (CIndexedCashFlow'))))))))))
 4054 
 4055 foreign import ccall safe "QuantLib/CashFlow.chs.h qlIndexedCashFlowBaseFixing"
 4056   baseFixing'_ :: ((C2HSImp.Ptr (CIndexedCashFlow')) -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO C2HSImp.CDouble)))
 4057 
 4058 foreign import ccall safe "QuantLib/CashFlow.chs.h qlIndexedCashFlowIndexFixing"
 4059   indexFixing'_ :: ((C2HSImp.Ptr (CIndexedCashFlow')) -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO C2HSImp.CDouble)))
 4060 
 4061 foreign import ccall safe "QuantLib/CashFlow.chs.h qlFixedRateCoupon"
 4062   fixedRateCoupon'_ :: (C2HSImp.CInt -> (C2HSImp.CDouble -> (C2HSImp.CDouble -> ((C2HSImp.Ptr (CDayCounter)) -> (C2HSImp.CInt -> (C2HSImp.CInt -> (C2HSImp.CInt -> (C2HSImp.CInt -> (C2HSImp.CInt -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO (C2HSImp.Ptr (CFixedRateCoupon')))))))))))))
 4063 
 4064 foreign import ccall safe "QuantLib/CashFlow.chs.h qlFixedRateCouponInterestRate"
 4065   interestRate'_ :: ((C2HSImp.Ptr (CFixedRateCoupon')) -> (IO (C2HSImp.Ptr (CInterestRate))))
 4066 
 4067 foreign import ccall safe "QuantLib/CashFlow.chs.h qlFloatingRateCoupon"
 4068   floatingRateCoupon'_ :: (C2HSImp.CInt -> (C2HSImp.CDouble -> (C2HSImp.CInt -> (C2HSImp.CInt -> (C2HSImp.CUInt -> ((C2HSImp.Ptr (CInterestRateIndex')) -> (C2HSImp.CDouble -> (C2HSImp.CDouble -> (C2HSImp.CInt -> (C2HSImp.CInt -> ((C2HSImp.Ptr (CDayCounter)) -> (C2HSImp.CInt -> (C2HSImp.CInt -> (C2HSImp.CInt -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO (C2HSImp.Ptr (CFloatingRateCoupon'))))))))))))))))))
 4069 
 4070 foreign import ccall safe "QuantLib/CashFlow.chs.h qlIborCouponExact"
 4071   iborCoupon'_ :: (C2HSImp.CInt -> (C2HSImp.CDouble -> (C2HSImp.CInt -> (C2HSImp.CInt -> (C2HSImp.CUInt -> ((C2HSImp.Ptr (CIborIndex')) -> (C2HSImp.CDouble -> (C2HSImp.CDouble -> (C2HSImp.CInt -> (C2HSImp.CInt -> ((C2HSImp.Ptr (CDayCounter)) -> (C2HSImp.CInt -> (C2HSImp.CInt -> (C2HSImp.CInt -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO (C2HSImp.Ptr (CIborCoupon'))))))))))))))))))
 4072 
 4073 foreign import ccall safe "QuantLib/CashFlow.chs.h qlAverageBMACoupon"
 4074   averageBmaCoupon'_ :: (C2HSImp.CInt -> (C2HSImp.CDouble -> (C2HSImp.CInt -> (C2HSImp.CInt -> ((C2HSImp.Ptr (CBMAIndex')) -> (C2HSImp.CDouble -> (C2HSImp.CDouble -> (C2HSImp.CInt -> (C2HSImp.CInt -> ((C2HSImp.Ptr (CDayCounter)) -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO (C2HSImp.Ptr (CAverageBMACoupon'))))))))))))))
 4075 
 4076 foreign import ccall safe "QuantLib/CashFlow.chs.h qlAverageBMACouponFixingDates"
 4077   averageBmaCouponFixingDatesRaw'_ :: ((C2HSImp.Ptr (CAverageBMACoupon')) -> ((C2HSImp.Ptr C2HSImp.CUInt) -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CInt)) -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO ())))))
 4078 
 4079 foreign import ccall safe "QuantLib/CashFlow.chs.h qlAverageBMACouponIndexFixings"
 4080   averageBmaCouponIndexFixingsRaw'_ :: ((C2HSImp.Ptr (CAverageBMACoupon')) -> ((C2HSImp.Ptr C2HSImp.CUInt) -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CDouble)) -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO ())))))
 4081 
 4082 foreign import ccall safe "QuantLib/CashFlow.chs.h qlCappedFlooredCoupon"
 4083   cappedFlooredCoupon'_ :: ((C2HSImp.Ptr (CFloatingRateCoupon')) -> (C2HSImp.CDouble -> (C2HSImp.CDouble -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO (C2HSImp.Ptr (CFloatingRateCoupon')))))))
 4084 
 4085 foreign import ccall safe "QuantLib/CashFlow.chs.h qlStrippedCappedFlooredCoupon"
 4086   strippedCappedFlooredCoupon'_ :: ((C2HSImp.Ptr (CFloatingRateCoupon')) -> (C2HSImp.CDouble -> (C2HSImp.CDouble -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO (C2HSImp.Ptr (CStrippedCappedFlooredCoupon')))))))
 4087 
 4088 foreign import ccall safe "QuantLib/CashFlow.chs.h qlStrippedCappedFlooredCouponCap"
 4089   capRate'_ :: ((C2HSImp.Ptr (CStrippedCappedFlooredCoupon')) -> (IO C2HSImp.CDouble))
 4090 
 4091 foreign import ccall safe "QuantLib/CashFlow.chs.h qlStrippedCappedFlooredCouponFloor"
 4092   floorRate'_ :: ((C2HSImp.Ptr (CStrippedCappedFlooredCoupon')) -> (IO C2HSImp.CDouble))
 4093 
 4094 foreign import ccall safe "QuantLib/CashFlow.chs.h qlStrippedCappedFlooredCouponEffectiveCap"
 4095   effectiveCap'_ :: ((C2HSImp.Ptr (CStrippedCappedFlooredCoupon')) -> (IO C2HSImp.CDouble))
 4096 
 4097 foreign import ccall safe "QuantLib/CashFlow.chs.h qlStrippedCappedFlooredCouponEffectiveFloor"
 4098   effectiveFloor'_ :: ((C2HSImp.Ptr (CStrippedCappedFlooredCoupon')) -> (IO C2HSImp.CDouble))
 4099 
 4100 foreign import ccall safe "QuantLib/CashFlow.chs.h qlStrippedCappedFlooredCouponIsCap"
 4101   isCap'_ :: ((C2HSImp.Ptr (CStrippedCappedFlooredCoupon')) -> (IO C2HSImp.CInt))
 4102 
 4103 foreign import ccall safe "QuantLib/CashFlow.chs.h qlStrippedCappedFlooredCouponIsFloor"
 4104   isFloor'_ :: ((C2HSImp.Ptr (CStrippedCappedFlooredCoupon')) -> (IO C2HSImp.CInt))
 4105 
 4106 foreign import ccall safe "QuantLib/CashFlow.chs.h qlStrippedCappedFlooredCouponIsCollar"
 4107   isCollar'_ :: ((C2HSImp.Ptr (CStrippedCappedFlooredCoupon')) -> (IO C2HSImp.CInt))
 4108 
 4109 foreign import ccall safe "QuantLib/CashFlow.chs.h qlCappedFlooredIborCoupon"
 4110   cappedFlooredIborCoupon'_ :: (C2HSImp.CInt -> (C2HSImp.CDouble -> (C2HSImp.CInt -> (C2HSImp.CInt -> (C2HSImp.CUInt -> ((C2HSImp.Ptr (CIborIndex')) -> (C2HSImp.CDouble -> (C2HSImp.CDouble -> (C2HSImp.CDouble -> (C2HSImp.CDouble -> (C2HSImp.CInt -> (C2HSImp.CInt -> ((C2HSImp.Ptr (CDayCounter)) -> (C2HSImp.CInt -> (C2HSImp.CInt -> (C2HSImp.CInt -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO (C2HSImp.Ptr (CFloatingRateCoupon'))))))))))))))))))))
 4111 
 4112 foreign import ccall safe "QuantLib/CashFlow.chs.h qlDigitalIborCoupon"
 4113   digitalIborCoupon'_ :: ((C2HSImp.Ptr (CIborCoupon')) -> (C2HSImp.CDouble -> (C2HSImp.CInt -> (C2HSImp.CInt -> (C2HSImp.CDouble -> (C2HSImp.CDouble -> (C2HSImp.CInt -> (C2HSImp.CInt -> (C2HSImp.CDouble -> ((C2HSImp.Ptr (CDigitalReplication)) -> (C2HSImp.CInt -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO (C2HSImp.Ptr (CDigitalCoupon')))))))))))))))
 4114 
 4115 foreign import ccall safe "QuantLib/CashFlow.chs.h qlDigitalCoupon"
 4116   digitalCoupon'_ :: ((C2HSImp.Ptr (CFloatingRateCoupon')) -> (C2HSImp.CDouble -> (C2HSImp.CInt -> (C2HSImp.CInt -> (C2HSImp.CDouble -> (C2HSImp.CDouble -> (C2HSImp.CInt -> (C2HSImp.CInt -> (C2HSImp.CDouble -> ((C2HSImp.Ptr (CDigitalReplication)) -> (C2HSImp.CInt -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO (C2HSImp.Ptr (CDigitalCoupon')))))))))))))))
 4117 
 4118 foreign import ccall safe "QuantLib/CashFlow.chs.h qlDigitalCouponCallOptionRate"
 4119   callOptionRate'_ :: ((C2HSImp.Ptr (CDigitalCoupon')) -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO C2HSImp.CDouble)))
 4120 
 4121 foreign import ccall safe "QuantLib/CashFlow.chs.h qlDigitalCouponPutOptionRate"
 4122   putOptionRate'_ :: ((C2HSImp.Ptr (CDigitalCoupon')) -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO C2HSImp.CDouble)))
 4123 
 4124 foreign import ccall safe "QuantLib/CashFlow.chs.h qlMultipleResetsCoupon"
 4125   multipleResetsCoupon'_ :: (C2HSImp.CInt -> (C2HSImp.CDouble -> ((C2HSImp.Ptr (CSchedule)) -> (C2HSImp.CUInt -> ((C2HSImp.Ptr (CIborIndex')) -> (C2HSImp.CDouble -> (C2HSImp.CDouble -> (C2HSImp.CDouble -> (C2HSImp.CInt -> (C2HSImp.CInt -> ((C2HSImp.Ptr (CDayCounter)) -> (C2HSImp.CInt -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO (C2HSImp.Ptr (CMultipleResetsCoupon'))))))))))))))))
 4126 
 4127 foreign import ccall safe "QuantLib/CashFlow.chs.h qlMultipleResetsCouponFixingDates"
 4128   multipleResetsCouponFixingDatesRaw'_ :: ((C2HSImp.Ptr (CMultipleResetsCoupon')) -> ((C2HSImp.Ptr C2HSImp.CUInt) -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CInt)) -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO ())))))
 4129 
 4130 foreign import ccall safe "QuantLib/CashFlow.chs.h qlRangeAccrualFloatersCoupon"
 4131   rangeAccrualFloatersCoupon'_ :: (C2HSImp.CInt -> (C2HSImp.CDouble -> ((C2HSImp.Ptr (CIborIndex')) -> (C2HSImp.CInt -> (C2HSImp.CInt -> (C2HSImp.CUInt -> ((C2HSImp.Ptr (CDayCounter)) -> (C2HSImp.CDouble -> (C2HSImp.CDouble -> (C2HSImp.CInt -> (C2HSImp.CInt -> ((C2HSImp.Ptr (CSchedule)) -> (C2HSImp.CDouble -> (C2HSImp.CDouble -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO (C2HSImp.Ptr (CRangeAccrualFloatersCoupon'))))))))))))))))))
 4132 
 4133 foreign import ccall safe "QuantLib/CashFlow.chs.h qlRangeAccrualFloatersCouponPriceWithoutOptionality"
 4134   priceWithoutOptionality'_ :: ((C2HSImp.Ptr (CRangeAccrualFloatersCoupon')) -> ((C2HSImp.Ptr (CYieldTermStructure')) -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO C2HSImp.CDouble))))
 4135 
 4136 foreign import ccall safe "QuantLib/CashFlow.chs.h qlYoYInflationCoupon"
 4137   yoyInflationCoupon'_ :: (C2HSImp.CInt -> (C2HSImp.CDouble -> (C2HSImp.CInt -> (C2HSImp.CInt -> (C2HSImp.CUInt -> ((C2HSImp.Ptr (CYoYInflationIndex')) -> (C2HSImp.CInt -> (C2HSImp.CInt -> (C2HSImp.CInt -> ((C2HSImp.Ptr (CDayCounter)) -> (C2HSImp.CDouble -> (C2HSImp.CDouble -> (C2HSImp.CInt -> (C2HSImp.CInt -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO (C2HSImp.Ptr (CYoYInflationCoupon'))))))))))))))))))
 4138 
 4139 foreign import ccall safe "QuantLib/CashFlow.chs.h qlYoYInflationCouponAdjustedFixing"
 4140   adjustedFixing'_ :: ((C2HSImp.Ptr (CYoYInflationCoupon')) -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO C2HSImp.CDouble)))
 4141 
 4142 foreign import ccall safe "QuantLib/CashFlow.chs.h qlAveragingMultipleResetsPricer"
 4143   averagingMultipleResetsPricer'_ :: ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO (C2HSImp.Ptr (CFloatingRateCouponPricer'))))
 4144 
 4145 foreign import ccall safe "QuantLib/CashFlow.chs.h qlCompoundingMultipleResetsPricer"
 4146   compoundingMultipleResetsPricer'_ :: ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO (C2HSImp.Ptr (CFloatingRateCouponPricer'))))
 4147 
 4148 foreign import ccall safe "QuantLib/CashFlow.chs.h qlOvernightIndexedCoupon"
 4149   overnightIndexedCoupon'_ :: (C2HSImp.CInt -> (C2HSImp.CDouble -> (C2HSImp.CInt -> (C2HSImp.CInt -> ((C2HSImp.Ptr (COvernightIndex')) -> (C2HSImp.CDouble -> (C2HSImp.CDouble -> (C2HSImp.CInt -> (C2HSImp.CInt -> ((C2HSImp.Ptr (CDayCounter)) -> (C2HSImp.CInt -> (C2HSImp.CInt -> (C2HSImp.CUInt -> (C2HSImp.CUInt -> (C2HSImp.CInt -> (C2HSImp.CInt -> (C2HSImp.CInt -> (C2HSImp.CInt -> (C2HSImp.CInt -> (C2HSImp.CInt -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO (C2HSImp.Ptr (COvernightIndexedCoupon'))))))))))))))))))))))))
 4150 
 4151 foreign import ccall safe "QuantLib/CashFlow.chs.h qlOvernightIndexedCouponFixingDates"
 4152   overnightIndexedCouponFixingDatesRaw'_ :: ((C2HSImp.Ptr (COvernightIndexedCoupon')) -> ((C2HSImp.Ptr C2HSImp.CUInt) -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CInt)) -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO ())))))
 4153 
 4154 foreign import ccall safe "QuantLib/CashFlow.chs.h qlOvernightIndexedCouponIndexFixings"
 4155   overnightIndexedCouponIndexFixingsRaw'_ :: ((C2HSImp.Ptr (COvernightIndexedCoupon')) -> ((C2HSImp.Ptr C2HSImp.CUInt) -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CDouble)) -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO ())))))
 4156 
 4157 foreign import ccall safe "QuantLib/CashFlow.chs.h qlCappedFlooredOvernightIndexedCoupon"
 4158   cappedFlooredOvernightIndexedCoupon'_ :: ((C2HSImp.Ptr (COvernightIndexedCoupon')) -> (C2HSImp.CDouble -> (C2HSImp.CDouble -> (C2HSImp.CInt -> (C2HSImp.CInt -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO (C2HSImp.Ptr (CFloatingRateCoupon')))))))))
 4159 
 4160 foreign import ccall safe "QuantLib/CashFlow.chs.h qlCompoundingOvernightIndexedCouponPricer"
 4161   compoundingOvernightIndexedCouponPricer'_ :: ((C2HSImp.Ptr (COptionletVolatilityStructure')) -> (C2HSImp.CInt -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO (C2HSImp.Ptr (CFloatingRateCouponPricer'))))))
 4162 
 4163 foreign import ccall safe "QuantLib/CashFlow.chs.h qlArithmeticAveragedOvernightIndexedCouponPricer"
 4164   arithmeticAveragedOvernightIndexedCouponPricer'_ :: (C2HSImp.CDouble -> (C2HSImp.CDouble -> (C2HSImp.CInt -> ((C2HSImp.Ptr (COptionletVolatilityStructure')) -> (C2HSImp.CInt -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO (C2HSImp.Ptr (CFloatingRateCouponPricer')))))))))
 4165 
 4166 foreign import ccall safe "QuantLib/CashFlow.chs.h qlBlackCompoundingOvernightIndexedCouponPricer"
 4167   blackCompoundingOvernightIndexedCouponPricer'_ :: ((C2HSImp.Ptr (COptionletVolatilityStructure')) -> (C2HSImp.CInt -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO (C2HSImp.Ptr (CFloatingRateCouponPricer'))))))
 4168 
 4169 foreign import ccall safe "QuantLib/CashFlow.chs.h qlBlackAveragingOvernightIndexedCouponPricer"
 4170   blackAveragingOvernightIndexedCouponPricer'_ :: ((C2HSImp.Ptr (COptionletVolatilityStructure')) -> (C2HSImp.CInt -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO (C2HSImp.Ptr (CFloatingRateCouponPricer'))))))
 4171 
 4172 foreign import ccall safe "QuantLib/CashFlow.chs.h qlCPICoupon"
 4173   cpiCoupon'_ :: (C2HSImp.CDouble -> (C2HSImp.CInt -> (C2HSImp.CDouble -> (C2HSImp.CInt -> (C2HSImp.CInt -> ((C2HSImp.Ptr (CZeroInflationIndex')) -> (C2HSImp.CInt -> (C2HSImp.CInt -> (C2HSImp.CInt -> ((C2HSImp.Ptr (CDayCounter)) -> (C2HSImp.CDouble -> (C2HSImp.CInt -> (C2HSImp.CInt -> (C2HSImp.CInt -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO (C2HSImp.Ptr (CCPICoupon'))))))))))))))))))
 4174 
 4175 foreign import ccall safe "QuantLib/CashFlow.chs.h qlCPICouponFromBaseDate"
 4176   cpiCouponFromBaseDate'_ :: (C2HSImp.CInt -> (C2HSImp.CInt -> (C2HSImp.CDouble -> (C2HSImp.CInt -> (C2HSImp.CInt -> ((C2HSImp.Ptr (CZeroInflationIndex')) -> (C2HSImp.CInt -> (C2HSImp.CInt -> (C2HSImp.CInt -> ((C2HSImp.Ptr (CDayCounter)) -> (C2HSImp.CDouble -> (C2HSImp.CInt -> (C2HSImp.CInt -> (C2HSImp.CInt -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO (C2HSImp.Ptr (CCPICoupon'))))))))))))))))))
 4177 
 4178 foreign import ccall safe "QuantLib/CashFlow.chs.h qlCPICouponWithBaseDate"
 4179   cpiCouponWithBaseDate'_ :: (C2HSImp.CDouble -> (C2HSImp.CInt -> (C2HSImp.CInt -> (C2HSImp.CDouble -> (C2HSImp.CInt -> (C2HSImp.CInt -> ((C2HSImp.Ptr (CZeroInflationIndex')) -> (C2HSImp.CInt -> (C2HSImp.CInt -> (C2HSImp.CInt -> ((C2HSImp.Ptr (CDayCounter)) -> (C2HSImp.CDouble -> (C2HSImp.CInt -> (C2HSImp.CInt -> (C2HSImp.CInt -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO (C2HSImp.Ptr (CCPICoupon')))))))))))))))))))
 4180 
 4181 foreign import ccall safe "QuantLib/CashFlow.chs.h qlCPICouponPricer"
 4182   cpiCouponPricer'_ :: ((C2HSImp.Ptr (CYieldTermStructure')) -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO (C2HSImp.Ptr (CCPICouponPricer)))))
 4183 
 4184 foreign import ccall safe "QuantLib/CashFlow.chs.h qlCPICouponPricerWithVol"
 4185   cpiCouponPricerWithVol'_ :: ((C2HSImp.Ptr (CCPIVolatilitySurface')) -> ((C2HSImp.Ptr (CYieldTermStructure')) -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO (C2HSImp.Ptr (CCPICouponPricer))))))
 4186 
 4187 foreign import ccall safe "QuantLib/CashFlow.chs.h qlCPICouponSetPricer"
 4188   setCpiCouponPricer'_ :: ((C2HSImp.Ptr (CCPICoupon')) -> ((C2HSImp.Ptr (CCPICouponPricer)) -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO ()))))
 4189 
 4190 foreign import ccall safe "QuantLib/CashFlow.chs.h qlCPICouponIndexRatio"
 4191   indexRatio'_ :: ((C2HSImp.Ptr (CCPICoupon')) -> (C2HSImp.CInt -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO C2HSImp.CDouble))))
 4192 
 4193 foreign import ccall safe "QuantLib/CashFlow.chs.h qlRedemption"
 4194   redemption'_ :: (C2HSImp.CDouble -> (C2HSImp.CInt -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO (C2HSImp.Ptr (CCashFlow'))))))
 4195 
 4196 foreign import ccall safe "QuantLib/CashFlow.chs.h qlAmortizingPayment"
 4197   amortizingPayment'_ :: (C2HSImp.CDouble -> (C2HSImp.CInt -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO (C2HSImp.Ptr (CCashFlow'))))))
 4198 
 4199 foreign import ccall safe "QuantLib/CashFlow.chs.h qlCashFlowLeg"
 4200   cashFlowLeg'_ :: (C2HSImp.CUInt -> ((C2HSImp.Ptr (C2HSImp.Ptr (CCashFlow'))) -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO (C2HSImp.Ptr (CLeg'))))))
 4201 
 4202 foreign import ccall safe "QuantLib/CashFlow.chs.h qlLegStartDate"
 4203   startDate'_ :: ((C2HSImp.Ptr (CLeg')) -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO C2HSImp.CInt)))
 4204 
 4205 foreign import ccall safe "QuantLib/CashFlow.chs.h qlNextCashFlows"
 4206   nextCashFlows'_ :: ((C2HSImp.Ptr (CLeg')) -> (C2HSImp.CInt -> (C2HSImp.CInt -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO (C2HSImp.Ptr (CLeg')))))))
 4207 
 4208 foreign import ccall safe "QuantLib/CashFlow.chs.h qlPreviousCashFlows"
 4209   previousCashFlows'_ :: ((C2HSImp.Ptr (CLeg')) -> (C2HSImp.CInt -> (C2HSImp.CInt -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO (C2HSImp.Ptr (CLeg')))))))
 4210 
 4211 foreign import ccall safe "QuantLib/CashFlow.chs.h qlLegCashFlows"
 4212   qlLegCashFlows'_ :: ((C2HSImp.Ptr (CLeg')) -> (C2HSImp.CInt -> (C2HSImp.CInt -> ((C2HSImp.Ptr C2HSImp.CUInt) -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CDouble)) -> ((C2HSImp.Ptr C2HSImp.CUInt) -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CInt)) -> ((C2HSImp.Ptr C2HSImp.CUInt) -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CInt)) -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO ())))))))))))
 4213 
 4214 foreign import ccall safe "QuantLib/CashFlow.chs.h qlCashFlowsDuration"
 4215   duration'_ :: ((C2HSImp.Ptr (CLeg')) -> ((C2HSImp.Ptr (CInterestRate)) -> (C2HSImp.CInt -> (C2HSImp.CInt -> (C2HSImp.CInt -> (C2HSImp.CInt -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO C2HSImp.CDouble))))))))
 4216 
 4217 foreign import ccall safe "QuantLib/CashFlow.chs.h qlCashFlowsAccrualDays"
 4218   accrualDays'_ :: ((C2HSImp.Ptr (CLeg')) -> (C2HSImp.CInt -> (C2HSImp.CInt -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO C2HSImp.CInt)))))
 4219 
 4220 foreign import ccall safe "QuantLib/CashFlow.chs.h qlCashFlowsAccrualEndDate"
 4221   accrualEndDate'_ :: ((C2HSImp.Ptr (CLeg')) -> (C2HSImp.CInt -> (C2HSImp.CInt -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO C2HSImp.CInt)))))
 4222 
 4223 foreign import ccall safe "QuantLib/CashFlow.chs.h qlCashFlowsAccrualPeriod"
 4224   accrualPeriod'_ :: ((C2HSImp.Ptr (CLeg')) -> (C2HSImp.CInt -> (C2HSImp.CInt -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO C2HSImp.CDouble)))))
 4225 
 4226 foreign import ccall safe "QuantLib/CashFlow.chs.h qlCashFlowsAccrualStartDate"
 4227   accrualStartDate'_ :: ((C2HSImp.Ptr (CLeg')) -> (C2HSImp.CInt -> (C2HSImp.CInt -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO C2HSImp.CInt)))))
 4228 
 4229 foreign import ccall safe "QuantLib/CashFlow.chs.h qlCashFlowsAccruedAmount"
 4230   accruedAmount'_ :: ((C2HSImp.Ptr (CLeg')) -> (C2HSImp.CInt -> (C2HSImp.CInt -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO C2HSImp.CDouble)))))
 4231 
 4232 foreign import ccall safe "QuantLib/CashFlow.chs.h qlCashFlowsAccruedDays"
 4233   accruedDays'_ :: ((C2HSImp.Ptr (CLeg')) -> (C2HSImp.CInt -> (C2HSImp.CInt -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO C2HSImp.CInt)))))
 4234 
 4235 foreign import ccall safe "QuantLib/CashFlow.chs.h qlCashFlowsAccruedPeriod"
 4236   accruedPeriod'_ :: ((C2HSImp.Ptr (CLeg')) -> (C2HSImp.CInt -> (C2HSImp.CInt -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO C2HSImp.CDouble)))))
 4237 
 4238 foreign import ccall safe "QuantLib/CashFlow.chs.h qlCashFlowsBasisPointValue"
 4239   basisPointValue'_ :: ((C2HSImp.Ptr (CLeg')) -> ((C2HSImp.Ptr (CInterestRate)) -> (C2HSImp.CInt -> (C2HSImp.CInt -> (C2HSImp.CInt -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO C2HSImp.CDouble)))))))
 4240 
 4241 foreign import ccall safe "QuantLib/CashFlow.chs.h qlCashFlowsBps1"
 4242   bpsFromYieldRaw'_ :: ((C2HSImp.Ptr (CLeg')) -> ((C2HSImp.Ptr (CInterestRate)) -> (C2HSImp.CInt -> (C2HSImp.CInt -> (C2HSImp.CInt -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO C2HSImp.CDouble)))))))
 4243 
 4244 foreign import ccall safe "QuantLib/CashFlow.chs.h qlCashFlowsConvexity"
 4245   convexity'_ :: ((C2HSImp.Ptr (CLeg')) -> ((C2HSImp.Ptr (CInterestRate)) -> (C2HSImp.CInt -> (C2HSImp.CInt -> (C2HSImp.CInt -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO C2HSImp.CDouble)))))))
 4246 
 4247 foreign import ccall safe "QuantLib/CashFlow.chs.h qlCashFlowsIsExpired"
 4248   isExpired'_ :: ((C2HSImp.Ptr (CLeg')) -> (C2HSImp.CInt -> (C2HSImp.CInt -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO C2HSImp.CInt)))))
 4249 
 4250 foreign import ccall safe "QuantLib/CashFlow.chs.h qlCashFlowsMaturityDate"
 4251   maturityDate'_ :: ((C2HSImp.Ptr (CLeg')) -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO C2HSImp.CInt)))
 4252 
 4253 foreign import ccall safe "QuantLib/CashFlow.chs.h qlCashFlowsNextCashFlowAmount"
 4254   nextCashFlowAmount'_ :: ((C2HSImp.Ptr (CLeg')) -> (C2HSImp.CInt -> (C2HSImp.CInt -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO C2HSImp.CDouble)))))
 4255 
 4256 foreign import ccall safe "QuantLib/CashFlow.chs.h qlCashFlowsNextCashFlowDate"
 4257   nextCashFlowDate'_ :: ((C2HSImp.Ptr (CLeg')) -> (C2HSImp.CInt -> (C2HSImp.CInt -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO C2HSImp.CInt)))))
 4258 
 4259 foreign import ccall safe "QuantLib/CashFlow.chs.h qlCashFlowsNextCouponRate"
 4260   nextCouponRate'_ :: ((C2HSImp.Ptr (CLeg')) -> (C2HSImp.CInt -> (C2HSImp.CInt -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO C2HSImp.CDouble)))))
 4261 
 4262 foreign import ccall safe "QuantLib/CashFlow.chs.h qlCashFlowsNominal"
 4263   nominal'_ :: ((C2HSImp.Ptr (CLeg')) -> (C2HSImp.CInt -> (C2HSImp.CInt -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO C2HSImp.CDouble)))))
 4264 
 4265 foreign import ccall safe "QuantLib/CashFlow.chs.h qlCashFlowsNpv1"
 4266   npvFromYieldRaw'_ :: ((C2HSImp.Ptr (CLeg')) -> ((C2HSImp.Ptr (CInterestRate)) -> (C2HSImp.CInt -> (C2HSImp.CInt -> (C2HSImp.CInt -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO C2HSImp.CDouble)))))))
 4267 
 4268 foreign import ccall safe "QuantLib/CashFlow.chs.h qlCashFlowsAtmRate"
 4269   atmRate'_ :: ((C2HSImp.Ptr (CLeg')) -> ((C2HSImp.Ptr (CYieldTermStructure')) -> (C2HSImp.CInt -> (C2HSImp.CInt -> (C2HSImp.CInt -> (C2HSImp.CDouble -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO C2HSImp.CDouble))))))))
 4270 
 4271 foreign import ccall safe "QuantLib/CashFlow.chs.h qlCashFlowsBps"
 4272   bpsFromCurveRaw'_ :: ((C2HSImp.Ptr (CLeg')) -> ((C2HSImp.Ptr (CYieldTermStructure')) -> (C2HSImp.CInt -> (C2HSImp.CInt -> (C2HSImp.CInt -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO C2HSImp.CDouble)))))))
 4273 
 4274 foreign import ccall safe "QuantLib/CashFlow.chs.h qlCashFlowsNpv3"
 4275   npvWithZSpreadRaw'_ :: ((C2HSImp.Ptr (CLeg')) -> ((C2HSImp.Ptr (CYieldTermStructure')) -> (C2HSImp.CDouble -> (C2HSImp.CInt -> (C2HSImp.CInt -> (C2HSImp.CInt -> (C2HSImp.CInt -> (C2HSImp.CInt -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO C2HSImp.CDouble))))))))))
 4276 
 4277 foreign import ccall safe "QuantLib/CashFlow.chs.h qlCashFlowsNpv"
 4278   npvFromCurveRaw'_ :: ((C2HSImp.Ptr (CLeg')) -> ((C2HSImp.Ptr (CYieldTermStructure')) -> (C2HSImp.CInt -> (C2HSImp.CInt -> (C2HSImp.CInt -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO C2HSImp.CDouble)))))))
 4279 
 4280 foreign import ccall safe "QuantLib/CashFlow.chs.h qlCashFlowsNpvbps"
 4281   npvBps'_ :: ((C2HSImp.Ptr (CLeg')) -> ((C2HSImp.Ptr (CYieldTermStructure')) -> (C2HSImp.CInt -> (C2HSImp.CInt -> (C2HSImp.CInt -> ((C2HSImp.Ptr C2HSImp.CDouble) -> ((C2HSImp.Ptr C2HSImp.CDouble) -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO ())))))))))
 4282 
 4283 foreign import ccall safe "QuantLib/CashFlow.chs.h qlCashFlowsZSpread"
 4284   zSpread'_ :: ((C2HSImp.Ptr (CLeg')) -> (C2HSImp.CDouble -> ((C2HSImp.Ptr (CYieldTermStructure')) -> (C2HSImp.CInt -> (C2HSImp.CInt -> (C2HSImp.CInt -> (C2HSImp.CInt -> (C2HSImp.CInt -> (C2HSImp.CDouble -> (C2HSImp.CUInt -> (C2HSImp.CDouble -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO C2HSImp.CDouble)))))))))))))
 4285 
 4286 foreign import ccall safe "QuantLib/CashFlow.chs.h qlCashFlowsPreviousCashFlowAmount"
 4287   previousCashFlowAmount'_ :: ((C2HSImp.Ptr (CLeg')) -> (C2HSImp.CInt -> (C2HSImp.CInt -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO C2HSImp.CDouble)))))
 4288 
 4289 foreign import ccall safe "QuantLib/CashFlow.chs.h qlCashFlowsPreviousCashFlowDate"
 4290   previousCashFlowDate'_ :: ((C2HSImp.Ptr (CLeg')) -> (C2HSImp.CInt -> (C2HSImp.CInt -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO C2HSImp.CInt)))))
 4291 
 4292 foreign import ccall safe "QuantLib/CashFlow.chs.h qlCashFlowsPreviousCouponRate"
 4293   previousCouponRate'_ :: ((C2HSImp.Ptr (CLeg')) -> (C2HSImp.CInt -> (C2HSImp.CInt -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO C2HSImp.CDouble)))))
 4294 
 4295 foreign import ccall safe "QuantLib/CashFlow.chs.h qlCashFlowsReferencePeriodEnd"
 4296   referencePeriodEnd'_ :: ((C2HSImp.Ptr (CLeg')) -> (C2HSImp.CInt -> (C2HSImp.CInt -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO C2HSImp.CInt)))))
 4297 
 4298 foreign import ccall safe "QuantLib/CashFlow.chs.h qlCashFlowsReferencePeriodStart"
 4299   referencePeriodStart'_ :: ((C2HSImp.Ptr (CLeg')) -> (C2HSImp.CInt -> (C2HSImp.CInt -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO C2HSImp.CInt)))))
 4300 
 4301 foreign import ccall safe "QuantLib/CashFlow.chs.h qlCashFlowsYield"
 4302   yield'_ :: ((C2HSImp.Ptr (CLeg')) -> (C2HSImp.CDouble -> ((C2HSImp.Ptr (CDayCounter)) -> (C2HSImp.CInt -> (C2HSImp.CInt -> (C2HSImp.CInt -> (C2HSImp.CInt -> (C2HSImp.CInt -> (C2HSImp.CDouble -> (C2HSImp.CUInt -> (C2HSImp.CDouble -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO C2HSImp.CDouble)))))))))))))
 4303 
 4304 foreign import ccall safe "QuantLib/CashFlow.chs.h qlCashFlowsYieldValueBasisPoint"
 4305   yieldValueBasisPoint'_ :: ((C2HSImp.Ptr (CLeg')) -> ((C2HSImp.Ptr (CInterestRate)) -> (C2HSImp.CInt -> (C2HSImp.CInt -> (C2HSImp.CInt -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO C2HSImp.CDouble)))))))
 4306 
 4307 foreign import ccall safe "QuantLib/CashFlow.chs.h qlCouponAccrualStartDates"
 4308   couponAccrualStartDates'_ :: ((C2HSImp.Ptr (CCouponLeg')) -> ((C2HSImp.Ptr C2HSImp.CUInt) -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CInt)) -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO ())))))
 4309 
 4310 foreign import ccall safe "QuantLib/CashFlow.chs.h qlFixedDividend"
 4311   fixedDividend'_ :: (C2HSImp.CDouble -> (C2HSImp.CInt -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO (C2HSImp.Ptr (CDividend))))))
 4312 
 4313 foreign import ccall safe "QuantLib/CashFlow.chs.h qlFractionalDividend1"
 4314   fractionalDividendWithNominal'_ :: (C2HSImp.CDouble -> (C2HSImp.CDouble -> (C2HSImp.CInt -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO (C2HSImp.Ptr (CDividend)))))))
 4315 
 4316 foreign import ccall safe "QuantLib/CashFlow.chs.h qlFractionalDividend"
 4317   fractionalDividend'_ :: (C2HSImp.CDouble -> (C2HSImp.CInt -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO (C2HSImp.Ptr (CDividend))))))
 4318 
 4319 foreign import ccall safe "QuantLib/CashFlow.chs.h qlAverageBMALeg"
 4320   averageBmaLeg'_ :: ((C2HSImp.Ptr (CSchedule)) -> ((C2HSImp.Ptr (CBMAIndex')) -> (C2HSImp.CUInt -> ((C2HSImp.Ptr C2HSImp.CDouble) -> ((C2HSImp.Ptr (CDayCounter)) -> (C2HSImp.CInt -> (C2HSImp.CUInt -> ((C2HSImp.Ptr C2HSImp.CDouble) -> (C2HSImp.CUInt -> ((C2HSImp.Ptr C2HSImp.CDouble) -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO (C2HSImp.Ptr (CLeg'))))))))))))))
 4321 
 4322 foreign import ccall safe "QuantLib/CashFlow.chs.h qlFixedRateLeg"
 4323   fixedRateLeg_'_ :: ((C2HSImp.Ptr (CSchedule)) -> (C2HSImp.CUInt -> ((C2HSImp.Ptr C2HSImp.CDouble) -> (C2HSImp.CUInt -> ((C2HSImp.Ptr (C2HSImp.Ptr (CInterestRate))) -> (C2HSImp.CInt -> ((C2HSImp.Ptr (CDayCounter)) -> ((C2HSImp.Ptr (CCalendar)) -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO (C2HSImp.Ptr (CLeg'))))))))))))
 4324 
 4325 foreign import ccall safe "QuantLib/CashFlow.chs.h qlIborLeg"
 4326   iborLeg_'_ :: ((C2HSImp.Ptr (CSchedule)) -> ((C2HSImp.Ptr (CIborIndex')) -> (C2HSImp.CUInt -> ((C2HSImp.Ptr C2HSImp.CDouble) -> ((C2HSImp.Ptr (CDayCounter)) -> (C2HSImp.CInt -> (C2HSImp.CUInt -> ((C2HSImp.Ptr C2HSImp.CUInt) -> (C2HSImp.CUInt -> ((C2HSImp.Ptr C2HSImp.CDouble) -> (C2HSImp.CUInt -> ((C2HSImp.Ptr C2HSImp.CDouble) -> (C2HSImp.CUInt -> ((C2HSImp.Ptr C2HSImp.CDouble) -> (C2HSImp.CUInt -> ((C2HSImp.Ptr C2HSImp.CDouble) -> (C2HSImp.CInt -> (C2HSImp.CInt -> (C2HSImp.CInt -> ((C2HSImp.Ptr (CCalendar)) -> (C2HSImp.CInt -> (C2HSImp.CInt -> ((C2HSImp.Ptr (CCalendar)) -> (C2HSImp.CInt -> (C2HSImp.CInt -> (C2HSImp.CInt -> (C2HSImp.CInt -> ((QlStubIndexSelection) -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO (C2HSImp.Ptr (CLeg'))))))))))))))))))))))))))))))))
 4327 
 4328 foreign import ccall safe "QuantLib/CashFlow.chs.h qlCmsLeg"
 4329   cmsLeg_'_ :: ((C2HSImp.Ptr (CSchedule)) -> ((C2HSImp.Ptr (CSwapIndex')) -> (C2HSImp.CUInt -> ((C2HSImp.Ptr C2HSImp.CDouble) -> ((C2HSImp.Ptr (CDayCounter)) -> (C2HSImp.CInt -> (C2HSImp.CUInt -> ((C2HSImp.Ptr C2HSImp.CUInt) -> (C2HSImp.CUInt -> ((C2HSImp.Ptr C2HSImp.CDouble) -> (C2HSImp.CUInt -> ((C2HSImp.Ptr C2HSImp.CDouble) -> (C2HSImp.CUInt -> ((C2HSImp.Ptr C2HSImp.CDouble) -> (C2HSImp.CUInt -> ((C2HSImp.Ptr C2HSImp.CDouble) -> (C2HSImp.CInt -> (C2HSImp.CInt -> (C2HSImp.CInt -> (C2HSImp.CInt -> ((C2HSImp.Ptr (CCalendar)) -> (C2HSImp.CInt -> (C2HSImp.CInt -> (C2HSImp.CInt -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO (C2HSImp.Ptr (CLeg'))))))))))))))))))))))))))))
 4330 
 4331 foreign import ccall safe "QuantLib/CashFlow.chs.h qlOvernightLeg"
 4332   overnightLeg'_ :: ((C2HSImp.Ptr (CSchedule)) -> ((C2HSImp.Ptr (COvernightIndex')) -> (C2HSImp.CUInt -> ((C2HSImp.Ptr C2HSImp.CDouble) -> ((C2HSImp.Ptr (CDayCounter)) -> (C2HSImp.CInt -> (C2HSImp.CUInt -> ((C2HSImp.Ptr C2HSImp.CDouble) -> (C2HSImp.CUInt -> ((C2HSImp.Ptr C2HSImp.CDouble) -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO (C2HSImp.Ptr (CLeg'))))))))))))))
 4333 
 4334 foreign import ccall safe "QuantLib/CashFlow.chs.h qlRangeAccrualLeg"
 4335   rangeAccrualLeg'_ :: ((C2HSImp.Ptr (CSchedule)) -> ((C2HSImp.Ptr (CIborIndex')) -> (C2HSImp.CUInt -> ((C2HSImp.Ptr C2HSImp.CDouble) -> ((C2HSImp.Ptr (CDayCounter)) -> (C2HSImp.CInt -> (C2HSImp.CUInt -> ((C2HSImp.Ptr C2HSImp.CUInt) -> (C2HSImp.CUInt -> ((C2HSImp.Ptr C2HSImp.CDouble) -> (C2HSImp.CUInt -> ((C2HSImp.Ptr C2HSImp.CDouble) -> (C2HSImp.CUInt -> ((C2HSImp.Ptr C2HSImp.CDouble) -> (C2HSImp.CUInt -> ((C2HSImp.Ptr C2HSImp.CDouble) -> (C2HSImp.CInt -> (C2HSImp.CInt -> (C2HSImp.CInt -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO (C2HSImp.Ptr (CLeg')))))))))))))))))))))))
 4336 
 4337 foreign import ccall safe "QuantLib/CashFlow.chs.h qlCPILeg"
 4338   cpiLeg'_ :: ((C2HSImp.Ptr (CSchedule)) -> ((C2HSImp.Ptr (CZeroInflationIndex')) -> (C2HSImp.CDouble -> (C2HSImp.CInt -> (C2HSImp.CInt -> (C2HSImp.CUInt -> ((C2HSImp.Ptr C2HSImp.CDouble) -> (C2HSImp.CUInt -> ((C2HSImp.Ptr C2HSImp.CDouble) -> ((C2HSImp.Ptr (CDayCounter)) -> (C2HSImp.CInt -> ((C2HSImp.Ptr (CCalendar)) -> (C2HSImp.CInt -> (C2HSImp.CInt -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO (C2HSImp.Ptr (CLeg'))))))))))))))))))
 4339 
 4340 foreign import ccall safe "QuantLib/CashFlow.chs.h qlYoYInflationLeg"
 4341   yoyInflationLeg'_ :: ((C2HSImp.Ptr (CSchedule)) -> ((C2HSImp.Ptr (CCalendar)) -> ((C2HSImp.Ptr (CYoYInflationIndex')) -> (C2HSImp.CInt -> (C2HSImp.CInt -> (C2HSImp.CInt -> (C2HSImp.CUInt -> ((C2HSImp.Ptr C2HSImp.CDouble) -> ((C2HSImp.Ptr (CDayCounter)) -> (C2HSImp.CInt -> (C2HSImp.CUInt -> ((C2HSImp.Ptr C2HSImp.CUInt) -> (C2HSImp.CUInt -> ((C2HSImp.Ptr C2HSImp.CDouble) -> (C2HSImp.CUInt -> ((C2HSImp.Ptr C2HSImp.CDouble) -> (C2HSImp.CUInt -> ((C2HSImp.Ptr C2HSImp.CDouble) -> (C2HSImp.CUInt -> ((C2HSImp.Ptr C2HSImp.CDouble) -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO (C2HSImp.Ptr (CLeg'))))))))))))))))))))))))
 4342 
 4343 foreign import ccall safe "QuantLib/CashFlow.chs.h qlZeroInflationCashFlow"
 4344   zeroInflationCashFlow'_ :: (C2HSImp.CDouble -> ((C2HSImp.Ptr (CZeroInflationIndex')) -> (C2HSImp.CInt -> (C2HSImp.CInt -> (C2HSImp.CInt -> (C2HSImp.CInt -> (C2HSImp.CInt -> (C2HSImp.CInt -> (C2HSImp.CInt -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO (C2HSImp.Ptr (CZeroInflationCashFlow')))))))))))))
 4345 
 4346 foreign import ccall safe "QuantLib/CashFlow.chs.h qlCPICashFlow"
 4347   cpiCashFlow'_ :: (C2HSImp.CDouble -> ((C2HSImp.Ptr (CZeroInflationIndex')) -> (C2HSImp.CInt -> (C2HSImp.CDouble -> (C2HSImp.CInt -> (C2HSImp.CInt -> (C2HSImp.CInt -> (C2HSImp.CInt -> (C2HSImp.CInt -> (C2HSImp.CInt -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO (C2HSImp.Ptr (CCPICashFlow'))))))))))))))
 4348 
 4349 foreign import ccall safe "QuantLib/CashFlow.chs.h qlEquityCashFlow"
 4350   equityCashFlow'_ :: (C2HSImp.CDouble -> ((C2HSImp.Ptr (CEquityIndex')) -> (C2HSImp.CInt -> (C2HSImp.CInt -> (C2HSImp.CInt -> (C2HSImp.CInt -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO (C2HSImp.Ptr (CEquityCashFlow'))))))))))
 4351 
 4352 foreign import ccall safe "QuantLib/CashFlow.chs.h qlEquityCashFlowSetPricer"
 4353   setEquityCashFlowPricer'_ :: ((C2HSImp.Ptr (CEquityCashFlow')) -> ((C2HSImp.Ptr (CEquityCashFlowPricer)) -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO ()))))
 4354 
 4355 foreign import ccall safe "QuantLib/CashFlow.chs.h qlEquityQuantoCashFlowPricer"
 4356   equityQuantoCashFlowPricer'_ :: ((C2HSImp.Ptr (CYieldTermStructure')) -> ((C2HSImp.Ptr (CBlackVolTermStructure')) -> ((C2HSImp.Ptr (CBlackVolTermStructure')) -> ((C2HSImp.Ptr (CQuote')) -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO (C2HSImp.Ptr (CEquityCashFlowPricer))))))))
 4357 
 4358 foreign import ccall safe "QuantLib/CashFlow.chs.h qlQuantLibSetEquityCashFlowPricer"
 4359   setEquityLegPricer'_ :: ((C2HSImp.Ptr (CLeg')) -> ((C2HSImp.Ptr (CEquityCashFlowPricer)) -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO ()))))
 4360 
 4361 foreign import ccall safe "QuantLib/CashFlow.chs.h qlLegToCouponLeg"
 4362   toCouponLeg'_ :: ((C2HSImp.Ptr (CLeg')) -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO (C2HSImp.Ptr (CCouponLeg')))))
 4363 
 4364 foreign import ccall safe "QuantLib/CashFlow.chs.h qlCouponLegCoupons"
 4365   coupons'_ :: ((C2HSImp.Ptr (CCouponLeg')) -> ((C2HSImp.Ptr C2HSImp.CUInt) -> ((C2HSImp.Ptr (C2HSImp.Ptr (C2HSImp.Ptr (CCoupon')))) -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO ())))))
 4366 
 4367 foreign import ccall safe "QuantLib/CashFlow.chs.h qlBlackIborCouponPricer"
 4368   blackIborCouponPricer'_ :: ((C2HSImp.Ptr (COptionletVolatilityStructure')) -> (C2HSImp.CInt -> ((C2HSImp.Ptr (CQuote')) -> (C2HSImp.CInt -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO (C2HSImp.Ptr (CFloatingRateCouponPricer'))))))))
 4369 
 4370 foreign import ccall safe "QuantLib/CashFlow.chs.h qlBlackIborQuantoCouponPricer"
 4371   blackIborQuantoCouponPricer'_ :: ((C2HSImp.Ptr (CBlackVolTermStructure')) -> ((C2HSImp.Ptr (CQuote')) -> ((C2HSImp.Ptr (COptionletVolatilityStructure')) -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO (C2HSImp.Ptr (CFloatingRateCouponPricer')))))))
 4372 
 4373 foreign import ccall safe "QuantLib/CashFlow.chs.h qlRangeAccrualPricerByBgm"
 4374   rangeAccrualPricerByBgm'_ :: (C2HSImp.CDouble -> ((C2HSImp.Ptr (CSmileSection)) -> ((C2HSImp.Ptr (CSmileSection)) -> (C2HSImp.CInt -> (C2HSImp.CInt -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO (C2HSImp.Ptr (CFloatingRateCouponPricer')))))))))
 4375 
 4376 foreign import ccall safe "QuantLib/CashFlow.chs.h qlBlackYoYInflationCouponPricer"
 4377   blackYoyInflationCouponPricer'_ :: ((C2HSImp.Ptr (CYoYOptionletVolatilitySurface')) -> ((C2HSImp.Ptr (CYieldTermStructure')) -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO (C2HSImp.Ptr (CYoYInflationCouponPricer))))))
 4378 
 4379 foreign import ccall safe "QuantLib/CashFlow.chs.h qlUnitDisplacedBlackYoYInflationCouponPricer"
 4380   unitDisplacedBlackYoyInflationCouponPricer'_ :: ((C2HSImp.Ptr (CYoYOptionletVolatilitySurface')) -> ((C2HSImp.Ptr (CYieldTermStructure')) -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO (C2HSImp.Ptr (CYoYInflationCouponPricer))))))
 4381 
 4382 foreign import ccall safe "QuantLib/CashFlow.chs.h qlBachelierYoYInflationCouponPricer"
 4383   bachelierYoyInflationCouponPricer'_ :: ((C2HSImp.Ptr (CYoYOptionletVolatilitySurface')) -> ((C2HSImp.Ptr (CYieldTermStructure')) -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO (C2HSImp.Ptr (CYoYInflationCouponPricer))))))
 4384 
 4385 foreign import ccall safe "QuantLib/CashFlow.chs.h qlSetYoYInflationCouponPricer"
 4386   setYoyInflationCouponPricer'_ :: ((C2HSImp.Ptr (CLeg')) -> ((C2HSImp.Ptr (CYoYInflationCouponPricer)) -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO ()))))
 4387 
 4388 foreign import ccall safe "QuantLib/CashFlow.chs.h qlQuantLibSetCouponPricer"
 4389   setCouponPricer'_ :: ((C2HSImp.Ptr (CLeg')) -> ((C2HSImp.Ptr (CFloatingRateCouponPricer')) -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO ()))))
 4390 
 4391 foreign import ccall safe "QuantLib/CashFlow.chs.h qlQuantLibSetCouponPricers"
 4392   setCouponPricers'_ :: ((C2HSImp.Ptr (CLeg')) -> (C2HSImp.CUInt -> ((C2HSImp.Ptr (C2HSImp.Ptr (CFloatingRateCouponPricer'))) -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO ())))))
 4393 
 4394 foreign import ccall safe "QuantLib/CashFlow.chs.h qlFloatingRateCouponPricerSwapletRate"
 4395   swapletRate'_ :: ((C2HSImp.Ptr (CFloatingRateCouponPricer')) -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO C2HSImp.CDouble)))
 4396 
 4397 foreign import ccall safe "QuantLib/CashFlow.chs.h qlFloatingRateCouponPricerSwapletPrice"
 4398   swapletPrice'_ :: ((C2HSImp.Ptr (CFloatingRateCouponPricer')) -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO C2HSImp.CDouble)))
 4399 
 4400 foreign import ccall safe "QuantLib/CashFlow.chs.h qlFloatingRateCouponPricerCapletPrice"
 4401   capletPrice'_ :: ((C2HSImp.Ptr (CFloatingRateCouponPricer')) -> (C2HSImp.CDouble -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO C2HSImp.CDouble))))
 4402 
 4403 foreign import ccall safe "QuantLib/CashFlow.chs.h qlFloatingRateCouponPricerCapletRate"
 4404   capletRate'_ :: ((C2HSImp.Ptr (CFloatingRateCouponPricer')) -> (C2HSImp.CDouble -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO C2HSImp.CDouble))))
 4405 
 4406 foreign import ccall safe "QuantLib/CashFlow.chs.h qlFloatingRateCouponPricerFloorletPrice"
 4407   floorletPrice'_ :: ((C2HSImp.Ptr (CFloatingRateCouponPricer')) -> (C2HSImp.CDouble -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO C2HSImp.CDouble))))
 4408 
 4409 foreign import ccall safe "QuantLib/CashFlow.chs.h qlFloatingRateCouponPricerFloorletRate"
 4410   floorletRate'_ :: ((C2HSImp.Ptr (CFloatingRateCouponPricer')) -> (C2HSImp.CDouble -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO C2HSImp.CDouble))))
 4411 
 4412 foreign import ccall safe "QuantLib/CashFlow.chs.h qlCmsCoupon"
 4413   cmsCoupon'_ :: (C2HSImp.CInt -> (C2HSImp.CDouble -> (C2HSImp.CInt -> (C2HSImp.CInt -> (C2HSImp.CUInt -> ((C2HSImp.Ptr (CSwapIndex')) -> (C2HSImp.CDouble -> (C2HSImp.CDouble -> (C2HSImp.CInt -> (C2HSImp.CInt -> ((C2HSImp.Ptr (CDayCounter)) -> (C2HSImp.CInt -> (C2HSImp.CInt -> (C2HSImp.CInt -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO (C2HSImp.Ptr (CCmsCoupon'))))))))))))))))))
 4414 
 4415 foreign import ccall safe "QuantLib/CashFlow.chs.h qlCmsSpreadCoupon"
 4416   cmsSpreadCoupon'_ :: (C2HSImp.CInt -> (C2HSImp.CDouble -> (C2HSImp.CInt -> (C2HSImp.CInt -> (C2HSImp.CUInt -> ((C2HSImp.Ptr (CSwapSpreadIndex')) -> (C2HSImp.CDouble -> (C2HSImp.CDouble -> (C2HSImp.CInt -> (C2HSImp.CInt -> ((C2HSImp.Ptr (CDayCounter)) -> (C2HSImp.CInt -> (C2HSImp.CInt -> (C2HSImp.CInt -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO (C2HSImp.Ptr (CFloatingRateCoupon'))))))))))))))))))
 4417 
 4418 foreign import ccall safe "QuantLib/CashFlow.chs.h qlCouponRate"
 4419   rate'_ :: ((C2HSImp.Ptr (CCoupon')) -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO C2HSImp.CDouble)))
 4420 
 4421 foreign import ccall safe "QuantLib/CashFlow.chs.h qlCouponAccruedAmount"
 4422   couponAccruedAmount'_ :: ((C2HSImp.Ptr (CCoupon')) -> (C2HSImp.CInt -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO C2HSImp.CDouble))))
 4423 
 4424 foreign import ccall safe "QuantLib/CashFlow.chs.h qlFloatingRateCouponSetPricer"
 4425   setFloatingRateCouponPricer'_ :: ((C2HSImp.Ptr (CFloatingRateCoupon')) -> ((C2HSImp.Ptr (CFloatingRateCouponPricer')) -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO ()))))
 4426 
 4427 foreign import ccall safe "QuantLib/CashFlow.chs.h qlFloatingRateCouponPrice"
 4428   price'_ :: ((C2HSImp.Ptr (CFloatingRateCoupon')) -> ((C2HSImp.Ptr (CYieldTermStructure')) -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO C2HSImp.CDouble))))
 4429 
 4430 foreign import ccall safe "QuantLib/CashFlow.chs.h qlFloatingRateCouponConvexityAdjustment"
 4431   convexityAdjustment'_ :: ((C2HSImp.Ptr (CFloatingRateCoupon')) -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO C2HSImp.CDouble)))
 4432 
 4433 foreign import ccall safe "QuantLib/CashFlow.chs.h qlCappedFlooredCmsCoupon"
 4434   cappedFlooredCmsCoupon'_ :: (C2HSImp.CInt -> (C2HSImp.CDouble -> (C2HSImp.CInt -> (C2HSImp.CInt -> (C2HSImp.CUInt -> ((C2HSImp.Ptr (CSwapIndex')) -> (C2HSImp.CDouble -> (C2HSImp.CDouble -> (C2HSImp.CDouble -> (C2HSImp.CDouble -> (C2HSImp.CInt -> (C2HSImp.CInt -> ((C2HSImp.Ptr (CDayCounter)) -> (C2HSImp.CInt -> (C2HSImp.CInt -> (C2HSImp.CInt -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO (C2HSImp.Ptr (CFloatingRateCoupon'))))))))))))))))))))
 4435 
 4436 foreign import ccall safe "QuantLib/CashFlow.chs.h qlCappedFlooredCmsSpreadCoupon"
 4437   cappedFlooredCmsSpreadCoupon'_ :: (C2HSImp.CInt -> (C2HSImp.CDouble -> (C2HSImp.CInt -> (C2HSImp.CInt -> (C2HSImp.CUInt -> ((C2HSImp.Ptr (CSwapSpreadIndex')) -> (C2HSImp.CDouble -> (C2HSImp.CDouble -> (C2HSImp.CDouble -> (C2HSImp.CDouble -> (C2HSImp.CInt -> (C2HSImp.CInt -> ((C2HSImp.Ptr (CDayCounter)) -> (C2HSImp.CInt -> (C2HSImp.CInt -> (C2HSImp.CInt -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO (C2HSImp.Ptr (CFloatingRateCoupon'))))))))))))))))))))
 4438 
 4439 foreign import ccall safe "QuantLib/CashFlow.chs.h qlCmsSpreadLeg"
 4440   cmsSpreadLeg'_ :: ((C2HSImp.Ptr (CSchedule)) -> ((C2HSImp.Ptr (CSwapSpreadIndex')) -> (C2HSImp.CUInt -> ((C2HSImp.Ptr C2HSImp.CDouble) -> ((C2HSImp.Ptr (CDayCounter)) -> (C2HSImp.CInt -> (C2HSImp.CUInt -> ((C2HSImp.Ptr C2HSImp.CUInt) -> (C2HSImp.CUInt -> ((C2HSImp.Ptr C2HSImp.CDouble) -> (C2HSImp.CUInt -> ((C2HSImp.Ptr C2HSImp.CDouble) -> (C2HSImp.CUInt -> ((C2HSImp.Ptr C2HSImp.CDouble) -> (C2HSImp.CUInt -> ((C2HSImp.Ptr C2HSImp.CDouble) -> (C2HSImp.CInt -> (C2HSImp.CInt -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO (C2HSImp.Ptr (CLeg'))))))))))))))))))))))
 4441 
 4442 foreign import ccall safe "QuantLib/CashFlow.chs.h qlDigitalReplication"
 4443   digitalReplication'_ :: (C2HSImp.CInt -> (C2HSImp.CDouble -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO (C2HSImp.Ptr (CDigitalReplication))))))
 4444 
 4445 foreign import ccall safe "QuantLib/CashFlow.chs.h qlDigitalReplicationType"
 4446   replicationType'_ :: ((C2HSImp.Ptr (CDigitalReplication)) -> (IO C2HSImp.CInt))
 4447 
 4448 foreign import ccall safe "QuantLib/CashFlow.chs.h qlDigitalReplicationGap"
 4449   gap'_ :: ((C2HSImp.Ptr (CDigitalReplication)) -> (IO C2HSImp.CDouble))
 4450 
 4451 foreign import ccall safe "QuantLib/CashFlow.chs.h qlDigitalCmsCoupon"
 4452   digitalCmsCoupon'_ :: ((C2HSImp.Ptr (CCmsCoupon')) -> (C2HSImp.CDouble -> (C2HSImp.CInt -> (C2HSImp.CInt -> (C2HSImp.CDouble -> (C2HSImp.CDouble -> (C2HSImp.CInt -> (C2HSImp.CInt -> (C2HSImp.CDouble -> ((C2HSImp.Ptr (CDigitalReplication)) -> (C2HSImp.CInt -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO (C2HSImp.Ptr (CDigitalCmsCoupon')))))))))))))))
 4453 
 4454 foreign import ccall safe "QuantLib/CashFlow.chs.h qlDigitalCmsSpreadCoupon"
 4455   digitalCmsSpreadCoupon'_ :: (C2HSImp.CInt -> (C2HSImp.CDouble -> (C2HSImp.CInt -> (C2HSImp.CInt -> (C2HSImp.CUInt -> ((C2HSImp.Ptr (CSwapSpreadIndex')) -> (C2HSImp.CDouble -> (C2HSImp.CDouble -> (C2HSImp.CInt -> (C2HSImp.CInt -> ((C2HSImp.Ptr (CDayCounter)) -> (C2HSImp.CInt -> (C2HSImp.CInt -> (C2HSImp.CInt -> (C2HSImp.CDouble -> (C2HSImp.CInt -> (C2HSImp.CInt -> (C2HSImp.CDouble -> (C2HSImp.CDouble -> (C2HSImp.CInt -> (C2HSImp.CInt -> (C2HSImp.CDouble -> ((C2HSImp.Ptr (CDigitalReplication)) -> (C2HSImp.CInt -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO (C2HSImp.Ptr (CDigitalCmsSpreadCoupon'))))))))))))))))))))))))))))
 4456 
 4457 foreign import ccall safe "QuantLib/CashFlow.chs.h qlDigitalCmsLeg"
 4458   digitalCmsLeg_'_ :: ((C2HSImp.Ptr (CSchedule)) -> ((C2HSImp.Ptr (CSwapIndex')) -> (C2HSImp.CUInt -> ((C2HSImp.Ptr C2HSImp.CDouble) -> ((C2HSImp.Ptr (CDayCounter)) -> (C2HSImp.CInt -> (C2HSImp.CUInt -> ((C2HSImp.Ptr C2HSImp.CUInt) -> (C2HSImp.CUInt -> ((C2HSImp.Ptr C2HSImp.CDouble) -> (C2HSImp.CUInt -> ((C2HSImp.Ptr C2HSImp.CDouble) -> (C2HSImp.CInt -> (C2HSImp.CUInt -> ((C2HSImp.Ptr C2HSImp.CDouble) -> (C2HSImp.CInt -> (C2HSImp.CInt -> (C2HSImp.CUInt -> ((C2HSImp.Ptr C2HSImp.CDouble) -> (C2HSImp.CUInt -> ((C2HSImp.Ptr C2HSImp.CDouble) -> (C2HSImp.CInt -> (C2HSImp.CInt -> (C2HSImp.CUInt -> ((C2HSImp.Ptr C2HSImp.CDouble) -> ((C2HSImp.Ptr (CDigitalReplication)) -> (C2HSImp.CInt -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO (C2HSImp.Ptr (CLeg')))))))))))))))))))))))))))))))
 4459 
 4460 foreign import ccall safe "QuantLib/CashFlow.chs.h qlDigitalIborLeg"
 4461   digitalIborLeg_'_ :: ((C2HSImp.Ptr (CSchedule)) -> ((C2HSImp.Ptr (CIborIndex')) -> (C2HSImp.CUInt -> ((C2HSImp.Ptr C2HSImp.CDouble) -> ((C2HSImp.Ptr (CDayCounter)) -> (C2HSImp.CInt -> (C2HSImp.CUInt -> ((C2HSImp.Ptr C2HSImp.CUInt) -> (C2HSImp.CUInt -> ((C2HSImp.Ptr C2HSImp.CDouble) -> (C2HSImp.CUInt -> ((C2HSImp.Ptr C2HSImp.CDouble) -> (C2HSImp.CInt -> (C2HSImp.CUInt -> ((C2HSImp.Ptr C2HSImp.CDouble) -> (C2HSImp.CInt -> (C2HSImp.CInt -> (C2HSImp.CUInt -> ((C2HSImp.Ptr C2HSImp.CDouble) -> (C2HSImp.CUInt -> ((C2HSImp.Ptr C2HSImp.CDouble) -> (C2HSImp.CInt -> (C2HSImp.CInt -> (C2HSImp.CUInt -> ((C2HSImp.Ptr C2HSImp.CDouble) -> ((C2HSImp.Ptr (CDigitalReplication)) -> (C2HSImp.CInt -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO (C2HSImp.Ptr (CLeg')))))))))))))))))))))))))))))))
 4462 
 4463 foreign import ccall safe "QuantLib/CashFlow.chs.h qlDigitalCmsSpreadLeg"
 4464   digitalCmsSpreadLeg_'_ :: ((C2HSImp.Ptr (CSchedule)) -> ((C2HSImp.Ptr (CSwapSpreadIndex')) -> (C2HSImp.CUInt -> ((C2HSImp.Ptr C2HSImp.CDouble) -> ((C2HSImp.Ptr (CDayCounter)) -> (C2HSImp.CInt -> (C2HSImp.CUInt -> ((C2HSImp.Ptr C2HSImp.CUInt) -> (C2HSImp.CUInt -> ((C2HSImp.Ptr C2HSImp.CDouble) -> (C2HSImp.CUInt -> ((C2HSImp.Ptr C2HSImp.CDouble) -> (C2HSImp.CInt -> (C2HSImp.CUInt -> ((C2HSImp.Ptr C2HSImp.CDouble) -> (C2HSImp.CInt -> (C2HSImp.CInt -> (C2HSImp.CUInt -> ((C2HSImp.Ptr C2HSImp.CDouble) -> (C2HSImp.CUInt -> ((C2HSImp.Ptr C2HSImp.CDouble) -> (C2HSImp.CInt -> (C2HSImp.CInt -> (C2HSImp.CUInt -> ((C2HSImp.Ptr C2HSImp.CDouble) -> ((C2HSImp.Ptr (CDigitalReplication)) -> (C2HSImp.CInt -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO (C2HSImp.Ptr (CLeg')))))))))))))))))))))))))))))))
 4465 
 4466 foreign import ccall safe "QuantLib/CashFlow.chs.h qlMultipleResetsLeg"
 4467   multipleResetsLeg_'_ :: ((C2HSImp.Ptr (CSchedule)) -> ((C2HSImp.Ptr (CIborIndex')) -> (C2HSImp.CUInt -> (C2HSImp.CUInt -> ((C2HSImp.Ptr C2HSImp.CDouble) -> ((C2HSImp.Ptr (CDayCounter)) -> (C2HSImp.CInt -> ((C2HSImp.Ptr (CCalendar)) -> (C2HSImp.CInt -> (C2HSImp.CUInt -> ((C2HSImp.Ptr C2HSImp.CUInt) -> (C2HSImp.CUInt -> ((C2HSImp.Ptr C2HSImp.CDouble) -> (C2HSImp.CUInt -> ((C2HSImp.Ptr C2HSImp.CDouble) -> (C2HSImp.CUInt -> ((C2HSImp.Ptr C2HSImp.CDouble) -> (C2HSImp.CInt -> (C2HSImp.CInt -> ((C2HSImp.Ptr (CCalendar)) -> (C2HSImp.CInt -> (C2HSImp.CInt -> (C2HSImp.CInt -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO (C2HSImp.Ptr (CLeg')))))))))))))))))))))))))))
 4468 
 4469 foreign import ccall safe "QuantLib/CashFlow.chs.h qlAnalyticHaganPricer"
 4470   analyticHaganPricer'_ :: ((C2HSImp.Ptr (CSwaptionVolatilityStructure')) -> (C2HSImp.CInt -> ((C2HSImp.Ptr (CQuote')) -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO (C2HSImp.Ptr (CCmsCouponPricer')))))))
 4471 
 4472 foreign import ccall safe "QuantLib/CashFlow.chs.h qlNumericHaganPricer"
 4473   numericHaganPricer'_ :: ((C2HSImp.Ptr (CSwaptionVolatilityStructure')) -> (C2HSImp.CInt -> ((C2HSImp.Ptr (CQuote')) -> (C2HSImp.CDouble -> (C2HSImp.CDouble -> (C2HSImp.CDouble -> (C2HSImp.CDouble -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO (C2HSImp.Ptr (CCmsCouponPricer')))))))))))
 4474 
 4475 foreign import ccall safe "QuantLib/CashFlow.chs.h qlLinearTsrPricer"
 4476   linearTsrPricer_'_ :: ((C2HSImp.Ptr (CSwaptionVolatilityStructure')) -> ((C2HSImp.Ptr (CQuote')) -> ((C2HSImp.Ptr (CYieldTermStructure')) -> (C2HSImp.CInt -> (C2HSImp.CDouble -> (C2HSImp.CInt -> (C2HSImp.CDouble -> (C2HSImp.CDouble -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO (C2HSImp.Ptr (CCmsCouponPricer'))))))))))))
 4477 
 4478 foreign import ccall safe "QuantLib/CashFlow.chs.h qlLognormalCmsSpreadPricer"
 4479   lognormalCmsSpreadPricer_'_ :: ((C2HSImp.Ptr (CCmsCouponPricer')) -> ((C2HSImp.Ptr (CQuote')) -> ((C2HSImp.Ptr (CYieldTermStructure')) -> (C2HSImp.CUInt -> (C2HSImp.CInt -> (C2HSImp.CInt -> (C2HSImp.CDouble -> (C2HSImp.CDouble -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO (C2HSImp.Ptr (CFloatingRateCouponPricer'))))))))))))
 4480 
 4481 foreign import ccall safe "QuantLib/CashFlow.chs.h qlLegFixingDependencies"
 4482   qlLegFixingDependencies'_ :: ((C2HSImp.Ptr (CLeg')) -> ((C2HSImp.Ptr C2HSImp.CUInt) -> ((C2HSImp.Ptr (C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar))) -> ((C2HSImp.Ptr C2HSImp.CUInt) -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CInt)) -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO ())))))))
 4483 
 4484 foreign import ccall safe "QuantLib/CashFlow.chs.h qlFxResetConventionReset"
 4485   fxResetObservationRaw'_ :: (C2HSImp.CUInt -> ((C2HSImp.Ptr (CCalendar)) -> (C2HSImp.CInt -> ((C2HSImp.Ptr C2HSImp.CInt) -> ((C2HSImp.Ptr C2HSImp.CInt) -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO ())))))))
 4486 
 4487 foreign import ccall safe "QuantLib/CashFlow.chs.h qlFxResetConventionValueDate"
 4488   fxResetValueDateRaw'_ :: (C2HSImp.CUInt -> ((C2HSImp.Ptr (CCalendar)) -> (C2HSImp.CInt -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO C2HSImp.CInt)))))
 4489 
 4490 foreign import ccall safe "QuantLib/CashFlow.chs.h qlDiscountingFxResetPricer"
 4491   discountingFxResetPricer'_ :: ((C2HSImp.Ptr (CCurrency)) -> ((C2HSImp.Ptr (CCurrency)) -> ((C2HSImp.Ptr (CYieldTermStructure')) -> ((C2HSImp.Ptr (CYieldTermStructure')) -> ((C2HSImp.Ptr (CQuote')) -> (C2HSImp.CInt -> (C2HSImp.CInt -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO (C2HSImp.Ptr (CFxResetPricer)))))))))))
 4492 
 4493 foreign import ccall safe "QuantLib/CashFlow.chs.h qlFxResetRate"
 4494   fxResetRate'_ :: ((C2HSImp.Ptr (CFxResetPricer)) -> (C2HSImp.CInt -> (C2HSImp.CInt -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO C2HSImp.CDouble)))))
 4495 
 4496 foreign import ccall safe "QuantLib/CashFlow.chs.h qlFxResetCoupon"
 4497   fxResetCoupon'_ :: ((C2HSImp.Ptr (CFloatingRateCoupon')) -> (C2HSImp.CDouble -> (C2HSImp.CInt -> (C2HSImp.CInt -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO (C2HSImp.Ptr (CFxResetCoupon'))))))))
 4498 
 4499 foreign import ccall safe "QuantLib/CashFlow.chs.h qlFxResetNotionalExchange"
 4500   fxResetNotionalExchange'_ :: (C2HSImp.CInt -> (C2HSImp.CDouble -> (C2HSImp.CInt -> (C2HSImp.CInt -> (C2HSImp.CInt -> (C2HSImp.CInt -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO (C2HSImp.Ptr (CFxResetNotionalExchange'))))))))))
 4501 
 4502 foreign import ccall safe "QuantLib/CashFlow.chs.h qlFxResetCouponSetFxResetPricer"
 4503   setFxResetCouponPricerRaw'_ :: ((C2HSImp.Ptr (CFxResetCoupon')) -> ((C2HSImp.Ptr (CFxResetPricer)) -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO ()))))
 4504 
 4505 foreign import ccall safe "QuantLib/CashFlow.chs.h qlFxResetNotionalExchangeSetFxResetPricer"
 4506   setFxResetNotionalExchangePricerRaw'_ :: ((C2HSImp.Ptr (CFxResetNotionalExchange')) -> ((C2HSImp.Ptr (CFxResetPricer)) -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO ()))))
 4507 
 4508 foreign import ccall safe "QuantLib/CashFlow.chs.h qlSetFxResetLegPricer"
 4509   setFxResetLegPricer'_ :: ((C2HSImp.Ptr (CLeg')) -> ((C2HSImp.Ptr (CFxResetPricer)) -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO ()))))
 4510 
 4511 foreign import ccall safe "QuantLib/CashFlow.chs.h qlStubIborCoupon"
 4512   stubIborCoupon'_ :: (C2HSImp.CInt -> (C2HSImp.CDouble -> (C2HSImp.CInt -> (C2HSImp.CInt -> (C2HSImp.CUInt -> ((QlStubIndexSelection) -> (C2HSImp.CDouble -> (C2HSImp.CDouble -> (C2HSImp.CInt -> (C2HSImp.CInt -> ((C2HSImp.Ptr (CDayCounter)) -> (C2HSImp.CInt -> (C2HSImp.CInt -> (C2HSImp.CInt -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO (C2HSImp.Ptr (CIborCoupon'))))))))))))))))))
 4513 
 4514 foreign import ccall safe "QuantLib/CashFlow.chs.h qlCouponNominal"
 4515   couponNominal'_ :: ((C2HSImp.Ptr (CCoupon')) -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO C2HSImp.CDouble)))