-- GENERATED by C->Haskell Compiler, version 0.28.8 Switcheroo, 25 November 2017 (Haskell)
-- Edit the ORIGNAL .chs file instead!


{-# LINE 1 "./QuantLib/CashFlow.chs" #-}
{-# LANGUAGE TemplateHaskell, FlexibleInstances #-}
module QuantLib.CashFlow
  (
    -- * Types
    -- ** Cash-flow hierarchy
    GenCashFlow
  , CashFlow
  , GenCoupon
  , Coupon
  , GenFloatingRateCoupon
  , FloatingRateCoupon
  , GenDigitalCoupon
  , DigitalCoupon
  , GenIndexedCashFlow
  , IndexedCashFlow
  , FixedRateCoupon
  , IborCoupon
  , AverageBMACoupon
  , StrippedCappedFlooredCoupon
  , CmsCoupon
  , DigitalCmsCoupon
  , DigitalCmsSpreadCoupon
  , MultipleResetsCoupon
  , OvernightIndexedCoupon
  , RangeAccrualFloatersCoupon
  , CPICoupon
  , YoYInflationCoupon
  , ZeroInflationCashFlow
  , CPICashFlow
  , EquityCashFlow
  , Dividend

    -- ** Legs
  , GenLeg
  , Leg
  , CouponLeg

    -- ** Coupon pricers
  , GenFloatingRateCouponPricer
  , FloatingRateCouponPricer
  , CmsCouponPricer
  , CPICouponPricer
  , YoYInflationCouponPricer
  , EquityCashFlowPricer

    -- ** Configuration
  , DurationType(..)
  , RateAveragingType(..)
  , TimingAdjustment(..)
  , PositionType(..)
  , CPIInterpolationType(..)
  , YieldCurveModel(..)
  , Discounting(..)
  , BpsDiscounting(..)
  , ReplicationType(..)
  , DigitalReplication
  , LinearTsrPricerStrategy(..)
  , LinearTsrPricerSettings(..)
  , IborLegOpts(..)
  , defaultIborLegOpts
  , CmsLegOpts(..)
  , defaultCmsLegOpts
  , DigitalIborLegOpts(..)
  , defaultDigitalIborLegOpts
  , DigitalCmsLegOpts(..)
  , defaultDigitalCmsLegOpts
  , DigitalCmsSpreadLegOpts(..)
  , defaultDigitalCmsSpreadLegOpts
  , MultipleResetsLegOpts(..)
  , defaultMultipleResetsLegOpts

    -- * Constructors
    -- ** Hierarchy conversion
  , asLeg
  , asCashFlow
  , asCoupon
  , asFloatingRateCoupon
  , asFloatingRateCouponPricer
  , toCouponLeg

    -- ** Cash flows and coupons
  , leg
  , cashFlowLeg
  , simpleCashFlow
  , indexedCashFlow
  , redemption
  , amortizingPayment
  , fixedRateCoupon
  , floatingRateCoupon
  , iborCoupon
  , averageBmaCoupon
  , cappedFlooredCoupon
  , strippedCappedFlooredCoupon
  , cappedFlooredIborCoupon
  , digitalIborCoupon
  , digitalCoupon
  , multipleResetsCoupon
  , rangeAccrualFloatersCoupon
  , overnightIndexedCoupon
  , cappedFlooredOvernightIndexedCoupon
  , cpiCoupon
  , cpiCouponFromBaseDate
  , cpiCouponWithBaseDate
  , yoyInflationCoupon
  , zeroInflationCashFlow
  , cpiCashFlow
  , equityCashFlow

    -- ** CMS coupons and digital replication
  , cmsCoupon
  , cappedFlooredCmsCoupon
  , cmsSpreadCoupon
  , cappedFlooredCmsSpreadCoupon
  , digitalReplication
  , digitalCmsCoupon
  , digitalCmsSpreadCoupon

    -- ** Dividends
  , fixedDividend
  , fractionalDividendWithNominal
  , fractionalDividend

    -- ** Coupon legs
  , fixedRateLeg
  , averageBmaLeg
  , iborLeg
  , iborLegWithOptions
  , digitalIborLeg
  , cmsLeg
  , cmsLegWithOptions
  , cmsSpreadLeg
  , digitalCmsLeg
  , digitalCmsSpreadLeg
  , multipleResetsLeg
  , overnightLeg
  , rangeAccrualLeg
  , cpiLeg
  , yoyInflationLeg

    -- ** Coupon pricers
  , blackIborCouponPricer
  , blackIborQuantoCouponPricer
  , analyticHaganPricer
  , numericHaganPricer
  , linearTsrPricer
  , lognormalCmsSpreadPricer
  , rangeAccrualPricerByBgm
  , averagingMultipleResetsPricer
  , compoundingMultipleResetsPricer
  , compoundingOvernightIndexedCouponPricer
  , arithmeticAveragedOvernightIndexedCouponPricer
  , blackCompoundingOvernightIndexedCouponPricer
  , blackAveragingOvernightIndexedCouponPricer
  , cpiCouponPricer
  , cpiCouponPricerWithVol
  , blackYoyInflationCouponPricer
  , unitDisplacedBlackYoyInflationCouponPricer
  , bachelierYoyInflationCouponPricer
  , equityQuantoCashFlowPricer

    -- * Mutators
  , setCpiCouponPricer
  , setFloatingRateCouponPricer
  , setYoyInflationCouponPricer
  , setEquityCashFlowPricer
  , setCouponPricer
  , setCouponPricers
  , setEquityLegPricer

    -- * Inspectors
    -- ** Coupon fixings
  , HasFixingDates(..)
  , fixingDependencies
  , HasIndexFixings(..)
  , baseFixing
  , indexFixing
  , adjustedFixing

    -- ** Leg analytics
  , amount
  , date
  , duration
  , accrualDays
  , accrualEndDate
  , accrualPeriod
  , accrualStartDate
  , accruedAmount
  , accruedDays
  , accruedPeriod
  , atmRate
  , basisPointValue
  , bps
  , convexity
  , isExpired
  , maturityDate
  , startDate
  , cashFlows
  , nextCashFlows
  , nextCashFlowAmount
  , nextCashFlowDate
  , nextCouponRate
  , previousCashFlows
  , previousCashFlowAmount
  , previousCashFlowDate
  , previousCouponRate
  , nominal
  , npv
  , npvBps
  , referencePeriodEnd
  , referencePeriodStart
  , yield
  , yieldValueBasisPoint
  , zSpread

    -- ** Coupon rates and prices
  , coupons
  , couponAccrualStartDates
  , couponAccruedAmount
  , rate
  , price
  , interestRate
  , indexRatio
  , convexityAdjustment
  , swapletRate
  , swapletPrice
  , capletPrice
  , capletRate
  , floorletPrice
  , floorletRate
  , replicationType
  , gap

    -- ** Capped and floored coupons
  , capRate
  , floorRate
  , effectiveCap
  , effectiveFloor
  , isCap
  , isFloor
  , isCollar
  , callOptionRate
  , putOptionRate
  , priceWithoutOptionality
  ) where
import qualified Foreign.C.Types as C2HSImp
import qualified Foreign.ForeignPtr as C2HSImp
import qualified Foreign.Marshal.Utils as C2HSImp
import qualified Foreign.Ptr as C2HSImp
import qualified System.IO.Unsafe as C2HSImp


import QuantLib.Internal
import QuantLib.InterestRate(Compounding, VolatilityType)
import QuantLib.Time.Schedule(Frequency)
import QuantLib.Time.Calendar(calendar, CalendarConstructor(..))
import QuantLib.Internal.Type
import QuantLib.Internal.Common
import QuantLib.Internal.Syntax(deriveOptionsRecord)
import Data.Maybe(fromMaybe)
import Data.List.NonEmpty(NonEmpty(..), toList)








{-# LINE 261 "./QuantLib/CashFlow.chs" #-}


{-# LINE 262 "./QuantLib/CashFlow.chs" #-}


{-# LINE 263 "./QuantLib/CashFlow.chs" #-}


{-# LINE 264 "./QuantLib/CashFlow.chs" #-}


{-# LINE 265 "./QuantLib/CashFlow.chs" #-}


{-# LINE 266 "./QuantLib/CashFlow.chs" #-}


{-# LINE 267 "./QuantLib/CashFlow.chs" #-}


{-# LINE 268 "./QuantLib/CashFlow.chs" #-}


{-# LINE 269 "./QuantLib/CashFlow.chs" #-}


{-# LINE 270 "./QuantLib/CashFlow.chs" #-}


{-# LINE 271 "./QuantLib/CashFlow.chs" #-}


{-# LINE 272 "./QuantLib/CashFlow.chs" #-}


{-# LINE 273 "./QuantLib/CashFlow.chs" #-}


{-# LINE 274 "./QuantLib/CashFlow.chs" #-}


{-# LINE 275 "./QuantLib/CashFlow.chs" #-}


{-# LINE 276 "./QuantLib/CashFlow.chs" #-}


{-# LINE 277 "./QuantLib/CashFlow.chs" #-}


{-# LINE 278 "./QuantLib/CashFlow.chs" #-}


{-# LINE 279 "./QuantLib/CashFlow.chs" #-}


{-# LINE 280 "./QuantLib/CashFlow.chs" #-}


{-# LINE 281 "./QuantLib/CashFlow.chs" #-}


{-# LINE 282 "./QuantLib/CashFlow.chs" #-}


{-# LINE 283 "./QuantLib/CashFlow.chs" #-}


{-# LINE 284 "./QuantLib/CashFlow.chs" #-}


{-# LINE 285 "./QuantLib/CashFlow.chs" #-}


{-# LINE 286 "./QuantLib/CashFlow.chs" #-}


{-# LINE 287 "./QuantLib/CashFlow.chs" #-}


{-# LINE 288 "./QuantLib/CashFlow.chs" #-}


{-# LINE 289 "./QuantLib/CashFlow.chs" #-}


{-# LINE 290 "./QuantLib/CashFlow.chs" #-}


{-# LINE 291 "./QuantLib/CashFlow.chs" #-}


{-# LINE 292 "./QuantLib/CashFlow.chs" #-}


{-# LINE 293 "./QuantLib/CashFlow.chs" #-}


{-# LINE 294 "./QuantLib/CashFlow.chs" #-}


{-# LINE 295 "./QuantLib/CashFlow.chs" #-}


{-# LINE 296 "./QuantLib/CashFlow.chs" #-}


{-# LINE 297 "./QuantLib/CashFlow.chs" #-}


{-# LINE 298 "./QuantLib/CashFlow.chs" #-}


{-# LINE 299 "./QuantLib/CashFlow.chs" #-}


{-# LINE 300 "./QuantLib/CashFlow.chs" #-}


{-# LINE 301 "./QuantLib/CashFlow.chs" #-}


{-# LINE 302 "./QuantLib/CashFlow.chs" #-}


{-# LINE 303 "./QuantLib/CashFlow.chs" #-}


{-# LINE 304 "./QuantLib/CashFlow.chs" #-}


{-# LINE 305 "./QuantLib/CashFlow.chs" #-}


{-# LINE 306 "./QuantLib/CashFlow.chs" #-}


{-# LINE 307 "./QuantLib/CashFlow.chs" #-}


{-# LINE 308 "./QuantLib/CashFlow.chs" #-}


data DurationType = Simple
                  | Macaulay
                  | Modified
  deriving (Enum,Show,Eq,Read)

{-# LINE 310 "./QuantLib/CashFlow.chs" #-}

data RateAveragingType = AveragingSimple
                       | AveragingCompound
  deriving (Enum,Show,Eq,Read)

{-# LINE 311 "./QuantLib/CashFlow.chs" #-}

data TimingAdjustment = Black76
                      | BivariateLognormal
  deriving (Enum,Show,Eq,Read)

{-# LINE 312 "./QuantLib/CashFlow.chs" #-}

data YieldCurveModel = Standard
                     | ExactYield
                     | ParallelShifts
                     | NonParallelShifts
  deriving (Int -> YieldCurveModel
Int -> ReplicationType -> ShowS
[ReplicationType] -> ShowS
ReplicationType -> String
YieldCurveModel -> Int
YieldCurveModel -> [YieldCurveModel]
YieldCurveModel -> YieldCurveModel
YieldCurveModel -> YieldCurveModel -> [YieldCurveModel]
YieldCurveModel
-> YieldCurveModel -> YieldCurveModel -> [YieldCurveModel]
(Int -> ReplicationType -> ShowS)
-> (ReplicationType -> String)
-> ([ReplicationType] -> ShowS)
-> Show ReplicationType
(YieldCurveModel -> YieldCurveModel)
-> (YieldCurveModel -> YieldCurveModel)
-> (Int -> YieldCurveModel)
-> (YieldCurveModel -> Int)
-> (YieldCurveModel -> [YieldCurveModel])
-> (YieldCurveModel -> YieldCurveModel -> [YieldCurveModel])
-> (YieldCurveModel -> YieldCurveModel -> [YieldCurveModel])
-> (YieldCurveModel
    -> YieldCurveModel -> YieldCurveModel -> [YieldCurveModel])
-> Enum YieldCurveModel
forall a.
(a -> a)
-> (a -> a)
-> (Int -> a)
-> (a -> Int)
-> (a -> [a])
-> (a -> a -> [a])
-> (a -> a -> [a])
-> (a -> a -> a -> [a])
-> Enum a
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> ReplicationType -> ShowS
showsPrec :: Int -> ReplicationType -> ShowS
$cshow :: ReplicationType -> String
show :: ReplicationType -> String
$cshowList :: [ReplicationType] -> ShowS
showList :: [ReplicationType] -> ShowS
$csucc :: YieldCurveModel -> YieldCurveModel
succ :: YieldCurveModel -> YieldCurveModel
$cpred :: YieldCurveModel -> YieldCurveModel
pred :: YieldCurveModel -> YieldCurveModel
$ctoEnum :: Int -> YieldCurveModel
toEnum :: Int -> YieldCurveModel
$cfromEnum :: YieldCurveModel -> Int
fromEnum :: YieldCurveModel -> Int
$cenumFrom :: YieldCurveModel -> [YieldCurveModel]
enumFrom :: YieldCurveModel -> [YieldCurveModel]
$cenumFromThen :: YieldCurveModel -> YieldCurveModel -> [YieldCurveModel]
enumFromThen :: YieldCurveModel -> YieldCurveModel -> [YieldCurveModel]
$cenumFromTo :: YieldCurveModel -> YieldCurveModel -> [YieldCurveModel]
enumFromTo :: YieldCurveModel -> YieldCurveModel -> [YieldCurveModel]
$cenumFromThenTo :: YieldCurveModel
-> YieldCurveModel -> YieldCurveModel -> [YieldCurveModel]
enumFromThenTo :: YieldCurveModel
-> YieldCurveModel -> YieldCurveModel -> [YieldCurveModel]
Enum,Int -> YieldCurveModel -> ShowS
[YieldCurveModel] -> ShowS
YieldCurveModel -> String
(Int -> YieldCurveModel -> ShowS)
-> (YieldCurveModel -> String)
-> ([YieldCurveModel] -> ShowS)
-> Show YieldCurveModel
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> YieldCurveModel -> ShowS
showsPrec :: Int -> YieldCurveModel -> ShowS
$cshow :: YieldCurveModel -> String
show :: YieldCurveModel -> String
$cshowList :: [YieldCurveModel] -> ShowS
showList :: [YieldCurveModel] -> ShowS
Show,Eq,ReadPrec [YieldCurveModel]
ReadPrec YieldCurveModel
Int -> ReadS YieldCurveModel
ReadS [YieldCurveModel]
(Int -> ReadS YieldCurveModel)
-> ReadS [YieldCurveModel]
-> ReadPrec YieldCurveModel
-> ReadPrec [YieldCurveModel]
-> Read YieldCurveModel
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
$creadsPrec :: Int -> ReadS YieldCurveModel
readsPrec :: Int -> ReadS YieldCurveModel
$creadList :: ReadS [YieldCurveModel]
readList :: ReadS [YieldCurveModel]
$creadPrec :: ReadPrec YieldCurveModel
readPrec :: ReadPrec YieldCurveModel
$creadListPrec :: ReadPrec [YieldCurveModel]
readListPrec :: ReadPrec [YieldCurveModel]
Read)

{-# LINE 313 "./QuantLib/CashFlow.chs" #-}

data ReplicationType = ReplicationSub
                     | ReplicationCentral
                     | ReplicationSuper
  deriving (Show,Eq,Read)
instance Enum ReplicationType where
  succ ReplicationSub = ReplicationCentral
  succ ReplicationCentral = ReplicationSuper
  succ ReplicationSuper = error "ReplicationType.succ: ReplicationSuper has no successor"

  pred ReplicationCentral = ReplicationSub
  pred ReplicationSuper = ReplicationCentral
  pred ReplicationSub = error "ReplicationType.pred: ReplicationSub has no predecessor"

  enumFromTo from to = go from
    where
      end = fromEnum to
      go v = case compare (fromEnum v) end of
                 LT -> v : go (succ v)
                 EQ -> [v]
                 GT -> []

  enumFrom from = enumFromTo from ReplicationSuper

  fromEnum ReplicationSub = 0
  fromEnum ReplicationCentral = 1
  fromEnum ReplicationSuper = 2

  toEnum 0 = ReplicationSub
  toEnum 1 = ReplicationCentral
  toEnum 2 = ReplicationSuper
  toEnum unmatched = error ("ReplicationType.toEnum: Cannot match " ++ show unmatched)

{-# LINE 314 "./QuantLib/CashFlow.chs" #-}


-- IborLegOpts/CmsLegOpts bundle every IborLeg/CmsLeg builder-method param beyond
-- iborLeg/cmsLeg's original 12-arg shape, pre-populated with upstream's own defaults via
-- defaultIborLegOpts/defaultCmsLegOpts, overridden through record-update syntax at the
-- call site -- see OISRateHelperOpts (QuantLib.TermStructure.Yield) for the worked
-- example this follows. The Calendar fields are Maybe here (unlike the raw bindings'
-- plain Calendar) since a real Calendar is only obtainable in IO (`calendar Null`) and
-- can't live in a pure default record value -- iborLegWithOptions/cmsLegWithOptions substitute a fresh
-- Null calendar for Nothing. This splice must stay textually before every
-- {#fun#}-generated binding in this file: c2hs always appends its raw foreign-import
-- stubs at the physical end of the generated module regardless of where in the .chs a
-- {#fun#} hook appears, and a top-level TH splice anywhere in between would otherwise
-- split the file into declaration groups that can't see each other, breaking every
-- earlier {#fun#} wrapper's reference to its own (always-last) foreign-import stub.
$(deriveOptionsRecord "IborLegOpts" []
  [ ("ilgPaymentLag", [t|Int|], [|0|])
  , ("ilgPaymentCalendar", [t|Maybe Calendar|], [|Nothing|])
  , ("ilgExCouponPeriod", [t|(Int, TimeUnit)|], [|(0, Days)|])
  , ("ilgExCouponCalendar", [t|Maybe Calendar|], [|Nothing|])
  , ("ilgExCouponConvention", [t|BusinessDayConvention|], [|Unadjusted|])
  , ("ilgExCouponEndOfMonth", [t|Bool|], [|False|])
  , ("ilgFixingConvention", [t|BusinessDayConvention|], [|Preceding|])
  , ("ilgUseIndexedCoupons", [t|Maybe Bool|], [|Nothing|])
  ])

-- Same shape as IborLegOpts, minus the fields CmsLeg's builder doesn't have
-- (withPaymentLag/withPaymentCalendar/withIndexedCoupons -- confirmed absent from
-- ql/cashflows/cmscoupon.hpp's CmsLeg). Same splice-placement constraint as above.
$(deriveOptionsRecord "CmsLegOpts" []
  [ ("cmslExCouponPeriod", [t|(Int, TimeUnit)|], [|(0, Days)|])
  , ("cmslExCouponCalendar", [t|Maybe Calendar|], [|Nothing|])
  , ("cmslExCouponConvention", [t|BusinessDayConvention|], [|Unadjusted|])
  , ("cmslExCouponEndOfMonth", [t|Bool|], [|False|])
  , ("cmslFixingConvention", [t|BusinessDayConvention|], [|Preceding|])
  ])

$(deriveOptionsRecord "DigitalCmsLegOpts" []
  [ ("dcmlCallStrikes", [t|[Double]|], [|[]|])
  , ("dcmlCallPosition", [t|PositionType|], [|Long|])
  , ("dcmlCallAtm", [t|Bool|], [|False|])
  , ("dcmlCallPayoffs", [t|[Double]|], [|[]|])
  , ("dcmlPutStrikes", [t|[Double]|], [|[]|])
  , ("dcmlPutPosition", [t|PositionType|], [|Long|])
  , ("dcmlPutAtm", [t|Bool|], [|False|])
  , ("dcmlPutPayoffs", [t|[Double]|], [|[]|])
  , ("dcmlReplication", [t|Maybe DigitalReplication|], [|Nothing|])
  , ("dcmlNakedOption", [t|Bool|], [|False|])
  ])

-- Same shape as DigitalCmsLegOpts -- DigitalCmsSpreadLeg's builder methods (upstream
-- ql/experimental/coupons/digitalcmsspreadcoupon.hpp) are identical to DigitalCmsLeg's, only the
-- index type differs (SwapSpreadIndex, not SwapIndex).
$(deriveOptionsRecord "DigitalCmsSpreadLegOpts" []
  [ ("dcmslCallStrikes", [t|[Double]|], [|[]|])
  , ("dcmslCallPosition", [t|PositionType|], [|Long|])
  , ("dcmslCallAtm", [t|Bool|], [|False|])
  , ("dcmslCallPayoffs", [t|[Double]|], [|[]|])
  , ("dcmslPutStrikes", [t|[Double]|], [|[]|])
  , ("dcmslPutPosition", [t|PositionType|], [|Long|])
  , ("dcmslPutAtm", [t|Bool|], [|False|])
  , ("dcmslPutPayoffs", [t|[Double]|], [|[]|])
  , ("dcmslReplication", [t|Maybe DigitalReplication|], [|Nothing|])
  , ("dcmslNakedOption", [t|Bool|], [|False|])
  ])

$(deriveOptionsRecord "DigitalIborLegOpts" []
  [ ("dilCallStrikes", [t|[Double]|], [|[]|]), ("dilCallPosition", [t|PositionType|], [|Long|]), ("dilCallAtm", [t|Bool|], [|False|]), ("dilCallPayoffs", [t|[Double]|], [|[]|])
  , ("dilPutStrikes", [t|[Double]|], [|[]|]), ("dilPutPosition", [t|PositionType|], [|Long|]), ("dilPutAtm", [t|Bool|], [|False|]), ("dilPutPayoffs", [t|[Double]|], [|[]|])
  , ("dilReplication", [t|Maybe DigitalReplication|], [|Nothing|]), ("dilNakedOption", [t|Bool|], [|False|]) ])

$(deriveOptionsRecord "MultipleResetsLegOpts" []
  [ ("mrlNotionals", [t|NonEmpty Double|], [|1.0 :| []|]), ("mrlPaymentCalendar", [t|Maybe Calendar|], [|Nothing|]), ("mrlPaymentLag", [t|Int|], [|0|]), ("mrlFixingDays", [t|[Word]|], [|[]|]), ("mrlGearings", [t|[Double]|], [|[]|]), ("mrlCouponSpreads", [t|[Double]|], [|[]|]), ("mrlRateSpreads", [t|[Double]|], [|[]|]), ("mrlExCouponPeriod", [t|(Int, TimeUnit)|], [|(0, Days)|]), ("mrlExCouponCalendar", [t|Maybe Calendar|], [|Nothing|]), ("mrlExCouponConvention", [t|BusinessDayConvention|], [|Unadjusted|]), ("mrlExCouponEndOfMonth", [t|Bool|], [|False|]), ("mrlAveragingMethod", [t|RateAveragingType|], [|AveragingCompound|]) ])

-- |Build a 'Leg' of plain, predetermined cash flows from parallel amount\/date arrays.
qlLeg :: ([Double]) -> ([Day]) -> IO ((Leg))
qlLeg :: [Double] -> [Day] -> IO Leg
qlLeg [Double]
a1 [Day]
a2 =
  [Double] -> ((CUInt, Ptr CDouble) -> IO Leg) -> IO Leg
forall b. [Double] -> ((CUInt, Ptr CDouble) -> IO b) -> IO b
withDoubleArray [Double]
a1 (((CUInt, Ptr CDouble) -> IO Leg) -> IO Leg)
-> ((CUInt, Ptr CDouble) -> IO Leg) -> IO Leg
forall a b. (a -> b) -> a -> b
$ \(CUInt
a1'1, Ptr CDouble
a1'2) -> 
  [Day] -> (Ptr CInt -> IO Leg) -> IO Leg
forall a. [Day] -> (Ptr CInt -> IO a) -> IO a
withDayPtr [Day]
a2 ((Ptr CInt -> IO Leg) -> IO Leg) -> (Ptr CInt -> IO Leg) -> IO Leg
forall a b. (a -> b) -> a -> b
$ \Ptr CInt
a2' -> 
  (Ptr (Ptr CChar) -> IO Leg) -> IO Leg
forall a b. (Ptr (Ptr a) -> IO b) -> IO b
preErrorCheck ((Ptr (Ptr CChar) -> IO Leg) -> IO Leg)
-> (Ptr (Ptr CChar) -> IO Leg) -> IO Leg
forall a b. (a -> b) -> a -> b
$ \Ptr (Ptr CChar)
a3' -> 
  CUInt
-> Ptr CDouble -> Ptr CInt -> Ptr (Ptr CChar) -> IO (Ptr CLeg')
qlLeg'_ CUInt
a1'1  Ptr CDouble
a1'2 Ptr CInt
a2' Ptr (Ptr CChar)
a3' IO (Ptr CLeg') -> (Ptr CLeg' -> IO Leg) -> IO Leg
forall a b. IO a -> (a -> IO b) -> IO b
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= \Ptr CLeg'
res ->
  Ptr CLeg' -> IO Leg
peekLeg Ptr CLeg'
res IO Leg -> (Leg -> IO Leg) -> IO Leg
forall a b. IO a -> (a -> IO b) -> IO b
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= \Leg
res' ->
  Ptr (Ptr CChar) -> IO ()
errorCheck  Ptr (Ptr CChar)
a3'IO () -> IO Leg -> IO Leg
forall a b. IO a -> IO b -> IO b
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>>
  Leg -> IO Leg
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return (Leg
res')

{-# LINE 389 "./QuantLib/CashFlow.chs" #-}


leg :: [(Day, Double)] -- ^amounts and dates
  -> IO Leg
leg f = qlLeg fs ds where (ds, fs) = unzip f

-- |A predetermined payment, suitable for mixing with other cash-flow kinds in
-- 'cashFlowLeg'.  For a leg made entirely of such payments, 'leg' is a more concise API.
simpleCashFlow :: (Double) -- ^amount
 -> (Day) -- ^payment date
 -> IO ((CashFlow))
simpleCashFlow :: Double -> Day -> IO CashFlow
simpleCashFlow Double
a1 Day
a2 =
  let {a1' :: CDouble
a1' = Double -> CDouble
forall a b. (Real a, Fractional b) => a -> b
realToFrac Double
a1} in 
  Day -> (CInt -> IO CashFlow) -> IO CashFlow
forall a. Day -> (CInt -> IO a) -> IO a
withDay Day
a2 ((CInt -> IO CashFlow) -> IO CashFlow)
-> (CInt -> IO CashFlow) -> IO CashFlow
forall a b. (a -> b) -> a -> b
$ \CInt
a2' -> 
  (Ptr (Ptr CChar) -> IO CashFlow) -> IO CashFlow
forall a b. (Ptr (Ptr a) -> IO b) -> IO b
preErrorCheck ((Ptr (Ptr CChar) -> IO CashFlow) -> IO CashFlow)
-> (Ptr (Ptr CChar) -> IO CashFlow) -> IO CashFlow
forall a b. (a -> b) -> a -> b
$ \Ptr (Ptr CChar)
a3' -> 
  CDouble -> CInt -> Ptr (Ptr CChar) -> IO (Ptr CCashFlow')
simpleCashFlow'_ CDouble
a1' CInt
a2' Ptr (Ptr CChar)
a3' IO (Ptr CCashFlow')
-> (Ptr CCashFlow' -> IO CashFlow) -> IO CashFlow
forall a b. IO a -> (a -> IO b) -> IO b
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= \Ptr CCashFlow'
res ->
  Ptr CCashFlow' -> IO CashFlow
peekCashFlow Ptr CCashFlow'
res IO CashFlow -> (CashFlow -> IO CashFlow) -> IO CashFlow
forall a b. IO a -> (a -> IO b) -> IO b
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= \CashFlow
res' ->
  Ptr (Ptr CChar) -> IO ()
errorCheck  Ptr (Ptr CChar)
a3'IO () -> IO CashFlow -> IO CashFlow
forall a b. IO a -> IO b -> IO b
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>>
  CashFlow -> IO CashFlow
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return (CashFlow
res')

{-# LINE 399 "./QuantLib/CashFlow.chs" #-}


-- |The undiscounted amount paid by a cash flow on its payment date.
amount :: (GenCashFlow cf) -- ^cashFlow
 -> IO ((Double))
amount a1 =
  withCashFlow a1 $ \a1' -> 
  preErrorCheck $ \a2' -> 
  amount'_ a1' a2' >>= \res ->
  let {res' = realToFrac res} in
  errorCheck  a2'>>
  return (res')

{-# LINE 403 "./QuantLib/CashFlow.chs" #-}


-- |The payment date of a cash flow.
date :: (GenCashFlow cf) -- ^cashFlow
 -> (Day)
date a1 =
  C2HSImp.unsafePerformIO $
  withCashFlow a1 $ \a1' -> 
  date'_ a1' >>= \res ->
  let {res' = toDay res} in
  return (res')

{-# LINE 407 "./QuantLib/CashFlow.chs" #-}


-- |A payment of @notional * i(fixingDate) \/ i(baseDate)@, or the same ratio minus one when
-- /growthOnly/ is true.  QuantLib does no date adjustment here; callers supply the already
-- adjusted fixing and payment dates.  This is the generic building block behind the specialized
-- CPI and equity cash flows, and accepts any bound t'GenIndex'.
indexedCashFlow :: (Double) -- ^notional
 -> (GenIndex idx) -- ^index
 -> (Day) -- ^base date
 -> (Day) -- ^fixing date
 -> (Day) -- ^payment date
 -> (Bool) -- ^growthOnly
 -> IO ((IndexedCashFlow))
indexedCashFlow :: forall idx.
Double
-> GenIndex idx -> Day -> Day -> Day -> Bool -> IO IndexedCashFlow
indexedCashFlow Double
a1 GenIndex idx
a2 Day
a3 Day
a4 Day
a5 Bool
a6 =
  let {a1' :: CDouble
a1' = Double -> CDouble
forall a b. (Real a, Fractional b) => a -> b
realToFrac Double
a1} in 
  GenIndex idx
-> (Ptr CIndex' -> IO IndexedCashFlow) -> IO IndexedCashFlow
forall idx b. GenIndex idx -> (Ptr CIndex' -> IO b) -> IO b
withIndex GenIndex idx
a2 ((Ptr CIndex' -> IO IndexedCashFlow) -> IO IndexedCashFlow)
-> (Ptr CIndex' -> IO IndexedCashFlow) -> IO IndexedCashFlow
forall a b. (a -> b) -> a -> b
$ \Ptr CIndex'
a2' -> 
  Day -> (CInt -> IO IndexedCashFlow) -> IO IndexedCashFlow
forall a. Day -> (CInt -> IO a) -> IO a
withDay Day
a3 ((CInt -> IO IndexedCashFlow) -> IO IndexedCashFlow)
-> (CInt -> IO IndexedCashFlow) -> IO IndexedCashFlow
forall a b. (a -> b) -> a -> b
$ \a3' -> 
  withDay a4 $ \a4' -> 
  withDay a5 $ \a5' -> 
  let {a6' = C2HSImp.fromBool a6} in 
  preErrorCheck $ \a7' -> 
  indexedCashFlow'_ a1' a2' a3' a4' a5' a6' a7' >>= \res ->
  peekIndexedCashFlow res >>= \res' ->
  errorCheck  a7'>>
  return (res')

{-# LINE 419 "./QuantLib/CashFlow.chs" #-}


-- |The fixing used as the base of an indexed cash flow's return ratio.
baseFixing :: (GenIndexedCashFlow icf) -> IO ((Double))
baseFixing a1 =
  withIndexedCashFlow a1 $ \a1' -> 
  preErrorCheck $ \a2' -> 
  baseFixing'_ a1' a2' >>= \res ->
  let {res' = realToFrac res} in
  errorCheck  a2'>>
  return (res')

{-# LINE 423 "./QuantLib/CashFlow.chs" #-}


-- |The fixing used as the numerator of an indexed cash flow's return ratio.
indexFixing :: (GenIndexedCashFlow icf) -> IO ((Double))
indexFixing a1 =
  withIndexedCashFlow a1 $ \a1' -> 
  preErrorCheck $ \a2' -> 
  indexFixing'_ a1' a2' >>= \res ->
  let {res' = realToFrac res} in
  errorCheck  a2'>>
  return (res')

{-# LINE 427 "./QuantLib/CashFlow.chs" #-}


-- |A fixed coupon with explicitly supplied payment, accrual, reference-period, and ex-coupon
-- dates.  'Nothing' for a reference or ex-coupon date passes QuantLib's empty @Date()@. A
-- homogeneous list of fixed coupons can be passed directly to 'cashFlowLeg'; use 'asCashFlow'
-- only when mixing it with other cash-flow types.
fixedRateCoupon :: (Day) -- ^paymentDate
 -> (Double) -- ^nominal
 -> (Double) -- ^rate
 -> (DayCounter) -- ^dayCounter
 -> (Day) -- ^accrualStartDate
 -> (Day) -- ^accrualEndDate
 -> (Maybe Day) -- ^referencePeriodStart
 -> (Maybe Day) -- ^referencePeriodEnd
 -> (Maybe Day) -- ^exCouponDate
 -> IO ((FixedRateCoupon))
fixedRateCoupon :: Day
-> Double
-> Double
-> DayCounter
-> Day
-> Day
-> Maybe Day
-> Maybe Day
-> Maybe Day
-> IO FixedRateCoupon
fixedRateCoupon Day
a1 Double
a2 Double
a3 DayCounter
a4 Day
a5 Day
a6 Maybe Day
a7 Maybe Day
a8 Maybe Day
a9 =
  Day -> (CInt -> IO FixedRateCoupon) -> IO FixedRateCoupon
forall a. Day -> (CInt -> IO a) -> IO a
withDay Day
a1 ((CInt -> IO FixedRateCoupon) -> IO FixedRateCoupon)
-> (CInt -> IO FixedRateCoupon) -> IO FixedRateCoupon
forall a b. (a -> b) -> a -> b
$ \CInt
a1' -> 
  let {a2' :: CDouble
a2' = Double -> CDouble
forall a b. (Real a, Fractional b) => a -> b
realToFrac Double
a2} in 
  let {a3' :: CDouble
a3' = Double -> CDouble
forall a b. (Real a, Fractional b) => a -> b
realToFrac Double
a3} in 
  DayCounter
-> (Ptr CDayCounter -> IO FixedRateCoupon) -> IO FixedRateCoupon
forall b. DayCounter -> (Ptr CDayCounter -> IO b) -> IO b
withDayCounter DayCounter
a4 ((Ptr CDayCounter -> IO FixedRateCoupon) -> IO FixedRateCoupon)
-> (Ptr CDayCounter -> IO FixedRateCoupon) -> IO FixedRateCoupon
forall a b. (a -> b) -> a -> b
$ \Ptr CDayCounter
a4' -> 
  Day -> (CInt -> IO FixedRateCoupon) -> IO FixedRateCoupon
forall a. Day -> (CInt -> IO a) -> IO a
withDay Day
a5 ((CInt -> IO FixedRateCoupon) -> IO FixedRateCoupon)
-> (CInt -> IO FixedRateCoupon) -> IO FixedRateCoupon
forall a b. (a -> b) -> a -> b
$ \CInt
a5' -> 
  Day -> (CInt -> IO FixedRateCoupon) -> IO FixedRateCoupon
forall a. Day -> (CInt -> IO a) -> IO a
withDay Day
a6 ((CInt -> IO FixedRateCoupon) -> IO FixedRateCoupon)
-> (CInt -> IO FixedRateCoupon) -> IO FixedRateCoupon
forall a b. (a -> b) -> a -> b
$ \CInt
a6' -> 
  Maybe Day -> (CInt -> IO FixedRateCoupon) -> IO FixedRateCoupon
forall a. Maybe Day -> (CInt -> IO a) -> IO a
withMaybeDay Maybe Day
a7 ((CInt -> IO FixedRateCoupon) -> IO FixedRateCoupon)
-> (CInt -> IO FixedRateCoupon) -> IO FixedRateCoupon
forall a b. (a -> b) -> a -> b
$ \CInt
a7' -> 
  Maybe Day -> (CInt -> IO FixedRateCoupon) -> IO FixedRateCoupon
forall a. Maybe Day -> (CInt -> IO a) -> IO a
withMaybeDay Maybe Day
a8 ((CInt -> IO FixedRateCoupon) -> IO FixedRateCoupon)
-> (CInt -> IO FixedRateCoupon) -> IO FixedRateCoupon
forall a b. (a -> b) -> a -> b
$ \CInt
a8' -> 
  Maybe Day -> (CInt -> IO FixedRateCoupon) -> IO FixedRateCoupon
forall a. Maybe Day -> (CInt -> IO a) -> IO a
withMaybeDay Maybe Day
a9 ((CInt -> IO FixedRateCoupon) -> IO FixedRateCoupon)
-> (CInt -> IO FixedRateCoupon) -> IO FixedRateCoupon
forall a b. (a -> b) -> a -> b
$ \CInt
a9' -> 
  (Ptr (Ptr CChar) -> IO FixedRateCoupon) -> IO FixedRateCoupon
forall a b. (Ptr (Ptr a) -> IO b) -> IO b
preErrorCheck ((Ptr (Ptr CChar) -> IO FixedRateCoupon) -> IO FixedRateCoupon)
-> (Ptr (Ptr CChar) -> IO FixedRateCoupon) -> IO FixedRateCoupon
forall a b. (a -> b) -> a -> b
$ \Ptr (Ptr CChar)
a10' -> 
  CInt
-> CDouble
-> CDouble
-> Ptr CDayCounter
-> CInt
-> CInt
-> CInt
-> CInt
-> CInt
-> Ptr (Ptr CChar)
-> IO (Ptr CFixedRateCoupon')
fixedRateCoupon'_ CInt
a1' CDouble
a2' CDouble
a3' Ptr CDayCounter
a4' CInt
a5' CInt
a6' CInt
a7' CInt
a8' CInt
a9' Ptr (Ptr CChar)
a10' IO (Ptr CFixedRateCoupon')
-> (Ptr CFixedRateCoupon' -> IO FixedRateCoupon)
-> IO FixedRateCoupon
forall a b. IO a -> (a -> IO b) -> IO b
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= \Ptr CFixedRateCoupon'
res ->
  Ptr CFixedRateCoupon' -> IO FixedRateCoupon
peekFixedRateCoupon Ptr CFixedRateCoupon'
res IO FixedRateCoupon
-> (FixedRateCoupon -> IO FixedRateCoupon) -> IO FixedRateCoupon
forall a b. IO a -> (a -> IO b) -> IO b
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= \FixedRateCoupon
res' ->
  Ptr (Ptr CChar) -> IO ()
errorCheck  Ptr (Ptr CChar)
a10'IO () -> IO FixedRateCoupon -> IO FixedRateCoupon
forall a b. IO a -> IO b -> IO b
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>>
  FixedRateCoupon -> IO FixedRateCoupon
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return (FixedRateCoupon
res')

{-# LINE 442 "./QuantLib/CashFlow.chs" #-}


-- |The coupon's own fixed rate, as an 'InterestRate' (rate value plus day counter/compounding/
-- frequency) rather than a bare rate -- distinct from 'rate', which returns a
-- bare @Double@ for the (possibly index-derived) accrual rate.
interestRate :: (FixedRateCoupon) -> IO ((InterestRate))
interestRate a1 =
  withFixedRateCoupon a1 $ \a1' -> 
  interestRate'_ a1' >>= \res ->
  peekInterestRate res >>= \res' ->
  return (res')

{-# LINE 447 "./QuantLib/CashFlow.chs" #-}


-- |A generic floating-rate coupon.  Attach a 'FloatingRateCouponPricer' to the resulting leg
-- with 'setCouponPricer' before evaluating a coupon whose rate requires one.  'Nothing' dates
-- pass QuantLib's empty @Date()@; all other constructor parameters are explicit.
floatingRateCoupon :: (Day) -- ^paymentDate
 -> (Double) -- ^nominal
 -> (Day) -- ^accrualStartDate
 -> (Day) -- ^accrualEndDate
 -> (Word) -- ^fixingDays
 -> (GenInterestRateIndex ridx) -- ^index
 -> (Double) -- ^gearing
 -> (Double) -- ^spread
 -> (Maybe Day) -- ^referencePeriodStart
 -> (Maybe Day) -- ^referencePeriodEnd
 -> (DayCounter) -- ^dayCounter
 -> (Bool) -- ^inArrears
 -> (Maybe Day) -- ^exCouponDate
 -> (BusinessDayConvention) -- ^fixingConvention
 -> IO ((FloatingRateCoupon))
floatingRateCoupon :: forall ridx.
Day
-> Double
-> Day
-> Day
-> Word
-> GenInterestRateIndex ridx
-> Double
-> Double
-> Maybe Day
-> Maybe Day
-> DayCounter
-> Bool
-> Maybe Day
-> BusinessDayConvention
-> IO FloatingRateCoupon
floatingRateCoupon Day
a1 Double
a2 Day
a3 Day
a4 Word
a5 GenInterestRateIndex ridx
a6 Double
a7 Double
a8 Maybe Day
a9 Maybe Day
a10 DayCounter
a11 Bool
a12 Maybe Day
a13 BusinessDayConvention
a14 =
  Day -> (CInt -> IO FloatingRateCoupon) -> IO FloatingRateCoupon
forall a. Day -> (CInt -> IO a) -> IO a
withDay Day
a1 ((CInt -> IO FloatingRateCoupon) -> IO FloatingRateCoupon)
-> (CInt -> IO FloatingRateCoupon) -> IO FloatingRateCoupon
forall a b. (a -> b) -> a -> b
$ \CInt
a1' -> 
  let {a2' :: CDouble
a2' = Double -> CDouble
forall a b. (Real a, Fractional b) => a -> b
realToFrac Double
a2} in 
  Day -> (CInt -> IO FloatingRateCoupon) -> IO FloatingRateCoupon
forall a. Day -> (CInt -> IO a) -> IO a
withDay Day
a3 ((CInt -> IO FloatingRateCoupon) -> IO FloatingRateCoupon)
-> (CInt -> IO FloatingRateCoupon) -> IO FloatingRateCoupon
forall a b. (a -> b) -> a -> b
$ \CInt
a3' -> 
  Day -> (CInt -> IO FloatingRateCoupon) -> IO FloatingRateCoupon
forall a. Day -> (CInt -> IO a) -> IO a
withDay Day
a4 ((CInt -> IO FloatingRateCoupon) -> IO FloatingRateCoupon)
-> (CInt -> IO FloatingRateCoupon) -> IO FloatingRateCoupon
forall a b. (a -> b) -> a -> b
$ \CInt
a4' -> 
  let {a5' :: CUInt
a5' = Word -> CUInt
forall a b. (Integral a, Num b) => a -> b
fromIntegral Word
a5} in 
  GenInterestRateIndex ridx
-> (Ptr CInterestRateIndex' -> IO FloatingRateCoupon)
-> IO FloatingRateCoupon
forall ridx b.
GenInterestRateIndex ridx
-> (Ptr CInterestRateIndex' -> IO b) -> IO b
withInterestRateIndex GenInterestRateIndex ridx
a6 ((Ptr CInterestRateIndex' -> IO FloatingRateCoupon)
 -> IO FloatingRateCoupon)
-> (Ptr CInterestRateIndex' -> IO FloatingRateCoupon)
-> IO FloatingRateCoupon
forall a b. (a -> b) -> a -> b
$ \Ptr CInterestRateIndex'
a6' -> 
  let {a7' :: CDouble
a7' = Double -> CDouble
forall a b. (Real a, Fractional b) => a -> b
realToFrac Double
a7} in 
  let {a8' :: CDouble
a8' = Double -> CDouble
forall a b. (Real a, Fractional b) => a -> b
realToFrac Double
a8} in 
  Maybe Day
-> (CInt -> IO FloatingRateCoupon) -> IO FloatingRateCoupon
forall a. Maybe Day -> (CInt -> IO a) -> IO a
withMaybeDay Maybe Day
a9 ((CInt -> IO FloatingRateCoupon) -> IO FloatingRateCoupon)
-> (CInt -> IO FloatingRateCoupon) -> IO FloatingRateCoupon
forall a b. (a -> b) -> a -> b
$ \CInt
a9' -> 
  Maybe Day
-> (CInt -> IO FloatingRateCoupon) -> IO FloatingRateCoupon
forall a. Maybe Day -> (CInt -> IO a) -> IO a
withMaybeDay Maybe Day
a10 ((CInt -> IO FloatingRateCoupon) -> IO FloatingRateCoupon)
-> (CInt -> IO FloatingRateCoupon) -> IO FloatingRateCoupon
forall a b. (a -> b) -> a -> b
$ \CInt
a10' -> 
  DayCounter
-> (Ptr CDayCounter -> IO FloatingRateCoupon)
-> IO FloatingRateCoupon
forall b. DayCounter -> (Ptr CDayCounter -> IO b) -> IO b
withDayCounter DayCounter
a11 ((Ptr CDayCounter -> IO FloatingRateCoupon)
 -> IO FloatingRateCoupon)
-> (Ptr CDayCounter -> IO FloatingRateCoupon)
-> IO FloatingRateCoupon
forall a b. (a -> b) -> a -> b
$ \Ptr CDayCounter
a11' -> 
  let {a12' :: CInt
a12' = Bool -> CInt
forall a. Num a => Bool -> a
C2HSImp.fromBool Bool
a12} in 
  Maybe Day
-> (CInt -> IO FloatingRateCoupon) -> IO FloatingRateCoupon
forall a. Maybe Day -> (CInt -> IO a) -> IO a
withMaybeDay Maybe Day
a13 ((CInt -> IO FloatingRateCoupon) -> IO FloatingRateCoupon)
-> (CInt -> IO FloatingRateCoupon) -> IO FloatingRateCoupon
forall a b. (a -> b) -> a -> b
$ \CInt
a13' -> 
  let {a14' :: CInt
a14' = BusinessDayConvention -> CInt
forall a b. (Enum a, Integral b) => a -> b
fromEnumC BusinessDayConvention
a14} in 
  (Ptr (Ptr CChar) -> IO FloatingRateCoupon) -> IO FloatingRateCoupon
forall a b. (Ptr (Ptr a) -> IO b) -> IO b
preErrorCheck ((Ptr (Ptr CChar) -> IO FloatingRateCoupon)
 -> IO FloatingRateCoupon)
-> (Ptr (Ptr CChar) -> IO FloatingRateCoupon)
-> IO FloatingRateCoupon
forall a b. (a -> b) -> a -> b
$ \Ptr (Ptr CChar)
a15' -> 
  CInt
-> CDouble
-> CInt
-> CInt
-> CUInt
-> Ptr CInterestRateIndex'
-> CDouble
-> CDouble
-> CInt
-> CInt
-> Ptr CDayCounter
-> CInt
-> CInt
-> CInt
-> Ptr (Ptr CChar)
-> IO (Ptr CFloatingRateCoupon')
floatingRateCoupon'_ CInt
a1' CDouble
a2' CInt
a3' CInt
a4' CUInt
a5' Ptr CInterestRateIndex'
a6' CDouble
a7' CDouble
a8' CInt
a9' CInt
a10' Ptr CDayCounter
a11' CInt
a12' CInt
a13' CInt
a14' Ptr (Ptr CChar)
a15' IO (Ptr CFloatingRateCoupon')
-> (Ptr CFloatingRateCoupon' -> IO FloatingRateCoupon)
-> IO FloatingRateCoupon
forall a b. IO a -> (a -> IO b) -> IO b
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= \Ptr CFloatingRateCoupon'
res ->
  Ptr CFloatingRateCoupon' -> IO FloatingRateCoupon
peekFloatingRateCoupon Ptr CFloatingRateCoupon'
res IO FloatingRateCoupon
-> (FloatingRateCoupon -> IO FloatingRateCoupon)
-> IO FloatingRateCoupon
forall a b. IO a -> (a -> IO b) -> IO b
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= \FloatingRateCoupon
res' ->
  Ptr (Ptr CChar) -> IO ()
errorCheck  Ptr (Ptr CChar)
a15'IO () -> IO FloatingRateCoupon -> IO FloatingRateCoupon
forall a b. IO a -> IO b -> IO b
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>>
  FloatingRateCoupon -> IO FloatingRateCoupon
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return (FloatingRateCoupon
res')

{-# LINE 466 "./QuantLib/CashFlow.chs" #-}


-- |An Ibor-specific floating coupon.  Prefer this to 'floatingRateCoupon' when the index is
-- Ibor: QuantLib then uses IborCoupon's fixing value/maturity-date logic rather than the base
-- floating-coupon implementation.  Date and pricer handling are as in 'floatingRateCoupon'.
iborCoupon :: (Day) -- ^paymentDate
 -> (Double) -- ^nominal
 -> (Day) -- ^accrualStartDate
 -> (Day) -- ^accrualEndDate
 -> (Word) -- ^fixingDays
 -> (GenIborIndex ibor) -- ^index
 -> (Double) -- ^gearing
 -> (Double) -- ^spread
 -> (Maybe Day) -- ^referencePeriodStart
 -> (Maybe Day) -- ^referencePeriodEnd
 -> (DayCounter) -- ^dayCounter
 -> (Bool) -- ^inArrears
 -> (Maybe Day) -- ^exCouponDate
 -> (BusinessDayConvention) -- ^fixingConvention
 -> IO ((IborCoupon))
iborCoupon a1 a2 a3 a4 a5 a6 a7 a8 a9 a10 a11 a12 a13 a14 =
  withDay a1 $ \a1' -> 
  let {a2' = realToFrac a2} in 
  withDay a3 $ \a3' -> 
  withDay a4 $ \a4' -> 
  let {a5' = fromIntegral a5} in 
  withIborIndex a6 $ \a6' -> 
  let {a7' = realToFrac a7} in 
  let {a8' = realToFrac a8} in 
  withMaybeDay a9 $ \a9' -> 
  withMaybeDay a10 $ \a10' -> 
  withDayCounter a11 $ \a11' -> 
  let {a12' = C2HSImp.fromBool a12} in 
  withMaybeDay a13 $ \a13' -> 
  let {a14' = fromEnumC a14} in 
  preErrorCheck $ \a15' -> 
  iborCoupon'_ a1' a2' a3' a4' a5' a6' a7' a8' a9' a10' a11' a12' a13' a14' a15' >>= \res ->
  peekIborCoupon res >>= \res' ->
  errorCheck  a15'>>
  return (res')

{-# LINE 485 "./QuantLib/CashFlow.chs" #-}


-- |A BMA-index coupon with explicitly supplied accrual and reference dates.
averageBmaCoupon :: (Day) -- ^paymentDate
 -> (Double) -- ^nominal
 -> (Day) -- ^accrualStartDate
 -> (Day) -- ^accrualEndDate
 -> (BMAIndex) -- ^index
 -> (Double) -- ^gearing
 -> (Double) -- ^spread
 -> (Maybe Day) -- ^referencePeriodStart
 -> (Maybe Day) -- ^referencePeriodEnd
 -> (DayCounter) -- ^dayCounter
 -> IO ((AverageBMACoupon))
averageBmaCoupon a1 a2 a3 a4 a5 a6 a7 a8 a9 a10 =
  withDay a1 $ \a1' -> 
  let {a2' = realToFrac a2} in 
  withDay a3 $ \a3' -> 
  withDay a4 $ \a4' -> 
  withBMAIndex a5 $ \a5' -> 
  let {a6' = realToFrac a6} in 
  let {a7' = realToFrac a7} in 
  withMaybeDay a8 $ \a8' -> 
  withMaybeDay a9 $ \a9' -> 
  withDayCounter a10 $ \a10' -> 
  preErrorCheck $ \a11' -> 
  averageBmaCoupon'_ a1' a2' a3' a4' a5' a6' a7' a8' a9' a10' a11' >>= \res ->
  peekAverageBMACoupon res >>= \res' ->
  errorCheck  a11'>>
  return (res')

{-# LINE 498 "./QuantLib/CashFlow.chs" #-}


-- |The fixing dates of the individual BMA rates being averaged over this coupon's accrual period.
averageBmaCouponFixingDatesRaw :: (AverageBMACoupon) -> IO (([Day]))
averageBmaCouponFixingDatesRaw a1 =
  withAverageBMACoupon a1 $ \a1' -> 
  preArray $ \(a2'1, a2'2) -> 
  preErrorCheck $ \a3' -> 
  averageBmaCouponFixingDatesRaw'_ a1' a2'1  a2'2 a3' >>
  peekDayArray  a2'1  a2'2>>= \a2'' -> 
  errorCheck  a3'>>
  return (a2'')

{-# LINE 501 "./QuantLib/CashFlow.chs" #-}


-- |The individual BMA fixings being averaged, in the same order as 'fixingDates'.
averageBmaCouponIndexFixingsRaw :: (AverageBMACoupon) -> IO (([Double]))
averageBmaCouponIndexFixingsRaw a1 =
  withAverageBMACoupon a1 $ \a1' -> 
  preArray $ \(a2'1, a2'2) -> 
  preErrorCheck $ \a3' -> 
  averageBmaCouponIndexFixingsRaw'_ a1' a2'1  a2'2 a3' >>
  peekDoubleArray  a2'1  a2'2>>= \a2'' -> 
  errorCheck  a3'>>
  return (a2'')

{-# LINE 504 "./QuantLib/CashFlow.chs" #-}


-- |Wrap a floating-rate coupon with optional cap and floor rates.
cappedFlooredCoupon :: (GenFloatingRateCoupon frc) -- ^underlying
 -> (Maybe Double) -- ^cap
 -> (Maybe Double) -- ^floor
 -> IO ((FloatingRateCoupon))
cappedFlooredCoupon a1 a2 a3 =
  withFloatingRateCoupon a1 $ \a1' -> 
  let {a2' = fromMaybeDouble a2} in 
  let {a3' = fromMaybeDouble a3} in 
  preErrorCheck $ \a4' -> 
  cappedFlooredCoupon'_ a1' a2' a3' a4' >>= \res ->
  peekFloatingRateCoupon res >>= \res' ->
  errorCheck  a4'>>
  return (res')

{-# LINE 510 "./QuantLib/CashFlow.chs" #-}


-- |Strip the embedded cap/floor option out of a capped\/floored coupon: builds a
-- 'CappedFlooredCoupon' from /underlying/, /cap/ and /floor/ (as 'cappedFlooredCoupon'
-- does), then wraps it so the option's rate, cap and floor are separately readable.
strippedCappedFlooredCoupon :: (GenFloatingRateCoupon frc) -- ^underlying
 -> (Maybe Double) -- ^cap
 -> (Maybe Double) -- ^floor
 -> IO ((StrippedCappedFlooredCoupon))
strippedCappedFlooredCoupon a1 a2 a3 =
  withFloatingRateCoupon a1 $ \a1' -> 
  let {a2' = fromMaybeDouble a2} in 
  let {a3' = fromMaybeDouble a3} in 
  preErrorCheck $ \a4' -> 
  strippedCappedFlooredCoupon'_ a1' a2' a3' a4' >>= \res ->
  peekStrippedCappedFlooredCoupon res >>= \res' ->
  errorCheck  a4'>>
  return (res')

{-# LINE 518 "./QuantLib/CashFlow.chs" #-}


-- |The cap actually in effect for this coupon, accounting for the sign of /gearing/;
-- QuantLib's null-rate sentinel means no cap applies.
capRate :: (StrippedCappedFlooredCoupon) -- ^coupon
 -> (Double)
capRate a1 =
  C2HSImp.unsafePerformIO $
  withStrippedCappedFlooredCoupon a1 $ \a1' -> 
  capRate'_ a1' >>= \res ->
  let {res' = realToFrac res} in
  return (res')

{-# LINE 523 "./QuantLib/CashFlow.chs" #-}


-- |The floor actually in effect for this coupon, accounting for the sign of /gearing/;
-- QuantLib's null-rate sentinel means no floor applies.
floorRate :: (StrippedCappedFlooredCoupon) -- ^coupon
 -> (Double)
floorRate a1 =
  C2HSImp.unsafePerformIO $
  withStrippedCappedFlooredCoupon a1 $ \a1' -> 
  floorRate'_ a1' >>= \res ->
  let {res' = realToFrac res} in
  return (res')

{-# LINE 528 "./QuantLib/CashFlow.chs" #-}


-- |The cap rate translated back to the underlying index rate (before gearing\/spread);
-- QuantLib's null-rate sentinel means the coupon is not capped.
effectiveCap :: (StrippedCappedFlooredCoupon) -- ^coupon
 -> (Double)
effectiveCap a1 =
  C2HSImp.unsafePerformIO $
  withStrippedCappedFlooredCoupon a1 $ \a1' -> 
  effectiveCap'_ a1' >>= \res ->
  let {res' = realToFrac res} in
  return (res')

{-# LINE 533 "./QuantLib/CashFlow.chs" #-}


-- |The floor rate translated back to the underlying index rate (before gearing\/spread);
-- QuantLib's null-rate sentinel means the coupon is not floored.
effectiveFloor :: (StrippedCappedFlooredCoupon) -- ^coupon
 -> (Double)
effectiveFloor a1 =
  C2HSImp.unsafePerformIO $
  withStrippedCappedFlooredCoupon a1 $ \a1' -> 
  effectiveFloor'_ a1' >>= \res ->
  let {res' = realToFrac res} in
  return (res')

{-# LINE 538 "./QuantLib/CashFlow.chs" #-}


-- |Whether this coupon has a cap in effect.
isCap :: (StrippedCappedFlooredCoupon) -- ^coupon
 -> (Bool)
isCap a1 =
  C2HSImp.unsafePerformIO $
  withStrippedCappedFlooredCoupon a1 $ \a1' -> 
  isCap'_ a1' >>= \res ->
  let {res' = C2HSImp.toBool res} in
  return (res')

{-# LINE 542 "./QuantLib/CashFlow.chs" #-}


-- |Whether this coupon has a floor in effect.
isFloor :: (StrippedCappedFlooredCoupon) -- ^coupon
 -> (Bool)
isFloor a1 =
  C2HSImp.unsafePerformIO $
  withStrippedCappedFlooredCoupon a1 $ \a1' -> 
  isFloor'_ a1' >>= \res ->
  let {res' = C2HSImp.toBool res} in
  return (res')

{-# LINE 546 "./QuantLib/CashFlow.chs" #-}


-- |Whether this coupon is both capped and floored (a collar).
isCollar :: (StrippedCappedFlooredCoupon) -- ^coupon
 -> (Bool)
isCollar a1 =
  C2HSImp.unsafePerformIO $
  withStrippedCappedFlooredCoupon a1 $ \a1' -> 
  isCollar'_ a1' >>= \res ->
  let {res' = C2HSImp.toBool res} in
  return (res')

{-# LINE 550 "./QuantLib/CashFlow.chs" #-}


-- |Ibor coupon with optional cap and floor rates.
cappedFlooredIborCoupon :: (Day) -- ^paymentDate
 -> (Double) -- ^nominal
 -> (Day) -- ^accrualStartDate
 -> (Day) -- ^accrualEndDate
 -> (Word) -- ^fixingDays
 -> (GenIborIndex ibor) -- ^index
 -> (Double) -- ^gearing
 -> (Double) -- ^spread
 -> (Maybe Double) -- ^cap
 -> (Maybe Double) -- ^floor
 -> (Maybe Day) -- ^referencePeriodStart
 -> (Maybe Day) -- ^referencePeriodEnd
 -> (DayCounter) -- ^dayCounter
 -> (Bool) -- ^inArrears
 -> (Maybe Day) -- ^exCouponDate
 -> (BusinessDayConvention) -- ^fixingConvention
 -> IO ((FloatingRateCoupon))
cappedFlooredIborCoupon :: forall ibor.
Day
-> Double
-> Day
-> Day
-> Word
-> GenIborIndex ibor
-> Double
-> Double
-> Maybe Double
-> Maybe Double
-> Maybe Day
-> Maybe Day
-> DayCounter
-> Bool
-> Maybe Day
-> BusinessDayConvention
-> IO FloatingRateCoupon
cappedFlooredIborCoupon Day
a1 Double
a2 Day
a3 Day
a4 Word
a5 GenIborIndex ibor
a6 Double
a7 Double
a8 Maybe Double
a9 Maybe Double
a10 Maybe Day
a11 Maybe Day
a12 DayCounter
a13 Bool
a14 Maybe Day
a15 BusinessDayConvention
a16 =
  Day -> (CInt -> IO FloatingRateCoupon) -> IO FloatingRateCoupon
forall a. Day -> (CInt -> IO a) -> IO a
withDay Day
a1 ((CInt -> IO FloatingRateCoupon) -> IO FloatingRateCoupon)
-> (CInt -> IO FloatingRateCoupon) -> IO FloatingRateCoupon
forall a b. (a -> b) -> a -> b
$ \CInt
a1' -> 
  let {a2' :: CDouble
a2' = Double -> CDouble
forall a b. (Real a, Fractional b) => a -> b
realToFrac Double
a2} in 
  Day -> (CInt -> IO FloatingRateCoupon) -> IO FloatingRateCoupon
forall a. Day -> (CInt -> IO a) -> IO a
withDay Day
a3 ((CInt -> IO FloatingRateCoupon) -> IO FloatingRateCoupon)
-> (CInt -> IO FloatingRateCoupon) -> IO FloatingRateCoupon
forall a b. (a -> b) -> a -> b
$ \CInt
a3' -> 
  Day -> (CInt -> IO FloatingRateCoupon) -> IO FloatingRateCoupon
forall a. Day -> (CInt -> IO a) -> IO a
withDay Day
a4 ((CInt -> IO FloatingRateCoupon) -> IO FloatingRateCoupon)
-> (CInt -> IO FloatingRateCoupon) -> IO FloatingRateCoupon
forall a b. (a -> b) -> a -> b
$ \CInt
a4' -> 
  let {a5' :: CUInt
a5' = Word -> CUInt
forall a b. (Integral a, Num b) => a -> b
fromIntegral Word
a5} in 
  GenIborIndex ibor
-> (Ptr CIborIndex' -> IO FloatingRateCoupon)
-> IO FloatingRateCoupon
forall ibor b.
GenIborIndex ibor -> (Ptr CIborIndex' -> IO b) -> IO b
withIborIndex GenIborIndex ibor
a6 ((Ptr CIborIndex' -> IO FloatingRateCoupon)
 -> IO FloatingRateCoupon)
-> (Ptr CIborIndex' -> IO FloatingRateCoupon)
-> IO FloatingRateCoupon
forall a b. (a -> b) -> a -> b
$ \Ptr CIborIndex'
a6' -> 
  let {a7' :: CDouble
a7' = Double -> CDouble
forall a b. (Real a, Fractional b) => a -> b
realToFrac Double
a7} in 
  let {a8' :: CDouble
a8' = Double -> CDouble
forall a b. (Real a, Fractional b) => a -> b
realToFrac Double
a8} in 
  let {a9' :: CDouble
a9' = Maybe Double -> CDouble
fromMaybeDouble Maybe Double
a9} in 
  let {a10' :: CDouble
a10' = Maybe Double -> CDouble
fromMaybeDouble Maybe Double
a10} in 
  Maybe Day
-> (CInt -> IO FloatingRateCoupon) -> IO FloatingRateCoupon
forall a. Maybe Day -> (CInt -> IO a) -> IO a
withMaybeDay Maybe Day
a11 ((CInt -> IO FloatingRateCoupon) -> IO FloatingRateCoupon)
-> (CInt -> IO FloatingRateCoupon) -> IO FloatingRateCoupon
forall a b. (a -> b) -> a -> b
$ \CInt
a11' -> 
  Maybe Day
-> (CInt -> IO FloatingRateCoupon) -> IO FloatingRateCoupon
forall a. Maybe Day -> (CInt -> IO a) -> IO a
withMaybeDay Maybe Day
a12 ((CInt -> IO FloatingRateCoupon) -> IO FloatingRateCoupon)
-> (CInt -> IO FloatingRateCoupon) -> IO FloatingRateCoupon
forall a b. (a -> b) -> a -> b
$ \CInt
a12' -> 
  DayCounter
-> (Ptr CDayCounter -> IO FloatingRateCoupon)
-> IO FloatingRateCoupon
forall b. DayCounter -> (Ptr CDayCounter -> IO b) -> IO b
withDayCounter DayCounter
a13 ((Ptr CDayCounter -> IO FloatingRateCoupon)
 -> IO FloatingRateCoupon)
-> (Ptr CDayCounter -> IO FloatingRateCoupon)
-> IO FloatingRateCoupon
forall a b. (a -> b) -> a -> b
$ \Ptr CDayCounter
a13' -> 
  let {a14' :: CInt
a14' = Bool -> CInt
forall a. Num a => Bool -> a
C2HSImp.fromBool Bool
a14} in 
  Maybe Day
-> (CInt -> IO FloatingRateCoupon) -> IO FloatingRateCoupon
forall a. Maybe Day -> (CInt -> IO a) -> IO a
withMaybeDay Maybe Day
a15 ((CInt -> IO FloatingRateCoupon) -> IO FloatingRateCoupon)
-> (CInt -> IO FloatingRateCoupon) -> IO FloatingRateCoupon
forall a b. (a -> b) -> a -> b
$ \CInt
a15' -> 
  let {a16' :: CInt
a16' = BusinessDayConvention -> CInt
forall a b. (Enum a, Integral b) => a -> b
fromEnumC BusinessDayConvention
a16} in 
  (Ptr (Ptr CChar) -> IO FloatingRateCoupon) -> IO FloatingRateCoupon
forall a b. (Ptr (Ptr a) -> IO b) -> IO b
preErrorCheck ((Ptr (Ptr CChar) -> IO FloatingRateCoupon)
 -> IO FloatingRateCoupon)
-> (Ptr (Ptr CChar) -> IO FloatingRateCoupon)
-> IO FloatingRateCoupon
forall a b. (a -> b) -> a -> b
$ \Ptr (Ptr CChar)
a17' -> 
  CInt
-> CDouble
-> CInt
-> CInt
-> CUInt
-> Ptr CIborIndex'
-> CDouble
-> CDouble
-> CDouble
-> CDouble
-> CInt
-> CInt
-> Ptr CDayCounter
-> CInt
-> CInt
-> CInt
-> Ptr (Ptr CChar)
-> IO (Ptr CFloatingRateCoupon')
cappedFlooredIborCoupon'_ CInt
a1' CDouble
a2' CInt
a3' CInt
a4' CUInt
a5' Ptr CIborIndex'
a6' CDouble
a7' CDouble
a8' CDouble
a9' CDouble
a10' CInt
a11' CInt
a12' Ptr CDayCounter
a13' CInt
a14' CInt
a15' CInt
a16' Ptr (Ptr CChar)
a17' IO (Ptr CFloatingRateCoupon')
-> (Ptr CFloatingRateCoupon' -> IO FloatingRateCoupon)
-> IO FloatingRateCoupon
forall a b. IO a -> (a -> IO b) -> IO b
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= \Ptr CFloatingRateCoupon'
res ->
  Ptr CFloatingRateCoupon' -> IO FloatingRateCoupon
peekFloatingRateCoupon Ptr CFloatingRateCoupon'
res IO FloatingRateCoupon
-> (FloatingRateCoupon -> IO FloatingRateCoupon)
-> IO FloatingRateCoupon
forall a b. IO a -> (a -> IO b) -> IO b
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= \FloatingRateCoupon
res' ->
  Ptr (Ptr CChar) -> IO ()
errorCheck  Ptr (Ptr CChar)
a17'IO () -> IO FloatingRateCoupon -> IO FloatingRateCoupon
forall a b. IO a -> IO b -> IO b
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>>
  FloatingRateCoupon -> IO FloatingRateCoupon
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return (FloatingRateCoupon
res')

{-# LINE 569 "./QuantLib/CashFlow.chs" #-}


-- |Ibor coupon with embedded digital call and put options.
digitalIborCoupon :: (IborCoupon) -- ^underlying
 -> (Maybe Double) -- ^callStrike
 -> (PositionType) -- ^callPosition
 -> (Bool) -- ^callATM
 -> (Maybe Double) -- ^callDigitalPayoff
 -> (Maybe Double) -- ^putStrike
 -> (PositionType) -- ^putPosition
 -> (Bool) -- ^putATM
 -> (Maybe Double) -- ^putDigitalPayoff
 -> (Maybe DigitalReplication) -- ^replication
 -> (Bool) -- ^nakedOption
 -> IO ((DigitalCoupon))
digitalIborCoupon a1 a2 a3 a4 a5 a6 a7 a8 a9 a10 a11 =
  withIborCoupon a1 $ \a1' -> 
  let {a2' = fromMaybeDouble a2} in 
  let {a3' = fromEnumC a3} in 
  let {a4' = C2HSImp.fromBool a4} in 
  let {a5' = fromMaybeDouble a5} in 
  let {a6' = fromMaybeDouble a6} in 
  let {a7' = fromEnumC a7} in 
  let {a8' = C2HSImp.fromBool a8} in 
  let {a9' = fromMaybeDouble a9} in 
  withMaybeDigitalReplication a10 $ \a10' -> 
  let {a11' = C2HSImp.fromBool a11} in 
  preErrorCheck $ \a12' -> 
  digitalIborCoupon'_ a1' a2' a3' a4' a5' a6' a7' a8' a9' a10' a11' a12' >>= \res ->
  peekDigitalCoupon res >>= \res' ->
  errorCheck  a12'>>
  return (res')

{-# LINE 583 "./QuantLib/CashFlow.chs" #-}


-- |A floating coupon with replicated digital call and put payoffs.  Optional
-- strikes/payoffs use 'Nothing' for QuantLib's null-rate sentinel.
digitalCoupon :: (GenFloatingRateCoupon frc) -- ^underlying
 -> (Maybe Double) -> (PositionType) -> (Bool) -> (Maybe Double) -> (Maybe Double) -> (PositionType) -> (Bool) -> (Maybe Double) -> (Maybe DigitalReplication) -> (Bool) -> IO ((DigitalCoupon))
digitalCoupon a1 a2 a3 a4 a5 a6 a7 a8 a9 a10 a11 =
  withFloatingRateCoupon a1 $ \a1' -> 
  let {a2' = fromMaybeDouble a2} in 
  let {a3' = fromEnumC a3} in 
  let {a4' = C2HSImp.fromBool a4} in 
  let {a5' = fromMaybeDouble a5} in 
  let {a6' = fromMaybeDouble a6} in 
  let {a7' = fromEnumC a7} in 
  let {a8' = C2HSImp.fromBool a8} in 
  let {a9' = fromMaybeDouble a9} in 
  withMaybeDigitalReplication a10 $ \a10' -> 
  let {a11' = C2HSImp.fromBool a11} in 
  preErrorCheck $ \a12' -> 
  digitalCoupon'_ a1' a2' a3' a4' a5' a6' a7' a8' a9' a10' a11' a12' >>= \res ->
  peekDigitalCoupon res >>= \res' ->
  errorCheck  a12'>>
  return (res')

{-# LINE 591 "./QuantLib/CashFlow.chs" #-}

callOptionRate :: (GenDigitalCoupon dc) -> IO ((Double))
callOptionRate a1 =
  withDigitalCoupon a1 $ \a1' -> 
  preErrorCheck $ \a2' -> 
  callOptionRate'_ a1' a2' >>= \res ->
  let {res' = realToFrac res} in
  errorCheck  a2'>>
  return (res')

{-# LINE 592 "./QuantLib/CashFlow.chs" #-}

putOptionRate :: (GenDigitalCoupon dc) -> IO ((Double))
putOptionRate a1 =
  withDigitalCoupon a1 $ \a1' -> 
  preErrorCheck $ \a2' -> 
  putOptionRate'_ a1' a2' >>= \res ->
  let {res' = realToFrac res} in
  errorCheck  a2'>>
  return (res')

{-# LINE 593 "./QuantLib/CashFlow.chs" #-}


-- |Ibor coupon whose rate averages multiple reset dates in each accrual period.
multipleResetsCoupon :: (Day) -- ^paymentDate
 -> (Double) -- ^nominal
 -> (Schedule) -- ^fixingSchedule
 -> (Word) -- ^fixingDays
 -> (GenIborIndex ibor) -- ^index
 -> (Double) -- ^gearing
 -> (Double) -- ^couponSpread
 -> (Double) -- ^rateSpread
 -> (Maybe Day) -- ^referencePeriodStart
 -> (Maybe Day) -- ^referencePeriodEnd
 -> (DayCounter) -- ^dayCounter
 -> (Maybe Day) -- ^exCouponDate
 -> IO ((MultipleResetsCoupon))
multipleResetsCoupon :: forall ibor.
Day
-> Double
-> Schedule
-> Word
-> GenIborIndex ibor
-> Double
-> Double
-> Double
-> Maybe Day
-> Maybe Day
-> DayCounter
-> Maybe Day
-> IO MultipleResetsCoupon
multipleResetsCoupon Day
a1 Double
a2 Schedule
a3 Word
a4 GenIborIndex ibor
a5 Double
a6 Double
a7 Double
a8 Maybe Day
a9 Maybe Day
a10 DayCounter
a11 Maybe Day
a12 =
  Day -> (CInt -> IO MultipleResetsCoupon) -> IO MultipleResetsCoupon
forall a. Day -> (CInt -> IO a) -> IO a
withDay Day
a1 ((CInt -> IO MultipleResetsCoupon) -> IO MultipleResetsCoupon)
-> (CInt -> IO MultipleResetsCoupon) -> IO MultipleResetsCoupon
forall a b. (a -> b) -> a -> b
$ \CInt
a1' -> 
  let {a2' :: CDouble
a2' = Double -> CDouble
forall a b. (Real a, Fractional b) => a -> b
realToFrac Double
a2} in 
  Schedule
-> (Ptr CSchedule -> IO MultipleResetsCoupon)
-> IO MultipleResetsCoupon
forall b. Schedule -> (Ptr CSchedule -> IO b) -> IO b
withSchedule Schedule
a3 ((Ptr CSchedule -> IO MultipleResetsCoupon)
 -> IO MultipleResetsCoupon)
-> (Ptr CSchedule -> IO MultipleResetsCoupon)
-> IO MultipleResetsCoupon
forall a b. (a -> b) -> a -> b
$ \Ptr CSchedule
a3' -> 
  let {a4' = fromIntegral a4} in 
  withIborIndex a5 $ \a5' -> 
  let {a6' = realToFrac a6} in 
  let {a7' = realToFrac a7} in 
  let {a8' = realToFrac a8} in 
  withMaybeDay a9 $ \a9' -> 
  withMaybeDay a10 $ \a10' -> 
  withDayCounter a11 $ \a11' -> 
  withMaybeDay a12 $ \a12' -> 
  preErrorCheck $ \a13' -> 
  multipleResetsCoupon'_ a1' a2' a3' a4' a5' a6' a7' a8' a9' a10' a11' a12' a13' >>= \res ->
  peekMultipleResetsCoupon res >>= \res' ->
  errorCheck  a13'>>
  return (res')

{-# LINE 608 "./QuantLib/CashFlow.chs" #-}


-- |Fixing dates for the rates being compounded over this coupon's reset schedule.
multipleResetsCouponFixingDatesRaw :: (MultipleResetsCoupon) -> IO (([Day]))
multipleResetsCouponFixingDatesRaw a1 =
  withMultipleResetsCoupon a1 $ \a1' -> 
  preArray $ \(a2'1, a2'2) -> 
  preErrorCheck $ \a3' -> 
  multipleResetsCouponFixingDatesRaw'_ a1' a2'1  a2'2 a3' >>
  peekDayArray  a2'1  a2'2>>= \a2'' -> 
  errorCheck  a3'>>
  return (a2'')

{-# LINE 611 "./QuantLib/CashFlow.chs" #-}


-- |A range-accrual coupon.  Attach the existing range-accrual pricer before
-- asking for its rate; 'priceWithoutOptionality'
-- needs only a discount curve.
rangeAccrualFloatersCoupon :: (Day) -> (Double) -> (GenIborIndex ibor) -> (Day) -> (Day) -> (Word) -> (DayCounter) -> (Double) -> (Double) -> (Maybe Day) -> (Maybe Day) -> (Schedule) -> (Double) -> (Double) -> IO ((RangeAccrualFloatersCoupon))
rangeAccrualFloatersCoupon a1 a2 a3 a4 a5 a6 a7 a8 a9 a10 a11 a12 a13 a14 =
  withDay a1 $ \a1' -> 
  let {a2' = realToFrac a2} in 
  withIborIndex a3 $ \a3' -> 
  withDay a4 $ \a4' -> 
  withDay a5 $ \a5' -> 
  let {a6' = fromIntegral a6} in 
  withDayCounter a7 $ \a7' -> 
  let {a8' = realToFrac a8} in 
  let {a9' = realToFrac a9} in 
  withMaybeDay a10 $ \a10' -> 
  withMaybeDay a11 $ \a11' -> 
  withSchedule a12 $ \a12' -> 
  let {a13' = realToFrac a13} in 
  let {a14' = realToFrac a14} in 
  preErrorCheck $ \a15' -> 
  rangeAccrualFloatersCoupon'_ a1' a2' a3' a4' a5' a6' a7' a8' a9' a10' a11' a12' a13' a14' a15' >>= \res ->
  peekRangeAccrualFloatersCoupon res >>= \res' ->
  errorCheck  a15'>>
  return (res')

{-# LINE 616 "./QuantLib/CashFlow.chs" #-}

priceWithoutOptionality :: (RangeAccrualFloatersCoupon) -> (GenYieldTermStructure y) -> IO ((Double))
priceWithoutOptionality a1 a2 =
  withRangeAccrualFloatersCoupon a1 $ \a1' -> 
  withYieldTermStructure a2 $ \a2' -> 
  preErrorCheck $ \a3' -> 
  priceWithoutOptionality'_ a1' a2' a3' >>= \res ->
  let {res' = realToFrac res} in
  errorCheck  a3'>>
  return (res')

{-# LINE 617 "./QuantLib/CashFlow.chs" #-}


-- |A year-on-year inflation coupon.  As for 'yoyInflationLeg', attach a
-- YoY inflation coupon pricer before evaluating the coupon rate.
yoyInflationCoupon :: (Day) -> (Double) -> (Day) -> (Day) -> (Word) -> (YoYInflationIndex) -> ((Int,TimeUnit)) -> (CPIInterpolationType) -> (DayCounter) -> (Double) -> (Double) -> (Maybe Day) -> (Maybe Day) -> IO ((YoYInflationCoupon))
yoyInflationCoupon a1 a2 a3 a4 a5 a6 a7 a8 a9 a10 a11 a12 a13 =
  withDay a1 $ \a1' -> 
  let {a2' = realToFrac a2} in 
  withDay a3 $ \a3' -> 
  withDay a4 $ \a4' -> 
  let {a5' = fromIntegral a5} in 
  withYoYInflationIndex a6 $ \a6' -> 
  let {(a7'1, a7'2) = fromEnumQuantity a7} in 
  let {a8' = fromEnumC a8} in 
  withDayCounter a9 $ \a9' -> 
  let {a10' = realToFrac a10} in 
  let {a11' = realToFrac a11} in 
  withMaybeDay a12 $ \a12' -> 
  withMaybeDay a13 $ \a13' -> 
  preErrorCheck $ \a14' -> 
  yoyInflationCoupon'_ a1' a2' a3' a4' a5' a6' a7'1  a7'2 a8' a9' a10' a11' a12' a13' a14' >>= \res ->
  peekYoYInflationCoupon res >>= \res' ->
  errorCheck  a14'>>
  return (res')

{-# LINE 621 "./QuantLib/CashFlow.chs" #-}

adjustedFixing :: (YoYInflationCoupon) -> IO ((Double))
adjustedFixing a1 =
  withYoYInflationCoupon a1 $ \a1' -> 
  preErrorCheck $ \a2' -> 
  adjustedFixing'_ a1' a2' >>= \res ->
  let {res' = realToFrac res} in
  errorCheck  a2'>>
  return (res')

{-# LINE 622 "./QuantLib/CashFlow.chs" #-}


-- |Pricer that arithmetically averages multiple Ibor resets.
averagingMultipleResetsPricer :: IO ((FloatingRateCouponPricer))
averagingMultipleResetsPricer =
  preErrorCheck $ \a1' -> 
  averagingMultipleResetsPricer'_ a1' >>= \res ->
  peekFloatingRateCouponPricer res >>= \res' ->
  errorCheck  a1'>>
  return (res')

{-# LINE 625 "./QuantLib/CashFlow.chs" #-}


-- |Pricer that compounds multiple Ibor resets.
compoundingMultipleResetsPricer :: IO ((FloatingRateCouponPricer))
compoundingMultipleResetsPricer =
  preErrorCheck $ \a1' -> 
  compoundingMultipleResetsPricer'_ a1' >>= \res ->
  peekFloatingRateCouponPricer res >>= \res' ->
  errorCheck  a1'>>
  return (res')

{-# LINE 628 "./QuantLib/CashFlow.chs" #-}


-- |Overnight-index coupon with explicit observation and accrual conventions.
overnightIndexedCoupon :: (Day) -- ^paymentDate
 -> (Double) -- ^nominal
 -> (Day) -- ^accrualStartDate
 -> (Day) -- ^accrualEndDate
 -> (OvernightIborIndex) -- ^index
 -> (Double) -- ^gearing
 -> (Double) -- ^spread
 -> (Maybe Day) -- ^referencePeriodStart
 -> (Maybe Day) -- ^referencePeriodEnd
 -> (DayCounter) -- ^dayCounter
 -> (Bool) -- ^telescopicValueDates
 -> (RateAveragingType) -- ^averagingMethod
 -> (Word) -- ^lookbackDays
 -> (Word) -- ^lockoutDays
 -> (Bool) -- ^applyObservationShift
 -> (Bool) -- ^includeSpread
 -> (Maybe Day) -- ^rateComputationStartDate
 -> (Maybe Day) -- ^rateComputationEndDate
 -> (Maybe Day) -- ^exCouponDate
 -> (Maybe Int) -- ^rounding
 -> IO ((OvernightIndexedCoupon))
overnightIndexedCoupon :: Day
-> Double
-> Day
-> Day
-> OvernightIborIndex
-> Double
-> Double
-> Maybe Day
-> Maybe Day
-> DayCounter
-> Bool
-> RateAveragingType
-> Word
-> Word
-> Bool
-> Bool
-> Maybe Day
-> Maybe Day
-> Maybe Day
-> Maybe Int
-> IO OvernightIndexedCoupon
overnightIndexedCoupon Day
a1 Double
a2 Day
a3 Day
a4 OvernightIborIndex
a5 Double
a6 Double
a7 Maybe Day
a8 Maybe Day
a9 DayCounter
a10 Bool
a11 RateAveragingType
a12 Word
a13 Word
a14 Bool
a15 Bool
a16 Maybe Day
a17 Maybe Day
a18 Maybe Day
a19 Maybe Int
a20 =
  Day
-> (CInt -> IO OvernightIndexedCoupon) -> IO OvernightIndexedCoupon
forall a. Day -> (CInt -> IO a) -> IO a
withDay Day
a1 ((CInt -> IO OvernightIndexedCoupon) -> IO OvernightIndexedCoupon)
-> (CInt -> IO OvernightIndexedCoupon) -> IO OvernightIndexedCoupon
forall a b. (a -> b) -> a -> b
$ \CInt
a1' -> 
  let {a2' :: CDouble
a2' = Double -> CDouble
forall a b. (Real a, Fractional b) => a -> b
realToFrac Double
a2} in 
  Day
-> (CInt -> IO OvernightIndexedCoupon) -> IO OvernightIndexedCoupon
forall a. Day -> (CInt -> IO a) -> IO a
withDay Day
a3 ((CInt -> IO OvernightIndexedCoupon) -> IO OvernightIndexedCoupon)
-> (CInt -> IO OvernightIndexedCoupon) -> IO OvernightIndexedCoupon
forall a b. (a -> b) -> a -> b
$ \CInt
a3' -> 
  Day
-> (CInt -> IO OvernightIndexedCoupon) -> IO OvernightIndexedCoupon
forall a. Day -> (CInt -> IO a) -> IO a
withDay Day
a4 ((CInt -> IO OvernightIndexedCoupon) -> IO OvernightIndexedCoupon)
-> (CInt -> IO OvernightIndexedCoupon) -> IO OvernightIndexedCoupon
forall a b. (a -> b) -> a -> b
$ \CInt
a4' -> 
  OvernightIborIndex
-> (Ptr COvernightIndex' -> IO OvernightIndexedCoupon)
-> IO OvernightIndexedCoupon
forall b.
OvernightIborIndex -> (Ptr COvernightIndex' -> IO b) -> IO b
withOvernightIborIndex OvernightIborIndex
a5 ((Ptr COvernightIndex' -> IO OvernightIndexedCoupon)
 -> IO OvernightIndexedCoupon)
-> (Ptr COvernightIndex' -> IO OvernightIndexedCoupon)
-> IO OvernightIndexedCoupon
forall a b. (a -> b) -> a -> b
$ \Ptr COvernightIndex'
a5' -> 
  let {a6' :: CDouble
a6' = Double -> CDouble
forall a b. (Real a, Fractional b) => a -> b
realToFrac Double
a6} in 
  let {a7' :: CDouble
a7' = Double -> CDouble
forall a b. (Real a, Fractional b) => a -> b
realToFrac Double
a7} in 
  Maybe Day
-> (CInt -> IO OvernightIndexedCoupon) -> IO OvernightIndexedCoupon
forall a. Maybe Day -> (CInt -> IO a) -> IO a
withMaybeDay Maybe Day
a8 ((CInt -> IO OvernightIndexedCoupon) -> IO OvernightIndexedCoupon)
-> (CInt -> IO OvernightIndexedCoupon) -> IO OvernightIndexedCoupon
forall a b. (a -> b) -> a -> b
$ \CInt
a8' -> 
  Maybe Day
-> (CInt -> IO OvernightIndexedCoupon) -> IO OvernightIndexedCoupon
forall a. Maybe Day -> (CInt -> IO a) -> IO a
withMaybeDay Maybe Day
a9 ((CInt -> IO OvernightIndexedCoupon) -> IO OvernightIndexedCoupon)
-> (CInt -> IO OvernightIndexedCoupon) -> IO OvernightIndexedCoupon
forall a b. (a -> b) -> a -> b
$ \CInt
a9' -> 
  DayCounter
-> (Ptr CDayCounter -> IO OvernightIndexedCoupon)
-> IO OvernightIndexedCoupon
forall b. DayCounter -> (Ptr CDayCounter -> IO b) -> IO b
withDayCounter DayCounter
a10 ((Ptr CDayCounter -> IO OvernightIndexedCoupon)
 -> IO OvernightIndexedCoupon)
-> (Ptr CDayCounter -> IO OvernightIndexedCoupon)
-> IO OvernightIndexedCoupon
forall a b. (a -> b) -> a -> b
$ \Ptr CDayCounter
a10' -> 
  let {a11' :: CInt
a11' = Bool -> CInt
forall a. Num a => Bool -> a
C2HSImp.fromBool Bool
a11} in 
  let {a12' :: CInt
a12' = RateAveragingType -> CInt
forall a b. (Enum a, Integral b) => a -> b
fromEnumC RateAveragingType
a12} in 
  let {a13' :: CUInt
a13' = Word -> CUInt
forall a b. (Integral a, Num b) => a -> b
fromIntegral Word
a13} in 
  let {a14' :: CUInt
a14' = Word -> CUInt
forall a b. (Integral a, Num b) => a -> b
fromIntegral Word
a14} in 
  let {a15' :: CInt
a15' = Bool -> CInt
forall a. Num a => Bool -> a
C2HSImp.fromBool Bool
a15} in 
  let {a16' :: CInt
a16' = Bool -> CInt
forall a. Num a => Bool -> a
C2HSImp.fromBool Bool
a16} in 
  Maybe Day
-> (CInt -> IO OvernightIndexedCoupon) -> IO OvernightIndexedCoupon
forall a. Maybe Day -> (CInt -> IO a) -> IO a
withMaybeDay Maybe Day
a17 ((CInt -> IO OvernightIndexedCoupon) -> IO OvernightIndexedCoupon)
-> (CInt -> IO OvernightIndexedCoupon) -> IO OvernightIndexedCoupon
forall a b. (a -> b) -> a -> b
$ \CInt
a17' -> 
  Maybe Day
-> (CInt -> IO OvernightIndexedCoupon) -> IO OvernightIndexedCoupon
forall a. Maybe Day -> (CInt -> IO a) -> IO a
withMaybeDay Maybe Day
a18 ((CInt -> IO OvernightIndexedCoupon) -> IO OvernightIndexedCoupon)
-> (CInt -> IO OvernightIndexedCoupon) -> IO OvernightIndexedCoupon
forall a b. (a -> b) -> a -> b
$ \CInt
a18' -> 
  Maybe Day
-> (CInt -> IO OvernightIndexedCoupon) -> IO OvernightIndexedCoupon
forall a. Maybe Day -> (CInt -> IO a) -> IO a
withMaybeDay Maybe Day
a19 ((CInt -> IO OvernightIndexedCoupon) -> IO OvernightIndexedCoupon)
-> (CInt -> IO OvernightIndexedCoupon) -> IO OvernightIndexedCoupon
forall a b. (a -> b) -> a -> b
$ \CInt
a19' -> 
  let {a20' :: CInt
a20' = Maybe Int -> CInt
forall a b. (Integral a, Integral b) => Maybe a -> b
fromMaybeInt Maybe Int
a20} in 
  (Ptr (Ptr CChar) -> IO OvernightIndexedCoupon)
-> IO OvernightIndexedCoupon
forall a b. (Ptr (Ptr a) -> IO b) -> IO b
preErrorCheck ((Ptr (Ptr CChar) -> IO OvernightIndexedCoupon)
 -> IO OvernightIndexedCoupon)
-> (Ptr (Ptr CChar) -> IO OvernightIndexedCoupon)
-> IO OvernightIndexedCoupon
forall a b. (a -> b) -> a -> b
$ \Ptr (Ptr CChar)
a21' -> 
  CInt
-> CDouble
-> CInt
-> CInt
-> Ptr COvernightIndex'
-> CDouble
-> CDouble
-> CInt
-> CInt
-> Ptr CDayCounter
-> CInt
-> CInt
-> CUInt
-> CUInt
-> CInt
-> CInt
-> CInt
-> CInt
-> CInt
-> CInt
-> Ptr (Ptr CChar)
-> IO (Ptr COvernightIndexedCoupon')
overnightIndexedCoupon'_ CInt
a1' CDouble
a2' CInt
a3' CInt
a4' Ptr COvernightIndex'
a5' CDouble
a6' CDouble
a7' CInt
a8' CInt
a9' Ptr CDayCounter
a10' CInt
a11' CInt
a12' CUInt
a13' CUInt
a14' CInt
a15' CInt
a16' CInt
a17' CInt
a18' CInt
a19' CInt
a20' Ptr (Ptr CChar)
a21' IO (Ptr COvernightIndexedCoupon')
-> (Ptr COvernightIndexedCoupon' -> IO OvernightIndexedCoupon)
-> IO OvernightIndexedCoupon
forall a b. IO a -> (a -> IO b) -> IO b
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= \Ptr COvernightIndexedCoupon'
res ->
  Ptr COvernightIndexedCoupon' -> IO OvernightIndexedCoupon
peekOvernightIndexedCoupon Ptr COvernightIndexedCoupon'
res IO OvernightIndexedCoupon
-> (OvernightIndexedCoupon -> IO OvernightIndexedCoupon)
-> IO OvernightIndexedCoupon
forall a b. IO a -> (a -> IO b) -> IO b
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= \OvernightIndexedCoupon
res' ->
  Ptr (Ptr CChar) -> IO ()
errorCheck  Ptr (Ptr CChar)
a21'IO () -> IO OvernightIndexedCoupon -> IO OvernightIndexedCoupon
forall a b. IO a -> IO b -> IO b
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>>
  OvernightIndexedCoupon -> IO OvernightIndexedCoupon
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return (OvernightIndexedCoupon
res')

{-# LINE 651 "./QuantLib/CashFlow.chs" #-}


-- |The dates on which the coupon observes the overnight index, one per accrual sub-period.
overnightIndexedCouponFixingDatesRaw :: (OvernightIndexedCoupon) -> IO (([Day]))
overnightIndexedCouponFixingDatesRaw a1 =
  withOvernightIndexedCoupon a1 $ \a1' -> 
  preArray $ \(a2'1, a2'2) -> 
  preErrorCheck $ \a3' -> 
  overnightIndexedCouponFixingDatesRaw'_ a1' a2'1  a2'2 a3' >>
  peekDayArray  a2'1  a2'2>>= \a2'' -> 
  errorCheck  a3'>>
  return (a2'')

{-# LINE 655 "./QuantLib/CashFlow.chs" #-}


-- |The index fixing observed at each of 'fixingDates', in the same order.
-- Requires the underlying overnight index to already have those fixings available (historical or
-- forecast via a projection curve).
overnightIndexedCouponIndexFixingsRaw :: (OvernightIndexedCoupon) -> IO (([Double]))
overnightIndexedCouponIndexFixingsRaw a1 =
  withOvernightIndexedCoupon a1 $ \a1' -> 
  preArray $ \(a2'1, a2'2) -> 
  preErrorCheck $ \a3' -> 
  overnightIndexedCouponIndexFixingsRaw'_ a1' a2'1  a2'2 a3' >>
  peekDoubleArray  a2'1  a2'2>>= \a2'' -> 
  errorCheck  a3'>>
  return (a2'')

{-# LINE 661 "./QuantLib/CashFlow.chs" #-}


-- |Capped/floored overnight-index coupon.
cappedFlooredOvernightIndexedCoupon :: (OvernightIndexedCoupon) -- ^underlying
 -> (Maybe Double) -- ^cap
 -> (Maybe Double) -- ^floor
 -> (Bool) -- ^nakedOption
 -> (Bool) -- ^includeSpread
 -> IO ((FloatingRateCoupon))
cappedFlooredOvernightIndexedCoupon a1 a2 a3 a4 a5 =
  withOvernightIndexedCoupon a1 $ \a1' -> 
  let {a2' = fromMaybeDouble a2} in 
  let {a3' = fromMaybeDouble a3} in 
  let {a4' = C2HSImp.fromBool a4} in 
  let {a5' = C2HSImp.fromBool a5} in 
  preErrorCheck $ \a6' -> 
  cappedFlooredOvernightIndexedCoupon'_ a1' a2' a3' a4' a5' a6' >>= \res ->
  peekFloatingRateCoupon res >>= \res' ->
  errorCheck  a6'>>
  return (res')

{-# LINE 669 "./QuantLib/CashFlow.chs" #-}


-- |Compounding overnight-index coupon pricer.
compoundingOvernightIndexedCouponPricer :: (Maybe OptionletVolatilityStructure) -- ^capletVolatility
 -> (Bool) -- ^byApprox
 -> IO ((FloatingRateCouponPricer))
compoundingOvernightIndexedCouponPricer a1 a2 =
  withMaybeOptionletVolatilityStructure a1 $ \a1' -> 
  let {a2' = C2HSImp.fromBool a2} in 
  preErrorCheck $ \a3' -> 
  compoundingOvernightIndexedCouponPricer'_ a1' a2' a3' >>= \res ->
  peekFloatingRateCouponPricer res >>= \res' ->
  errorCheck  a3'>>
  return (res')

{-# LINE 674 "./QuantLib/CashFlow.chs" #-}


-- |Arithmetic-average overnight-index coupon pricer.
arithmeticAveragedOvernightIndexedCouponPricer :: (Double) -- ^meanReversion
 -> (Double) -- ^volatility
 -> (Bool) -- ^byApprox
 -> (Maybe OptionletVolatilityStructure) -- ^capletVolatility
 -> (Bool) -- ^effective
 -> IO ((FloatingRateCouponPricer))
arithmeticAveragedOvernightIndexedCouponPricer a1 a2 a3 a4 a5 =
  let {a1' = realToFrac a1} in 
  let {a2' = realToFrac a2} in 
  let {a3' = C2HSImp.fromBool a3} in 
  withMaybeOptionletVolatilityStructure a4 $ \a4' -> 
  let {a5' = C2HSImp.fromBool a5} in 
  preErrorCheck $ \a6' -> 
  arithmeticAveragedOvernightIndexedCouponPricer'_ a1' a2' a3' a4' a5' a6' >>= \res ->
  peekFloatingRateCouponPricer res >>= \res' ->
  errorCheck  a6'>>
  return (res')

{-# LINE 682 "./QuantLib/CashFlow.chs" #-}


-- |Black-formula compounding overnight-index coupon pricer.
blackCompoundingOvernightIndexedCouponPricer :: (Maybe OptionletVolatilityStructure) -- ^capletVolatility
 -> (Bool) -- ^effective
 -> IO ((FloatingRateCouponPricer))
blackCompoundingOvernightIndexedCouponPricer a1 a2 =
  withMaybeOptionletVolatilityStructure a1 $ \a1' -> 
  let {a2' = C2HSImp.fromBool a2} in 
  preErrorCheck $ \a3' -> 
  blackCompoundingOvernightIndexedCouponPricer'_ a1' a2' a3' >>= \res ->
  peekFloatingRateCouponPricer res >>= \res' ->
  errorCheck  a3'>>
  return (res')

{-# LINE 687 "./QuantLib/CashFlow.chs" #-}


-- |Black-formula arithmetic-average overnight-index coupon pricer.
blackAveragingOvernightIndexedCouponPricer :: (Maybe OptionletVolatilityStructure) -- ^capletVolatility
 -> (Bool) -- ^effective
 -> IO ((FloatingRateCouponPricer))
blackAveragingOvernightIndexedCouponPricer a1 a2 =
  withMaybeOptionletVolatilityStructure a1 $ \a1' -> 
  let {a2' = C2HSImp.fromBool a2} in 
  preErrorCheck $ \a3' -> 
  blackAveragingOvernightIndexedCouponPricer'_ a1' a2' a3' >>= \res ->
  peekFloatingRateCouponPricer res >>= \res' ->
  errorCheck  a3'>>
  return (res')

{-# LINE 692 "./QuantLib/CashFlow.chs" #-}


-- |CPI-linked coupon whose base fixing is supplied directly.
cpiCoupon :: (Double) -- ^baseCPI
 -> (Day) -- ^paymentDate
 -> (Double) -- ^nominal
 -> (Day) -- ^accrualStartDate
 -> (Day) -- ^accrualEndDate
 -> (GenZeroInflationIndex zidx) -- ^index
 -> ((Int,TimeUnit)) -- ^observationLag
 -> (CPIInterpolationType) -- ^observationInterpolation
 -> (DayCounter) -- ^dayCounter
 -> (Double) -- ^fixedRate
 -> (Maybe Day) -- ^referencePeriodStart
 -> (Maybe Day) -- ^referencePeriodEnd
 -> (Maybe Day) -- ^exCouponDate
 -> IO ((CPICoupon))
cpiCoupon :: forall zidx.
Double
-> Day
-> Double
-> Day
-> Day
-> GenZeroInflationIndex zidx
-> (Int, TimeUnit)
-> CPIInterpolationType
-> DayCounter
-> Double
-> Maybe Day
-> Maybe Day
-> Maybe Day
-> IO CPICoupon
cpiCoupon Double
a1 Day
a2 Double
a3 Day
a4 Day
a5 GenZeroInflationIndex zidx
a6 (Int, TimeUnit)
a7 CPIInterpolationType
a8 DayCounter
a9 Double
a10 Maybe Day
a11 Maybe Day
a12 Maybe Day
a13 =
  let {a1' :: CDouble
a1' = Double -> CDouble
forall a b. (Real a, Fractional b) => a -> b
realToFrac Double
a1} in 
  Day -> (CInt -> IO CPICoupon) -> IO CPICoupon
forall a. Day -> (CInt -> IO a) -> IO a
withDay Day
a2 ((CInt -> IO CPICoupon) -> IO CPICoupon)
-> (CInt -> IO CPICoupon) -> IO CPICoupon
forall a b. (a -> b) -> a -> b
$ \CInt
a2' -> 
  let {a3' :: CDouble
a3' = Double -> CDouble
forall a b. (Real a, Fractional b) => a -> b
realToFrac Double
a3} in 
  Day -> (CInt -> IO CPICoupon) -> IO CPICoupon
forall a. Day -> (CInt -> IO a) -> IO a
withDay Day
a4 ((CInt -> IO CPICoupon) -> IO CPICoupon)
-> (CInt -> IO CPICoupon) -> IO CPICoupon
forall a b. (a -> b) -> a -> b
$ \CInt
a4' -> 
  Day -> (CInt -> IO CPICoupon) -> IO CPICoupon
forall a. Day -> (CInt -> IO a) -> IO a
withDay Day
a5 ((CInt -> IO CPICoupon) -> IO CPICoupon)
-> (CInt -> IO CPICoupon) -> IO CPICoupon
forall a b. (a -> b) -> a -> b
$ \CInt
a5' -> 
  GenZeroInflationIndex zidx
-> (Ptr CZeroInflationIndex' -> IO CPICoupon) -> IO CPICoupon
forall zidx b.
GenZeroInflationIndex zidx
-> (Ptr CZeroInflationIndex' -> IO b) -> IO b
withZeroInflationIndex GenZeroInflationIndex zidx
a6 ((Ptr CZeroInflationIndex' -> IO CPICoupon) -> IO CPICoupon)
-> (Ptr CZeroInflationIndex' -> IO CPICoupon) -> IO CPICoupon
forall a b. (a -> b) -> a -> b
$ \Ptr CZeroInflationIndex'
a6' -> 
  let {(CInt
a7'1, CInt
a7'2) = (Int, TimeUnit) -> (CInt, CInt)
forall a b c.
(Enum a, Integral b, Integral c) =>
(b, a) -> (CInt, c)
fromEnumQuantity (Int, TimeUnit)
a7} in 
  let {a8' :: CInt
a8' = CPIInterpolationType -> CInt
forall a b. (Enum a, Integral b) => a -> b
fromEnumC CPIInterpolationType
a8} in 
  DayCounter -> (Ptr CDayCounter -> IO CPICoupon) -> IO CPICoupon
forall b. DayCounter -> (Ptr CDayCounter -> IO b) -> IO b
withDayCounter DayCounter
a9 ((Ptr CDayCounter -> IO CPICoupon) -> IO CPICoupon)
-> (Ptr CDayCounter -> IO CPICoupon) -> IO CPICoupon
forall a b. (a -> b) -> a -> b
$ \Ptr CDayCounter
a9' -> 
  let {a10' :: CDouble
a10' = Double -> CDouble
forall a b. (Real a, Fractional b) => a -> b
realToFrac Double
a10} in 
  Maybe Day -> (CInt -> IO CPICoupon) -> IO CPICoupon
forall a. Maybe Day -> (CInt -> IO a) -> IO a
withMaybeDay Maybe Day
a11 ((CInt -> IO CPICoupon) -> IO CPICoupon)
-> (CInt -> IO CPICoupon) -> IO CPICoupon
forall a b. (a -> b) -> a -> b
$ \CInt
a11' -> 
  Maybe Day -> (CInt -> IO CPICoupon) -> IO CPICoupon
forall a. Maybe Day -> (CInt -> IO a) -> IO a
withMaybeDay Maybe Day
a12 ((CInt -> IO CPICoupon) -> IO CPICoupon)
-> (CInt -> IO CPICoupon) -> IO CPICoupon
forall a b. (a -> b) -> a -> b
$ \CInt
a12' -> 
  Maybe Day -> (CInt -> IO CPICoupon) -> IO CPICoupon
forall a. Maybe Day -> (CInt -> IO a) -> IO a
withMaybeDay Maybe Day
a13 ((CInt -> IO CPICoupon) -> IO CPICoupon)
-> (CInt -> IO CPICoupon) -> IO CPICoupon
forall a b. (a -> b) -> a -> b
$ \CInt
a13' -> 
  (Ptr (Ptr CChar) -> IO CPICoupon) -> IO CPICoupon
forall a b. (Ptr (Ptr a) -> IO b) -> IO b
preErrorCheck ((Ptr (Ptr CChar) -> IO CPICoupon) -> IO CPICoupon)
-> (Ptr (Ptr CChar) -> IO CPICoupon) -> IO CPICoupon
forall a b. (a -> b) -> a -> b
$ \Ptr (Ptr CChar)
a14' -> 
  CDouble
-> CInt
-> CDouble
-> CInt
-> CInt
-> Ptr CZeroInflationIndex'
-> CInt
-> CInt
-> CInt
-> Ptr CDayCounter
-> CDouble
-> CInt
-> CInt
-> CInt
-> Ptr (Ptr CChar)
-> IO (Ptr CCPICoupon')
cpiCoupon'_ CDouble
a1' CInt
a2' CDouble
a3' CInt
a4' CInt
a5' Ptr CZeroInflationIndex'
a6' CInt
a7'1  CInt
a7'2 CInt
a8' Ptr CDayCounter
a9' CDouble
a10' CInt
a11' CInt
a12' CInt
a13' Ptr (Ptr CChar)
a14' IO (Ptr CCPICoupon')
-> (Ptr CCPICoupon' -> IO CPICoupon) -> IO CPICoupon
forall a b. IO a -> (a -> IO b) -> IO b
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= \Ptr CCPICoupon'
res ->
  Ptr CCPICoupon' -> IO CPICoupon
peekCPICoupon Ptr CCPICoupon'
res IO CPICoupon -> (CPICoupon -> IO CPICoupon) -> IO CPICoupon
forall a b. IO a -> (a -> IO b) -> IO b
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= \CPICoupon
res' ->
  Ptr (Ptr CChar) -> IO ()
errorCheck  Ptr (Ptr CChar)
a14'IO () -> IO CPICoupon -> IO CPICoupon
forall a b. IO a -> IO b -> IO b
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>>
  CPICoupon -> IO CPICoupon
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return (CPICoupon
res')

{-# LINE 708 "./QuantLib/CashFlow.chs" #-}


-- |CPI-linked coupon whose base fixing is determined by a base date.
cpiCouponFromBaseDate :: (Day) -- ^baseDate
 -> (Day) -- ^paymentDate
 -> (Double) -- ^nominal
 -> (Day) -- ^accrualStartDate
 -> (Day) -- ^accrualEndDate
 -> (GenZeroInflationIndex zidx) -- ^index
 -> ((Int,TimeUnit)) -- ^observationLag
 -> (CPIInterpolationType) -- ^observationInterpolation
 -> (DayCounter) -- ^dayCounter
 -> (Double) -- ^fixedRate
 -> (Maybe Day) -- ^referencePeriodStart
 -> (Maybe Day) -- ^referencePeriodEnd
 -> (Maybe Day) -- ^exCouponDate
 -> IO ((CPICoupon))
cpiCouponFromBaseDate a1 a2 a3 a4 a5 a6 a7 a8 a9 a10 a11 a12 a13 =
  withDay a1 $ \a1' -> 
  withDay a2 $ \a2' -> 
  let {a3' = realToFrac a3} in 
  withDay a4 $ \a4' -> 
  withDay a5 $ \a5' -> 
  withZeroInflationIndex a6 $ \a6' -> 
  let {(a7'1, a7'2) = fromEnumQuantity a7} in 
  let {a8' = fromEnumC a8} in 
  withDayCounter a9 $ \a9' -> 
  let {a10' = realToFrac a10} in 
  withMaybeDay a11 $ \a11' -> 
  withMaybeDay a12 $ \a12' -> 
  withMaybeDay a13 $ \a13' -> 
  preErrorCheck $ \a14' -> 
  cpiCouponFromBaseDate'_ a1' a2' a3' a4' a5' a6' a7'1  a7'2 a8' a9' a10' a11' a12' a13' a14' >>= \res ->
  peekCPICoupon res >>= \res' ->
  errorCheck  a14'>>
  return (res')

{-# LINE 724 "./QuantLib/CashFlow.chs" #-}


-- |CPI-linked coupon with both an explicit base CPI and base date.
cpiCouponWithBaseDate :: (Double) -- ^baseCPI
 -> (Day) -- ^baseDate
 -> (Day) -- ^paymentDate
 -> (Double) -- ^nominal
 -> (Day) -- ^accrualStartDate
 -> (Day) -- ^accrualEndDate
 -> (GenZeroInflationIndex zidx) -- ^index
 -> ((Int,TimeUnit)) -- ^observationLag
 -> (CPIInterpolationType) -- ^observationInterpolation
 -> (DayCounter) -- ^dayCounter
 -> (Double) -- ^fixedRate
 -> (Maybe Day) -- ^referencePeriodStart
 -> (Maybe Day) -- ^referencePeriodEnd
 -> (Maybe Day) -- ^exCouponDate
 -> IO ((CPICoupon))
cpiCouponWithBaseDate a1 a2 a3 a4 a5 a6 a7 a8 a9 a10 a11 a12 a13 a14 =
  let {a1' = realToFrac a1} in 
  withDay a2 $ \a2' -> 
  withDay a3 $ \a3' -> 
  let {a4' = realToFrac a4} in 
  withDay a5 $ \a5' -> 
  withDay a6 $ \a6' -> 
  withZeroInflationIndex a7 $ \a7' -> 
  let {(a8'1, a8'2) = fromEnumQuantity a8} in 
  let {a9' = fromEnumC a9} in 
  withDayCounter a10 $ \a10' -> 
  let {a11' = realToFrac a11} in 
  withMaybeDay a12 $ \a12' -> 
  withMaybeDay a13 $ \a13' -> 
  withMaybeDay a14 $ \a14' -> 
  preErrorCheck $ \a15' -> 
  cpiCouponWithBaseDate'_ a1' a2' a3' a4' a5' a6' a7' a8'1  a8'2 a9' a10' a11' a12' a13' a14' a15' >>= \res ->
  peekCPICoupon res >>= \res' ->
  errorCheck  a15'>>
  return (res')

{-# LINE 741 "./QuantLib/CashFlow.chs" #-}


-- |CPI coupon pricer using an optional nominal yield curve.
cpiCouponPricer :: (Maybe YieldTermStructure) -- ^nominalTermStructure
 -> IO ((CPICouponPricer))
cpiCouponPricer a1 =
  withMaybeYieldTermStructure a1 $ \a1' -> 
  preErrorCheck $ \a2' -> 
  cpiCouponPricer'_ a1' a2' >>= \res ->
  peekCPICouponPricer res >>= \res' ->
  errorCheck  a2'>>
  return (res')

{-# LINE 745 "./QuantLib/CashFlow.chs" #-}


-- |CPI coupon pricer using a CPI volatility surface and optional nominal yield curve.
cpiCouponPricerWithVol :: (CPIVolatilitySurface) -- ^volatilitySurface
 -> (Maybe YieldTermStructure) -- ^nominalTermStructure
 -> IO ((CPICouponPricer))
cpiCouponPricerWithVol a1 a2 =
  withGenVolatilityTermStructure a1 $ \a1' -> 
  withMaybeYieldTermStructure a2 $ \a2' -> 
  preErrorCheck $ \a3' -> 
  cpiCouponPricerWithVol'_ a1' a2' a3' >>= \res ->
  peekCPICouponPricer res >>= \res' ->
  errorCheck  a3'>>
  return (res')

{-# LINE 750 "./QuantLib/CashFlow.chs" #-}


-- |Attach a CPI coupon pricer to a CPI coupon.
setCpiCouponPricer :: (CPICoupon) -- ^coupon
 -> (CPICouponPricer) -- ^pricer
 -> IO ()
setCpiCouponPricer a1 a2 =
  withCPICoupon a1 $ \a1' -> 
  withCPICouponPricer a2 $ \a2' -> 
  preErrorCheck $ \a3' -> 
  setCpiCouponPricer'_ a1' a2' a3' >>
  errorCheck  a3'>>
  return ()

{-# LINE 755 "./QuantLib/CashFlow.chs" #-}


-- |The ratio of the (possibly interpolated) index value on /d/ to the coupon's base index
-- value, i.e. the inflation-adjustment factor applied to the coupon's fixed rate.
indexRatio :: (CPICoupon) -- ^coupon
 -> (Day) -- ^d
 -> IO ((Double))
indexRatio a1 a2 =
  withCPICoupon a1 $ \a1' -> 
  withDay a2 $ \a2' -> 
  preErrorCheck $ \a3' -> 
  indexRatio'_ a1' a2' a3' >>= \res ->
  let {res' = realToFrac res} in
  errorCheck  a3'>>
  return (res')

{-# LINE 761 "./QuantLib/CashFlow.chs" #-}


-- |A single redemption payment.
redemption :: (Double) -- ^amount
 -> (Day) -- ^date
 -> IO ((CashFlow))
redemption a1 a2 =
  let {a1' = realToFrac a1} in 
  withDay a2 $ \a2' -> 
  preErrorCheck $ \a3' -> 
  redemption'_ a1' a2' a3' >>= \res ->
  peekCashFlow res >>= \res' ->
  errorCheck  a3'>>
  return (res')

{-# LINE 766 "./QuantLib/CashFlow.chs" #-}


-- |An amortizing principal payment.
amortizingPayment :: (Double) -- ^amount
 -> (Day) -- ^date
 -> IO ((CashFlow))
amortizingPayment a1 a2 =
  let {a1' = realToFrac a1} in 
  withDay a2 $ \a2' -> 
  preErrorCheck $ \a3' -> 
  amortizingPayment'_ a1' a2' a3' >>= \res ->
  peekCashFlow res >>= \res' ->
  errorCheck  a3'>>
  return (res')

{-# LINE 771 "./QuantLib/CashFlow.chs" #-}


-- |Build a 'Leg' from a homogeneous cash-flow subtype, or from explicitly erased 'CashFlow'
-- values when the elements are heterogeneous. The leg takes shared ownership of each flow, so
-- it remains valid when the individual values are no longer retained.
cashFlowLeg :: ([GenCashFlow cf]) -- ^cashFlows
 -> IO ((Leg))
cashFlowLeg a1 =
  withCashFlowArray a1 $ \(a1'1, a1'2) -> 
  preErrorCheck $ \a2' -> 
  cashFlowLeg'_ a1'1  a1'2 a2' >>= \res ->
  peekLeg res >>= \res' ->
  errorCheck  a2'>>
  return (res')

{-# LINE 777 "./QuantLib/CashFlow.chs" #-}


-- |Returns the start (i.e. first accrual) date for the given Leg
startDate :: (GenLeg l) -> IO ((Day))
startDate a1 =
  withLeg a1 $ \a1' -> 
  preErrorCheck $ \a2' -> 
  startDate'_ a1' a2' >>= \res ->
  let {res' = toDay res} in
  errorCheck  a2'>>
  return (res')

{-# LINE 780 "./QuantLib/CashFlow.chs" #-}


-- |return cashflows that will occur after /settlementDate/
nextCashFlows :: (GenLeg l) -> (Bool) -- ^includeSettlementDateFlows
 -> (Maybe Day) -- ^settlementDate
 -> IO ((Leg))
nextCashFlows a1 a2 a3 =
  withLeg a1 $ \a1' -> 
  let {a2' = C2HSImp.fromBool a2} in 
  withMaybeDay a3 $ \a3' -> 
  preErrorCheck $ \a4' -> 
  nextCashFlows'_ a1' a2' a3' a4' >>= \res ->
  peekLeg res >>= \res' ->
  errorCheck  a4'>>
  return (res')

{-# LINE 785 "./QuantLib/CashFlow.chs" #-}


-- |return cashflows that occurred before /settlementDate/
previousCashFlows :: (GenLeg l) -> (Bool) -- ^includeSettlementDateFlows
 -> (Maybe Day) -- ^settlementDate
 -> IO ((Leg))
previousCashFlows a1 a2 a3 =
  withLeg a1 $ \a1' -> 
  let {a2' = C2HSImp.fromBool a2} in 
  withMaybeDay a3 $ \a3' -> 
  preErrorCheck $ \a4' -> 
  previousCashFlows'_ a1' a2' a3' a4' >>= \res ->
  peekLeg res >>= \res' ->
  errorCheck  a4'>>
  return (res')

{-# LINE 790 "./QuantLib/CashFlow.chs" #-}


-- |Raw binding for 'cashFlows': dates, amounts, and whether each has occurred as of /settlementDate/.
qlLegCashFlows :: (GenLeg l) -> (Maybe Bool) -- ^includeSettlementDateFlows
 -> (Maybe Day) -- ^settlementDate
 -> IO (([Double]), ([Day]), ([Bool]))
qlLegCashFlows a1 a2 a3 =
  withLeg a1 $ \a1' -> 
  let {a2' = fromMaybeBool a2} in 
  withMaybeDay a3 $ \a3' -> 
  preArray $ \(a4'1, a4'2) -> 
  preArray $ \(a5'1, a5'2) -> 
  preArray $ \(a6'1, a6'2) -> 
  preErrorCheck $ \a7' -> 
  qlLegCashFlows'_ a1' a2' a3' a4'1  a4'2 a5'1  a5'2 a6'1  a6'2 a7' >>
  peekDoubleArray  a4'1  a4'2>>= \a4'' -> 
  peekDayArray  a5'1  a5'2>>= \a5'' -> 
  peekBoolArray  a6'1  a6'2>>= \a6'' -> 
  errorCheck  a7'>>
  return (a4'', a5'', a6'')

duration :: forall l.
GenLeg l
-> InterestRate
-> DurationType
-> Bool
-> Maybe Day
-> Maybe Day
-> IO Double
{-# LINE 795 "./QuantLib/CashFlow.chs" #-}


-- |return cash flows together with an indicator whether they occurred as of /settlementDate/
cashFlows :: GenLeg l
  -> Maybe Bool -- ^includeSettlementDateFlows
  -> Maybe Day -- ^settlementDate
  -> IO [(Day, Double, Bool)] -- ^date, amount, hasOccurred
cashFlows l i d = do{(as, ds, hs) <- qlLegCashFlows l i d; return $ zip3 ds as hs}

-- |Cash-flow duration.
-- 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.
duration :: (GenLeg l) -> (InterestRate) -- ^yield
 -> (DurationType) -> (Bool) -- ^includeSettlementDateFlows
 -> (Maybe Day) -- ^settlementDate
 -> (Maybe Day) -- ^npvDate
 -> IO ((Double))
duration :: forall l.
GenLeg l
-> InterestRate
-> DurationType
-> Bool
-> Maybe Day
-> Maybe Day
-> IO Double
duration GenLeg l
a1 InterestRate
a2 DurationType
a3 Bool
a4 Maybe Day
a5 Maybe Day
a6 =
  GenLeg l -> (Ptr CLeg' -> IO Double) -> IO Double
forall l b. GenLeg l -> (Ptr CLeg' -> IO b) -> IO b
withLeg GenLeg l
a1 ((Ptr CLeg' -> IO Double) -> IO Double)
-> (Ptr CLeg' -> IO Double) -> IO Double
forall a b. (a -> b) -> a -> b
$ \Ptr CLeg'
a1' -> 
  InterestRate -> (Ptr CInterestRate -> IO Double) -> IO Double
forall b. InterestRate -> (Ptr CInterestRate -> IO b) -> IO b
withInterestRate InterestRate
a2 ((Ptr CInterestRate -> IO Double) -> IO Double)
-> (Ptr CInterestRate -> IO Double) -> IO Double
forall a b. (a -> b) -> a -> b
$ \Ptr CInterestRate
a2' -> 
  let {a3' :: CInt
a3' = (Int -> CInt
forall a b. (Integral a, Num b) => a -> b
fromIntegral (Int -> CInt) -> (DurationType -> Int) -> DurationType -> CInt
forall b c a. (b -> c) -> (a -> b) -> a -> c
. DurationType -> Int
forall a. Enum a => a -> Int
fromEnum) DurationType
a3} in 
  let {a4' :: CInt
a4' = Bool -> CInt
forall a. Num a => Bool -> a
C2HSImp.fromBool Bool
a4} in 
  Maybe Day -> (CInt -> IO Double) -> IO Double
forall a. Maybe Day -> (CInt -> IO a) -> IO a
withMaybeDay Maybe Day
a5 ((CInt -> IO Double) -> IO Double)
-> (CInt -> IO Double) -> IO Double
forall a b. (a -> b) -> a -> b
$ \CInt
a5' -> 
  Maybe Day -> (CInt -> IO Double) -> IO Double
forall a. Maybe Day -> (CInt -> IO a) -> IO a
withMaybeDay Maybe Day
a6 ((CInt -> IO Double) -> IO Double)
-> (CInt -> IO Double) -> IO Double
forall a b. (a -> b) -> a -> b
$ \CInt
a6' -> 
  (Ptr (Ptr CChar) -> IO Double) -> IO Double
forall a b. (Ptr (Ptr a) -> IO b) -> IO b
preErrorCheck ((Ptr (Ptr CChar) -> IO Double) -> IO Double)
-> (Ptr (Ptr CChar) -> IO Double) -> IO Double
forall a b. (a -> b) -> a -> b
$ \Ptr (Ptr CChar)
a7' -> 
  Ptr CLeg'
-> Ptr CInterestRate
-> CInt
-> CInt
-> CInt
-> CInt
-> Ptr (Ptr CChar)
-> IO CDouble
duration'_ Ptr CLeg'
a1' Ptr CInterestRate
a2' CInt
a3' CInt
a4' CInt
a5' CInt
a6' Ptr (Ptr CChar)
a7' IO CDouble -> (CDouble -> IO Double) -> IO Double
forall a b. IO a -> (a -> IO b) -> IO b
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= \CDouble
res ->
  let {res' :: Double
res' = CDouble -> Double
forall a b. (Real a, Fractional b) => a -> b
realToFrac CDouble
res} in
  Ptr (Ptr CChar) -> IO ()
errorCheck  Ptr (Ptr CChar)
a7'IO () -> IO Double -> IO Double
forall a b. IO a -> IO b -> IO b
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>>
  Double -> IO Double
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return (Double
res')

{-# LINE 810 "./QuantLib/CashFlow.chs" #-}


-- |Number of days in the accrual period of the coupon paying on /settlementDate/.
accrualDays :: (GenLeg l) -> (Bool) -- ^includeSettlementDateFlows
 -> (Maybe Day) -- ^settlementDate
 -> IO ((Int))
accrualDays a1 a2 a3 =
  withLeg a1 $ \a1' -> 
  let {a2' = C2HSImp.fromBool a2} in 
  withMaybeDay a3 $ \a3' -> 
  preErrorCheck $ \a4' -> 
  accrualDays'_ a1' a2' a3' a4' >>= \res ->
  let {res' = fromIntegral res} in
  errorCheck  a4'>>
  return (res')

{-# LINE 815 "./QuantLib/CashFlow.chs" #-}


-- |End of the accrual period of the coupon paying on /settlementDate/.
accrualEndDate :: (GenLeg l) -> (Bool) -- ^includeSettlementDateFlows
 -> (Maybe Day) -- ^settlementDate
 -> IO ((Maybe Day))
accrualEndDate a1 a2 a3 =
  withLeg a1 $ \a1' -> 
  let {a2' = C2HSImp.fromBool a2} in 
  withMaybeDay a3 $ \a3' -> 
  preErrorCheck $ \a4' -> 
  accrualEndDate'_ a1' a2' a3' a4' >>= \res ->
  let {res' = toMaybeDay res} in
  errorCheck  a4'>>
  return (res')

{-# LINE 820 "./QuantLib/CashFlow.chs" #-}


-- |Length, in years, of the accrual period of the coupon paying on /settlementDate/.
accrualPeriod :: (GenLeg l) -> (Bool) -- ^includeSettlementDateFlows
 -> (Maybe Day) -- ^settlementDate
 -> IO ((Double))
accrualPeriod a1 a2 a3 =
  withLeg a1 $ \a1' -> 
  let {a2' = C2HSImp.fromBool a2} in 
  withMaybeDay a3 $ \a3' -> 
  preErrorCheck $ \a4' -> 
  accrualPeriod'_ a1' a2' a3' a4' >>= \res ->
  let {res' = realToFrac res} in
  errorCheck  a4'>>
  return (res')

{-# LINE 825 "./QuantLib/CashFlow.chs" #-}


-- |Start of the accrual period of the coupon paying on /settlementDate/.
accrualStartDate :: (GenLeg l) -> (Bool) -- ^includeSettlementDateFlows
 -> (Maybe Day) -- ^settlementDate
 -> IO ((Maybe Day))
accrualStartDate a1 a2 a3 =
  withLeg a1 $ \a1' -> 
  let {a2' = C2HSImp.fromBool a2} in 
  withMaybeDay a3 $ \a3' -> 
  preErrorCheck $ \a4' -> 
  accrualStartDate'_ a1' a2' a3' a4' >>= \res ->
  let {res' = toMaybeDay res} in
  errorCheck  a4'>>
  return (res')

{-# LINE 830 "./QuantLib/CashFlow.chs" #-}


-- |Accrued amount of the coupon paying on /settlementDate/.
accruedAmount :: (GenLeg l) -> (Bool) -- ^includeSettlementDateFlows
 -> (Maybe Day) -- ^settlementDate
 -> IO ((Double))
accruedAmount a1 a2 a3 =
  withLeg a1 $ \a1' -> 
  let {a2' = C2HSImp.fromBool a2} in 
  withMaybeDay a3 $ \a3' -> 
  preErrorCheck $ \a4' -> 
  accruedAmount'_ a1' a2' a3' a4' >>= \res ->
  let {res' = realToFrac res} in
  errorCheck  a4'>>
  return (res')

{-# LINE 835 "./QuantLib/CashFlow.chs" #-}


-- |Number of days accrued so far on the coupon paying on /settlementDate/.
accruedDays :: (GenLeg l) -> (Bool) -- ^includeSettlementDateFlows
 -> (Maybe Day) -- ^settlementDate
 -> IO ((Int))
accruedDays a1 a2 a3 =
  withLeg a1 $ \a1' -> 
  let {a2' = C2HSImp.fromBool a2} in 
  withMaybeDay a3 $ \a3' -> 
  preErrorCheck $ \a4' -> 
  accruedDays'_ a1' a2' a3' a4' >>= \res ->
  let {res' = fromIntegral res} in
  errorCheck  a4'>>
  return (res')

{-# LINE 840 "./QuantLib/CashFlow.chs" #-}


-- |Fraction of the accrual period elapsed, as of /settlementDate/, for the coupon paying then.
accruedPeriod :: (GenLeg l) -> (Bool) -- ^includeSettlementDateFlows
 -> (Maybe Day) -- ^settlementDate
 -> IO ((Double))
accruedPeriod a1 a2 a3 =
  withLeg a1 $ \a1' -> 
  let {a2' = C2HSImp.fromBool a2} in 
  withMaybeDay a3 $ \a3' -> 
  preErrorCheck $ \a4' -> 
  accruedPeriod'_ a1' a2' a3' a4' >>= \res ->
  let {res' = realToFrac res} in
  errorCheck  a4'>>
  return (res')

{-# LINE 845 "./QuantLib/CashFlow.chs" #-}


-- |Basis-point value.
-- Obtained by setting dy = 0.0001 in the 2nd-order Taylor series expansion.
basisPointValue :: (GenLeg l) -> (InterestRate) -> (Bool) -- ^includeSettlementDateFlows
 -> (Maybe Day) -- ^settlementDate
 -> (Maybe Day) -- ^npvDate
 -> IO ((Double))
basisPointValue a1 a2 a3 a4 a5 =
  withLeg a1 $ \a1' -> 
  withInterestRate a2 $ \a2' -> 
  let {a3' = C2HSImp.fromBool a3} in 
  withMaybeDay a4 $ \a4' -> 
  withMaybeDay a5 $ \a5' -> 
  preErrorCheck $ \a6' -> 
  basisPointValue'_ a1' a2' a3' a4' a5' a6' >>= \res ->
  let {res' = realToFrac res} in
  errorCheck  a6'>>
  return (res')

{-# LINE 853 "./QuantLib/CashFlow.chs" #-}


-- |Where discount factors come from.
data Discounting y
  = DiscountingCurve !(GenYieldTermStructure y)
  | DiscountingZSpread !(GenYieldTermStructure y) !Double !Compounding !Frequency -- ^curve, zSpread, compounding, frequency
  | DiscountingYield !InterestRate

-- |'Discounting' restricted to the cases 'bps' supports: upstream has no Z-spreaded bps.
data BpsDiscounting y
  = BpsDiscountingCurve !(GenYieldTermStructure y)
  | BpsDiscountingYield !InterestRate

-- |Basis-point sensitivity of the cash flows.
-- 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.
bpsFromYieldRaw :: (GenLeg l) -> (InterestRate) -> (Bool) -- ^includeSettlementDateFlows
 -> (Maybe Day) -- ^settlementDate
 -> (Maybe Day) -- ^npvDate
 -> IO ((Double))
bpsFromYieldRaw :: forall l.
GenLeg l
-> InterestRate -> Bool -> Maybe Day -> Maybe Day -> IO Double
bpsFromYieldRaw GenLeg l
a1 InterestRate
a2 Bool
a3 Maybe Day
a4 Maybe Day
a5 =
  GenLeg l -> (Ptr CLeg' -> IO Double) -> IO Double
forall l b. GenLeg l -> (Ptr CLeg' -> IO b) -> IO b
withLeg GenLeg l
a1 ((Ptr CLeg' -> IO Double) -> IO Double)
-> (Ptr CLeg' -> IO Double) -> IO Double
forall a b. (a -> b) -> a -> b
$ \Ptr CLeg'
a1' -> 
  InterestRate -> (Ptr CInterestRate -> IO Double) -> IO Double
forall b. InterestRate -> (Ptr CInterestRate -> IO b) -> IO b
withInterestRate InterestRate
a2 ((Ptr CInterestRate -> IO Double) -> IO Double)
-> (Ptr CInterestRate -> IO Double) -> IO Double
forall a b. (a -> b) -> a -> b
$ \Ptr CInterestRate
a2' -> 
  let {a3' :: CInt
a3' = Bool -> CInt
forall a. Num a => Bool -> a
C2HSImp.fromBool Bool
a3} in 
  Maybe Day -> (CInt -> IO Double) -> IO Double
forall a. Maybe Day -> (CInt -> IO a) -> IO a
withMaybeDay Maybe Day
a4 ((CInt -> IO Double) -> IO Double)
-> (CInt -> IO Double) -> IO Double
forall a b. (a -> b) -> a -> b
$ \CInt
a4' -> 
  Maybe Day -> (CInt -> IO Double) -> IO Double
forall a. Maybe Day -> (CInt -> IO a) -> IO a
withMaybeDay Maybe Day
a5 ((CInt -> IO Double) -> IO Double)
-> (CInt -> IO Double) -> IO Double
forall a b. (a -> b) -> a -> b
$ \CInt
a5' -> 
  (Ptr (Ptr CChar) -> IO Double) -> IO Double
forall a b. (Ptr (Ptr a) -> IO b) -> IO b
preErrorCheck ((Ptr (Ptr CChar) -> IO Double) -> IO Double)
-> (Ptr (Ptr CChar) -> IO Double) -> IO Double
forall a b. (a -> b) -> a -> b
$ \Ptr (Ptr CChar)
a6' -> 
  Ptr CLeg'
-> Ptr CInterestRate
-> CInt
-> CInt
-> CInt
-> Ptr (Ptr CChar)
-> IO CDouble
bpsFromYieldRaw'_ Ptr CLeg'
a1' Ptr CInterestRate
a2' CInt
a3' CInt
a4' CInt
a5' Ptr (Ptr CChar)
a6' IO CDouble -> (CDouble -> IO Double) -> IO Double
forall a b. IO a -> (a -> IO b) -> IO b
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= \CDouble
res ->
  let {res' :: Double
res' = CDouble -> Double
forall a b. (Real a, Fractional b) => a -> b
realToFrac CDouble
res} in
  Ptr (Ptr CChar) -> IO ()
errorCheck  Ptr (Ptr CChar)
a6'IO () -> IO Double -> IO Double
forall a b. IO a -> IO b -> IO b
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>>
  Double -> IO Double
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return (Double
res')

{-# LINE 872 "./QuantLib/CashFlow.chs" #-}


-- |Cash-flow convexity.
-- 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 $.
convexity :: (GenLeg l) -> (InterestRate) -> (Bool) -- ^includeSettlementDateFlows
 -> (Maybe Day) -- ^settlementDate
 -> (Maybe Day) -- ^npvDate
 -> IO ((Double))
convexity a1 a2 a3 a4 a5 =
  withLeg a1 $ \a1' -> 
  withInterestRate a2 $ \a2' -> 
  let {a3' = C2HSImp.fromBool a3} in 
  withMaybeDay a4 $ \a4' -> 
  withMaybeDay a5 $ \a5' -> 
  preErrorCheck $ \a6' -> 
  convexity'_ a1' a2' a3' a4' a5' a6' >>= \res ->
  let {res' = realToFrac res} in
  errorCheck  a6'>>
  return (res')

{-# LINE 880 "./QuantLib/CashFlow.chs" #-}


-- |Whether every cash flow in the leg has occurred as of /settlementDate/.
isExpired :: (GenLeg l) -> (Bool) -- ^includeSettlementDateFlows
 -> (Maybe Day) -- ^settlementDate
 -> IO ((Bool))
isExpired a1 a2 a3 =
  withLeg a1 $ \a1' -> 
  let {a2' = C2HSImp.fromBool a2} in 
  withMaybeDay a3 $ \a3' -> 
  preErrorCheck $ \a4' -> 
  isExpired'_ a1' a2' a3' a4' >>= \res ->
  let {res' = C2HSImp.toBool res} in
  errorCheck  a4'>>
  return (res')

{-# LINE 885 "./QuantLib/CashFlow.chs" #-}


-- |Date of the leg's last cash flow.
maturityDate :: (GenLeg l) -> IO ((Day))
maturityDate a1 =
  withLeg a1 $ \a1' -> 
  preErrorCheck $ \a2' -> 
  maturityDate'_ a1' a2' >>= \res ->
  let {res' = toDay res} in
  errorCheck  a2'>>
  return (res')

{-# LINE 888 "./QuantLib/CashFlow.chs" #-}


-- |Amount of the first cash flow paying after /settlementDate/.
nextCashFlowAmount :: (GenLeg l) -> (Bool) -- ^includeSettlementDateFlows
 -> (Maybe Day) -- ^settlementDate
 -> IO ((Double))
nextCashFlowAmount a1 a2 a3 =
  withLeg a1 $ \a1' -> 
  let {a2' = C2HSImp.fromBool a2} in 
  withMaybeDay a3 $ \a3' -> 
  preErrorCheck $ \a4' -> 
  nextCashFlowAmount'_ a1' a2' a3' a4' >>= \res ->
  let {res' = realToFrac res} in
  errorCheck  a4'>>
  return (res')

{-# LINE 893 "./QuantLib/CashFlow.chs" #-}


-- |Date of the first cash flow paying after /settlementDate/.
nextCashFlowDate :: (GenLeg l) -> (Bool) -- ^includeSettlementDateFlows
 -> (Maybe Day) -- ^settlementDate
 -> IO (((Maybe Day)))
nextCashFlowDate a1 a2 a3 =
  withLeg a1 $ \a1' -> 
  let {a2' = C2HSImp.fromBool a2} in 
  withMaybeDay a3 $ \a3' -> 
  preErrorCheck $ \a4' -> 
  nextCashFlowDate'_ a1' a2' a3' a4' >>= \res ->
  let {res' = toMaybeDay res} in
  errorCheck  a4'>>
  return (res')

{-# LINE 898 "./QuantLib/CashFlow.chs" #-}


-- |Coupon rate of the next cash flow paying after /settlementDate/.
nextCouponRate :: (GenLeg l) -> (Bool) -- ^includeSettlementDateFlows
 -> (Maybe Day) -- ^settlementDate
 -> IO ((Double))
nextCouponRate a1 a2 a3 =
  withLeg a1 $ \a1' -> 
  let {a2' = C2HSImp.fromBool a2} in 
  withMaybeDay a3 $ \a3' -> 
  preErrorCheck $ \a4' -> 
  nextCouponRate'_ a1' a2' a3' a4' >>= \res ->
  let {res' = realToFrac res} in
  errorCheck  a4'>>
  return (res')

{-# LINE 903 "./QuantLib/CashFlow.chs" #-}


-- |Nominal of the coupon paying on /settlementDate/.
nominal :: (GenLeg l) -> (Bool) -- ^includeSettlementDateFlows
 -> (Maybe Day) -- ^settlementDate
 -> IO ((Double))
nominal a1 a2 a3 =
  withLeg a1 $ \a1' -> 
  let {a2' = C2HSImp.fromBool a2} in 
  withMaybeDay a3 $ \a3' -> 
  preErrorCheck $ \a4' -> 
  nominal'_ a1' a2' a3' a4' >>= \res ->
  let {res' = realToFrac res} in
  errorCheck  a4'>>
  return (res')

{-# LINE 908 "./QuantLib/CashFlow.chs" #-}


-- |NPV of the cash flows.
-- 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.
npvFromYieldRaw :: (GenLeg l) -> (InterestRate) -> (Bool) -- ^includeSettlementDateFlows
 -> (Maybe Day) -- ^settlementDate
 -> (Maybe Day) -- ^npvDate
 -> IO ((Double))
npvFromYieldRaw a1 a2 a3 a4 a5 =
  withLeg a1 $ \a1' -> 
  withInterestRate a2 $ \a2' -> 
  let {a3' = C2HSImp.fromBool a3} in 
  withMaybeDay a4 $ \a4' -> 
  withMaybeDay a5 $ \a5' -> 
  preErrorCheck $ \a6' -> 
  npvFromYieldRaw'_ a1' a2' a3' a4' a5' a6' >>= \res ->
  let {res' = realToFrac res} in
  errorCheck  a6'>>
  return (res')

{-# LINE 915 "./QuantLib/CashFlow.chs" #-}


-- |At-the-money rate of the cash flows.
-- 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.
atmRate :: (GenLeg l) -> (GenYieldTermStructure y) -> (Bool) -- ^includeSettlementDateFlows
 -> (Maybe Day) -- ^settlementDate
 -> (Maybe Day) -- ^npvDate
 -> (Double) -- ^npv
 -> IO ((Double))
atmRate a1 a2 a3 a4 a5 a6 =
  withLeg a1 $ \a1' -> 
  withYieldTermStructure a2 $ \a2' -> 
  let {a3' = C2HSImp.fromBool a3} in 
  withMaybeDay a4 $ \a4' -> 
  withMaybeDay a5 $ \a5' -> 
  let {a6' = realToFrac a6} in 
  preErrorCheck $ \a7' -> 
  atmRate'_ a1' a2' a3' a4' a5' a6' a7' >>= \res ->
  let {res' = realToFrac res} in
  errorCheck  a7'>>
  return (res')

{-# LINE 923 "./QuantLib/CashFlow.chs" #-}


-- |Basis-point sensitivity of the cash flows.
-- 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.
bpsFromCurveRaw :: (GenLeg l) -> (GenYieldTermStructure y) -> (Bool) -- ^includeSettlementDateFlows
 -> (Maybe Day) -- ^settlementDate
 -> (Maybe Day) -- ^npvDate
 -> IO ((Double))
bpsFromCurveRaw a1 a2 a3 a4 a5 =
  withLeg a1 $ \a1' -> 
  withYieldTermStructure a2 $ \a2' -> 
  let {a3' = C2HSImp.fromBool a3} in 
  withMaybeDay a4 $ \a4' -> 
  withMaybeDay a5 $ \a5' -> 
  preErrorCheck $ \a6' -> 
  bpsFromCurveRaw'_ a1' a2' a3' a4' a5' a6' >>= \res ->
  let {res' = realToFrac res} in
  errorCheck  a6'>>
  return (res')

{-# LINE 930 "./QuantLib/CashFlow.chs" #-}


-- |NPV of the cash flows.
-- 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.
npvWithZSpreadRaw :: (GenLeg l) -> (GenYieldTermStructure y) -> (Double) -- ^zSpread
 -> (Compounding) -> (Frequency) -> (Bool) -- ^includeSettlementDateFlows
 -> (Maybe Day) -- ^settlementDate
 -> (Maybe Day) -- ^npvDate
 -> IO ((Double))
npvWithZSpreadRaw a1 a2 a3 a4 a5 a6 a7 a8 =
  withLeg a1 $ \a1' -> 
  withYieldTermStructure a2 $ \a2' -> 
  let {a3' = realToFrac a3} in 
  let {a4' = (fromIntegral . fromEnum) a4} in 
  let {a5' = (fromIntegral . fromEnum) a5} in 
  let {a6' = C2HSImp.fromBool a6} in 
  withMaybeDay a7 $ \a7' -> 
  withMaybeDay a8 $ \a8' -> 
  preErrorCheck $ \a9' -> 
  npvWithZSpreadRaw'_ a1' a2' a3' a4' a5' a6' a7' a8' a9' >>= \res ->
  let {res' = realToFrac res} in
  errorCheck  a9'>>
  return (res')

{-# LINE 938 "./QuantLib/CashFlow.chs" #-}


-- |NPV of the cash flows.
-- The NPV is the sum of the cash flows, each discounted according to the given term structure.
npvFromCurveRaw :: (GenLeg l) -> (GenYieldTermStructure y) -> (Bool) -- ^includeSettlementDateFlows
 -> (Maybe Day) -- ^settlementDate
 -> (Maybe Day) -- ^npvDate
 -> IO ((Double))
npvFromCurveRaw a1 a2 a3 a4 a5 =
  withLeg a1 $ \a1' -> 
  withYieldTermStructure a2 $ \a2' -> 
  let {a3' = C2HSImp.fromBool a3} in 
  withMaybeDay a4 $ \a4' -> 
  withMaybeDay a5 $ \a5' -> 
  preErrorCheck $ \a6' -> 
  npvFromCurveRaw'_ a1' a2' a3' a4' a5' a6' >>= \res ->
  let {res' = realToFrac res} in
  errorCheck  a6'>>
  return (res')

{-# LINE 945 "./QuantLib/CashFlow.chs" #-}


-- |NPV of the cash flows under the given discounting.
npv :: GenLeg l -> Discounting y -> Bool -> Maybe Day -> Maybe Day -> IO Double
npv cashflows discounting = case discounting of
  DiscountingCurve curve -> npvFromCurveRaw cashflows curve
  DiscountingZSpread curve z comp freq -> npvWithZSpreadRaw cashflows curve z comp freq
  DiscountingYield y -> npvFromYieldRaw cashflows y

-- |Basis-point sensitivity of the cash flows under the given discounting.
bps :: GenLeg l -> BpsDiscounting y -> Bool -> Maybe Day -> Maybe Day -> IO Double
bps cashflows discounting = case discounting of
  BpsDiscountingCurve curve -> bpsFromCurveRaw cashflows curve
  BpsDiscountingYield y -> bpsFromYieldRaw cashflows y

-- |NPV and BPS of the cash flows.
-- The NPV and BPS of the cash flows calculated together for performance reason
npvBps :: (GenLeg l) -> (GenYieldTermStructure y) -> (Bool) -- ^includeSettlementDateFlows
 -> (Day) -- ^settlementDate
 -> (Day) -- ^npvDate
 -> IO ((Double), (Double))
npvBps :: forall l y.
GenLeg l
-> GenYieldTermStructure y
-> Bool
-> Day
-> Day
-> IO (Double, Double)
npvBps GenLeg l
a1 GenYieldTermStructure y
a2 Bool
a3 Day
a4 Day
a5 =
  GenLeg l
-> (Ptr CLeg' -> IO (Double, Double)) -> IO (Double, Double)
forall l b. GenLeg l -> (Ptr CLeg' -> IO b) -> IO b
withLeg GenLeg l
a1 ((Ptr CLeg' -> IO (Double, Double)) -> IO (Double, Double))
-> (Ptr CLeg' -> IO (Double, Double)) -> IO (Double, Double)
forall a b. (a -> b) -> a -> b
$ \Ptr CLeg'
a1' -> 
  GenYieldTermStructure y
-> (Ptr CYieldTermStructure' -> IO (Double, Double))
-> IO (Double, Double)
forall y b.
GenYieldTermStructure y
-> (Ptr CYieldTermStructure' -> IO b) -> IO b
withYieldTermStructure GenYieldTermStructure y
a2 ((Ptr CYieldTermStructure' -> IO (Double, Double))
 -> IO (Double, Double))
-> (Ptr CYieldTermStructure' -> IO (Double, Double))
-> IO (Double, Double)
forall a b. (a -> b) -> a -> b
$ \Ptr CYieldTermStructure'
a2' -> 
  let {a3' :: CInt
a3' = Bool -> CInt
forall a. Num a => Bool -> a
C2HSImp.fromBool Bool
a3} in 
  Day -> (CInt -> IO (Double, Double)) -> IO (Double, Double)
forall a. Day -> (CInt -> IO a) -> IO a
withDay Day
a4 ((CInt -> IO (Double, Double)) -> IO (Double, Double))
-> (CInt -> IO (Double, Double)) -> IO (Double, Double)
forall a b. (a -> b) -> a -> b
$ \CInt
a4' -> 
  Day -> (CInt -> IO (Double, Double)) -> IO (Double, Double)
forall a. Day -> (CInt -> IO a) -> IO a
withDay Day
a5 ((CInt -> IO (Double, Double)) -> IO (Double, Double))
-> (CInt -> IO (Double, Double)) -> IO (Double, Double)
forall a b. (a -> b) -> a -> b
$ \CInt
a5' -> 
  (Ptr CDouble -> IO (Double, Double)) -> IO (Double, Double)
forall a b. Storable a => (Ptr a -> IO b) -> IO b
prePtr ((Ptr CDouble -> IO (Double, Double)) -> IO (Double, Double))
-> (Ptr CDouble -> IO (Double, Double)) -> IO (Double, Double)
forall a b. (a -> b) -> a -> b
$ \Ptr CDouble
a6' -> 
  (Ptr CDouble -> IO (Double, Double)) -> IO (Double, Double)
forall a b. Storable a => (Ptr a -> IO b) -> IO b
prePtr ((Ptr CDouble -> IO (Double, Double)) -> IO (Double, Double))
-> (Ptr CDouble -> IO (Double, Double)) -> IO (Double, Double)
forall a b. (a -> b) -> a -> b
$ \Ptr CDouble
a7' -> 
  (Ptr (Ptr CChar) -> IO (Double, Double)) -> IO (Double, Double)
forall a b. (Ptr (Ptr a) -> IO b) -> IO b
preErrorCheck ((Ptr (Ptr CChar) -> IO (Double, Double)) -> IO (Double, Double))
-> (Ptr (Ptr CChar) -> IO (Double, Double)) -> IO (Double, Double)
forall a b. (a -> b) -> a -> b
$ \Ptr (Ptr CChar)
a8' -> 
  Ptr CLeg'
-> Ptr CYieldTermStructure'
-> CInt
-> CInt
-> CInt
-> Ptr CDouble
-> Ptr CDouble
-> Ptr (Ptr CChar)
-> IO ()
npvBps'_ Ptr CLeg'
a1' Ptr CYieldTermStructure'
a2' CInt
a3' CInt
a4' CInt
a5' Ptr CDouble
a6' Ptr CDouble
a7' Ptr (Ptr CChar)
a8' IO () -> IO Double -> IO Double
forall a b. IO a -> IO b -> IO b
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>>
  Ptr CDouble -> IO Double
peekDouble  Ptr CDouble
a6'IO Double -> (Double -> IO (Double, Double)) -> IO (Double, Double)
forall a b. IO a -> (a -> IO b) -> IO b
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= \Double
a6'' -> 
  Ptr CDouble -> IO Double
peekDouble  Ptr CDouble
a7'IO Double -> (Double -> IO (Double, Double)) -> IO (Double, Double)
forall a b. IO a -> (a -> IO b) -> IO b
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= \Double
a7'' -> 
  Ptr (Ptr CChar) -> IO ()
errorCheck  Ptr (Ptr CChar)
a8'IO () -> IO (Double, Double) -> IO (Double, Double)
forall a b. IO a -> IO b -> IO b
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>>
  (Double, Double) -> IO (Double, Double)
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return (Double
a6'', Double
a7'')

{-# LINE 965 "./QuantLib/CashFlow.chs" #-}


-- |implied Z-spread.
zSpread :: (GenLeg l) -> (Double) -- ^npv
 -> (GenYieldTermStructure y) -> (Compounding) -> (Frequency) -> (Bool) -- ^includeSettlementDateFlows
 -> (Maybe Day) -- ^settlementDate
 -> (Maybe Day) -- ^npvDate
 -> (Double) -- ^accuracy
 -> (Word) -- ^maxIterations
 -> (Double) -- ^guess
 -> IO ((Double))
zSpread a1 a2 a3 a4 a5 a6 a7 a8 a9 a10 a11 =
  withLeg a1 $ \a1' -> 
  let {a2' = realToFrac a2} in 
  withYieldTermStructure a3 $ \a3' -> 
  let {a4' = (fromIntegral . fromEnum) a4} in 
  let {a5' = (fromIntegral . fromEnum) a5} in 
  let {a6' = C2HSImp.fromBool a6} in 
  withMaybeDay a7 $ \a7' -> 
  withMaybeDay a8 $ \a8' -> 
  let {a9' = realToFrac a9} in 
  let {a10' = fromIntegral a10} in 
  let {a11' = realToFrac a11} in 
  preErrorCheck $ \a12' -> 
  zSpread'_ a1' a2' a3' a4' a5' a6' a7' a8' a9' a10' a11' a12' >>= \res ->
  let {res' = realToFrac res} in
  errorCheck  a12'>>
  return (res')

{-# LINE 975 "./QuantLib/CashFlow.chs" #-}


-- |Amount of the last cash flow that paid before or at /settlementDate/.
previousCashFlowAmount :: (GenLeg l) -> (Bool) -- ^includeSettlementDateFlows
 -> (Maybe Day) -- ^settlementDate
 -> IO ((Double))
previousCashFlowAmount a1 a2 a3 =
  withLeg a1 $ \a1' -> 
  let {a2' = C2HSImp.fromBool a2} in 
  withMaybeDay a3 $ \a3' -> 
  preErrorCheck $ \a4' -> 
  previousCashFlowAmount'_ a1' a2' a3' a4' >>= \res ->
  let {res' = realToFrac res} in
  errorCheck  a4'>>
  return (res')

{-# LINE 980 "./QuantLib/CashFlow.chs" #-}


-- |Date of the last cash flow that paid before or at /settlementDate/.
previousCashFlowDate :: (GenLeg l) -> (Bool) -- ^includeSettlementDateFlows
 -> (Maybe Day) -- ^settlementDate
 -> IO ((Maybe Day))
previousCashFlowDate a1 a2 a3 =
  withLeg a1 $ \a1' -> 
  let {a2' = C2HSImp.fromBool a2} in 
  withMaybeDay a3 $ \a3' -> 
  preErrorCheck $ \a4' -> 
  previousCashFlowDate'_ a1' a2' a3' a4' >>= \res ->
  let {res' = toMaybeDay res} in
  errorCheck  a4'>>
  return (res')

{-# LINE 985 "./QuantLib/CashFlow.chs" #-}


-- |Coupon rate of the last cash flow that paid before or at /settlementDate/.
previousCouponRate :: (GenLeg l) -> (Bool) -- ^includeSettlementDateFlows
 -> (Maybe Day) -- ^settlementDate
 -> IO ((Double))
previousCouponRate a1 a2 a3 =
  withLeg a1 $ \a1' -> 
  let {a2' = C2HSImp.fromBool a2} in 
  withMaybeDay a3 $ \a3' -> 
  preErrorCheck $ \a4' -> 
  previousCouponRate'_ a1' a2' a3' a4' >>= \res ->
  let {res' = realToFrac res} in
  errorCheck  a4'>>
  return (res')

{-# LINE 990 "./QuantLib/CashFlow.chs" #-}


-- |End of the reference period of the coupon paying on /settlementDate/.
referencePeriodEnd :: (GenLeg l) -> (Bool) -- ^includeSettlementDateFlows
 -> (Maybe Day) -- ^settlementDate
 -> IO ((Maybe Day))
referencePeriodEnd a1 a2 a3 =
  withLeg a1 $ \a1' -> 
  let {a2' = C2HSImp.fromBool a2} in 
  withMaybeDay a3 $ \a3' -> 
  preErrorCheck $ \a4' -> 
  referencePeriodEnd'_ a1' a2' a3' a4' >>= \res ->
  let {res' = toMaybeDay res} in
  errorCheck  a4'>>
  return (res')

{-# LINE 995 "./QuantLib/CashFlow.chs" #-}


-- |Start of the reference period of the coupon paying on /settlementDate/.
referencePeriodStart :: (GenLeg l) -> (Bool) -- ^includeSettlementDateFlows
 -> (Maybe Day) -- ^settlementDate
 -> IO ((Maybe Day))
referencePeriodStart a1 a2 a3 =
  withLeg a1 $ \a1' -> 
  let {a2' = C2HSImp.fromBool a2} in 
  withMaybeDay a3 $ \a3' -> 
  preErrorCheck $ \a4' -> 
  referencePeriodStart'_ a1' a2' a3' a4' >>= \res ->
  let {res' = toMaybeDay res} in
  errorCheck  a4'>>
  return (res')

{-# LINE 1000 "./QuantLib/CashFlow.chs" #-}


-- |Implied internal rate of return.
-- The function verifies the theoretical existance of an IRR and numerically establishes the IRR to the desired precision.
yield :: (GenLeg l) -> (Double) -- ^npv
 -> (DayCounter) -> (Compounding) -> (Frequency) -> (Bool) -- ^includeSettlementDateFlows
 -> (Maybe Day) -- ^settlementDate
 -> (Maybe Day) -- ^npvDate
 -> (Double) -- ^accuracy
 -> (Word) -- ^maxIterations
 -> (Double) -- ^guess
 -> IO ((Double))
yield :: forall l.
GenLeg l
-> Double
-> DayCounter
-> Compounding
-> Frequency
-> Bool
-> Maybe Day
-> Maybe Day
-> Double
-> Word
-> Double
-> IO Double
yield GenLeg l
a1 Double
a2 DayCounter
a3 Compounding
a4 Frequency
a5 Bool
a6 Maybe Day
a7 Maybe Day
a8 Double
a9 Word
a10 Double
a11 =
  GenLeg l -> (Ptr CLeg' -> IO Double) -> IO Double
forall l b. GenLeg l -> (Ptr CLeg' -> IO b) -> IO b
withLeg GenLeg l
a1 ((Ptr CLeg' -> IO Double) -> IO Double)
-> (Ptr CLeg' -> IO Double) -> IO Double
forall a b. (a -> b) -> a -> b
$ \Ptr CLeg'
a1' -> 
  let {a2' :: CDouble
a2' = Double -> CDouble
forall a b. (Real a, Fractional b) => a -> b
realToFrac Double
a2} in 
  DayCounter -> (Ptr CDayCounter -> IO Double) -> IO Double
forall b. DayCounter -> (Ptr CDayCounter -> IO b) -> IO b
withDayCounter DayCounter
a3 ((Ptr CDayCounter -> IO Double) -> IO Double)
-> (Ptr CDayCounter -> IO Double) -> IO Double
forall a b. (a -> b) -> a -> b
$ \Ptr CDayCounter
a3' -> 
  let {a4' :: CInt
a4' = (Int -> CInt
forall a b. (Integral a, Num b) => a -> b
fromIntegral (Int -> CInt) -> (Compounding -> Int) -> Compounding -> CInt
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Compounding -> Int
forall a. Enum a => a -> Int
fromEnum) Compounding
a4} in 
  let {a5' :: CInt
a5' = (Int -> CInt
forall a b. (Integral a, Num b) => a -> b
fromIntegral (Int -> CInt) -> (Frequency -> Int) -> Frequency -> CInt
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Frequency -> Int
forall a. Enum a => a -> Int
fromEnum) Frequency
a5} in 
  let {a6' :: CInt
a6' = Bool -> CInt
forall a. Num a => Bool -> a
C2HSImp.fromBool Bool
a6} in 
  Maybe Day -> (CInt -> IO Double) -> IO Double
forall a. Maybe Day -> (CInt -> IO a) -> IO a
withMaybeDay Maybe Day
a7 ((CInt -> IO Double) -> IO Double)
-> (CInt -> IO Double) -> IO Double
forall a b. (a -> b) -> a -> b
$ \CInt
a7' -> 
  Maybe Day -> (CInt -> IO Double) -> IO Double
forall a. Maybe Day -> (CInt -> IO a) -> IO a
withMaybeDay Maybe Day
a8 ((CInt -> IO Double) -> IO Double)
-> (CInt -> IO Double) -> IO Double
forall a b. (a -> b) -> a -> b
$ \CInt
a8' -> 
  let {a9' :: CDouble
a9' = Double -> CDouble
forall a b. (Real a, Fractional b) => a -> b
realToFrac Double
a9} in 
  let {a10' :: CUInt
a10' = Word -> CUInt
forall a b. (Integral a, Num b) => a -> b
fromIntegral Word
a10} in 
  let {a11' :: CDouble
a11' = Double -> CDouble
forall a b. (Real a, Fractional b) => a -> b
realToFrac Double
a11} in 
  (Ptr (Ptr CChar) -> IO Double) -> IO Double
forall a b. (Ptr (Ptr a) -> IO b) -> IO b
preErrorCheck ((Ptr (Ptr CChar) -> IO Double) -> IO Double)
-> (Ptr (Ptr CChar) -> IO Double) -> IO Double
forall a b. (a -> b) -> a -> b
$ \Ptr (Ptr CChar)
a12' -> 
  Ptr CLeg'
-> CDouble
-> Ptr CDayCounter
-> CInt
-> CInt
-> CInt
-> CInt
-> CInt
-> CDouble
-> CUInt
-> CDouble
-> Ptr (Ptr CChar)
-> IO CDouble
yield'_ Ptr CLeg'
a1' CDouble
a2' Ptr CDayCounter
a3' CInt
a4' CInt
a5' CInt
a6' CInt
a7' CInt
a8' CDouble
a9' CUInt
a10' CDouble
a11' Ptr (Ptr CChar)
a12' IO CDouble -> (CDouble -> IO Double) -> IO Double
forall a b. IO a -> (a -> IO b) -> IO b
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= \CDouble
res ->
  let {res' :: Double
res' = CDouble -> Double
forall a b. (Real a, Fractional b) => a -> b
realToFrac CDouble
res} in
  Ptr (Ptr CChar) -> IO ()
errorCheck  Ptr (Ptr CChar)
a12'IO () -> IO Double -> IO Double
forall a b. IO a -> IO b -> IO b
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>>
  Double -> IO Double
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return (Double
res')

{-# LINE 1011 "./QuantLib/CashFlow.chs" #-}


-- |Yield value of a basis point.
-- 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
yieldValueBasisPoint :: (GenLeg l) -> (InterestRate) -- ^yield
 -> (Bool) -- ^includeSettlementDateFlows
 -> (Maybe Day) -- ^settlementDate
 -> (Maybe Day) -- ^npvDate
 -> IO ((Double))
yieldValueBasisPoint a1 a2 a3 a4 a5 =
  withLeg a1 $ \a1' -> 
  withInterestRate a2 $ \a2' -> 
  let {a3' = C2HSImp.fromBool a3} in 
  withMaybeDay a4 $ \a4' -> 
  withMaybeDay a5 $ \a5' -> 
  preErrorCheck $ \a6' -> 
  yieldValueBasisPoint'_ a1' a2' a3' a4' a5' a6' >>= \res ->
  let {res' = realToFrac res} in
  errorCheck  a6'>>
  return (res')

{-# LINE 1019 "./QuantLib/CashFlow.chs" #-}


-- |start of the accrual periods for a coupon leg
couponAccrualStartDates :: (CouponLeg) -> IO (([Day]))
couponAccrualStartDates a1 =
  withGenLeg a1 $ \a1' -> 
  preArray $ \(a2'1, a2'2) -> 
  preErrorCheck $ \a3' -> 
  couponAccrualStartDates'_ a1' a2'1  a2'2 a3' >>
  peekDayArray  a2'1  a2'2>>= \a2'' -> 
  errorCheck  a3'>>
  return (a2'')

{-# LINE 1022 "./QuantLib/CashFlow.chs" #-}


-- |Predetermined cash flow paying a fixed /amount/ at /date/.
fixedDividend :: (Double) -- ^amount
 -> (Day) -- ^date
 -> IO ((Dividend))
fixedDividend a1 a2 =
  let {a1' = realToFrac a1} in 
  withDay a2 $ \a2' -> 
  preErrorCheck $ \a3' -> 
  fixedDividend'_ a1' a2' a3' >>= \res ->
  peekDividend res >>= \res' ->
  errorCheck  a3'>>
  return (res')

{-# LINE 1027 "./QuantLib/CashFlow.chs" #-}


-- |Predetermined cash flow paying /rate/ times /nominal/ at /date/.
fractionalDividendWithNominal :: (Double) -- ^rate
 -> (Double) -- ^nominal
 -> (Day) -- ^date
 -> IO ((Dividend))
fractionalDividendWithNominal a1 a2 a3 =
  let {a1' = realToFrac a1} in 
  let {a2' = realToFrac a2} in 
  withDay a3 $ \a3' -> 
  preErrorCheck $ \a4' -> 
  fractionalDividendWithNominal'_ a1' a2' a3' a4' >>= \res ->
  peekDividend res >>= \res' ->
  errorCheck  a4'>>
  return (res')

{-# LINE 1033 "./QuantLib/CashFlow.chs" #-}


-- |Predetermined cash flow paying a fractional /rate/ of the underlying's price at /date/.
fractionalDividend :: (Double) -- ^rate
 -> (Day) -- ^date
 -> IO ((Dividend))
fractionalDividend a1 a2 =
  let {a1' = realToFrac a1} in 
  withDay a2 $ \a2' -> 
  preErrorCheck $ \a3' -> 
  fractionalDividend'_ a1' a2' a3' >>= \res ->
  peekDividend res >>= \res' ->
  errorCheck  a3'>>
  return (res')

{-# LINE 1038 "./QuantLib/CashFlow.chs" #-}


-- |Build a leg of average-BMA coupons.
averageBmaLeg :: (Schedule) -> (BMAIndex) -> (NonEmpty Double) -- ^notionals
 -> (DayCounter) -> (BusinessDayConvention) -> ([Double]) -- ^gearings
 -> ([Double]) -- ^spreads
 -> IO ((Leg))
averageBmaLeg a1 a2 a3 a4 a5 a6 a7 =
  withSchedule a1 $ \a1' -> 
  withBMAIndex a2 $ \a2' -> 
  withNonEmptyDoubleArray a3 $ \(a3'1, a3'2) -> 
  withDayCounter a4 $ \a4' -> 
  let {a5' = fromEnumC a5} in 
  withDoubleArray a6 $ \(a6'1, a6'2) -> 
  withDoubleArray a7 $ \(a7'1, a7'2) -> 
  preErrorCheck $ \a8' -> 
  averageBmaLeg'_ a1' a2' a3'1  a3'2 a4' a5' a6'1  a6'2 a7'1  a7'2 a8' >>= \res ->
  peekLeg res >>= \res' ->
  errorCheck  a8'>>
  return (res')

{-# LINE 1045 "./QuantLib/CashFlow.chs" #-}


-- |Build a leg of fixed-rate coupons.
fixedRateLeg :: Schedule -> NonEmpty Double -> NonEmpty InterestRate -> BusinessDayConvention -> DayCounter -> Calendar -> IO Leg
fixedRateLeg schedule notionals rates = fixedRateLeg_ schedule notionals (toList rates)
fixedRateLeg_ :: (Schedule) -> (NonEmpty Double) -- ^notionals
 -> ([InterestRate]) -- ^couponRates
 -> (BusinessDayConvention) -- ^paymentAdjustment
 -> (DayCounter) -- ^firstPeriodDayCounter
 -> (Calendar) -- ^paymentCalendar
 -> IO ((Leg))
fixedRateLeg_ a1 a2 a3 a4 a5 a6 =
  withSchedule a1 $ \a1' -> 
  withNonEmptyDoubleArray a2 $ \(a2'1, a2'2) -> 
  withInterestRateArray a3 $ \(a3'1, a3'2) -> 
  let {a4' = fromEnumC a4} in 
  withDayCounter a5 $ \a5' -> 
  withCalendar a6 $ \a6' -> 
  preErrorCheck $ \a7' -> 
  fixedRateLeg_'_ a1' a2'1  a2'2 a3'1  a3'2 a4' a5' a6' a7' >>= \res ->
  peekLeg res >>= \res' ->
  errorCheck  a7'>>
  return (res')

{-# LINE 1055 "./QuantLib/CashFlow.chs" #-}


-- |iborLeg keeps its original 12-arg signature -- existing callers are unaffected -- but
-- now delegates to iborLeg_, the raw binding widened to IborLeg's full builder surface,
-- hardcoding upstream's own defaults for the params iborLeg doesn't expose. Use
-- 'iborLegWithOptions' to reach those (payment lag\/calendar, ex-coupon period, fixing
-- convention, indexed\/at-par coupons) via 'IborLegOpts'.
iborLeg :: Schedule -> GenIborIndex ibor -> NonEmpty Double -> DayCounter -> BusinessDayConvention
  -> [Word] -> [Double] -> [Double] -> [Double] -> [Double] -> Bool -> Bool -> IO Leg
iborLeg schedule idx notionals dc adj fixingDays gearings spreads caps floors inArrears zp = do
  cal <- calendar Null
  iborLeg_ schedule idx notionals dc adj fixingDays gearings spreads caps floors inArrears zp
    (ilgPaymentLag defaultIborLegOpts) cal (ilgExCouponPeriod defaultIborLegOpts) cal
    (ilgExCouponConvention defaultIborLegOpts) (ilgExCouponEndOfMonth defaultIborLegOpts)
    (ilgFixingConvention defaultIborLegOpts) (ilgUseIndexedCoupons defaultIborLegOpts)

-- |'iborLeg' widened to every 'IborLeg' builder-method param via 'IborLegOpts'.
iborLegWithOptions :: Schedule -> GenIborIndex ibor -> NonEmpty Double -> DayCounter -> BusinessDayConvention
  -> [Word] -> [Double] -> [Double] -> [Double] -> [Double] -> Bool -> Bool -> IborLegOpts
  -> IO Leg
iborLegWithOptions :: forall ibor.
Schedule
-> GenIborIndex ibor
-> NonEmpty Double
-> DayCounter
-> BusinessDayConvention
-> [Word]
-> [Double]
-> [Double]
-> [Double]
-> [Double]
-> Bool
-> Bool
-> IborLegOpts
-> IO Leg
iborLegWithOptions Schedule
schedule GenIborIndex ibor
idx NonEmpty Double
notionals DayCounter
dc BusinessDayConvention
adj [Word]
fixingDays [Double]
gearings [Double]
spreads [Double]
caps [Double]
floors Bool
inArrears Bool
zp IborLegOpts
opts = do
  cal <- CalendarConstructor -> IO Calendar
calendar CalendarConstructor
Null
  iborLeg_ schedule idx notionals dc adj fixingDays gearings spreads caps floors inArrears zp
    (ilgPaymentLag opts) (fromMaybe cal (ilgPaymentCalendar opts)) (ilgExCouponPeriod opts)
    (fromMaybe cal (ilgExCouponCalendar opts)) (ilgExCouponConvention opts)
    (ilgExCouponEndOfMonth opts) (ilgFixingConvention opts) (ilgUseIndexedCoupons opts)

-- |Raw binding for 'iborLeg'\/'iborLegWithOptions': builds a leg of capped\/floored Ibor-rate coupons.
iborLeg_ :: (Schedule) -> (GenIborIndex ibor) -> (NonEmpty Double) -- ^notionals
 -> (DayCounter) -> (BusinessDayConvention) -- ^paymentAdjustment
 -> ([Word]) -- ^fixingDays
 -> ([Double]) -- ^gearings
 -> ([Double]) -- ^spreads
 -> ([Double]) -- ^caps
 -> ([Double]) -- ^floors
 -> (Bool) -- ^inArrears
 -> (Bool) -- ^zeroPayments
 -> (Int) -- ^paymentLag
 -> (Calendar) -- ^paymentCalendar
 -> ((Int,TimeUnit)) -- ^exCouponPeriod
 -> (Calendar) -- ^exCouponCalendar
 -> (BusinessDayConvention) -- ^exCouponConvention
 -> (Bool) -- ^exCouponEndOfMonth
 -> (BusinessDayConvention) -- ^fixingConvention
 -> (Maybe Bool) -- ^useIndexedCoupons
 -> IO ((Leg))
iborLeg_ :: forall ibor.
Schedule
-> GenIborIndex ibor
-> NonEmpty Double
-> DayCounter
-> BusinessDayConvention
-> [Word]
-> [Double]
-> [Double]
-> [Double]
-> [Double]
-> Bool
-> Bool
-> Int
-> Calendar
-> (Int, TimeUnit)
-> Calendar
-> BusinessDayConvention
-> Bool
-> BusinessDayConvention
-> Maybe Bool
-> IO Leg
iborLeg_ Schedule
a1 GenIborIndex ibor
a2 NonEmpty Double
a3 DayCounter
a4 BusinessDayConvention
a5 [Word]
a6 [Double]
a7 [Double]
a8 [Double]
a9 [Double]
a10 Bool
a11 Bool
a12 Int
a13 Calendar
a14 (Int, TimeUnit)
a15 Calendar
a16 BusinessDayConvention
a17 Bool
a18 BusinessDayConvention
a19 Maybe Bool
a20 =
  Schedule -> (Ptr CSchedule -> IO Leg) -> IO Leg
forall b. Schedule -> (Ptr CSchedule -> IO b) -> IO b
withSchedule Schedule
a1 ((Ptr CSchedule -> IO Leg) -> IO Leg)
-> (Ptr CSchedule -> IO Leg) -> IO Leg
forall a b. (a -> b) -> a -> b
$ \Ptr CSchedule
a1' -> 
  GenIborIndex ibor -> (Ptr CIborIndex' -> IO Leg) -> IO Leg
forall ibor b.
GenIborIndex ibor -> (Ptr CIborIndex' -> IO b) -> IO b
withIborIndex GenIborIndex ibor
a2 ((Ptr CIborIndex' -> IO Leg) -> IO Leg)
-> (Ptr CIborIndex' -> IO Leg) -> IO Leg
forall a b. (a -> b) -> a -> b
$ \Ptr CIborIndex'
a2' -> 
  NonEmpty Double -> ((CUInt, Ptr CDouble) -> IO Leg) -> IO Leg
forall b. NonEmpty Double -> ((CUInt, Ptr CDouble) -> IO b) -> IO b
withNonEmptyDoubleArray NonEmpty Double
a3 (((CUInt, Ptr CDouble) -> IO Leg) -> IO Leg)
-> ((CUInt, Ptr CDouble) -> IO Leg) -> IO Leg
forall a b. (a -> b) -> a -> b
$ \(CUInt
a3'1, Ptr CDouble
a3'2) -> 
  DayCounter -> (Ptr CDayCounter -> IO Leg) -> IO Leg
forall b. DayCounter -> (Ptr CDayCounter -> IO b) -> IO b
withDayCounter DayCounter
a4 ((Ptr CDayCounter -> IO Leg) -> IO Leg)
-> (Ptr CDayCounter -> IO Leg) -> IO Leg
forall a b. (a -> b) -> a -> b
$ \Ptr CDayCounter
a4' -> 
  let {a5' :: CInt
a5' = BusinessDayConvention -> CInt
forall a b. (Enum a, Integral b) => a -> b
fromEnumC BusinessDayConvention
a5} in 
  [Word] -> ((CUInt, Ptr CUInt) -> IO Leg) -> IO Leg
forall a n b.
(Integral a, Num n, Storable n) =>
[a] -> ((CUInt, Ptr n) -> IO b) -> IO b
withIntArray [Word]
a6 (((CUInt, Ptr CUInt) -> IO Leg) -> IO Leg)
-> ((CUInt, Ptr CUInt) -> IO Leg) -> IO Leg
forall a b. (a -> b) -> a -> b
$ \(CUInt
a6'1, Ptr CUInt
a6'2) -> 
  [Double] -> ((CUInt, Ptr CDouble) -> IO Leg) -> IO Leg
forall b. [Double] -> ((CUInt, Ptr CDouble) -> IO b) -> IO b
withDoubleArray [Double]
a7 (((CUInt, Ptr CDouble) -> IO Leg) -> IO Leg)
-> ((CUInt, Ptr CDouble) -> IO Leg) -> IO Leg
forall a b. (a -> b) -> a -> b
$ \(CUInt
a7'1, Ptr CDouble
a7'2) -> 
  [Double] -> ((CUInt, Ptr CDouble) -> IO Leg) -> IO Leg
forall b. [Double] -> ((CUInt, Ptr CDouble) -> IO b) -> IO b
withDoubleArray [Double]
a8 (((CUInt, Ptr CDouble) -> IO Leg) -> IO Leg)
-> ((CUInt, Ptr CDouble) -> IO Leg) -> IO Leg
forall a b. (a -> b) -> a -> b
$ \(CUInt
a8'1, Ptr CDouble
a8'2) -> 
  [Double] -> ((CUInt, Ptr CDouble) -> IO Leg) -> IO Leg
forall b. [Double] -> ((CUInt, Ptr CDouble) -> IO b) -> IO b
withDoubleArray [Double]
a9 (((CUInt, Ptr CDouble) -> IO Leg) -> IO Leg)
-> ((CUInt, Ptr CDouble) -> IO Leg) -> IO Leg
forall a b. (a -> b) -> a -> b
$ \(CUInt
a9'1, Ptr CDouble
a9'2) -> 
  [Double] -> ((CUInt, Ptr CDouble) -> IO Leg) -> IO Leg
forall b. [Double] -> ((CUInt, Ptr CDouble) -> IO b) -> IO b
withDoubleArray [Double]
a10 (((CUInt, Ptr CDouble) -> IO Leg) -> IO Leg)
-> ((CUInt, Ptr CDouble) -> IO Leg) -> IO Leg
forall a b. (a -> b) -> a -> b
$ \(CUInt
a10'1, Ptr CDouble
a10'2) -> 
  let {a11' :: CInt
a11' = Bool -> CInt
forall a. Num a => Bool -> a
C2HSImp.fromBool Bool
a11} in 
  let {a12' :: CInt
a12' = Bool -> CInt
forall a. Num a => Bool -> a
C2HSImp.fromBool Bool
a12} in 
  let {a13' :: CInt
a13' = Int -> CInt
forall a b. (Integral a, Num b) => a -> b
fromIntegral Int
a13} in 
  Calendar -> (Ptr CCalendar -> IO Leg) -> IO Leg
forall b. Calendar -> (Ptr CCalendar -> IO b) -> IO b
withCalendar Calendar
a14 ((Ptr CCalendar -> IO Leg) -> IO Leg)
-> (Ptr CCalendar -> IO Leg) -> IO Leg
forall a b. (a -> b) -> a -> b
$ \Ptr CCalendar
a14' -> 
  let {(CInt
a15'1, CInt
a15'2) = (Int, TimeUnit) -> (CInt, CInt)
forall a b c.
(Enum a, Integral b, Integral c) =>
(b, a) -> (CInt, c)
fromEnumQuantity (Int, TimeUnit)
a15} in 
  Calendar -> (Ptr CCalendar -> IO Leg) -> IO Leg
forall b. Calendar -> (Ptr CCalendar -> IO b) -> IO b
withCalendar Calendar
a16 ((Ptr CCalendar -> IO Leg) -> IO Leg)
-> (Ptr CCalendar -> IO Leg) -> IO Leg
forall a b. (a -> b) -> a -> b
$ \Ptr CCalendar
a16' -> 
  let {a17' :: CInt
a17' = BusinessDayConvention -> CInt
forall a b. (Enum a, Integral b) => a -> b
fromEnumC BusinessDayConvention
a17} in 
  let {a18' :: CInt
a18' = Bool -> CInt
forall a. Num a => Bool -> a
C2HSImp.fromBool Bool
a18} in 
  let {a19' :: CInt
a19' = BusinessDayConvention -> CInt
forall a b. (Enum a, Integral b) => a -> b
fromEnumC BusinessDayConvention
a19} in 
  let {a20' :: CInt
a20' = Maybe Bool -> CInt
fromMaybeBool Maybe Bool
a20} in 
  (Ptr (Ptr CChar) -> IO Leg) -> IO Leg
forall a b. (Ptr (Ptr a) -> IO b) -> IO b
preErrorCheck ((Ptr (Ptr CChar) -> IO Leg) -> IO Leg)
-> (Ptr (Ptr CChar) -> IO Leg) -> IO Leg
forall a b. (a -> b) -> a -> b
$ \Ptr (Ptr CChar)
a21' -> 
  Ptr CSchedule
-> Ptr CIborIndex'
-> CUInt
-> Ptr CDouble
-> Ptr CDayCounter
-> CInt
-> CUInt
-> Ptr CUInt
-> CUInt
-> Ptr CDouble
-> CUInt
-> Ptr CDouble
-> CUInt
-> Ptr CDouble
-> CUInt
-> Ptr CDouble
-> CInt
-> CInt
-> CInt
-> Ptr CCalendar
-> CInt
-> CInt
-> Ptr CCalendar
-> CInt
-> CInt
-> CInt
-> CInt
-> Ptr (Ptr CChar)
-> IO (Ptr CLeg')
iborLeg_'_ Ptr CSchedule
a1' Ptr CIborIndex'
a2' CUInt
a3'1  Ptr CDouble
a3'2 Ptr CDayCounter
a4' CInt
a5' CUInt
a6'1  Ptr CUInt
a6'2 CUInt
a7'1  Ptr CDouble
a7'2 CUInt
a8'1  Ptr CDouble
a8'2 CUInt
a9'1  Ptr CDouble
a9'2 CUInt
a10'1  Ptr CDouble
a10'2 CInt
a11' CInt
a12' CInt
a13' Ptr CCalendar
a14' CInt
a15'1  CInt
a15'2 Ptr CCalendar
a16' CInt
a17' CInt
a18' CInt
a19' CInt
a20' Ptr (Ptr CChar)
a21' IO (Ptr CLeg') -> (Ptr CLeg' -> IO Leg) -> IO Leg
forall a b. IO a -> (a -> IO b) -> IO b
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= \Ptr CLeg'
res ->
  Ptr CLeg' -> IO Leg
peekLeg Ptr CLeg'
res IO Leg -> (Leg -> IO Leg) -> IO Leg
forall a b. IO a -> (a -> IO b) -> IO b
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= \Leg
res' ->
  Ptr (Ptr CChar) -> IO ()
errorCheck  Ptr (Ptr CChar)
a21'IO () -> IO Leg -> IO Leg
forall a b. IO a -> IO b -> IO b
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>>
  Leg -> IO Leg
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return (Leg
res')

{-# LINE 1100 "./QuantLib/CashFlow.chs" #-}


-- |CMS leg builder (analog of 'iborLeg'), 12-arg core shape -- same defaults-hardcoding
-- pattern as 'iborLeg' for the params not in this signature. Use 'cmsLegWithOptions' to reach
-- them ('CmsLegOpts').
cmsLeg :: Schedule -> GenSwapIndex sidx -> NonEmpty Double -> DayCounter -> BusinessDayConvention
  -> [Word] -> [Double] -> [Double] -> [Double] -> [Double] -> Bool -> Bool -> IO Leg
cmsLeg schedule idx notionals dc adj fixingDays gearings spreads caps floors inArrears zp = do
  cal <- calendar Null
  cmsLeg_ schedule idx notionals dc adj fixingDays gearings spreads caps floors inArrears zp
    (cmslExCouponPeriod defaultCmsLegOpts) cal (cmslExCouponConvention defaultCmsLegOpts)
    (cmslExCouponEndOfMonth defaultCmsLegOpts) (cmslFixingConvention defaultCmsLegOpts)

-- |'cmsLeg' widened to every 'CmsLeg' builder-method param via 'CmsLegOpts'.
cmsLegWithOptions :: Schedule -> GenSwapIndex sidx -> NonEmpty Double -> DayCounter -> BusinessDayConvention
  -> [Word] -> [Double] -> [Double] -> [Double] -> [Double] -> Bool -> Bool -> CmsLegOpts
  -> IO Leg
cmsLegWithOptions schedule idx notionals dc adj fixingDays gearings spreads caps floors inArrears zp opts = do
  cal <- calendar Null
  cmsLeg_ schedule idx notionals dc adj fixingDays gearings spreads caps floors inArrears zp
    (cmslExCouponPeriod opts) (fromMaybe cal (cmslExCouponCalendar opts))
    (cmslExCouponConvention opts) (cmslExCouponEndOfMonth opts) (cmslFixingConvention opts)

-- |Raw binding for 'cmsLeg'\/'cmsLegWithOptions': builds a leg of capped\/floored CMS-rate coupons.
cmsLeg_ :: (Schedule) -> (GenSwapIndex sidx) -> (NonEmpty Double) -- ^notionals
 -> (DayCounter) -> (BusinessDayConvention) -- ^paymentAdjustment
 -> ([Word]) -- ^fixingDays
 -> ([Double]) -- ^gearings
 -> ([Double]) -- ^spreads
 -> ([Double]) -- ^caps
 -> ([Double]) -- ^floors
 -> (Bool) -- ^inArrears
 -> (Bool) -- ^zeroPayments
 -> ((Int,TimeUnit)) -- ^exCouponPeriod
 -> (Calendar) -- ^exCouponCalendar
 -> (BusinessDayConvention) -- ^exCouponConvention
 -> (Bool) -- ^exCouponEndOfMonth
 -> (BusinessDayConvention) -- ^fixingConvention
 -> IO ((Leg))
cmsLeg_ :: forall sidx.
Schedule
-> GenSwapIndex sidx
-> NonEmpty Double
-> DayCounter
-> BusinessDayConvention
-> [Word]
-> [Double]
-> [Double]
-> [Double]
-> [Double]
-> Bool
-> Bool
-> (Int, TimeUnit)
-> Calendar
-> BusinessDayConvention
-> Bool
-> BusinessDayConvention
-> IO Leg
cmsLeg_ Schedule
a1 GenSwapIndex sidx
a2 NonEmpty Double
a3 DayCounter
a4 BusinessDayConvention
a5 [Word]
a6 [Double]
a7 [Double]
a8 [Double]
a9 [Double]
a10 Bool
a11 Bool
a12 (Int, TimeUnit)
a13 Calendar
a14 BusinessDayConvention
a15 Bool
a16 BusinessDayConvention
a17 =
  Schedule -> (Ptr CSchedule -> IO Leg) -> IO Leg
forall b. Schedule -> (Ptr CSchedule -> IO b) -> IO b
withSchedule Schedule
a1 ((Ptr CSchedule -> IO Leg) -> IO Leg)
-> (Ptr CSchedule -> IO Leg) -> IO Leg
forall a b. (a -> b) -> a -> b
$ \Ptr CSchedule
a1' -> 
  GenSwapIndex sidx -> (Ptr CSwapIndex' -> IO Leg) -> IO Leg
forall sidx b.
GenSwapIndex sidx -> (Ptr CSwapIndex' -> IO b) -> IO b
withSwapIndex GenSwapIndex sidx
a2 ((Ptr CSwapIndex' -> IO Leg) -> IO Leg)
-> (Ptr CSwapIndex' -> IO Leg) -> IO Leg
forall a b. (a -> b) -> a -> b
$ \Ptr CSwapIndex'
a2' -> 
  NonEmpty Double -> ((CUInt, Ptr CDouble) -> IO Leg) -> IO Leg
forall b. NonEmpty Double -> ((CUInt, Ptr CDouble) -> IO b) -> IO b
withNonEmptyDoubleArray NonEmpty Double
a3 (((CUInt, Ptr CDouble) -> IO Leg) -> IO Leg)
-> ((CUInt, Ptr CDouble) -> IO Leg) -> IO Leg
forall a b. (a -> b) -> a -> b
$ \(CUInt
a3'1, Ptr CDouble
a3'2) -> 
  DayCounter -> (Ptr CDayCounter -> IO Leg) -> IO Leg
forall b. DayCounter -> (Ptr CDayCounter -> IO b) -> IO b
withDayCounter DayCounter
a4 ((Ptr CDayCounter -> IO Leg) -> IO Leg)
-> (Ptr CDayCounter -> IO Leg) -> IO Leg
forall a b. (a -> b) -> a -> b
$ \Ptr CDayCounter
a4' -> 
  let {a5' :: CInt
a5' = BusinessDayConvention -> CInt
forall a b. (Enum a, Integral b) => a -> b
fromEnumC BusinessDayConvention
a5} in 
  [Word] -> ((CUInt, Ptr CUInt) -> IO Leg) -> IO Leg
forall a n b.
(Integral a, Num n, Storable n) =>
[a] -> ((CUInt, Ptr n) -> IO b) -> IO b
withIntArray [Word]
a6 (((CUInt, Ptr CUInt) -> IO Leg) -> IO Leg)
-> ((CUInt, Ptr CUInt) -> IO Leg) -> IO Leg
forall a b. (a -> b) -> a -> b
$ \(CUInt
a6'1, Ptr CUInt
a6'2) -> 
  [Double] -> ((CUInt, Ptr CDouble) -> IO Leg) -> IO Leg
forall b. [Double] -> ((CUInt, Ptr CDouble) -> IO b) -> IO b
withDoubleArray [Double]
a7 (((CUInt, Ptr CDouble) -> IO Leg) -> IO Leg)
-> ((CUInt, Ptr CDouble) -> IO Leg) -> IO Leg
forall a b. (a -> b) -> a -> b
$ \(CUInt
a7'1, Ptr CDouble
a7'2) -> 
  [Double] -> ((CUInt, Ptr CDouble) -> IO Leg) -> IO Leg
forall b. [Double] -> ((CUInt, Ptr CDouble) -> IO b) -> IO b
withDoubleArray [Double]
a8 (((CUInt, Ptr CDouble) -> IO Leg) -> IO Leg)
-> ((CUInt, Ptr CDouble) -> IO Leg) -> IO Leg
forall a b. (a -> b) -> a -> b
$ \(CUInt
a8'1, Ptr CDouble
a8'2) -> 
  [Double] -> ((CUInt, Ptr CDouble) -> IO Leg) -> IO Leg
forall b. [Double] -> ((CUInt, Ptr CDouble) -> IO b) -> IO b
withDoubleArray [Double]
a9 (((CUInt, Ptr CDouble) -> IO Leg) -> IO Leg)
-> ((CUInt, Ptr CDouble) -> IO Leg) -> IO Leg
forall a b. (a -> b) -> a -> b
$ \(CUInt
a9'1, Ptr CDouble
a9'2) -> 
  [Double] -> ((CUInt, Ptr CDouble) -> IO Leg) -> IO Leg
forall b. [Double] -> ((CUInt, Ptr CDouble) -> IO b) -> IO b
withDoubleArray [Double]
a10 (((CUInt, Ptr CDouble) -> IO Leg) -> IO Leg)
-> ((CUInt, Ptr CDouble) -> IO Leg) -> IO Leg
forall a b. (a -> b) -> a -> b
$ \(CUInt
a10'1, Ptr CDouble
a10'2) -> 
  let {a11' :: CInt
a11' = Bool -> CInt
forall a. Num a => Bool -> a
C2HSImp.fromBool Bool
a11} in 
  let {a12' :: CInt
a12' = Bool -> CInt
forall a. Num a => Bool -> a
C2HSImp.fromBool Bool
a12} in 
  let {(CInt
a13'1, CInt
a13'2) = (Int, TimeUnit) -> (CInt, CInt)
forall a b c.
(Enum a, Integral b, Integral c) =>
(b, a) -> (CInt, c)
fromEnumQuantity (Int, TimeUnit)
a13} in 
  Calendar -> (Ptr CCalendar -> IO Leg) -> IO Leg
forall b. Calendar -> (Ptr CCalendar -> IO b) -> IO b
withCalendar Calendar
a14 ((Ptr CCalendar -> IO Leg) -> IO Leg)
-> (Ptr CCalendar -> IO Leg) -> IO Leg
forall a b. (a -> b) -> a -> b
$ \Ptr CCalendar
a14' -> 
  let {a15' :: CInt
a15' = BusinessDayConvention -> CInt
forall a b. (Enum a, Integral b) => a -> b
fromEnumC BusinessDayConvention
a15} in 
  let {a16' :: CInt
a16' = Bool -> CInt
forall a. Num a => Bool -> a
C2HSImp.fromBool Bool
a16} in 
  let {a17' :: CInt
a17' = BusinessDayConvention -> CInt
forall a b. (Enum a, Integral b) => a -> b
fromEnumC BusinessDayConvention
a17} in 
  (Ptr (Ptr CChar) -> IO Leg) -> IO Leg
forall a b. (Ptr (Ptr a) -> IO b) -> IO b
preErrorCheck ((Ptr (Ptr CChar) -> IO Leg) -> IO Leg)
-> (Ptr (Ptr CChar) -> IO Leg) -> IO Leg
forall a b. (a -> b) -> a -> b
$ \Ptr (Ptr CChar)
a18' -> 
  Ptr CSchedule
-> Ptr CSwapIndex'
-> CUInt
-> Ptr CDouble
-> Ptr CDayCounter
-> CInt
-> CUInt
-> Ptr CUInt
-> CUInt
-> Ptr CDouble
-> CUInt
-> Ptr CDouble
-> CUInt
-> Ptr CDouble
-> CUInt
-> Ptr CDouble
-> CInt
-> CInt
-> CInt
-> CInt
-> Ptr CCalendar
-> CInt
-> CInt
-> CInt
-> Ptr (Ptr CChar)
-> IO (Ptr CLeg')
cmsLeg_'_ Ptr CSchedule
a1' Ptr CSwapIndex'
a2' CUInt
a3'1  Ptr CDouble
a3'2 Ptr CDayCounter
a4' CInt
a5' CUInt
a6'1  Ptr CUInt
a6'2 CUInt
a7'1  Ptr CDouble
a7'2 CUInt
a8'1  Ptr CDouble
a8'2 CUInt
a9'1  Ptr CDouble
a9'2 CUInt
a10'1  Ptr CDouble
a10'2 CInt
a11' CInt
a12' CInt
a13'1  CInt
a13'2 Ptr CCalendar
a14' CInt
a15' CInt
a16' CInt
a17' Ptr (Ptr CChar)
a18' IO (Ptr CLeg') -> (Ptr CLeg' -> IO Leg) -> IO Leg
forall a b. IO a -> (a -> IO b) -> IO b
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= \Ptr CLeg'
res ->
  Ptr CLeg' -> IO Leg
peekLeg Ptr CLeg'
res IO Leg -> (Leg -> IO Leg) -> IO Leg
forall a b. IO a -> (a -> IO b) -> IO b
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= \Leg
res' ->
  Ptr (Ptr CChar) -> IO ()
errorCheck  Ptr (Ptr CChar)
a18'IO () -> IO Leg -> IO Leg
forall a b. IO a -> IO b -> IO b
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>>
  Leg -> IO Leg
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return (Leg
res')

{-# LINE 1138 "./QuantLib/CashFlow.chs" #-}


-- |Build a leg of overnight-index coupons.
overnightLeg :: (Schedule) -> (OvernightIborIndex) -> (NonEmpty Double) -- ^notionals'
 -> (DayCounter) -> (BusinessDayConvention) -> ([Double]) -- ^gearings
 -> ([Double]) -- ^spreads
 -> IO ((Leg))
overnightLeg a1 a2 a3 a4 a5 a6 a7 =
  withSchedule a1 $ \a1' -> 
  withOvernightIborIndex a2 $ \a2' -> 
  withNonEmptyDoubleArray a3 $ \(a3'1, a3'2) -> 
  withDayCounter a4 $ \a4' -> 
  let {a5' = fromEnumC a5} in 
  withDoubleArray a6 $ \(a6'1, a6'2) -> 
  withDoubleArray a7 $ \(a7'1, a7'2) -> 
  preErrorCheck $ \a8' -> 
  overnightLeg'_ a1' a2' a3'1  a3'2 a4' a5' a6'1  a6'2 a7'1  a7'2 a8' >>= \res ->
  peekLeg res >>= \res' ->
  errorCheck  a8'>>
  return (res')

{-# LINE 1144 "./QuantLib/CashFlow.chs" #-}


-- |Build a leg of range-accrual floating-rate coupons.
rangeAccrualLeg :: (Schedule) -> (GenIborIndex ibor) -> (NonEmpty Double) -- ^notionals
 -> (DayCounter) -> (BusinessDayConvention) -> ([Word]) -- ^fixingDays
 -> ([Double]) -- ^gearings
 -> ([Double]) -- ^spreads
 -> ([Double]) -- ^lowerTriggers
 -> ([Double]) -- ^upperTriggers
 -> ((Int,TimeUnit)) -- ^observationTenor
 -> (BusinessDayConvention) -> IO ((Leg))
rangeAccrualLeg a1 a2 a3 a4 a5 a6 a7 a8 a9 a10 a11 a12 =
  withSchedule a1 $ \a1' -> 
  withIborIndex a2 $ \a2' -> 
  withNonEmptyDoubleArray a3 $ \(a3'1, a3'2) -> 
  withDayCounter a4 $ \a4' -> 
  let {a5' = fromEnumC a5} in 
  withIntArray a6 $ \(a6'1, a6'2) -> 
  withDoubleArray a7 $ \(a7'1, a7'2) -> 
  withDoubleArray a8 $ \(a8'1, a8'2) -> 
  withDoubleArray a9 $ \(a9'1, a9'2) -> 
  withDoubleArray a10 $ \(a10'1, a10'2) -> 
  let {(a11'1, a11'2) = fromEnumQuantity a11} in 
  let {a12' = fromEnumC a12} in 
  preErrorCheck $ \a13' -> 
  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 ->
  peekLeg res >>= \res' ->
  errorCheck  a13'>>
  return (res')

{-# LINE 1154 "./QuantLib/CashFlow.chs" #-}


-- |Fixed-rate coupons scaled by the ratio of a 'ZeroInflationIndex' fixing to /baseCPI/
-- (a 'CPICoupon' leg -- no capped\/floored variant, unlike 'yoyInflationLeg': QL 1.43 has no
-- @CappedFlooredCPICoupon@ class to build one from, see README.md's TODO).
cpiLeg :: (Schedule) -> (ZeroInflationIndex) -> (Double) -- ^baseCPI
 -> ((Word,TimeUnit)) -- ^observationLag
 -> (NonEmpty Double) -- ^notionals
 -> (NonEmpty Double) -- ^fixedRates
 -> (DayCounter) -- ^paymentDayCounter
 -> (BusinessDayConvention) -- ^paymentAdjustment
 -> (Calendar) -- ^paymentCalendar
 -> (CPIInterpolationType) -- ^observationInterpolation
 -> (Bool) -- ^subtractInflationNominal
 -> IO ((Leg))
cpiLeg a1 a2 a3 a4 a5 a6 a7 a8 a9 a10 a11 =
  withSchedule a1 $ \a1' -> 
  withZeroInflationIndex a2 $ \a2' -> 
  let {a3' = realToFrac a3} in 
  let {(a4'1, a4'2) = fromEnumQuantity a4} in 
  withNonEmptyDoubleArray a5 $ \(a5'1, a5'2) -> 
  withNonEmptyDoubleArray a6 $ \(a6'1, a6'2) -> 
  withDayCounter a7 $ \a7' -> 
  let {a8' = fromEnumC a8} in 
  withCalendar a9 $ \a9' -> 
  let {a10' = fromEnumC a10} in 
  let {a11' = C2HSImp.fromBool a11} in 
  preErrorCheck $ \a12' -> 
  cpiLeg'_ a1' a2' a3' a4'1  a4'2 a5'1  a5'2 a6'1  a6'2 a7' a8' a9' a10' a11' a12' >>= \res ->
  peekLeg res >>= \res' ->
  errorCheck  a12'>>
  return (res')

{-# LINE 1169 "./QuantLib/CashFlow.chs" #-}


-- |Year-on-year inflation-linked coupons (a 'YoYInflationCoupon' leg). Non-empty /caps/\//floors/
-- build 'CappedFlooredYoYInflationCoupon's instead of plain ones -- but /any/ resulting coupon
-- (capped or not) still needs a pricer set via 'setYoyInflationCouponPricer' before its
-- 'QuantLib.CashFlow.npvWithZSpread\/'amount' can be computed: upstream's @InflationCoupon::rate()@
-- requires @pricer_@ unconditionally, not just for the capped\/floored case (confirmed by reading
-- @inflationcoupon.cpp@). CPI-leg ('cpiLeg') caps\/floors have no equivalent in QL 1.43 (no
-- @CappedFlooredCPICoupon@ class exists upstream, see README.md's TODO) -- this is a
-- QuantLib-version limitation, not an unbound feature.
yoyInflationLeg :: (Schedule) -> (Calendar) -> (YoYInflationIndex) -> ((Word,TimeUnit)) -- ^observationLag
 -> (CPIInterpolationType) -- ^interpolation
 -> (NonEmpty Double) -- ^notionals
 -> (DayCounter) -- ^paymentDayCounter
 -> (BusinessDayConvention) -- ^paymentAdjustment
 -> ([Word]) -- ^fixingDays
 -> ([Double]) -- ^gearings
 -> ([Double]) -- ^spreads
 -> ([Double]) -- ^caps
 -> ([Double]) -- ^floors
 -> IO ((Leg))
yoyInflationLeg :: Schedule
-> Calendar
-> YoYInflationIndex
-> (Word, TimeUnit)
-> CPIInterpolationType
-> NonEmpty Double
-> DayCounter
-> BusinessDayConvention
-> [Word]
-> [Double]
-> [Double]
-> [Double]
-> [Double]
-> IO Leg
yoyInflationLeg Schedule
a1 Calendar
a2 YoYInflationIndex
a3 (Word, TimeUnit)
a4 CPIInterpolationType
a5 NonEmpty Double
a6 DayCounter
a7 BusinessDayConvention
a8 [Word]
a9 [Double]
a10 [Double]
a11 [Double]
a12 [Double]
a13 =
  Schedule -> (Ptr CSchedule -> IO Leg) -> IO Leg
forall b. Schedule -> (Ptr CSchedule -> IO b) -> IO b
withSchedule Schedule
a1 ((Ptr CSchedule -> IO Leg) -> IO Leg)
-> (Ptr CSchedule -> IO Leg) -> IO Leg
forall a b. (a -> b) -> a -> b
$ \Ptr CSchedule
a1' -> 
  Calendar -> (Ptr CCalendar -> IO Leg) -> IO Leg
forall b. Calendar -> (Ptr CCalendar -> IO b) -> IO b
withCalendar Calendar
a2 ((Ptr CCalendar -> IO Leg) -> IO Leg)
-> (Ptr CCalendar -> IO Leg) -> IO Leg
forall a b. (a -> b) -> a -> b
$ \Ptr CCalendar
a2' -> 
  YoYInflationIndex -> (Ptr CYoYInflationIndex' -> IO Leg) -> IO Leg
forall yidx b.
GenYoYInflationIndex yidx
-> (Ptr CYoYInflationIndex' -> IO b) -> IO b
withYoYInflationIndex YoYInflationIndex
a3 ((Ptr CYoYInflationIndex' -> IO Leg) -> IO Leg)
-> (Ptr CYoYInflationIndex' -> IO Leg) -> IO Leg
forall a b. (a -> b) -> a -> b
$ \Ptr CYoYInflationIndex'
a3' -> 
  let {(CInt
a4'1, CInt
a4'2) = (Word, TimeUnit) -> (CInt, CInt)
forall a b c.
(Enum a, Integral b, Integral c) =>
(b, a) -> (CInt, c)
fromEnumQuantity (Word, TimeUnit)
a4} in 
  let {a5' :: CInt
a5' = CPIInterpolationType -> CInt
forall a b. (Enum a, Integral b) => a -> b
fromEnumC CPIInterpolationType
a5} in 
  NonEmpty Double -> ((CUInt, Ptr CDouble) -> IO Leg) -> IO Leg
forall b. NonEmpty Double -> ((CUInt, Ptr CDouble) -> IO b) -> IO b
withNonEmptyDoubleArray NonEmpty Double
a6 (((CUInt, Ptr CDouble) -> IO Leg) -> IO Leg)
-> ((CUInt, Ptr CDouble) -> IO Leg) -> IO Leg
forall a b. (a -> b) -> a -> b
$ \(CUInt
a6'1, Ptr CDouble
a6'2) -> 
  DayCounter -> (Ptr CDayCounter -> IO Leg) -> IO Leg
forall b. DayCounter -> (Ptr CDayCounter -> IO b) -> IO b
withDayCounter DayCounter
a7 ((Ptr CDayCounter -> IO Leg) -> IO Leg)
-> (Ptr CDayCounter -> IO Leg) -> IO Leg
forall a b. (a -> b) -> a -> b
$ \Ptr CDayCounter
a7' -> 
  let {a8' :: CInt
a8' = BusinessDayConvention -> CInt
forall a b. (Enum a, Integral b) => a -> b
fromEnumC BusinessDayConvention
a8} in 
  [Word] -> ((CUInt, Ptr CUInt) -> IO Leg) -> IO Leg
forall a n b.
(Integral a, Num n, Storable n) =>
[a] -> ((CUInt, Ptr n) -> IO b) -> IO b
withIntArray [Word]
a9 (((CUInt, Ptr CUInt) -> IO Leg) -> IO Leg)
-> ((CUInt, Ptr CUInt) -> IO Leg) -> IO Leg
forall a b. (a -> b) -> a -> b
$ \(CUInt
a9'1, Ptr CUInt
a9'2) -> 
  [Double] -> ((CUInt, Ptr CDouble) -> IO Leg) -> IO Leg
forall b. [Double] -> ((CUInt, Ptr CDouble) -> IO b) -> IO b
withDoubleArray [Double]
a10 (((CUInt, Ptr CDouble) -> IO Leg) -> IO Leg)
-> ((CUInt, Ptr CDouble) -> IO Leg) -> IO Leg
forall a b. (a -> b) -> a -> b
$ \(CUInt
a10'1, Ptr CDouble
a10'2) -> 
  [Double] -> ((CUInt, Ptr CDouble) -> IO Leg) -> IO Leg
forall b. [Double] -> ((CUInt, Ptr CDouble) -> IO b) -> IO b
withDoubleArray [Double]
a11 (((CUInt, Ptr CDouble) -> IO Leg) -> IO Leg)
-> ((CUInt, Ptr CDouble) -> IO Leg) -> IO Leg
forall a b. (a -> b) -> a -> b
$ \(CUInt
a11'1, Ptr CDouble
a11'2) -> 
  [Double] -> ((CUInt, Ptr CDouble) -> IO Leg) -> IO Leg
forall b. [Double] -> ((CUInt, Ptr CDouble) -> IO b) -> IO b
withDoubleArray [Double]
a12 (((CUInt, Ptr CDouble) -> IO Leg) -> IO Leg)
-> ((CUInt, Ptr CDouble) -> IO Leg) -> IO Leg
forall a b. (a -> b) -> a -> b
$ \(CUInt
a12'1, Ptr CDouble
a12'2) -> 
  [Double] -> ((CUInt, Ptr CDouble) -> IO Leg) -> IO Leg
forall b. [Double] -> ((CUInt, Ptr CDouble) -> IO b) -> IO b
withDoubleArray [Double]
a13 (((CUInt, Ptr CDouble) -> IO Leg) -> IO Leg)
-> ((CUInt, Ptr CDouble) -> IO Leg) -> IO Leg
forall a b. (a -> b) -> a -> b
$ \(CUInt
a13'1, Ptr CDouble
a13'2) -> 
  (Ptr (Ptr CChar) -> IO Leg) -> IO Leg
forall a b. (Ptr (Ptr a) -> IO b) -> IO b
preErrorCheck ((Ptr (Ptr CChar) -> IO Leg) -> IO Leg)
-> (Ptr (Ptr CChar) -> IO Leg) -> IO Leg
forall a b. (a -> b) -> a -> b
$ \Ptr (Ptr CChar)
a14' -> 
  Ptr CSchedule
-> Ptr CCalendar
-> Ptr CYoYInflationIndex'
-> CInt
-> CInt
-> CInt
-> CUInt
-> Ptr CDouble
-> Ptr CDayCounter
-> CInt
-> CUInt
-> Ptr CUInt
-> CUInt
-> Ptr CDouble
-> CUInt
-> Ptr CDouble
-> CUInt
-> Ptr CDouble
-> CUInt
-> Ptr CDouble
-> Ptr (Ptr CChar)
-> IO (Ptr CLeg')
yoyInflationLeg'_ Ptr CSchedule
a1' Ptr CCalendar
a2' Ptr CYoYInflationIndex'
a3' CInt
a4'1  CInt
a4'2 CInt
a5' CUInt
a6'1  Ptr CDouble
a6'2 Ptr CDayCounter
a7' CInt
a8' CUInt
a9'1  Ptr CUInt
a9'2 CUInt
a10'1  Ptr CDouble
a10'2 CUInt
a11'1  Ptr CDouble
a11'2 CUInt
a12'1  Ptr CDouble
a12'2 CUInt
a13'1  Ptr CDouble
a13'2 Ptr (Ptr CChar)
a14' IO (Ptr CLeg') -> (Ptr CLeg' -> IO Leg) -> IO Leg
forall a b. IO a -> (a -> IO b) -> IO b
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= \Ptr CLeg'
res ->
  Ptr CLeg' -> IO Leg
peekLeg Ptr CLeg'
res IO Leg -> (Leg -> IO Leg) -> IO Leg
forall a b. IO a -> (a -> IO b) -> IO b
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= \Leg
res' ->
  Ptr (Ptr CChar) -> IO ()
errorCheck  Ptr (Ptr CChar)
a14'IO () -> IO Leg -> IO Leg
forall a b. IO a -> IO b -> IO b
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>>
  Leg -> IO Leg
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return (Leg
res')

{-# LINE 1191 "./QuantLib/CashFlow.chs" #-}


{-# LINE 1192 "./QuantLib/CashFlow.chs" #-}


-- |Cash flow dependent on a 'ZeroInflationIndex' ratio (not a coupon -- no accruals).
-- The ratio is taken between fixings observed at /startDate/ and /endDate/ minus /observationLag/.
zeroInflationCashFlow :: (Double) -- ^notional
 -> (ZeroInflationIndex) -> (CPIInterpolationType) -- ^observationInterpolation
 -> (Day) -- ^startDate
 -> (Day) -- ^endDate
 -> ((Word,TimeUnit)) -- ^observationLag
 -> (Day) -- ^paymentDate
 -> (Bool) -- ^growthOnly
 -> IO ((ZeroInflationCashFlow))
zeroInflationCashFlow a1 a2 a3 a4 a5 a6 a7 a8 =
  let {a1' = realToFrac a1} in 
  withZeroInflationIndex a2 $ \a2' -> 
  let {a3' = fromEnumC a3} in 
  withDay a4 $ \a4' -> 
  withDay a5 $ \a5' -> 
  let {(a6'1, a6'2) = fromEnumQuantity a6} in 
  withDay a7 $ \a7' -> 
  let {a8' = C2HSImp.fromBool a8} in 
  preErrorCheck $ \a9' -> 
  zeroInflationCashFlow'_ a1' a2' a3' a4' a5' a6'1  a6'2 a7' a8' a9' >>= \res ->
  peekZeroInflationCashFlow res >>= \res' ->
  errorCheck  a9'>>
  return (res')

{-# LINE 1204 "./QuantLib/CashFlow.chs" #-}


-- |CPI-linked cash flow (not a coupon -- no accruals), with an optional explicit /baseFixing/
-- (pass 'Nothing' to derive it from /baseDate/ instead).
cpiCashFlow :: (Double) -- ^notional
 -> (ZeroInflationIndex) -> (Maybe Day) -- ^baseDate
 -> (Maybe Double) -- ^baseFixing
 -> (Day) -- ^observationDate
 -> ((Word,TimeUnit)) -- ^observationLag
 -> (CPIInterpolationType) -- ^interpolation
 -> (Day) -- ^paymentDate
 -> (Bool) -- ^growthOnly
 -> IO ((CPICashFlow))
cpiCashFlow a1 a2 a3 a4 a5 a6 a7 a8 a9 =
  let {a1' = realToFrac a1} in 
  withZeroInflationIndex a2 $ \a2' -> 
  withMaybeDay a3 $ \a3' -> 
  let {a4' = fromMaybeDouble a4} in 
  withDay a5 $ \a5' -> 
  let {(a6'1, a6'2) = fromEnumQuantity a6} in 
  let {a7' = fromEnumC a7} in 
  withDay a8 $ \a8' -> 
  let {a9' = C2HSImp.fromBool a9} in 
  preErrorCheck $ \a10' -> 
  cpiCashFlow'_ a1' a2' a3' a4' a5' a6'1  a6'2 a7' a8' a9' a10' >>= \res ->
  peekCPICashFlow res >>= \res' ->
  errorCheck  a10'>>
  return (res')

{-# LINE 1217 "./QuantLib/CashFlow.chs" #-}


-- |Cash flow dependent on the total return of an 'QuantLib.Index.Equity.EquityIndex' (not a coupon
-- -- no accruals): @index(fixingDate)\/index(baseDate)@, or that ratio minus one if /growthOnly/.
-- If no 'EquityCashFlowPricer' is attached via 'setEquityCashFlowPricer', 'amount'
-- computes this ratio directly from the index; a pricer (e.g. 'equityQuantoCashFlowPricer') is only
-- needed to price a quanto-adjusted variant.
equityCashFlow :: (Double) -- ^notional
 -> (EquityIndex) -> (Day) -- ^baseDate
 -> (Day) -- ^fixingDate
 -> (Day) -- ^paymentDate
 -> (Bool) -- ^growthOnly
 -> IO ((EquityCashFlow))
equityCashFlow a1 a2 a3 a4 a5 a6 =
  let {a1' = realToFrac a1} in 
  withEquityIndex a2 $ \a2' -> 
  withDay a3 $ \a3' -> 
  withDay a4 $ \a4' -> 
  withDay a5 $ \a5' -> 
  let {a6' = C2HSImp.fromBool a6} in 
  preErrorCheck $ \a7' -> 
  equityCashFlow'_ a1' a2' a3' a4' a5' a6' a7' >>= \res ->
  peekEquityCashFlow res >>= \res' ->
  errorCheck  a7'>>
  return (res')

{-# LINE 1230 "./QuantLib/CashFlow.chs" #-}


-- |Attach a pricer (e.g. from 'equityQuantoCashFlowPricer') to a single 'EquityCashFlow'; see
-- 'setEquityLegPricer' to attach one to every 'EquityCashFlow' in a leg instead.
setEquityCashFlowPricer :: (EquityCashFlow) -> (EquityCashFlowPricer) -> IO ()
setEquityCashFlowPricer a1 a2 =
  withEquityCashFlow a1 $ \a1' -> 
  withEquityCashFlowPricer a2 $ \a2' -> 
  preErrorCheck $ \a3' -> 
  setEquityCashFlowPricer'_ a1' a2' a3' >>
  errorCheck  a3'>>
  return ()

{-# LINE 1234 "./QuantLib/CashFlow.chs" #-}


-- |Quanto-adjusted pricer for an 'EquityCashFlow' whose equity leg is denominated in a currency
-- other than the swap's payment currency.
equityQuantoCashFlowPricer :: (GenYieldTermStructure y) -- ^quantoCurrencyTermStructure
 -> (GenBlackVolTermStructure bv1) -- ^equityVolatility
 -> (GenBlackVolTermStructure bv2) -- ^fxVolatility
 -> (GenQuote q) -- ^correlation
 -> IO ((EquityCashFlowPricer))
equityQuantoCashFlowPricer :: forall y bv1 bv2 q.
GenYieldTermStructure y
-> GenBlackVolTermStructure bv1
-> GenBlackVolTermStructure bv2
-> GenQuote q
-> IO EquityCashFlowPricer
equityQuantoCashFlowPricer GenYieldTermStructure y
a1 GenBlackVolTermStructure bv1
a2 GenBlackVolTermStructure bv2
a3 GenQuote q
a4 =
  GenYieldTermStructure y
-> (Ptr CYieldTermStructure' -> IO EquityCashFlowPricer)
-> IO EquityCashFlowPricer
forall y b.
GenYieldTermStructure y
-> (Ptr CYieldTermStructure' -> IO b) -> IO b
withYieldTermStructure GenYieldTermStructure y
a1 ((Ptr CYieldTermStructure' -> IO EquityCashFlowPricer)
 -> IO EquityCashFlowPricer)
-> (Ptr CYieldTermStructure' -> IO EquityCashFlowPricer)
-> IO EquityCashFlowPricer
forall a b. (a -> b) -> a -> b
$ \Ptr CYieldTermStructure'
a1' -> 
  GenBlackVolTermStructure bv1
-> (Ptr CBlackVolTermStructure' -> IO EquityCashFlowPricer)
-> IO EquityCashFlowPricer
forall bv b.
GenBlackVolTermStructure bv
-> (Ptr CBlackVolTermStructure' -> IO b) -> IO b
withBlackVolTermStructure GenBlackVolTermStructure bv1
a2 ((Ptr CBlackVolTermStructure' -> IO EquityCashFlowPricer)
 -> IO EquityCashFlowPricer)
-> (Ptr CBlackVolTermStructure' -> IO EquityCashFlowPricer)
-> IO EquityCashFlowPricer
forall a b. (a -> b) -> a -> b
$ \Ptr CBlackVolTermStructure'
a2' -> 
  GenBlackVolTermStructure bv2
-> (Ptr CBlackVolTermStructure' -> IO EquityCashFlowPricer)
-> IO EquityCashFlowPricer
forall bv b.
GenBlackVolTermStructure bv
-> (Ptr CBlackVolTermStructure' -> IO b) -> IO b
withBlackVolTermStructure GenBlackVolTermStructure bv2
a3 ((Ptr CBlackVolTermStructure' -> IO EquityCashFlowPricer)
 -> IO EquityCashFlowPricer)
-> (Ptr CBlackVolTermStructure' -> IO EquityCashFlowPricer)
-> IO EquityCashFlowPricer
forall a b. (a -> b) -> a -> b
$ \Ptr CBlackVolTermStructure'
a3' -> 
  GenQuote q
-> (Ptr CQuote' -> IO EquityCashFlowPricer)
-> IO EquityCashFlowPricer
forall q b. GenQuote q -> (Ptr CQuote' -> IO b) -> IO b
withQuote GenQuote q
a4 ((Ptr CQuote' -> IO EquityCashFlowPricer)
 -> IO EquityCashFlowPricer)
-> (Ptr CQuote' -> IO EquityCashFlowPricer)
-> IO EquityCashFlowPricer
forall a b. (a -> b) -> a -> b
$ \Ptr CQuote'
a4' -> 
  (Ptr (Ptr CChar) -> IO EquityCashFlowPricer)
-> IO EquityCashFlowPricer
forall a b. (Ptr (Ptr a) -> IO b) -> IO b
preErrorCheck ((Ptr (Ptr CChar) -> IO EquityCashFlowPricer)
 -> IO EquityCashFlowPricer)
-> (Ptr (Ptr CChar) -> IO EquityCashFlowPricer)
-> IO EquityCashFlowPricer
forall a b. (a -> b) -> a -> b
$ \Ptr (Ptr CChar)
a5' -> 
  Ptr CYieldTermStructure'
-> Ptr CBlackVolTermStructure'
-> Ptr CBlackVolTermStructure'
-> Ptr CQuote'
-> Ptr (Ptr CChar)
-> IO (Ptr CEquityCashFlowPricer)
equityQuantoCashFlowPricer'_ Ptr CYieldTermStructure'
a1' Ptr CBlackVolTermStructure'
a2' Ptr CBlackVolTermStructure'
a3' Ptr CQuote'
a4' Ptr (Ptr CChar)
a5' IO (Ptr CEquityCashFlowPricer)
-> (Ptr CEquityCashFlowPricer -> IO EquityCashFlowPricer)
-> IO EquityCashFlowPricer
forall a b. IO a -> (a -> IO b) -> IO b
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= \Ptr CEquityCashFlowPricer
res ->
  Ptr CEquityCashFlowPricer -> IO EquityCashFlowPricer
peekEquityCashFlowPricer Ptr CEquityCashFlowPricer
res IO EquityCashFlowPricer
-> (EquityCashFlowPricer -> IO EquityCashFlowPricer)
-> IO EquityCashFlowPricer
forall a b. IO a -> (a -> IO b) -> IO b
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= \EquityCashFlowPricer
res' ->
  Ptr (Ptr CChar) -> IO ()
errorCheck  Ptr (Ptr CChar)
a5'IO () -> IO EquityCashFlowPricer -> IO EquityCashFlowPricer
forall a b. IO a -> IO b -> IO b
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>>
  EquityCashFlowPricer -> IO EquityCashFlowPricer
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return (EquityCashFlowPricer
res')

{-# LINE 1242 "./QuantLib/CashFlow.chs" #-}


-- |Attach a pricer to every 'EquityCashFlow' found in /leg/ (non-'EquityCashFlow' entries are left
-- untouched); see 'setEquityCashFlowPricer' to attach one to a single cash flow instead.
setEquityLegPricer :: (GenLeg l) -> (EquityCashFlowPricer) -> IO ()
setEquityLegPricer a1 a2 =
  withLeg a1 $ \a1' -> 
  withEquityCashFlowPricer a2 $ \a2' -> 
  preErrorCheck $ \a3' -> 
  setEquityLegPricer'_ a1' a2' a3' >>
  errorCheck  a3'>>
  return ()

{-# LINE 1246 "./QuantLib/CashFlow.chs" #-}


-- |try to downcast leg to a coupon leg
toCouponLeg :: (GenLeg l) -> IO ((CouponLeg))
toCouponLeg a1 =
  withLeg a1 $ \a1' -> 
  preErrorCheck $ \a2' -> 
  toCouponLeg'_ a1' a2' >>= \res ->
  peekCouponLeg res >>= \res' ->
  errorCheck  a2'>>
  return (res')

{-# LINE 1249 "./QuantLib/CashFlow.chs" #-}


-- |The individual coupons of a coupon leg, e.g. to ask each one its own 'rate' or
-- 'couponAccruedAmount'.  Pair with 'toCouponLeg' to get here from a 'Leg'.
coupons :: (CouponLeg) -- ^leg
 -> IO (([Coupon]))
coupons a1 =
  withGenLeg a1 $ \a1' -> 
  preArray $ \(a2'1, a2'2) -> 
  preErrorCheck $ \a3' -> 
  coupons'_ a1' a2'1  a2'2 a3' >>
  peekCouponArray  a2'1  a2'2>>= \a2'' -> 
  errorCheck  a3'>>
  return (a2'')

{-# LINE 1254 "./QuantLib/CashFlow.chs" #-}


-- |Black-formula pricer for capped/floored Ibor coupons
blackIborCouponPricer :: (GenOptionletVolatilityStructure ov) -> (TimingAdjustment) -> (Maybe (GenQuote q)) -- ^correlation
 -> (Maybe Bool) -- ^useIndexedCoupon
 -> IO ((FloatingRateCouponPricer))
blackIborCouponPricer a1 a2 a3 a4 =
  withOptionletVolatilityStructure a1 $ \a1' -> 
  let {a2' = (fromIntegral . fromEnum) a2} in 
  withMaybeQuote a3 $ \a3' -> 
  let {a4' = fromMaybeBool a4} in 
  preErrorCheck $ \a5' -> 
  blackIborCouponPricer'_ a1' a2' a3' a4' a5' >>= \res ->
  peekFloatingRateCouponPricer res >>= \res' ->
  errorCheck  a5'>>
  return (res')

{-# LINE 1261 "./QuantLib/CashFlow.chs" #-}


-- |Experimental quanto-adjusted Black-formula pricer for capped/floored Ibor coupons.
-- The FX Black volatility and underlying/FX correlation determine the quanto adjustment;
-- the caplet volatility supplies the ordinary Ibor optionlet pricing inputs.  The three
-- handles are retained by QuantLib, so relinking their underlying quotes or term structures
-- updates the pricer in the usual way.
blackIborQuantoCouponPricer :: (GenBlackVolTermStructure bv) -- ^fxVolatility
 -> (GenQuote q) -- ^underlyingFxCorrelation
 -> (GenOptionletVolatilityStructure ov) -- ^capletVolatility
 -> IO ((FloatingRateCouponPricer))
blackIborQuantoCouponPricer :: forall bv q ov.
GenBlackVolTermStructure bv
-> GenQuote q
-> GenOptionletVolatilityStructure ov
-> IO FloatingRateCouponPricer
blackIborQuantoCouponPricer GenBlackVolTermStructure bv
a1 GenQuote q
a2 GenOptionletVolatilityStructure ov
a3 =
  GenBlackVolTermStructure bv
-> (Ptr CBlackVolTermStructure' -> IO FloatingRateCouponPricer)
-> IO FloatingRateCouponPricer
forall bv b.
GenBlackVolTermStructure bv
-> (Ptr CBlackVolTermStructure' -> IO b) -> IO b
withBlackVolTermStructure GenBlackVolTermStructure bv
a1 ((Ptr CBlackVolTermStructure' -> IO FloatingRateCouponPricer)
 -> IO FloatingRateCouponPricer)
-> (Ptr CBlackVolTermStructure' -> IO FloatingRateCouponPricer)
-> IO FloatingRateCouponPricer
forall a b. (a -> b) -> a -> b
$ \Ptr CBlackVolTermStructure'
a1' -> 
  GenQuote q
-> (Ptr CQuote' -> IO FloatingRateCouponPricer)
-> IO FloatingRateCouponPricer
forall q b. GenQuote q -> (Ptr CQuote' -> IO b) -> IO b
withQuote GenQuote q
a2 ((Ptr CQuote' -> IO FloatingRateCouponPricer)
 -> IO FloatingRateCouponPricer)
-> (Ptr CQuote' -> IO FloatingRateCouponPricer)
-> IO FloatingRateCouponPricer
forall a b. (a -> b) -> a -> b
$ \Ptr CQuote'
a2' -> 
  GenOptionletVolatilityStructure ov
-> (Ptr COptionletVolatilityStructure'
    -> IO FloatingRateCouponPricer)
-> IO FloatingRateCouponPricer
forall ov b.
GenOptionletVolatilityStructure ov
-> (Ptr COptionletVolatilityStructure' -> IO b) -> IO b
withOptionletVolatilityStructure GenOptionletVolatilityStructure ov
a3 ((Ptr COptionletVolatilityStructure'
  -> IO FloatingRateCouponPricer)
 -> IO FloatingRateCouponPricer)
-> (Ptr COptionletVolatilityStructure'
    -> IO FloatingRateCouponPricer)
-> IO FloatingRateCouponPricer
forall a b. (a -> b) -> a -> b
$ \Ptr COptionletVolatilityStructure'
a3' -> 
  (Ptr (Ptr CChar) -> IO FloatingRateCouponPricer)
-> IO FloatingRateCouponPricer
forall a b. (Ptr (Ptr a) -> IO b) -> IO b
preErrorCheck ((Ptr (Ptr CChar) -> IO FloatingRateCouponPricer)
 -> IO FloatingRateCouponPricer)
-> (Ptr (Ptr CChar) -> IO FloatingRateCouponPricer)
-> IO FloatingRateCouponPricer
forall a b. (a -> b) -> a -> b
$ \Ptr (Ptr CChar)
a4' -> 
  Ptr CBlackVolTermStructure'
-> Ptr CQuote'
-> Ptr COptionletVolatilityStructure'
-> Ptr (Ptr CChar)
-> IO (Ptr CFloatingRateCouponPricer')
blackIborQuantoCouponPricer'_ Ptr CBlackVolTermStructure'
a1' Ptr CQuote'
a2' Ptr COptionletVolatilityStructure'
a3' Ptr (Ptr CChar)
a4' IO (Ptr CFloatingRateCouponPricer')
-> (Ptr CFloatingRateCouponPricer' -> IO FloatingRateCouponPricer)
-> IO FloatingRateCouponPricer
forall a b. IO a -> (a -> IO b) -> IO b
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= \Ptr CFloatingRateCouponPricer'
res ->
  Ptr CFloatingRateCouponPricer' -> IO FloatingRateCouponPricer
peekFloatingRateCouponPricer Ptr CFloatingRateCouponPricer'
res IO FloatingRateCouponPricer
-> (FloatingRateCouponPricer -> IO FloatingRateCouponPricer)
-> IO FloatingRateCouponPricer
forall a b. IO a -> (a -> IO b) -> IO b
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= \FloatingRateCouponPricer
res' ->
  Ptr (Ptr CChar) -> IO ()
errorCheck  Ptr (Ptr CChar)
a4'IO () -> IO FloatingRateCouponPricer -> IO FloatingRateCouponPricer
forall a b. IO a -> IO b -> IO b
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>>
  FloatingRateCouponPricer -> IO FloatingRateCouponPricer
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return (FloatingRateCouponPricer
res')

{-# LINE 1271 "./QuantLib/CashFlow.chs" #-}


-- |BGM-based pricer for 'RangeAccrualFloatersCoupon's (a 'rangeAccrualLeg')
rangeAccrualPricerByBgm :: (Double) -- ^correlation
 -> (SmileSection) -- ^smilesOnExpiry
 -> (SmileSection) -- ^smilesOnPayment
 -> (Bool) -- ^withSmile
 -> (Bool) -- ^byCallSpread
 -> IO ((FloatingRateCouponPricer))
rangeAccrualPricerByBgm a1 a2 a3 a4 a5 =
  let {a1' = realToFrac a1} in 
  withSmileSection a2 $ \a2' -> 
  withSmileSection a3 $ \a3' -> 
  let {a4' = C2HSImp.fromBool a4} in 
  let {a5' = C2HSImp.fromBool a5} in 
  preErrorCheck $ \a6' -> 
  rangeAccrualPricerByBgm'_ a1' a2' a3' a4' a5' a6' >>= \res ->
  peekFloatingRateCouponPricer res >>= \res' ->
  errorCheck  a6'>>
  return (res')

{-# LINE 1279 "./QuantLib/CashFlow.chs" #-}


-- |Black-formula pricer for capped\/floored 'yoyInflationLeg' coupons.
blackYoyInflationCouponPricer :: (YoYOptionletVolatilitySurface) -> (GenYieldTermStructure y) -- ^nominalTermStructure
 -> IO ((YoYInflationCouponPricer))
blackYoyInflationCouponPricer a1 a2 =
  withGenVolatilityTermStructure a1 $ \a1' -> 
  withYieldTermStructure a2 $ \a2' -> 
  preErrorCheck $ \a3' -> 
  blackYoyInflationCouponPricer'_ a1' a2' a3' >>= \res ->
  peekYoYInflationCouponPricer res >>= \res' ->
  errorCheck  a3'>>
  return (res')

{-# LINE 1284 "./QuantLib/CashFlow.chs" #-}


-- |Unit-Displaced-Black-formula pricer for capped\/floored 'yoyInflationLeg' coupons.
unitDisplacedBlackYoyInflationCouponPricer :: (YoYOptionletVolatilitySurface) -> (GenYieldTermStructure y) -- ^nominalTermStructure
 -> IO ((YoYInflationCouponPricer))
unitDisplacedBlackYoyInflationCouponPricer a1 a2 =
  withGenVolatilityTermStructure a1 $ \a1' -> 
  withYieldTermStructure a2 $ \a2' -> 
  preErrorCheck $ \a3' -> 
  unitDisplacedBlackYoyInflationCouponPricer'_ a1' a2' a3' >>= \res ->
  peekYoYInflationCouponPricer res >>= \res' ->
  errorCheck  a3'>>
  return (res')

{-# LINE 1289 "./QuantLib/CashFlow.chs" #-}


-- |Bachelier-formula pricer for capped\/floored 'yoyInflationLeg' coupons.
bachelierYoyInflationCouponPricer :: (YoYOptionletVolatilitySurface) -> (GenYieldTermStructure y) -- ^nominalTermStructure
 -> IO ((YoYInflationCouponPricer))
bachelierYoyInflationCouponPricer a1 a2 =
  withGenVolatilityTermStructure a1 $ \a1' -> 
  withYieldTermStructure a2 $ \a2' -> 
  preErrorCheck $ \a3' -> 
  bachelierYoyInflationCouponPricer'_ a1' a2' a3' >>= \res ->
  peekYoYInflationCouponPricer res >>= \res' ->
  errorCheck  a3'>>
  return (res')

{-# LINE 1294 "./QuantLib/CashFlow.chs" #-}


-- |Set the pricer of every 'QuantLib.Instrument.InflationCapFloor.YoYInflationCapFloor'-ready
-- 'YoYInflationCoupon'\/'CappedFlooredYoYInflationCoupon' in /leg/. Required before pricing (via
-- 'QuantLib.CashFlow.npvWithZSpread or an 'QuantLib.Instrument.setPricingEngine'd instrument built on the
-- leg) any 'yoyInflationLeg' built with non-empty caps\/floors -- 'yoyInflationLeg' auto-attaches
-- a default (non-vol) pricer only when caps and floors are both empty.
setYoyInflationCouponPricer :: (GenLeg l) -> (YoYInflationCouponPricer) -> IO ()
setYoyInflationCouponPricer a1 a2 =
  withLeg a1 $ \a1' -> 
  withYoYInflationCouponPricer a2 $ \a2' -> 
  preErrorCheck $ \a3' -> 
  setYoyInflationCouponPricer'_ a1' a2' a3' >>
  errorCheck  a3'>>
  return ()

{-# LINE 1301 "./QuantLib/CashFlow.chs" #-}


-- |Set the pricer of every floating-rate coupon in /leg/.
setCouponPricer :: (GenLeg l) -> (GenFloatingRateCouponPricer frcp) -> IO ()
setCouponPricer a1 a2 =
  withLeg a1 $ \a1' -> 
  withFloatingRateCouponPricer a2 $ \a2' -> 
  preErrorCheck $ \a3' -> 
  setCouponPricer'_ a1' a2' a3' >>
  errorCheck  a3'>>
  return ()

{-# LINE 1304 "./QuantLib/CashFlow.chs" #-}


-- |Set the pricer of every floating-rate coupon in /leg/, picking each coupon's pricer from
-- /pricers/ by matching coupon type.
setCouponPricers :: (GenLeg l) -> ([GenFloatingRateCouponPricer frcp]) -> IO ()
setCouponPricers a1 a2 =
  withLeg a1 $ \a1' -> 
  withFloatingRateCouponPricerArray a2 $ \(a2'1, a2'2) -> 
  preErrorCheck $ \a3' -> 
  setCouponPricers'_ a1' a2'1  a2'2 a3' >>
  errorCheck  a3'>>
  return ()

{-# LINE 1308 "./QuantLib/CashFlow.chs" #-}


-- |Rate for a fully-determined coupon period, with no cap\/floor.
swapletRate :: (GenFloatingRateCouponPricer frcp) -> IO ((Double))
swapletRate a1 =
  withFloatingRateCouponPricer a1 $ \a1' -> 
  preErrorCheck $ \a2' -> 
  swapletRate'_ a1' a2' >>= \res ->
  let {res' = realToFrac res} in
  errorCheck  a2'>>
  return (res')

{-# LINE 1311 "./QuantLib/CashFlow.chs" #-}


-- |Price (NPV contribution) for a fully-determined coupon period, with no cap\/floor.  Not
-- every pricer supports this: e.g. 'CompoundingOvernightIndexedCouponPricer' throws.
swapletPrice :: (GenFloatingRateCouponPricer frcp) -> IO ((Double))
swapletPrice a1 =
  withFloatingRateCouponPricer a1 $ \a1' -> 
  preErrorCheck $ \a2' -> 
  swapletPrice'_ a1' a2' >>= \res ->
  let {res' = realToFrac res} in
  errorCheck  a2'>>
  return (res')

{-# LINE 1315 "./QuantLib/CashFlow.chs" #-}


-- |Price of the caplet with the given effective cap rate.  Not every pricer supports this.
capletPrice :: (GenFloatingRateCouponPricer frcp) -> (Double) -- ^effectiveCap
 -> IO ((Double))
capletPrice a1 a2 =
  withFloatingRateCouponPricer a1 $ \a1' -> 
  let {a2' = realToFrac a2} in 
  preErrorCheck $ \a3' -> 
  capletPrice'_ a1' a2' a3' >>= \res ->
  let {res' = realToFrac res} in
  errorCheck  a3'>>
  return (res')

{-# LINE 1320 "./QuantLib/CashFlow.chs" #-}


-- |Rate of the caplet with the given effective cap rate.  Not every pricer supports this.
capletRate :: (GenFloatingRateCouponPricer frcp) -> (Double) -- ^effectiveCap
 -> IO ((Double))
capletRate a1 a2 =
  withFloatingRateCouponPricer a1 $ \a1' -> 
  let {a2' = realToFrac a2} in 
  preErrorCheck $ \a3' -> 
  capletRate'_ a1' a2' a3' >>= \res ->
  let {res' = realToFrac res} in
  errorCheck  a3'>>
  return (res')

{-# LINE 1325 "./QuantLib/CashFlow.chs" #-}


-- |Price of the floorlet with the given effective floor rate.  Not every pricer supports this.
floorletPrice :: (GenFloatingRateCouponPricer frcp) -> (Double) -- ^effectiveFloor
 -> IO ((Double))
floorletPrice a1 a2 =
  withFloatingRateCouponPricer a1 $ \a1' -> 
  let {a2' = realToFrac a2} in 
  preErrorCheck $ \a3' -> 
  floorletPrice'_ a1' a2' a3' >>= \res ->
  let {res' = realToFrac res} in
  errorCheck  a3'>>
  return (res')

{-# LINE 1330 "./QuantLib/CashFlow.chs" #-}


-- |Rate of the floorlet with the given effective floor rate.  Not every pricer supports this.
floorletRate :: (GenFloatingRateCouponPricer frcp) -> (Double) -- ^effectiveFloor
 -> IO ((Double))
floorletRate a1 a2 =
  withFloatingRateCouponPricer a1 $ \a1' -> 
  let {a2' = realToFrac a2} in 
  preErrorCheck $ \a3' -> 
  floorletRate'_ a1' a2' a3' >>= \res ->
  let {res' = realToFrac res} in
  errorCheck  a3'>>
  return (res')

{-# LINE 1335 "./QuantLib/CashFlow.chs" #-}


-- |Constant-maturity-swap (CMS) coupon.
--
-- The start and end dates are used as supplied: QuantLib performs no business-day adjustment
-- when constructing this coupon, so callers must supply already adjusted dates.  Attach a CMS
-- pricer before asking for its rate or amount.
cmsCoupon :: (Day) -- ^paymentDate
 -> (Double) -- ^nominal
 -> (Day) -- ^accrualStartDate
 -> (Day) -- ^accrualEndDate
 -> (Word) -- ^fixingDays
 -> (GenSwapIndex sidx) -- ^index
 -> (Double) -- ^gearing
 -> (Double) -- ^spread
 -> (Maybe Day) -- ^referencePeriodStart
 -> (Maybe Day) -- ^referencePeriodEnd
 -> (DayCounter) -- ^dayCounter
 -> (Bool) -- ^inArrears
 -> (Maybe Day) -- ^exCouponDate
 -> (BusinessDayConvention) -- ^fixingConvention
 -> IO ((CmsCoupon))
cmsCoupon :: forall sidx.
Day
-> Double
-> Day
-> Day
-> Word
-> GenSwapIndex sidx
-> Double
-> Double
-> Maybe Day
-> Maybe Day
-> DayCounter
-> Bool
-> Maybe Day
-> BusinessDayConvention
-> IO CmsCoupon
cmsCoupon Day
a1 Double
a2 Day
a3 Day
a4 Word
a5 GenSwapIndex sidx
a6 Double
a7 Double
a8 Maybe Day
a9 Maybe Day
a10 DayCounter
a11 Bool
a12 Maybe Day
a13 BusinessDayConvention
a14 =
  Day -> (CInt -> IO CmsCoupon) -> IO CmsCoupon
forall a. Day -> (CInt -> IO a) -> IO a
withDay Day
a1 ((CInt -> IO CmsCoupon) -> IO CmsCoupon)
-> (CInt -> IO CmsCoupon) -> IO CmsCoupon
forall a b. (a -> b) -> a -> b
$ \CInt
a1' -> 
  let {a2' :: CDouble
a2' = Double -> CDouble
forall a b. (Real a, Fractional b) => a -> b
realToFrac Double
a2} in 
  Day -> (CInt -> IO CmsCoupon) -> IO CmsCoupon
forall a. Day -> (CInt -> IO a) -> IO a
withDay Day
a3 ((CInt -> IO CmsCoupon) -> IO CmsCoupon)
-> (CInt -> IO CmsCoupon) -> IO CmsCoupon
forall a b. (a -> b) -> a -> b
$ \CInt
a3' -> 
  Day -> (CInt -> IO CmsCoupon) -> IO CmsCoupon
forall a. Day -> (CInt -> IO a) -> IO a
withDay Day
a4 ((CInt -> IO CmsCoupon) -> IO CmsCoupon)
-> (CInt -> IO CmsCoupon) -> IO CmsCoupon
forall a b. (a -> b) -> a -> b
$ \CInt
a4' -> 
  let {a5' :: CUInt
a5' = Word -> CUInt
forall a b. (Integral a, Num b) => a -> b
fromIntegral Word
a5} in 
  GenSwapIndex sidx
-> (Ptr CSwapIndex' -> IO CmsCoupon) -> IO CmsCoupon
forall sidx b.
GenSwapIndex sidx -> (Ptr CSwapIndex' -> IO b) -> IO b
withSwapIndex GenSwapIndex sidx
a6 ((Ptr CSwapIndex' -> IO CmsCoupon) -> IO CmsCoupon)
-> (Ptr CSwapIndex' -> IO CmsCoupon) -> IO CmsCoupon
forall a b. (a -> b) -> a -> b
$ \Ptr CSwapIndex'
a6' -> 
  let {a7' :: CDouble
a7' = Double -> CDouble
forall a b. (Real a, Fractional b) => a -> b
realToFrac Double
a7} in 
  let {a8' :: CDouble
a8' = Double -> CDouble
forall a b. (Real a, Fractional b) => a -> b
realToFrac Double
a8} in 
  Maybe Day -> (CInt -> IO CmsCoupon) -> IO CmsCoupon
forall a. Maybe Day -> (CInt -> IO a) -> IO a
withMaybeDay Maybe Day
a9 ((CInt -> IO CmsCoupon) -> IO CmsCoupon)
-> (CInt -> IO CmsCoupon) -> IO CmsCoupon
forall a b. (a -> b) -> a -> b
$ \CInt
a9' -> 
  Maybe Day -> (CInt -> IO CmsCoupon) -> IO CmsCoupon
forall a. Maybe Day -> (CInt -> IO a) -> IO a
withMaybeDay Maybe Day
a10 ((CInt -> IO CmsCoupon) -> IO CmsCoupon)
-> (CInt -> IO CmsCoupon) -> IO CmsCoupon
forall a b. (a -> b) -> a -> b
$ \CInt
a10' -> 
  DayCounter -> (Ptr CDayCounter -> IO CmsCoupon) -> IO CmsCoupon
forall b. DayCounter -> (Ptr CDayCounter -> IO b) -> IO b
withDayCounter DayCounter
a11 ((Ptr CDayCounter -> IO CmsCoupon) -> IO CmsCoupon)
-> (Ptr CDayCounter -> IO CmsCoupon) -> IO CmsCoupon
forall a b. (a -> b) -> a -> b
$ \Ptr CDayCounter
a11' -> 
  let {a12' :: CInt
a12' = Bool -> CInt
forall a. Num a => Bool -> a
C2HSImp.fromBool Bool
a12} in 
  Maybe Day -> (CInt -> IO CmsCoupon) -> IO CmsCoupon
forall a. Maybe Day -> (CInt -> IO a) -> IO a
withMaybeDay Maybe Day
a13 ((CInt -> IO CmsCoupon) -> IO CmsCoupon)
-> (CInt -> IO CmsCoupon) -> IO CmsCoupon
forall a b. (a -> b) -> a -> b
$ \CInt
a13' -> 
  let {a14' :: CInt
a14' = BusinessDayConvention -> CInt
forall a b. (Enum a, Integral b) => a -> b
fromEnumC BusinessDayConvention
a14} in 
  (Ptr (Ptr CChar) -> IO CmsCoupon) -> IO CmsCoupon
forall a b. (Ptr (Ptr a) -> IO b) -> IO b
preErrorCheck ((Ptr (Ptr CChar) -> IO CmsCoupon) -> IO CmsCoupon)
-> (Ptr (Ptr CChar) -> IO CmsCoupon) -> IO CmsCoupon
forall a b. (a -> b) -> a -> b
$ \Ptr (Ptr CChar)
a15' -> 
  CInt
-> CDouble
-> CInt
-> CInt
-> CUInt
-> Ptr CSwapIndex'
-> CDouble
-> CDouble
-> CInt
-> CInt
-> Ptr CDayCounter
-> CInt
-> CInt
-> CInt
-> Ptr (Ptr CChar)
-> IO (Ptr CCmsCoupon')
cmsCoupon'_ CInt
a1' CDouble
a2' CInt
a3' CInt
a4' CUInt
a5' Ptr CSwapIndex'
a6' CDouble
a7' CDouble
a8' CInt
a9' CInt
a10' Ptr CDayCounter
a11' CInt
a12' CInt
a13' CInt
a14' Ptr (Ptr CChar)
a15' IO (Ptr CCmsCoupon')
-> (Ptr CCmsCoupon' -> IO CmsCoupon) -> IO CmsCoupon
forall a b. IO a -> (a -> IO b) -> IO b
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= \Ptr CCmsCoupon'
res ->
  Ptr CCmsCoupon' -> IO CmsCoupon
peekCmsCoupon Ptr CCmsCoupon'
res IO CmsCoupon -> (CmsCoupon -> IO CmsCoupon) -> IO CmsCoupon
forall a b. IO a -> (a -> IO b) -> IO b
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= \CmsCoupon
res' ->
  Ptr (Ptr CChar) -> IO ()
errorCheck  Ptr (Ptr CChar)
a15'IO () -> IO CmsCoupon -> IO CmsCoupon
forall a b. IO a -> IO b -> IO b
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>>
  CmsCoupon -> IO CmsCoupon
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return (CmsCoupon
res')

{-# LINE 1356 "./QuantLib/CashFlow.chs" #-}


-- |Constant-maturity-swap-spread coupon.  Its index is the geared difference of two swap rates.
-- QuantLib does no date adjustment at construction, so callers must provide business dates.
cmsSpreadCoupon :: (Day) -- ^paymentDate
 -> (Double) -- ^nominal
 -> (Day) -- ^accrualStartDate
 -> (Day) -- ^accrualEndDate
 -> (Word) -- ^fixingDays
 -> (SwapSpreadIndex) -- ^index
 -> (Double) -- ^gearing
 -> (Double) -- ^spread
 -> (Maybe Day) -- ^referencePeriodStart
 -> (Maybe Day) -- ^referencePeriodEnd
 -> (DayCounter) -- ^dayCounter
 -> (Bool) -- ^inArrears
 -> (Maybe Day) -- ^exCouponDate
 -> (BusinessDayConvention) -- ^fixingConvention
 -> IO ((FloatingRateCoupon))
cmsSpreadCoupon a1 a2 a3 a4 a5 a6 a7 a8 a9 a10 a11 a12 a13 a14 =
  withDay a1 $ \a1' -> 
  let {a2' = realToFrac a2} in 
  withDay a3 $ \a3' -> 
  withDay a4 $ \a4' -> 
  let {a5' = fromIntegral a5} in 
  withSwapSpreadIndex a6 $ \a6' -> 
  let {a7' = realToFrac a7} in 
  let {a8' = realToFrac a8} in 
  withMaybeDay a9 $ \a9' -> 
  withMaybeDay a10 $ \a10' -> 
  withDayCounter a11 $ \a11' -> 
  let {a12' = C2HSImp.fromBool a12} in 
  withMaybeDay a13 $ \a13' -> 
  let {a14' = fromEnumC a14} in 
  preErrorCheck $ \a15' -> 
  cmsSpreadCoupon'_ a1' a2' a3' a4' a5' a6' a7' a8' a9' a10' a11' a12' a13' a14' a15' >>= \res ->
  peekFloatingRateCoupon res >>= \res' ->
  errorCheck  a15'>>
  return (res')

{-# LINE 1374 "./QuantLib/CashFlow.chs" #-}


-- |The coupon rate, at the 'Coupon' level every accruing cash flow shares.  How it is obtained
-- is the subtype's business: a 'FixedRateCoupon' returns its own rate, a 'CPICoupon' its fixed
-- rate times the index ratio, and a 'FloatingRateCoupon' requires an attached
-- 'FloatingRateCouponPricer' and throws without one (see 'setFloatingRateCouponPricer').
rate :: (GenCoupon c) -- ^coupon
 -> IO ((Double))
rate a1 =
  withCoupon a1 $ \a1' -> 
  preErrorCheck $ \a2' -> 
  rate'_ a1' a2' >>= \res ->
  let {res' = realToFrac res} in
  errorCheck  a2'>>
  return (res')

{-# LINE 1381 "./QuantLib/CashFlow.chs" #-}


-- |Interest accrued on a single coupon up to the given date -- nominal times 'rate' times the
-- accrued fraction of the accrual period.  Named apart from the leg-level 'accruedAmount', which
-- sums a whole 'Leg' and takes settlement-date arguments this does not.
couponAccruedAmount :: (GenCoupon c) -- ^coupon
 -> (Day) -- ^date
 -> IO ((Double))
couponAccruedAmount a1 a2 =
  withCoupon a1 $ \a1' -> 
  withDay a2 $ \a2' -> 
  preErrorCheck $ \a3' -> 
  couponAccruedAmount'_ a1' a2' a3' >>= \res ->
  let {res' = realToFrac res} in
  errorCheck  a3'>>
  return (res')

{-# LINE 1388 "./QuantLib/CashFlow.chs" #-}


-- |Set the coupon pricer used to calculate a floating-rate coupon's rate.
setFloatingRateCouponPricer :: (GenFloatingRateCoupon frc) -- ^coupon
 -> (GenFloatingRateCouponPricer frcp) -- ^pricer
 -> IO ()
setFloatingRateCouponPricer a1 a2 =
  withFloatingRateCoupon a1 $ \a1' -> 
  withFloatingRateCouponPricer a2 $ \a2' -> 
  preErrorCheck $ \a3' -> 
  setFloatingRateCouponPricer'_ a1' a2' a3' >>
  errorCheck  a3'>>
  return ()

{-# LINE 1393 "./QuantLib/CashFlow.chs" #-}


-- |Net present value of the coupon, i.e. the coupon amount discounted off the given curve.
-- 'Nothing' uses the coupon's own default discounting (an empty @Handle\<YieldTermStructure\>@).
price :: (GenFloatingRateCoupon frc) -- ^coupon
 -> (Maybe (GenYieldTermStructure y)) -- ^discountingCurve
 -> IO ((Double))
price a1 a2 =
  withFloatingRateCoupon a1 $ \a1' -> 
  withMaybeYieldTermStructure a2 $ \a2' -> 
  preErrorCheck $ \a3' -> 
  price'_ a1' a2' a3' >>= \res ->
  let {res' = realToFrac res} in
  errorCheck  a3'>>
  return (res')

{-# LINE 1399 "./QuantLib/CashFlow.chs" #-}


-- |The adjustment (e.g. for coupons that fix in arrears) applied to the plain index fixing to
-- get the effective, convexity-adjusted fixing used in 'rate'.
convexityAdjustment :: (GenFloatingRateCoupon frc) -- ^coupon
 -> IO ((Double))
convexityAdjustment a1 =
  withFloatingRateCoupon a1 $ \a1' -> 
  preErrorCheck $ \a2' -> 
  convexityAdjustment'_ a1' a2' >>= \res ->
  let {res' = realToFrac res} in
  errorCheck  a2'>>
  return (res')

{-# LINE 1404 "./QuantLib/CashFlow.chs" #-}


-- |CMS coupon with optional cap and floor.  This is QuantLib's
-- @CappedFlooredCmsCoupon@: it wraps a 'CmsCoupon' in a capped/floored coupon and returns it at
-- the useful 'FloatingRateCoupon' level.  'Nothing' means no cap or floor.
cappedFlooredCmsCoupon :: (Day) -- ^paymentDate
 -> (Double) -- ^nominal
 -> (Day) -- ^accrualStartDate
 -> (Day) -- ^accrualEndDate
 -> (Word) -- ^fixingDays
 -> (GenSwapIndex sidx) -- ^index
 -> (Double) -- ^gearing
 -> (Double) -- ^spread
 -> (Maybe Double) -- ^cap
 -> (Maybe Double) -- ^floor
 -> (Maybe Day) -- ^referencePeriodStart
 -> (Maybe Day) -- ^referencePeriodEnd
 -> (DayCounter) -- ^dayCounter
 -> (Bool) -- ^inArrears
 -> (Maybe Day) -- ^exCouponDate
 -> (BusinessDayConvention) -- ^fixingConvention
 -> IO ((FloatingRateCoupon))
cappedFlooredCmsCoupon :: forall sidx.
Day
-> Double
-> Day
-> Day
-> Word
-> GenSwapIndex sidx
-> Double
-> Double
-> Maybe Double
-> Maybe Double
-> Maybe Day
-> Maybe Day
-> DayCounter
-> Bool
-> Maybe Day
-> BusinessDayConvention
-> IO FloatingRateCoupon
cappedFlooredCmsCoupon Day
a1 Double
a2 Day
a3 Day
a4 Word
a5 GenSwapIndex sidx
a6 Double
a7 Double
a8 Maybe Double
a9 Maybe Double
a10 Maybe Day
a11 Maybe Day
a12 DayCounter
a13 Bool
a14 Maybe Day
a15 BusinessDayConvention
a16 =
  Day -> (CInt -> IO FloatingRateCoupon) -> IO FloatingRateCoupon
forall a. Day -> (CInt -> IO a) -> IO a
withDay Day
a1 ((CInt -> IO FloatingRateCoupon) -> IO FloatingRateCoupon)
-> (CInt -> IO FloatingRateCoupon) -> IO FloatingRateCoupon
forall a b. (a -> b) -> a -> b
$ \CInt
a1' -> 
  let {a2' :: CDouble
a2' = Double -> CDouble
forall a b. (Real a, Fractional b) => a -> b
realToFrac Double
a2} in 
  Day -> (CInt -> IO FloatingRateCoupon) -> IO FloatingRateCoupon
forall a. Day -> (CInt -> IO a) -> IO a
withDay Day
a3 ((CInt -> IO FloatingRateCoupon) -> IO FloatingRateCoupon)
-> (CInt -> IO FloatingRateCoupon) -> IO FloatingRateCoupon
forall a b. (a -> b) -> a -> b
$ \CInt
a3' -> 
  Day -> (CInt -> IO FloatingRateCoupon) -> IO FloatingRateCoupon
forall a. Day -> (CInt -> IO a) -> IO a
withDay Day
a4 ((CInt -> IO FloatingRateCoupon) -> IO FloatingRateCoupon)
-> (CInt -> IO FloatingRateCoupon) -> IO FloatingRateCoupon
forall a b. (a -> b) -> a -> b
$ \CInt
a4' -> 
  let {a5' :: CUInt
a5' = Word -> CUInt
forall a b. (Integral a, Num b) => a -> b
fromIntegral Word
a5} in 
  GenSwapIndex sidx
-> (Ptr CSwapIndex' -> IO FloatingRateCoupon)
-> IO FloatingRateCoupon
forall sidx b.
GenSwapIndex sidx -> (Ptr CSwapIndex' -> IO b) -> IO b
withSwapIndex GenSwapIndex sidx
a6 ((Ptr CSwapIndex' -> IO FloatingRateCoupon)
 -> IO FloatingRateCoupon)
-> (Ptr CSwapIndex' -> IO FloatingRateCoupon)
-> IO FloatingRateCoupon
forall a b. (a -> b) -> a -> b
$ \Ptr CSwapIndex'
a6' -> 
  let {a7' :: CDouble
a7' = Double -> CDouble
forall a b. (Real a, Fractional b) => a -> b
realToFrac Double
a7} in 
  let {a8' :: CDouble
a8' = Double -> CDouble
forall a b. (Real a, Fractional b) => a -> b
realToFrac Double
a8} in 
  let {a9' :: CDouble
a9' = Maybe Double -> CDouble
fromMaybeDouble Maybe Double
a9} in 
  let {a10' :: CDouble
a10' = Maybe Double -> CDouble
fromMaybeDouble Maybe Double
a10} in 
  Maybe Day
-> (CInt -> IO FloatingRateCoupon) -> IO FloatingRateCoupon
forall a. Maybe Day -> (CInt -> IO a) -> IO a
withMaybeDay Maybe Day
a11 ((CInt -> IO FloatingRateCoupon) -> IO FloatingRateCoupon)
-> (CInt -> IO FloatingRateCoupon) -> IO FloatingRateCoupon
forall a b. (a -> b) -> a -> b
$ \CInt
a11' -> 
  Maybe Day
-> (CInt -> IO FloatingRateCoupon) -> IO FloatingRateCoupon
forall a. Maybe Day -> (CInt -> IO a) -> IO a
withMaybeDay Maybe Day
a12 ((CInt -> IO FloatingRateCoupon) -> IO FloatingRateCoupon)
-> (CInt -> IO FloatingRateCoupon) -> IO FloatingRateCoupon
forall a b. (a -> b) -> a -> b
$ \CInt
a12' -> 
  DayCounter
-> (Ptr CDayCounter -> IO FloatingRateCoupon)
-> IO FloatingRateCoupon
forall b. DayCounter -> (Ptr CDayCounter -> IO b) -> IO b
withDayCounter DayCounter
a13 ((Ptr CDayCounter -> IO FloatingRateCoupon)
 -> IO FloatingRateCoupon)
-> (Ptr CDayCounter -> IO FloatingRateCoupon)
-> IO FloatingRateCoupon
forall a b. (a -> b) -> a -> b
$ \Ptr CDayCounter
a13' -> 
  let {a14' :: CInt
a14' = Bool -> CInt
forall a. Num a => Bool -> a
C2HSImp.fromBool Bool
a14} in 
  Maybe Day
-> (CInt -> IO FloatingRateCoupon) -> IO FloatingRateCoupon
forall a. Maybe Day -> (CInt -> IO a) -> IO a
withMaybeDay Maybe Day
a15 ((CInt -> IO FloatingRateCoupon) -> IO FloatingRateCoupon)
-> (CInt -> IO FloatingRateCoupon) -> IO FloatingRateCoupon
forall a b. (a -> b) -> a -> b
$ \CInt
a15' -> 
  let {a16' :: CInt
a16' = BusinessDayConvention -> CInt
forall a b. (Enum a, Integral b) => a -> b
fromEnumC BusinessDayConvention
a16} in 
  (Ptr (Ptr CChar) -> IO FloatingRateCoupon) -> IO FloatingRateCoupon
forall a b. (Ptr (Ptr a) -> IO b) -> IO b
preErrorCheck ((Ptr (Ptr CChar) -> IO FloatingRateCoupon)
 -> IO FloatingRateCoupon)
-> (Ptr (Ptr CChar) -> IO FloatingRateCoupon)
-> IO FloatingRateCoupon
forall a b. (a -> b) -> a -> b
$ \Ptr (Ptr CChar)
a17' -> 
  CInt
-> CDouble
-> CInt
-> CInt
-> CUInt
-> Ptr CSwapIndex'
-> CDouble
-> CDouble
-> CDouble
-> CDouble
-> CInt
-> CInt
-> Ptr CDayCounter
-> CInt
-> CInt
-> CInt
-> Ptr (Ptr CChar)
-> IO (Ptr CFloatingRateCoupon')
cappedFlooredCmsCoupon'_ CInt
a1' CDouble
a2' CInt
a3' CInt
a4' CUInt
a5' Ptr CSwapIndex'
a6' CDouble
a7' CDouble
a8' CDouble
a9' CDouble
a10' CInt
a11' CInt
a12' Ptr CDayCounter
a13' CInt
a14' CInt
a15' CInt
a16' Ptr (Ptr CChar)
a17' IO (Ptr CFloatingRateCoupon')
-> (Ptr CFloatingRateCoupon' -> IO FloatingRateCoupon)
-> IO FloatingRateCoupon
forall a b. IO a -> (a -> IO b) -> IO b
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= \Ptr CFloatingRateCoupon'
res ->
  Ptr CFloatingRateCoupon' -> IO FloatingRateCoupon
peekFloatingRateCoupon Ptr CFloatingRateCoupon'
res IO FloatingRateCoupon
-> (FloatingRateCoupon -> IO FloatingRateCoupon)
-> IO FloatingRateCoupon
forall a b. IO a -> (a -> IO b) -> IO b
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= \FloatingRateCoupon
res' ->
  Ptr (Ptr CChar) -> IO ()
errorCheck  Ptr (Ptr CChar)
a17'IO () -> IO FloatingRateCoupon -> IO FloatingRateCoupon
forall a b. IO a -> IO b -> IO b
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>>
  FloatingRateCoupon -> IO FloatingRateCoupon
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return (FloatingRateCoupon
res')

{-# LINE 1425 "./QuantLib/CashFlow.chs" #-}


-- |Capped/floored CMS-spread coupon, returned at the useful 'FloatingRateCoupon' level.
-- 'Nothing' represents QuantLib's absent cap or floor.
cappedFlooredCmsSpreadCoupon :: (Day) -- ^paymentDate
 -> (Double) -- ^nominal
 -> (Day) -- ^accrualStartDate
 -> (Day) -- ^accrualEndDate
 -> (Word) -- ^fixingDays
 -> (SwapSpreadIndex) -- ^index
 -> (Double) -- ^gearing
 -> (Double) -- ^spread
 -> (Maybe Double) -- ^cap
 -> (Maybe Double) -- ^floor
 -> (Maybe Day) -- ^referencePeriodStart
 -> (Maybe Day) -- ^referencePeriodEnd
 -> (DayCounter) -- ^dayCounter
 -> (Bool) -- ^inArrears
 -> (Maybe Day) -- ^exCouponDate
 -> (BusinessDayConvention) -- ^fixingConvention
 -> IO ((FloatingRateCoupon))
cappedFlooredCmsSpreadCoupon a1 a2 a3 a4 a5 a6 a7 a8 a9 a10 a11 a12 a13 a14 a15 a16 =
  withDay a1 $ \a1' -> 
  let {a2' = realToFrac a2} in 
  withDay a3 $ \a3' -> 
  withDay a4 $ \a4' -> 
  let {a5' = fromIntegral a5} in 
  withSwapSpreadIndex a6 $ \a6' -> 
  let {a7' = realToFrac a7} in 
  let {a8' = realToFrac a8} in 
  let {a9' = fromMaybeDouble a9} in 
  let {a10' = fromMaybeDouble a10} in 
  withMaybeDay a11 $ \a11' -> 
  withMaybeDay a12 $ \a12' -> 
  withDayCounter a13 $ \a13' -> 
  let {a14' = C2HSImp.fromBool a14} in 
  withMaybeDay a15 $ \a15' -> 
  let {a16' = fromEnumC a16} in 
  preErrorCheck $ \a17' -> 
  cappedFlooredCmsSpreadCoupon'_ a1' a2' a3' a4' a5' a6' a7' a8' a9' a10' a11' a12' a13' a14' a15' a16' a17' >>= \res ->
  peekFloatingRateCoupon res >>= \res' ->
  errorCheck  a17'>>
  return (res')

{-# LINE 1445 "./QuantLib/CashFlow.chs" #-}


-- |CMS-spread leg builder.  Unlike 'CmsLeg', upstream's @CmsSpreadLeg@ has no
-- ex-coupon-period\/fixing-convention builder methods, so this binds its full builder surface
-- directly with no accompanying options record.
cmsSpreadLeg :: (Schedule) -> (SwapSpreadIndex) -- ^swapSpreadIndex
 -> (NonEmpty Double) -- ^notionals
 -> (DayCounter) -> (BusinessDayConvention) -- ^paymentAdjustment
 -> ([Word]) -- ^fixingDays
 -> ([Double]) -- ^gearings
 -> ([Double]) -- ^spreads
 -> ([Double]) -- ^caps
 -> ([Double]) -- ^floors
 -> (Bool) -- ^inArrears
 -> (Bool) -- ^zeroPayments
 -> IO ((Leg))
cmsSpreadLeg a1 a2 a3 a4 a5 a6 a7 a8 a9 a10 a11 a12 =
  withSchedule a1 $ \a1' -> 
  withSwapSpreadIndex a2 $ \a2' -> 
  withNonEmptyDoubleArray a3 $ \(a3'1, a3'2) -> 
  withDayCounter a4 $ \a4' -> 
  let {a5' = fromEnumC a5} in 
  withIntArray a6 $ \(a6'1, a6'2) -> 
  withDoubleArray a7 $ \(a7'1, a7'2) -> 
  withDoubleArray a8 $ \(a8'1, a8'2) -> 
  withDoubleArray a9 $ \(a9'1, a9'2) -> 
  withDoubleArray a10 $ \(a10'1, a10'2) -> 
  let {a11' = C2HSImp.fromBool a11} in 
  let {a12' = C2HSImp.fromBool a12} in 
  preErrorCheck $ \a13' -> 
  cmsSpreadLeg'_ a1' a2' a3'1  a3'2 a4' a5' a6'1  a6'2 a7'1  a7'2 a8'1  a8'2 a9'1  a9'2 a10'1  a10'2 a11' a12' a13' >>= \res ->
  peekLeg res >>= \res' ->
  errorCheck  a13'>>
  return (res')

{-# LINE 1460 "./QuantLib/CashFlow.chs" #-}


-- |Digital-option replication strategy.  It specifies the sub, central, or super replication
-- used to price the embedded digital option in a digital coupon; /gap/ is the call/put-spread
-- width used by that replication.
digitalReplication :: (ReplicationType) -- ^replicationType
 -> (Double) -- ^gap
 -> IO ((DigitalReplication))
digitalReplication a1 a2 =
  let {a1' = (fromIntegral . fromEnum) a1} in 
  let {a2' = realToFrac a2} in 
  preErrorCheck $ \a3' -> 
  digitalReplication'_ a1' a2' a3' >>= \res ->
  peekDigitalReplication res >>= \res' ->
  errorCheck  a3'>>
  return (res')

{-# LINE 1467 "./QuantLib/CashFlow.chs" #-}

replicationType :: (DigitalReplication) -- ^replication
 -> (ReplicationType)
replicationType a1 =
  C2HSImp.unsafePerformIO $
  withDigitalReplication a1 $ \a1' -> 
  replicationType'_ a1' >>= \res ->
  let {res' = (toEnum . fromIntegral) res} in
  return (res')

{-# LINE 1469 "./QuantLib/CashFlow.chs" #-}

gap :: (DigitalReplication) -- ^replication
 -> (Double)
gap a1 =
  C2HSImp.unsafePerformIO $
  withDigitalReplication a1 $ \a1' -> 
  gap'_ a1' >>= \res ->
  let {res' = realToFrac res} in
  return (res')

{-# LINE 1471 "./QuantLib/CashFlow.chs" #-}


-- |CMS-rate coupon with embedded digital call and put options.
--
-- QuantLib evaluates the digital options by call/put-spread replication.  A supplied digital
-- payoff produces a cash-or-nothing option; without one the option is asset-or-nothing.  When
-- /nakedOption/ is true, the underlying coupon rate is excluded from the payoff.  Optional
-- strikes and payoffs use 'Nothing' for QuantLib's null-rate sentinel.
digitalCmsCoupon :: (CmsCoupon) -- ^underlying
 -> (Maybe Double) -- ^callStrike
 -> (PositionType) -- ^callPosition
 -> (Bool) -- ^callATM
 -> (Maybe Double) -- ^callDigitalPayoff
 -> (Maybe Double) -- ^putStrike
 -> (PositionType) -- ^putPosition
 -> (Bool) -- ^putATM
 -> (Maybe Double) -- ^putDigitalPayoff
 -> (Maybe DigitalReplication) -- ^replication
 -> (Bool) -- ^nakedOption
 -> IO ((DigitalCmsCoupon))
digitalCmsCoupon :: CmsCoupon
-> Maybe Double
-> PositionType
-> Bool
-> Maybe Double
-> Maybe Double
-> PositionType
-> Bool
-> Maybe Double
-> Maybe DigitalReplication
-> Bool
-> IO DigitalCmsCoupon
digitalCmsCoupon CmsCoupon
a1 Maybe Double
a2 PositionType
a3 Bool
a4 Maybe Double
a5 Maybe Double
a6 PositionType
a7 Bool
a8 Maybe Double
a9 Maybe DigitalReplication
a10 Bool
a11 =
  CmsCoupon
-> (Ptr CCmsCoupon' -> IO DigitalCmsCoupon) -> IO DigitalCmsCoupon
forall b. CmsCoupon -> (Ptr CCmsCoupon' -> IO b) -> IO b
withCmsCoupon CmsCoupon
a1 ((Ptr CCmsCoupon' -> IO DigitalCmsCoupon) -> IO DigitalCmsCoupon)
-> (Ptr CCmsCoupon' -> IO DigitalCmsCoupon) -> IO DigitalCmsCoupon
forall a b. (a -> b) -> a -> b
$ \Ptr CCmsCoupon'
a1' -> 
  let {a2' :: CDouble
a2' = Maybe Double -> CDouble
fromMaybeDouble Maybe Double
a2} in 
  let {a3' :: CInt
a3' = PositionType -> CInt
forall a b. (Enum a, Integral b) => a -> b
fromEnumC PositionType
a3} in 
  let {a4' :: CInt
a4' = Bool -> CInt
forall a. Num a => Bool -> a
C2HSImp.fromBool Bool
a4} in 
  let {a5' :: CDouble
a5' = Maybe Double -> CDouble
fromMaybeDouble Maybe Double
a5} in 
  let {a6' :: CDouble
a6' = Maybe Double -> CDouble
fromMaybeDouble Maybe Double
a6} in 
  let {a7' :: CInt
a7' = PositionType -> CInt
forall a b. (Enum a, Integral b) => a -> b
fromEnumC PositionType
a7} in 
  let {a8' :: CInt
a8' = Bool -> CInt
forall a. Num a => Bool -> a
C2HSImp.fromBool Bool
a8} in 
  let {a9' :: CDouble
a9' = Maybe Double -> CDouble
fromMaybeDouble Maybe Double
a9} in 
  Maybe DigitalReplication
-> (Ptr CDigitalReplication -> IO DigitalCmsCoupon)
-> IO DigitalCmsCoupon
forall b.
Maybe DigitalReplication
-> (Ptr CDigitalReplication -> IO b) -> IO b
withMaybeDigitalReplication Maybe DigitalReplication
a10 ((Ptr CDigitalReplication -> IO DigitalCmsCoupon)
 -> IO DigitalCmsCoupon)
-> (Ptr CDigitalReplication -> IO DigitalCmsCoupon)
-> IO DigitalCmsCoupon
forall a b. (a -> b) -> a -> b
$ \Ptr CDigitalReplication
a10' -> 
  let {a11' :: CInt
a11' = Bool -> CInt
forall a. Num a => Bool -> a
C2HSImp.fromBool Bool
a11} in 
  (Ptr (Ptr CChar) -> IO DigitalCmsCoupon) -> IO DigitalCmsCoupon
forall a b. (Ptr (Ptr a) -> IO b) -> IO b
preErrorCheck ((Ptr (Ptr CChar) -> IO DigitalCmsCoupon) -> IO DigitalCmsCoupon)
-> (Ptr (Ptr CChar) -> IO DigitalCmsCoupon) -> IO DigitalCmsCoupon
forall a b. (a -> b) -> a -> b
$ \Ptr (Ptr CChar)
a12' -> 
  Ptr CCmsCoupon'
-> CDouble
-> CInt
-> CInt
-> CDouble
-> CDouble
-> CInt
-> CInt
-> CDouble
-> Ptr CDigitalReplication
-> CInt
-> Ptr (Ptr CChar)
-> IO (Ptr CDigitalCmsCoupon')
digitalCmsCoupon'_ Ptr CCmsCoupon'
a1' CDouble
a2' CInt
a3' CInt
a4' CDouble
a5' CDouble
a6' CInt
a7' CInt
a8' CDouble
a9' Ptr CDigitalReplication
a10' CInt
a11' Ptr (Ptr CChar)
a12' IO (Ptr CDigitalCmsCoupon')
-> (Ptr CDigitalCmsCoupon' -> IO DigitalCmsCoupon)
-> IO DigitalCmsCoupon
forall a b. IO a -> (a -> IO b) -> IO b
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= \Ptr CDigitalCmsCoupon'
res ->
  Ptr CDigitalCmsCoupon' -> IO DigitalCmsCoupon
peekDigitalCmsCoupon Ptr CDigitalCmsCoupon'
res IO DigitalCmsCoupon
-> (DigitalCmsCoupon -> IO DigitalCmsCoupon) -> IO DigitalCmsCoupon
forall a b. IO a -> (a -> IO b) -> IO b
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= \DigitalCmsCoupon
res' ->
  Ptr (Ptr CChar) -> IO ()
errorCheck  Ptr (Ptr CChar)
a12'IO () -> IO DigitalCmsCoupon -> IO DigitalCmsCoupon
forall a b. IO a -> IO b -> IO b
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>>
  DigitalCmsCoupon -> IO DigitalCmsCoupon
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return (DigitalCmsCoupon
res')

{-# LINE 1490 "./QuantLib/CashFlow.chs" #-}


-- |CMS-spread-rate coupon with embedded digital call and put options.  Builds its own
-- underlying 'CmsSpreadCoupon' from /paymentDate/ through /fixingConvention/ (as
-- 'cmsSpreadCoupon' does), then wraps it exactly as 'digitalCmsCoupon' wraps a 'CmsCoupon'.
-- QuantLib does no date adjustment at construction, so callers must provide business dates.
-- Optional strikes and payoffs use 'Nothing' for QuantLib's null-rate sentinel.
digitalCmsSpreadCoupon :: (Day) -- ^paymentDate
 -> (Double) -- ^nominal
 -> (Day) -- ^accrualStartDate
 -> (Day) -- ^accrualEndDate
 -> (Word) -- ^fixingDays
 -> (SwapSpreadIndex) -- ^index
 -> (Double) -- ^gearing
 -> (Double) -- ^spread
 -> (Maybe Day) -- ^referencePeriodStart
 -> (Maybe Day) -- ^referencePeriodEnd
 -> (DayCounter) -- ^dayCounter
 -> (Bool) -- ^inArrears
 -> (Maybe Day) -- ^exCouponDate
 -> (BusinessDayConvention) -- ^fixingConvention
 -> (Maybe Double) -- ^callStrike
 -> (PositionType) -- ^callPosition
 -> (Bool) -- ^callATM
 -> (Maybe Double) -- ^callDigitalPayoff
 -> (Maybe Double) -- ^putStrike
 -> (PositionType) -- ^putPosition
 -> (Bool) -- ^putATM
 -> (Maybe Double) -- ^putDigitalPayoff
 -> (Maybe DigitalReplication) -- ^replication
 -> (Bool) -- ^nakedOption
 -> IO ((DigitalCmsSpreadCoupon))
digitalCmsSpreadCoupon :: Day
-> Double
-> Day
-> Day
-> Word
-> SwapSpreadIndex
-> Double
-> Double
-> Maybe Day
-> Maybe Day
-> DayCounter
-> Bool
-> Maybe Day
-> BusinessDayConvention
-> Maybe Double
-> PositionType
-> Bool
-> Maybe Double
-> Maybe Double
-> PositionType
-> Bool
-> Maybe Double
-> Maybe DigitalReplication
-> Bool
-> IO DigitalCmsSpreadCoupon
digitalCmsSpreadCoupon Day
a1 Double
a2 Day
a3 Day
a4 Word
a5 SwapSpreadIndex
a6 Double
a7 Double
a8 Maybe Day
a9 Maybe Day
a10 DayCounter
a11 Bool
a12 Maybe Day
a13 BusinessDayConvention
a14 Maybe Double
a15 PositionType
a16 Bool
a17 Maybe Double
a18 Maybe Double
a19 PositionType
a20 Bool
a21 Maybe Double
a22 Maybe DigitalReplication
a23 Bool
a24 =
  Day
-> (CInt -> IO DigitalCmsSpreadCoupon) -> IO DigitalCmsSpreadCoupon
forall a. Day -> (CInt -> IO a) -> IO a
withDay Day
a1 ((CInt -> IO DigitalCmsSpreadCoupon) -> IO DigitalCmsSpreadCoupon)
-> (CInt -> IO DigitalCmsSpreadCoupon) -> IO DigitalCmsSpreadCoupon
forall a b. (a -> b) -> a -> b
$ \CInt
a1' -> 
  let {a2' :: CDouble
a2' = Double -> CDouble
forall a b. (Real a, Fractional b) => a -> b
realToFrac Double
a2} in 
  Day
-> (CInt -> IO DigitalCmsSpreadCoupon) -> IO DigitalCmsSpreadCoupon
forall a. Day -> (CInt -> IO a) -> IO a
withDay Day
a3 ((CInt -> IO DigitalCmsSpreadCoupon) -> IO DigitalCmsSpreadCoupon)
-> (CInt -> IO DigitalCmsSpreadCoupon) -> IO DigitalCmsSpreadCoupon
forall a b. (a -> b) -> a -> b
$ \CInt
a3' -> 
  Day
-> (CInt -> IO DigitalCmsSpreadCoupon) -> IO DigitalCmsSpreadCoupon
forall a. Day -> (CInt -> IO a) -> IO a
withDay Day
a4 ((CInt -> IO DigitalCmsSpreadCoupon) -> IO DigitalCmsSpreadCoupon)
-> (CInt -> IO DigitalCmsSpreadCoupon) -> IO DigitalCmsSpreadCoupon
forall a b. (a -> b) -> a -> b
$ \CInt
a4' -> 
  let {a5' :: CUInt
a5' = Word -> CUInt
forall a b. (Integral a, Num b) => a -> b
fromIntegral Word
a5} in 
  SwapSpreadIndex
-> (Ptr CSwapSpreadIndex' -> IO DigitalCmsSpreadCoupon)
-> IO DigitalCmsSpreadCoupon
forall b.
SwapSpreadIndex -> (Ptr CSwapSpreadIndex' -> IO b) -> IO b
withSwapSpreadIndex SwapSpreadIndex
a6 ((Ptr CSwapSpreadIndex' -> IO DigitalCmsSpreadCoupon)
 -> IO DigitalCmsSpreadCoupon)
-> (Ptr CSwapSpreadIndex' -> IO DigitalCmsSpreadCoupon)
-> IO DigitalCmsSpreadCoupon
forall a b. (a -> b) -> a -> b
$ \Ptr CSwapSpreadIndex'
a6' -> 
  let {a7' :: CDouble
a7' = Double -> CDouble
forall a b. (Real a, Fractional b) => a -> b
realToFrac Double
a7} in 
  let {a8' = realToFrac a8} in 
  Maybe Day
-> (CInt -> IO DigitalCmsSpreadCoupon) -> IO DigitalCmsSpreadCoupon
forall a. Maybe Day -> (CInt -> IO a) -> IO a
withMaybeDay Maybe Day
a9 ((CInt -> IO DigitalCmsSpreadCoupon) -> IO DigitalCmsSpreadCoupon)
-> (CInt -> IO DigitalCmsSpreadCoupon) -> IO DigitalCmsSpreadCoupon
forall a b. (a -> b) -> a -> b
$ \CInt
a9' -> 
  Maybe Day
-> (CInt -> IO DigitalCmsSpreadCoupon) -> IO DigitalCmsSpreadCoupon
forall a. Maybe Day -> (CInt -> IO a) -> IO a
withMaybeDay Maybe Day
a10 ((CInt -> IO DigitalCmsSpreadCoupon) -> IO DigitalCmsSpreadCoupon)
-> (CInt -> IO DigitalCmsSpreadCoupon) -> IO DigitalCmsSpreadCoupon
forall a b. (a -> b) -> a -> b
$ \CInt
a10' -> 
  DayCounter
-> (Ptr CDayCounter -> IO DigitalCmsSpreadCoupon)
-> IO DigitalCmsSpreadCoupon
forall b. DayCounter -> (Ptr CDayCounter -> IO b) -> IO b
withDayCounter DayCounter
a11 ((Ptr CDayCounter -> IO DigitalCmsSpreadCoupon)
 -> IO DigitalCmsSpreadCoupon)
-> (Ptr CDayCounter -> IO DigitalCmsSpreadCoupon)
-> IO DigitalCmsSpreadCoupon
forall a b. (a -> b) -> a -> b
$ \Ptr CDayCounter
a11' -> 
  let {a12' :: CInt
a12' = Bool -> CInt
forall a. Num a => Bool -> a
C2HSImp.fromBool Bool
a12} in 
  Maybe Day
-> (CInt -> IO DigitalCmsSpreadCoupon) -> IO DigitalCmsSpreadCoupon
forall a. Maybe Day -> (CInt -> IO a) -> IO a
withMaybeDay Maybe Day
a13 ((CInt -> IO DigitalCmsSpreadCoupon) -> IO DigitalCmsSpreadCoupon)
-> (CInt -> IO DigitalCmsSpreadCoupon) -> IO DigitalCmsSpreadCoupon
forall a b. (a -> b) -> a -> b
$ \CInt
a13' -> 
  let {a14' :: CInt
a14' = BusinessDayConvention -> CInt
forall a b. (Enum a, Integral b) => a -> b
fromEnumC BusinessDayConvention
a14} in 
  let {a15' :: CDouble
a15' = Maybe Double -> CDouble
fromMaybeDouble Maybe Double
a15} in 
  let {a16' :: CInt
a16' = PositionType -> CInt
forall a b. (Enum a, Integral b) => a -> b
fromEnumC PositionType
a16} in 
  let {a17' :: CInt
a17' = Bool -> CInt
forall a. Num a => Bool -> a
C2HSImp.fromBool Bool
a17} in 
  let {a18' :: CDouble
a18' = Maybe Double -> CDouble
fromMaybeDouble Maybe Double
a18} in 
  let {a19' :: CDouble
a19' = Maybe Double -> CDouble
fromMaybeDouble Maybe Double
a19} in 
  let {a20' :: CInt
a20' = PositionType -> CInt
forall a b. (Enum a, Integral b) => a -> b
fromEnumC PositionType
a20} in 
  let {a21' = C2HSImp.fromBool a21} in 
  let {a22' = fromMaybeDouble a22} in 
  withMaybeDigitalReplication a23 $ \a23' -> 
  let {a24' = C2HSImp.fromBool a24} in 
  preErrorCheck $ \a25' -> 
  digitalCmsSpreadCoupon'_ a1' a2' a3' a4' a5' a6' a7' a8' a9' a10' a11' a12' a13' a14' a15' a16' a17' a18' a19' a20' a21' a22' a23' a24' a25' >>= \res ->
  peekDigitalCmsSpreadCoupon res >>= \res' ->
  errorCheck  a25'>>
  return (res')

{-# LINE 1521 "./QuantLib/CashFlow.chs" #-}


-- |Build a sequence of digital CMS-rate coupons.  The options record covers all digital call/put
-- and replication choices.
digitalCmsLeg :: Schedule -> GenSwapIndex sidx -> NonEmpty Double -> DayCounter -> BusinessDayConvention -> [Word] -> [Double] -> [Double] -> Bool -> DigitalCmsLegOpts -> IO Leg
digitalCmsLeg schedule index notionals dc adjustment fixingDays gearings spreads inArrears opts =
  digitalCmsLeg_ schedule index notionals dc adjustment fixingDays gearings spreads inArrears
    (dcmlCallStrikes opts) (dcmlCallPosition opts) (dcmlCallAtm opts) (dcmlCallPayoffs opts)
    (dcmlPutStrikes opts) (dcmlPutPosition opts) (dcmlPutAtm opts) (dcmlPutPayoffs opts)
    (dcmlReplication opts) (dcmlNakedOption opts)

digitalIborLeg :: Schedule -> GenIborIndex ibor -> NonEmpty Double -> DayCounter -> BusinessDayConvention -> [Word] -> [Double] -> [Double] -> Bool -> DigitalIborLegOpts -> IO Leg
digitalIborLeg schedule index notionals dc adjustment fixingDays gearings spreads inArrears opts =
  digitalIborLeg_ schedule index notionals dc adjustment fixingDays gearings spreads inArrears (dilCallStrikes opts) (dilCallPosition opts) (dilCallAtm opts) (dilCallPayoffs opts) (dilPutStrikes opts) (dilPutPosition opts) (dilPutAtm opts) (dilPutPayoffs opts) (dilReplication opts) (dilNakedOption opts)

-- |Build a sequence of digital CMS-spread-rate coupons.  The options record covers all digital
-- call/put and replication choices, exactly as 'digitalCmsLeg' does for the plain CMS index case.
digitalCmsSpreadLeg :: Schedule -> SwapSpreadIndex -> NonEmpty Double -> DayCounter -> BusinessDayConvention -> [Word] -> [Double] -> [Double] -> Bool -> DigitalCmsSpreadLegOpts -> IO Leg
digitalCmsSpreadLeg schedule index notionals dc adjustment fixingDays gearings spreads inArrears opts =
  digitalCmsSpreadLeg_ schedule index notionals dc adjustment fixingDays gearings spreads inArrears
    (dcmslCallStrikes opts) (dcmslCallPosition opts) (dcmslCallAtm opts) (dcmslCallPayoffs opts)
    (dcmslPutStrikes opts) (dcmslPutPosition opts) (dcmslPutAtm opts) (dcmslPutPayoffs opts)
    (dcmslReplication opts) (dcmslNakedOption opts)

multipleResetsLeg :: Schedule -> GenIborIndex ibor -> Word -> DayCounter -> BusinessDayConvention -> MultipleResetsLegOpts -> IO Leg
multipleResetsLeg schedule index resets dc adjustment opts = do
  nullCalendar <- calendar Null
  multipleResetsLeg_ schedule index resets (mrlNotionals opts) dc adjustment (fromMaybe nullCalendar (mrlPaymentCalendar opts)) (mrlPaymentLag opts) (mrlFixingDays opts) (mrlGearings opts) (mrlCouponSpreads opts) (mrlRateSpreads opts) (mrlExCouponPeriod opts) (fromMaybe nullCalendar (mrlExCouponCalendar opts)) (mrlExCouponConvention opts) (mrlExCouponEndOfMonth opts) (mrlAveragingMethod opts)

digitalCmsLeg_ :: (Schedule) -> (GenSwapIndex sidx) -> (NonEmpty Double) -> (DayCounter) -> (BusinessDayConvention) -> ([Word]) -> ([Double]) -> ([Double]) -> (Bool) -> ([Double]) -> (PositionType) -> (Bool) -> ([Double]) -> ([Double]) -> (PositionType) -> (Bool) -> ([Double]) -> (Maybe DigitalReplication) -> (Bool) -> IO ((Leg))
digitalCmsLeg_ a1 a2 a3 a4 a5 a6 a7 a8 a9 a10 a11 a12 a13 a14 a15 a16 a17 a18 a19 =
  withSchedule a1 $ \a1' -> 
  withSwapIndex a2 $ \a2' -> 
  withNonEmptyDoubleArray a3 $ \(a3'1, a3'2) -> 
  withDayCounter a4 $ \a4' -> 
  let {a5' = fromEnumC a5} in 
  withIntArray a6 $ \(a6'1, a6'2) -> 
  withDoubleArray a7 $ \(a7'1, a7'2) -> 
  withDoubleArray a8 $ \(a8'1, a8'2) -> 
  let {a9' = C2HSImp.fromBool a9} in 
  withDoubleArray a10 $ \(a10'1, a10'2) -> 
  let {a11' = fromEnumC a11} in 
  let {a12' = C2HSImp.fromBool a12} in 
  withDoubleArray a13 $ \(a13'1, a13'2) -> 
  withDoubleArray a14 $ \(a14'1, a14'2) -> 
  let {a15' = fromEnumC a15} in 
  let {a16' = C2HSImp.fromBool a16} in 
  withDoubleArray a17 $ \(a17'1, a17'2) -> 
  withMaybeDigitalReplication a18 $ \a18' -> 
  let {a19' = C2HSImp.fromBool a19} in 
  preErrorCheck $ \a20' -> 
  digitalCmsLeg_'_ a1' a2' a3'1  a3'2 a4' a5' a6'1  a6'2 a7'1  a7'2 a8'1  a8'2 a9' a10'1  a10'2 a11' a12' a13'1  a13'2 a14'1  a14'2 a15' a16' a17'1  a17'2 a18' a19' a20' >>= \res ->
  peekLeg res >>= \res' ->
  errorCheck  a20'>>
  return (res')

{-# LINE 1554 "./QuantLib/CashFlow.chs" #-}

digitalIborLeg_ :: (Schedule) -> (GenIborIndex ibor) -> (NonEmpty Double) -> (DayCounter) -> (BusinessDayConvention) -> ([Word]) -> ([Double]) -> ([Double]) -> (Bool) -> ([Double]) -> (PositionType) -> (Bool) -> ([Double]) -> ([Double]) -> (PositionType) -> (Bool) -> ([Double]) -> (Maybe DigitalReplication) -> (Bool) -> IO ((Leg))
digitalIborLeg_ a1 a2 a3 a4 a5 a6 a7 a8 a9 a10 a11 a12 a13 a14 a15 a16 a17 a18 a19 =
  withSchedule a1 $ \a1' -> 
  withIborIndex a2 $ \a2' -> 
  withNonEmptyDoubleArray a3 $ \(a3'1, a3'2) -> 
  withDayCounter a4 $ \a4' -> 
  let {a5' = fromEnumC a5} in 
  withIntArray a6 $ \(a6'1, a6'2) -> 
  withDoubleArray a7 $ \(a7'1, a7'2) -> 
  withDoubleArray a8 $ \(a8'1, a8'2) -> 
  let {a9' = C2HSImp.fromBool a9} in 
  withDoubleArray a10 $ \(a10'1, a10'2) -> 
  let {a11' = fromEnumC a11} in 
  let {a12' = C2HSImp.fromBool a12} in 
  withDoubleArray a13 $ \(a13'1, a13'2) -> 
  withDoubleArray a14 $ \(a14'1, a14'2) -> 
  let {a15' = fromEnumC a15} in 
  let {a16' = C2HSImp.fromBool a16} in 
  withDoubleArray a17 $ \(a17'1, a17'2) -> 
  withMaybeDigitalReplication a18 $ \a18' -> 
  let {a19' = C2HSImp.fromBool a19} in 
  preErrorCheck $ \a20' -> 
  digitalIborLeg_'_ a1' a2' a3'1  a3'2 a4' a5' a6'1  a6'2 a7'1  a7'2 a8'1  a8'2 a9' a10'1  a10'2 a11' a12' a13'1  a13'2 a14'1  a14'2 a15' a16' a17'1  a17'2 a18' a19' a20' >>= \res ->
  peekLeg res >>= \res' ->
  errorCheck  a20'>>
  return (res')

{-# LINE 1555 "./QuantLib/CashFlow.chs" #-}

digitalCmsSpreadLeg_ :: (Schedule) -> (SwapSpreadIndex) -> (NonEmpty Double) -> (DayCounter) -> (BusinessDayConvention) -> ([Word]) -> ([Double]) -> ([Double]) -> (Bool) -> ([Double]) -> (PositionType) -> (Bool) -> ([Double]) -> ([Double]) -> (PositionType) -> (Bool) -> ([Double]) -> (Maybe DigitalReplication) -> (Bool) -> IO ((Leg))
digitalCmsSpreadLeg_ a1 a2 a3 a4 a5 a6 a7 a8 a9 a10 a11 a12 a13 a14 a15 a16 a17 a18 a19 =
  withSchedule a1 $ \a1' -> 
  withSwapSpreadIndex a2 $ \a2' -> 
  withNonEmptyDoubleArray a3 $ \(a3'1, a3'2) -> 
  withDayCounter a4 $ \a4' -> 
  let {a5' = fromEnumC a5} in 
  withIntArray a6 $ \(a6'1, a6'2) -> 
  withDoubleArray a7 $ \(a7'1, a7'2) -> 
  withDoubleArray a8 $ \(a8'1, a8'2) -> 
  let {a9' = C2HSImp.fromBool a9} in 
  withDoubleArray a10 $ \(a10'1, a10'2) -> 
  let {a11' = fromEnumC a11} in 
  let {a12' = C2HSImp.fromBool a12} in 
  withDoubleArray a13 $ \(a13'1, a13'2) -> 
  withDoubleArray a14 $ \(a14'1, a14'2) -> 
  let {a15' = fromEnumC a15} in 
  let {a16' = C2HSImp.fromBool a16} in 
  withDoubleArray a17 $ \(a17'1, a17'2) -> 
  withMaybeDigitalReplication a18 $ \a18' -> 
  let {a19' = C2HSImp.fromBool a19} in 
  preErrorCheck $ \a20' -> 
  digitalCmsSpreadLeg_'_ a1' a2' a3'1  a3'2 a4' a5' a6'1  a6'2 a7'1  a7'2 a8'1  a8'2 a9' a10'1  a10'2 a11' a12' a13'1  a13'2 a14'1  a14'2 a15' a16' a17'1  a17'2 a18' a19' a20' >>= \res ->
  peekLeg res >>= \res' ->
  errorCheck  a20'>>
  return (res')

{-# LINE 1560 "./QuantLib/CashFlow.chs" #-}

multipleResetsLeg_ :: (Schedule) -> (GenIborIndex ibor) -> (Word) -> (NonEmpty Double) -> (DayCounter) -> (BusinessDayConvention) -> (Calendar) -> (Int) -> ([Word]) -> ([Double]) -> ([Double]) -> ([Double]) -> ((Int,TimeUnit)) -> (Calendar) -> (BusinessDayConvention) -> (Bool) -> (RateAveragingType) -> IO ((Leg))
multipleResetsLeg_ a1 a2 a3 a4 a5 a6 a7 a8 a9 a10 a11 a12 a13 a14 a15 a16 a17 =
  withSchedule a1 $ \a1' -> 
  withIborIndex a2 $ \a2' -> 
  let {a3' = fromIntegral a3} in 
  withNonEmptyDoubleArray a4 $ \(a4'1, a4'2) -> 
  withDayCounter a5 $ \a5' -> 
  let {a6' = fromEnumC a6} in 
  withCalendar a7 $ \a7' -> 
  let {a8' = fromIntegral a8} in 
  withIntArray a9 $ \(a9'1, a9'2) -> 
  withDoubleArray a10 $ \(a10'1, a10'2) -> 
  withDoubleArray a11 $ \(a11'1, a11'2) -> 
  withDoubleArray a12 $ \(a12'1, a12'2) -> 
  let {(a13'1, a13'2) = fromEnumQuantity a13} in 
  withCalendar a14 $ \a14' -> 
  let {a15' = fromEnumC a15} in 
  let {a16' = C2HSImp.fromBool a16} in 
  let {a17' = fromEnumC a17} in 
  preErrorCheck $ \a18' -> 
  multipleResetsLeg_'_ a1' a2' a3' a4'1  a4'2 a5' a6' a7' a8' a9'1  a9'2 a10'1  a10'2 a11'1  a11'2 a12'1  a12'2 a13'1  a13'2 a14' a15' a16' a17' a18' >>= \res ->
  peekLeg res >>= \res' ->
  errorCheck  a18'>>
  return (res')

{-# LINE 1561 "./QuantLib/CashFlow.chs" #-}


-- |CMS-coupon pricer via static replication (Hagan's "Conundrums..."), using an analytic
-- closed-form approximation of the replication integrals.
analyticHaganPricer :: (GenSwaptionVolatilityStructure sv) -> (YieldCurveModel) -> (GenQuote q) -- ^meanReversion
 -> IO ((CmsCouponPricer))
analyticHaganPricer a1 a2 a3 =
  withSwaptionVolatilityStructure a1 $ \a1' -> 
  let {a2' = (fromIntegral . fromEnum) a2} in 
  withQuote a3 $ \a3' -> 
  preErrorCheck $ \a4' -> 
  analyticHaganPricer'_ a1' a2' a3' a4' >>= \res ->
  peekCmsCouponPricer res >>= \res' ->
  errorCheck  a4'>>
  return (res')

{-# LINE 1566 "./QuantLib/CashFlow.chs" #-}


-- |CMS-coupon pricer via static replication (Hagan's "Conundrums..."), evaluating the
-- replication integrals by numerical integration over vanilla swaption prices.
numericHaganPricer :: (GenSwaptionVolatilityStructure sv) -> (YieldCurveModel) -> (GenQuote q) -- ^meanReversion
 -> (Double) -- ^lowerLimit
 -> (Double) -- ^upperLimit
 -> (Double) -- ^precision
 -> (Double) -- ^hardUpperLimit
 -> IO ((CmsCouponPricer))
numericHaganPricer a1 a2 a3 a4 a5 a6 a7 =
  withSwaptionVolatilityStructure a1 $ \a1' -> 
  let {a2' = (fromIntegral . fromEnum) a2} in 
  withQuote a3 $ \a3' -> 
  let {a4' = realToFrac a4} in 
  let {a5' = realToFrac a5} in 
  let {a6' = realToFrac a6} in 
  let {a7' = realToFrac a7} in 
  preErrorCheck $ \a8' -> 
  numericHaganPricer'_ a1' a2' a3' a4' a5' a6' a7' a8' >>= \res ->
  peekCmsCouponPricer res >>= \res' ->
  errorCheck  a8'>>
  return (res')

{-# LINE 1575 "./QuantLib/CashFlow.chs" #-}


-- |The strategy 'LinearTsrPricer' uses to pick the integration cut-off strike bounds; each
-- carries the strategy-specific parameter upstream's corresponding @Settings::withX@ takes
-- ('LinearTsrRateBound' has none). Pass explicit bounds via 'LinearTsrPricerSettings''
-- /ltsrBounds/ rather than baking upstream's own default bounds in here, since upstream's
-- no-explicit-bounds overloads aren't just sugar for those same numbers -- they also flip
-- @Settings::defaultBounds_@, which under a normal-vol swaption surface adjusts the lower
-- bound to @min(-upperBound, lowerBound)@ (see @ql/cashflows/lineartsrpricer.cpp@). Passing
-- 'Nothing' reaches that adjustment; passing explicit bounds via 'Just' does not.
data LinearTsrPricerStrategy
  = LinearTsrRateBound
  | LinearTsrVegaRatio Double        -- ^vegaRatio
  | LinearTsrPriceThreshold Double   -- ^priceThreshold
  | LinearTsrBSStdDevs Double        -- ^stdDevs
  deriving (Int -> LinearTsrPricerStrategy -> ShowS
[LinearTsrPricerStrategy] -> ShowS
LinearTsrPricerStrategy -> String
(Int -> LinearTsrPricerStrategy -> ShowS)
-> (LinearTsrPricerStrategy -> String)
-> ([LinearTsrPricerStrategy] -> ShowS)
-> Show LinearTsrPricerStrategy
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> LinearTsrPricerStrategy -> ShowS
showsPrec :: Int -> LinearTsrPricerStrategy -> ShowS
$cshow :: LinearTsrPricerStrategy -> String
show :: LinearTsrPricerStrategy -> String
$cshowList :: [LinearTsrPricerStrategy] -> ShowS
showList :: [LinearTsrPricerStrategy] -> ShowS
Show, LinearTsrPricerStrategy -> LinearTsrPricerStrategy -> Bool
(LinearTsrPricerStrategy -> LinearTsrPricerStrategy -> Bool)
-> (LinearTsrPricerStrategy -> LinearTsrPricerStrategy -> Bool)
-> Eq LinearTsrPricerStrategy
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: LinearTsrPricerStrategy -> LinearTsrPricerStrategy -> Bool
== :: LinearTsrPricerStrategy -> LinearTsrPricerStrategy -> Bool
$c/= :: LinearTsrPricerStrategy -> LinearTsrPricerStrategy -> Bool
/= :: LinearTsrPricerStrategy -> LinearTsrPricerStrategy -> Bool
Eq)

-- |'ltsrBounds' of 'Nothing' uses upstream's own default lower\/upper rate bounds (and, for a
-- normal-vol surface, its default-bounds strike adjustment -- see 'LinearTsrPricerStrategy');
-- @'Just' (lower, upper)@ pins explicit bounds instead.
data LinearTsrPricerSettings = LinearTsrPricerSettings
  { LinearTsrPricerSettings -> LinearTsrPricerStrategy
ltsrStrategy :: LinearTsrPricerStrategy
  , LinearTsrPricerSettings -> Maybe (Double, Double)
ltsrBounds :: Maybe (Double, Double)
  } deriving (Int -> LinearTsrPricerSettings -> ShowS
[LinearTsrPricerSettings] -> ShowS
LinearTsrPricerSettings -> String
(Int -> LinearTsrPricerSettings -> ShowS)
-> (LinearTsrPricerSettings -> String)
-> ([LinearTsrPricerSettings] -> ShowS)
-> Show LinearTsrPricerSettings
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> LinearTsrPricerSettings -> ShowS
showsPrec :: Int -> LinearTsrPricerSettings -> ShowS
$cshow :: LinearTsrPricerSettings -> String
show :: LinearTsrPricerSettings -> String
$cshowList :: [LinearTsrPricerSettings] -> ShowS
showList :: [LinearTsrPricerSettings] -> ShowS
Show, LinearTsrPricerSettings -> LinearTsrPricerSettings -> Bool
(LinearTsrPricerSettings -> LinearTsrPricerSettings -> Bool)
-> (LinearTsrPricerSettings -> LinearTsrPricerSettings -> Bool)
-> Eq LinearTsrPricerSettings
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: LinearTsrPricerSettings -> LinearTsrPricerSettings -> Bool
== :: LinearTsrPricerSettings -> LinearTsrPricerSettings -> Bool
$c/= :: LinearTsrPricerSettings -> LinearTsrPricerSettings -> Bool
/= :: LinearTsrPricerSettings -> LinearTsrPricerSettings -> Bool
Eq)

-- |CMS-coupon pricer using a linear terminal swap rate model (Andersen\/Piterbarg 16.3.2).
-- /couponDiscountCurve/ of 'Nothing' uses the coupon's own discount curve, matching upstream's
-- default empty 'Handle'. The upstream constructor's trailing /integrator/ parameter (an
-- advanced numerical-integration override) is not exposed; upstream's own default
-- (@ext::shared_ptr\<Integrator\>()@) is always used.
linearTsrPricer :: GenSwaptionVolatilityStructure sv -> GenQuote q -> Maybe (GenYieldTermStructure y)
  -> LinearTsrPricerSettings -> IO CmsCouponPricer
linearTsrPricer :: forall sv q y.
GenSwaptionVolatilityStructure sv
-> GenQuote q
-> Maybe (GenYieldTermStructure y)
-> LinearTsrPricerSettings
-> IO CmsCouponPricer
linearTsrPricer GenSwaptionVolatilityStructure sv
swaptionVol GenQuote q
meanReversion Maybe (GenYieldTermStructure y)
couponDiscountCurve (LinearTsrPricerSettings LinearTsrPricerStrategy
strat Maybe (Double, Double)
bounds) =
  GenSwaptionVolatilityStructure sv
-> GenQuote q
-> Maybe (GenYieldTermStructure y)
-> Int
-> Double
-> Bool
-> Double
-> Double
-> IO CmsCouponPricer
forall sv q y.
GenSwaptionVolatilityStructure sv
-> GenQuote q
-> Maybe (GenYieldTermStructure y)
-> Int
-> Double
-> Bool
-> Double
-> Double
-> IO CmsCouponPricer
linearTsrPricer_ GenSwaptionVolatilityStructure sv
swaptionVol GenQuote q
meanReversion Maybe (GenYieldTermStructure y)
couponDiscountCurve Int
strategyTag Double
param
    (Bool
-> ((Double, Double) -> Bool) -> Maybe (Double, Double) -> Bool
forall b a. b -> (a -> b) -> Maybe a -> b
maybe Bool
False (Bool -> (Double, Double) -> Bool
forall a b. a -> b -> a
const Bool
True) Maybe (Double, Double)
bounds) Double
lowerBound Double
upperBound
  where
    (Int
strategyTag, Double
param) = case LinearTsrPricerStrategy
strat of
      LinearTsrPricerStrategy
LinearTsrRateBound        -> (LinearTsrPricerStrategyTag -> Int
forall a. Enum a => a -> Int
fromEnum LinearTsrPricerStrategyTag
LinearTsrPricerRateBound, Double
0)
      LinearTsrVegaRatio Double
p      -> (LinearTsrPricerStrategyTag -> Int
forall a. Enum a => a -> Int
fromEnum LinearTsrPricerStrategyTag
LinearTsrPricerVegaRatio, Double
p)
      LinearTsrPriceThreshold Double
p -> (LinearTsrPricerStrategyTag -> Int
forall a. Enum a => a -> Int
fromEnum LinearTsrPricerStrategyTag
LinearTsrPricerPriceThreshold, Double
p)
      LinearTsrBSStdDevs Double
p      -> (LinearTsrPricerStrategyTag -> Int
forall a. Enum a => a -> Int
fromEnum LinearTsrPricerStrategyTag
LinearTsrPricerBSStdDevs, Double
p)
    (Double
lowerBound, Double
upperBound) = (Double, Double) -> Maybe (Double, Double) -> (Double, Double)
forall a. a -> Maybe a -> a
fromMaybe (Double
0, Double
0) Maybe (Double, Double)
bounds

data LinearTsrPricerStrategyTag = LinearTsrPricerRateBound
                                | LinearTsrPricerVegaRatio
                                | LinearTsrPricerPriceThreshold
                                | LinearTsrPricerBSStdDevs
  deriving (Int -> LinearTsrPricerStrategyTag -> ShowS
[LinearTsrPricerStrategyTag] -> ShowS
LinearTsrPricerStrategyTag -> String
(Int -> LinearTsrPricerStrategyTag -> ShowS)
-> (LinearTsrPricerStrategyTag -> String)
-> ([LinearTsrPricerStrategyTag] -> ShowS)
-> Show LinearTsrPricerStrategyTag
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> LinearTsrPricerStrategyTag -> ShowS
showsPrec :: Int -> LinearTsrPricerStrategyTag -> ShowS
$cshow :: LinearTsrPricerStrategyTag -> String
show :: LinearTsrPricerStrategyTag -> String
$cshowList :: [LinearTsrPricerStrategyTag] -> ShowS
showList :: [LinearTsrPricerStrategyTag] -> ShowS
Show,LinearTsrPricerStrategyTag -> LinearTsrPricerStrategyTag -> Bool
(LinearTsrPricerStrategyTag -> LinearTsrPricerStrategyTag -> Bool)
-> (LinearTsrPricerStrategyTag
    -> LinearTsrPricerStrategyTag -> Bool)
-> Eq LinearTsrPricerStrategyTag
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: LinearTsrPricerStrategyTag -> LinearTsrPricerStrategyTag -> Bool
== :: LinearTsrPricerStrategyTag -> LinearTsrPricerStrategyTag -> Bool
$c/= :: LinearTsrPricerStrategyTag -> LinearTsrPricerStrategyTag -> Bool
/= :: LinearTsrPricerStrategyTag -> LinearTsrPricerStrategyTag -> Bool
Eq,ReadPrec [LinearTsrPricerStrategyTag]
ReadPrec LinearTsrPricerStrategyTag
Int -> ReadS LinearTsrPricerStrategyTag
ReadS [LinearTsrPricerStrategyTag]
(Int -> ReadS LinearTsrPricerStrategyTag)
-> ReadS [LinearTsrPricerStrategyTag]
-> ReadPrec LinearTsrPricerStrategyTag
-> ReadPrec [LinearTsrPricerStrategyTag]
-> Read LinearTsrPricerStrategyTag
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
$creadsPrec :: Int -> ReadS LinearTsrPricerStrategyTag
readsPrec :: Int -> ReadS LinearTsrPricerStrategyTag
$creadList :: ReadS [LinearTsrPricerStrategyTag]
readList :: ReadS [LinearTsrPricerStrategyTag]
$creadPrec :: ReadPrec LinearTsrPricerStrategyTag
readPrec :: ReadPrec LinearTsrPricerStrategyTag
$creadListPrec :: ReadPrec [LinearTsrPricerStrategyTag]
readListPrec :: ReadPrec [LinearTsrPricerStrategyTag]
Read)
instance Enum LinearTsrPricerStrategyTag where
  succ LinearTsrPricerRateBound = LinearTsrPricerVegaRatio
  succ LinearTsrPricerVegaRatio = LinearTsrPricerPriceThreshold
  succ LinearTsrPricerPriceThreshold = LinearTsrPricerBSStdDevs
  succ LinearTsrPricerBSStdDevs = error "LinearTsrPricerStrategyTag.succ: LinearTsrPricerBSStdDevs has no successor"

  pred :: LinearTsrPricerStrategyTag -> LinearTsrPricerStrategyTag
pred LinearTsrPricerStrategyTag
LinearTsrPricerVegaRatio = LinearTsrPricerStrategyTag
LinearTsrPricerRateBound
  pred LinearTsrPricerStrategyTag
LinearTsrPricerPriceThreshold = LinearTsrPricerStrategyTag
LinearTsrPricerVegaRatio
  pred LinearTsrPricerStrategyTag
LinearTsrPricerBSStdDevs = LinearTsrPricerStrategyTag
LinearTsrPricerPriceThreshold
  pred LinearTsrPricerStrategyTag
LinearTsrPricerRateBound = String -> LinearTsrPricerStrategyTag
forall a. HasCallStack => String -> a
error String
"LinearTsrPricerStrategyTag.pred: LinearTsrPricerRateBound has no predecessor"

  enumFromTo from to = go from
    where
      end = fromEnum to
      go v = case compare (fromEnum v) end of
                 LT -> v : go (succ v)
                 EQ -> [v]
                 GT -> []

  enumFrom from = enumFromTo from LinearTsrPricerBSStdDevs

  fromEnum LinearTsrPricerRateBound = 0
  fromEnum LinearTsrPricerVegaRatio = 1
  fromEnum LinearTsrPricerPriceThreshold = 2
  fromEnum LinearTsrPricerBSStdDevs = 3

  toEnum 0 = LinearTsrPricerRateBound
  toEnum 1 = LinearTsrPricerVegaRatio
  toEnum 2 = LinearTsrPricerPriceThreshold
  toEnum 3 = LinearTsrPricerBSStdDevs
  toEnum unmatched = error ("LinearTsrPricerStrategyTag.toEnum: Cannot match " ++ show unmatched)

{-# LINE 1618 "./QuantLib/CashFlow.chs" #-}


-- |Raw binding for 'linearTsrPricer', taking the 'LinearTsrPricerSettings' unpacked into a
-- strategy tag\/parameter and an explicit-bounds flag.
linearTsrPricer_ :: (GenSwaptionVolatilityStructure sv) -> (GenQuote q) -- ^meanReversion
 -> (Maybe (GenYieldTermStructure y)) -- ^couponDiscountCurve
 -> (Int) -- ^strategy tag, see 'LinearTsrPricerStrategyTag'
 -> (Double) -- ^strategy-specific parameter (unused for RateBound)
 -> (Bool) -- ^haveBounds
 -> (Double) -- ^lowerBound (ignored unless haveBounds)
 -> (Double) -- ^upperBound (ignored unless haveBounds)
 -> IO ((CmsCouponPricer))
linearTsrPricer_ a1 a2 a3 a4 a5 a6 a7 a8 =
  withSwaptionVolatilityStructure a1 $ \a1' -> 
  withQuote a2 $ \a2' -> 
  withMaybeYieldTermStructure a3 $ \a3' -> 
  let {a4' = fromIntegral a4} in 
  let {a5' = realToFrac a5} in 
  let {a6' = C2HSImp.fromBool a6} in 
  let {a7' = realToFrac a7} in 
  let {a8' = realToFrac a8} in 
  preErrorCheck $ \a9' -> 
  linearTsrPricer_'_ a1' a2' a3' a4' a5' a6' a7' a8' a9' >>= \res ->
  peekCmsCouponPricer res >>= \res' ->
  errorCheck  a9'>>
  return (res')

{-# LINE 1629 "./QuantLib/CashFlow.chs" #-}


-- |CMS-spread pricer using the Brigo--Mercurio bivariate model, with extensions for shifted
-- lognormal and normal dynamics.  /volatilityType/ of 'Nothing' inherits the type and shifts
-- from the component swaption volatility structures; in that case both shifts must be 'Nothing'.
lognormalCmsSpreadPricer :: CmsCouponPricer -> GenQuote q -> Maybe (GenYieldTermStructure y) -> Word
  -> Maybe VolatilityType -> Maybe Double -> Maybe Double -> IO FloatingRateCouponPricer
lognormalCmsSpreadPricer cmsPricer correlation discountCurve integrationPoints volatilityType shift1 shift2 =
  lognormalCmsSpreadPricer_ cmsPricer correlation discountCurve integrationPoints
    (maybe False (const True) volatilityType) (maybe 0 fromEnum volatilityType) shift1 shift2

lognormalCmsSpreadPricer_ :: (CmsCouponPricer) -> (GenQuote q) -> (Maybe (GenYieldTermStructure y)) -> (Word) -> (Bool) -> (Int) -> (Maybe Double) -> (Maybe Double) -> IO ((FloatingRateCouponPricer))
lognormalCmsSpreadPricer_ a1 a2 a3 a4 a5 a6 a7 a8 =
  withCmsCouponPricer a1 $ \a1' -> 
  withQuote a2 $ \a2' -> 
  withMaybeYieldTermStructure a3 $ \a3' -> 
  let {a4' = fromIntegral a4} in 
  let {a5' = C2HSImp.fromBool a5} in 
  let {a6' = fromIntegral a6} in 
  let {a7' = fromMaybeDouble a7} in 
  let {a8' = fromMaybeDouble a8} in 
  preErrorCheck $ \a9' -> 
  lognormalCmsSpreadPricer_'_ a1' a2' a3' a4' a5' a6' a7' a8' a9' >>= \res ->
  peekFloatingRateCouponPricer res >>= \res' ->
  errorCheck  a9'>>
  return (res')

{-# LINE 1642 "./QuantLib/CashFlow.chs" #-}


-- |Coupon types that expose the dates of their component index fixings.
-- |Every fixing the cash flows of this leg need, as @(index name, fixing date)@ pairs in leg
-- order.  QuantLib has no @requiredFixings@ query, so this walks the leg itself, unwrapping
-- decorating coupons (capped\/floored, stripped, digital) and asking each coupon for its own
-- fixing dates: one for an Ibor, CMS or CMS-spread coupon, one per averaged date for an
-- overnight, BMA or multiple-resets coupon, and the fixing and base dates for an inflation
-- coupon or an index-linked payment.  A CMS-spread coupon reports its two underlying swap
-- indexes rather than the spread index, because that is where the fixings are stored.  Names
-- are 'QuantLib.Index.name', the key QuantLib\'s process-global fixing store uses.  A cash flow
-- that needs no fixing -- a redemption, a fixed-rate coupon -- contributes nothing.  Duplicates
-- are not removed: two coupons may fix the same index on the same date.
fixingDependencies :: GenLeg l -> IO [(String, Day)]
fixingDependencies l = uncurry zip <$> qlLegFixingDependencies l
qlLegFixingDependencies :: (GenLeg l) -> IO (([String]), ([Day]))
qlLegFixingDependencies :: forall l. GenLeg l -> IO ([String], [Day])
qlLegFixingDependencies GenLeg l
a1 =
  GenLeg l
-> (Ptr CLeg' -> IO ([String], [Day])) -> IO ([String], [Day])
forall l b. GenLeg l -> (Ptr CLeg' -> IO b) -> IO b
withLeg GenLeg l
a1 ((Ptr CLeg' -> IO ([String], [Day])) -> IO ([String], [Day]))
-> (Ptr CLeg' -> IO ([String], [Day])) -> IO ([String], [Day])
forall a b. (a -> b) -> a -> b
$ \Ptr CLeg'
a1' -> 
  ((Ptr CUInt, Ptr (Ptr (Ptr CChar))) -> IO ([String], [Day]))
-> IO ([String], [Day])
forall a b. ((Ptr CUInt, Ptr (Ptr a)) -> IO b) -> IO b
preArray (((Ptr CUInt, Ptr (Ptr (Ptr CChar))) -> IO ([String], [Day]))
 -> IO ([String], [Day]))
-> ((Ptr CUInt, Ptr (Ptr (Ptr CChar))) -> IO ([String], [Day]))
-> IO ([String], [Day])
forall a b. (a -> b) -> a -> b
$ \(Ptr CUInt
a2'1, Ptr (Ptr (Ptr CChar))
a2'2) -> 
  ((Ptr CUInt, Ptr (Ptr CInt)) -> IO ([String], [Day]))
-> IO ([String], [Day])
forall a b. ((Ptr CUInt, Ptr (Ptr a)) -> IO b) -> IO b
preArray (((Ptr CUInt, Ptr (Ptr CInt)) -> IO ([String], [Day]))
 -> IO ([String], [Day]))
-> ((Ptr CUInt, Ptr (Ptr CInt)) -> IO ([String], [Day]))
-> IO ([String], [Day])
forall a b. (a -> b) -> a -> b
$ \(Ptr CUInt
a3'1, Ptr (Ptr CInt)
a3'2) -> 
  (Ptr (Ptr CChar) -> IO ([String], [Day])) -> IO ([String], [Day])
forall a b. (Ptr (Ptr a) -> IO b) -> IO b
preErrorCheck ((Ptr (Ptr CChar) -> IO ([String], [Day])) -> IO ([String], [Day]))
-> (Ptr (Ptr CChar) -> IO ([String], [Day]))
-> IO ([String], [Day])
forall a b. (a -> b) -> a -> b
$ \Ptr (Ptr CChar)
a4' -> 
  Ptr CLeg'
-> Ptr CUInt
-> Ptr (Ptr (Ptr CChar))
-> Ptr CUInt
-> Ptr (Ptr CInt)
-> Ptr (Ptr CChar)
-> IO ()
qlLegFixingDependencies'_ Ptr CLeg'
a1' Ptr CUInt
a2'1  Ptr (Ptr (Ptr CChar))
a2'2 Ptr CUInt
a3'1  Ptr (Ptr CInt)
a3'2 Ptr (Ptr CChar)
a4' IO () -> IO [String] -> IO [String]
forall a b. IO a -> IO b -> IO b
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>>
  Ptr CUInt -> Ptr (Ptr (Ptr CChar)) -> IO [String]
peekCStringArray  Ptr CUInt
a2'1  Ptr (Ptr (Ptr CChar))
a2'2IO [String]
-> ([String] -> IO ([String], [Day])) -> IO ([String], [Day])
forall a b. IO a -> (a -> IO b) -> IO b
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= \[String]
a2'' -> 
  Ptr CUInt -> Ptr (Ptr CInt) -> IO [Day]
peekDayArray  Ptr CUInt
a3'1  Ptr (Ptr CInt)
a3'2IO [Day] -> ([Day] -> IO ([String], [Day])) -> IO ([String], [Day])
forall a b. IO a -> (a -> IO b) -> IO b
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= \a3'' -> 
  Ptr (Ptr CChar) -> IO ()
errorCheck  Ptr (Ptr CChar)
a4'IO () -> IO ([String], [Day]) -> IO ([String], [Day])
forall a b. IO a -> IO b -> IO b
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>>
  ([String], [Day]) -> IO ([String], [Day])
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return ([String]
a2'', [Day]
a3'')

{-# LINE 1659 "./QuantLib/CashFlow.chs" #-}


class HasFixingDates coupon where
  fixingDates :: coupon -> IO [Day]

instance HasFixingDates AverageBMACoupon where
  fixingDates = averageBmaCouponFixingDatesRaw
instance HasFixingDates MultipleResetsCoupon where
  fixingDates = multipleResetsCouponFixingDatesRaw
instance HasFixingDates OvernightIndexedCoupon where
  fixingDates = overnightIndexedCouponFixingDatesRaw

-- |Coupon types that expose their component index fixings.
class HasIndexFixings coupon where
  indexFixings :: coupon -> IO [Double]

instance HasIndexFixings AverageBMACoupon where
  indexFixings :: AverageBMACoupon -> IO [Double]
indexFixings = AverageBMACoupon -> IO [Double]
averageBmaCouponIndexFixingsRaw
instance HasIndexFixings OvernightIndexedCoupon where
  indexFixings :: OvernightIndexedCoupon -> IO [Double]
indexFixings = OvernightIndexedCoupon -> IO [Double]
overnightIndexedCouponIndexFixingsRaw

-- vim: set ff=unix ts=8 sts=2 sw=2 et:

foreign import ccall safe "QuantLib/CashFlow.chs.h qlLeg"
  qlLeg'_ :: (C2HSImp.CUInt -> ((C2HSImp.Ptr C2HSImp.CDouble) -> ((C2HSImp.Ptr C2HSImp.CInt) -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO (C2HSImp.Ptr (CLeg')))))))

foreign import ccall safe "QuantLib/CashFlow.chs.h qlSimpleCashFlow"
  simpleCashFlow'_ :: (C2HSImp.CDouble -> (C2HSImp.CInt -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO (C2HSImp.Ptr (CCashFlow'))))))

foreign import ccall safe "QuantLib/CashFlow.chs.h qlCashFlowAmount"
  amount'_ :: ((C2HSImp.Ptr (CCashFlow')) -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO C2HSImp.CDouble)))

foreign import ccall safe "QuantLib/CashFlow.chs.h qlCashFlowDate"
  date'_ :: ((C2HSImp.Ptr (CCashFlow')) -> (IO C2HSImp.CInt))

foreign import ccall safe "QuantLib/CashFlow.chs.h qlIndexedCashFlow"
  indexedCashFlow'_ :: (C2HSImp.CDouble -> ((C2HSImp.Ptr (CIndex')) -> (C2HSImp.CInt -> (C2HSImp.CInt -> (C2HSImp.CInt -> (C2HSImp.CInt -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO (C2HSImp.Ptr (CIndexedCashFlow'))))))))))

foreign import ccall safe "QuantLib/CashFlow.chs.h qlIndexedCashFlowBaseFixing"
  baseFixing'_ :: ((C2HSImp.Ptr (CIndexedCashFlow')) -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO C2HSImp.CDouble)))

foreign import ccall safe "QuantLib/CashFlow.chs.h qlIndexedCashFlowIndexFixing"
  indexFixing'_ :: ((C2HSImp.Ptr (CIndexedCashFlow')) -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO C2HSImp.CDouble)))

foreign import ccall safe "QuantLib/CashFlow.chs.h qlFixedRateCoupon"
  fixedRateCoupon'_ :: (C2HSImp.CInt -> (C2HSImp.CDouble -> (C2HSImp.CDouble -> ((C2HSImp.Ptr (CDayCounter)) -> (C2HSImp.CInt -> (C2HSImp.CInt -> (C2HSImp.CInt -> (C2HSImp.CInt -> (C2HSImp.CInt -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO (C2HSImp.Ptr (CFixedRateCoupon')))))))))))))

foreign import ccall safe "QuantLib/CashFlow.chs.h qlFixedRateCouponInterestRate"
  interestRate'_ :: ((C2HSImp.Ptr (CFixedRateCoupon')) -> (IO (C2HSImp.Ptr (CInterestRate))))

foreign import ccall safe "QuantLib/CashFlow.chs.h qlFloatingRateCoupon"
  floatingRateCoupon'_ :: (C2HSImp.CInt -> (C2HSImp.CDouble -> (C2HSImp.CInt -> (C2HSImp.CInt -> (C2HSImp.CUInt -> ((C2HSImp.Ptr (CInterestRateIndex')) -> (C2HSImp.CDouble -> (C2HSImp.CDouble -> (C2HSImp.CInt -> (C2HSImp.CInt -> ((C2HSImp.Ptr (CDayCounter)) -> (C2HSImp.CInt -> (C2HSImp.CInt -> (C2HSImp.CInt -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO (C2HSImp.Ptr (CFloatingRateCoupon'))))))))))))))))))

foreign import ccall safe "QuantLib/CashFlow.chs.h qlIborCouponExact"
  iborCoupon'_ :: (C2HSImp.CInt -> (C2HSImp.CDouble -> (C2HSImp.CInt -> (C2HSImp.CInt -> (C2HSImp.CUInt -> ((C2HSImp.Ptr (CIborIndex')) -> (C2HSImp.CDouble -> (C2HSImp.CDouble -> (C2HSImp.CInt -> (C2HSImp.CInt -> ((C2HSImp.Ptr (CDayCounter)) -> (C2HSImp.CInt -> (C2HSImp.CInt -> (C2HSImp.CInt -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO (C2HSImp.Ptr (CIborCoupon'))))))))))))))))))

foreign import ccall safe "QuantLib/CashFlow.chs.h qlAverageBMACoupon"
  averageBmaCoupon'_ :: (C2HSImp.CInt -> (C2HSImp.CDouble -> (C2HSImp.CInt -> (C2HSImp.CInt -> ((C2HSImp.Ptr (CBMAIndex')) -> (C2HSImp.CDouble -> (C2HSImp.CDouble -> (C2HSImp.CInt -> (C2HSImp.CInt -> ((C2HSImp.Ptr (CDayCounter)) -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO (C2HSImp.Ptr (CAverageBMACoupon'))))))))))))))

foreign import ccall safe "QuantLib/CashFlow.chs.h qlAverageBMACouponFixingDates"
  averageBmaCouponFixingDatesRaw'_ :: ((C2HSImp.Ptr (CAverageBMACoupon')) -> ((C2HSImp.Ptr C2HSImp.CUInt) -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CInt)) -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO ())))))

foreign import ccall safe "QuantLib/CashFlow.chs.h qlAverageBMACouponIndexFixings"
  averageBmaCouponIndexFixingsRaw'_ :: ((C2HSImp.Ptr (CAverageBMACoupon')) -> ((C2HSImp.Ptr C2HSImp.CUInt) -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CDouble)) -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO ())))))

foreign import ccall safe "QuantLib/CashFlow.chs.h qlCappedFlooredCoupon"
  cappedFlooredCoupon'_ :: ((C2HSImp.Ptr (CFloatingRateCoupon')) -> (C2HSImp.CDouble -> (C2HSImp.CDouble -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO (C2HSImp.Ptr (CFloatingRateCoupon')))))))

foreign import ccall safe "QuantLib/CashFlow.chs.h qlStrippedCappedFlooredCoupon"
  strippedCappedFlooredCoupon'_ :: ((C2HSImp.Ptr (CFloatingRateCoupon')) -> (C2HSImp.CDouble -> (C2HSImp.CDouble -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO (C2HSImp.Ptr (CStrippedCappedFlooredCoupon')))))))

foreign import ccall safe "QuantLib/CashFlow.chs.h qlStrippedCappedFlooredCouponCap"
  capRate'_ :: ((C2HSImp.Ptr (CStrippedCappedFlooredCoupon')) -> (IO C2HSImp.CDouble))

foreign import ccall safe "QuantLib/CashFlow.chs.h qlStrippedCappedFlooredCouponFloor"
  floorRate'_ :: ((C2HSImp.Ptr (CStrippedCappedFlooredCoupon')) -> (IO C2HSImp.CDouble))

foreign import ccall safe "QuantLib/CashFlow.chs.h qlStrippedCappedFlooredCouponEffectiveCap"
  effectiveCap'_ :: ((C2HSImp.Ptr (CStrippedCappedFlooredCoupon')) -> (IO C2HSImp.CDouble))

foreign import ccall safe "QuantLib/CashFlow.chs.h qlStrippedCappedFlooredCouponEffectiveFloor"
  effectiveFloor'_ :: ((C2HSImp.Ptr (CStrippedCappedFlooredCoupon')) -> (IO C2HSImp.CDouble))

foreign import ccall safe "QuantLib/CashFlow.chs.h qlStrippedCappedFlooredCouponIsCap"
  isCap'_ :: ((C2HSImp.Ptr (CStrippedCappedFlooredCoupon')) -> (IO C2HSImp.CInt))

foreign import ccall safe "QuantLib/CashFlow.chs.h qlStrippedCappedFlooredCouponIsFloor"
  isFloor'_ :: ((C2HSImp.Ptr (CStrippedCappedFlooredCoupon')) -> (IO C2HSImp.CInt))

foreign import ccall safe "QuantLib/CashFlow.chs.h qlStrippedCappedFlooredCouponIsCollar"
  isCollar'_ :: ((C2HSImp.Ptr (CStrippedCappedFlooredCoupon')) -> (IO C2HSImp.CInt))

foreign import ccall safe "QuantLib/CashFlow.chs.h qlCappedFlooredIborCoupon"
  cappedFlooredIborCoupon'_ :: (C2HSImp.CInt -> (C2HSImp.CDouble -> (C2HSImp.CInt -> (C2HSImp.CInt -> (C2HSImp.CUInt -> ((C2HSImp.Ptr (CIborIndex')) -> (C2HSImp.CDouble -> (C2HSImp.CDouble -> (C2HSImp.CDouble -> (C2HSImp.CDouble -> (C2HSImp.CInt -> (C2HSImp.CInt -> ((C2HSImp.Ptr (CDayCounter)) -> (C2HSImp.CInt -> (C2HSImp.CInt -> (C2HSImp.CInt -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO (C2HSImp.Ptr (CFloatingRateCoupon'))))))))))))))))))))

foreign import ccall safe "QuantLib/CashFlow.chs.h qlDigitalIborCoupon"
  digitalIborCoupon'_ :: ((C2HSImp.Ptr (CIborCoupon')) -> (C2HSImp.CDouble -> (C2HSImp.CInt -> (C2HSImp.CInt -> (C2HSImp.CDouble -> (C2HSImp.CDouble -> (C2HSImp.CInt -> (C2HSImp.CInt -> (C2HSImp.CDouble -> ((C2HSImp.Ptr (CDigitalReplication)) -> (C2HSImp.CInt -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO (C2HSImp.Ptr (CDigitalCoupon')))))))))))))))

foreign import ccall safe "QuantLib/CashFlow.chs.h qlDigitalCoupon"
  digitalCoupon'_ :: ((C2HSImp.Ptr (CFloatingRateCoupon')) -> (C2HSImp.CDouble -> (C2HSImp.CInt -> (C2HSImp.CInt -> (C2HSImp.CDouble -> (C2HSImp.CDouble -> (C2HSImp.CInt -> (C2HSImp.CInt -> (C2HSImp.CDouble -> ((C2HSImp.Ptr (CDigitalReplication)) -> (C2HSImp.CInt -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO (C2HSImp.Ptr (CDigitalCoupon')))))))))))))))

foreign import ccall safe "QuantLib/CashFlow.chs.h qlDigitalCouponCallOptionRate"
  callOptionRate'_ :: ((C2HSImp.Ptr (CDigitalCoupon')) -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO C2HSImp.CDouble)))

foreign import ccall safe "QuantLib/CashFlow.chs.h qlDigitalCouponPutOptionRate"
  putOptionRate'_ :: ((C2HSImp.Ptr (CDigitalCoupon')) -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO C2HSImp.CDouble)))

foreign import ccall safe "QuantLib/CashFlow.chs.h qlMultipleResetsCoupon"
  multipleResetsCoupon'_ :: (C2HSImp.CInt -> (C2HSImp.CDouble -> ((C2HSImp.Ptr (CSchedule)) -> (C2HSImp.CUInt -> ((C2HSImp.Ptr (CIborIndex')) -> (C2HSImp.CDouble -> (C2HSImp.CDouble -> (C2HSImp.CDouble -> (C2HSImp.CInt -> (C2HSImp.CInt -> ((C2HSImp.Ptr (CDayCounter)) -> (C2HSImp.CInt -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO (C2HSImp.Ptr (CMultipleResetsCoupon'))))))))))))))))

foreign import ccall safe "QuantLib/CashFlow.chs.h qlMultipleResetsCouponFixingDates"
  multipleResetsCouponFixingDatesRaw'_ :: ((C2HSImp.Ptr (CMultipleResetsCoupon')) -> ((C2HSImp.Ptr C2HSImp.CUInt) -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CInt)) -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO ())))))

foreign import ccall safe "QuantLib/CashFlow.chs.h qlRangeAccrualFloatersCoupon"
  rangeAccrualFloatersCoupon'_ :: (C2HSImp.CInt -> (C2HSImp.CDouble -> ((C2HSImp.Ptr (CIborIndex')) -> (C2HSImp.CInt -> (C2HSImp.CInt -> (C2HSImp.CUInt -> ((C2HSImp.Ptr (CDayCounter)) -> (C2HSImp.CDouble -> (C2HSImp.CDouble -> (C2HSImp.CInt -> (C2HSImp.CInt -> ((C2HSImp.Ptr (CSchedule)) -> (C2HSImp.CDouble -> (C2HSImp.CDouble -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO (C2HSImp.Ptr (CRangeAccrualFloatersCoupon'))))))))))))))))))

foreign import ccall safe "QuantLib/CashFlow.chs.h qlRangeAccrualFloatersCouponPriceWithoutOptionality"
  priceWithoutOptionality'_ :: ((C2HSImp.Ptr (CRangeAccrualFloatersCoupon')) -> ((C2HSImp.Ptr (CYieldTermStructure')) -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO C2HSImp.CDouble))))

foreign import ccall safe "QuantLib/CashFlow.chs.h qlYoYInflationCoupon"
  yoyInflationCoupon'_ :: (C2HSImp.CInt -> (C2HSImp.CDouble -> (C2HSImp.CInt -> (C2HSImp.CInt -> (C2HSImp.CUInt -> ((C2HSImp.Ptr (CYoYInflationIndex')) -> (C2HSImp.CInt -> (C2HSImp.CInt -> (C2HSImp.CInt -> ((C2HSImp.Ptr (CDayCounter)) -> (C2HSImp.CDouble -> (C2HSImp.CDouble -> (C2HSImp.CInt -> (C2HSImp.CInt -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO (C2HSImp.Ptr (CYoYInflationCoupon'))))))))))))))))))

foreign import ccall safe "QuantLib/CashFlow.chs.h qlYoYInflationCouponAdjustedFixing"
  adjustedFixing'_ :: ((C2HSImp.Ptr (CYoYInflationCoupon')) -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO C2HSImp.CDouble)))

foreign import ccall safe "QuantLib/CashFlow.chs.h qlAveragingMultipleResetsPricer"
  averagingMultipleResetsPricer'_ :: ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO (C2HSImp.Ptr (CFloatingRateCouponPricer'))))

foreign import ccall safe "QuantLib/CashFlow.chs.h qlCompoundingMultipleResetsPricer"
  compoundingMultipleResetsPricer'_ :: ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO (C2HSImp.Ptr (CFloatingRateCouponPricer'))))

foreign import ccall safe "QuantLib/CashFlow.chs.h qlOvernightIndexedCoupon"
  overnightIndexedCoupon'_ :: (C2HSImp.CInt -> (C2HSImp.CDouble -> (C2HSImp.CInt -> (C2HSImp.CInt -> ((C2HSImp.Ptr (COvernightIndex')) -> (C2HSImp.CDouble -> (C2HSImp.CDouble -> (C2HSImp.CInt -> (C2HSImp.CInt -> ((C2HSImp.Ptr (CDayCounter)) -> (C2HSImp.CInt -> (C2HSImp.CInt -> (C2HSImp.CUInt -> (C2HSImp.CUInt -> (C2HSImp.CInt -> (C2HSImp.CInt -> (C2HSImp.CInt -> (C2HSImp.CInt -> (C2HSImp.CInt -> (C2HSImp.CInt -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO (C2HSImp.Ptr (COvernightIndexedCoupon'))))))))))))))))))))))))

foreign import ccall safe "QuantLib/CashFlow.chs.h qlOvernightIndexedCouponFixingDates"
  overnightIndexedCouponFixingDatesRaw'_ :: ((C2HSImp.Ptr (COvernightIndexedCoupon')) -> ((C2HSImp.Ptr C2HSImp.CUInt) -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CInt)) -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO ())))))

foreign import ccall safe "QuantLib/CashFlow.chs.h qlOvernightIndexedCouponIndexFixings"
  overnightIndexedCouponIndexFixingsRaw'_ :: ((C2HSImp.Ptr (COvernightIndexedCoupon')) -> ((C2HSImp.Ptr C2HSImp.CUInt) -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CDouble)) -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO ())))))

foreign import ccall safe "QuantLib/CashFlow.chs.h qlCappedFlooredOvernightIndexedCoupon"
  cappedFlooredOvernightIndexedCoupon'_ :: ((C2HSImp.Ptr (COvernightIndexedCoupon')) -> (C2HSImp.CDouble -> (C2HSImp.CDouble -> (C2HSImp.CInt -> (C2HSImp.CInt -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO (C2HSImp.Ptr (CFloatingRateCoupon')))))))))

foreign import ccall safe "QuantLib/CashFlow.chs.h qlCompoundingOvernightIndexedCouponPricer"
  compoundingOvernightIndexedCouponPricer'_ :: ((C2HSImp.Ptr (COptionletVolatilityStructure')) -> (C2HSImp.CInt -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO (C2HSImp.Ptr (CFloatingRateCouponPricer'))))))

foreign import ccall safe "QuantLib/CashFlow.chs.h qlArithmeticAveragedOvernightIndexedCouponPricer"
  arithmeticAveragedOvernightIndexedCouponPricer'_ :: (C2HSImp.CDouble -> (C2HSImp.CDouble -> (C2HSImp.CInt -> ((C2HSImp.Ptr (COptionletVolatilityStructure')) -> (C2HSImp.CInt -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO (C2HSImp.Ptr (CFloatingRateCouponPricer')))))))))

foreign import ccall safe "QuantLib/CashFlow.chs.h qlBlackCompoundingOvernightIndexedCouponPricer"
  blackCompoundingOvernightIndexedCouponPricer'_ :: ((C2HSImp.Ptr (COptionletVolatilityStructure')) -> (C2HSImp.CInt -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO (C2HSImp.Ptr (CFloatingRateCouponPricer'))))))

foreign import ccall safe "QuantLib/CashFlow.chs.h qlBlackAveragingOvernightIndexedCouponPricer"
  blackAveragingOvernightIndexedCouponPricer'_ :: ((C2HSImp.Ptr (COptionletVolatilityStructure')) -> (C2HSImp.CInt -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO (C2HSImp.Ptr (CFloatingRateCouponPricer'))))))

foreign import ccall safe "QuantLib/CashFlow.chs.h qlCPICoupon"
  cpiCoupon'_ :: (C2HSImp.CDouble -> (C2HSImp.CInt -> (C2HSImp.CDouble -> (C2HSImp.CInt -> (C2HSImp.CInt -> ((C2HSImp.Ptr (CZeroInflationIndex')) -> (C2HSImp.CInt -> (C2HSImp.CInt -> (C2HSImp.CInt -> ((C2HSImp.Ptr (CDayCounter)) -> (C2HSImp.CDouble -> (C2HSImp.CInt -> (C2HSImp.CInt -> (C2HSImp.CInt -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO (C2HSImp.Ptr (CCPICoupon'))))))))))))))))))

foreign import ccall safe "QuantLib/CashFlow.chs.h qlCPICouponFromBaseDate"
  cpiCouponFromBaseDate'_ :: (C2HSImp.CInt -> (C2HSImp.CInt -> (C2HSImp.CDouble -> (C2HSImp.CInt -> (C2HSImp.CInt -> ((C2HSImp.Ptr (CZeroInflationIndex')) -> (C2HSImp.CInt -> (C2HSImp.CInt -> (C2HSImp.CInt -> ((C2HSImp.Ptr (CDayCounter)) -> (C2HSImp.CDouble -> (C2HSImp.CInt -> (C2HSImp.CInt -> (C2HSImp.CInt -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO (C2HSImp.Ptr (CCPICoupon'))))))))))))))))))

foreign import ccall safe "QuantLib/CashFlow.chs.h qlCPICouponWithBaseDate"
  cpiCouponWithBaseDate'_ :: (C2HSImp.CDouble -> (C2HSImp.CInt -> (C2HSImp.CInt -> (C2HSImp.CDouble -> (C2HSImp.CInt -> (C2HSImp.CInt -> ((C2HSImp.Ptr (CZeroInflationIndex')) -> (C2HSImp.CInt -> (C2HSImp.CInt -> (C2HSImp.CInt -> ((C2HSImp.Ptr (CDayCounter)) -> (C2HSImp.CDouble -> (C2HSImp.CInt -> (C2HSImp.CInt -> (C2HSImp.CInt -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO (C2HSImp.Ptr (CCPICoupon')))))))))))))))))))

foreign import ccall safe "QuantLib/CashFlow.chs.h qlCPICouponPricer"
  cpiCouponPricer'_ :: ((C2HSImp.Ptr (CYieldTermStructure')) -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO (C2HSImp.Ptr (CCPICouponPricer)))))

foreign import ccall safe "QuantLib/CashFlow.chs.h qlCPICouponPricerWithVol"
  cpiCouponPricerWithVol'_ :: ((C2HSImp.Ptr (CCPIVolatilitySurface')) -> ((C2HSImp.Ptr (CYieldTermStructure')) -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO (C2HSImp.Ptr (CCPICouponPricer))))))

foreign import ccall safe "QuantLib/CashFlow.chs.h qlCPICouponSetPricer"
  setCpiCouponPricer'_ :: ((C2HSImp.Ptr (CCPICoupon')) -> ((C2HSImp.Ptr (CCPICouponPricer)) -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO ()))))

foreign import ccall safe "QuantLib/CashFlow.chs.h qlCPICouponIndexRatio"
  indexRatio'_ :: ((C2HSImp.Ptr (CCPICoupon')) -> (C2HSImp.CInt -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO C2HSImp.CDouble))))

foreign import ccall safe "QuantLib/CashFlow.chs.h qlRedemption"
  redemption'_ :: (C2HSImp.CDouble -> (C2HSImp.CInt -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO (C2HSImp.Ptr (CCashFlow'))))))

foreign import ccall safe "QuantLib/CashFlow.chs.h qlAmortizingPayment"
  amortizingPayment'_ :: (C2HSImp.CDouble -> (C2HSImp.CInt -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO (C2HSImp.Ptr (CCashFlow'))))))

foreign import ccall safe "QuantLib/CashFlow.chs.h qlCashFlowLeg"
  cashFlowLeg'_ :: (C2HSImp.CUInt -> ((C2HSImp.Ptr (C2HSImp.Ptr (CCashFlow'))) -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO (C2HSImp.Ptr (CLeg'))))))

foreign import ccall safe "QuantLib/CashFlow.chs.h qlLegStartDate"
  startDate'_ :: ((C2HSImp.Ptr (CLeg')) -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO C2HSImp.CInt)))

foreign import ccall safe "QuantLib/CashFlow.chs.h qlNextCashFlows"
  nextCashFlows'_ :: ((C2HSImp.Ptr (CLeg')) -> (C2HSImp.CInt -> (C2HSImp.CInt -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO (C2HSImp.Ptr (CLeg')))))))

foreign import ccall safe "QuantLib/CashFlow.chs.h qlPreviousCashFlows"
  previousCashFlows'_ :: ((C2HSImp.Ptr (CLeg')) -> (C2HSImp.CInt -> (C2HSImp.CInt -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO (C2HSImp.Ptr (CLeg')))))))

foreign import ccall safe "QuantLib/CashFlow.chs.h qlLegCashFlows"
  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 ())))))))))))

foreign import ccall safe "QuantLib/CashFlow.chs.h qlCashFlowsDuration"
  duration'_ :: ((C2HSImp.Ptr (CLeg')) -> ((C2HSImp.Ptr (CInterestRate)) -> (C2HSImp.CInt -> (C2HSImp.CInt -> (C2HSImp.CInt -> (C2HSImp.CInt -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO C2HSImp.CDouble))))))))

foreign import ccall safe "QuantLib/CashFlow.chs.h qlCashFlowsAccrualDays"
  accrualDays'_ :: ((C2HSImp.Ptr (CLeg')) -> (C2HSImp.CInt -> (C2HSImp.CInt -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO C2HSImp.CInt)))))

foreign import ccall safe "QuantLib/CashFlow.chs.h qlCashFlowsAccrualEndDate"
  accrualEndDate'_ :: ((C2HSImp.Ptr (CLeg')) -> (C2HSImp.CInt -> (C2HSImp.CInt -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO C2HSImp.CInt)))))

foreign import ccall safe "QuantLib/CashFlow.chs.h qlCashFlowsAccrualPeriod"
  accrualPeriod'_ :: ((C2HSImp.Ptr (CLeg')) -> (C2HSImp.CInt -> (C2HSImp.CInt -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO C2HSImp.CDouble)))))

foreign import ccall safe "QuantLib/CashFlow.chs.h qlCashFlowsAccrualStartDate"
  accrualStartDate'_ :: ((C2HSImp.Ptr (CLeg')) -> (C2HSImp.CInt -> (C2HSImp.CInt -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO C2HSImp.CInt)))))

foreign import ccall safe "QuantLib/CashFlow.chs.h qlCashFlowsAccruedAmount"
  accruedAmount'_ :: ((C2HSImp.Ptr (CLeg')) -> (C2HSImp.CInt -> (C2HSImp.CInt -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO C2HSImp.CDouble)))))

foreign import ccall safe "QuantLib/CashFlow.chs.h qlCashFlowsAccruedDays"
  accruedDays'_ :: ((C2HSImp.Ptr (CLeg')) -> (C2HSImp.CInt -> (C2HSImp.CInt -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO C2HSImp.CInt)))))

foreign import ccall safe "QuantLib/CashFlow.chs.h qlCashFlowsAccruedPeriod"
  accruedPeriod'_ :: ((C2HSImp.Ptr (CLeg')) -> (C2HSImp.CInt -> (C2HSImp.CInt -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO C2HSImp.CDouble)))))

foreign import ccall safe "QuantLib/CashFlow.chs.h qlCashFlowsBasisPointValue"
  basisPointValue'_ :: ((C2HSImp.Ptr (CLeg')) -> ((C2HSImp.Ptr (CInterestRate)) -> (C2HSImp.CInt -> (C2HSImp.CInt -> (C2HSImp.CInt -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO C2HSImp.CDouble)))))))

foreign import ccall safe "QuantLib/CashFlow.chs.h qlCashFlowsBps1"
  bpsFromYieldRaw'_ :: ((C2HSImp.Ptr (CLeg')) -> ((C2HSImp.Ptr (CInterestRate)) -> (C2HSImp.CInt -> (C2HSImp.CInt -> (C2HSImp.CInt -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO C2HSImp.CDouble)))))))

foreign import ccall safe "QuantLib/CashFlow.chs.h qlCashFlowsConvexity"
  convexity'_ :: ((C2HSImp.Ptr (CLeg')) -> ((C2HSImp.Ptr (CInterestRate)) -> (C2HSImp.CInt -> (C2HSImp.CInt -> (C2HSImp.CInt -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO C2HSImp.CDouble)))))))

foreign import ccall safe "QuantLib/CashFlow.chs.h qlCashFlowsIsExpired"
  isExpired'_ :: ((C2HSImp.Ptr (CLeg')) -> (C2HSImp.CInt -> (C2HSImp.CInt -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO C2HSImp.CInt)))))

foreign import ccall safe "QuantLib/CashFlow.chs.h qlCashFlowsMaturityDate"
  maturityDate'_ :: ((C2HSImp.Ptr (CLeg')) -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO C2HSImp.CInt)))

foreign import ccall safe "QuantLib/CashFlow.chs.h qlCashFlowsNextCashFlowAmount"
  nextCashFlowAmount'_ :: ((C2HSImp.Ptr (CLeg')) -> (C2HSImp.CInt -> (C2HSImp.CInt -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO C2HSImp.CDouble)))))

foreign import ccall safe "QuantLib/CashFlow.chs.h qlCashFlowsNextCashFlowDate"
  nextCashFlowDate'_ :: ((C2HSImp.Ptr (CLeg')) -> (C2HSImp.CInt -> (C2HSImp.CInt -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO C2HSImp.CInt)))))

foreign import ccall safe "QuantLib/CashFlow.chs.h qlCashFlowsNextCouponRate"
  nextCouponRate'_ :: ((C2HSImp.Ptr (CLeg')) -> (C2HSImp.CInt -> (C2HSImp.CInt -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO C2HSImp.CDouble)))))

foreign import ccall safe "QuantLib/CashFlow.chs.h qlCashFlowsNominal"
  nominal'_ :: ((C2HSImp.Ptr (CLeg')) -> (C2HSImp.CInt -> (C2HSImp.CInt -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO C2HSImp.CDouble)))))

foreign import ccall safe "QuantLib/CashFlow.chs.h qlCashFlowsNpv1"
  npvFromYieldRaw'_ :: ((C2HSImp.Ptr (CLeg')) -> ((C2HSImp.Ptr (CInterestRate)) -> (C2HSImp.CInt -> (C2HSImp.CInt -> (C2HSImp.CInt -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO C2HSImp.CDouble)))))))

foreign import ccall safe "QuantLib/CashFlow.chs.h qlCashFlowsAtmRate"
  atmRate'_ :: ((C2HSImp.Ptr (CLeg')) -> ((C2HSImp.Ptr (CYieldTermStructure')) -> (C2HSImp.CInt -> (C2HSImp.CInt -> (C2HSImp.CInt -> (C2HSImp.CDouble -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO C2HSImp.CDouble))))))))

foreign import ccall safe "QuantLib/CashFlow.chs.h qlCashFlowsBps"
  bpsFromCurveRaw'_ :: ((C2HSImp.Ptr (CLeg')) -> ((C2HSImp.Ptr (CYieldTermStructure')) -> (C2HSImp.CInt -> (C2HSImp.CInt -> (C2HSImp.CInt -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO C2HSImp.CDouble)))))))

foreign import ccall safe "QuantLib/CashFlow.chs.h qlCashFlowsNpv3"
  npvWithZSpreadRaw'_ :: ((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))))))))))

foreign import ccall safe "QuantLib/CashFlow.chs.h qlCashFlowsNpv"
  npvFromCurveRaw'_ :: ((C2HSImp.Ptr (CLeg')) -> ((C2HSImp.Ptr (CYieldTermStructure')) -> (C2HSImp.CInt -> (C2HSImp.CInt -> (C2HSImp.CInt -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO C2HSImp.CDouble)))))))

foreign import ccall safe "QuantLib/CashFlow.chs.h qlCashFlowsNpvbps"
  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 ())))))))))

foreign import ccall safe "QuantLib/CashFlow.chs.h qlCashFlowsZSpread"
  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)))))))))))))

foreign import ccall safe "QuantLib/CashFlow.chs.h qlCashFlowsPreviousCashFlowAmount"
  previousCashFlowAmount'_ :: ((C2HSImp.Ptr (CLeg')) -> (C2HSImp.CInt -> (C2HSImp.CInt -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO C2HSImp.CDouble)))))

foreign import ccall safe "QuantLib/CashFlow.chs.h qlCashFlowsPreviousCashFlowDate"
  previousCashFlowDate'_ :: ((C2HSImp.Ptr (CLeg')) -> (C2HSImp.CInt -> (C2HSImp.CInt -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO C2HSImp.CInt)))))

foreign import ccall safe "QuantLib/CashFlow.chs.h qlCashFlowsPreviousCouponRate"
  previousCouponRate'_ :: ((C2HSImp.Ptr (CLeg')) -> (C2HSImp.CInt -> (C2HSImp.CInt -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO C2HSImp.CDouble)))))

foreign import ccall safe "QuantLib/CashFlow.chs.h qlCashFlowsReferencePeriodEnd"
  referencePeriodEnd'_ :: ((C2HSImp.Ptr (CLeg')) -> (C2HSImp.CInt -> (C2HSImp.CInt -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO C2HSImp.CInt)))))

foreign import ccall safe "QuantLib/CashFlow.chs.h qlCashFlowsReferencePeriodStart"
  referencePeriodStart'_ :: ((C2HSImp.Ptr (CLeg')) -> (C2HSImp.CInt -> (C2HSImp.CInt -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO C2HSImp.CInt)))))

foreign import ccall safe "QuantLib/CashFlow.chs.h qlCashFlowsYield"
  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)))))))))))))

foreign import ccall safe "QuantLib/CashFlow.chs.h qlCashFlowsYieldValueBasisPoint"
  yieldValueBasisPoint'_ :: ((C2HSImp.Ptr (CLeg')) -> ((C2HSImp.Ptr (CInterestRate)) -> (C2HSImp.CInt -> (C2HSImp.CInt -> (C2HSImp.CInt -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO C2HSImp.CDouble)))))))

foreign import ccall safe "QuantLib/CashFlow.chs.h qlCouponAccrualStartDates"
  couponAccrualStartDates'_ :: ((C2HSImp.Ptr (CCouponLeg')) -> ((C2HSImp.Ptr C2HSImp.CUInt) -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CInt)) -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO ())))))

foreign import ccall safe "QuantLib/CashFlow.chs.h qlFixedDividend"
  fixedDividend'_ :: (C2HSImp.CDouble -> (C2HSImp.CInt -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO (C2HSImp.Ptr (CDividend))))))

foreign import ccall safe "QuantLib/CashFlow.chs.h qlFractionalDividend1"
  fractionalDividendWithNominal'_ :: (C2HSImp.CDouble -> (C2HSImp.CDouble -> (C2HSImp.CInt -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO (C2HSImp.Ptr (CDividend)))))))

foreign import ccall safe "QuantLib/CashFlow.chs.h qlFractionalDividend"
  fractionalDividend'_ :: (C2HSImp.CDouble -> (C2HSImp.CInt -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO (C2HSImp.Ptr (CDividend))))))

foreign import ccall safe "QuantLib/CashFlow.chs.h qlAverageBMALeg"
  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'))))))))))))))

foreign import ccall safe "QuantLib/CashFlow.chs.h qlFixedRateLeg"
  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'))))))))))))

foreign import ccall safe "QuantLib/CashFlow.chs.h qlIborLeg"
  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')))))))))))))))))))))))))))))))

foreign import ccall safe "QuantLib/CashFlow.chs.h qlCmsLeg"
  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'))))))))))))))))))))))))))))

foreign import ccall safe "QuantLib/CashFlow.chs.h qlOvernightLeg"
  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'))))))))))))))

foreign import ccall safe "QuantLib/CashFlow.chs.h qlRangeAccrualLeg"
  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')))))))))))))))))))))))

foreign import ccall safe "QuantLib/CashFlow.chs.h qlCPILeg"
  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'))))))))))))))))))

foreign import ccall safe "QuantLib/CashFlow.chs.h qlYoYInflationLeg"
  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'))))))))))))))))))))))))

foreign import ccall safe "QuantLib/CashFlow.chs.h qlZeroInflationCashFlow"
  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')))))))))))))

foreign import ccall safe "QuantLib/CashFlow.chs.h qlCPICashFlow"
  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'))))))))))))))

foreign import ccall safe "QuantLib/CashFlow.chs.h qlEquityCashFlow"
  equityCashFlow'_ :: (C2HSImp.CDouble -> ((C2HSImp.Ptr (CEquityIndex')) -> (C2HSImp.CInt -> (C2HSImp.CInt -> (C2HSImp.CInt -> (C2HSImp.CInt -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO (C2HSImp.Ptr (CEquityCashFlow'))))))))))

foreign import ccall safe "QuantLib/CashFlow.chs.h qlEquityCashFlowSetPricer"
  setEquityCashFlowPricer'_ :: ((C2HSImp.Ptr (CEquityCashFlow')) -> ((C2HSImp.Ptr (CEquityCashFlowPricer)) -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO ()))))

foreign import ccall safe "QuantLib/CashFlow.chs.h qlEquityQuantoCashFlowPricer"
  equityQuantoCashFlowPricer'_ :: ((C2HSImp.Ptr (CYieldTermStructure')) -> ((C2HSImp.Ptr (CBlackVolTermStructure')) -> ((C2HSImp.Ptr (CBlackVolTermStructure')) -> ((C2HSImp.Ptr (CQuote')) -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO (C2HSImp.Ptr (CEquityCashFlowPricer))))))))

foreign import ccall safe "QuantLib/CashFlow.chs.h qlQuantLibSetEquityCashFlowPricer"
  setEquityLegPricer'_ :: ((C2HSImp.Ptr (CLeg')) -> ((C2HSImp.Ptr (CEquityCashFlowPricer)) -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO ()))))

foreign import ccall safe "QuantLib/CashFlow.chs.h qlLegToCouponLeg"
  toCouponLeg'_ :: ((C2HSImp.Ptr (CLeg')) -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO (C2HSImp.Ptr (CCouponLeg')))))

foreign import ccall safe "QuantLib/CashFlow.chs.h qlCouponLegCoupons"
  coupons'_ :: ((C2HSImp.Ptr (CCouponLeg')) -> ((C2HSImp.Ptr C2HSImp.CUInt) -> ((C2HSImp.Ptr (C2HSImp.Ptr (C2HSImp.Ptr (CCoupon')))) -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO ())))))

foreign import ccall safe "QuantLib/CashFlow.chs.h qlBlackIborCouponPricer"
  blackIborCouponPricer'_ :: ((C2HSImp.Ptr (COptionletVolatilityStructure')) -> (C2HSImp.CInt -> ((C2HSImp.Ptr (CQuote')) -> (C2HSImp.CInt -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO (C2HSImp.Ptr (CFloatingRateCouponPricer'))))))))

foreign import ccall safe "QuantLib/CashFlow.chs.h qlBlackIborQuantoCouponPricer"
  blackIborQuantoCouponPricer'_ :: ((C2HSImp.Ptr (CBlackVolTermStructure')) -> ((C2HSImp.Ptr (CQuote')) -> ((C2HSImp.Ptr (COptionletVolatilityStructure')) -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO (C2HSImp.Ptr (CFloatingRateCouponPricer')))))))

foreign import ccall safe "QuantLib/CashFlow.chs.h qlRangeAccrualPricerByBgm"
  rangeAccrualPricerByBgm'_ :: (C2HSImp.CDouble -> ((C2HSImp.Ptr (CSmileSection)) -> ((C2HSImp.Ptr (CSmileSection)) -> (C2HSImp.CInt -> (C2HSImp.CInt -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO (C2HSImp.Ptr (CFloatingRateCouponPricer')))))))))

foreign import ccall safe "QuantLib/CashFlow.chs.h qlBlackYoYInflationCouponPricer"
  blackYoyInflationCouponPricer'_ :: ((C2HSImp.Ptr (CYoYOptionletVolatilitySurface')) -> ((C2HSImp.Ptr (CYieldTermStructure')) -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO (C2HSImp.Ptr (CYoYInflationCouponPricer))))))

foreign import ccall safe "QuantLib/CashFlow.chs.h qlUnitDisplacedBlackYoYInflationCouponPricer"
  unitDisplacedBlackYoyInflationCouponPricer'_ :: ((C2HSImp.Ptr (CYoYOptionletVolatilitySurface')) -> ((C2HSImp.Ptr (CYieldTermStructure')) -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO (C2HSImp.Ptr (CYoYInflationCouponPricer))))))

foreign import ccall safe "QuantLib/CashFlow.chs.h qlBachelierYoYInflationCouponPricer"
  bachelierYoyInflationCouponPricer'_ :: ((C2HSImp.Ptr (CYoYOptionletVolatilitySurface')) -> ((C2HSImp.Ptr (CYieldTermStructure')) -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO (C2HSImp.Ptr (CYoYInflationCouponPricer))))))

foreign import ccall safe "QuantLib/CashFlow.chs.h qlSetYoYInflationCouponPricer"
  setYoyInflationCouponPricer'_ :: ((C2HSImp.Ptr (CLeg')) -> ((C2HSImp.Ptr (CYoYInflationCouponPricer)) -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO ()))))

foreign import ccall safe "QuantLib/CashFlow.chs.h qlQuantLibSetCouponPricer"
  setCouponPricer'_ :: ((C2HSImp.Ptr (CLeg')) -> ((C2HSImp.Ptr (CFloatingRateCouponPricer')) -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO ()))))

foreign import ccall safe "QuantLib/CashFlow.chs.h qlQuantLibSetCouponPricers"
  setCouponPricers'_ :: ((C2HSImp.Ptr (CLeg')) -> (C2HSImp.CUInt -> ((C2HSImp.Ptr (C2HSImp.Ptr (CFloatingRateCouponPricer'))) -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO ())))))

foreign import ccall safe "QuantLib/CashFlow.chs.h qlFloatingRateCouponPricerSwapletRate"
  swapletRate'_ :: ((C2HSImp.Ptr (CFloatingRateCouponPricer')) -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO C2HSImp.CDouble)))

foreign import ccall safe "QuantLib/CashFlow.chs.h qlFloatingRateCouponPricerSwapletPrice"
  swapletPrice'_ :: ((C2HSImp.Ptr (CFloatingRateCouponPricer')) -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO C2HSImp.CDouble)))

foreign import ccall safe "QuantLib/CashFlow.chs.h qlFloatingRateCouponPricerCapletPrice"
  capletPrice'_ :: ((C2HSImp.Ptr (CFloatingRateCouponPricer')) -> (C2HSImp.CDouble -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO C2HSImp.CDouble))))

foreign import ccall safe "QuantLib/CashFlow.chs.h qlFloatingRateCouponPricerCapletRate"
  capletRate'_ :: ((C2HSImp.Ptr (CFloatingRateCouponPricer')) -> (C2HSImp.CDouble -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO C2HSImp.CDouble))))

foreign import ccall safe "QuantLib/CashFlow.chs.h qlFloatingRateCouponPricerFloorletPrice"
  floorletPrice'_ :: ((C2HSImp.Ptr (CFloatingRateCouponPricer')) -> (C2HSImp.CDouble -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO C2HSImp.CDouble))))

foreign import ccall safe "QuantLib/CashFlow.chs.h qlFloatingRateCouponPricerFloorletRate"
  floorletRate'_ :: ((C2HSImp.Ptr (CFloatingRateCouponPricer')) -> (C2HSImp.CDouble -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO C2HSImp.CDouble))))

foreign import ccall safe "QuantLib/CashFlow.chs.h qlCmsCoupon"
  cmsCoupon'_ :: (C2HSImp.CInt -> (C2HSImp.CDouble -> (C2HSImp.CInt -> (C2HSImp.CInt -> (C2HSImp.CUInt -> ((C2HSImp.Ptr (CSwapIndex')) -> (C2HSImp.CDouble -> (C2HSImp.CDouble -> (C2HSImp.CInt -> (C2HSImp.CInt -> ((C2HSImp.Ptr (CDayCounter)) -> (C2HSImp.CInt -> (C2HSImp.CInt -> (C2HSImp.CInt -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO (C2HSImp.Ptr (CCmsCoupon'))))))))))))))))))

foreign import ccall safe "QuantLib/CashFlow.chs.h qlCmsSpreadCoupon"
  cmsSpreadCoupon'_ :: (C2HSImp.CInt -> (C2HSImp.CDouble -> (C2HSImp.CInt -> (C2HSImp.CInt -> (C2HSImp.CUInt -> ((C2HSImp.Ptr (CSwapSpreadIndex')) -> (C2HSImp.CDouble -> (C2HSImp.CDouble -> (C2HSImp.CInt -> (C2HSImp.CInt -> ((C2HSImp.Ptr (CDayCounter)) -> (C2HSImp.CInt -> (C2HSImp.CInt -> (C2HSImp.CInt -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO (C2HSImp.Ptr (CFloatingRateCoupon'))))))))))))))))))

foreign import ccall safe "QuantLib/CashFlow.chs.h qlCouponRate"
  rate'_ :: ((C2HSImp.Ptr (CCoupon')) -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO C2HSImp.CDouble)))

foreign import ccall safe "QuantLib/CashFlow.chs.h qlCouponAccruedAmount"
  couponAccruedAmount'_ :: ((C2HSImp.Ptr (CCoupon')) -> (C2HSImp.CInt -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO C2HSImp.CDouble))))

foreign import ccall safe "QuantLib/CashFlow.chs.h qlFloatingRateCouponSetPricer"
  setFloatingRateCouponPricer'_ :: ((C2HSImp.Ptr (CFloatingRateCoupon')) -> ((C2HSImp.Ptr (CFloatingRateCouponPricer')) -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO ()))))

foreign import ccall safe "QuantLib/CashFlow.chs.h qlFloatingRateCouponPrice"
  price'_ :: ((C2HSImp.Ptr (CFloatingRateCoupon')) -> ((C2HSImp.Ptr (CYieldTermStructure')) -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO C2HSImp.CDouble))))

foreign import ccall safe "QuantLib/CashFlow.chs.h qlFloatingRateCouponConvexityAdjustment"
  convexityAdjustment'_ :: ((C2HSImp.Ptr (CFloatingRateCoupon')) -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO C2HSImp.CDouble)))

foreign import ccall safe "QuantLib/CashFlow.chs.h qlCappedFlooredCmsCoupon"
  cappedFlooredCmsCoupon'_ :: (C2HSImp.CInt -> (C2HSImp.CDouble -> (C2HSImp.CInt -> (C2HSImp.CInt -> (C2HSImp.CUInt -> ((C2HSImp.Ptr (CSwapIndex')) -> (C2HSImp.CDouble -> (C2HSImp.CDouble -> (C2HSImp.CDouble -> (C2HSImp.CDouble -> (C2HSImp.CInt -> (C2HSImp.CInt -> ((C2HSImp.Ptr (CDayCounter)) -> (C2HSImp.CInt -> (C2HSImp.CInt -> (C2HSImp.CInt -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO (C2HSImp.Ptr (CFloatingRateCoupon'))))))))))))))))))))

foreign import ccall safe "QuantLib/CashFlow.chs.h qlCappedFlooredCmsSpreadCoupon"
  cappedFlooredCmsSpreadCoupon'_ :: (C2HSImp.CInt -> (C2HSImp.CDouble -> (C2HSImp.CInt -> (C2HSImp.CInt -> (C2HSImp.CUInt -> ((C2HSImp.Ptr (CSwapSpreadIndex')) -> (C2HSImp.CDouble -> (C2HSImp.CDouble -> (C2HSImp.CDouble -> (C2HSImp.CDouble -> (C2HSImp.CInt -> (C2HSImp.CInt -> ((C2HSImp.Ptr (CDayCounter)) -> (C2HSImp.CInt -> (C2HSImp.CInt -> (C2HSImp.CInt -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO (C2HSImp.Ptr (CFloatingRateCoupon'))))))))))))))))))))

foreign import ccall safe "QuantLib/CashFlow.chs.h qlCmsSpreadLeg"
  cmsSpreadLeg'_ :: ((C2HSImp.Ptr (CSchedule)) -> ((C2HSImp.Ptr (CSwapSpreadIndex')) -> (C2HSImp.CUInt -> ((C2HSImp.Ptr C2HSImp.CDouble) -> ((C2HSImp.Ptr (CDayCounter)) -> (C2HSImp.CInt -> (C2HSImp.CUInt -> ((C2HSImp.Ptr C2HSImp.CUInt) -> (C2HSImp.CUInt -> ((C2HSImp.Ptr C2HSImp.CDouble) -> (C2HSImp.CUInt -> ((C2HSImp.Ptr C2HSImp.CDouble) -> (C2HSImp.CUInt -> ((C2HSImp.Ptr C2HSImp.CDouble) -> (C2HSImp.CUInt -> ((C2HSImp.Ptr C2HSImp.CDouble) -> (C2HSImp.CInt -> (C2HSImp.CInt -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO (C2HSImp.Ptr (CLeg'))))))))))))))))))))))

foreign import ccall safe "QuantLib/CashFlow.chs.h qlDigitalReplication"
  digitalReplication'_ :: (C2HSImp.CInt -> (C2HSImp.CDouble -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO (C2HSImp.Ptr (CDigitalReplication))))))

foreign import ccall safe "QuantLib/CashFlow.chs.h qlDigitalReplicationType"
  replicationType'_ :: ((C2HSImp.Ptr (CDigitalReplication)) -> (IO C2HSImp.CInt))

foreign import ccall safe "QuantLib/CashFlow.chs.h qlDigitalReplicationGap"
  gap'_ :: ((C2HSImp.Ptr (CDigitalReplication)) -> (IO C2HSImp.CDouble))

foreign import ccall safe "QuantLib/CashFlow.chs.h qlDigitalCmsCoupon"
  digitalCmsCoupon'_ :: ((C2HSImp.Ptr (CCmsCoupon')) -> (C2HSImp.CDouble -> (C2HSImp.CInt -> (C2HSImp.CInt -> (C2HSImp.CDouble -> (C2HSImp.CDouble -> (C2HSImp.CInt -> (C2HSImp.CInt -> (C2HSImp.CDouble -> ((C2HSImp.Ptr (CDigitalReplication)) -> (C2HSImp.CInt -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO (C2HSImp.Ptr (CDigitalCmsCoupon')))))))))))))))

foreign import ccall safe "QuantLib/CashFlow.chs.h qlDigitalCmsSpreadCoupon"
  digitalCmsSpreadCoupon'_ :: (C2HSImp.CInt -> (C2HSImp.CDouble -> (C2HSImp.CInt -> (C2HSImp.CInt -> (C2HSImp.CUInt -> ((C2HSImp.Ptr (CSwapSpreadIndex')) -> (C2HSImp.CDouble -> (C2HSImp.CDouble -> (C2HSImp.CInt -> (C2HSImp.CInt -> ((C2HSImp.Ptr (CDayCounter)) -> (C2HSImp.CInt -> (C2HSImp.CInt -> (C2HSImp.CInt -> (C2HSImp.CDouble -> (C2HSImp.CInt -> (C2HSImp.CInt -> (C2HSImp.CDouble -> (C2HSImp.CDouble -> (C2HSImp.CInt -> (C2HSImp.CInt -> (C2HSImp.CDouble -> ((C2HSImp.Ptr (CDigitalReplication)) -> (C2HSImp.CInt -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO (C2HSImp.Ptr (CDigitalCmsSpreadCoupon'))))))))))))))))))))))))))))

foreign import ccall safe "QuantLib/CashFlow.chs.h qlDigitalCmsLeg"
  digitalCmsLeg_'_ :: ((C2HSImp.Ptr (CSchedule)) -> ((C2HSImp.Ptr (CSwapIndex')) -> (C2HSImp.CUInt -> ((C2HSImp.Ptr C2HSImp.CDouble) -> ((C2HSImp.Ptr (CDayCounter)) -> (C2HSImp.CInt -> (C2HSImp.CUInt -> ((C2HSImp.Ptr C2HSImp.CUInt) -> (C2HSImp.CUInt -> ((C2HSImp.Ptr C2HSImp.CDouble) -> (C2HSImp.CUInt -> ((C2HSImp.Ptr C2HSImp.CDouble) -> (C2HSImp.CInt -> (C2HSImp.CUInt -> ((C2HSImp.Ptr C2HSImp.CDouble) -> (C2HSImp.CInt -> (C2HSImp.CInt -> (C2HSImp.CUInt -> ((C2HSImp.Ptr C2HSImp.CDouble) -> (C2HSImp.CUInt -> ((C2HSImp.Ptr C2HSImp.CDouble) -> (C2HSImp.CInt -> (C2HSImp.CInt -> (C2HSImp.CUInt -> ((C2HSImp.Ptr C2HSImp.CDouble) -> ((C2HSImp.Ptr (CDigitalReplication)) -> (C2HSImp.CInt -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO (C2HSImp.Ptr (CLeg')))))))))))))))))))))))))))))))

foreign import ccall safe "QuantLib/CashFlow.chs.h qlDigitalIborLeg"
  digitalIborLeg_'_ :: ((C2HSImp.Ptr (CSchedule)) -> ((C2HSImp.Ptr (CIborIndex')) -> (C2HSImp.CUInt -> ((C2HSImp.Ptr C2HSImp.CDouble) -> ((C2HSImp.Ptr (CDayCounter)) -> (C2HSImp.CInt -> (C2HSImp.CUInt -> ((C2HSImp.Ptr C2HSImp.CUInt) -> (C2HSImp.CUInt -> ((C2HSImp.Ptr C2HSImp.CDouble) -> (C2HSImp.CUInt -> ((C2HSImp.Ptr C2HSImp.CDouble) -> (C2HSImp.CInt -> (C2HSImp.CUInt -> ((C2HSImp.Ptr C2HSImp.CDouble) -> (C2HSImp.CInt -> (C2HSImp.CInt -> (C2HSImp.CUInt -> ((C2HSImp.Ptr C2HSImp.CDouble) -> (C2HSImp.CUInt -> ((C2HSImp.Ptr C2HSImp.CDouble) -> (C2HSImp.CInt -> (C2HSImp.CInt -> (C2HSImp.CUInt -> ((C2HSImp.Ptr C2HSImp.CDouble) -> ((C2HSImp.Ptr (CDigitalReplication)) -> (C2HSImp.CInt -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO (C2HSImp.Ptr (CLeg')))))))))))))))))))))))))))))))

foreign import ccall safe "QuantLib/CashFlow.chs.h qlDigitalCmsSpreadLeg"
  digitalCmsSpreadLeg_'_ :: ((C2HSImp.Ptr (CSchedule)) -> ((C2HSImp.Ptr (CSwapSpreadIndex')) -> (C2HSImp.CUInt -> ((C2HSImp.Ptr C2HSImp.CDouble) -> ((C2HSImp.Ptr (CDayCounter)) -> (C2HSImp.CInt -> (C2HSImp.CUInt -> ((C2HSImp.Ptr C2HSImp.CUInt) -> (C2HSImp.CUInt -> ((C2HSImp.Ptr C2HSImp.CDouble) -> (C2HSImp.CUInt -> ((C2HSImp.Ptr C2HSImp.CDouble) -> (C2HSImp.CInt -> (C2HSImp.CUInt -> ((C2HSImp.Ptr C2HSImp.CDouble) -> (C2HSImp.CInt -> (C2HSImp.CInt -> (C2HSImp.CUInt -> ((C2HSImp.Ptr C2HSImp.CDouble) -> (C2HSImp.CUInt -> ((C2HSImp.Ptr C2HSImp.CDouble) -> (C2HSImp.CInt -> (C2HSImp.CInt -> (C2HSImp.CUInt -> ((C2HSImp.Ptr C2HSImp.CDouble) -> ((C2HSImp.Ptr (CDigitalReplication)) -> (C2HSImp.CInt -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO (C2HSImp.Ptr (CLeg')))))))))))))))))))))))))))))))

foreign import ccall safe "QuantLib/CashFlow.chs.h qlMultipleResetsLeg"
  multipleResetsLeg_'_ :: ((C2HSImp.Ptr (CSchedule)) -> ((C2HSImp.Ptr (CIborIndex')) -> (C2HSImp.CUInt -> (C2HSImp.CUInt -> ((C2HSImp.Ptr C2HSImp.CDouble) -> ((C2HSImp.Ptr (CDayCounter)) -> (C2HSImp.CInt -> ((C2HSImp.Ptr (CCalendar)) -> (C2HSImp.CInt -> (C2HSImp.CUInt -> ((C2HSImp.Ptr C2HSImp.CUInt) -> (C2HSImp.CUInt -> ((C2HSImp.Ptr C2HSImp.CDouble) -> (C2HSImp.CUInt -> ((C2HSImp.Ptr C2HSImp.CDouble) -> (C2HSImp.CUInt -> ((C2HSImp.Ptr C2HSImp.CDouble) -> (C2HSImp.CInt -> (C2HSImp.CInt -> ((C2HSImp.Ptr (CCalendar)) -> (C2HSImp.CInt -> (C2HSImp.CInt -> (C2HSImp.CInt -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO (C2HSImp.Ptr (CLeg')))))))))))))))))))))))))))

foreign import ccall safe "QuantLib/CashFlow.chs.h qlAnalyticHaganPricer"
  analyticHaganPricer'_ :: ((C2HSImp.Ptr (CSwaptionVolatilityStructure')) -> (C2HSImp.CInt -> ((C2HSImp.Ptr (CQuote')) -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO (C2HSImp.Ptr (CCmsCouponPricer')))))))

foreign import ccall safe "QuantLib/CashFlow.chs.h qlNumericHaganPricer"
  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 (CCmsCouponPricer')))))))))))

foreign import ccall safe "QuantLib/CashFlow.chs.h qlLinearTsrPricer"
  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 (CCmsCouponPricer'))))))))))))

foreign import ccall safe "QuantLib/CashFlow.chs.h qlLognormalCmsSpreadPricer"
  lognormalCmsSpreadPricer_'_ :: ((C2HSImp.Ptr (CCmsCouponPricer')) -> ((C2HSImp.Ptr (CQuote')) -> ((C2HSImp.Ptr (CYieldTermStructure')) -> (C2HSImp.CUInt -> (C2HSImp.CInt -> (C2HSImp.CInt -> (C2HSImp.CDouble -> (C2HSImp.CDouble -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO (C2HSImp.Ptr (CFloatingRateCouponPricer'))))))))))))

foreign import ccall safe "QuantLib/CashFlow.chs.h qlLegFixingDependencies"
  qlLegFixingDependencies'_ :: ((C2HSImp.Ptr (CLeg')) -> ((C2HSImp.Ptr C2HSImp.CUInt) -> ((C2HSImp.Ptr (C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar))) -> ((C2HSImp.Ptr C2HSImp.CUInt) -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CInt)) -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO ())))))))