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 #-}
    6 module QuantLib.CashFlow
    7   (
    8     Leg
    9   , CouponLeg
   10   , asLeg
   11   , Dividend
   12   , DurationType(..)
   13   , RateAveragingType(..)
   14   , TimingAdjustment(..)
   15   , CPIInterpolationType(..)
   16   , GenLeg
   17 
   18   , leg
   19   , startDate
   20   , nextCashFlows
   21   , previousCashFlows
   22   , cashFlows
   23 
   24   , duration
   25   , accrualDays
   26   , accrualEndDate
   27   , accrualPeriod
   28   , accrualStartDate
   29   , accruedAmount
   30   , accruedDays
   31   , accruedPeriod
   32   , atmRate
   33   , basisPointValue'
   34   , basisPointValue
   35   , bpsFromYield
   36   , bpsFromYield'
   37   , bps
   38   , convexity'
   39   , convexity
   40   , duration'
   41   , isExpired
   42   , maturityDate
   43   , nextCashFlowAmount
   44   , nextCashFlowDate
   45   , nextCouponRate
   46   , nominal
   47   , npvFromYield
   48   , npvFromYield'
   49   , npv'
   50   , npv
   51   , npvbps
   52   , previousCashFlowAmount
   53   , previousCashFlowDate
   54   , previousCouponRate
   55   , referencePeriodEnd
   56   , referencePeriodStart
   57   , yield
   58   , yieldValueBasisPoint'
   59   , yieldValueBasisPoint
   60   , zSpread
   61 
   62   , toCouponLeg
   63   , couponAccrualStartDates
   64 
   65   , fixedDividend
   66   , fractionalDividend'
   67   , fractionalDividend
   68 
   69   , averageBMALeg
   70   , fixedRateLeg
   71   , iborLeg
   72   , iborLegFull
   73   , IborLegOpts(..)
   74   , defaultIborLegOpts
   75   , cmsLeg
   76   , cmsLegFull
   77   , CmsLegOpts(..)
   78   , defaultCmsLegOpts
   79   , overnightLeg
   80   , rangeAccrualLeg
   81   , cpiLeg
   82   , yoyInflationLeg
   83   , YoYInflationCouponPricer
   84   , blackYoYInflationCouponPricer
   85   , unitDisplacedBlackYoYInflationCouponPricer
   86   , bachelierYoYInflationCouponPricer
   87   , setYoYInflationCouponPricer
   88   , ZeroInflationCashFlow
   89   , zeroInflationCashFlow
   90   , zeroInflationCashFlowAmount
   91   , zeroInflationCashFlowBaseFixing
   92   , zeroInflationCashFlowIndexFixing
   93   , CPICashFlow
   94   , cpiCashFlow
   95   , cpiCashFlowAmount
   96   , cpiCashFlowBaseFixing
   97   , cpiCashFlowIndexFixing
   98   , EquityCashFlow
   99   , equityCashFlow
  100   , equityCashFlowAmount
  101   , equityCashFlowBaseFixing
  102   , equityCashFlowIndexFixing
  103   , setEquityCashFlowPricer
  104   , YieldCurveModel(..)
  105 
  106   , FloatingRateCouponPricer
  107   , blackIborCouponPricer
  108   , rangeAccrualPricerByBgm
  109   , setCouponPricer
  110   , setCouponPricers
  111   , analyticHaganPricer
  112   , numericHaganPricer
  113   , LinearTsrPricerStrategy(..)
  114   , LinearTsrPricerSettings(..)
  115   , linearTsrPricer
  116   , EquityCashFlowPricer
  117   , equityQuantoCashFlowPricer
  118   , setEquityLegPricer
  119   ) where
  120 import qualified Foreign.C.Types as C2HSImp
  121 import qualified Foreign.ForeignPtr as C2HSImp
  122 import qualified Foreign.Marshal.Utils as C2HSImp
  123 import qualified Foreign.Ptr as C2HSImp
  124 
  125 
  126 import QuantLib.Internal
  127 import QuantLib.InterestRate(Compounding)
  128 import QuantLib.Time.Schedule(Frequency)
  129 import QuantLib.Time.Calendar(calendar, CalendarConstructor(..))
  130 import QuantLib.Internal.Type
  131 import QuantLib.Internal.Common
  132 import QuantLib.Internal.Syntax(deriveOptionsRecord)
  133 import Data.Maybe(fromMaybe)
  134 
  135 
  136 
  137 
  138 
  139 
  140 
  141 
  142 
  143 
  144 
  145 
  146 
  147 
  148 
  149 
  150 
  151 
  152 
  153 
  154 
  155 
  156 
  157 
  158 
  159 
  160 
  161 
  162 
  163 
  164 
  165 
  166 
  167 
  168 
  169 
  170 
  171 
  172 
  173 
  174 
  175 
  176 data DurationType = Simple
  177                   | Macaulay
  178                   | Modified
  179   deriving (Enum,Show,Eq,Read)
  180 
  181 
  182 data RateAveragingType = AveragingSimple
  183                        | AveragingCompound
  184   deriving (Enum,Show,Eq,Read)
  185 
  186 
  187 data TimingAdjustment = Black76
  188                       | BivariateLognormal
  189   deriving (Enum,Show,Eq,Read)
  190 
  191 
  192 
  193 -- IborLegOpts/CmsLegOpts bundle every IborLeg/CmsLeg builder-method param beyond
  194 -- iborLeg/cmsLeg's original 12-arg shape, pre-populated with upstream's own defaults via
  195 -- defaultIborLegOpts/defaultCmsLegOpts, overridden through record-update syntax at the
  196 -- call site -- see OISRateHelperOpts (QuantLib.TermStructure.Yield) for the worked
  197 -- example this follows. The Calendar fields are Maybe here (unlike the raw bindings'
  198 -- plain Calendar) since a real Calendar is only obtainable in IO (`calendar Null`) and
  199 -- can't live in a pure default record value -- iborLegFull/cmsLegFull substitute a fresh
  200 -- Null calendar for Nothing. This splice must stay textually before every
  201 -- {#fun#}-generated binding in this file: c2hs always appends its raw foreign-import
  202 -- stubs at the physical end of the generated module regardless of where in the .chs a
  203 -- {#fun#} hook appears, and a top-level TH splice anywhere in between would otherwise
  204 -- split the file into declaration groups that can't see each other, breaking every
  205 -- earlier {#fun#} wrapper's reference to its own (always-last) foreign-import stub.
  206 $(deriveOptionsRecord "IborLegOpts" []
  207   [ ("ilgPaymentLag", [t|Int|], [|0|])
  208   , ("ilgPaymentCalendar", [t|Maybe Calendar|], [|Nothing|])
  209   , ("ilgExCouponPeriod", [t|(Int, TimeUnit)|], [|(0, Days)|])
  210   , ("ilgExCouponCalendar", [t|Maybe Calendar|], [|Nothing|])
  211   , ("ilgExCouponConvention", [t|BusinessDayConvention|], [|Unadjusted|])
  212   , ("ilgExCouponEndOfMonth", [t|Bool|], [|False|])
  213   , ("ilgFixingConvention", [t|BusinessDayConvention|], [|Preceding|])
  214   , ("ilgUseIndexedCoupons", [t|Maybe Bool|], [|Nothing|])
  215   ])
  216 
  217 -- Same shape as IborLegOpts, minus the fields CmsLeg's builder doesn't have
  218 -- (withPaymentLag/withPaymentCalendar/withIndexedCoupons -- confirmed absent from
  219 -- ql/cashflows/cmscoupon.hpp's CmsLeg). Same splice-placement constraint as above.
  220 $(deriveOptionsRecord "CmsLegOpts" []
  221   [ ("cmslExCouponPeriod", [t|(Int, TimeUnit)|], [|(0, Days)|])
  222   , ("cmslExCouponCalendar", [t|Maybe Calendar|], [|Nothing|])
  223   , ("cmslExCouponConvention", [t|BusinessDayConvention|], [|Unadjusted|])
  224   , ("cmslExCouponEndOfMonth", [t|Bool|], [|False|])
  225   , ("cmslFixingConvention", [t|BusinessDayConvention|], [|Preceding|])
  226   ])
  227 
  228 -- |Build a 'Leg' of plain, predetermined cash flows from parallel amount\/date arrays.
  229 qlLeg :: ([Double]) -> ([Day]) -> IO ((Leg))
  230 qlLeg a1 a2 =
  231   withDoubleArray a1 $ \(a1'1, a1'2) -> 
  232   withDayPtr a2 $ \a2' -> 
  233   preErrorCheck $ \a3' -> 
  234   qlLeg'_ a1'1  a1'2 a2' a3' >>= \res ->
  235   peekLeg res >>= \res' ->
  236   errorCheck  a3'>>
  237   return (res')
  238 
  239 
  240 
  241 leg :: [(Day, Double)] -- ^amounts and dates
  242   -> IO Leg
  243 leg f = qlLeg fs ds where (ds, fs) = unzip f
  244 
  245 -- |Returns the start (i.e. first accrual) date for the given Leg
  246 startDate :: (GenLeg l) -> IO ((Day))
  247 startDate a1 =
  248   withLeg a1 $ \a1' -> 
  249   preErrorCheck $ \a2' -> 
  250   startDate'_ a1' a2' >>= \res ->
  251   let {res' = toDay res} in
  252   errorCheck  a2'>>
  253   return (res')
  254 
  255 
  256 
  257 -- |return cashflows that will occur after /settlementDate/
  258 nextCashFlows :: (GenLeg l) -> (Bool) -- ^includeSettlementDateFlows
  259  -> (Maybe Day) -- ^settlementDate
  260  -> IO ((Leg))
  261 nextCashFlows a1 a2 a3 =
  262   withLeg a1 $ \a1' -> 
  263   let {a2' = C2HSImp.fromBool a2} in 
  264   withMaybeDay a3 $ \a3' -> 
  265   preErrorCheck $ \a4' -> 
  266   nextCashFlows'_ a1' a2' a3' a4' >>= \res ->
  267   peekLeg res >>= \res' ->
  268   errorCheck  a4'>>
  269   return (res')
  270 
  271 
  272 
  273 -- |return cashflows that occurred before /settlementDate/
  274 previousCashFlows :: (GenLeg l) -> (Bool) -- ^includeSettlementDateFlows
  275  -> (Maybe Day) -- ^settlementDate
  276  -> IO ((Leg))
  277 previousCashFlows a1 a2 a3 =
  278   withLeg a1 $ \a1' -> 
  279   let {a2' = C2HSImp.fromBool a2} in 
  280   withMaybeDay a3 $ \a3' -> 
  281   preErrorCheck $ \a4' -> 
  282   previousCashFlows'_ a1' a2' a3' a4' >>= \res ->
  283   peekLeg res >>= \res' ->
  284   errorCheck  a4'>>
  285   return (res')
  286 
  287 
  288 
  289 -- |Raw binding for 'cashFlows': dates, amounts, and whether each has occurred as of /settlementDate/.
  290 qlLegCashFlows :: (GenLeg l) -> (Maybe Bool) -- ^includeSettlementDateFlows
  291  -> (Maybe Day) -- ^settlementDate
  292  -> IO (([Double]), ([Day]), ([Bool]))
  293 qlLegCashFlows a1 a2 a3 =
  294   withLeg a1 $ \a1' -> 
  295   let {a2' = fromMaybeBool a2} in 
  296   withMaybeDay a3 $ \a3' -> 
  297   preArray $ \(a4'1, a4'2) -> 
  298   preArray $ \(a5'1, a5'2) -> 
  299   preArray $ \(a6'1, a6'2) -> 
  300   preErrorCheck $ \a7' -> 
  301   qlLegCashFlows'_ a1' a2' a3' a4'1  a4'2 a5'1  a5'2 a6'1  a6'2 a7' >>
  302   peekDoubleArray  a4'1  a4'2>>= \a4'' -> 
  303   peekDayArray  a5'1  a5'2>>= \a5'' -> 
  304   peekBoolArray  a6'1  a6'2>>= \a6'' -> 
  305   errorCheck  a7'>>
  306   return (a4'', a5'', a6'')
  307 
  308 
  309 
  310 -- |return cash flows together with an indicator whether they occurred as of /settlementDate/
  311 cashFlows :: Leg
  312   -> Maybe Bool -- ^includeSettlementDateFlows
  313   -> Maybe Day -- ^settlementDate
  314   -> IO [(Day, Double, Bool)] -- ^date, amount, hasOccurred
  315 cashFlows l i d = do{(as, ds, hs) <- qlLegCashFlows l i d; return $ zip3 ds as hs}
  316 
  317 -- |Cash-flow duration.
  318 -- 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.
  319 duration :: (GenLeg l) -> (InterestRate) -- ^yield
  320  -> (DurationType) -> (Bool) -- ^includeSettlementDateFlows
  321  -> (Maybe Day) -- ^settlementDate
  322  -> (Maybe Day) -- ^npvDate
  323  -> IO ((Double))
  324 duration a1 a2 a3 a4 a5 a6 =
  325   withLeg a1 $ \a1' -> 
  326   withInterestRate a2 $ \a2' -> 
  327   let {a3' = (fromIntegral . fromEnum) a3} in 
  328   let {a4' = C2HSImp.fromBool a4} in 
  329   withMaybeDay a5 $ \a5' -> 
  330   withMaybeDay a6 $ \a6' -> 
  331   preErrorCheck $ \a7' -> 
  332   duration'_ a1' a2' a3' a4' a5' a6' a7' >>= \res ->
  333   let {res' = realToFrac res} in
  334   errorCheck  a7'>>
  335   return (res')
  336 
  337 
  338 
  339 -- |Number of days in the accrual period of the coupon paying on /settlementDate/.
  340 accrualDays :: (GenLeg l) -> (Bool) -- ^includeSettlementDateFlows
  341  -> (Maybe Day) -- ^settlementDate
  342  -> IO ((Int))
  343 accrualDays a1 a2 a3 =
  344   withLeg a1 $ \a1' -> 
  345   let {a2' = C2HSImp.fromBool a2} in 
  346   withMaybeDay a3 $ \a3' -> 
  347   preErrorCheck $ \a4' -> 
  348   accrualDays'_ a1' a2' a3' a4' >>= \res ->
  349   let {res' = fromIntegral res} in
  350   errorCheck  a4'>>
  351   return (res')
  352 
  353 
  354 
  355 -- |End of the accrual period of the coupon paying on /settlementDate/.
  356 accrualEndDate :: (GenLeg l) -> (Bool) -- ^includeSettlementDateFlows
  357  -> (Maybe Day) -- ^settlementDate
  358  -> IO ((Maybe Day))
  359 accrualEndDate a1 a2 a3 =
  360   withLeg a1 $ \a1' -> 
  361   let {a2' = C2HSImp.fromBool a2} in 
  362   withMaybeDay a3 $ \a3' -> 
  363   preErrorCheck $ \a4' -> 
  364   accrualEndDate'_ a1' a2' a3' a4' >>= \res ->
  365   let {res' = toMaybeDay res} in
  366   errorCheck  a4'>>
  367   return (res')
  368 
  369 
  370 
  371 -- |Length, in years, of the accrual period of the coupon paying on /settlementDate/.
  372 accrualPeriod :: (GenLeg l) -> (Bool) -- ^includeSettlementDateFlows
  373  -> (Maybe Day) -- ^settlementDate
  374  -> IO ((Double))
  375 accrualPeriod a1 a2 a3 =
  376   withLeg a1 $ \a1' -> 
  377   let {a2' = C2HSImp.fromBool a2} in 
  378   withMaybeDay a3 $ \a3' -> 
  379   preErrorCheck $ \a4' -> 
  380   accrualPeriod'_ a1' a2' a3' a4' >>= \res ->
  381   let {res' = realToFrac res} in
  382   errorCheck  a4'>>
  383   return (res')
  384 
  385 
  386 
  387 -- |Start of the accrual period of the coupon paying on /settlementDate/.
  388 accrualStartDate :: (GenLeg l) -> (Bool) -- ^includeSettlementDateFlows
  389  -> (Maybe Day) -- ^settlementDate
  390  -> IO ((Maybe Day))
  391 accrualStartDate a1 a2 a3 =
  392   withLeg a1 $ \a1' -> 
  393   let {a2' = C2HSImp.fromBool a2} in 
  394   withMaybeDay a3 $ \a3' -> 
  395   preErrorCheck $ \a4' -> 
  396   accrualStartDate'_ a1' a2' a3' a4' >>= \res ->
  397   let {res' = toMaybeDay res} in
  398   errorCheck  a4'>>
  399   return (res')
  400 
  401 
  402 
  403 -- |Accrued amount of the coupon paying on /settlementDate/.
  404 accruedAmount :: (GenLeg l) -> (Bool) -- ^includeSettlementDateFlows
  405  -> (Maybe Day) -- ^settlementDate
  406  -> IO ((Double))
  407 accruedAmount a1 a2 a3 =
  408   withLeg a1 $ \a1' -> 
  409   let {a2' = C2HSImp.fromBool a2} in 
  410   withMaybeDay a3 $ \a3' -> 
  411   preErrorCheck $ \a4' -> 
  412   accruedAmount'_ a1' a2' a3' a4' >>= \res ->
  413   let {res' = realToFrac res} in
  414   errorCheck  a4'>>
  415   return (res')
  416 
  417 
  418 
  419 -- |Number of days accrued so far on the coupon paying on /settlementDate/.
  420 accruedDays :: (GenLeg l) -> (Bool) -- ^includeSettlementDateFlows
  421  -> (Maybe Day) -- ^settlementDate
  422  -> IO ((Int))
  423 accruedDays a1 a2 a3 =
  424   withLeg a1 $ \a1' -> 
  425   let {a2' = C2HSImp.fromBool a2} in 
  426   withMaybeDay a3 $ \a3' -> 
  427   preErrorCheck $ \a4' -> 
  428   accruedDays'_ a1' a2' a3' a4' >>= \res ->
  429   let {res' = fromIntegral res} in
  430   errorCheck  a4'>>
  431   return (res')
  432 
  433 
  434 
  435 -- |Fraction of the accrual period elapsed, as of /settlementDate/, for the coupon paying then.
  436 accruedPeriod :: (GenLeg l) -> (Bool) -- ^includeSettlementDateFlows
  437  -> (Maybe Day) -- ^settlementDate
  438  -> IO ((Double))
  439 accruedPeriod a1 a2 a3 =
  440   withLeg a1 $ \a1' -> 
  441   let {a2' = C2HSImp.fromBool a2} in 
  442   withMaybeDay a3 $ \a3' -> 
  443   preErrorCheck $ \a4' -> 
  444   accruedPeriod'_ a1' a2' a3' a4' >>= \res ->
  445   let {res' = realToFrac res} in
  446   errorCheck  a4'>>
  447   return (res')
  448 
  449 
  450 
  451 -- |Basis-point value, as 'basisPointValue'' but taking a plain yield\/day counter\/compounding\/frequency
  452 -- instead of an 'InterestRate'.
  453 basisPointValue :: (GenLeg l) -> (Double) -> (DayCounter) -> (Compounding) -> (Frequency) -> (Bool) -- ^includeSettlementDateFlows
  454  -> (Maybe Day) -- ^settlementDate
  455  -> (Maybe Day) -- ^npvDate
  456  -> IO ((Double))
  457 basisPointValue a1 a2 a3 a4 a5 a6 a7 a8 =
  458   withLeg a1 $ \a1' -> 
  459   let {a2' = realToFrac a2} in 
  460   withDayCounter a3 $ \a3' -> 
  461   let {a4' = (fromIntegral . fromEnum) a4} in 
  462   let {a5' = (fromIntegral . fromEnum) a5} in 
  463   let {a6' = C2HSImp.fromBool a6} in 
  464   withMaybeDay a7 $ \a7' -> 
  465   withMaybeDay a8 $ \a8' -> 
  466   preErrorCheck $ \a9' -> 
  467   basisPointValue'_ a1' a2' a3' a4' a5' a6' a7' a8' a9' >>= \res ->
  468   let {res' = realToFrac res} in
  469   errorCheck  a9'>>
  470   return (res')
  471 
  472 
  473 
  474 -- |Basis-point value.
  475 -- Obtained by setting dy = 0.0001 in the 2nd-order Taylor series expansion.
  476 basisPointValue' :: (GenLeg l) -> (InterestRate) -> (Bool) -- ^includeSettlementDateFlows
  477  -> (Maybe Day) -- ^settlementDate
  478  -> (Maybe Day) -- ^npvDate
  479  -> IO ((Double))
  480 basisPointValue' a1 a2 a3 a4 a5 =
  481   withLeg a1 $ \a1' -> 
  482   withInterestRate a2 $ \a2' -> 
  483   let {a3' = C2HSImp.fromBool a3} in 
  484   withMaybeDay a4 $ \a4' -> 
  485   withMaybeDay a5 $ \a5' -> 
  486   preErrorCheck $ \a6' -> 
  487   basisPointValue''_ a1' a2' a3' a4' a5' a6' >>= \res ->
  488   let {res' = realToFrac res} in
  489   errorCheck  a6'>>
  490   return (res')
  491 
  492 
  493 
  494 -- |Basis-point sensitivity of the cash flows.
  495 -- 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.
  496 bpsFromYield' :: (GenLeg l) -> (InterestRate) -> (Bool) -- ^includeSettlementDateFlows
  497  -> (Maybe Day) -- ^settlementDate
  498  -> (Maybe Day) -- ^npvDate
  499  -> IO ((Double))
  500 bpsFromYield' a1 a2 a3 a4 a5 =
  501   withLeg a1 $ \a1' -> 
  502   withInterestRate a2 $ \a2' -> 
  503   let {a3' = C2HSImp.fromBool a3} in 
  504   withMaybeDay a4 $ \a4' -> 
  505   withMaybeDay a5 $ \a5' -> 
  506   preErrorCheck $ \a6' -> 
  507   bpsFromYield''_ a1' a2' a3' a4' a5' a6' >>= \res ->
  508   let {res' = realToFrac res} in
  509   errorCheck  a6'>>
  510   return (res')
  511 
  512 
  513 
  514 -- |Basis-point sensitivity, as 'bpsFromYield'' but taking a plain yield\/day counter\/compounding\/frequency
  515 -- instead of an 'InterestRate'.
  516 bpsFromYield :: (GenLeg l) -> (Double) -> (DayCounter) -> (Compounding) -> (Frequency) -> (Bool) -- ^includeSettlementDateFlows
  517  -> (Maybe Day) -- ^settlementDate
  518  -> (Maybe Day) -- ^npvDate
  519  -> IO ((Double))
  520 bpsFromYield a1 a2 a3 a4 a5 a6 a7 a8 =
  521   withLeg a1 $ \a1' -> 
  522   let {a2' = realToFrac a2} in 
  523   withDayCounter a3 $ \a3' -> 
  524   let {a4' = (fromIntegral . fromEnum) a4} in 
  525   let {a5' = (fromIntegral . fromEnum) a5} in 
  526   let {a6' = C2HSImp.fromBool a6} in 
  527   withMaybeDay a7 $ \a7' -> 
  528   withMaybeDay a8 $ \a8' -> 
  529   preErrorCheck $ \a9' -> 
  530   bpsFromYield'_ a1' a2' a3' a4' a5' a6' a7' a8' a9' >>= \res ->
  531   let {res' = realToFrac res} in
  532   errorCheck  a9'>>
  533   return (res')
  534 
  535 
  536 
  537 -- |Cash-flow convexity, as 'convexity'' but taking a plain yield\/day counter\/compounding\/frequency
  538 -- instead of an 'InterestRate'.
  539 convexity :: (GenLeg l) -> (Double) -> (DayCounter) -> (Compounding) -> (Frequency) -> (Bool) -- ^includeSettlementDateFlows
  540  -> (Maybe Day) -- ^settlementDate
  541  -> (Maybe Day) -- ^npvDate
  542  -> IO ((Double))
  543 convexity a1 a2 a3 a4 a5 a6 a7 a8 =
  544   withLeg a1 $ \a1' -> 
  545   let {a2' = realToFrac a2} in 
  546   withDayCounter a3 $ \a3' -> 
  547   let {a4' = (fromIntegral . fromEnum) a4} in 
  548   let {a5' = (fromIntegral . fromEnum) a5} in 
  549   let {a6' = C2HSImp.fromBool a6} in 
  550   withMaybeDay a7 $ \a7' -> 
  551   withMaybeDay a8 $ \a8' -> 
  552   preErrorCheck $ \a9' -> 
  553   convexity'_ a1' a2' a3' a4' a5' a6' a7' a8' a9' >>= \res ->
  554   let {res' = realToFrac res} in
  555   errorCheck  a9'>>
  556   return (res')
  557 
  558 
  559 
  560 -- |Cash-flow convexity.
  561 -- 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 $.
  562 convexity' :: (GenLeg l) -> (InterestRate) -> (Bool) -- ^includeSettlementDateFlows
  563  -> (Maybe Day) -- ^settlementDate
  564  -> (Maybe Day) -- ^npvDate
  565  -> IO ((Double))
  566 convexity' a1 a2 a3 a4 a5 =
  567   withLeg a1 $ \a1' -> 
  568   withInterestRate a2 $ \a2' -> 
  569   let {a3' = C2HSImp.fromBool a3} in 
  570   withMaybeDay a4 $ \a4' -> 
  571   withMaybeDay a5 $ \a5' -> 
  572   preErrorCheck $ \a6' -> 
  573   convexity''_ a1' a2' a3' a4' a5' a6' >>= \res ->
  574   let {res' = realToFrac res} in
  575   errorCheck  a6'>>
  576   return (res')
  577 
  578 
  579 
  580 -- |Cash-flow duration, as 'duration' but taking a plain yield\/day counter\/compounding\/frequency
  581 -- instead of an 'InterestRate'.
  582 duration' :: (GenLeg l) -> (Double) -> (DayCounter) -> (Compounding) -> (Frequency) -> (DurationType) -> (Bool) -- ^includeSettlementDateFlows
  583  -> (Maybe Day) -- ^settlementDate
  584  -> (Maybe Day) -- ^npvDate
  585  -> IO ((Double))
  586 duration' a1 a2 a3 a4 a5 a6 a7 a8 a9 =
  587   withLeg a1 $ \a1' -> 
  588   let {a2' = realToFrac a2} in 
  589   withDayCounter a3 $ \a3' -> 
  590   let {a4' = (fromIntegral . fromEnum) a4} in 
  591   let {a5' = (fromIntegral . fromEnum) a5} in 
  592   let {a6' = (fromIntegral . fromEnum) a6} in 
  593   let {a7' = C2HSImp.fromBool a7} in 
  594   withMaybeDay a8 $ \a8' -> 
  595   withMaybeDay a9 $ \a9' -> 
  596   preErrorCheck $ \a10' -> 
  597   duration''_ a1' a2' a3' a4' a5' a6' a7' a8' a9' a10' >>= \res ->
  598   let {res' = realToFrac res} in
  599   errorCheck  a10'>>
  600   return (res')
  601 
  602 
  603 
  604 -- |Whether every cash flow in the leg has occurred as of /settlementDate/.
  605 isExpired :: (GenLeg l) -> (Bool) -- ^includeSettlementDateFlows
  606  -> (Maybe Day) -- ^settlementDate
  607  -> IO ((Bool))
  608 isExpired a1 a2 a3 =
  609   withLeg a1 $ \a1' -> 
  610   let {a2' = C2HSImp.fromBool a2} in 
  611   withMaybeDay a3 $ \a3' -> 
  612   preErrorCheck $ \a4' -> 
  613   isExpired'_ a1' a2' a3' a4' >>= \res ->
  614   let {res' = C2HSImp.toBool res} in
  615   errorCheck  a4'>>
  616   return (res')
  617 
  618 
  619 
  620 -- |Date of the leg's last cash flow.
  621 maturityDate :: (GenLeg l) -> IO ((Day))
  622 maturityDate a1 =
  623   withLeg a1 $ \a1' -> 
  624   preErrorCheck $ \a2' -> 
  625   maturityDate'_ a1' a2' >>= \res ->
  626   let {res' = toDay res} in
  627   errorCheck  a2'>>
  628   return (res')
  629 
  630 
  631 
  632 -- |Amount of the first cash flow paying after /settlementDate/.
  633 nextCashFlowAmount :: (GenLeg l) -> (Bool) -- ^includeSettlementDateFlows
  634  -> (Maybe Day) -- ^settlementDate
  635  -> IO ((Double))
  636 nextCashFlowAmount a1 a2 a3 =
  637   withLeg a1 $ \a1' -> 
  638   let {a2' = C2HSImp.fromBool a2} in 
  639   withMaybeDay a3 $ \a3' -> 
  640   preErrorCheck $ \a4' -> 
  641   nextCashFlowAmount'_ a1' a2' a3' a4' >>= \res ->
  642   let {res' = realToFrac res} in
  643   errorCheck  a4'>>
  644   return (res')
  645 
  646 
  647 
  648 -- |Date of the first cash flow paying after /settlementDate/.
  649 nextCashFlowDate :: (GenLeg l) -> (Bool) -- ^includeSettlementDateFlows
  650  -> (Maybe Day) -- ^settlementDate
  651  -> IO (((Maybe Day)))
  652 nextCashFlowDate a1 a2 a3 =
  653   withLeg a1 $ \a1' -> 
  654   let {a2' = C2HSImp.fromBool a2} in 
  655   withMaybeDay a3 $ \a3' -> 
  656   preErrorCheck $ \a4' -> 
  657   nextCashFlowDate'_ a1' a2' a3' a4' >>= \res ->
  658   let {res' = toMaybeDay res} in
  659   errorCheck  a4'>>
  660   return (res')
  661 
  662 
  663 
  664 -- |Coupon rate of the next cash flow paying after /settlementDate/.
  665 nextCouponRate :: (GenLeg l) -> (Bool) -- ^includeSettlementDateFlows
  666  -> (Maybe Day) -- ^settlementDate
  667  -> IO ((Double))
  668 nextCouponRate a1 a2 a3 =
  669   withLeg a1 $ \a1' -> 
  670   let {a2' = C2HSImp.fromBool a2} in 
  671   withMaybeDay a3 $ \a3' -> 
  672   preErrorCheck $ \a4' -> 
  673   nextCouponRate'_ a1' a2' a3' a4' >>= \res ->
  674   let {res' = realToFrac res} in
  675   errorCheck  a4'>>
  676   return (res')
  677 
  678 
  679 
  680 -- |Nominal of the coupon paying on /settlementDate/.
  681 nominal :: (GenLeg l) -> (Bool) -- ^includeSettlementDateFlows
  682  -> (Maybe Day) -- ^settlementDate
  683  -> IO ((Double))
  684 nominal a1 a2 a3 =
  685   withLeg a1 $ \a1' -> 
  686   let {a2' = C2HSImp.fromBool a2} in 
  687   withMaybeDay a3 $ \a3' -> 
  688   preErrorCheck $ \a4' -> 
  689   nominal'_ a1' a2' a3' a4' >>= \res ->
  690   let {res' = realToFrac res} in
  691   errorCheck  a4'>>
  692   return (res')
  693 
  694 
  695 
  696 -- |NPV of the cash flows.
  697 -- 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.
  698 npvFromYield' :: (GenLeg l) -> (InterestRate) -> (Bool) -- ^includeSettlementDateFlows
  699  -> (Maybe Day) -- ^settlementDate
  700  -> (Maybe Day) -- ^npvDate
  701  -> IO ((Double))
  702 npvFromYield' a1 a2 a3 a4 a5 =
  703   withLeg a1 $ \a1' -> 
  704   withInterestRate a2 $ \a2' -> 
  705   let {a3' = C2HSImp.fromBool a3} in 
  706   withMaybeDay a4 $ \a4' -> 
  707   withMaybeDay a5 $ \a5' -> 
  708   preErrorCheck $ \a6' -> 
  709   npvFromYield''_ a1' a2' a3' a4' a5' a6' >>= \res ->
  710   let {res' = realToFrac res} in
  711   errorCheck  a6'>>
  712   return (res')
  713 
  714 
  715 
  716 -- |NPV of the cash flows, as 'npvFromYield'' but taking a plain yield\/day counter\/compounding\/frequency
  717 -- instead of an 'InterestRate'.
  718 npvFromYield :: (GenLeg l) -> (Double) -> (DayCounter) -> (Compounding) -> (Frequency) -> (Bool) -- ^includeSettlementDateFlows
  719  -> (Maybe Day) -- ^settlementDate
  720  -> (Maybe Day) -- ^npvDate
  721  -> IO ((Double))
  722 npvFromYield a1 a2 a3 a4 a5 a6 a7 a8 =
  723   withLeg a1 $ \a1' -> 
  724   let {a2' = realToFrac a2} in 
  725   withDayCounter a3 $ \a3' -> 
  726   let {a4' = (fromIntegral . fromEnum) a4} in 
  727   let {a5' = (fromIntegral . fromEnum) a5} in 
  728   let {a6' = C2HSImp.fromBool a6} in 
  729   withMaybeDay a7 $ \a7' -> 
  730   withMaybeDay a8 $ \a8' -> 
  731   preErrorCheck $ \a9' -> 
  732   npvFromYield'_ a1' a2' a3' a4' a5' a6' a7' a8' a9' >>= \res ->
  733   let {res' = realToFrac res} in
  734   errorCheck  a9'>>
  735   return (res')
  736 
  737 
  738 
  739 -- |At-the-money rate of the cash flows.
  740 -- 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.
  741 atmRate :: (GenLeg l) -> (GenYieldTermStructure y) -> (Bool) -- ^includeSettlementDateFlows
  742  -> (Maybe Day) -- ^settlementDate
  743  -> (Maybe Day) -- ^npvDate
  744  -> (Double) -- ^npv
  745  -> IO ((Double))
  746 atmRate a1 a2 a3 a4 a5 a6 =
  747   withLeg a1 $ \a1' -> 
  748   withYieldTermStructure a2 $ \a2' -> 
  749   let {a3' = C2HSImp.fromBool a3} in 
  750   withMaybeDay a4 $ \a4' -> 
  751   withMaybeDay a5 $ \a5' -> 
  752   let {a6' = realToFrac a6} in 
  753   preErrorCheck $ \a7' -> 
  754   atmRate'_ a1' a2' a3' a4' a5' a6' a7' >>= \res ->
  755   let {res' = realToFrac res} in
  756   errorCheck  a7'>>
  757   return (res')
  758 
  759 
  760 
  761 -- |Basis-point sensitivity of the cash flows.
  762 -- 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.
  763 bps :: (GenLeg l) -> (GenYieldTermStructure y) -> (Bool) -- ^includeSettlementDateFlows
  764  -> (Maybe Day) -- ^settlementDate
  765  -> (Maybe Day) -- ^npvDate
  766  -> IO ((Double))
  767 bps a1 a2 a3 a4 a5 =
  768   withLeg a1 $ \a1' -> 
  769   withYieldTermStructure a2 $ \a2' -> 
  770   let {a3' = C2HSImp.fromBool a3} in 
  771   withMaybeDay a4 $ \a4' -> 
  772   withMaybeDay a5 $ \a5' -> 
  773   preErrorCheck $ \a6' -> 
  774   bps'_ a1' a2' a3' a4' a5' a6' >>= \res ->
  775   let {res' = realToFrac res} in
  776   errorCheck  a6'>>
  777   return (res')
  778 
  779 
  780 
  781 -- |NPV of the cash flows.
  782 -- 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.
  783 npv' :: (GenLeg l) -> (GenYieldTermStructure y) -> (Double) -- ^zSpread
  784  -> (Compounding) -> (Frequency) -> (Bool) -- ^includeSettlementDateFlows
  785  -> (Maybe Day) -- ^settlementDate
  786  -> (Maybe Day) -- ^npvDate
  787  -> IO ((Double))
  788 npv' a1 a2 a3 a4 a5 a6 a7 a8 =
  789   withLeg a1 $ \a1' -> 
  790   withYieldTermStructure a2 $ \a2' -> 
  791   let {a3' = realToFrac a3} in 
  792   let {a4' = (fromIntegral . fromEnum) a4} in 
  793   let {a5' = (fromIntegral . fromEnum) a5} in 
  794   let {a6' = C2HSImp.fromBool a6} in 
  795   withMaybeDay a7 $ \a7' -> 
  796   withMaybeDay a8 $ \a8' -> 
  797   preErrorCheck $ \a9' -> 
  798   npv''_ a1' a2' a3' a4' a5' a6' a7' a8' a9' >>= \res ->
  799   let {res' = realToFrac res} in
  800   errorCheck  a9'>>
  801   return (res')
  802 
  803 
  804 
  805 -- |NPV of the cash flows.
  806 -- The NPV is the sum of the cash flows, each discounted according to the given term structure.
  807 npv :: (GenLeg l) -> (GenYieldTermStructure y) -> (Bool) -- ^includeSettlementDateFlows
  808  -> (Maybe Day) -- ^settlementDate
  809  -> (Maybe Day) -- ^npvDate
  810  -> IO ((Double))
  811 npv a1 a2 a3 a4 a5 =
  812   withLeg a1 $ \a1' -> 
  813   withYieldTermStructure a2 $ \a2' -> 
  814   let {a3' = C2HSImp.fromBool a3} in 
  815   withMaybeDay a4 $ \a4' -> 
  816   withMaybeDay a5 $ \a5' -> 
  817   preErrorCheck $ \a6' -> 
  818   npv'_ a1' a2' a3' a4' a5' a6' >>= \res ->
  819   let {res' = realToFrac res} in
  820   errorCheck  a6'>>
  821   return (res')
  822 
  823 
  824 
  825 -- |NPV and BPS of the cash flows.
  826 -- The NPV and BPS of the cash flows calculated together for performance reason
  827 npvbps :: (GenLeg l) -> (GenYieldTermStructure y) -> (Bool) -- ^includeSettlementDateFlows
  828  -> (Day) -- ^settlementDate
  829  -> (Day) -- ^npvDate
  830  -> IO ((Double), (Double))
  831 npvbps a1 a2 a3 a4 a5 =
  832   withLeg a1 $ \a1' -> 
  833   withYieldTermStructure a2 $ \a2' -> 
  834   let {a3' = C2HSImp.fromBool a3} in 
  835   withDay a4 $ \a4' -> 
  836   withDay a5 $ \a5' -> 
  837   prePtr $ \a6' -> 
  838   prePtr $ \a7' -> 
  839   preErrorCheck $ \a8' -> 
  840   npvbps'_ a1' a2' a3' a4' a5' a6' a7' a8' >>
  841   peekDouble  a6'>>= \a6'' -> 
  842   peekDouble  a7'>>= \a7'' -> 
  843   errorCheck  a8'>>
  844   return (a6'', a7'')
  845 
  846 
  847 
  848 -- |implied Z-spread.
  849 zSpread :: (GenLeg l) -> (Double) -- ^npv
  850  -> (GenYieldTermStructure y) -> (Compounding) -> (Frequency) -> (Bool) -- ^includeSettlementDateFlows
  851  -> (Maybe Day) -- ^settlementDate
  852  -> (Maybe Day) -- ^npvDate
  853  -> (Double) -- ^accuracy
  854  -> (Word) -- ^maxIterations
  855  -> (Double) -- ^guess
  856  -> IO ((Double))
  857 zSpread a1 a2 a3 a4 a5 a6 a7 a8 a9 a10 a11 =
  858   withLeg a1 $ \a1' -> 
  859   let {a2' = realToFrac a2} in 
  860   withYieldTermStructure a3 $ \a3' -> 
  861   let {a4' = (fromIntegral . fromEnum) a4} in 
  862   let {a5' = (fromIntegral . fromEnum) a5} in 
  863   let {a6' = C2HSImp.fromBool a6} in 
  864   withMaybeDay a7 $ \a7' -> 
  865   withMaybeDay a8 $ \a8' -> 
  866   let {a9' = realToFrac a9} in 
  867   let {a10' = fromIntegral a10} in 
  868   let {a11' = realToFrac a11} in 
  869   preErrorCheck $ \a12' -> 
  870   zSpread'_ a1' a2' a3' a4' a5' a6' a7' a8' a9' a10' a11' a12' >>= \res ->
  871   let {res' = realToFrac res} in
  872   errorCheck  a12'>>
  873   return (res')
  874 
  875 
  876 
  877 -- |Amount of the last cash flow that paid before or at /settlementDate/.
  878 previousCashFlowAmount :: (GenLeg l) -> (Bool) -- ^includeSettlementDateFlows
  879  -> (Maybe Day) -- ^settlementDate
  880  -> IO ((Double))
  881 previousCashFlowAmount a1 a2 a3 =
  882   withLeg a1 $ \a1' -> 
  883   let {a2' = C2HSImp.fromBool a2} in 
  884   withMaybeDay a3 $ \a3' -> 
  885   preErrorCheck $ \a4' -> 
  886   previousCashFlowAmount'_ a1' a2' a3' a4' >>= \res ->
  887   let {res' = realToFrac res} in
  888   errorCheck  a4'>>
  889   return (res')
  890 
  891 
  892 
  893 -- |Date of the last cash flow that paid before or at /settlementDate/.
  894 previousCashFlowDate :: (GenLeg l) -> (Bool) -- ^includeSettlementDateFlows
  895  -> (Maybe Day) -- ^settlementDate
  896  -> IO ((Maybe Day))
  897 previousCashFlowDate a1 a2 a3 =
  898   withLeg a1 $ \a1' -> 
  899   let {a2' = C2HSImp.fromBool a2} in 
  900   withMaybeDay a3 $ \a3' -> 
  901   preErrorCheck $ \a4' -> 
  902   previousCashFlowDate'_ a1' a2' a3' a4' >>= \res ->
  903   let {res' = toMaybeDay res} in
  904   errorCheck  a4'>>
  905   return (res')
  906 
  907 
  908 
  909 -- |Coupon rate of the last cash flow that paid before or at /settlementDate/.
  910 previousCouponRate :: (GenLeg l) -> (Bool) -- ^includeSettlementDateFlows
  911  -> (Maybe Day) -- ^settlementDate
  912  -> IO ((Double))
  913 previousCouponRate a1 a2 a3 =
  914   withLeg a1 $ \a1' -> 
  915   let {a2' = C2HSImp.fromBool a2} in 
  916   withMaybeDay a3 $ \a3' -> 
  917   preErrorCheck $ \a4' -> 
  918   previousCouponRate'_ a1' a2' a3' a4' >>= \res ->
  919   let {res' = realToFrac res} in
  920   errorCheck  a4'>>
  921   return (res')
  922 
  923 
  924 
  925 -- |End of the reference period of the coupon paying on /settlementDate/.
  926 referencePeriodEnd :: (GenLeg l) -> (Bool) -- ^includeSettlementDateFlows
  927  -> (Maybe Day) -- ^settlementDate
  928  -> IO ((Maybe Day))
  929 referencePeriodEnd a1 a2 a3 =
  930   withLeg a1 $ \a1' -> 
  931   let {a2' = C2HSImp.fromBool a2} in 
  932   withMaybeDay a3 $ \a3' -> 
  933   preErrorCheck $ \a4' -> 
  934   referencePeriodEnd'_ a1' a2' a3' a4' >>= \res ->
  935   let {res' = toMaybeDay res} in
  936   errorCheck  a4'>>
  937   return (res')
  938 
  939 
  940 
  941 -- |Start of the reference period of the coupon paying on /settlementDate/.
  942 referencePeriodStart :: (GenLeg l) -> (Bool) -- ^includeSettlementDateFlows
  943  -> (Maybe Day) -- ^settlementDate
  944  -> IO ((Maybe Day))
  945 referencePeriodStart a1 a2 a3 =
  946   withLeg a1 $ \a1' -> 
  947   let {a2' = C2HSImp.fromBool a2} in 
  948   withMaybeDay a3 $ \a3' -> 
  949   preErrorCheck $ \a4' -> 
  950   referencePeriodStart'_ a1' a2' a3' a4' >>= \res ->
  951   let {res' = toMaybeDay res} in
  952   errorCheck  a4'>>
  953   return (res')
  954 
  955 
  956 
  957 -- |Implied internal rate of return.
  958 -- The function verifies the theoretical existance of an IRR and numerically establishes the IRR to the desired precision.
  959 yield :: (GenLeg l) -> (Double) -- ^npv
  960  -> (DayCounter) -> (Compounding) -> (Frequency) -> (Bool) -- ^includeSettlementDateFlows
  961  -> (Maybe Day) -- ^settlementDate
  962  -> (Maybe Day) -- ^npvDate
  963  -> (Double) -- ^accuracy
  964  -> (Word) -- ^maxIterations
  965  -> (Double) -- ^guess
  966  -> IO ((Double))
  967 yield a1 a2 a3 a4 a5 a6 a7 a8 a9 a10 a11 =
  968   withLeg a1 $ \a1' -> 
  969   let {a2' = realToFrac a2} in 
  970   withDayCounter a3 $ \a3' -> 
  971   let {a4' = (fromIntegral . fromEnum) a4} in 
  972   let {a5' = (fromIntegral . fromEnum) a5} in 
  973   let {a6' = C2HSImp.fromBool a6} in 
  974   withMaybeDay a7 $ \a7' -> 
  975   withMaybeDay a8 $ \a8' -> 
  976   let {a9' = realToFrac a9} in 
  977   let {a10' = fromIntegral a10} in 
  978   let {a11' = realToFrac a11} in 
  979   preErrorCheck $ \a12' -> 
  980   yield'_ a1' a2' a3' a4' a5' a6' a7' a8' a9' a10' a11' a12' >>= \res ->
  981   let {res' = realToFrac res} in
  982   errorCheck  a12'>>
  983   return (res')
  984 
  985 
  986 
  987 -- |Yield value of a basis point, as 'yieldValueBasisPoint'' but taking a plain
  988 -- yield\/day counter\/compounding\/frequency instead of an 'InterestRate'.
  989 yieldValueBasisPoint :: (GenLeg l) -> (Double) -- ^yield
  990  -> (DayCounter) -> (Compounding) -> (Frequency) -> (Bool) -- ^includeSettlementDateFlows
  991  -> (Maybe Day) -- ^settlementDate
  992  -> (Maybe Day) -- ^npvDate
  993  -> IO ((Double))
  994 yieldValueBasisPoint a1 a2 a3 a4 a5 a6 a7 a8 =
  995   withLeg a1 $ \a1' -> 
  996   let {a2' = realToFrac a2} in 
  997   withDayCounter a3 $ \a3' -> 
  998   let {a4' = (fromIntegral . fromEnum) a4} in 
  999   let {a5' = (fromIntegral . fromEnum) a5} in 
 1000   let {a6' = C2HSImp.fromBool a6} in 
 1001   withMaybeDay a7 $ \a7' -> 
 1002   withMaybeDay a8 $ \a8' -> 
 1003   preErrorCheck $ \a9' -> 
 1004   yieldValueBasisPoint'_ a1' a2' a3' a4' a5' a6' a7' a8' a9' >>= \res ->
 1005   let {res' = realToFrac res} in
 1006   errorCheck  a9'>>
 1007   return (res')
 1008 
 1009 
 1010 
 1011 -- |Yield value of a basis point.
 1012 -- 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
 1013 yieldValueBasisPoint' :: (GenLeg l) -> (InterestRate) -- ^yield
 1014  -> (Bool) -- ^includeSettlementDateFlows
 1015  -> (Maybe Day) -- ^settlementDate
 1016  -> (Maybe Day) -- ^npvDate
 1017  -> IO ((Double))
 1018 yieldValueBasisPoint' a1 a2 a3 a4 a5 =
 1019   withLeg a1 $ \a1' -> 
 1020   withInterestRate a2 $ \a2' -> 
 1021   let {a3' = C2HSImp.fromBool a3} in 
 1022   withMaybeDay a4 $ \a4' -> 
 1023   withMaybeDay a5 $ \a5' -> 
 1024   preErrorCheck $ \a6' -> 
 1025   yieldValueBasisPoint''_ a1' a2' a3' a4' a5' a6' >>= \res ->
 1026   let {res' = realToFrac res} in
 1027   errorCheck  a6'>>
 1028   return (res')
 1029 
 1030 
 1031 
 1032 -- |start of the accrual periods for a coupon leg
 1033 couponAccrualStartDates :: (CouponLeg) -> IO (([Day]))
 1034 couponAccrualStartDates a1 =
 1035   withGenLeg a1 $ \a1' -> 
 1036   preArray $ \(a2'1, a2'2) -> 
 1037   preErrorCheck $ \a3' -> 
 1038   couponAccrualStartDates'_ a1' a2'1  a2'2 a3' >>
 1039   peekDayArray  a2'1  a2'2>>= \a2'' -> 
 1040   errorCheck  a3'>>
 1041   return (a2'')
 1042 
 1043 
 1044 
 1045 -- |Predetermined cash flow paying a fixed /amount/ at /date/.
 1046 fixedDividend :: (Double) -- ^amount
 1047  -> (Day) -- ^date
 1048  -> IO ((Dividend))
 1049 fixedDividend a1 a2 =
 1050   let {a1' = realToFrac a1} in 
 1051   withDay a2 $ \a2' -> 
 1052   preErrorCheck $ \a3' -> 
 1053   fixedDividend'_ a1' a2' a3' >>= \res ->
 1054   peekDividend res >>= \res' ->
 1055   errorCheck  a3'>>
 1056   return (res')
 1057 
 1058 
 1059 
 1060 -- |Predetermined cash flow paying /rate/ times /nominal/ at /date/.
 1061 fractionalDividend' :: (Double) -- ^rate
 1062  -> (Double) -- ^nominal
 1063  -> (Day) -- ^date
 1064  -> IO ((Dividend))
 1065 fractionalDividend' a1 a2 a3 =
 1066   let {a1' = realToFrac a1} in 
 1067   let {a2' = realToFrac a2} in 
 1068   withDay a3 $ \a3' -> 
 1069   preErrorCheck $ \a4' -> 
 1070   fractionalDividend''_ a1' a2' a3' a4' >>= \res ->
 1071   peekDividend res >>= \res' ->
 1072   errorCheck  a4'>>
 1073   return (res')
 1074 
 1075 
 1076 
 1077 -- |Predetermined cash flow paying a fractional /rate/ of the underlying's price at /date/.
 1078 fractionalDividend :: (Double) -- ^rate
 1079  -> (Day) -- ^date
 1080  -> IO ((Dividend))
 1081 fractionalDividend a1 a2 =
 1082   let {a1' = realToFrac a1} in 
 1083   withDay a2 $ \a2' -> 
 1084   preErrorCheck $ \a3' -> 
 1085   fractionalDividend'_ a1' a2' a3' >>= \res ->
 1086   peekDividend res >>= \res' ->
 1087   errorCheck  a3'>>
 1088   return (res')
 1089 
 1090 
 1091 
 1092 -- |Build a leg of average-BMA coupons.
 1093 averageBMALeg :: (Schedule) -> (BMAIndex) -> ([Double]) -- ^notionals
 1094  -> (DayCounter) -> (BusinessDayConvention) -> ([Double]) -- ^gearings
 1095  -> ([Double]) -- ^spreads
 1096  -> IO ((Leg))
 1097 averageBMALeg a1 a2 a3 a4 a5 a6 a7 =
 1098   withSchedule a1 $ \a1' -> 
 1099   withBMAIndex a2 $ \a2' -> 
 1100   withDoubleArray a3 $ \(a3'1, a3'2) -> 
 1101   withDayCounter a4 $ \a4' -> 
 1102   let {a5' = fromEnumC a5} in 
 1103   withDoubleArray a6 $ \(a6'1, a6'2) -> 
 1104   withDoubleArray a7 $ \(a7'1, a7'2) -> 
 1105   preErrorCheck $ \a8' -> 
 1106   averageBMALeg'_ a1' a2' a3'1  a3'2 a4' a5' a6'1  a6'2 a7'1  a7'2 a8' >>= \res ->
 1107   peekLeg res >>= \res' ->
 1108   errorCheck  a8'>>
 1109   return (res')
 1110 
 1111 
 1112 
 1113 -- |Build a leg of fixed-rate coupons.
 1114 fixedRateLeg :: (Schedule) -> ([Double]) -- ^notionals
 1115  -> ([InterestRate]) -- ^couponRates
 1116  -> (BusinessDayConvention) -- ^paymentAdjustment
 1117  -> (DayCounter) -- ^firstPeriodDayCounter
 1118  -> (Calendar) -- ^paymentCalendar
 1119  -> IO ((Leg))
 1120 fixedRateLeg a1 a2 a3 a4 a5 a6 =
 1121   withSchedule a1 $ \a1' -> 
 1122   withDoubleArray a2 $ \(a2'1, a2'2) -> 
 1123   withInterestRateArray a3 $ \(a3'1, a3'2) -> 
 1124   let {a4' = fromEnumC a4} in 
 1125   withDayCounter a5 $ \a5' -> 
 1126   withCalendar a6 $ \a6' -> 
 1127   preErrorCheck $ \a7' -> 
 1128   fixedRateLeg'_ a1' a2'1  a2'2 a3'1  a3'2 a4' a5' a6' a7' >>= \res ->
 1129   peekLeg res >>= \res' ->
 1130   errorCheck  a7'>>
 1131   return (res')
 1132 
 1133 
 1134 
 1135 -- |iborLeg keeps its original 12-arg signature -- existing callers are unaffected -- but
 1136 -- now delegates to iborLeg_, the raw binding widened to IborLeg's full builder surface,
 1137 -- hardcoding upstream's own defaults for the params iborLeg doesn't expose. Use
 1138 -- 'iborLegFull' to reach those (payment lag\/calendar, ex-coupon period, fixing
 1139 -- convention, indexed\/at-par coupons) via 'IborLegOpts'.
 1140 iborLeg :: Schedule -> GenIborIndex ibor -> [Double] -> DayCounter -> BusinessDayConvention
 1141   -> [Word] -> [Double] -> [Double] -> [Double] -> [Double] -> Bool -> Bool -> IO Leg
 1142 iborLeg schedule idx notionals dc adj fixingDays gearings spreads caps floors inArrears zp = do
 1143   cal <- calendar Null
 1144   iborLeg_ schedule idx notionals dc adj fixingDays gearings spreads caps floors inArrears zp
 1145     (ilgPaymentLag defaultIborLegOpts) cal (ilgExCouponPeriod defaultIborLegOpts) cal
 1146     (ilgExCouponConvention defaultIborLegOpts) (ilgExCouponEndOfMonth defaultIborLegOpts)
 1147     (ilgFixingConvention defaultIborLegOpts) (ilgUseIndexedCoupons defaultIborLegOpts)
 1148 
 1149 -- |'iborLeg' widened to every 'IborLeg' builder-method param via 'IborLegOpts'.
 1150 iborLegFull :: Schedule -> GenIborIndex ibor -> [Double] -> DayCounter -> BusinessDayConvention
 1151   -> [Word] -> [Double] -> [Double] -> [Double] -> [Double] -> Bool -> Bool -> IborLegOpts
 1152   -> IO Leg
 1153 iborLegFull schedule idx notionals dc adj fixingDays gearings spreads caps floors inArrears zp opts = do
 1154   cal <- calendar Null
 1155   iborLeg_ schedule idx notionals dc adj fixingDays gearings spreads caps floors inArrears zp
 1156     (ilgPaymentLag opts) (fromMaybe cal (ilgPaymentCalendar opts)) (ilgExCouponPeriod opts)
 1157     (fromMaybe cal (ilgExCouponCalendar opts)) (ilgExCouponConvention opts)
 1158     (ilgExCouponEndOfMonth opts) (ilgFixingConvention opts) (ilgUseIndexedCoupons opts)
 1159 
 1160 -- |Raw binding for 'iborLeg'\/'iborLegFull': builds a leg of capped\/floored Ibor-rate coupons.
 1161 iborLeg_ :: (Schedule) -> (GenIborIndex ibor) -> ([Double]) -- ^notionals
 1162  -> (DayCounter) -> (BusinessDayConvention) -- ^paymentAdjustment
 1163  -> ([Word]) -- ^fixingDays
 1164  -> ([Double]) -- ^gearings
 1165  -> ([Double]) -- ^spreads
 1166  -> ([Double]) -- ^caps
 1167  -> ([Double]) -- ^floors
 1168  -> (Bool) -- ^inArrears
 1169  -> (Bool) -- ^zeroPayments
 1170  -> (Int) -- ^paymentLag
 1171  -> (Calendar) -- ^paymentCalendar
 1172  -> ((Int,TimeUnit)) -- ^exCouponPeriod
 1173  -> (Calendar) -- ^exCouponCalendar
 1174  -> (BusinessDayConvention) -- ^exCouponConvention
 1175  -> (Bool) -- ^exCouponEndOfMonth
 1176  -> (BusinessDayConvention) -- ^fixingConvention
 1177  -> (Maybe Bool) -- ^useIndexedCoupons
 1178  -> IO ((Leg))
 1179 iborLeg_ a1 a2 a3 a4 a5 a6 a7 a8 a9 a10 a11 a12 a13 a14 a15 a16 a17 a18 a19 a20 =
 1180   withSchedule a1 $ \a1' -> 
 1181   withIborIndex a2 $ \a2' -> 
 1182   withDoubleArray a3 $ \(a3'1, a3'2) -> 
 1183   withDayCounter a4 $ \a4' -> 
 1184   let {a5' = fromEnumC a5} in 
 1185   withIntArray a6 $ \(a6'1, a6'2) -> 
 1186   withDoubleArray a7 $ \(a7'1, a7'2) -> 
 1187   withDoubleArray a8 $ \(a8'1, a8'2) -> 
 1188   withDoubleArray a9 $ \(a9'1, a9'2) -> 
 1189   withDoubleArray a10 $ \(a10'1, a10'2) -> 
 1190   let {a11' = C2HSImp.fromBool a11} in 
 1191   let {a12' = C2HSImp.fromBool a12} in 
 1192   let {a13' = fromIntegral a13} in 
 1193   withCalendar a14 $ \a14' -> 
 1194   let {(a15'1, a15'2) = fromEnumQuantity a15} in 
 1195   withCalendar a16 $ \a16' -> 
 1196   let {a17' = fromEnumC a17} in 
 1197   let {a18' = C2HSImp.fromBool a18} in 
 1198   let {a19' = fromEnumC a19} in 
 1199   let {a20' = fromMaybeBool a20} in 
 1200   preErrorCheck $ \a21' -> 
 1201   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' >>= \res ->
 1202   peekLeg res >>= \res' ->
 1203   errorCheck  a21'>>
 1204   return (res')
 1205 
 1206 
 1207 
 1208 -- |CMS leg builder (analog of 'iborLeg'), 12-arg core shape -- same defaults-hardcoding
 1209 -- pattern as 'iborLeg' for the params not in this signature. Use 'cmsLegFull' to reach
 1210 -- them ('CmsLegOpts').
 1211 cmsLeg :: Schedule -> GenSwapIndex sidx -> [Double] -> DayCounter -> BusinessDayConvention
 1212   -> [Word] -> [Double] -> [Double] -> [Double] -> [Double] -> Bool -> Bool -> IO Leg
 1213 cmsLeg schedule idx notionals dc adj fixingDays gearings spreads caps floors inArrears zp = do
 1214   cal <- calendar Null
 1215   cmsLeg_ schedule idx notionals dc adj fixingDays gearings spreads caps floors inArrears zp
 1216     (cmslExCouponPeriod defaultCmsLegOpts) cal (cmslExCouponConvention defaultCmsLegOpts)
 1217     (cmslExCouponEndOfMonth defaultCmsLegOpts) (cmslFixingConvention defaultCmsLegOpts)
 1218 
 1219 -- |'cmsLeg' widened to every 'CmsLeg' builder-method param via 'CmsLegOpts'.
 1220 cmsLegFull :: Schedule -> GenSwapIndex sidx -> [Double] -> DayCounter -> BusinessDayConvention
 1221   -> [Word] -> [Double] -> [Double] -> [Double] -> [Double] -> Bool -> Bool -> CmsLegOpts
 1222   -> IO Leg
 1223 cmsLegFull schedule idx notionals dc adj fixingDays gearings spreads caps floors inArrears zp opts = do
 1224   cal <- calendar Null
 1225   cmsLeg_ schedule idx notionals dc adj fixingDays gearings spreads caps floors inArrears zp
 1226     (cmslExCouponPeriod opts) (fromMaybe cal (cmslExCouponCalendar opts))
 1227     (cmslExCouponConvention opts) (cmslExCouponEndOfMonth opts) (cmslFixingConvention opts)
 1228 
 1229 -- |Raw binding for 'cmsLeg'\/'cmsLegFull': builds a leg of capped\/floored CMS-rate coupons.
 1230 cmsLeg_ :: (Schedule) -> (GenSwapIndex sidx) -> ([Double]) -- ^notionals
 1231  -> (DayCounter) -> (BusinessDayConvention) -- ^paymentAdjustment
 1232  -> ([Word]) -- ^fixingDays
 1233  -> ([Double]) -- ^gearings
 1234  -> ([Double]) -- ^spreads
 1235  -> ([Double]) -- ^caps
 1236  -> ([Double]) -- ^floors
 1237  -> (Bool) -- ^inArrears
 1238  -> (Bool) -- ^zeroPayments
 1239  -> ((Int,TimeUnit)) -- ^exCouponPeriod
 1240  -> (Calendar) -- ^exCouponCalendar
 1241  -> (BusinessDayConvention) -- ^exCouponConvention
 1242  -> (Bool) -- ^exCouponEndOfMonth
 1243  -> (BusinessDayConvention) -- ^fixingConvention
 1244  -> IO ((Leg))
 1245 cmsLeg_ a1 a2 a3 a4 a5 a6 a7 a8 a9 a10 a11 a12 a13 a14 a15 a16 a17 =
 1246   withSchedule a1 $ \a1' -> 
 1247   withSwapIndex a2 $ \a2' -> 
 1248   withDoubleArray a3 $ \(a3'1, a3'2) -> 
 1249   withDayCounter a4 $ \a4' -> 
 1250   let {a5' = fromEnumC a5} in 
 1251   withIntArray a6 $ \(a6'1, a6'2) -> 
 1252   withDoubleArray a7 $ \(a7'1, a7'2) -> 
 1253   withDoubleArray a8 $ \(a8'1, a8'2) -> 
 1254   withDoubleArray a9 $ \(a9'1, a9'2) -> 
 1255   withDoubleArray a10 $ \(a10'1, a10'2) -> 
 1256   let {a11' = C2HSImp.fromBool a11} in 
 1257   let {a12' = C2HSImp.fromBool a12} in 
 1258   let {(a13'1, a13'2) = fromEnumQuantity a13} in 
 1259   withCalendar a14 $ \a14' -> 
 1260   let {a15' = fromEnumC a15} in 
 1261   let {a16' = C2HSImp.fromBool a16} in 
 1262   let {a17' = fromEnumC a17} in 
 1263   preErrorCheck $ \a18' -> 
 1264   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 ->
 1265   peekLeg res >>= \res' ->
 1266   errorCheck  a18'>>
 1267   return (res')
 1268 
 1269 
 1270 
 1271 -- |Build a leg of overnight-index coupons.
 1272 overnightLeg :: (Schedule) -> (OvernightIborIndex) -> ([Double]) -- ^notionals'
 1273  -> (DayCounter) -> (BusinessDayConvention) -> ([Double]) -- ^gearings
 1274  -> ([Double]) -- ^spreads
 1275  -> IO ((Leg))
 1276 overnightLeg a1 a2 a3 a4 a5 a6 a7 =
 1277   withSchedule a1 $ \a1' -> 
 1278   withOvernightIborIndex a2 $ \a2' -> 
 1279   withDoubleArray a3 $ \(a3'1, a3'2) -> 
 1280   withDayCounter a4 $ \a4' -> 
 1281   let {a5' = fromEnumC a5} in 
 1282   withDoubleArray a6 $ \(a6'1, a6'2) -> 
 1283   withDoubleArray a7 $ \(a7'1, a7'2) -> 
 1284   preErrorCheck $ \a8' -> 
 1285   overnightLeg'_ a1' a2' a3'1  a3'2 a4' a5' a6'1  a6'2 a7'1  a7'2 a8' >>= \res ->
 1286   peekLeg res >>= \res' ->
 1287   errorCheck  a8'>>
 1288   return (res')
 1289 
 1290 
 1291 
 1292 -- |Build a leg of range-accrual floating-rate coupons.
 1293 rangeAccrualLeg :: (Schedule) -> (GenIborIndex ibor) -> ([Double]) -- ^notionals
 1294  -> (DayCounter) -> (BusinessDayConvention) -> ([Word]) -- ^fixingDays
 1295  -> ([Double]) -- ^gearings
 1296  -> ([Double]) -- ^spreads
 1297  -> ([Double]) -- ^lowerTriggers
 1298  -> ([Double]) -- ^upperTriggers
 1299  -> ((Int,TimeUnit)) -- ^observationTenor
 1300  -> (BusinessDayConvention) -> IO ((Leg))
 1301 rangeAccrualLeg a1 a2 a3 a4 a5 a6 a7 a8 a9 a10 a11 a12 =
 1302   withSchedule a1 $ \a1' -> 
 1303   withIborIndex a2 $ \a2' -> 
 1304   withDoubleArray a3 $ \(a3'1, a3'2) -> 
 1305   withDayCounter a4 $ \a4' -> 
 1306   let {a5' = fromEnumC a5} in 
 1307   withIntArray a6 $ \(a6'1, a6'2) -> 
 1308   withDoubleArray a7 $ \(a7'1, a7'2) -> 
 1309   withDoubleArray a8 $ \(a8'1, a8'2) -> 
 1310   withDoubleArray a9 $ \(a9'1, a9'2) -> 
 1311   withDoubleArray a10 $ \(a10'1, a10'2) -> 
 1312   let {(a11'1, a11'2) = fromEnumQuantity a11} in 
 1313   let {a12' = fromEnumC a12} in 
 1314   preErrorCheck $ \a13' -> 
 1315   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 ->
 1316   peekLeg res >>= \res' ->
 1317   errorCheck  a13'>>
 1318   return (res')
 1319 
 1320 
 1321 
 1322 -- |Fixed-rate coupons scaled by the ratio of a 'ZeroInflationIndex' fixing to /baseCPI/
 1323 -- (a 'CPICoupon' leg -- no capped\/floored variant, unlike 'yoyInflationLeg': QL 1.43 has no
 1324 -- @CappedFlooredCPICoupon@ class to build one from, see README.md's TODO).
 1325 cpiLeg :: (Schedule) -> (ZeroInflationIndex) -> (Double) -- ^baseCPI
 1326  -> ((Word,TimeUnit)) -- ^observationLag
 1327  -> ([Double]) -- ^notionals
 1328  -> ([Double]) -- ^fixedRates
 1329  -> (DayCounter) -- ^paymentDayCounter
 1330  -> (BusinessDayConvention) -- ^paymentAdjustment
 1331  -> (Calendar) -- ^paymentCalendar
 1332  -> (CPIInterpolationType) -- ^observationInterpolation
 1333  -> (Bool) -- ^subtractInflationNominal
 1334  -> IO ((Leg))
 1335 cpiLeg a1 a2 a3 a4 a5 a6 a7 a8 a9 a10 a11 =
 1336   withSchedule a1 $ \a1' -> 
 1337   withZeroInflationIndex a2 $ \a2' -> 
 1338   let {a3' = realToFrac a3} in 
 1339   let {(a4'1, a4'2) = fromEnumQuantity a4} in 
 1340   withDoubleArray a5 $ \(a5'1, a5'2) -> 
 1341   withDoubleArray a6 $ \(a6'1, a6'2) -> 
 1342   withDayCounter a7 $ \a7' -> 
 1343   let {a8' = fromEnumC a8} in 
 1344   withCalendar a9 $ \a9' -> 
 1345   let {a10' = fromEnumC a10} in 
 1346   let {a11' = C2HSImp.fromBool a11} in 
 1347   preErrorCheck $ \a12' -> 
 1348   cpiLeg'_ a1' a2' a3' a4'1  a4'2 a5'1  a5'2 a6'1  a6'2 a7' a8' a9' a10' a11' a12' >>= \res ->
 1349   peekLeg res >>= \res' ->
 1350   errorCheck  a12'>>
 1351   return (res')
 1352 
 1353 
 1354 
 1355 -- |Year-on-year inflation-linked coupons (a 'YoYInflationCoupon' leg). Non-empty /caps/\//floors/
 1356 -- build 'CappedFlooredYoYInflationCoupon's instead of plain ones -- but /any/ resulting coupon
 1357 -- (capped or not) still needs a pricer set via 'setYoYInflationCouponPricer' before its
 1358 -- 'QuantLib.CashFlow.npv'\/'amount' can be computed: upstream's @InflationCoupon::rate()@
 1359 -- requires @pricer_@ unconditionally, not just for the capped\/floored case (confirmed by reading
 1360 -- @inflationcoupon.cpp@). CPI-leg ('cpiLeg') caps\/floors have no equivalent in QL 1.43 (no
 1361 -- @CappedFlooredCPICoupon@ class exists upstream, see README.md's TODO) -- this is a
 1362 -- QuantLib-version limitation, not an unbound feature.
 1363 yoyInflationLeg :: (Schedule) -> (Calendar) -> (YoYInflationIndex) -> ((Word,TimeUnit)) -- ^observationLag
 1364  -> (CPIInterpolationType) -- ^interpolation
 1365  -> ([Double]) -- ^notionals
 1366  -> (DayCounter) -- ^paymentDayCounter
 1367  -> (BusinessDayConvention) -- ^paymentAdjustment
 1368  -> ([Word]) -- ^fixingDays
 1369  -> ([Double]) -- ^gearings
 1370  -> ([Double]) -- ^spreads
 1371  -> ([Double]) -- ^caps
 1372  -> ([Double]) -- ^floors
 1373  -> IO ((Leg))
 1374 yoyInflationLeg a1 a2 a3 a4 a5 a6 a7 a8 a9 a10 a11 a12 a13 =
 1375   withSchedule a1 $ \a1' -> 
 1376   withCalendar a2 $ \a2' -> 
 1377   withYoYInflationIndex a3 $ \a3' -> 
 1378   let {(a4'1, a4'2) = fromEnumQuantity a4} in 
 1379   let {a5' = fromEnumC a5} in 
 1380   withDoubleArray a6 $ \(a6'1, a6'2) -> 
 1381   withDayCounter a7 $ \a7' -> 
 1382   let {a8' = fromEnumC a8} in 
 1383   withIntArray a9 $ \(a9'1, a9'2) -> 
 1384   withDoubleArray a10 $ \(a10'1, a10'2) -> 
 1385   withDoubleArray a11 $ \(a11'1, a11'2) -> 
 1386   withDoubleArray a12 $ \(a12'1, a12'2) -> 
 1387   withDoubleArray a13 $ \(a13'1, a13'2) -> 
 1388   preErrorCheck $ \a14' -> 
 1389   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 ->
 1390   peekLeg res >>= \res' ->
 1391   errorCheck  a14'>>
 1392   return (res')
 1393 
 1394 
 1395 
 1396 
 1397 
 1398 
 1399 
 1400 
 1401 
 1402 
 1403 
 1404 -- |Cash flow dependent on a 'ZeroInflationIndex' ratio (not a coupon -- no accruals).
 1405 -- The ratio is taken between fixings observed at /startDate/ and /endDate/ minus /observationLag/.
 1406 zeroInflationCashFlow :: (Double) -- ^notional
 1407  -> (ZeroInflationIndex) -> (CPIInterpolationType) -- ^observationInterpolation
 1408  -> (Day) -- ^startDate
 1409  -> (Day) -- ^endDate
 1410  -> ((Word,TimeUnit)) -- ^observationLag
 1411  -> (Day) -- ^paymentDate
 1412  -> (Bool) -- ^growthOnly
 1413  -> IO ((ZeroInflationCashFlow))
 1414 zeroInflationCashFlow a1 a2 a3 a4 a5 a6 a7 a8 =
 1415   let {a1' = realToFrac a1} in 
 1416   withZeroInflationIndex a2 $ \a2' -> 
 1417   let {a3' = fromEnumC a3} in 
 1418   withDay a4 $ \a4' -> 
 1419   withDay a5 $ \a5' -> 
 1420   let {(a6'1, a6'2) = fromEnumQuantity a6} in 
 1421   withDay a7 $ \a7' -> 
 1422   let {a8' = C2HSImp.fromBool a8} in 
 1423   preErrorCheck $ \a9' -> 
 1424   zeroInflationCashFlow'_ a1' a2' a3' a4' a5' a6'1  a6'2 a7' a8' a9' >>= \res ->
 1425   peekZeroInflationCashFlow res >>= \res' ->
 1426   errorCheck  a9'>>
 1427   return (res')
 1428 
 1429 
 1430 
 1431 -- |Amount of the cash flow: the index ratio (times notional), or the ratio minus one if growthOnly.
 1432 zeroInflationCashFlowAmount :: (ZeroInflationCashFlow) -> IO ((Double))
 1433 zeroInflationCashFlowAmount a1 =
 1434   withZeroInflationCashFlow a1 $ \a1' -> 
 1435   preErrorCheck $ \a2' -> 
 1436   zeroInflationCashFlowAmount'_ a1' a2' >>= \res ->
 1437   let {res' = realToFrac res} in
 1438   errorCheck  a2'>>
 1439   return (res')
 1440 
 1441 
 1442 
 1443 -- |Fixing used as the base of the ratio (as of /startDate/, lagged).
 1444 zeroInflationCashFlowBaseFixing :: (ZeroInflationCashFlow) -> IO ((Double))
 1445 zeroInflationCashFlowBaseFixing a1 =
 1446   withZeroInflationCashFlow a1 $ \a1' -> 
 1447   preErrorCheck $ \a2' -> 
 1448   zeroInflationCashFlowBaseFixing'_ a1' a2' >>= \res ->
 1449   let {res' = realToFrac res} in
 1450   errorCheck  a2'>>
 1451   return (res')
 1452 
 1453 
 1454 
 1455 -- |Fixing used as the numerator of the ratio (as of /endDate/, lagged).
 1456 zeroInflationCashFlowIndexFixing :: (ZeroInflationCashFlow) -> IO ((Double))
 1457 zeroInflationCashFlowIndexFixing a1 =
 1458   withZeroInflationCashFlow a1 $ \a1' -> 
 1459   preErrorCheck $ \a2' -> 
 1460   zeroInflationCashFlowIndexFixing'_ a1' a2' >>= \res ->
 1461   let {res' = realToFrac res} in
 1462   errorCheck  a2'>>
 1463   return (res')
 1464 
 1465 
 1466 
 1467 -- |CPI-linked cash flow (not a coupon -- no accruals), with an optional explicit /baseFixing/
 1468 -- (pass 'Nothing' to derive it from /baseDate/ instead).
 1469 cpiCashFlow :: (Double) -- ^notional
 1470  -> (ZeroInflationIndex) -> (Maybe Day) -- ^baseDate
 1471  -> (Maybe Double) -- ^baseFixing
 1472  -> (Day) -- ^observationDate
 1473  -> ((Word,TimeUnit)) -- ^observationLag
 1474  -> (CPIInterpolationType) -- ^interpolation
 1475  -> (Day) -- ^paymentDate
 1476  -> (Bool) -- ^growthOnly
 1477  -> IO ((CPICashFlow))
 1478 cpiCashFlow a1 a2 a3 a4 a5 a6 a7 a8 a9 =
 1479   let {a1' = realToFrac a1} in 
 1480   withZeroInflationIndex a2 $ \a2' -> 
 1481   withMaybeDay a3 $ \a3' -> 
 1482   let {a4' = fromMaybeDouble a4} in 
 1483   withDay a5 $ \a5' -> 
 1484   let {(a6'1, a6'2) = fromEnumQuantity a6} in 
 1485   let {a7' = fromEnumC a7} in 
 1486   withDay a8 $ \a8' -> 
 1487   let {a9' = C2HSImp.fromBool a9} in 
 1488   preErrorCheck $ \a10' -> 
 1489   cpiCashFlow'_ a1' a2' a3' a4' a5' a6'1  a6'2 a7' a8' a9' a10' >>= \res ->
 1490   peekCPICashFlow res >>= \res' ->
 1491   errorCheck  a10'>>
 1492   return (res')
 1493 
 1494 
 1495 
 1496 -- |Amount of the cash flow: the index ratio (times notional), or the ratio minus one if growthOnly.
 1497 cpiCashFlowAmount :: (CPICashFlow) -> IO ((Double))
 1498 cpiCashFlowAmount a1 =
 1499   withCPICashFlow a1 $ \a1' -> 
 1500   preErrorCheck $ \a2' -> 
 1501   cpiCashFlowAmount'_ a1' a2' >>= \res ->
 1502   let {res' = realToFrac res} in
 1503   errorCheck  a2'>>
 1504   return (res')
 1505 
 1506 
 1507 
 1508 -- |Fixing used as the base of the ratio: the explicit /baseFixing/ if given at construction, else derived from /baseDate/.
 1509 cpiCashFlowBaseFixing :: (CPICashFlow) -> IO ((Double))
 1510 cpiCashFlowBaseFixing a1 =
 1511   withCPICashFlow a1 $ \a1' -> 
 1512   preErrorCheck $ \a2' -> 
 1513   cpiCashFlowBaseFixing'_ a1' a2' >>= \res ->
 1514   let {res' = realToFrac res} in
 1515   errorCheck  a2'>>
 1516   return (res')
 1517 
 1518 
 1519 
 1520 -- |Fixing used as the numerator of the ratio (as of /observationDate/, lagged).
 1521 cpiCashFlowIndexFixing :: (CPICashFlow) -> IO ((Double))
 1522 cpiCashFlowIndexFixing a1 =
 1523   withCPICashFlow a1 $ \a1' -> 
 1524   preErrorCheck $ \a2' -> 
 1525   cpiCashFlowIndexFixing'_ a1' a2' >>= \res ->
 1526   let {res' = realToFrac res} in
 1527   errorCheck  a2'>>
 1528   return (res')
 1529 
 1530 
 1531 
 1532 -- |Cash flow dependent on the total return of an 'QuantLib.Index.Equity.EquityIndex' (not a coupon
 1533 -- -- no accruals): @index(fixingDate)\/index(baseDate)@, or that ratio minus one if /growthOnly/.
 1534 -- If no 'EquityCashFlowPricer' is attached via 'setEquityCashFlowPricer', 'equityCashFlowAmount'
 1535 -- computes this ratio directly from the index; a pricer (e.g. 'equityQuantoCashFlowPricer') is only
 1536 -- needed to price a quanto-adjusted variant.
 1537 equityCashFlow :: (Double) -- ^notional
 1538  -> (EquityIndex) -> (Day) -- ^baseDate
 1539  -> (Day) -- ^fixingDate
 1540  -> (Day) -- ^paymentDate
 1541  -> (Bool) -- ^growthOnly
 1542  -> IO ((EquityCashFlow))
 1543 equityCashFlow a1 a2 a3 a4 a5 a6 =
 1544   let {a1' = realToFrac a1} in 
 1545   withEquityIndex a2 $ \a2' -> 
 1546   withDay a3 $ \a3' -> 
 1547   withDay a4 $ \a4' -> 
 1548   withDay a5 $ \a5' -> 
 1549   let {a6' = C2HSImp.fromBool a6} in 
 1550   preErrorCheck $ \a7' -> 
 1551   equityCashFlow'_ a1' a2' a3' a4' a5' a6' a7' >>= \res ->
 1552   peekEquityCashFlow res >>= \res' ->
 1553   errorCheck  a7'>>
 1554   return (res')
 1555 
 1556 
 1557 
 1558 -- |Amount of the cash flow: the index ratio (times notional), or the ratio minus one if growthOnly --
 1559 -- or, if a pricer is attached, the notional times the pricer's 'price'.
 1560 equityCashFlowAmount :: (EquityCashFlow) -> IO ((Double))
 1561 equityCashFlowAmount a1 =
 1562   withEquityCashFlow a1 $ \a1' -> 
 1563   preErrorCheck $ \a2' -> 
 1564   equityCashFlowAmount'_ a1' a2' >>= \res ->
 1565   let {res' = realToFrac res} in
 1566   errorCheck  a2'>>
 1567   return (res')
 1568 
 1569 
 1570 
 1571 -- |Fixing used as the base of the ratio (as of /baseDate/).
 1572 equityCashFlowBaseFixing :: (EquityCashFlow) -> IO ((Double))
 1573 equityCashFlowBaseFixing a1 =
 1574   withEquityCashFlow a1 $ \a1' -> 
 1575   preErrorCheck $ \a2' -> 
 1576   equityCashFlowBaseFixing'_ a1' a2' >>= \res ->
 1577   let {res' = realToFrac res} in
 1578   errorCheck  a2'>>
 1579   return (res')
 1580 
 1581 
 1582 
 1583 -- |Fixing used as the numerator of the ratio (as of /fixingDate/).
 1584 equityCashFlowIndexFixing :: (EquityCashFlow) -> IO ((Double))
 1585 equityCashFlowIndexFixing a1 =
 1586   withEquityCashFlow a1 $ \a1' -> 
 1587   preErrorCheck $ \a2' -> 
 1588   equityCashFlowIndexFixing'_ a1' a2' >>= \res ->
 1589   let {res' = realToFrac res} in
 1590   errorCheck  a2'>>
 1591   return (res')
 1592 
 1593 
 1594 
 1595 -- |Attach a pricer (e.g. from 'equityQuantoCashFlowPricer') to a single 'EquityCashFlow'; see
 1596 -- 'setEquityLegPricer' to attach one to every 'EquityCashFlow' in a leg instead.
 1597 setEquityCashFlowPricer :: (EquityCashFlow) -> (EquityCashFlowPricer) -> IO ()
 1598 setEquityCashFlowPricer a1 a2 =
 1599   withEquityCashFlow a1 $ \a1' -> 
 1600   withEquityCashFlowPricer a2 $ \a2' -> 
 1601   preErrorCheck $ \a3' -> 
 1602   setEquityCashFlowPricer'_ a1' a2' a3' >>
 1603   errorCheck  a3'>>
 1604   return ()
 1605 
 1606 
 1607 
 1608 -- |Quanto-adjusted pricer for an 'EquityCashFlow' whose equity leg is denominated in a currency
 1609 -- other than the swap's payment currency.
 1610 equityQuantoCashFlowPricer :: (GenYieldTermStructure y) -- ^quantoCurrencyTermStructure
 1611  -> (GenBlackVolTermStructure bv1) -- ^equityVolatility
 1612  -> (GenBlackVolTermStructure bv2) -- ^fxVolatility
 1613  -> (GenQuote q) -- ^correlation
 1614  -> IO ((EquityCashFlowPricer))
 1615 equityQuantoCashFlowPricer a1 a2 a3 a4 =
 1616   withYieldTermStructure a1 $ \a1' -> 
 1617   withBlackVolTermStructure a2 $ \a2' -> 
 1618   withBlackVolTermStructure a3 $ \a3' -> 
 1619   withQuote a4 $ \a4' -> 
 1620   preErrorCheck $ \a5' -> 
 1621   equityQuantoCashFlowPricer'_ a1' a2' a3' a4' a5' >>= \res ->
 1622   peekEquityCashFlowPricer res >>= \res' ->
 1623   errorCheck  a5'>>
 1624   return (res')
 1625 
 1626 
 1627 
 1628 -- |Attach a pricer to every 'EquityCashFlow' found in /leg/ (non-'EquityCashFlow' entries are left
 1629 -- untouched); see 'setEquityCashFlowPricer' to attach one to a single cash flow instead.
 1630 setEquityLegPricer :: (GenLeg l) -> (EquityCashFlowPricer) -> IO ()
 1631 setEquityLegPricer a1 a2 =
 1632   withLeg a1 $ \a1' -> 
 1633   withEquityCashFlowPricer a2 $ \a2' -> 
 1634   preErrorCheck $ \a3' -> 
 1635   setEquityLegPricer'_ a1' a2' a3' >>
 1636   errorCheck  a3'>>
 1637   return ()
 1638 
 1639 
 1640 
 1641 -- |try to downcast leg to a coupon leg
 1642 -- don't blame me, it's how QuantLib works
 1643 toCouponLeg :: (GenLeg l) -> IO ((CouponLeg))
 1644 toCouponLeg a1 =
 1645   withLeg a1 $ \a1' -> 
 1646   preErrorCheck $ \a2' -> 
 1647   toCouponLeg'_ a1' a2' >>= \res ->
 1648   peekCouponLeg res >>= \res' ->
 1649   errorCheck  a2'>>
 1650   return (res')
 1651 
 1652 
 1653 
 1654 data YieldCurveModel = Standard
 1655                      | ExactYield
 1656                      | ParallelShifts
 1657                      | NonParallelShifts
 1658   deriving (Enum,Show,Eq,Read)
 1659 
 1660 
 1661 
 1662 
 1663 
 1664 
 1665 
 1666 
 1667 
 1668 
 1669 
 1670 
 1671 -- |Black-formula pricer for capped/floored Ibor coupons
 1672 blackIborCouponPricer :: (GenOptionletVolatilityStructure ov) -> (TimingAdjustment) -> (Maybe (GenQuote q)) -- ^correlation
 1673  -> (Maybe Bool) -- ^useIndexedCoupon
 1674  -> IO ((FloatingRateCouponPricer))
 1675 blackIborCouponPricer a1 a2 a3 a4 =
 1676   withOptionletVolatilityStructure a1 $ \a1' -> 
 1677   let {a2' = (fromIntegral . fromEnum) a2} in 
 1678   withMaybeQuote a3 $ \a3' -> 
 1679   let {a4' = fromMaybeBool a4} in 
 1680   preErrorCheck $ \a5' -> 
 1681   blackIborCouponPricer'_ a1' a2' a3' a4' a5' >>= \res ->
 1682   peekFloatingRateCouponPricer res >>= \res' ->
 1683   errorCheck  a5'>>
 1684   return (res')
 1685 
 1686 
 1687 
 1688 -- |BGM-based pricer for 'RangeAccrualFloatersCoupon's (a 'rangeAccrualLeg')
 1689 rangeAccrualPricerByBgm :: (Double) -- ^correlation
 1690  -> (SmileSection) -- ^smilesOnExpiry
 1691  -> (SmileSection) -- ^smilesOnPayment
 1692  -> (Bool) -- ^withSmile
 1693  -> (Bool) -- ^byCallSpread
 1694  -> IO ((FloatingRateCouponPricer))
 1695 rangeAccrualPricerByBgm a1 a2 a3 a4 a5 =
 1696   let {a1' = realToFrac a1} in 
 1697   withSmileSection a2 $ \a2' -> 
 1698   withSmileSection a3 $ \a3' -> 
 1699   let {a4' = C2HSImp.fromBool a4} in 
 1700   let {a5' = C2HSImp.fromBool a5} in 
 1701   preErrorCheck $ \a6' -> 
 1702   rangeAccrualPricerByBgm'_ a1' a2' a3' a4' a5' a6' >>= \res ->
 1703   peekFloatingRateCouponPricer res >>= \res' ->
 1704   errorCheck  a6'>>
 1705   return (res')
 1706 
 1707 
 1708 
 1709 -- |Black-formula pricer for capped\/floored 'yoyInflationLeg' coupons.
 1710 blackYoYInflationCouponPricer :: (YoYOptionletVolatilitySurface) -> (GenYieldTermStructure y) -- ^nominalTermStructure
 1711  -> IO ((YoYInflationCouponPricer))
 1712 blackYoYInflationCouponPricer a1 a2 =
 1713   withGenVolatilityTermStructure a1 $ \a1' -> 
 1714   withYieldTermStructure a2 $ \a2' -> 
 1715   preErrorCheck $ \a3' -> 
 1716   blackYoYInflationCouponPricer'_ a1' a2' a3' >>= \res ->
 1717   peekYoYInflationCouponPricer res >>= \res' ->
 1718   errorCheck  a3'>>
 1719   return (res')
 1720 
 1721 
 1722 
 1723 -- |Unit-Displaced-Black-formula pricer for capped\/floored 'yoyInflationLeg' coupons.
 1724 unitDisplacedBlackYoYInflationCouponPricer :: (YoYOptionletVolatilitySurface) -> (GenYieldTermStructure y) -- ^nominalTermStructure
 1725  -> IO ((YoYInflationCouponPricer))
 1726 unitDisplacedBlackYoYInflationCouponPricer a1 a2 =
 1727   withGenVolatilityTermStructure a1 $ \a1' -> 
 1728   withYieldTermStructure a2 $ \a2' -> 
 1729   preErrorCheck $ \a3' -> 
 1730   unitDisplacedBlackYoYInflationCouponPricer'_ a1' a2' a3' >>= \res ->
 1731   peekYoYInflationCouponPricer res >>= \res' ->
 1732   errorCheck  a3'>>
 1733   return (res')
 1734 
 1735 
 1736 
 1737 -- |Bachelier-formula pricer for capped\/floored 'yoyInflationLeg' coupons.
 1738 bachelierYoYInflationCouponPricer :: (YoYOptionletVolatilitySurface) -> (GenYieldTermStructure y) -- ^nominalTermStructure
 1739  -> IO ((YoYInflationCouponPricer))
 1740 bachelierYoYInflationCouponPricer a1 a2 =
 1741   withGenVolatilityTermStructure a1 $ \a1' -> 
 1742   withYieldTermStructure a2 $ \a2' -> 
 1743   preErrorCheck $ \a3' -> 
 1744   bachelierYoYInflationCouponPricer'_ a1' a2' a3' >>= \res ->
 1745   peekYoYInflationCouponPricer res >>= \res' ->
 1746   errorCheck  a3'>>
 1747   return (res')
 1748 
 1749 
 1750 
 1751 -- |Set the pricer of every 'QuantLib.Instrument.InflationCapFloor.YoYInflationCapFloor'-ready
 1752 -- 'YoYInflationCoupon'\/'CappedFlooredYoYInflationCoupon' in /leg/. Required before pricing (via
 1753 -- 'QuantLib.CashFlow.npv' or an 'QuantLib.Instrument.setPricingEngine'd instrument built on the
 1754 -- leg) any 'yoyInflationLeg' built with non-empty caps\/floors -- 'yoyInflationLeg' auto-attaches
 1755 -- a default (non-vol) pricer only when caps and floors are both empty.
 1756 setYoYInflationCouponPricer :: (GenLeg l) -> (YoYInflationCouponPricer) -> IO ()
 1757 setYoYInflationCouponPricer a1 a2 =
 1758   withLeg a1 $ \a1' -> 
 1759   withYoYInflationCouponPricer a2 $ \a2' -> 
 1760   preErrorCheck $ \a3' -> 
 1761   setYoYInflationCouponPricer'_ a1' a2' a3' >>
 1762   errorCheck  a3'>>
 1763   return ()
 1764 
 1765 
 1766 
 1767 -- |Set the pricer of every floating-rate coupon in /leg/.
 1768 setCouponPricer :: (GenLeg l) -> (FloatingRateCouponPricer) -> IO ()
 1769 setCouponPricer a1 a2 =
 1770   withLeg a1 $ \a1' -> 
 1771   withFloatingRateCouponPricer a2 $ \a2' -> 
 1772   preErrorCheck $ \a3' -> 
 1773   setCouponPricer'_ a1' a2' a3' >>
 1774   errorCheck  a3'>>
 1775   return ()
 1776 
 1777 
 1778 
 1779 -- |Set the pricer of every floating-rate coupon in /leg/, picking each coupon's pricer from
 1780 -- /pricers/ by matching coupon type.
 1781 setCouponPricers :: (GenLeg l) -> ([FloatingRateCouponPricer]) -> IO ()
 1782 setCouponPricers a1 a2 =
 1783   withLeg a1 $ \a1' -> 
 1784   withFloatingRateCouponPricerArray a2 $ \(a2'1, a2'2) -> 
 1785   preErrorCheck $ \a3' -> 
 1786   setCouponPricers'_ a1' a2'1  a2'2 a3' >>
 1787   errorCheck  a3'>>
 1788   return ()
 1789 
 1790 
 1791 
 1792 -- |CMS-coupon pricer via static replication (Hagan's "Conundrums..."), using an analytic
 1793 -- closed-form approximation of the replication integrals.
 1794 analyticHaganPricer :: (GenSwaptionVolatilityStructure sv) -> (YieldCurveModel) -> (GenQuote q) -- ^meanReversion
 1795  -> IO ((FloatingRateCouponPricer))
 1796 analyticHaganPricer a1 a2 a3 =
 1797   withSwaptionVolatilityStructure a1 $ \a1' -> 
 1798   let {a2' = (fromIntegral . fromEnum) a2} in 
 1799   withQuote a3 $ \a3' -> 
 1800   preErrorCheck $ \a4' -> 
 1801   analyticHaganPricer'_ a1' a2' a3' a4' >>= \res ->
 1802   peekFloatingRateCouponPricer res >>= \res' ->
 1803   errorCheck  a4'>>
 1804   return (res')
 1805 
 1806 
 1807 
 1808 -- |CMS-coupon pricer via static replication (Hagan's "Conundrums..."), evaluating the
 1809 -- replication integrals by numerical integration over vanilla swaption prices.
 1810 numericHaganPricer :: (GenSwaptionVolatilityStructure sv) -> (YieldCurveModel) -> (GenQuote q) -- ^meanReversion
 1811  -> (Double) -- ^lowerLimit
 1812  -> (Double) -- ^upperLimit
 1813  -> (Double) -- ^precision
 1814  -> (Double) -- ^hardUpperLimit
 1815  -> IO ((FloatingRateCouponPricer))
 1816 numericHaganPricer a1 a2 a3 a4 a5 a6 a7 =
 1817   withSwaptionVolatilityStructure a1 $ \a1' -> 
 1818   let {a2' = (fromIntegral . fromEnum) a2} in 
 1819   withQuote a3 $ \a3' -> 
 1820   let {a4' = realToFrac a4} in 
 1821   let {a5' = realToFrac a5} in 
 1822   let {a6' = realToFrac a6} in 
 1823   let {a7' = realToFrac a7} in 
 1824   preErrorCheck $ \a8' -> 
 1825   numericHaganPricer'_ a1' a2' a3' a4' a5' a6' a7' a8' >>= \res ->
 1826   peekFloatingRateCouponPricer res >>= \res' ->
 1827   errorCheck  a8'>>
 1828   return (res')
 1829 
 1830 
 1831 
 1832 -- |The strategy 'LinearTsrPricer' uses to pick the integration cut-off strike bounds; each
 1833 -- carries the strategy-specific parameter upstream's corresponding @Settings::withX@ takes
 1834 -- ('LinearTsrRateBound' has none). Pass explicit bounds via 'LinearTsrPricerSettings''
 1835 -- /ltsrBounds/ rather than baking upstream's own default bounds in here, since upstream's
 1836 -- no-explicit-bounds overloads aren't just sugar for those same numbers -- they also flip
 1837 -- @Settings::defaultBounds_@, which under a normal-vol swaption surface adjusts the lower
 1838 -- bound to @min(-upperBound, lowerBound)@ (see @ql/cashflows/lineartsrpricer.cpp@). Passing
 1839 -- 'Nothing' reaches that adjustment; passing explicit bounds via 'Just' does not.
 1840 data LinearTsrPricerStrategy
 1841   = LinearTsrRateBound
 1842   | LinearTsrVegaRatio Double        -- ^vegaRatio
 1843   | LinearTsrPriceThreshold Double   -- ^priceThreshold
 1844   | LinearTsrBSStdDevs Double        -- ^stdDevs
 1845   deriving (Show, Eq)
 1846 
 1847 -- |'ltsrBounds' of 'Nothing' uses upstream's own default lower\/upper rate bounds (and, for a
 1848 -- normal-vol surface, its default-bounds strike adjustment -- see 'LinearTsrPricerStrategy');
 1849 -- @'Just' (lower, upper)@ pins explicit bounds instead.
 1850 data LinearTsrPricerSettings = LinearTsrPricerSettings
 1851   { ltsrStrategy :: LinearTsrPricerStrategy
 1852   , ltsrBounds :: Maybe (Double, Double)
 1853   } deriving (Show, Eq)
 1854 
 1855 -- |CMS-coupon pricer using a linear terminal swap rate model (Andersen\/Piterbarg 16.3.2).
 1856 -- /couponDiscountCurve/ of 'Nothing' uses the coupon's own discount curve, matching upstream's
 1857 -- default empty 'Handle'. The upstream constructor's trailing /integrator/ parameter (an
 1858 -- advanced numerical-integration override) is not exposed; upstream's own default
 1859 -- (@ext::shared_ptr\<Integrator\>()@) is always used.
 1860 linearTsrPricer :: GenSwaptionVolatilityStructure sv -> GenQuote q -> Maybe (GenYieldTermStructure y)
 1861   -> LinearTsrPricerSettings -> IO FloatingRateCouponPricer
 1862 linearTsrPricer swaptionVol meanReversion couponDiscountCurve (LinearTsrPricerSettings strat bounds) =
 1863   linearTsrPricer_ swaptionVol meanReversion couponDiscountCurve strategyTag param
 1864     (maybe False (const True) bounds) lowerBound upperBound
 1865   where
 1866     (strategyTag, param) = case strat of
 1867       LinearTsrRateBound        -> (fromEnum LinearTsrPricerRateBound, 0)
 1868       LinearTsrVegaRatio p      -> (fromEnum LinearTsrPricerVegaRatio, p)
 1869       LinearTsrPriceThreshold p -> (fromEnum LinearTsrPricerPriceThreshold, p)
 1870       LinearTsrBSStdDevs p      -> (fromEnum LinearTsrPricerBSStdDevs, p)
 1871     (lowerBound, upperBound) = fromMaybe (0, 0) bounds
 1872 
 1873 data LinearTsrPricerStrategyTag = LinearTsrPricerRateBound
 1874                                 | LinearTsrPricerVegaRatio
 1875                                 | LinearTsrPricerPriceThreshold
 1876                                 | LinearTsrPricerBSStdDevs
 1877   deriving (Show,Eq,Read)
 1878 instance Enum LinearTsrPricerStrategyTag where
 1879   succ LinearTsrPricerRateBound = LinearTsrPricerVegaRatio
 1880   succ LinearTsrPricerVegaRatio = LinearTsrPricerPriceThreshold
 1881   succ LinearTsrPricerPriceThreshold = LinearTsrPricerBSStdDevs
 1882   succ LinearTsrPricerBSStdDevs = error "LinearTsrPricerStrategyTag.succ: LinearTsrPricerBSStdDevs has no successor"
 1883 
 1884   pred LinearTsrPricerVegaRatio = LinearTsrPricerRateBound
 1885   pred LinearTsrPricerPriceThreshold = LinearTsrPricerVegaRatio
 1886   pred LinearTsrPricerBSStdDevs = LinearTsrPricerPriceThreshold
 1887   pred LinearTsrPricerRateBound = error "LinearTsrPricerStrategyTag.pred: LinearTsrPricerRateBound has no predecessor"
 1888 
 1889   enumFromTo from to = go from
 1890     where
 1891       end = fromEnum to
 1892       go v = case compare (fromEnum v) end of
 1893                  LT -> v : go (succ v)
 1894                  EQ -> [v]
 1895                  GT -> []
 1896 
 1897   enumFrom from = enumFromTo from LinearTsrPricerBSStdDevs
 1898 
 1899   fromEnum LinearTsrPricerRateBound = 0
 1900   fromEnum LinearTsrPricerVegaRatio = 1
 1901   fromEnum LinearTsrPricerPriceThreshold = 2
 1902   fromEnum LinearTsrPricerBSStdDevs = 3
 1903 
 1904   toEnum 0 = LinearTsrPricerRateBound
 1905   toEnum 1 = LinearTsrPricerVegaRatio
 1906   toEnum 2 = LinearTsrPricerPriceThreshold
 1907   toEnum 3 = LinearTsrPricerBSStdDevs
 1908   toEnum unmatched = error ("LinearTsrPricerStrategyTag.toEnum: Cannot match " ++ show unmatched)
 1909 
 1910 
 1911 
 1912 -- |Raw binding for 'linearTsrPricer', taking the 'LinearTsrPricerSettings' unpacked into a
 1913 -- strategy tag\/parameter and an explicit-bounds flag.
 1914 linearTsrPricer_ :: (GenSwaptionVolatilityStructure sv) -> (GenQuote q) -- ^meanReversion
 1915  -> (Maybe (GenYieldTermStructure y)) -- ^couponDiscountCurve
 1916  -> (Int) -- ^strategy tag, see 'LinearTsrPricerStrategyTag'
 1917  -> (Double) -- ^strategy-specific parameter (unused for RateBound)
 1918  -> (Bool) -- ^haveBounds
 1919  -> (Double) -- ^lowerBound (ignored unless haveBounds)
 1920  -> (Double) -- ^upperBound (ignored unless haveBounds)
 1921  -> IO ((FloatingRateCouponPricer))
 1922 linearTsrPricer_ a1 a2 a3 a4 a5 a6 a7 a8 =
 1923   withSwaptionVolatilityStructure a1 $ \a1' -> 
 1924   withQuote a2 $ \a2' -> 
 1925   withMaybeYieldTermStructure a3 $ \a3' -> 
 1926   let {a4' = fromIntegral a4} in 
 1927   let {a5' = realToFrac a5} in 
 1928   let {a6' = C2HSImp.fromBool a6} in 
 1929   let {a7' = realToFrac a7} in 
 1930   let {a8' = realToFrac a8} in 
 1931   preErrorCheck $ \a9' -> 
 1932   linearTsrPricer_'_ a1' a2' a3' a4' a5' a6' a7' a8' a9' >>= \res ->
 1933   peekFloatingRateCouponPricer res >>= \res' ->
 1934   errorCheck  a9'>>
 1935   return (res')
 1936 
 1937 
 1938 
 1939 -- vim: set ff=unix ts=8 sts=2 sw=2 et:
 1940 
 1941 foreign import ccall safe "QuantLib/CashFlow.chs.h qlLeg"
 1942   qlLeg'_ :: (C2HSImp.CUInt -> ((C2HSImp.Ptr C2HSImp.CDouble) -> ((C2HSImp.Ptr C2HSImp.CInt) -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO (C2HSImp.Ptr (CLeg')))))))
 1943 
 1944 foreign import ccall safe "QuantLib/CashFlow.chs.h qlLegStartDate"
 1945   startDate'_ :: ((C2HSImp.Ptr (CLeg')) -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO C2HSImp.CInt)))
 1946 
 1947 foreign import ccall safe "QuantLib/CashFlow.chs.h qlNextCashFlows"
 1948   nextCashFlows'_ :: ((C2HSImp.Ptr (CLeg')) -> (C2HSImp.CInt -> (C2HSImp.CInt -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO (C2HSImp.Ptr (CLeg')))))))
 1949 
 1950 foreign import ccall safe "QuantLib/CashFlow.chs.h qlPreviousCashFlows"
 1951   previousCashFlows'_ :: ((C2HSImp.Ptr (CLeg')) -> (C2HSImp.CInt -> (C2HSImp.CInt -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO (C2HSImp.Ptr (CLeg')))))))
 1952 
 1953 foreign import ccall safe "QuantLib/CashFlow.chs.h qlLegCashFlows"
 1954   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 C2HSImp.CChar)) -> (IO ())))))))))))
 1955 
 1956 foreign import ccall safe "QuantLib/CashFlow.chs.h qlCashFlowsDuration"
 1957   duration'_ :: ((C2HSImp.Ptr (CLeg')) -> ((C2HSImp.Ptr (CInterestRate)) -> (C2HSImp.CInt -> (C2HSImp.CInt -> (C2HSImp.CInt -> (C2HSImp.CInt -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO C2HSImp.CDouble))))))))
 1958 
 1959 foreign import ccall safe "QuantLib/CashFlow.chs.h qlCashFlowsAccrualDays"
 1960   accrualDays'_ :: ((C2HSImp.Ptr (CLeg')) -> (C2HSImp.CInt -> (C2HSImp.CInt -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO C2HSImp.CInt)))))
 1961 
 1962 foreign import ccall safe "QuantLib/CashFlow.chs.h qlCashFlowsAccrualEndDate"
 1963   accrualEndDate'_ :: ((C2HSImp.Ptr (CLeg')) -> (C2HSImp.CInt -> (C2HSImp.CInt -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO C2HSImp.CInt)))))
 1964 
 1965 foreign import ccall safe "QuantLib/CashFlow.chs.h qlCashFlowsAccrualPeriod"
 1966   accrualPeriod'_ :: ((C2HSImp.Ptr (CLeg')) -> (C2HSImp.CInt -> (C2HSImp.CInt -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO C2HSImp.CDouble)))))
 1967 
 1968 foreign import ccall safe "QuantLib/CashFlow.chs.h qlCashFlowsAccrualStartDate"
 1969   accrualStartDate'_ :: ((C2HSImp.Ptr (CLeg')) -> (C2HSImp.CInt -> (C2HSImp.CInt -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO C2HSImp.CInt)))))
 1970 
 1971 foreign import ccall safe "QuantLib/CashFlow.chs.h qlCashFlowsAccruedAmount"
 1972   accruedAmount'_ :: ((C2HSImp.Ptr (CLeg')) -> (C2HSImp.CInt -> (C2HSImp.CInt -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO C2HSImp.CDouble)))))
 1973 
 1974 foreign import ccall safe "QuantLib/CashFlow.chs.h qlCashFlowsAccruedDays"
 1975   accruedDays'_ :: ((C2HSImp.Ptr (CLeg')) -> (C2HSImp.CInt -> (C2HSImp.CInt -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO C2HSImp.CInt)))))
 1976 
 1977 foreign import ccall safe "QuantLib/CashFlow.chs.h qlCashFlowsAccruedPeriod"
 1978   accruedPeriod'_ :: ((C2HSImp.Ptr (CLeg')) -> (C2HSImp.CInt -> (C2HSImp.CInt -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO C2HSImp.CDouble)))))
 1979 
 1980 foreign import ccall safe "QuantLib/CashFlow.chs.h qlCashFlowsBasisPointValue1"
 1981   basisPointValue'_ :: ((C2HSImp.Ptr (CLeg')) -> (C2HSImp.CDouble -> ((C2HSImp.Ptr (CDayCounter)) -> (C2HSImp.CInt -> (C2HSImp.CInt -> (C2HSImp.CInt -> (C2HSImp.CInt -> (C2HSImp.CInt -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO C2HSImp.CDouble))))))))))
 1982 
 1983 foreign import ccall safe "QuantLib/CashFlow.chs.h qlCashFlowsBasisPointValue"
 1984   basisPointValue''_ :: ((C2HSImp.Ptr (CLeg')) -> ((C2HSImp.Ptr (CInterestRate)) -> (C2HSImp.CInt -> (C2HSImp.CInt -> (C2HSImp.CInt -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO C2HSImp.CDouble)))))))
 1985 
 1986 foreign import ccall safe "QuantLib/CashFlow.chs.h qlCashFlowsBps1"
 1987   bpsFromYield''_ :: ((C2HSImp.Ptr (CLeg')) -> ((C2HSImp.Ptr (CInterestRate)) -> (C2HSImp.CInt -> (C2HSImp.CInt -> (C2HSImp.CInt -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO C2HSImp.CDouble)))))))
 1988 
 1989 foreign import ccall safe "QuantLib/CashFlow.chs.h qlCashFlowsBps2"
 1990   bpsFromYield'_ :: ((C2HSImp.Ptr (CLeg')) -> (C2HSImp.CDouble -> ((C2HSImp.Ptr (CDayCounter)) -> (C2HSImp.CInt -> (C2HSImp.CInt -> (C2HSImp.CInt -> (C2HSImp.CInt -> (C2HSImp.CInt -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO C2HSImp.CDouble))))))))))
 1991 
 1992 foreign import ccall safe "QuantLib/CashFlow.chs.h qlCashFlowsConvexity1"
 1993   convexity'_ :: ((C2HSImp.Ptr (CLeg')) -> (C2HSImp.CDouble -> ((C2HSImp.Ptr (CDayCounter)) -> (C2HSImp.CInt -> (C2HSImp.CInt -> (C2HSImp.CInt -> (C2HSImp.CInt -> (C2HSImp.CInt -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO C2HSImp.CDouble))))))))))
 1994 
 1995 foreign import ccall safe "QuantLib/CashFlow.chs.h qlCashFlowsConvexity"
 1996   convexity''_ :: ((C2HSImp.Ptr (CLeg')) -> ((C2HSImp.Ptr (CInterestRate)) -> (C2HSImp.CInt -> (C2HSImp.CInt -> (C2HSImp.CInt -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO C2HSImp.CDouble)))))))
 1997 
 1998 foreign import ccall safe "QuantLib/CashFlow.chs.h qlCashFlowsDuration1"
 1999   duration''_ :: ((C2HSImp.Ptr (CLeg')) -> (C2HSImp.CDouble -> ((C2HSImp.Ptr (CDayCounter)) -> (C2HSImp.CInt -> (C2HSImp.CInt -> (C2HSImp.CInt -> (C2HSImp.CInt -> (C2HSImp.CInt -> (C2HSImp.CInt -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO C2HSImp.CDouble)))))))))))
 2000 
 2001 foreign import ccall safe "QuantLib/CashFlow.chs.h qlCashFlowsIsExpired"
 2002   isExpired'_ :: ((C2HSImp.Ptr (CLeg')) -> (C2HSImp.CInt -> (C2HSImp.CInt -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO C2HSImp.CInt)))))
 2003 
 2004 foreign import ccall safe "QuantLib/CashFlow.chs.h qlCashFlowsMaturityDate"
 2005   maturityDate'_ :: ((C2HSImp.Ptr (CLeg')) -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO C2HSImp.CInt)))
 2006 
 2007 foreign import ccall safe "QuantLib/CashFlow.chs.h qlCashFlowsNextCashFlowAmount"
 2008   nextCashFlowAmount'_ :: ((C2HSImp.Ptr (CLeg')) -> (C2HSImp.CInt -> (C2HSImp.CInt -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO C2HSImp.CDouble)))))
 2009 
 2010 foreign import ccall safe "QuantLib/CashFlow.chs.h qlCashFlowsNextCashFlowDate"
 2011   nextCashFlowDate'_ :: ((C2HSImp.Ptr (CLeg')) -> (C2HSImp.CInt -> (C2HSImp.CInt -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO C2HSImp.CInt)))))
 2012 
 2013 foreign import ccall safe "QuantLib/CashFlow.chs.h qlCashFlowsNextCouponRate"
 2014   nextCouponRate'_ :: ((C2HSImp.Ptr (CLeg')) -> (C2HSImp.CInt -> (C2HSImp.CInt -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO C2HSImp.CDouble)))))
 2015 
 2016 foreign import ccall safe "QuantLib/CashFlow.chs.h qlCashFlowsNominal"
 2017   nominal'_ :: ((C2HSImp.Ptr (CLeg')) -> (C2HSImp.CInt -> (C2HSImp.CInt -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO C2HSImp.CDouble)))))
 2018 
 2019 foreign import ccall safe "QuantLib/CashFlow.chs.h qlCashFlowsNpv1"
 2020   npvFromYield''_ :: ((C2HSImp.Ptr (CLeg')) -> ((C2HSImp.Ptr (CInterestRate)) -> (C2HSImp.CInt -> (C2HSImp.CInt -> (C2HSImp.CInt -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO C2HSImp.CDouble)))))))
 2021 
 2022 foreign import ccall safe "QuantLib/CashFlow.chs.h qlCashFlowsNpv2"
 2023   npvFromYield'_ :: ((C2HSImp.Ptr (CLeg')) -> (C2HSImp.CDouble -> ((C2HSImp.Ptr (CDayCounter)) -> (C2HSImp.CInt -> (C2HSImp.CInt -> (C2HSImp.CInt -> (C2HSImp.CInt -> (C2HSImp.CInt -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO C2HSImp.CDouble))))))))))
 2024 
 2025 foreign import ccall safe "QuantLib/CashFlow.chs.h qlCashFlowsAtmRate"
 2026   atmRate'_ :: ((C2HSImp.Ptr (CLeg')) -> ((C2HSImp.Ptr (CYieldTermStructure')) -> (C2HSImp.CInt -> (C2HSImp.CInt -> (C2HSImp.CInt -> (C2HSImp.CDouble -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO C2HSImp.CDouble))))))))
 2027 
 2028 foreign import ccall safe "QuantLib/CashFlow.chs.h qlCashFlowsBps"
 2029   bps'_ :: ((C2HSImp.Ptr (CLeg')) -> ((C2HSImp.Ptr (CYieldTermStructure')) -> (C2HSImp.CInt -> (C2HSImp.CInt -> (C2HSImp.CInt -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO C2HSImp.CDouble)))))))
 2030 
 2031 foreign import ccall safe "QuantLib/CashFlow.chs.h qlCashFlowsNpv3"
 2032   npv''_ :: ((C2HSImp.Ptr (CLeg')) -> ((C2HSImp.Ptr (CYieldTermStructure')) -> (C2HSImp.CDouble -> (C2HSImp.CInt -> (C2HSImp.CInt -> (C2HSImp.CInt -> (C2HSImp.CInt -> (C2HSImp.CInt -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO C2HSImp.CDouble))))))))))
 2033 
 2034 foreign import ccall safe "QuantLib/CashFlow.chs.h qlCashFlowsNpv"
 2035   npv'_ :: ((C2HSImp.Ptr (CLeg')) -> ((C2HSImp.Ptr (CYieldTermStructure')) -> (C2HSImp.CInt -> (C2HSImp.CInt -> (C2HSImp.CInt -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO C2HSImp.CDouble)))))))
 2036 
 2037 foreign import ccall safe "QuantLib/CashFlow.chs.h qlCashFlowsNpvbps"
 2038   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 C2HSImp.CChar)) -> (IO ())))))))))
 2039 
 2040 foreign import ccall safe "QuantLib/CashFlow.chs.h qlCashFlowsZSpread"
 2041   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 C2HSImp.CChar)) -> (IO C2HSImp.CDouble)))))))))))))
 2042 
 2043 foreign import ccall safe "QuantLib/CashFlow.chs.h qlCashFlowsPreviousCashFlowAmount"
 2044   previousCashFlowAmount'_ :: ((C2HSImp.Ptr (CLeg')) -> (C2HSImp.CInt -> (C2HSImp.CInt -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO C2HSImp.CDouble)))))
 2045 
 2046 foreign import ccall safe "QuantLib/CashFlow.chs.h qlCashFlowsPreviousCashFlowDate"
 2047   previousCashFlowDate'_ :: ((C2HSImp.Ptr (CLeg')) -> (C2HSImp.CInt -> (C2HSImp.CInt -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO C2HSImp.CInt)))))
 2048 
 2049 foreign import ccall safe "QuantLib/CashFlow.chs.h qlCashFlowsPreviousCouponRate"
 2050   previousCouponRate'_ :: ((C2HSImp.Ptr (CLeg')) -> (C2HSImp.CInt -> (C2HSImp.CInt -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO C2HSImp.CDouble)))))
 2051 
 2052 foreign import ccall safe "QuantLib/CashFlow.chs.h qlCashFlowsReferencePeriodEnd"
 2053   referencePeriodEnd'_ :: ((C2HSImp.Ptr (CLeg')) -> (C2HSImp.CInt -> (C2HSImp.CInt -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO C2HSImp.CInt)))))
 2054 
 2055 foreign import ccall safe "QuantLib/CashFlow.chs.h qlCashFlowsReferencePeriodStart"
 2056   referencePeriodStart'_ :: ((C2HSImp.Ptr (CLeg')) -> (C2HSImp.CInt -> (C2HSImp.CInt -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO C2HSImp.CInt)))))
 2057 
 2058 foreign import ccall safe "QuantLib/CashFlow.chs.h qlCashFlowsYield"
 2059   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 C2HSImp.CChar)) -> (IO C2HSImp.CDouble)))))))))))))
 2060 
 2061 foreign import ccall safe "QuantLib/CashFlow.chs.h qlCashFlowsYieldValueBasisPoint1"
 2062   yieldValueBasisPoint'_ :: ((C2HSImp.Ptr (CLeg')) -> (C2HSImp.CDouble -> ((C2HSImp.Ptr (CDayCounter)) -> (C2HSImp.CInt -> (C2HSImp.CInt -> (C2HSImp.CInt -> (C2HSImp.CInt -> (C2HSImp.CInt -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO C2HSImp.CDouble))))))))))
 2063 
 2064 foreign import ccall safe "QuantLib/CashFlow.chs.h qlCashFlowsYieldValueBasisPoint"
 2065   yieldValueBasisPoint''_ :: ((C2HSImp.Ptr (CLeg')) -> ((C2HSImp.Ptr (CInterestRate)) -> (C2HSImp.CInt -> (C2HSImp.CInt -> (C2HSImp.CInt -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO C2HSImp.CDouble)))))))
 2066 
 2067 foreign import ccall safe "QuantLib/CashFlow.chs.h qlCouponAccrualStartDates"
 2068   couponAccrualStartDates'_ :: ((C2HSImp.Ptr (CCouponLeg')) -> ((C2HSImp.Ptr C2HSImp.CUInt) -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CInt)) -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO ())))))
 2069 
 2070 foreign import ccall safe "QuantLib/CashFlow.chs.h qlFixedDividend"
 2071   fixedDividend'_ :: (C2HSImp.CDouble -> (C2HSImp.CInt -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO (C2HSImp.Ptr (CDividend))))))
 2072 
 2073 foreign import ccall safe "QuantLib/CashFlow.chs.h qlFractionalDividend1"
 2074   fractionalDividend''_ :: (C2HSImp.CDouble -> (C2HSImp.CDouble -> (C2HSImp.CInt -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO (C2HSImp.Ptr (CDividend)))))))
 2075 
 2076 foreign import ccall safe "QuantLib/CashFlow.chs.h qlFractionalDividend"
 2077   fractionalDividend'_ :: (C2HSImp.CDouble -> (C2HSImp.CInt -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO (C2HSImp.Ptr (CDividend))))))
 2078 
 2079 foreign import ccall safe "QuantLib/CashFlow.chs.h qlAverageBMALeg"
 2080   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 C2HSImp.CChar)) -> (IO (C2HSImp.Ptr (CLeg'))))))))))))))
 2081 
 2082 foreign import ccall safe "QuantLib/CashFlow.chs.h qlFixedRateLeg"
 2083   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 C2HSImp.CChar)) -> (IO (C2HSImp.Ptr (CLeg'))))))))))))
 2084 
 2085 foreign import ccall safe "QuantLib/CashFlow.chs.h qlIborLeg"
 2086   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 -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO (C2HSImp.Ptr (CLeg')))))))))))))))))))))))))))))))
 2087 
 2088 foreign import ccall safe "QuantLib/CashFlow.chs.h qlCmsLeg"
 2089   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 C2HSImp.CChar)) -> (IO (C2HSImp.Ptr (CLeg'))))))))))))))))))))))))))))
 2090 
 2091 foreign import ccall safe "QuantLib/CashFlow.chs.h qlOvernightLeg"
 2092   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 C2HSImp.CChar)) -> (IO (C2HSImp.Ptr (CLeg'))))))))))))))
 2093 
 2094 foreign import ccall safe "QuantLib/CashFlow.chs.h qlRangeAccrualLeg"
 2095   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 C2HSImp.CChar)) -> (IO (C2HSImp.Ptr (CLeg')))))))))))))))))))))))
 2096 
 2097 foreign import ccall safe "QuantLib/CashFlow.chs.h qlCPILeg"
 2098   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 C2HSImp.CChar)) -> (IO (C2HSImp.Ptr (CLeg'))))))))))))))))))
 2099 
 2100 foreign import ccall safe "QuantLib/CashFlow.chs.h qlYoYInflationLeg"
 2101   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 C2HSImp.CChar)) -> (IO (C2HSImp.Ptr (CLeg'))))))))))))))))))))))))
 2102 
 2103 foreign import ccall safe "QuantLib/CashFlow.chs.h qlZeroInflationCashFlow"
 2104   zeroInflationCashFlow'_ :: (C2HSImp.CDouble -> ((C2HSImp.Ptr (CZeroInflationIndex')) -> (C2HSImp.CInt -> (C2HSImp.CInt -> (C2HSImp.CInt -> (C2HSImp.CInt -> (C2HSImp.CInt -> (C2HSImp.CInt -> (C2HSImp.CInt -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO (C2HSImp.Ptr (CZeroInflationCashFlow)))))))))))))
 2105 
 2106 foreign import ccall safe "QuantLib/CashFlow.chs.h qlZeroInflationCashFlowAmount"
 2107   zeroInflationCashFlowAmount'_ :: ((C2HSImp.Ptr (CZeroInflationCashFlow)) -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO C2HSImp.CDouble)))
 2108 
 2109 foreign import ccall safe "QuantLib/CashFlow.chs.h qlZeroInflationCashFlowBaseFixing"
 2110   zeroInflationCashFlowBaseFixing'_ :: ((C2HSImp.Ptr (CZeroInflationCashFlow)) -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO C2HSImp.CDouble)))
 2111 
 2112 foreign import ccall safe "QuantLib/CashFlow.chs.h qlZeroInflationCashFlowIndexFixing"
 2113   zeroInflationCashFlowIndexFixing'_ :: ((C2HSImp.Ptr (CZeroInflationCashFlow)) -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO C2HSImp.CDouble)))
 2114 
 2115 foreign import ccall safe "QuantLib/CashFlow.chs.h qlCPICashFlow"
 2116   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 C2HSImp.CChar)) -> (IO (C2HSImp.Ptr (CCPICashFlow))))))))))))))
 2117 
 2118 foreign import ccall safe "QuantLib/CashFlow.chs.h qlCPICashFlowAmount"
 2119   cpiCashFlowAmount'_ :: ((C2HSImp.Ptr (CCPICashFlow)) -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO C2HSImp.CDouble)))
 2120 
 2121 foreign import ccall safe "QuantLib/CashFlow.chs.h qlCPICashFlowBaseFixing"
 2122   cpiCashFlowBaseFixing'_ :: ((C2HSImp.Ptr (CCPICashFlow)) -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO C2HSImp.CDouble)))
 2123 
 2124 foreign import ccall safe "QuantLib/CashFlow.chs.h qlCPICashFlowIndexFixing"
 2125   cpiCashFlowIndexFixing'_ :: ((C2HSImp.Ptr (CCPICashFlow)) -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO C2HSImp.CDouble)))
 2126 
 2127 foreign import ccall safe "QuantLib/CashFlow.chs.h qlEquityCashFlow"
 2128   equityCashFlow'_ :: (C2HSImp.CDouble -> ((C2HSImp.Ptr (CEquityIndex')) -> (C2HSImp.CInt -> (C2HSImp.CInt -> (C2HSImp.CInt -> (C2HSImp.CInt -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO (C2HSImp.Ptr (CEquityCashFlow))))))))))
 2129 
 2130 foreign import ccall safe "QuantLib/CashFlow.chs.h qlEquityCashFlowAmount"
 2131   equityCashFlowAmount'_ :: ((C2HSImp.Ptr (CEquityCashFlow)) -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO C2HSImp.CDouble)))
 2132 
 2133 foreign import ccall safe "QuantLib/CashFlow.chs.h qlEquityCashFlowBaseFixing"
 2134   equityCashFlowBaseFixing'_ :: ((C2HSImp.Ptr (CEquityCashFlow)) -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO C2HSImp.CDouble)))
 2135 
 2136 foreign import ccall safe "QuantLib/CashFlow.chs.h qlEquityCashFlowIndexFixing"
 2137   equityCashFlowIndexFixing'_ :: ((C2HSImp.Ptr (CEquityCashFlow)) -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO C2HSImp.CDouble)))
 2138 
 2139 foreign import ccall safe "QuantLib/CashFlow.chs.h qlEquityCashFlowSetPricer"
 2140   setEquityCashFlowPricer'_ :: ((C2HSImp.Ptr (CEquityCashFlow)) -> ((C2HSImp.Ptr (CEquityCashFlowPricer)) -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO ()))))
 2141 
 2142 foreign import ccall safe "QuantLib/CashFlow.chs.h qlEquityQuantoCashFlowPricer"
 2143   equityQuantoCashFlowPricer'_ :: ((C2HSImp.Ptr (CYieldTermStructure')) -> ((C2HSImp.Ptr (CBlackVolTermStructure')) -> ((C2HSImp.Ptr (CBlackVolTermStructure')) -> ((C2HSImp.Ptr (CQuote')) -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO (C2HSImp.Ptr (CEquityCashFlowPricer))))))))
 2144 
 2145 foreign import ccall safe "QuantLib/CashFlow.chs.h qlQuantLibSetEquityCashFlowPricer"
 2146   setEquityLegPricer'_ :: ((C2HSImp.Ptr (CLeg')) -> ((C2HSImp.Ptr (CEquityCashFlowPricer)) -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO ()))))
 2147 
 2148 foreign import ccall safe "QuantLib/CashFlow.chs.h qlLegToCouponLeg"
 2149   toCouponLeg'_ :: ((C2HSImp.Ptr (CLeg')) -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO (C2HSImp.Ptr (CCouponLeg')))))
 2150 
 2151 foreign import ccall safe "QuantLib/CashFlow.chs.h qlBlackIborCouponPricer"
 2152   blackIborCouponPricer'_ :: ((C2HSImp.Ptr (COptionletVolatilityStructure')) -> (C2HSImp.CInt -> ((C2HSImp.Ptr (CQuote')) -> (C2HSImp.CInt -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO (C2HSImp.Ptr (CFloatingRateCouponPricer))))))))
 2153 
 2154 foreign import ccall safe "QuantLib/CashFlow.chs.h qlRangeAccrualPricerByBgm"
 2155   rangeAccrualPricerByBgm'_ :: (C2HSImp.CDouble -> ((C2HSImp.Ptr (CSmileSection)) -> ((C2HSImp.Ptr (CSmileSection)) -> (C2HSImp.CInt -> (C2HSImp.CInt -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO (C2HSImp.Ptr (CFloatingRateCouponPricer)))))))))
 2156 
 2157 foreign import ccall safe "QuantLib/CashFlow.chs.h qlBlackYoYInflationCouponPricer"
 2158   blackYoYInflationCouponPricer'_ :: ((C2HSImp.Ptr (CYoYOptionletVolatilitySurface')) -> ((C2HSImp.Ptr (CYieldTermStructure')) -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO (C2HSImp.Ptr (CYoYInflationCouponPricer))))))
 2159 
 2160 foreign import ccall safe "QuantLib/CashFlow.chs.h qlUnitDisplacedBlackYoYInflationCouponPricer"
 2161   unitDisplacedBlackYoYInflationCouponPricer'_ :: ((C2HSImp.Ptr (CYoYOptionletVolatilitySurface')) -> ((C2HSImp.Ptr (CYieldTermStructure')) -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO (C2HSImp.Ptr (CYoYInflationCouponPricer))))))
 2162 
 2163 foreign import ccall safe "QuantLib/CashFlow.chs.h qlBachelierYoYInflationCouponPricer"
 2164   bachelierYoYInflationCouponPricer'_ :: ((C2HSImp.Ptr (CYoYOptionletVolatilitySurface')) -> ((C2HSImp.Ptr (CYieldTermStructure')) -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO (C2HSImp.Ptr (CYoYInflationCouponPricer))))))
 2165 
 2166 foreign import ccall safe "QuantLib/CashFlow.chs.h qlSetYoYInflationCouponPricer"
 2167   setYoYInflationCouponPricer'_ :: ((C2HSImp.Ptr (CLeg')) -> ((C2HSImp.Ptr (CYoYInflationCouponPricer)) -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO ()))))
 2168 
 2169 foreign import ccall safe "QuantLib/CashFlow.chs.h qlQuantLibSetCouponPricer"
 2170   setCouponPricer'_ :: ((C2HSImp.Ptr (CLeg')) -> ((C2HSImp.Ptr (CFloatingRateCouponPricer)) -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO ()))))
 2171 
 2172 foreign import ccall safe "QuantLib/CashFlow.chs.h qlQuantLibSetCouponPricers"
 2173   setCouponPricers'_ :: ((C2HSImp.Ptr (CLeg')) -> (C2HSImp.CUInt -> ((C2HSImp.Ptr (C2HSImp.Ptr (CFloatingRateCouponPricer))) -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO ())))))
 2174 
 2175 foreign import ccall safe "QuantLib/CashFlow.chs.h qlAnalyticHaganPricer"
 2176   analyticHaganPricer'_ :: ((C2HSImp.Ptr (CSwaptionVolatilityStructure')) -> (C2HSImp.CInt -> ((C2HSImp.Ptr (CQuote')) -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO (C2HSImp.Ptr (CFloatingRateCouponPricer)))))))
 2177 
 2178 foreign import ccall safe "QuantLib/CashFlow.chs.h qlNumericHaganPricer"
 2179   numericHaganPricer'_ :: ((C2HSImp.Ptr (CSwaptionVolatilityStructure')) -> (C2HSImp.CInt -> ((C2HSImp.Ptr (CQuote')) -> (C2HSImp.CDouble -> (C2HSImp.CDouble -> (C2HSImp.CDouble -> (C2HSImp.CDouble -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO (C2HSImp.Ptr (CFloatingRateCouponPricer)))))))))))
 2180 
 2181 foreign import ccall safe "QuantLib/CashFlow.chs.h qlLinearTsrPricer"
 2182   linearTsrPricer_'_ :: ((C2HSImp.Ptr (CSwaptionVolatilityStructure')) -> ((C2HSImp.Ptr (CQuote')) -> ((C2HSImp.Ptr (CYieldTermStructure')) -> (C2HSImp.CInt -> (C2HSImp.CDouble -> (C2HSImp.CInt -> (C2HSImp.CDouble -> (C2HSImp.CDouble -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO (C2HSImp.Ptr (CFloatingRateCouponPricer))))))))))))