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


{-# LINE 1 "./QuantLib/Instrument/Bond.chs" #-}
{-# LANGUAGE TemplateHaskell #-}
module QuantLib.Instrument.Bond
  (
    -- * Types
    -- ** Bond hierarchy
    GenBond
  , Bond
  , GenFixedRateBond
  , FixedRateBond
  , BTP
  , CPIBond
  , CallableBond
  , ConvertibleBond
  , RendistatoBasket
  , RendistatoCalculator

    -- ** Configuration
  , BondPriceType(..)
  , CPIInterpolationType(..)
  , Discounting(..)
  , BpsDiscounting(..)
  , AmortizingFloatingRateBondOpts(..)
  , defaultAmortizingFloatingRateBondOpts

    -- * Constructors
    -- ** Hierarchy conversion
  , asBond

    -- ** Bonds and baskets
  , bond
  , fixedRateBond
  , btp
  , btpWithRedemption
  , zeroCouponBond
  , floatingRateBond
  , cmsRateBond
  , cpiBond
  , amortizingFixedRateBond
  , amortizingCmsRateBond
  , amortizingFloatingRateBond
  , sinkingSchedule
  , sinkingNotionals
  , rendistatoBasket
  , rendistatoCalculator

    -- ** Callable and convertible bonds
  , callableFixedRateBond
  , callableZeroCouponBond
  , convertibleFixedCouponBond
  , convertibleFloatingRateBond
  , convertibleZeroCouponBond

    -- * Inspectors
    -- ** Bond state
  , maturityDate
  , yield
  , accruedAmount
  , dirtyPriceFromYield
  , nextCashFlowDate
  , nextCouponRate
  , notional
  , previousCashFlowDate
  , previousCouponRate
  , settlementValueFromCleanPrice
  , settlementValue
  , yieldFromPrice
  , isTradable
  , notionals
  , cashFlows
  , redemptions
  , settlementDate
  , startDate

    -- ** Bond analytics
  , accrualDays
  , accrualEndDate
  , accrualPeriod
  , accrualStartDate
  , accruedDays
  , accruedPeriod
  , atmRate
  , basisPointValue
  , bps
  , cleanPrice
  , convexity
  , duration
  , nextCashFlowAmount
  , previousCashFlowAmount
  , referencePeriodEnd
  , referencePeriodStart
  , yieldFromPriceWithGuess
  , yieldValueBasisPoint
  , zSpread

    -- ** Current prices
  , currentCleanPrice
  , currentDirtyPrice

    -- ** Rendistato basket analytics
  , rendistatoYield
  , rendistatoDuration
  , rendistatoYields
  , rendistatoDurations
  , rendistatoSwapLengths
  , rendistatoSwapRates
  , rendistatoSwapYields
  , rendistatoSwapDurations
  , rendistatoEquivalentSwap
  , rendistatoEquivalentSwapRate
  , rendistatoEquivalentSwapYield
  , rendistatoEquivalentSwapDuration
  , rendistatoEquivalentSwapLength
  , rendistatoEquivalentSwapSpread
  , rendistatoEquivalentSwapLengthQuote
  , rendistatoEquivalentSwapSpreadQuote
  ) 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 QuantLib.Internal
import QuantLib.Internal.Type
import QuantLib.Time.Schedule(Frequency)
import QuantLib.CashFlow(DurationType)
import QuantLib.InterestRate(Compounding)
import QuantLib.Internal.Common
import QuantLib.CashFlow(Discounting(..), BpsDiscounting(..))
import QuantLib.Internal.Syntax(deriveOptionsRecord)
import QuantLib.Time.Calendar(calendar, CalendarConstructor(..))
import Data.Maybe(fromMaybe)
import Data.List.NonEmpty(NonEmpty, toList)








{-# LINE 135 "./QuantLib/Instrument/Bond.chs" #-}


{-# LINE 136 "./QuantLib/Instrument/Bond.chs" #-}


{-# LINE 137 "./QuantLib/Instrument/Bond.chs" #-}


{-# LINE 138 "./QuantLib/Instrument/Bond.chs" #-}


{-# LINE 139 "./QuantLib/Instrument/Bond.chs" #-}


{-# LINE 140 "./QuantLib/Instrument/Bond.chs" #-}


{-# LINE 141 "./QuantLib/Instrument/Bond.chs" #-}


{-# LINE 142 "./QuantLib/Instrument/Bond.chs" #-}


{-# LINE 143 "./QuantLib/Instrument/Bond.chs" #-}


{-# LINE 144 "./QuantLib/Instrument/Bond.chs" #-}


{-# LINE 145 "./QuantLib/Instrument/Bond.chs" #-}


{-# LINE 146 "./QuantLib/Instrument/Bond.chs" #-}


{-# LINE 147 "./QuantLib/Instrument/Bond.chs" #-}


{-# LINE 148 "./QuantLib/Instrument/Bond.chs" #-}


{-# LINE 149 "./QuantLib/Instrument/Bond.chs" #-}


{-# LINE 150 "./QuantLib/Instrument/Bond.chs" #-}


-- AmortizingFloatingRateBondOpts bundles every trailing param
-- amortizingFloatingRateBond hardcodes, pre-populated with upstream's own
-- defaults via defaultAmortizingFloatingRateBondOpts, overridden through
-- record-update syntax at the call site -- see the add-quantlib-options-record
-- skill. 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 "AmortizingFloatingRateBondOpts" []
  [ ("afrbPaymentConvention", [t|BusinessDayConvention|], [|Following|])
  , ("afrbFixingDays", [t|Maybe Word|], [|Nothing|])
  , ("afrbGearings", [t|[Double]|], [|[1.0]|])
  , ("afrbSpreads", [t|[Double]|], [|[0.0]|])
  , ("afrbCaps", [t|[Double]|], [|[]|])
  , ("afrbFloors", [t|[Double]|], [|[]|])
  , ("afrbInArrears", [t|Bool|], [|False|])
  , ("afrbIssueDate", [t|Maybe Day|], [|Nothing|])
  , ("afrbExCouponPeriod", [t|(Int, TimeUnit)|], [|(0, Days)|])
  , ("afrbExCouponCalendar", [t|Maybe Calendar|], [|Nothing|])
  , ("afrbExCouponConvention", [t|BusinessDayConvention|], [|Unadjusted|])
  , ("afrbExCouponEndOfMonth", [t|Bool|], [|False|])
  , ("afrbRedemptions", [t|[Double]|], [|[100.0]|])
  , ("afrbPaymentLag", [t|Int|], [|0|])
  ])

-- |the bond's yield to maturity given a market price and discount curve
atmRate :: (GenBond b) -> (GenYieldTermStructure y) -> (Day) -> (Double,BondPriceType) -> IO ((Double))
atmRate :: forall b y.
GenBond b
-> GenYieldTermStructure y
-> Day
-> (Double, BondPriceType)
-> IO Double
atmRate GenBond b
a1 GenYieldTermStructure y
a2 Day
a3 (Double, BondPriceType)
a4 =
  GenBond b -> (Ptr CBond' -> IO Double) -> IO Double
forall b r. GenBond b -> (Ptr CBond' -> IO r) -> IO r
withBond GenBond b
a1 ((Ptr CBond' -> IO Double) -> IO Double)
-> (Ptr CBond' -> IO Double) -> IO Double
forall a b. (a -> b) -> a -> b
$ \Ptr CBond'
a1' -> 
  GenYieldTermStructure y
-> (Ptr CYieldTermStructure' -> IO Double) -> IO Double
forall y b.
GenYieldTermStructure y
-> (Ptr CYieldTermStructure' -> IO b) -> IO b
withYieldTermStructure GenYieldTermStructure y
a2 ((Ptr CYieldTermStructure' -> IO Double) -> IO Double)
-> (Ptr CYieldTermStructure' -> IO Double) -> IO Double
forall a b. (a -> b) -> a -> b
$ \Ptr CYieldTermStructure'
a2' -> 
  Day -> (CInt -> IO Double) -> IO Double
forall a. Day -> (CInt -> IO a) -> IO a
withDay Day
a3 ((CInt -> IO Double) -> IO Double)
-> (CInt -> IO Double) -> IO Double
forall a b. (a -> b) -> a -> b
$ \CInt
a3' -> 
  let {(CDouble
a4'1, CInt
a4'2) = (Double, BondPriceType) -> (CDouble, CInt)
forall a c. (Enum a, Integral c) => (Double, a) -> (CDouble, c)
fromEnumDouble (Double, BondPriceType)
a4} 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)
a5' -> 
  Ptr CBond'
-> Ptr CYieldTermStructure'
-> CInt
-> CDouble
-> CInt
-> Ptr (Ptr CChar)
-> IO CDouble
atmRate'_ Ptr CBond'
a1' Ptr CYieldTermStructure'
a2' CInt
a3' CDouble
a4'1  CInt
a4'2 Ptr (Ptr CChar)
a5' 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)
a5'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 181 "./QuantLib/Instrument/Bond.chs" #-}


-- |constructor for amortizing or non-amortizing bonds.
-- Redemptions and maturity are calculated from the coupon data, if available. Therefore, redemptions must not be included in the passed cash flows.
bond :: (Word) -> (Calendar) -> (Maybe Day) -- ^issueDate
 -> (GenLeg l) -- ^coupons
 -> IO ((Bond))
bond a1 a2 a3 a4 =
  let {a1' = fromIntegral a1} in 
  withCalendar a2 $ \a2' -> 
  withMaybeDay a3 $ \a3' -> 
  withLeg a4 $ \a4' -> 
  preErrorCheck $ \a5' -> 
  bond'_ a1' a2' a3' a4' a5' >>= \res ->
  peekBond res >>= \res' ->
  errorCheck  a5'>>
  return (res')

{-# LINE 187 "./QuantLib/Instrument/Bond.chs" #-}


-- |Returns the maturity date of the bond
maturityDate :: (GenBond b) -> IO ((Maybe Day))
maturityDate a1 =
  withBond a1 $ \a1' -> 
  preErrorCheck $ \a2' -> 
  maturityDate'_ a1' a2' >>= \res ->
  let {res' = toMaybeDay res} in
  errorCheck  a2'>>
  return (res')

{-# LINE 190 "./QuantLib/Instrument/Bond.chs" #-}


-- |generic compounding and frequency InterestRate coupons
fixedRateBond :: (Word) -- ^settlementDays
 -> (Double) -- ^faceAmount
 -> (Schedule) -- ^schedule
 -> (NonEmpty Double) -- ^coupons
 -> (DayCounter) -- ^accrualDayCounter
 -> (BusinessDayConvention) -- ^paymentConvention
 -> (Double) -- ^redemption
 -> (Maybe Day) -- ^issueDate
 -> (Calendar) -- ^paymentCalendar
 -> ((Int,TimeUnit)) -- ^exCouponPeriod
 -> (Calendar) -- ^exCouponCalendar
 -> (BusinessDayConvention) -- ^exCouponConvention
 -> (Bool) -- ^exCouponEndOfMonth
 -> (DayCounter) -- ^firstPeriodDayCounter
 -> IO ((FixedRateBond))
fixedRateBond :: Word
-> Double
-> Schedule
-> NonEmpty Double
-> DayCounter
-> BusinessDayConvention
-> Double
-> Maybe Day
-> Calendar
-> (Int, TimeUnit)
-> Calendar
-> BusinessDayConvention
-> Bool
-> DayCounter
-> IO FixedRateBond
fixedRateBond Word
a1 Double
a2 Schedule
a3 NonEmpty Double
a4 DayCounter
a5 BusinessDayConvention
a6 Double
a7 Maybe Day
a8 Calendar
a9 (Int, TimeUnit)
a10 Calendar
a11 BusinessDayConvention
a12 Bool
a13 DayCounter
a14 =
  let {a1' :: CUInt
a1' = Word -> CUInt
forall a b. (Integral a, Num b) => a -> b
fromIntegral Word
a1} in 
  let {a2' :: CDouble
a2' = Double -> CDouble
forall a b. (Real a, Fractional b) => a -> b
realToFrac Double
a2} in 
  Schedule -> (Ptr CSchedule -> IO FixedRateBond) -> IO FixedRateBond
forall b. Schedule -> (Ptr CSchedule -> IO b) -> IO b
withSchedule Schedule
a3 ((Ptr CSchedule -> IO FixedRateBond) -> IO FixedRateBond)
-> (Ptr CSchedule -> IO FixedRateBond) -> IO FixedRateBond
forall a b. (a -> b) -> a -> b
$ \Ptr CSchedule
a3' -> 
  NonEmpty Double
-> ((CUInt, Ptr CDouble) -> IO FixedRateBond) -> IO FixedRateBond
forall b. NonEmpty Double -> ((CUInt, Ptr CDouble) -> IO b) -> IO b
withNonEmptyDoubleArray NonEmpty Double
a4 (((CUInt, Ptr CDouble) -> IO FixedRateBond) -> IO FixedRateBond)
-> ((CUInt, Ptr CDouble) -> IO FixedRateBond) -> IO FixedRateBond
forall a b. (a -> b) -> a -> b
$ \(CUInt
a4'1, Ptr CDouble
a4'2) -> 
  DayCounter
-> (Ptr CDayCounter -> IO FixedRateBond) -> IO FixedRateBond
forall b. DayCounter -> (Ptr CDayCounter -> IO b) -> IO b
withDayCounter DayCounter
a5 ((Ptr CDayCounter -> IO FixedRateBond) -> IO FixedRateBond)
-> (Ptr CDayCounter -> IO FixedRateBond) -> IO FixedRateBond
forall a b. (a -> b) -> a -> b
$ \Ptr CDayCounter
a5' -> 
  let {a6' :: CInt
a6' = BusinessDayConvention -> CInt
forall a b. (Enum a, Integral b) => a -> b
fromEnumC BusinessDayConvention
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 FixedRateBond) -> IO FixedRateBond
forall a. Maybe Day -> (CInt -> IO a) -> IO a
withMaybeDay Maybe Day
a8 ((CInt -> IO FixedRateBond) -> IO FixedRateBond)
-> (CInt -> IO FixedRateBond) -> IO FixedRateBond
forall a b. (a -> b) -> a -> b
$ \CInt
a8' -> 
  Calendar -> (Ptr CCalendar -> IO FixedRateBond) -> IO FixedRateBond
forall b. Calendar -> (Ptr CCalendar -> IO b) -> IO b
withCalendar Calendar
a9 ((Ptr CCalendar -> IO FixedRateBond) -> IO FixedRateBond)
-> (Ptr CCalendar -> IO FixedRateBond) -> IO FixedRateBond
forall a b. (a -> b) -> a -> b
$ \Ptr CCalendar
a9' -> 
  let {(CInt
a10'1, CInt
a10'2) = (Int, TimeUnit) -> (CInt, CInt)
forall a b c.
(Enum a, Integral b, Integral c) =>
(b, a) -> (CInt, c)
fromEnumQuantity (Int, TimeUnit)
a10} in 
  Calendar -> (Ptr CCalendar -> IO FixedRateBond) -> IO FixedRateBond
forall b. Calendar -> (Ptr CCalendar -> IO b) -> IO b
withCalendar Calendar
a11 ((Ptr CCalendar -> IO FixedRateBond) -> IO FixedRateBond)
-> (Ptr CCalendar -> IO FixedRateBond) -> IO FixedRateBond
forall a b. (a -> b) -> a -> b
$ \Ptr CCalendar
a11' -> 
  let {a12' :: CInt
a12' = BusinessDayConvention -> CInt
forall a b. (Enum a, Integral b) => a -> b
fromEnumC BusinessDayConvention
a12} in 
  let {a13' :: CInt
a13' = Bool -> CInt
forall a. Num a => Bool -> a
C2HSImp.fromBool Bool
a13} in 
  DayCounter
-> (Ptr CDayCounter -> IO FixedRateBond) -> IO FixedRateBond
forall b. DayCounter -> (Ptr CDayCounter -> IO b) -> IO b
withDayCounter DayCounter
a14 ((Ptr CDayCounter -> IO FixedRateBond) -> IO FixedRateBond)
-> (Ptr CDayCounter -> IO FixedRateBond) -> IO FixedRateBond
forall a b. (a -> b) -> a -> b
$ \Ptr CDayCounter
a14' -> 
  (Ptr (Ptr CChar) -> IO FixedRateBond) -> IO FixedRateBond
forall a b. (Ptr (Ptr a) -> IO b) -> IO b
preErrorCheck ((Ptr (Ptr CChar) -> IO FixedRateBond) -> IO FixedRateBond)
-> (Ptr (Ptr CChar) -> IO FixedRateBond) -> IO FixedRateBond
forall a b. (a -> b) -> a -> b
$ \Ptr (Ptr CChar)
a15' -> 
  CUInt
-> CDouble
-> Ptr CSchedule
-> CUInt
-> Ptr CDouble
-> Ptr CDayCounter
-> CInt
-> CDouble
-> CInt
-> Ptr CCalendar
-> CInt
-> CInt
-> Ptr CCalendar
-> CInt
-> CInt
-> Ptr CDayCounter
-> Ptr (Ptr CChar)
-> IO (Ptr CFixedRateBond')
fixedRateBond'_ CUInt
a1' CDouble
a2' Ptr CSchedule
a3' CUInt
a4'1  Ptr CDouble
a4'2 Ptr CDayCounter
a5' CInt
a6' CDouble
a7' CInt
a8' Ptr CCalendar
a9' CInt
a10'1  CInt
a10'2 Ptr CCalendar
a11' CInt
a12' CInt
a13' Ptr CDayCounter
a14' Ptr (Ptr CChar)
a15' IO (Ptr CFixedRateBond')
-> (Ptr CFixedRateBond' -> IO FixedRateBond) -> IO FixedRateBond
forall a b. IO a -> (a -> IO b) -> IO b
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= \Ptr CFixedRateBond'
res ->
  Ptr CFixedRateBond' -> IO FixedRateBond
peekFixedRateBond Ptr CFixedRateBond'
res IO FixedRateBond
-> (FixedRateBond -> IO FixedRateBond) -> IO FixedRateBond
forall a b. IO a -> (a -> IO b) -> IO b
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= \FixedRateBond
res' ->
  Ptr (Ptr CChar) -> IO ()
errorCheck  Ptr (Ptr CChar)
a15'IO () -> IO FixedRateBond -> IO FixedRateBond
forall a b. IO a -> IO b -> IO b
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>>
  FixedRateBond -> IO FixedRateBond
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return (FixedRateBond
res')

{-# LINE 207 "./QuantLib/Instrument/Bond.chs" #-}


-- |Italian BTP (Buono Poliennali del Tesoro): a 'FixedRateBond' with the Italian Treasury's own
-- hardcoded conventions baked in -- semiannual, Actual\/Actual (ISMA), ModifiedFollowing, TARGET
-- payment calendar, par (100) redemption. 'accruedAmount' (generic, via 'GenBond') additionally
-- rounds to 5 decimal places on a 'BTP', through the C++ override -- no separate binding needed.
-- 'BTP.yield' upstream is a thin wrapper fixing 'yield''s day counter\/compounding\/frequency
-- arguments to Actual\/Actual (ISMA)\/Compounded\/Annual and is not bound; call the generic
-- 'yield' with those same arguments instead.
btp :: (Day) -- ^maturityDate
 -> (Double) -- ^fixedRate
 -> (Maybe Day) -- ^startDate
 -> (Maybe Day) -- ^issueDate
 -> IO ((BTP))
btp a1 a2 a3 a4 =
  withDay a1 $ \a1' -> 
  let {a2' = realToFrac a2} in 
  withMaybeDay a3 $ \a3' -> 
  withMaybeDay a4 $ \a4' -> 
  preErrorCheck $ \a5' -> 
  btp'_ a1' a2' a3' a4' a5' >>= \res ->
  peekBTP res >>= \res' ->
  errorCheck  a5'>>
  return (res')

{-# LINE 220 "./QuantLib/Instrument/Bond.chs" #-}


-- |As 'btp', but with an explicit (non-par) redemption amount -- needed only for one remaining
-- legacy BTP (as of upstream's own documentation) that redeems below par.
btpWithRedemption :: (Day) -- ^maturityDate
 -> (Double) -- ^fixedRate
 -> (Double) -- ^redemption
 -> (Maybe Day) -- ^startDate
 -> (Maybe Day) -- ^issueDate
 -> IO ((BTP))
btpWithRedemption a1 a2 a3 a4 a5 =
  withDay a1 $ \a1' -> 
  let {a2' = realToFrac a2} in 
  let {a3' = realToFrac a3} in 
  withMaybeDay a4 $ \a4' -> 
  withMaybeDay a5 $ \a5' -> 
  preErrorCheck $ \a6' -> 
  btpWithRedemption'_ a1' a2' a3' a4' a5' a6' >>= \res ->
  peekBTP res >>= \res' ->
  errorCheck  a6'>>
  return (res')

{-# LINE 229 "./QuantLib/Instrument/Bond.chs" #-}


-- |amortizing fixed-rate bond: like 'fixedRateBond' but with a per-period notional schedule
-- instead of a single face amount (see 'sinkingSchedule'\/'sinkingNotionals' for building one).
amortizingFixedRateBond :: (Word) -- ^settlementDays
 -> (NonEmpty Double) -- ^notionals
 -> (Schedule) -- ^schedule
 -> (NonEmpty Double) -- ^coupons
 -> (DayCounter) -- ^accrualDayCounter
 -> (BusinessDayConvention) -- ^paymentConvention
 -> (Maybe Day) -- ^issueDate
 -> ((Int,TimeUnit)) -- ^exCouponPeriod
 -> (Calendar) -- ^exCouponCalendar
 -> (BusinessDayConvention) -- ^exCouponConvention
 -> (Bool) -- ^exCouponEndOfMonth
 -> ([Double]) -- ^redemptions
 -> (Int) -- ^paymentLag
 -> IO ((Bond))
amortizingFixedRateBond :: Word
-> NonEmpty Double
-> Schedule
-> NonEmpty Double
-> DayCounter
-> BusinessDayConvention
-> Maybe Day
-> (Int, TimeUnit)
-> Calendar
-> BusinessDayConvention
-> Bool
-> [Double]
-> Int
-> IO Bond
amortizingFixedRateBond Word
a1 NonEmpty Double
a2 Schedule
a3 NonEmpty Double
a4 DayCounter
a5 BusinessDayConvention
a6 Maybe Day
a7 (Int, TimeUnit)
a8 Calendar
a9 BusinessDayConvention
a10 Bool
a11 [Double]
a12 Int
a13 =
  let {a1' :: CUInt
a1' = Word -> CUInt
forall a b. (Integral a, Num b) => a -> b
fromIntegral Word
a1} in 
  NonEmpty Double -> ((CUInt, Ptr CDouble) -> IO Bond) -> IO Bond
forall b. NonEmpty Double -> ((CUInt, Ptr CDouble) -> IO b) -> IO b
withNonEmptyDoubleArray NonEmpty Double
a2 (((CUInt, Ptr CDouble) -> IO Bond) -> IO Bond)
-> ((CUInt, Ptr CDouble) -> IO Bond) -> IO Bond
forall a b. (a -> b) -> a -> b
$ \(CUInt
a2'1, Ptr CDouble
a2'2) -> 
  Schedule -> (Ptr CSchedule -> IO Bond) -> IO Bond
forall b. Schedule -> (Ptr CSchedule -> IO b) -> IO b
withSchedule Schedule
a3 ((Ptr CSchedule -> IO Bond) -> IO Bond)
-> (Ptr CSchedule -> IO Bond) -> IO Bond
forall a b. (a -> b) -> a -> b
$ \Ptr CSchedule
a3' -> 
  NonEmpty Double -> ((CUInt, Ptr CDouble) -> IO Bond) -> IO Bond
forall b. NonEmpty Double -> ((CUInt, Ptr CDouble) -> IO b) -> IO b
withNonEmptyDoubleArray NonEmpty Double
a4 (((CUInt, Ptr CDouble) -> IO Bond) -> IO Bond)
-> ((CUInt, Ptr CDouble) -> IO Bond) -> IO Bond
forall a b. (a -> b) -> a -> b
$ \(CUInt
a4'1, Ptr CDouble
a4'2) -> 
  DayCounter -> (Ptr CDayCounter -> IO Bond) -> IO Bond
forall b. DayCounter -> (Ptr CDayCounter -> IO b) -> IO b
withDayCounter DayCounter
a5 ((Ptr CDayCounter -> IO Bond) -> IO Bond)
-> (Ptr CDayCounter -> IO Bond) -> IO Bond
forall a b. (a -> b) -> a -> b
$ \Ptr CDayCounter
a5' -> 
  let {a6' :: CInt
a6' = BusinessDayConvention -> CInt
forall a b. (Enum a, Integral b) => a -> b
fromEnumC BusinessDayConvention
a6} in 
  Maybe Day -> (CInt -> IO Bond) -> IO Bond
forall a. Maybe Day -> (CInt -> IO a) -> IO a
withMaybeDay Maybe Day
a7 ((CInt -> IO Bond) -> IO Bond) -> (CInt -> IO Bond) -> IO Bond
forall a b. (a -> b) -> a -> b
$ \CInt
a7' -> 
  let {(CInt
a8'1, CInt
a8'2) = (Int, TimeUnit) -> (CInt, CInt)
forall a b c.
(Enum a, Integral b, Integral c) =>
(b, a) -> (CInt, c)
fromEnumQuantity (Int, TimeUnit)
a8} in 
  Calendar -> (Ptr CCalendar -> IO Bond) -> IO Bond
forall b. Calendar -> (Ptr CCalendar -> IO b) -> IO b
withCalendar Calendar
a9 ((Ptr CCalendar -> IO Bond) -> IO Bond)
-> (Ptr CCalendar -> IO Bond) -> IO Bond
forall a b. (a -> b) -> a -> b
$ \Ptr CCalendar
a9' -> 
  let {a10' = fromEnumC a10} in 
  let {a11' = C2HSImp.fromBool a11} in 
  withDoubleArray a12 $ \(a12'1, a12'2) -> 
  let {a13' = fromIntegral a13} in 
  preErrorCheck $ \a14' -> 
  CUInt
-> CUInt
-> Ptr CDouble
-> Ptr CSchedule
-> CUInt
-> Ptr CDouble
-> Ptr CDayCounter
-> CInt
-> CInt
-> CInt
-> CInt
-> Ptr CCalendar
-> CInt
-> CInt
-> CUInt
-> Ptr CDouble
-> CInt
-> Ptr (Ptr CChar)
-> IO (Ptr CBond')
amortizingFixedRateBond'_ CUInt
a1' CUInt
a2'1  Ptr CDouble
a2'2 Ptr CSchedule
a3' CUInt
a4'1  Ptr CDouble
a4'2 Ptr CDayCounter
a5' CInt
a6' CInt
a7' CInt
a8'1  CInt
a8'2 Ptr CCalendar
a9' CInt
a10' CInt
a11' CUInt
a12'1  Ptr CDouble
a12'2 CInt
a13' Ptr (Ptr CChar)
a14' IO (Ptr CBond') -> (Ptr CBond' -> IO Bond) -> IO Bond
forall a b. IO a -> (a -> IO b) -> IO b
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= \Ptr CBond'
res ->
  peekBond res >>= \res' ->
  errorCheck  a14'>>
  return (res')

{-# LINE 246 "./QuantLib/Instrument/Bond.chs" #-}


-- |returns a schedule for French amortization
sinkingSchedule :: (Day) -- ^startDate
 -> ((Int,TimeUnit)) -- ^bondLength
 -> (Frequency) -> (Calendar) -- ^paymentCalendar
 -> IO ((Schedule))
sinkingSchedule a1 a2 a3 a4 =
  withDay a1 $ \a1' -> 
  let {(a2'1, a2'2) = fromEnumQuantity a2} in 
  let {a3' = (fromIntegral . fromEnum) a3} in 
  withCalendar a4 $ \a4' -> 
  preErrorCheck $ \a5' -> 
  sinkingSchedule'_ a1' a2'1  a2'2 a3' a4' a5' >>= \res ->
  peekSchedule res >>= \res' ->
  errorCheck  a5'>>
  return (res')

{-# LINE 253 "./QuantLib/Instrument/Bond.chs" #-}


-- |returns a sequence of notionals for French amortization
sinkingNotionals :: ((Int,TimeUnit)) -- ^bondLength
 -> (Frequency) -> (Double) -- ^couponRate
 -> (Double) -- ^initialNotional
 -> IO (([Double]))
sinkingNotionals a1 a2 a3 a4 =
  let {(a1'1, a1'2) = fromEnumQuantity a1} in 
  let {a2' = (fromIntegral . fromEnum) a2} in 
  let {a3' = realToFrac a3} in 
  let {a4' = realToFrac a4} in 
  preArray $ \(a5'1, a5'2) -> 
  preErrorCheck $ \a6' -> 
  sinkingNotionals'_ a1'1  a1'2 a2' a3' a4' a5'1  a5'2 a6' >>
  peekDoubleArray  a5'1  a5'2>>= \a5'' -> 
  errorCheck  a6'>>
  return (a5'')

{-# LINE 261 "./QuantLib/Instrument/Bond.chs" #-}


-- |An inflation-linked bond whose redemption and coupons scale with a 'ZeroInflationIndex'
-- fixing relative to /baseCPI/.
cpiBond :: (Word) -- ^settlementDays
 -> (Double) -- ^faceAmount
 -> (Double) -- ^baseCPI
 -> ((Word,TimeUnit)) -- ^observationLag
 -> (ZeroInflationIndex) -> (CPIInterpolationType) -- ^observationInterpolation
 -> (Schedule) -> (NonEmpty Double) -- ^coupons
 -> (DayCounter) -- ^accrualDayCounter
 -> (BusinessDayConvention) -- ^paymentConvention
 -> (Maybe Day) -- ^issueDate
 -> (Calendar) -- ^paymentCalendar
 -> ((Int,TimeUnit)) -- ^exCouponPeriod
 -> (Calendar) -- ^exCouponCalendar
 -> (BusinessDayConvention) -- ^exCouponConvention
 -> (Bool) -- ^exCouponEndOfMonth
 -> IO ((CPIBond))
cpiBond :: Word
-> Double
-> Double
-> (Word, TimeUnit)
-> ZeroInflationIndex
-> CPIInterpolationType
-> Schedule
-> NonEmpty Double
-> DayCounter
-> BusinessDayConvention
-> Maybe Day
-> Calendar
-> (Int, TimeUnit)
-> Calendar
-> BusinessDayConvention
-> Bool
-> IO CPIBond
cpiBond Word
a1 Double
a2 Double
a3 (Word, TimeUnit)
a4 ZeroInflationIndex
a5 CPIInterpolationType
a6 Schedule
a7 NonEmpty Double
a8 DayCounter
a9 BusinessDayConvention
a10 Maybe Day
a11 Calendar
a12 (Int, TimeUnit)
a13 Calendar
a14 BusinessDayConvention
a15 Bool
a16 =
  let {a1' :: CUInt
a1' = Word -> CUInt
forall a b. (Integral a, Num b) => a -> b
fromIntegral Word
a1} in 
  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 
  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 
  ZeroInflationIndex
-> (Ptr CZeroInflationIndex' -> IO CPIBond) -> IO CPIBond
forall zidx b.
GenZeroInflationIndex zidx
-> (Ptr CZeroInflationIndex' -> IO b) -> IO b
withZeroInflationIndex ZeroInflationIndex
a5 ((Ptr CZeroInflationIndex' -> IO CPIBond) -> IO CPIBond)
-> (Ptr CZeroInflationIndex' -> IO CPIBond) -> IO CPIBond
forall a b. (a -> b) -> a -> b
$ \Ptr CZeroInflationIndex'
a5' -> 
  let {a6' :: CInt
a6' = CPIInterpolationType -> CInt
forall a b. (Enum a, Integral b) => a -> b
fromEnumC CPIInterpolationType
a6} in 
  Schedule -> (Ptr CSchedule -> IO CPIBond) -> IO CPIBond
forall b. Schedule -> (Ptr CSchedule -> IO b) -> IO b
withSchedule Schedule
a7 ((Ptr CSchedule -> IO CPIBond) -> IO CPIBond)
-> (Ptr CSchedule -> IO CPIBond) -> IO CPIBond
forall a b. (a -> b) -> a -> b
$ \Ptr CSchedule
a7' -> 
  NonEmpty Double
-> ((CUInt, Ptr CDouble) -> IO CPIBond) -> IO CPIBond
forall b. NonEmpty Double -> ((CUInt, Ptr CDouble) -> IO b) -> IO b
withNonEmptyDoubleArray NonEmpty Double
a8 (((CUInt, Ptr CDouble) -> IO CPIBond) -> IO CPIBond)
-> ((CUInt, Ptr CDouble) -> IO CPIBond) -> IO CPIBond
forall a b. (a -> b) -> a -> b
$ \(CUInt
a8'1, Ptr CDouble
a8'2) -> 
  DayCounter -> (Ptr CDayCounter -> IO CPIBond) -> IO CPIBond
forall b. DayCounter -> (Ptr CDayCounter -> IO b) -> IO b
withDayCounter DayCounter
a9 ((Ptr CDayCounter -> IO CPIBond) -> IO CPIBond)
-> (Ptr CDayCounter -> IO CPIBond) -> IO CPIBond
forall a b. (a -> b) -> a -> b
$ \Ptr CDayCounter
a9' -> 
  let {a10' :: CInt
a10' = BusinessDayConvention -> CInt
forall a b. (Enum a, Integral b) => a -> b
fromEnumC BusinessDayConvention
a10} in 
  Maybe Day -> (CInt -> IO CPIBond) -> IO CPIBond
forall a. Maybe Day -> (CInt -> IO a) -> IO a
withMaybeDay Maybe Day
a11 ((CInt -> IO CPIBond) -> IO CPIBond)
-> (CInt -> IO CPIBond) -> IO CPIBond
forall a b. (a -> b) -> a -> b
$ \CInt
a11' -> 
  Calendar -> (Ptr CCalendar -> IO CPIBond) -> IO CPIBond
forall b. Calendar -> (Ptr CCalendar -> IO b) -> IO b
withCalendar Calendar
a12 ((Ptr CCalendar -> IO CPIBond) -> IO CPIBond)
-> (Ptr CCalendar -> IO CPIBond) -> IO CPIBond
forall a b. (a -> b) -> a -> b
$ \Ptr CCalendar
a12' -> 
  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 CPIBond) -> IO CPIBond
forall b. Calendar -> (Ptr CCalendar -> IO b) -> IO b
withCalendar Calendar
a14 ((Ptr CCalendar -> IO CPIBond) -> IO CPIBond)
-> (Ptr CCalendar -> IO CPIBond) -> IO CPIBond
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 
  (Ptr (Ptr CChar) -> IO CPIBond) -> IO CPIBond
forall a b. (Ptr (Ptr a) -> IO b) -> IO b
preErrorCheck ((Ptr (Ptr CChar) -> IO CPIBond) -> IO CPIBond)
-> (Ptr (Ptr CChar) -> IO CPIBond) -> IO CPIBond
forall a b. (a -> b) -> a -> b
$ \Ptr (Ptr CChar)
a17' -> 
  CUInt
-> CDouble
-> CDouble
-> CInt
-> CInt
-> Ptr CZeroInflationIndex'
-> CInt
-> Ptr CSchedule
-> CUInt
-> Ptr CDouble
-> Ptr CDayCounter
-> CInt
-> CInt
-> Ptr CCalendar
-> CInt
-> CInt
-> Ptr CCalendar
-> CInt
-> CInt
-> Ptr (Ptr CChar)
-> IO (Ptr CCPIBond')
cpiBond'_ CUInt
a1' CDouble
a2' CDouble
a3' CInt
a4'1  CInt
a4'2 Ptr CZeroInflationIndex'
a5' CInt
a6' Ptr CSchedule
a7' CUInt
a8'1  Ptr CDouble
a8'2 Ptr CDayCounter
a9' CInt
a10' CInt
a11' Ptr CCalendar
a12' CInt
a13'1  CInt
a13'2 Ptr CCalendar
a14' CInt
a15' CInt
a16' Ptr (Ptr CChar)
a17' IO (Ptr CCPIBond') -> (Ptr CCPIBond' -> IO CPIBond) -> IO CPIBond
forall a b. IO a -> (a -> IO b) -> IO b
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= \Ptr CCPIBond'
res ->
  Ptr CCPIBond' -> IO CPIBond
peekCPIBond Ptr CCPIBond'
res IO CPIBond -> (CPIBond -> IO CPIBond) -> IO CPIBond
forall a b. IO a -> (a -> IO b) -> IO b
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= \CPIBond
res' ->
  Ptr (Ptr CChar) -> IO ()
errorCheck  Ptr (Ptr CChar)
a17'IO () -> IO CPIBond -> IO CPIBond
forall a b. IO a -> IO b -> IO b
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>>
  CPIBond -> IO CPIBond
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return (CPIBond
res')

{-# LINE 281 "./QuantLib/Instrument/Bond.chs" #-}


-- |zero-coupon bond
zeroCouponBond :: (Word) -- ^settlementDays
 -> (Calendar) -> (Double) -- ^faceAmount
 -> (Day) -- ^maturityDate
 -> (BusinessDayConvention) -> (Double) -- ^redemption
 -> (Maybe Day) -- ^issueDate
 -> IO ((Bond))
zeroCouponBond a1 a2 a3 a4 a5 a6 a7 =
  let {a1' = fromIntegral a1} in 
  withCalendar a2 $ \a2' -> 
  let {a3' = realToFrac a3} in 
  withDay a4 $ \a4' -> 
  let {a5' = fromEnumC a5} in 
  let {a6' = realToFrac a6} in 
  withMaybeDay a7 $ \a7' -> 
  preErrorCheck $ \a8' -> 
  zeroCouponBond'_ a1' a2' a3' a4' a5' a6' a7' a8' >>= \res ->
  peekBond res >>= \res' ->
  errorCheck  a8'>>
  return (res')

{-# LINE 291 "./QuantLib/Instrument/Bond.chs" #-}


-- |floating-rate bond (possibly capped and/or floored)
floatingRateBond :: (Word) -- ^settlementDays
 -> (Double) -- ^faceAmount
 -> (Schedule) -- ^schedule
 -> (GenIborIndex ibor) -> (DayCounter) -- ^accrualDayCounter
 -> (BusinessDayConvention) -> (Word) -- ^fixingDays
 -> ([Double]) -- ^gearings
 -> ([Double]) -- ^spreads
 -> ([Double]) -- ^caps
 -> ([Double]) -- ^floors
 -> (Bool) -- ^inArrears
 -> (Double) -- ^redemption
 -> (Maybe Day) -- ^issueDate
 -> ((Int,TimeUnit)) -- ^exCouponPeriod
 -> (Calendar) -- ^exCouponCalendar
 -> (BusinessDayConvention) -- ^exCouponConvention
 -> (Bool) -- ^exCouponEndOfMonth
 -> (BusinessDayConvention) -- ^fixingConvention
 -> IO ((Bond))
floatingRateBond :: forall ibor.
Word
-> Double
-> Schedule
-> GenIborIndex ibor
-> DayCounter
-> BusinessDayConvention
-> Word
-> [Double]
-> [Double]
-> [Double]
-> [Double]
-> Bool
-> Double
-> Maybe Day
-> (Int, TimeUnit)
-> Calendar
-> BusinessDayConvention
-> Bool
-> BusinessDayConvention
-> IO Bond
floatingRateBond Word
a1 Double
a2 Schedule
a3 GenIborIndex ibor
a4 DayCounter
a5 BusinessDayConvention
a6 Word
a7 [Double]
a8 [Double]
a9 [Double]
a10 [Double]
a11 Bool
a12 Double
a13 Maybe Day
a14 (Int, TimeUnit)
a15 Calendar
a16 BusinessDayConvention
a17 Bool
a18 BusinessDayConvention
a19 =
  let {a1' :: CUInt
a1' = Word -> CUInt
forall a b. (Integral a, Num b) => a -> b
fromIntegral Word
a1} in 
  let {a2' :: CDouble
a2' = Double -> CDouble
forall a b. (Real a, Fractional b) => a -> b
realToFrac Double
a2} in 
  Schedule -> (Ptr CSchedule -> IO Bond) -> IO Bond
forall b. Schedule -> (Ptr CSchedule -> IO b) -> IO b
withSchedule Schedule
a3 ((Ptr CSchedule -> IO Bond) -> IO Bond)
-> (Ptr CSchedule -> IO Bond) -> IO Bond
forall a b. (a -> b) -> a -> b
$ \Ptr CSchedule
a3' -> 
  GenIborIndex ibor -> (Ptr CIborIndex' -> IO Bond) -> IO Bond
forall ibor b.
GenIborIndex ibor -> (Ptr CIborIndex' -> IO b) -> IO b
withIborIndex GenIborIndex ibor
a4 ((Ptr CIborIndex' -> IO Bond) -> IO Bond)
-> (Ptr CIborIndex' -> IO Bond) -> IO Bond
forall a b. (a -> b) -> a -> b
$ \Ptr CIborIndex'
a4' -> 
  DayCounter -> (Ptr CDayCounter -> IO Bond) -> IO Bond
forall b. DayCounter -> (Ptr CDayCounter -> IO b) -> IO b
withDayCounter DayCounter
a5 ((Ptr CDayCounter -> IO Bond) -> IO Bond)
-> (Ptr CDayCounter -> IO Bond) -> IO Bond
forall a b. (a -> b) -> a -> b
$ \Ptr CDayCounter
a5' -> 
  let {a6' :: CInt
a6' = BusinessDayConvention -> CInt
forall a b. (Enum a, Integral b) => a -> b
fromEnumC BusinessDayConvention
a6} in 
  let {a7' :: CUInt
a7' = Word -> CUInt
forall a b. (Integral a, Num b) => a -> b
fromIntegral Word
a7} in 
  [Double] -> ((CUInt, Ptr CDouble) -> IO Bond) -> IO Bond
forall b. [Double] -> ((CUInt, Ptr CDouble) -> IO b) -> IO b
withDoubleArray [Double]
a8 (((CUInt, Ptr CDouble) -> IO Bond) -> IO Bond)
-> ((CUInt, Ptr CDouble) -> IO Bond) -> IO Bond
forall a b. (a -> b) -> a -> b
$ \(CUInt
a8'1, Ptr CDouble
a8'2) -> 
  [Double] -> ((CUInt, Ptr CDouble) -> IO Bond) -> IO Bond
forall b. [Double] -> ((CUInt, Ptr CDouble) -> IO b) -> IO b
withDoubleArray [Double]
a9 (((CUInt, Ptr CDouble) -> IO Bond) -> IO Bond)
-> ((CUInt, Ptr CDouble) -> IO Bond) -> IO Bond
forall a b. (a -> b) -> a -> b
$ \(CUInt
a9'1, Ptr CDouble
a9'2) -> 
  [Double] -> ((CUInt, Ptr CDouble) -> IO Bond) -> IO Bond
forall b. [Double] -> ((CUInt, Ptr CDouble) -> IO b) -> IO b
withDoubleArray [Double]
a10 (((CUInt, Ptr CDouble) -> IO Bond) -> IO Bond)
-> ((CUInt, Ptr CDouble) -> IO Bond) -> IO Bond
forall a b. (a -> b) -> a -> b
$ \(CUInt
a10'1, Ptr CDouble
a10'2) -> 
  [Double] -> ((CUInt, Ptr CDouble) -> IO Bond) -> IO Bond
forall b. [Double] -> ((CUInt, Ptr CDouble) -> IO b) -> IO b
withDoubleArray [Double]
a11 (((CUInt, Ptr CDouble) -> IO Bond) -> IO Bond)
-> ((CUInt, Ptr CDouble) -> IO Bond) -> IO Bond
forall a b. (a -> b) -> a -> b
$ \(CUInt
a11'1, Ptr CDouble
a11'2) -> 
  let {a12' :: CInt
a12' = Bool -> CInt
forall a. Num a => Bool -> a
C2HSImp.fromBool Bool
a12} in 
  let {a13' :: CDouble
a13' = Double -> CDouble
forall a b. (Real a, Fractional b) => a -> b
realToFrac Double
a13} in 
  Maybe Day -> (CInt -> IO Bond) -> IO Bond
forall a. Maybe Day -> (CInt -> IO a) -> IO a
withMaybeDay Maybe Day
a14 ((CInt -> IO Bond) -> IO Bond) -> (CInt -> IO Bond) -> IO Bond
forall a b. (a -> b) -> a -> b
$ \CInt
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 Bond) -> IO Bond
forall b. Calendar -> (Ptr CCalendar -> IO b) -> IO b
withCalendar Calendar
a16 ((Ptr CCalendar -> IO Bond) -> IO Bond)
-> (Ptr CCalendar -> IO Bond) -> IO Bond
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 
  (Ptr (Ptr CChar) -> IO Bond) -> IO Bond
forall a b. (Ptr (Ptr a) -> IO b) -> IO b
preErrorCheck ((Ptr (Ptr CChar) -> IO Bond) -> IO Bond)
-> (Ptr (Ptr CChar) -> IO Bond) -> IO Bond
forall a b. (a -> b) -> a -> b
$ \Ptr (Ptr CChar)
a20' -> 
  CUInt
-> CDouble
-> Ptr CSchedule
-> Ptr CIborIndex'
-> Ptr CDayCounter
-> CInt
-> CUInt
-> CUInt
-> Ptr CDouble
-> CUInt
-> Ptr CDouble
-> CUInt
-> Ptr CDouble
-> CUInt
-> Ptr CDouble
-> CInt
-> CDouble
-> CInt
-> CInt
-> CInt
-> Ptr CCalendar
-> CInt
-> CInt
-> CInt
-> Ptr (Ptr CChar)
-> IO (Ptr CBond')
floatingRateBond'_ CUInt
a1' CDouble
a2' Ptr CSchedule
a3' Ptr CIborIndex'
a4' Ptr CDayCounter
a5' CInt
a6' CUInt
a7' CUInt
a8'1  Ptr CDouble
a8'2 CUInt
a9'1  Ptr CDouble
a9'2 CUInt
a10'1  Ptr CDouble
a10'2 CUInt
a11'1  Ptr CDouble
a11'2 CInt
a12' CDouble
a13' CInt
a14' CInt
a15'1  CInt
a15'2 Ptr CCalendar
a16' CInt
a17' CInt
a18' CInt
a19' Ptr (Ptr CChar)
a20' IO (Ptr CBond') -> (Ptr CBond' -> IO Bond) -> IO Bond
forall a b. IO a -> (a -> IO b) -> IO b
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= \Ptr CBond'
res ->
  Ptr CBond' -> IO Bond
peekBond Ptr CBond'
res IO Bond -> (Bond -> IO Bond) -> IO Bond
forall a b. IO a -> (a -> IO b) -> IO b
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= \Bond
res' ->
  Ptr (Ptr CChar) -> IO ()
errorCheck  Ptr (Ptr CChar)
a20'IO () -> IO Bond -> IO Bond
forall a b. IO a -> IO b -> IO b
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>>
  Bond -> IO Bond
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return (Bond
res')

{-# LINE 313 "./QuantLib/Instrument/Bond.chs" #-}


-- |CMS-rate bond
cmsRateBond :: (Word) -- ^settlementDays
 -> (Double) -- ^faceAmount
 -> (Schedule) -- ^schedule
 -> (GenSwapIndex sidx) -> (DayCounter) -- ^paymentDayCounter
 -> (BusinessDayConvention) -- ^paymentConvention
 -> (Word) -- ^fixingDays
 -> ([Double]) -- ^gearings
 -> ([Double]) -- ^spreads
 -> ([Double]) -- ^caps
 -> ([Double]) -- ^floors
 -> (Bool) -- ^inArrears
 -> (Double) -- ^redemption
 -> (Maybe Day) -- ^issueDate
 -> IO ((Bond))
cmsRateBond a1 a2 a3 a4 a5 a6 a7 a8 a9 a10 a11 a12 a13 a14 =
  let {a1' = fromIntegral a1} in 
  let {a2' = realToFrac a2} in 
  withSchedule a3 $ \a3' -> 
  withSwapIndex a4 $ \a4' -> 
  withDayCounter a5 $ \a5' -> 
  let {a6' = fromEnumC a6} in 
  let {a7' = fromIntegral a7} in 
  withDoubleArray a8 $ \(a8'1, a8'2) -> 
  withDoubleArray a9 $ \(a9'1, a9'2) -> 
  withDoubleArray a10 $ \(a10'1, a10'2) -> 
  withDoubleArray a11 $ \(a11'1, a11'2) -> 
  let {a12' = C2HSImp.fromBool a12} in 
  let {a13' = realToFrac a13} in 
  withMaybeDay a14 $ \a14' -> 
  preErrorCheck $ \a15' -> 
  cmsRateBond'_ a1' a2' a3' a4' a5' a6' a7' a8'1  a8'2 a9'1  a9'2 a10'1  a10'2 a11'1  a11'2 a12' a13' a14' a15' >>= \res ->
  peekBond res >>= \res' ->
  errorCheck  a15'>>
  return (res')

{-# LINE 330 "./QuantLib/Instrument/Bond.chs" #-}


-- |amortizing CMS-rate bond (possibly capped and\/or floored) with a per-period
-- notional schedule instead of a single face amount, and a per-period redemption
-- schedule instead of a single redemption value.
amortizingCmsRateBond :: (Word) -- ^settlementDays
 -> (NonEmpty Double) -- ^notionals
 -> (Schedule) -- ^schedule
 -> (GenSwapIndex sidx) -> (DayCounter) -- ^paymentDayCounter
 -> (BusinessDayConvention) -- ^paymentConvention
 -> (Word) -- ^fixingDays
 -> ([Double]) -- ^gearings
 -> ([Double]) -- ^spreads
 -> ([Double]) -- ^caps
 -> ([Double]) -- ^floors
 -> (Bool) -- ^inArrears
 -> (Maybe Day) -- ^issueDate
 -> ([Double]) -- ^redemptions
 -> IO ((Bond))
amortizingCmsRateBond a1 a2 a3 a4 a5 a6 a7 a8 a9 a10 a11 a12 a13 a14 =
  let {a1' = fromIntegral a1} in 
  withNonEmptyDoubleArray a2 $ \(a2'1, a2'2) -> 
  withSchedule a3 $ \a3' -> 
  withSwapIndex a4 $ \a4' -> 
  withDayCounter a5 $ \a5' -> 
  let {a6' = fromEnumC a6} in 
  let {a7' = fromIntegral a7} in 
  withDoubleArray a8 $ \(a8'1, a8'2) -> 
  withDoubleArray a9 $ \(a9'1, a9'2) -> 
  withDoubleArray a10 $ \(a10'1, a10'2) -> 
  withDoubleArray a11 $ \(a11'1, a11'2) -> 
  let {a12' = C2HSImp.fromBool a12} in 
  withMaybeDay a13 $ \a13' -> 
  withDoubleArray a14 $ \(a14'1, a14'2) -> 
  preErrorCheck $ \a15' -> 
  amortizingCmsRateBond'_ a1' a2'1  a2'2 a3' a4' a5' a6' a7' a8'1  a8'2 a9'1  a9'2 a10'1  a10'2 a11'1  a11'2 a12' a13' a14'1  a14'2 a15' >>= \res ->
  peekBond res >>= \res' ->
  errorCheck  a15'>>
  return (res')

{-# LINE 349 "./QuantLib/Instrument/Bond.chs" #-}


-- |amortizing floating-rate bond (possibly capped and\/or floored) with a per-period
-- notional schedule instead of a single face amount; see 'AmortizingFloatingRateBondOpts'
-- for the trailing optional parameters (default via 'defaultAmortizingFloatingRateBondOpts',
-- override with record-update syntax).
amortizingFloatingRateBond :: Word -> NonEmpty Double -> Schedule -> GenIborIndex ibor -> DayCounter
  -> AmortizingFloatingRateBondOpts -> IO Bond
amortizingFloatingRateBond settlementDays notionalsArg schedule idx accrualDayCounter opts = do
  cal <- calendar Null
  amortizingFloatingRateBond_ settlementDays notionalsArg schedule idx accrualDayCounter
    (afrbPaymentConvention opts) (fromMaybeInt (afrbFixingDays opts))
    (afrbGearings opts) (afrbSpreads opts) (afrbCaps opts) (afrbFloors opts)
    (afrbInArrears opts) (afrbIssueDate opts) (afrbExCouponPeriod opts)
    (fromMaybe cal (afrbExCouponCalendar opts)) (afrbExCouponConvention opts)
    (afrbExCouponEndOfMonth opts) (afrbRedemptions opts) (afrbPaymentLag opts)

-- |raw entry point for 'amortizingFloatingRateBond', taking every trailing option as a
-- separate flat argument; see 'AmortizingFloatingRateBondOpts' for the public wrapper.
amortizingFloatingRateBond_ :: (Word) -- ^settlementDays
 -> (NonEmpty Double) -- ^notionals
 -> (Schedule) -- ^schedule
 -> (GenIborIndex ibor) -> (DayCounter) -- ^accrualDayCounter
 -> (BusinessDayConvention) -- ^paymentConvention
 -> (Word) -- ^fixingDays
 -> ([Double]) -- ^gearings
 -> ([Double]) -- ^spreads
 -> ([Double]) -- ^caps
 -> ([Double]) -- ^floors
 -> (Bool) -- ^inArrears
 -> (Maybe Day) -- ^issueDate
 -> ((Int,TimeUnit)) -- ^exCouponPeriod
 -> (Calendar) -- ^exCouponCalendar
 -> (BusinessDayConvention) -- ^exCouponConvention
 -> (Bool) -- ^exCouponEndOfMonth
 -> ([Double]) -- ^redemptions
 -> (Int) -- ^paymentLag
 -> IO ((Bond))
amortizingFloatingRateBond_ :: forall ibor.
Word
-> NonEmpty Double
-> Schedule
-> GenIborIndex ibor
-> DayCounter
-> BusinessDayConvention
-> Word
-> [Double]
-> [Double]
-> [Double]
-> [Double]
-> Bool
-> Maybe Day
-> (Int, TimeUnit)
-> Calendar
-> BusinessDayConvention
-> Bool
-> [Double]
-> Int
-> IO Bond
amortizingFloatingRateBond_ Word
a1 NonEmpty Double
a2 Schedule
a3 GenIborIndex ibor
a4 DayCounter
a5 BusinessDayConvention
a6 Word
a7 [Double]
a8 [Double]
a9 [Double]
a10 [Double]
a11 Bool
a12 Maybe Day
a13 (Int, TimeUnit)
a14 Calendar
a15 BusinessDayConvention
a16 Bool
a17 [Double]
a18 Int
a19 =
  let {a1' :: CUInt
a1' = Word -> CUInt
forall a b. (Integral a, Num b) => a -> b
fromIntegral Word
a1} in 
  NonEmpty Double -> ((CUInt, Ptr CDouble) -> IO Bond) -> IO Bond
forall b. NonEmpty Double -> ((CUInt, Ptr CDouble) -> IO b) -> IO b
withNonEmptyDoubleArray NonEmpty Double
a2 (((CUInt, Ptr CDouble) -> IO Bond) -> IO Bond)
-> ((CUInt, Ptr CDouble) -> IO Bond) -> IO Bond
forall a b. (a -> b) -> a -> b
$ \(CUInt
a2'1, Ptr CDouble
a2'2) -> 
  Schedule -> (Ptr CSchedule -> IO Bond) -> IO Bond
forall b. Schedule -> (Ptr CSchedule -> IO b) -> IO b
withSchedule Schedule
a3 ((Ptr CSchedule -> IO Bond) -> IO Bond)
-> (Ptr CSchedule -> IO Bond) -> IO Bond
forall a b. (a -> b) -> a -> b
$ \Ptr CSchedule
a3' -> 
  GenIborIndex ibor -> (Ptr CIborIndex' -> IO Bond) -> IO Bond
forall ibor b.
GenIborIndex ibor -> (Ptr CIborIndex' -> IO b) -> IO b
withIborIndex GenIborIndex ibor
a4 ((Ptr CIborIndex' -> IO Bond) -> IO Bond)
-> (Ptr CIborIndex' -> IO Bond) -> IO Bond
forall a b. (a -> b) -> a -> b
$ \Ptr CIborIndex'
a4' -> 
  DayCounter -> (Ptr CDayCounter -> IO Bond) -> IO Bond
forall b. DayCounter -> (Ptr CDayCounter -> IO b) -> IO b
withDayCounter DayCounter
a5 ((Ptr CDayCounter -> IO Bond) -> IO Bond)
-> (Ptr CDayCounter -> IO Bond) -> IO Bond
forall a b. (a -> b) -> a -> b
$ \Ptr CDayCounter
a5' -> 
  let {a6' :: CInt
a6' = BusinessDayConvention -> CInt
forall a b. (Enum a, Integral b) => a -> b
fromEnumC BusinessDayConvention
a6} in 
  let {a7' :: CUInt
a7' = Word -> CUInt
forall a b. (Integral a, Num b) => a -> b
fromIntegral Word
a7} in 
  [Double] -> ((CUInt, Ptr CDouble) -> IO Bond) -> IO Bond
forall b. [Double] -> ((CUInt, Ptr CDouble) -> IO b) -> IO b
withDoubleArray [Double]
a8 (((CUInt, Ptr CDouble) -> IO Bond) -> IO Bond)
-> ((CUInt, Ptr CDouble) -> IO Bond) -> IO Bond
forall a b. (a -> b) -> a -> b
$ \(CUInt
a8'1, Ptr CDouble
a8'2) -> 
  [Double] -> ((CUInt, Ptr CDouble) -> IO Bond) -> IO Bond
forall b. [Double] -> ((CUInt, Ptr CDouble) -> IO b) -> IO b
withDoubleArray [Double]
a9 (((CUInt, Ptr CDouble) -> IO Bond) -> IO Bond)
-> ((CUInt, Ptr CDouble) -> IO Bond) -> IO Bond
forall a b. (a -> b) -> a -> b
$ \(a9'1, a9'2) -> 
  withDoubleArray a10 $ \(a10'1, a10'2) -> 
  withDoubleArray a11 $ \(a11'1, a11'2) -> 
  let {a12' = C2HSImp.fromBool a12} in 
  withMaybeDay a13 $ \a13' -> 
  let {(a14'1, a14'2) = fromEnumQuantity a14} in 
  withCalendar a15 $ \a15' -> 
  let {a16' = fromEnumC a16} in 
  let {a17' = C2HSImp.fromBool a17} in 
  withDoubleArray a18 $ \(a18'1, a18'2) -> 
  let {a19' = fromIntegral a19} in 
  preErrorCheck $ \a20' -> 
  amortizingFloatingRateBond_'_ a1' a2'1  a2'2 a3' a4' a5' a6' a7' a8'1  a8'2 a9'1  a9'2 a10'1  a10'2 a11'1  a11'2 a12' a13' a14'1  a14'2 a15' a16' a17' a18'1  a18'2 a19' a20' >>= \res ->
  peekBond res >>= \res' ->
  errorCheck  a20'>>
  return (res')

{-# LINE 387 "./QuantLib/Instrument/Bond.chs" #-}


-- |theoretical bond yield
yield :: (GenBond b) -> (DayCounter) -> (Compounding) -> (Frequency) -> (Double) -- ^accuracy
 -> (Word) -- ^maxEvaluations
 -> (Double,BondPriceType) -- ^guess, priceType
 -> IO ((Double))
yield a1 a2 a3 a4 a5 a6 a7 =
  withBond a1 $ \a1' -> 
  withDayCounter a2 $ \a2' -> 
  let {a3' = (fromIntegral . fromEnum) a3} in 
  let {a4' = (fromIntegral . fromEnum) a4} in 
  let {a5' = realToFrac a5} in 
  let {a6' = fromIntegral a6} in 
  let {(a7'1, a7'2) = fromEnumDouble a7} in 
  preErrorCheck $ \a8' -> 
  yield'_ a1' a2' a3' a4' a5' a6' a7'1  a7'2 a8' >>= \res ->
  let {res' = realToFrac res} in
  errorCheck  a8'>>
  return (res')

{-# LINE 394 "./QuantLib/Instrument/Bond.chs" #-}


-- |accrued amount at a given date
accruedAmount :: (GenBond b) -> (Day) -> IO ((Double))
accruedAmount a1 a2 =
  withBond a1 $ \a1' -> 
  withDay a2 $ \a2' -> 
  preErrorCheck $ \a3' -> 
  accruedAmount'_ a1' a2' a3' >>= \res ->
  let {res' = realToFrac res} in
  errorCheck  a3'>>
  return (res')

{-# LINE 397 "./QuantLib/Instrument/Bond.chs" #-}


-- |dirty price given a yield and settlement date
dirtyPriceFromYield :: (GenBond b) -> (Double) -> (DayCounter) -> (Compounding) -> (Frequency) -> (Day) -> IO ((Double))
dirtyPriceFromYield a1 a2 a3 a4 a5 a6 =
  withBond a1 $ \a1' -> 
  let {a2' = realToFrac a2} in 
  withDayCounter a3 $ \a3' -> 
  let {a4' = (fromIntegral . fromEnum) a4} in 
  let {a5' = (fromIntegral . fromEnum) a5} in 
  withDay a6 $ \a6' -> 
  preErrorCheck $ \a7' -> 
  dirtyPriceFromYield'_ a1' a2' a3' a4' a5' a6' a7' >>= \res ->
  let {res' = realToFrac res} in
  errorCheck  a7'>>
  return (res')

{-# LINE 400 "./QuantLib/Instrument/Bond.chs" #-}


-- |date of the next cash flow after the given (or default settlement) date
nextCashFlowDate :: (GenBond b) -> (Day) -> IO ((Maybe Day))
nextCashFlowDate a1 a2 =
  withBond a1 $ \a1' -> 
  withDay a2 $ \a2' -> 
  preErrorCheck $ \a3' -> 
  nextCashFlowDate'_ a1' a2' a3' >>= \res ->
  let {res' = toMaybeDay res} in
  errorCheck  a3'>>
  return (res')

{-# LINE 403 "./QuantLib/Instrument/Bond.chs" #-}


-- |Expected next coupon: depending on (the bond and) the given date the coupon can be historic, deterministic or expected in a stochastic sense. When the bond settlement date is used the coupon is the already-fixed not-yet-paid one.The current bond settlement is used if no date is given.
nextCouponRate :: (GenBond b) -> (Day) -> IO ((Double))
nextCouponRate a1 a2 =
  withBond a1 $ \a1' -> 
  withDay a2 $ \a2' -> 
  preErrorCheck $ \a3' -> 
  nextCouponRate'_ a1' a2' a3' >>= \res ->
  let {res' = realToFrac res} in
  errorCheck  a3'>>
  return (res')

{-# LINE 406 "./QuantLib/Instrument/Bond.chs" #-}


-- |bond notional outstanding at the given date
notional :: (GenBond b) -> (Day) -> IO ((Double))
notional a1 a2 =
  withBond a1 $ \a1' -> 
  withDay a2 $ \a2' -> 
  preErrorCheck $ \a3' -> 
  notional'_ a1' a2' a3' >>= \res ->
  let {res' = realToFrac res} in
  errorCheck  a3'>>
  return (res')

{-# LINE 409 "./QuantLib/Instrument/Bond.chs" #-}


-- |date of the cash flow immediately before the given (or default settlement) date
previousCashFlowDate :: (GenBond b) -> (Day) -> IO ((Maybe Day))
previousCashFlowDate a1 a2 =
  withBond a1 $ \a1' -> 
  withDay a2 $ \a2' -> 
  preErrorCheck $ \a3' -> 
  previousCashFlowDate'_ a1' a2' a3' >>= \res ->
  let {res' = toMaybeDay res} in
  errorCheck  a3'>>
  return (res')

{-# LINE 412 "./QuantLib/Instrument/Bond.chs" #-}


-- |Previous coupon already paid at a given date.
-- Expected previous coupon: depending on (the bond and) the given date the coupon can be historic, deterministic or expected in a stochastic sense. When the bond settlement date is used the coupon is the last paid one.The current bond settlement is used if no date is given.
previousCouponRate :: (GenBond b) -> (Day) -> IO ((Double))
previousCouponRate a1 a2 =
  withBond a1 $ \a1' -> 
  withDay a2 $ \a2' -> 
  preErrorCheck $ \a3' -> 
  previousCouponRate'_ a1' a2' a3' >>= \res ->
  let {res' = realToFrac res} in
  errorCheck  a3'>>
  return (res')

{-# LINE 416 "./QuantLib/Instrument/Bond.chs" #-}


-- |settlement value as a function of the clean price
-- The default bond settlement date is used for calculation.
settlementValueFromCleanPrice :: (GenBond b) -> (Double) -> IO ((Double))
settlementValueFromCleanPrice a1 a2 =
  withBond a1 $ \a1' -> 
  let {a2' = realToFrac a2} in 
  preErrorCheck $ \a3' -> 
  settlementValueFromCleanPrice'_ a1' a2' a3' >>= \res ->
  let {res' = realToFrac res} in
  errorCheck  a3'>>
  return (res')

{-# LINE 420 "./QuantLib/Instrument/Bond.chs" #-}


-- |theoretical settlement value
-- The default bond settlement date is used for calculation.
settlementValue :: (GenBond b) -> IO ((Double))
settlementValue a1 =
  withBond a1 $ \a1' -> 
  preErrorCheck $ \a2' -> 
  settlementValue'_ a1' a2' >>= \res ->
  let {res' = realToFrac res} in
  errorCheck  a2'>>
  return (res')

{-# LINE 424 "./QuantLib/Instrument/Bond.chs" #-}


-- |yield given a (clean) price and settlement date
yieldFromPrice :: (GenBond b) -> (Double,BondPriceType) -> (DayCounter) -> (Compounding) -> (Frequency) -> (Day) -- settlementDate
 -> (Double) -- ^accuracy
 -> (Word) -- ^maxEvaluations
 -> IO ((Double))
yieldFromPrice a1 a2 a3 a4 a5 a6 a7 a8 =
  withBond a1 $ \a1' -> 
  let {(a2'1, a2'2) = fromEnumDouble a2} in 
  withDayCounter a3 $ \a3' -> 
  let {a4' = (fromIntegral . fromEnum) a4} in 
  let {a5' = (fromIntegral . fromEnum) a5} in 
  withDay a6 $ \a6' -> 
  let {a7' = realToFrac a7} in 
  let {a8' = fromIntegral a8} in 
  preErrorCheck $ \a9' -> 
  yieldFromPrice'_ a1' a2'1  a2'2 a3' a4' a5' a6' a7' a8' a9' >>= \res ->
  let {res' = realToFrac res} in
  errorCheck  a9'>>
  return (res')

{-# LINE 431 "./QuantLib/Instrument/Bond.chs" #-}


-- |whether the bond can be traded (i.e. still has a positive notional) at the given date
isTradable :: (GenBond b) -> (Day) -> IO ((Bool))
isTradable a1 a2 =
  withBond a1 $ \a1' -> 
  withDay a2 $ \a2' -> 
  preErrorCheck $ \a3' -> 
  isTradable'_ a1' a2' a3' >>= \res ->
  let {res' = C2HSImp.toBool res} in
  errorCheck  a3'>>
  return (res')

{-# LINE 434 "./QuantLib/Instrument/Bond.chs" #-}


-- |notionals for each period of the bond's amortization schedule
notionals :: (GenBond b) -> IO (([Double]))
notionals a1 =
  withBond a1 $ \a1' -> 
  preArray $ \(a2'1, a2'2) -> 
  preErrorCheck $ \a3' -> 
  notionals'_ a1' a2'1  a2'2 a3' >>
  peekDoubleArray  a2'1  a2'2>>= \a2'' -> 
  errorCheck  a3'>>
  return (a2'')

{-# LINE 437 "./QuantLib/Instrument/Bond.chs" #-}


-- |returns all the cashflows, including the redemptions.
cashFlows :: (GenBond b) -> IO ((Leg))
cashFlows a1 =
  withBond a1 $ \a1' -> 
  preErrorCheck $ \a2' -> 
  cashFlows'_ a1' a2' >>= \res ->
  peekLeg res >>= \res' ->
  errorCheck  a2'>>
  return (res')

{-# LINE 440 "./QuantLib/Instrument/Bond.chs" #-}


-- |returns just the redemption flows (not interest payments)
redemptions :: (GenBond b) -> IO ((Leg))
redemptions a1 =
  withBond a1 $ \a1' -> 
  preErrorCheck $ \a2' -> 
  redemptions'_ a1' a2' >>= \res ->
  peekLeg res >>= \res' ->
  errorCheck  a2'>>
  return (res')

{-# LINE 443 "./QuantLib/Instrument/Bond.chs" #-}


-- |settlement date computed from the given date (or today's date if none is given)
settlementDate :: (GenBond b) -> (Day) -> IO ((Day))
settlementDate a1 a2 =
  withBond a1 $ \a1' -> 
  withDay a2 $ \a2' -> 
  preErrorCheck $ \a3' -> 
  settlementDate'_ a1' a2' a3' >>= \res ->
  let {res' = toDay res} in
  errorCheck  a3'>>
  return (res')

{-# LINE 446 "./QuantLib/Instrument/Bond.chs" #-}


-- |date the bond starts accruing
startDate :: (GenBond b) -> IO ((Day))
startDate a1 =
  withBond a1 $ \a1' -> 
  preErrorCheck $ \a2' -> 
  startDate'_ a1' a2' >>= \res ->
  let {res' = toDay res} in
  errorCheck  a2'>>
  return (res')

{-# LINE 449 "./QuantLib/Instrument/Bond.chs" #-}


-- |number of days in the current accrual period up to the given (or default settlement) date
accrualDays :: (GenBond b) -> (Day) -> IO ((Int))
accrualDays a1 a2 =
  withBond a1 $ \a1' -> 
  withDay a2 $ \a2' -> 
  preErrorCheck $ \a3' -> 
  accrualDays'_ a1' a2' a3' >>= \res ->
  let {res' = fromIntegral res} in
  errorCheck  a3'>>
  return (res')

{-# LINE 452 "./QuantLib/Instrument/Bond.chs" #-}


-- |end date of the accrual period containing the given (or default settlement) date
accrualEndDate :: (GenBond b) -> (Day) -> IO ((Maybe Day))
accrualEndDate a1 a2 =
  withBond a1 $ \a1' -> 
  withDay a2 $ \a2' -> 
  preErrorCheck $ \a3' -> 
  accrualEndDate'_ a1' a2' a3' >>= \res ->
  let {res' = toMaybeDay res} in
  errorCheck  a3'>>
  return (res')

{-# LINE 455 "./QuantLib/Instrument/Bond.chs" #-}


-- |length in time of the accrual period containing the given (or default settlement) date
accrualPeriod :: (GenBond b) -> (Day) -> IO ((Double))
accrualPeriod a1 a2 =
  withBond a1 $ \a1' -> 
  withDay a2 $ \a2' -> 
  preErrorCheck $ \a3' -> 
  accrualPeriod'_ a1' a2' a3' >>= \res ->
  let {res' = realToFrac res} in
  errorCheck  a3'>>
  return (res')

{-# LINE 458 "./QuantLib/Instrument/Bond.chs" #-}


-- |start date of the accrual period containing the given (or default settlement) date
accrualStartDate :: (GenBond b) -> (Day) -> IO ((Maybe Day))
accrualStartDate a1 a2 =
  withBond a1 $ \a1' -> 
  withDay a2 $ \a2' -> 
  preErrorCheck $ \a3' -> 
  accrualStartDate'_ a1' a2' a3' >>= \res ->
  let {res' = toMaybeDay res} in
  errorCheck  a3'>>
  return (res')

{-# LINE 461 "./QuantLib/Instrument/Bond.chs" #-}


-- |number of days accrued up to the given (or default settlement) date
accruedDays :: (GenBond b) -> (Day) -> IO ((Int))
accruedDays a1 a2 =
  withBond a1 $ \a1' -> 
  withDay a2 $ \a2' -> 
  preErrorCheck $ \a3' -> 
  accruedDays'_ a1' a2' a3' >>= \res ->
  let {res' = fromIntegral res} in
  errorCheck  a3'>>
  return (res')

{-# LINE 464 "./QuantLib/Instrument/Bond.chs" #-}


-- |length in time accrued up to the given (or default settlement) date
accruedPeriod :: (GenBond b) -> (Day) -> IO ((Double))
accruedPeriod a1 a2 =
  withBond a1 $ \a1' -> 
  withDay a2 $ \a2' -> 
  preErrorCheck $ \a3' -> 
  accruedPeriod'_ a1' a2' a3' >>= \res ->
  let {res' = realToFrac res} in
  errorCheck  a3'>>
  return (res')

{-# LINE 467 "./QuantLib/Instrument/Bond.chs" #-}


-- |basis-point value given an 'InterestRate' yield
basisPointValue :: (GenBond b) -> (InterestRate) -> (Day) -> IO ((Double))
basisPointValue a1 a2 a3 =
  withBond a1 $ \a1' -> 
  withInterestRate a2 $ \a2' -> 
  withDay a3 $ \a3' -> 
  preErrorCheck $ \a4' -> 
  basisPointValue'_ a1' a2' a3' a4' >>= \res ->
  let {res' = realToFrac res} in
  errorCheck  a4'>>
  return (res')

{-# LINE 470 "./QuantLib/Instrument/Bond.chs" #-}


-- |bps (Basis Point Sensitivity) given an 'InterestRate' yield
bpsFromYieldRaw :: (GenBond b) -> (InterestRate) -> (Day) -> IO ((Double))
bpsFromYieldRaw a1 a2 a3 =
  withBond a1 $ \a1' -> 
  withInterestRate a2 $ \a2' -> 
  withDay a3 $ \a3' -> 
  preErrorCheck $ \a4' -> 
  bpsFromYieldRaw'_ a1' a2' a3' a4' >>= \res ->
  let {res' = realToFrac res} in
  errorCheck  a4'>>
  return (res')

{-# LINE 473 "./QuantLib/Instrument/Bond.chs" #-}


-- |bps (Basis Point Sensitivity) given a discount curve
bpsFromCurveRaw :: (GenBond b) -> (GenYieldTermStructure y) -> (Day) -> IO ((Double))
bpsFromCurveRaw a1 a2 a3 =
  withBond a1 $ \a1' -> 
  withYieldTermStructure a2 $ \a2' -> 
  withDay a3 $ \a3' -> 
  preErrorCheck $ \a4' -> 
  bpsFromCurveRaw'_ a1' a2' a3' a4' >>= \res ->
  let {res' = realToFrac res} in
  errorCheck  a4'>>
  return (res')

{-# LINE 476 "./QuantLib/Instrument/Bond.chs" #-}


-- |clean price given a discount curve and settlement date
cleanPriceFromCurveRaw :: (GenBond b) -> (GenYieldTermStructure y) -> (Day) -> IO ((Double))
cleanPriceFromCurveRaw a1 a2 a3 =
  withBond a1 $ \a1' -> 
  withYieldTermStructure a2 $ \a2' -> 
  withDay a3 $ \a3' -> 
  preErrorCheck $ \a4' -> 
  cleanPriceFromCurveRaw'_ a1' a2' a3' a4' >>= \res ->
  let {res' = realToFrac res} in
  errorCheck  a4'>>
  return (res')

{-# LINE 479 "./QuantLib/Instrument/Bond.chs" #-}


-- |clean price given a discount curve, a Z-spread over it, compounding and frequency
cleanPriceWithZSpreadRaw :: (GenBond b) -> (GenYieldTermStructure y) -- ^discount
 -> (Double) -- ^zSpread
 -> (Compounding) -> (Frequency) -> (Day) -- ^settlementDate
 -> IO ((Double))
cleanPriceWithZSpreadRaw a1 a2 a3 a4 a5 a6 =
  withBond a1 $ \a1' -> 
  withYieldTermStructure a2 $ \a2' -> 
  let {a3' = realToFrac a3} in 
  let {a4' = (fromIntegral . fromEnum) a4} in 
  let {a5' = (fromIntegral . fromEnum) a5} in 
  withDay a6 $ \a6' -> 
  preErrorCheck $ \a7' -> 
  cleanPriceWithZSpreadRaw'_ a1' a2' a3' a4' a5' a6' a7' >>= \res ->
  let {res' = realToFrac res} in
  errorCheck  a7'>>
  return (res')

{-# LINE 485 "./QuantLib/Instrument/Bond.chs" #-}


-- |clean price given an 'InterestRate' yield
cleanPriceFromYieldRaw :: (GenBond b) -> (InterestRate) -> (Day) -> IO ((Double))
cleanPriceFromYieldRaw a1 a2 a3 =
  withBond a1 $ \a1' -> 
  withInterestRate a2 $ \a2' -> 
  withDay a3 $ \a3' -> 
  preErrorCheck $ \a4' -> 
  cleanPriceFromYieldRaw'_ a1' a2' a3' a4' >>= \res ->
  let {res' = realToFrac res} in
  errorCheck  a4'>>
  return (res')

{-# LINE 488 "./QuantLib/Instrument/Bond.chs" #-}


-- |Clean price under the given discounting, at a settlement date.
cleanPrice :: GenBond b -> Discounting y -> Day -> IO Double
cleanPrice instr discounting = case discounting of
  DiscountingCurve curve -> cleanPriceFromCurveRaw instr curve
  DiscountingZSpread curve z comp freq -> cleanPriceWithZSpreadRaw instr curve z comp freq
  DiscountingYield y -> cleanPriceFromYieldRaw instr y

-- |Basis-point sensitivity under the given discounting, at a settlement date.
bps :: GenBond b -> BpsDiscounting y -> Day -> IO Double
bps instr discounting = case discounting of
  BpsDiscountingCurve curve -> bpsFromCurveRaw instr curve
  BpsDiscountingYield y -> bpsFromYieldRaw instr y

-- |convexity given an 'InterestRate' yield
convexity :: (GenBond b) -> (InterestRate) -- ^yield
 -> (Day) -- ^settlementDate
 -> IO ((Double))
convexity :: forall b. GenBond b -> InterestRate -> Day -> IO Double
convexity GenBond b
a1 InterestRate
a2 Day
a3 =
  GenBond b -> (Ptr CBond' -> IO Double) -> IO Double
forall b r. GenBond b -> (Ptr CBond' -> IO r) -> IO r
withBond GenBond b
a1 ((Ptr CBond' -> IO Double) -> IO Double)
-> (Ptr CBond' -> IO Double) -> IO Double
forall a b. (a -> b) -> a -> b
$ \Ptr CBond'
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' -> 
  Day -> (CInt -> IO Double) -> IO Double
forall a. Day -> (CInt -> IO a) -> IO a
withDay Day
a3 ((CInt -> IO Double) -> IO Double)
-> (CInt -> IO Double) -> IO Double
forall a b. (a -> b) -> a -> b
$ \CInt
a3' -> 
  (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)
a4' -> 
  Ptr CBond'
-> Ptr CInterestRate -> CInt -> Ptr (Ptr CChar) -> IO CDouble
convexity'_ Ptr CBond'
a1' Ptr CInterestRate
a2' CInt
a3' Ptr (Ptr CChar)
a4' 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)
a4'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 506 "./QuantLib/Instrument/Bond.chs" #-}


-- |duration given an 'InterestRate' yield and duration type
duration :: (GenBond b) -> (InterestRate) -- ^yield
 -> (DurationType) -> (Day) -> IO ((Double))
duration a1 a2 a3 a4 =
  withBond a1 $ \a1' -> 
  withInterestRate a2 $ \a2' -> 
  let {a3' = (fromIntegral . fromEnum) a3} in 
  withDay a4 $ \a4' -> 
  preErrorCheck $ \a5' -> 
  duration'_ a1' a2' a3' a4' a5' >>= \res ->
  let {res' = realToFrac res} in
  errorCheck  a5'>>
  return (res')

{-# LINE 510 "./QuantLib/Instrument/Bond.chs" #-}


-- |amount of the cash flow immediately after the given (or default settlement) date
nextCashFlowAmount :: (GenBond b) -> (Day) -> IO ((Double))
nextCashFlowAmount a1 a2 =
  withBond a1 $ \a1' -> 
  withDay a2 $ \a2' -> 
  preErrorCheck $ \a3' -> 
  nextCashFlowAmount'_ a1' a2' a3' >>= \res ->
  let {res' = realToFrac res} in
  errorCheck  a3'>>
  return (res')

{-# LINE 513 "./QuantLib/Instrument/Bond.chs" #-}


-- |amount of the cash flow immediately before the given (or default settlement) date
previousCashFlowAmount :: (GenBond b) -> (Day) -> IO ((Double))
previousCashFlowAmount a1 a2 =
  withBond a1 $ \a1' -> 
  withDay a2 $ \a2' -> 
  preErrorCheck $ \a3' -> 
  previousCashFlowAmount'_ a1' a2' a3' >>= \res ->
  let {res' = realToFrac res} in
  errorCheck  a3'>>
  return (res')

{-# LINE 516 "./QuantLib/Instrument/Bond.chs" #-}


-- |end date of the reference period containing the given (or default settlement) date
referencePeriodEnd :: (GenBond b) -> (Day) -> IO ((Maybe Day))
referencePeriodEnd a1 a2 =
  withBond a1 $ \a1' -> 
  withDay a2 $ \a2' -> 
  preErrorCheck $ \a3' -> 
  referencePeriodEnd'_ a1' a2' a3' >>= \res ->
  let {res' = toMaybeDay res} in
  errorCheck  a3'>>
  return (res')

{-# LINE 519 "./QuantLib/Instrument/Bond.chs" #-}


-- |start date of the reference period containing the given (or default settlement) date
referencePeriodStart :: (GenBond b) -> (Day) -> IO ((Maybe Day))
referencePeriodStart a1 a2 =
  withBond a1 $ \a1' -> 
  withDay a2 $ \a2' -> 
  preErrorCheck $ \a3' -> 
  referencePeriodStart'_ a1' a2' a3' >>= \res ->
  let {res' = toMaybeDay res} in
  errorCheck  a3'>>
  return (res')

{-# LINE 522 "./QuantLib/Instrument/Bond.chs" #-}


-- |yield given a (clean) price and settlement date, solved to the given accuracy
yieldFromPriceWithGuess :: (GenBond b) -> (Double,BondPriceType) -> (DayCounter) -> (Compounding) -> (Frequency) -> (Day) -- ^settlementDate
 -> (Double) --  ^accuracy
 -> (Word) -- ^maxIterations
 -> (Double) -- ^guess
 -> IO ((Double))
yieldFromPriceWithGuess a1 a2 a3 a4 a5 a6 a7 a8 a9 =
  withBond a1 $ \a1' -> 
  let {(a2'1, a2'2) = fromEnumDouble a2} in 
  withDayCounter a3 $ \a3' -> 
  let {a4' = (fromIntegral . fromEnum) a4} in 
  let {a5' = (fromIntegral . fromEnum) a5} in 
  withDay a6 $ \a6' -> 
  let {a7' = realToFrac a7} in 
  let {a8' = fromIntegral a8} in 
  let {a9' = realToFrac a9} in 
  preErrorCheck $ \a10' -> 
  yieldFromPriceWithGuess'_ a1' a2'1  a2'2 a3' a4' a5' a6' a7' a8' a9' a10' >>= \res ->
  let {res' = realToFrac res} in
  errorCheck  a10'>>
  return (res')

{-# LINE 530 "./QuantLib/Instrument/Bond.chs" #-}


-- |yield value of a basis point given an 'InterestRate' yield
yieldValueBasisPoint :: (GenBond b) -> (InterestRate) -- ^yield
 -> (Day) -> IO ((Double))
yieldValueBasisPoint a1 a2 a3 =
  withBond a1 $ \a1' -> 
  withInterestRate a2 $ \a2' -> 
  withDay a3 $ \a3' -> 
  preErrorCheck $ \a4' -> 
  yieldValueBasisPoint'_ a1' a2' a3' a4' >>= \res ->
  let {res' = realToFrac res} in
  errorCheck  a4'>>
  return (res')

{-# LINE 534 "./QuantLib/Instrument/Bond.chs" #-}


-- |Z-spread over a discount curve implied by a (clean) price, solved to the given accuracy
zSpread :: (GenBond b) -> (Double,BondPriceType) -> (GenYieldTermStructure y) -> (Compounding) -> (Frequency) -> (Day) -- ^settlementDate
 -> (Double) -- ^accuracy
 -> (Word) -- ^maxIterations
 -> (Double) -- ^guess
 -> IO ((Double))
zSpread a1 a2 a3 a4 a5 a6 a7 a8 a9 =
  withBond a1 $ \a1' -> 
  let {(a2'1, a2'2) = fromEnumDouble a2} in 
  withYieldTermStructure a3 $ \a3' -> 
  let {a4' = (fromIntegral . fromEnum) a4} in 
  let {a5' = (fromIntegral . fromEnum) a5} in 
  withDay a6 $ \a6' -> 
  let {a7' = realToFrac a7} in 
  let {a8' = fromIntegral a8} in 
  let {a9' = realToFrac a9} in 
  preErrorCheck $ \a10' -> 
  zSpread'_ a1' a2'1  a2'2 a3' a4' a5' a6' a7' a8' a9' a10' >>= \res ->
  let {res' = realToFrac res} in
  errorCheck  a10'>>
  return (res')

{-# LINE 543 "./QuantLib/Instrument/Bond.chs" #-}


-- |theoretical clean price for the current evaluation date and term structure
currentCleanPrice :: (GenBond b) -> IO ((Double))
currentCleanPrice a1 =
  withBond a1 $ \a1' -> 
  preErrorCheck $ \a2' -> 
  currentCleanPrice'_ a1' a2' >>= \res ->
  let {res' = realToFrac res} in
  errorCheck  a2'>>
  return (res')

{-# LINE 546 "./QuantLib/Instrument/Bond.chs" #-}


-- |theoretical dirty price
-- The default bond settlement is used for calculation. /Warning/ the theoretical price calculated from a flat term structure might differ slightly from the price calculated from the corresponding yield by means of the other overload of this function. If the price from a constant yield is desired, it is advisable to use such other overload.
currentDirtyPrice :: (GenBond b) -> IO ((Double))
currentDirtyPrice a1 =
  withBond a1 $ \a1' -> 
  preErrorCheck $ \a2' -> 
  currentDirtyPrice'_ a1' a2' >>= \res ->
  let {res' = realToFrac res} in
  errorCheck  a2'>>
  return (res')

{-# LINE 550 "./QuantLib/Instrument/Bond.chs" #-}


-- |fixed-rate bond with an embedded call\/put schedule
callableFixedRateBond :: (Word) -- ^settlementDays
 -> (Double) -- ^faceAmount
 -> (Schedule) -> (NonEmpty Double) -- ^coupons
 -> (DayCounter) -> (BusinessDayConvention) -> (Double) -- ^redemption
 -> (Maybe Day) -- ^issueDate
 -> ([Callability]) -> ((Int,TimeUnit)) -- ^exCouponPeriod
 -> (Calendar) -- ^exCouponCalendar
 -> (BusinessDayConvention) -- ^exCouponConvention
 -> (Bool) -- ^exCouponEndOfMonth
 -> IO ((CallableBond))
callableFixedRateBond :: Word
-> Double
-> Schedule
-> NonEmpty Double
-> DayCounter
-> BusinessDayConvention
-> Double
-> Maybe Day
-> [Callability]
-> (Int, TimeUnit)
-> Calendar
-> BusinessDayConvention
-> Bool
-> IO CallableBond
callableFixedRateBond Word
a1 Double
a2 Schedule
a3 NonEmpty Double
a4 DayCounter
a5 BusinessDayConvention
a6 Double
a7 Maybe Day
a8 [Callability]
a9 (Int, TimeUnit)
a10 Calendar
a11 BusinessDayConvention
a12 Bool
a13 =
  let {a1' :: CUInt
a1' = Word -> CUInt
forall a b. (Integral a, Num b) => a -> b
fromIntegral Word
a1} in 
  let {a2' :: CDouble
a2' = Double -> CDouble
forall a b. (Real a, Fractional b) => a -> b
realToFrac Double
a2} in 
  Schedule -> (Ptr CSchedule -> IO CallableBond) -> IO CallableBond
forall b. Schedule -> (Ptr CSchedule -> IO b) -> IO b
withSchedule Schedule
a3 ((Ptr CSchedule -> IO CallableBond) -> IO CallableBond)
-> (Ptr CSchedule -> IO CallableBond) -> IO CallableBond
forall a b. (a -> b) -> a -> b
$ \Ptr CSchedule
a3' -> 
  NonEmpty Double
-> ((CUInt, Ptr CDouble) -> IO CallableBond) -> IO CallableBond
forall b. NonEmpty Double -> ((CUInt, Ptr CDouble) -> IO b) -> IO b
withNonEmptyDoubleArray NonEmpty Double
a4 (((CUInt, Ptr CDouble) -> IO CallableBond) -> IO CallableBond)
-> ((CUInt, Ptr CDouble) -> IO CallableBond) -> IO CallableBond
forall a b. (a -> b) -> a -> b
$ \(CUInt
a4'1, Ptr CDouble
a4'2) -> 
  DayCounter
-> (Ptr CDayCounter -> IO CallableBond) -> IO CallableBond
forall b. DayCounter -> (Ptr CDayCounter -> IO b) -> IO b
withDayCounter DayCounter
a5 ((Ptr CDayCounter -> IO CallableBond) -> IO CallableBond)
-> (Ptr CDayCounter -> IO CallableBond) -> IO CallableBond
forall a b. (a -> b) -> a -> b
$ \Ptr CDayCounter
a5' -> 
  let {a6' :: CInt
a6' = BusinessDayConvention -> CInt
forall a b. (Enum a, Integral b) => a -> b
fromEnumC BusinessDayConvention
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 CallableBond) -> IO CallableBond
forall a. Maybe Day -> (CInt -> IO a) -> IO a
withMaybeDay Maybe Day
a8 ((CInt -> IO CallableBond) -> IO CallableBond)
-> (CInt -> IO CallableBond) -> IO CallableBond
forall a b. (a -> b) -> a -> b
$ \CInt
a8' -> 
  [Callability]
-> ((CUInt, Ptr (Ptr CQlCallability)) -> IO CallableBond)
-> IO CallableBond
forall c.
[Callability]
-> ((CUInt, Ptr (Ptr CQlCallability)) -> IO c) -> IO c
withCallabilityArray [Callability]
a9 (((CUInt, Ptr (Ptr CQlCallability)) -> IO CallableBond)
 -> IO CallableBond)
-> ((CUInt, Ptr (Ptr CQlCallability)) -> IO CallableBond)
-> IO CallableBond
forall a b. (a -> b) -> a -> b
$ \(CUInt
a9'1, Ptr (Ptr CQlCallability)
a9'2) -> 
  let {(CInt
a10'1, CInt
a10'2) = (Int, TimeUnit) -> (CInt, CInt)
forall a b c.
(Enum a, Integral b, Integral c) =>
(b, a) -> (CInt, c)
fromEnumQuantity (Int, TimeUnit)
a10} in 
  Calendar -> (Ptr CCalendar -> IO CallableBond) -> IO CallableBond
forall b. Calendar -> (Ptr CCalendar -> IO b) -> IO b
withCalendar Calendar
a11 ((Ptr CCalendar -> IO CallableBond) -> IO CallableBond)
-> (Ptr CCalendar -> IO CallableBond) -> IO CallableBond
forall a b. (a -> b) -> a -> b
$ \Ptr CCalendar
a11' -> 
  let {a12' :: CInt
a12' = BusinessDayConvention -> CInt
forall a b. (Enum a, Integral b) => a -> b
fromEnumC BusinessDayConvention
a12} in 
  let {a13' :: CInt
a13' = Bool -> CInt
forall a. Num a => Bool -> a
C2HSImp.fromBool Bool
a13} in 
  (Ptr (Ptr CChar) -> IO CallableBond) -> IO CallableBond
forall a b. (Ptr (Ptr a) -> IO b) -> IO b
preErrorCheck ((Ptr (Ptr CChar) -> IO CallableBond) -> IO CallableBond)
-> (Ptr (Ptr CChar) -> IO CallableBond) -> IO CallableBond
forall a b. (a -> b) -> a -> b
$ \Ptr (Ptr CChar)
a14' -> 
  CUInt
-> CDouble
-> Ptr CSchedule
-> CUInt
-> Ptr CDouble
-> Ptr CDayCounter
-> CInt
-> CDouble
-> CInt
-> CUInt
-> Ptr (Ptr CQlCallability)
-> CInt
-> CInt
-> Ptr CCalendar
-> CInt
-> CInt
-> Ptr (Ptr CChar)
-> IO (Ptr CCallableBond')
callableFixedRateBond'_ CUInt
a1' CDouble
a2' Ptr CSchedule
a3' CUInt
a4'1  Ptr CDouble
a4'2 Ptr CDayCounter
a5' CInt
a6' CDouble
a7' CInt
a8' CUInt
a9'1  Ptr (Ptr CQlCallability)
a9'2 CInt
a10'1  CInt
a10'2 Ptr CCalendar
a11' CInt
a12' CInt
a13' Ptr (Ptr CChar)
a14' IO (Ptr CCallableBond')
-> (Ptr CCallableBond' -> IO CallableBond) -> IO CallableBond
forall a b. IO a -> (a -> IO b) -> IO b
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= \Ptr CCallableBond'
res ->
  Ptr CCallableBond' -> IO CallableBond
peekCallableBond Ptr CCallableBond'
res IO CallableBond
-> (CallableBond -> IO CallableBond) -> IO CallableBond
forall a b. IO a -> (a -> IO b) -> IO b
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= \CallableBond
res' ->
  Ptr (Ptr CChar) -> IO ()
errorCheck  Ptr (Ptr CChar)
a14'IO () -> IO CallableBond -> IO CallableBond
forall a b. IO a -> IO b -> IO b
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>>
  CallableBond -> IO CallableBond
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return (CallableBond
res')

{-# LINE 564 "./QuantLib/Instrument/Bond.chs" #-}


-- |zero-coupon bond with an embedded call\/put schedule
callableZeroCouponBond :: (Word) -- ^settlementDays
 -> (Double) -- ^faceAmount
 -> (Calendar) -> (Day) -- ^maturityDate
 -> (DayCounter) -> (BusinessDayConvention) -> (Double) -- ^redemption
 -> (Maybe Day) -- ^issueDate
 -> ([Callability]) -> IO ((CallableBond))
callableZeroCouponBond a1 a2 a3 a4 a5 a6 a7 a8 a9 =
  let {a1' = fromIntegral a1} in 
  let {a2' = realToFrac a2} in 
  withCalendar a3 $ \a3' -> 
  withDay a4 $ \a4' -> 
  withDayCounter a5 $ \a5' -> 
  let {a6' = fromEnumC a6} in 
  let {a7' = realToFrac a7} in 
  withMaybeDay a8 $ \a8' -> 
  withCallabilityArray a9 $ \(a9'1, a9'2) -> 
  preErrorCheck $ \a10' -> 
  callableZeroCouponBond'_ a1' a2' a3' a4' a5' a6' a7' a8' a9'1  a9'2 a10' >>= \res ->
  peekCallableBond res >>= \res' ->
  errorCheck  a10'>>
  return (res')

{-# LINE 573 "./QuantLib/Instrument/Bond.chs" #-}


-- |convertible bond with a fixed-rate coupon leg
convertibleFixedCouponBond :: (Exercise) -> (Double) -- ^conversionRatio
 -> ([Callability]) -> (Day) -- ^issueDate
 -> (Word) -- ^settlementDays
 -> (NonEmpty Double) -- ^coupons
 -> (DayCounter) -> (Schedule) -> (Double) -- ^redemption
 -> ((Int,TimeUnit)) -- ^exCouponPeriod
 -> (Calendar) -- ^exCouponCalendar
 -> (BusinessDayConvention) -- ^exCouponConvention
 -> (Bool) -- ^exCouponEndOfMonth
 -> IO ((ConvertibleBond))
convertibleFixedCouponBond a1 a2 a3 a4 a5 a6 a7 a8 a9 a10 a11 a12 a13 =
  withExercise a1 $ \a1' -> 
  let {a2' = realToFrac a2} in 
  withCallabilityArray a3 $ \(a3'1, a3'2) -> 
  withDay a4 $ \a4' -> 
  let {a5' = fromIntegral a5} in 
  withNonEmptyDoubleArray a6 $ \(a6'1, a6'2) -> 
  withDayCounter a7 $ \a7' -> 
  withSchedule a8 $ \a8' -> 
  let {a9' = realToFrac a9} in 
  let {(a10'1, a10'2) = fromEnumQuantity a10} in 
  withCalendar a11 $ \a11' -> 
  let {a12' = fromEnumC a12} in 
  let {a13' = C2HSImp.fromBool a13} in 
  preErrorCheck $ \a14' -> 
  convertibleFixedCouponBond'_ a1' a2' a3'1  a3'2 a4' a5' a6'1  a6'2 a7' a8' a9' a10'1  a10'2 a11' a12' a13' a14' >>= \res ->
  peekConvertibleBond res >>= \res' ->
  errorCheck  a14'>>
  return (res')

{-# LINE 586 "./QuantLib/Instrument/Bond.chs" #-}


-- |convertible bond with a floating-rate coupon leg
convertibleFloatingRateBond :: (Exercise) -> (Double) -- ^conversionRatio
 -> ([Callability]) -> (Day) -- ^issueDate
 -> (Word) -- ^settlementDays
 -> (GenIborIndex ibor) -> (Word) -- ^fixingDays
 -> ([Double]) -- ^spreads
 -> (DayCounter) -> (Schedule) -> (Double) -- ^redemption
 -> ((Int,TimeUnit)) -- ^exCouponPeriod
 -> (Calendar) -- ^exCouponCalendar
 -> (BusinessDayConvention) -- ^exCouponConvention
 -> (Bool) -- ^exCouponEndOfMonth
 -> IO ((ConvertibleBond))
convertibleFloatingRateBond a1 a2 a3 a4 a5 a6 a7 a8 a9 a10 a11 a12 a13 a14 a15 =
  withExercise a1 $ \a1' -> 
  let {a2' = realToFrac a2} in 
  withCallabilityArray a3 $ \(a3'1, a3'2) -> 
  withDay a4 $ \a4' -> 
  let {a5' = fromIntegral a5} in 
  withIborIndex a6 $ \a6' -> 
  let {a7' = fromIntegral a7} in 
  withDoubleArray a8 $ \(a8'1, a8'2) -> 
  withDayCounter a9 $ \a9' -> 
  withSchedule a10 $ \a10' -> 
  let {a11' = realToFrac a11} in 
  let {(a12'1, a12'2) = fromEnumQuantity a12} in 
  withCalendar a13 $ \a13' -> 
  let {a14' = fromEnumC a14} in 
  let {a15' = C2HSImp.fromBool a15} in 
  preErrorCheck $ \a16' -> 
  convertibleFloatingRateBond'_ a1' a2' a3'1  a3'2 a4' a5' a6' a7' a8'1  a8'2 a9' a10' a11' a12'1  a12'2 a13' a14' a15' a16' >>= \res ->
  peekConvertibleBond res >>= \res' ->
  errorCheck  a16'>>
  return (res')

{-# LINE 600 "./QuantLib/Instrument/Bond.chs" #-}


-- |convertible zero-coupon bond
convertibleZeroCouponBond :: (Exercise) -> (Double) -- ^conversionRatio
 -> ([Callability]) -> (Day) -- ^issueDate
 -> (Word) -- ^settlementDays
 -> (DayCounter) -> (Schedule) -> (Double) -- redemption
 -> IO ((ConvertibleBond))
convertibleZeroCouponBond a1 a2 a3 a4 a5 a6 a7 a8 =
  withExercise a1 $ \a1' -> 
  let {a2' = realToFrac a2} in 
  withCallabilityArray a3 $ \(a3'1, a3'2) -> 
  withDay a4 $ \a4' -> 
  let {a5' = fromIntegral a5} in 
  withDayCounter a6 $ \a6' -> 
  withSchedule a7 $ \a7' -> 
  let {a8' = realToFrac a8} in 
  preErrorCheck $ \a9' -> 
  convertibleZeroCouponBond'_ a1' a2' a3'1  a3'2 a4' a5' a6' a7' a8' a9' >>= \res ->
  peekConvertibleBond res >>= \res' ->
  errorCheck  a9'>>
  return (res')

{-# LINE 608 "./QuantLib/Instrument/Bond.chs" #-}


-- |A weighted collection of BTPs with their outstanding amounts and live clean-price quotes,
-- used by 'rendistatoCalculator'. size\/btps\/cleanPriceQuotes\/outstandings\/weights\/outstanding
-- are all constructor echoes and are not bound.
rendistatoBasket :: NonEmpty (BTP, Double, GenQuote q) -> IO RendistatoBasket
rendistatoBasket xs = qlRendistatoBasket btps outstandings quotes
  where (btps, outstandings, quotes) = unzip3 (toList xs)
qlRendistatoBasket :: ([BTP]) -> ([Double]) -> ([GenQuote q]) -> IO ((RendistatoBasket))
qlRendistatoBasket a1 a2 a3 =
  withBTPArray a1 $ \(a1'1, a1'2) -> 
  withDoubleArray a2 $ \(a2'1, a2'2) -> 
  withQuoteArray a3 $ \(a3'1, a3'2) -> 
  preErrorCheck $ \a4' -> 
  qlRendistatoBasket'_ a1'1  a1'2 a2'1  a2'2 a3'1  a3'2 a4' >>= \res ->
  peekRendistatoBasket res >>= \res' ->
  errorCheck  a4'>>
  return (res')

{-# LINE 619 "./QuantLib/Instrument/Bond.chs" #-}


-- |QuantLib's own BTP-vs-EUR-swap-curve relative-value tool
-- (@ql\/instruments\/bonds\/btp.hpp@'s @RendistatoCalculator@): aggregates a 'RendistatoBasket'
-- into a weighted BTP yield\/duration, prices a fixed ladder of 1..15Y EUR swaps against a
-- discount curve, and reports the swap whose duration is closest to (without exceeding) the
-- basket's own duration as the \"equivalent swap\". @euriborForwardCurve@ forwards the internally
-- constructed Euribor index used for those comparison swaps' floating leg -- matching upstream's
-- own @Euribor@ default when @Nothing@, but the calculator immediately prices those swaps
-- (@fairRate@), which needs a real forwarding curve to project floating cashflows, so a
-- @Nothing@ here throws rather than degrading gracefully; pass the same curve as
-- @discountCurve@ unless a genuinely different forward curve is wanted. @discountCurve@ is
-- required, with no upstream default.
rendistatoCalculator :: (RendistatoBasket) -- ^basket
 -> ((Int,TimeUnit)) -- ^euriborTenor
 -> (Maybe (GenYieldTermStructure y1)) -- ^euriborForwardCurve
 -> (GenYieldTermStructure y2) -- ^discountCurve
 -> IO ((RendistatoCalculator))
rendistatoCalculator :: forall y1 y2.
RendistatoBasket
-> (Int, TimeUnit)
-> Maybe (GenYieldTermStructure y1)
-> GenYieldTermStructure y2
-> IO RendistatoCalculator
rendistatoCalculator RendistatoBasket
a1 (Int, TimeUnit)
a2 Maybe (GenYieldTermStructure y1)
a3 GenYieldTermStructure y2
a4 =
  RendistatoBasket
-> (Ptr CRendistatoBasket -> IO RendistatoCalculator)
-> IO RendistatoCalculator
forall b.
RendistatoBasket -> (Ptr CRendistatoBasket -> IO b) -> IO b
withRendistatoBasket RendistatoBasket
a1 ((Ptr CRendistatoBasket -> IO RendistatoCalculator)
 -> IO RendistatoCalculator)
-> (Ptr CRendistatoBasket -> IO RendistatoCalculator)
-> IO RendistatoCalculator
forall a b. (a -> b) -> a -> b
$ \Ptr CRendistatoBasket
a1' -> 
  let {(CInt
a2'1, CInt
a2'2) = (Int, TimeUnit) -> (CInt, CInt)
forall a b c.
(Enum a, Integral b, Integral c) =>
(b, a) -> (CInt, c)
fromEnumQuantity (Int, TimeUnit)
a2} in 
  Maybe (GenYieldTermStructure y1)
-> (Ptr CYieldTermStructure' -> IO RendistatoCalculator)
-> IO RendistatoCalculator
forall y b.
Maybe (GenYieldTermStructure y)
-> (Ptr CYieldTermStructure' -> IO b) -> IO b
withMaybeYieldTermStructure Maybe (GenYieldTermStructure y1)
a3 ((Ptr CYieldTermStructure' -> IO RendistatoCalculator)
 -> IO RendistatoCalculator)
-> (Ptr CYieldTermStructure' -> IO RendistatoCalculator)
-> IO RendistatoCalculator
forall a b. (a -> b) -> a -> b
$ \Ptr CYieldTermStructure'
a3' -> 
  GenYieldTermStructure y2
-> (Ptr CYieldTermStructure' -> IO RendistatoCalculator)
-> IO RendistatoCalculator
forall y b.
GenYieldTermStructure y
-> (Ptr CYieldTermStructure' -> IO b) -> IO b
withYieldTermStructure GenYieldTermStructure y2
a4 ((Ptr CYieldTermStructure' -> IO RendistatoCalculator)
 -> IO RendistatoCalculator)
-> (Ptr CYieldTermStructure' -> IO RendistatoCalculator)
-> IO RendistatoCalculator
forall a b. (a -> b) -> a -> b
$ \Ptr CYieldTermStructure'
a4' -> 
  (Ptr (Ptr CChar) -> IO RendistatoCalculator)
-> IO RendistatoCalculator
forall a b. (Ptr (Ptr a) -> IO b) -> IO b
preErrorCheck ((Ptr (Ptr CChar) -> IO RendistatoCalculator)
 -> IO RendistatoCalculator)
-> (Ptr (Ptr CChar) -> IO RendistatoCalculator)
-> IO RendistatoCalculator
forall a b. (a -> b) -> a -> b
$ \Ptr (Ptr CChar)
a5' -> 
  Ptr CRendistatoBasket
-> CInt
-> CInt
-> Ptr CYieldTermStructure'
-> Ptr CYieldTermStructure'
-> Ptr (Ptr CChar)
-> IO (Ptr CRendistatoCalculator)
rendistatoCalculator'_ Ptr CRendistatoBasket
a1' CInt
a2'1  CInt
a2'2 Ptr CYieldTermStructure'
a3' Ptr CYieldTermStructure'
a4' Ptr (Ptr CChar)
a5' IO (Ptr CRendistatoCalculator)
-> (Ptr CRendistatoCalculator -> IO RendistatoCalculator)
-> IO RendistatoCalculator
forall a b. IO a -> (a -> IO b) -> IO b
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= \Ptr CRendistatoCalculator
res ->
  Ptr CRendistatoCalculator -> IO RendistatoCalculator
peekRendistatoCalculator Ptr CRendistatoCalculator
res IO RendistatoCalculator
-> (RendistatoCalculator -> IO RendistatoCalculator)
-> IO RendistatoCalculator
forall a b. IO a -> (a -> IO b) -> IO b
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= \RendistatoCalculator
res' ->
  Ptr (Ptr CChar) -> IO ()
errorCheck  Ptr (Ptr CChar)
a5'IO () -> IO RendistatoCalculator -> IO RendistatoCalculator
forall a b. IO a -> IO b -> IO b
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>>
  RendistatoCalculator -> IO RendistatoCalculator
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return (RendistatoCalculator
res')

{-# LINE 636 "./QuantLib/Instrument/Bond.chs" #-}


-- |the basket's outstanding-weighted BTP yield: @sum (weights * yields)@ -- a near-tautology
-- over 'rendistatoYields', kept because it is upstream's own published aggregate.
rendistatoYield :: (RendistatoCalculator) -> IO ((Double))
rendistatoYield a1 =
  withRendistatoCalculator a1 $ \a1' -> 
  preErrorCheck $ \a2' -> 
  rendistatoYield'_ a1' a2' >>= \res ->
  let {res' = realToFrac res} in
  errorCheck  a2'>>
  return (res')

{-# LINE 640 "./QuantLib/Instrument/Bond.chs" #-}


-- |the basket's outstanding-weighted BTP (modified) duration.
rendistatoDuration :: (RendistatoCalculator) -> IO ((Double))
rendistatoDuration a1 =
  withRendistatoCalculator a1 $ \a1' -> 
  preErrorCheck $ \a2' -> 
  rendistatoDuration'_ a1' a2' >>= \res ->
  let {res' = realToFrac res} in
  errorCheck  a2'>>
  return (res')

{-# LINE 643 "./QuantLib/Instrument/Bond.chs" #-}


-- |per-bond yields, in basket order.
rendistatoYields :: (RendistatoCalculator) -> IO (([Double]))
rendistatoYields a1 =
  withRendistatoCalculator a1 $ \a1' -> 
  preArray $ \(a2'1, a2'2) -> 
  preErrorCheck $ \a3' -> 
  rendistatoYields'_ a1' a2'1  a2'2 a3' >>
  peekDoubleArray  a2'1  a2'2>>= \a2'' -> 
  errorCheck  a3'>>
  return (a2'')

{-# LINE 647 "./QuantLib/Instrument/Bond.chs" #-}


-- |per-bond (modified) durations, in basket order.
rendistatoDurations :: (RendistatoCalculator) -> IO (([Double]))
rendistatoDurations a1 =
  withRendistatoCalculator a1 $ \a1' -> 
  preArray $ \(a2'1, a2'2) -> 
  preErrorCheck $ \a3' -> 
  rendistatoDurations'_ a1' a2'1  a2'2 a3' >>
  peekDoubleArray  a2'1  a2'2>>= \a2'' -> 
  errorCheck  a3'>>
  return (a2'')

{-# LINE 651 "./QuantLib/Instrument/Bond.chs" #-}


-- |the fixed 1..15Y comparison-swap ladder's lengths, in years -- pairs positionally with
-- 'rendistatoSwapRates'\/'rendistatoSwapYields'\/'rendistatoSwapDurations'.
rendistatoSwapLengths :: (RendistatoCalculator) -> IO (([Double]))
rendistatoSwapLengths a1 =
  withRendistatoCalculator a1 $ \a1' -> 
  preArray $ \(a2'1, a2'2) -> 
  preErrorCheck $ \a3' -> 
  rendistatoSwapLengths'_ a1' a2'1  a2'2 a3' >>
  peekDoubleArray  a2'1  a2'2>>= \a2'' -> 
  errorCheck  a3'>>
  return (a2'')

{-# LINE 656 "./QuantLib/Instrument/Bond.chs" #-}


-- |each ladder swap's fair (par) rate.
rendistatoSwapRates :: (RendistatoCalculator) -> IO (([Double]))
rendistatoSwapRates a1 =
  withRendistatoCalculator a1 $ \a1' -> 
  preArray $ \(a2'1, a2'2) -> 
  preErrorCheck $ \a3' -> 
  rendistatoSwapRates'_ a1' a2'1  a2'2 a3' >>
  peekDoubleArray  a2'1  a2'2>>= \a2'' -> 
  errorCheck  a3'>>
  return (a2'')

{-# LINE 660 "./QuantLib/Instrument/Bond.chs" #-}


-- |each ladder swap's fixed leg, repriced as a par bond and re-expressed as a BTP-convention yield.
rendistatoSwapYields :: (RendistatoCalculator) -> IO (([Double]))
rendistatoSwapYields a1 =
  withRendistatoCalculator a1 $ \a1' -> 
  preArray $ \(a2'1, a2'2) -> 
  preErrorCheck $ \a3' -> 
  rendistatoSwapYields'_ a1' a2'1  a2'2 a3' >>
  peekDoubleArray  a2'1  a2'2>>= \a2'' -> 
  errorCheck  a3'>>
  return (a2'')

{-# LINE 664 "./QuantLib/Instrument/Bond.chs" #-}


-- |each ladder swap's fixed leg (modified) duration, on the same par-bond proxy.
rendistatoSwapDurations :: (RendistatoCalculator) -> IO (([Double]))
rendistatoSwapDurations a1 =
  withRendistatoCalculator a1 $ \a1' -> 
  preArray $ \(a2'1, a2'2) -> 
  preErrorCheck $ \a3' -> 
  rendistatoSwapDurations'_ a1' a2'1  a2'2 a3' >>
  peekDoubleArray  a2'1  a2'2>>= \a2'' -> 
  errorCheck  a3'>>
  return (a2'')

{-# LINE 668 "./QuantLib/Instrument/Bond.chs" #-}


-- |the ladder swap whose duration is closest to (without exceeding) the basket's own duration.
rendistatoEquivalentSwap :: (RendistatoCalculator) -> IO ((VanillaSwap))
rendistatoEquivalentSwap a1 =
  withRendistatoCalculator a1 $ \a1' -> 
  preErrorCheck $ \a2' -> 
  rendistatoEquivalentSwap'_ a1' a2' >>= \res ->
  peekVanillaSwap res >>= \res' ->
  errorCheck  a2'>>
  return (res')

{-# LINE 671 "./QuantLib/Instrument/Bond.chs" #-}


-- |the equivalent swap's fair rate.
rendistatoEquivalentSwapRate :: (RendistatoCalculator) -> IO ((Double))
rendistatoEquivalentSwapRate a1 =
  withRendistatoCalculator a1 $ \a1' -> 
  preErrorCheck $ \a2' -> 
  rendistatoEquivalentSwapRate'_ a1' a2' >>= \res ->
  let {res' = realToFrac res} in
  errorCheck  a2'>>
  return (res')

{-# LINE 674 "./QuantLib/Instrument/Bond.chs" #-}


-- |the equivalent swap's par-bond-proxy yield.
rendistatoEquivalentSwapYield :: (RendistatoCalculator) -> IO ((Double))
rendistatoEquivalentSwapYield a1 =
  withRendistatoCalculator a1 $ \a1' -> 
  preErrorCheck $ \a2' -> 
  rendistatoEquivalentSwapYield'_ a1' a2' >>= \res ->
  let {res' = realToFrac res} in
  errorCheck  a2'>>
  return (res')

{-# LINE 677 "./QuantLib/Instrument/Bond.chs" #-}


-- |the equivalent swap's par-bond-proxy duration.
rendistatoEquivalentSwapDuration :: (RendistatoCalculator) -> IO ((Double))
rendistatoEquivalentSwapDuration a1 =
  withRendistatoCalculator a1 $ \a1' -> 
  preErrorCheck $ \a2' -> 
  rendistatoEquivalentSwapDuration'_ a1' a2' >>= \res ->
  let {res' = realToFrac res} in
  errorCheck  a2'>>
  return (res')

{-# LINE 680 "./QuantLib/Instrument/Bond.chs" #-}


-- |the equivalent swap's length, in years.
rendistatoEquivalentSwapLength :: (RendistatoCalculator) -> IO ((Double))
rendistatoEquivalentSwapLength a1 =
  withRendistatoCalculator a1 $ \a1' -> 
  preErrorCheck $ \a2' -> 
  rendistatoEquivalentSwapLength'_ a1' a2' >>= \res ->
  let {res' = realToFrac res} in
  errorCheck  a2'>>
  return (res')

{-# LINE 683 "./QuantLib/Instrument/Bond.chs" #-}


-- |@rendistatoYield - rendistatoEquivalentSwapRate@: the basket's spread over
-- its equivalent swap.
rendistatoEquivalentSwapSpread :: (RendistatoCalculator) -> IO ((Double))
rendistatoEquivalentSwapSpread a1 =
  withRendistatoCalculator a1 $ \a1' -> 
  preErrorCheck $ \a2' -> 
  rendistatoEquivalentSwapSpread'_ a1' a2' >>= \res ->
  let {res' = realToFrac res} in
  errorCheck  a2'>>
  return (res')

{-# LINE 687 "./QuantLib/Instrument/Bond.chs" #-}


-- |A live 'Quote' tracking 'rendistatoEquivalentSwapLength' -- re-evaluates on every
-- access rather than snapshotting it, so it can be wired into curve bootstrapping like any other
-- quote.
rendistatoEquivalentSwapLengthQuote :: (RendistatoCalculator) -> IO ((Quote))
rendistatoEquivalentSwapLengthQuote a1 =
  withRendistatoCalculator a1 $ \a1' -> 
  preErrorCheck $ \a2' -> 
  rendistatoEquivalentSwapLengthQuote'_ a1' a2' >>= \res ->
  peekQuote res >>= \res' ->
  errorCheck  a2'>>
  return (res')

{-# LINE 692 "./QuantLib/Instrument/Bond.chs" #-}


-- |A live 'Quote' tracking 'rendistatoEquivalentSwapSpread'.
rendistatoEquivalentSwapSpreadQuote :: (RendistatoCalculator) -> IO ((Quote))
rendistatoEquivalentSwapSpreadQuote a1 =
  withRendistatoCalculator a1 $ \a1' -> 
  preErrorCheck $ \a2' -> 
  rendistatoEquivalentSwapSpreadQuote'_ a1' a2' >>= \res ->
  peekQuote res >>= \res' ->
  errorCheck  a2'>>
  return (res')

{-# LINE 695 "./QuantLib/Instrument/Bond.chs" #-}


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

foreign import ccall safe "QuantLib/Instrument/Bond.chs.h qlBondFunctionsAtmRate"
  atmRate'_ :: ((C2HSImp.Ptr (CBond')) -> ((C2HSImp.Ptr (CYieldTermStructure')) -> (C2HSImp.CInt -> (C2HSImp.CDouble -> (C2HSImp.CInt -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO C2HSImp.CDouble)))))))

foreign import ccall safe "QuantLib/Instrument/Bond.chs.h qlBond"
  bond'_ :: (C2HSImp.CUInt -> ((C2HSImp.Ptr (CCalendar)) -> (C2HSImp.CInt -> ((C2HSImp.Ptr (CLeg')) -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO (C2HSImp.Ptr (CBond'))))))))

foreign import ccall safe "QuantLib/Instrument/Bond.chs.h qlBondMaturityDate"
  maturityDate'_ :: ((C2HSImp.Ptr (CBond')) -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO C2HSImp.CInt)))

foreign import ccall safe "QuantLib/Instrument/Bond.chs.h qlFixedRateBond"
  fixedRateBond'_ :: (C2HSImp.CUInt -> (C2HSImp.CDouble -> ((C2HSImp.Ptr (CSchedule)) -> (C2HSImp.CUInt -> ((C2HSImp.Ptr C2HSImp.CDouble) -> ((C2HSImp.Ptr (CDayCounter)) -> (C2HSImp.CInt -> (C2HSImp.CDouble -> (C2HSImp.CInt -> ((C2HSImp.Ptr (CCalendar)) -> (C2HSImp.CInt -> (C2HSImp.CInt -> ((C2HSImp.Ptr (CCalendar)) -> (C2HSImp.CInt -> (C2HSImp.CInt -> ((C2HSImp.Ptr (CDayCounter)) -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO (C2HSImp.Ptr (CFixedRateBond'))))))))))))))))))))

foreign import ccall safe "QuantLib/Instrument/Bond.chs.h qlBtp"
  btp'_ :: (C2HSImp.CInt -> (C2HSImp.CDouble -> (C2HSImp.CInt -> (C2HSImp.CInt -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO (C2HSImp.Ptr (CBTP'))))))))

foreign import ccall safe "QuantLib/Instrument/Bond.chs.h qlBtpWithRedemption"
  btpWithRedemption'_ :: (C2HSImp.CInt -> (C2HSImp.CDouble -> (C2HSImp.CDouble -> (C2HSImp.CInt -> (C2HSImp.CInt -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO (C2HSImp.Ptr (CBTP')))))))))

foreign import ccall safe "QuantLib/Instrument/Bond.chs.h qlAmortizingFixedRateBond"
  amortizingFixedRateBond'_ :: (C2HSImp.CUInt -> (C2HSImp.CUInt -> ((C2HSImp.Ptr C2HSImp.CDouble) -> ((C2HSImp.Ptr (CSchedule)) -> (C2HSImp.CUInt -> ((C2HSImp.Ptr C2HSImp.CDouble) -> ((C2HSImp.Ptr (CDayCounter)) -> (C2HSImp.CInt -> (C2HSImp.CInt -> (C2HSImp.CInt -> (C2HSImp.CInt -> ((C2HSImp.Ptr (CCalendar)) -> (C2HSImp.CInt -> (C2HSImp.CInt -> (C2HSImp.CUInt -> ((C2HSImp.Ptr C2HSImp.CDouble) -> (C2HSImp.CInt -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO (C2HSImp.Ptr (CBond')))))))))))))))))))))

foreign import ccall safe "QuantLib/Instrument/Bond.chs.h qlSinkingSchedule"
  sinkingSchedule'_ :: (C2HSImp.CInt -> (C2HSImp.CInt -> (C2HSImp.CInt -> (C2HSImp.CInt -> ((C2HSImp.Ptr (CCalendar)) -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO (C2HSImp.Ptr (CSchedule)))))))))

foreign import ccall safe "QuantLib/Instrument/Bond.chs.h qlSinkingNotionals"
  sinkingNotionals'_ :: (C2HSImp.CInt -> (C2HSImp.CInt -> (C2HSImp.CInt -> (C2HSImp.CDouble -> (C2HSImp.CDouble -> ((C2HSImp.Ptr C2HSImp.CUInt) -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CDouble)) -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO ())))))))))

foreign import ccall safe "QuantLib/Instrument/Bond.chs.h qlCPIBond"
  cpiBond'_ :: (C2HSImp.CUInt -> (C2HSImp.CDouble -> (C2HSImp.CDouble -> (C2HSImp.CInt -> (C2HSImp.CInt -> ((C2HSImp.Ptr (CZeroInflationIndex')) -> (C2HSImp.CInt -> ((C2HSImp.Ptr (CSchedule)) -> (C2HSImp.CUInt -> ((C2HSImp.Ptr C2HSImp.CDouble) -> ((C2HSImp.Ptr (CDayCounter)) -> (C2HSImp.CInt -> (C2HSImp.CInt -> ((C2HSImp.Ptr (CCalendar)) -> (C2HSImp.CInt -> (C2HSImp.CInt -> ((C2HSImp.Ptr (CCalendar)) -> (C2HSImp.CInt -> (C2HSImp.CInt -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO (C2HSImp.Ptr (CCPIBond')))))))))))))))))))))))

foreign import ccall safe "QuantLib/Instrument/Bond.chs.h qlZeroCouponBond"
  zeroCouponBond'_ :: (C2HSImp.CInt -> ((C2HSImp.Ptr (CCalendar)) -> (C2HSImp.CDouble -> (C2HSImp.CInt -> (C2HSImp.CInt -> (C2HSImp.CDouble -> (C2HSImp.CInt -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO (C2HSImp.Ptr (CBond')))))))))))

foreign import ccall safe "QuantLib/Instrument/Bond.chs.h qlFloatingRateBond"
  floatingRateBond'_ :: (C2HSImp.CUInt -> (C2HSImp.CDouble -> ((C2HSImp.Ptr (CSchedule)) -> ((C2HSImp.Ptr (CIborIndex')) -> ((C2HSImp.Ptr (CDayCounter)) -> (C2HSImp.CInt -> (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.CDouble -> (C2HSImp.CInt -> (C2HSImp.CInt -> (C2HSImp.CInt -> ((C2HSImp.Ptr (CCalendar)) -> (C2HSImp.CInt -> (C2HSImp.CInt -> (C2HSImp.CInt -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO (C2HSImp.Ptr (CBond'))))))))))))))))))))))))))))

foreign import ccall safe "QuantLib/Instrument/Bond.chs.h qlCmsRateBond"
  cmsRateBond'_ :: (C2HSImp.CUInt -> (C2HSImp.CDouble -> ((C2HSImp.Ptr (CSchedule)) -> ((C2HSImp.Ptr (CSwapIndex')) -> ((C2HSImp.Ptr (CDayCounter)) -> (C2HSImp.CInt -> (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.CDouble -> (C2HSImp.CInt -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO (C2HSImp.Ptr (CBond'))))))))))))))))))))))

foreign import ccall safe "QuantLib/Instrument/Bond.chs.h qlAmortizingCmsRateBond"
  amortizingCmsRateBond'_ :: (C2HSImp.CUInt -> (C2HSImp.CUInt -> ((C2HSImp.Ptr C2HSImp.CDouble) -> ((C2HSImp.Ptr (CSchedule)) -> ((C2HSImp.Ptr (CSwapIndex')) -> ((C2HSImp.Ptr (CDayCounter)) -> (C2HSImp.CInt -> (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.CUInt -> ((C2HSImp.Ptr C2HSImp.CDouble) -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO (C2HSImp.Ptr (CBond'))))))))))))))))))))))))

foreign import ccall safe "QuantLib/Instrument/Bond.chs.h qlAmortizingFloatingRateBond"
  amortizingFloatingRateBond_'_ :: (C2HSImp.CUInt -> (C2HSImp.CUInt -> ((C2HSImp.Ptr C2HSImp.CDouble) -> ((C2HSImp.Ptr (CSchedule)) -> ((C2HSImp.Ptr (CIborIndex')) -> ((C2HSImp.Ptr (CDayCounter)) -> (C2HSImp.CInt -> (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.CUInt -> ((C2HSImp.Ptr C2HSImp.CDouble) -> (C2HSImp.CInt -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO (C2HSImp.Ptr (CBond'))))))))))))))))))))))))))))))

foreign import ccall safe "QuantLib/Instrument/Bond.chs.h qlBondYield"
  yield'_ :: ((C2HSImp.Ptr (CBond')) -> ((C2HSImp.Ptr (CDayCounter)) -> (C2HSImp.CInt -> (C2HSImp.CInt -> (C2HSImp.CDouble -> (C2HSImp.CUInt -> (C2HSImp.CDouble -> (C2HSImp.CInt -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO C2HSImp.CDouble))))))))))

foreign import ccall safe "QuantLib/Instrument/Bond.chs.h qlBondAccruedAmount"
  accruedAmount'_ :: ((C2HSImp.Ptr (CBond')) -> (C2HSImp.CInt -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO C2HSImp.CDouble))))

foreign import ccall safe "QuantLib/Instrument/Bond.chs.h qlBondDirtyPrice1"
  dirtyPriceFromYield'_ :: ((C2HSImp.Ptr (CBond')) -> (C2HSImp.CDouble -> ((C2HSImp.Ptr (CDayCounter)) -> (C2HSImp.CInt -> (C2HSImp.CInt -> (C2HSImp.CInt -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO C2HSImp.CDouble))))))))

foreign import ccall safe "QuantLib/Instrument/Bond.chs.h qlBondNextCashFlowDate"
  nextCashFlowDate'_ :: ((C2HSImp.Ptr (CBond')) -> (C2HSImp.CInt -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO C2HSImp.CInt))))

foreign import ccall safe "QuantLib/Instrument/Bond.chs.h qlBondNextCouponRate"
  nextCouponRate'_ :: ((C2HSImp.Ptr (CBond')) -> (C2HSImp.CInt -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO C2HSImp.CDouble))))

foreign import ccall safe "QuantLib/Instrument/Bond.chs.h qlBondNotional"
  notional'_ :: ((C2HSImp.Ptr (CBond')) -> (C2HSImp.CInt -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO C2HSImp.CDouble))))

foreign import ccall safe "QuantLib/Instrument/Bond.chs.h qlBondPreviousCashFlowDate"
  previousCashFlowDate'_ :: ((C2HSImp.Ptr (CBond')) -> (C2HSImp.CInt -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO C2HSImp.CInt))))

foreign import ccall safe "QuantLib/Instrument/Bond.chs.h qlBondPreviousCouponRate"
  previousCouponRate'_ :: ((C2HSImp.Ptr (CBond')) -> (C2HSImp.CInt -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO C2HSImp.CDouble))))

foreign import ccall safe "QuantLib/Instrument/Bond.chs.h qlBondSettlementValue1"
  settlementValueFromCleanPrice'_ :: ((C2HSImp.Ptr (CBond')) -> (C2HSImp.CDouble -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO C2HSImp.CDouble))))

foreign import ccall safe "QuantLib/Instrument/Bond.chs.h qlBondSettlementValue"
  settlementValue'_ :: ((C2HSImp.Ptr (CBond')) -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO C2HSImp.CDouble)))

foreign import ccall safe "QuantLib/Instrument/Bond.chs.h qlBondYield1"
  yieldFromPrice'_ :: ((C2HSImp.Ptr (CBond')) -> (C2HSImp.CDouble -> (C2HSImp.CInt -> ((C2HSImp.Ptr (CDayCounter)) -> (C2HSImp.CInt -> (C2HSImp.CInt -> (C2HSImp.CInt -> (C2HSImp.CDouble -> (C2HSImp.CUInt -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO C2HSImp.CDouble)))))))))))

foreign import ccall safe "QuantLib/Instrument/Bond.chs.h qlBondIsTradable"
  isTradable'_ :: ((C2HSImp.Ptr (CBond')) -> (C2HSImp.CInt -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO C2HSImp.CInt))))

foreign import ccall safe "QuantLib/Instrument/Bond.chs.h qlBondNotionals"
  notionals'_ :: ((C2HSImp.Ptr (CBond')) -> ((C2HSImp.Ptr C2HSImp.CUInt) -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CDouble)) -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO ())))))

foreign import ccall safe "QuantLib/Instrument/Bond.chs.h qlBondCashflows"
  cashFlows'_ :: ((C2HSImp.Ptr (CBond')) -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO (C2HSImp.Ptr (CLeg')))))

foreign import ccall safe "QuantLib/Instrument/Bond.chs.h qlBondRedemptions"
  redemptions'_ :: ((C2HSImp.Ptr (CBond')) -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO (C2HSImp.Ptr (CLeg')))))

foreign import ccall safe "QuantLib/Instrument/Bond.chs.h qlBondSettlementDate"
  settlementDate'_ :: ((C2HSImp.Ptr (CBond')) -> (C2HSImp.CInt -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO C2HSImp.CInt))))

foreign import ccall safe "QuantLib/Instrument/Bond.chs.h qlBondStartDate"
  startDate'_ :: ((C2HSImp.Ptr (CBond')) -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO C2HSImp.CInt)))

foreign import ccall safe "QuantLib/Instrument/Bond.chs.h qlBondFunctionsAccrualDays"
  accrualDays'_ :: ((C2HSImp.Ptr (CBond')) -> (C2HSImp.CInt -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO C2HSImp.CInt))))

foreign import ccall safe "QuantLib/Instrument/Bond.chs.h qlBondFunctionsAccrualEndDate"
  accrualEndDate'_ :: ((C2HSImp.Ptr (CBond')) -> (C2HSImp.CInt -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO C2HSImp.CInt))))

foreign import ccall safe "QuantLib/Instrument/Bond.chs.h qlBondFunctionsAccrualPeriod"
  accrualPeriod'_ :: ((C2HSImp.Ptr (CBond')) -> (C2HSImp.CInt -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO C2HSImp.CDouble))))

foreign import ccall safe "QuantLib/Instrument/Bond.chs.h qlBondFunctionsAccrualStartDate"
  accrualStartDate'_ :: ((C2HSImp.Ptr (CBond')) -> (C2HSImp.CInt -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO C2HSImp.CInt))))

foreign import ccall safe "QuantLib/Instrument/Bond.chs.h qlBondFunctionsAccruedDays"
  accruedDays'_ :: ((C2HSImp.Ptr (CBond')) -> (C2HSImp.CInt -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO C2HSImp.CInt))))

foreign import ccall safe "QuantLib/Instrument/Bond.chs.h qlBondFunctionsAccruedPeriod"
  accruedPeriod'_ :: ((C2HSImp.Ptr (CBond')) -> (C2HSImp.CInt -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO C2HSImp.CDouble))))

foreign import ccall safe "QuantLib/Instrument/Bond.chs.h qlBondFunctionsBasisPointValue"
  basisPointValue'_ :: ((C2HSImp.Ptr (CBond')) -> ((C2HSImp.Ptr (CInterestRate)) -> (C2HSImp.CInt -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO C2HSImp.CDouble)))))

foreign import ccall safe "QuantLib/Instrument/Bond.chs.h qlBondFunctionsBps1"
  bpsFromYieldRaw'_ :: ((C2HSImp.Ptr (CBond')) -> ((C2HSImp.Ptr (CInterestRate)) -> (C2HSImp.CInt -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO C2HSImp.CDouble)))))

foreign import ccall safe "QuantLib/Instrument/Bond.chs.h qlBondFunctionsBps"
  bpsFromCurveRaw'_ :: ((C2HSImp.Ptr (CBond')) -> ((C2HSImp.Ptr (CYieldTermStructure')) -> (C2HSImp.CInt -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO C2HSImp.CDouble)))))

foreign import ccall safe "QuantLib/Instrument/Bond.chs.h qlBondFunctionsCleanPrice2"
  cleanPriceFromCurveRaw'_ :: ((C2HSImp.Ptr (CBond')) -> ((C2HSImp.Ptr (CYieldTermStructure')) -> (C2HSImp.CInt -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO C2HSImp.CDouble)))))

foreign import ccall safe "QuantLib/Instrument/Bond.chs.h qlBondFunctionsCleanPrice3"
  cleanPriceWithZSpreadRaw'_ :: ((C2HSImp.Ptr (CBond')) -> ((C2HSImp.Ptr (CYieldTermStructure')) -> (C2HSImp.CDouble -> (C2HSImp.CInt -> (C2HSImp.CInt -> (C2HSImp.CInt -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO C2HSImp.CDouble))))))))

foreign import ccall safe "QuantLib/Instrument/Bond.chs.h qlBondFunctionsCleanPrice4"
  cleanPriceFromYieldRaw'_ :: ((C2HSImp.Ptr (CBond')) -> ((C2HSImp.Ptr (CInterestRate)) -> (C2HSImp.CInt -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO C2HSImp.CDouble)))))

foreign import ccall safe "QuantLib/Instrument/Bond.chs.h qlBondFunctionsConvexity"
  convexity'_ :: ((C2HSImp.Ptr (CBond')) -> ((C2HSImp.Ptr (CInterestRate)) -> (C2HSImp.CInt -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO C2HSImp.CDouble)))))

foreign import ccall safe "QuantLib/Instrument/Bond.chs.h qlBondFunctionsDuration"
  duration'_ :: ((C2HSImp.Ptr (CBond')) -> ((C2HSImp.Ptr (CInterestRate)) -> (C2HSImp.CInt -> (C2HSImp.CInt -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO C2HSImp.CDouble))))))

foreign import ccall safe "QuantLib/Instrument/Bond.chs.h qlBondFunctionsNextCashFlowAmount"
  nextCashFlowAmount'_ :: ((C2HSImp.Ptr (CBond')) -> (C2HSImp.CInt -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO C2HSImp.CDouble))))

foreign import ccall safe "QuantLib/Instrument/Bond.chs.h qlBondFunctionsPreviousCashFlowAmount"
  previousCashFlowAmount'_ :: ((C2HSImp.Ptr (CBond')) -> (C2HSImp.CInt -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO C2HSImp.CDouble))))

foreign import ccall safe "QuantLib/Instrument/Bond.chs.h qlBondFunctionsReferencePeriodEnd"
  referencePeriodEnd'_ :: ((C2HSImp.Ptr (CBond')) -> (C2HSImp.CInt -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO C2HSImp.CInt))))

foreign import ccall safe "QuantLib/Instrument/Bond.chs.h qlBondFunctionsReferencePeriodStart"
  referencePeriodStart'_ :: ((C2HSImp.Ptr (CBond')) -> (C2HSImp.CInt -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO C2HSImp.CInt))))

foreign import ccall safe "QuantLib/Instrument/Bond.chs.h qlBondFunctionsYield2"
  yieldFromPriceWithGuess'_ :: ((C2HSImp.Ptr (CBond')) -> (C2HSImp.CDouble -> (C2HSImp.CInt -> ((C2HSImp.Ptr (CDayCounter)) -> (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/Instrument/Bond.chs.h qlBondFunctionsYieldValueBasisPoint"
  yieldValueBasisPoint'_ :: ((C2HSImp.Ptr (CBond')) -> ((C2HSImp.Ptr (CInterestRate)) -> (C2HSImp.CInt -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO C2HSImp.CDouble)))))

foreign import ccall safe "QuantLib/Instrument/Bond.chs.h qlBondFunctionsZSpread"
  zSpread'_ :: ((C2HSImp.Ptr (CBond')) -> (C2HSImp.CDouble -> (C2HSImp.CInt -> ((C2HSImp.Ptr (CYieldTermStructure')) -> (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/Instrument/Bond.chs.h qlBondCleanPrice"
  currentCleanPrice'_ :: ((C2HSImp.Ptr (CBond')) -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO C2HSImp.CDouble)))

foreign import ccall safe "QuantLib/Instrument/Bond.chs.h qlBondDirtyPrice"
  currentDirtyPrice'_ :: ((C2HSImp.Ptr (CBond')) -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO C2HSImp.CDouble)))

foreign import ccall safe "QuantLib/Instrument/Bond.chs.h qlCallableFixedRateBond"
  callableFixedRateBond'_ :: (C2HSImp.CUInt -> (C2HSImp.CDouble -> ((C2HSImp.Ptr (CSchedule)) -> (C2HSImp.CUInt -> ((C2HSImp.Ptr C2HSImp.CDouble) -> ((C2HSImp.Ptr (CDayCounter)) -> (C2HSImp.CInt -> (C2HSImp.CDouble -> (C2HSImp.CInt -> (C2HSImp.CUInt -> ((C2HSImp.Ptr (C2HSImp.Ptr (CQlCallability))) -> (C2HSImp.CInt -> (C2HSImp.CInt -> ((C2HSImp.Ptr (CCalendar)) -> (C2HSImp.CInt -> (C2HSImp.CInt -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO (C2HSImp.Ptr (CCallableBond'))))))))))))))))))))

foreign import ccall safe "QuantLib/Instrument/Bond.chs.h qlCallableZeroCouponBond"
  callableZeroCouponBond'_ :: (C2HSImp.CUInt -> (C2HSImp.CDouble -> ((C2HSImp.Ptr (CCalendar)) -> (C2HSImp.CInt -> ((C2HSImp.Ptr (CDayCounter)) -> (C2HSImp.CInt -> (C2HSImp.CDouble -> (C2HSImp.CInt -> (C2HSImp.CUInt -> ((C2HSImp.Ptr (C2HSImp.Ptr (CQlCallability))) -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO (C2HSImp.Ptr (CCallableBond'))))))))))))))

foreign import ccall safe "QuantLib/Instrument/Bond.chs.h qlConvertibleFixedCouponBond"
  convertibleFixedCouponBond'_ :: ((QlExercise) -> (C2HSImp.CDouble -> (C2HSImp.CUInt -> ((C2HSImp.Ptr (C2HSImp.Ptr (CQlCallability))) -> (C2HSImp.CInt -> (C2HSImp.CUInt -> (C2HSImp.CUInt -> ((C2HSImp.Ptr C2HSImp.CDouble) -> ((C2HSImp.Ptr (CDayCounter)) -> ((C2HSImp.Ptr (CSchedule)) -> (C2HSImp.CDouble -> (C2HSImp.CInt -> (C2HSImp.CInt -> ((C2HSImp.Ptr (CCalendar)) -> (C2HSImp.CInt -> (C2HSImp.CInt -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO (C2HSImp.Ptr (CConvertibleBond'))))))))))))))))))))

foreign import ccall safe "QuantLib/Instrument/Bond.chs.h qlConvertibleFloatingRateBond"
  convertibleFloatingRateBond'_ :: ((QlExercise) -> (C2HSImp.CDouble -> (C2HSImp.CUInt -> ((C2HSImp.Ptr (C2HSImp.Ptr (CQlCallability))) -> (C2HSImp.CInt -> (C2HSImp.CUInt -> ((C2HSImp.Ptr (CIborIndex')) -> (C2HSImp.CUInt -> (C2HSImp.CUInt -> ((C2HSImp.Ptr C2HSImp.CDouble) -> ((C2HSImp.Ptr (CDayCounter)) -> ((C2HSImp.Ptr (CSchedule)) -> (C2HSImp.CDouble -> (C2HSImp.CInt -> (C2HSImp.CInt -> ((C2HSImp.Ptr (CCalendar)) -> (C2HSImp.CInt -> (C2HSImp.CInt -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO (C2HSImp.Ptr (CConvertibleBond'))))))))))))))))))))))

foreign import ccall safe "QuantLib/Instrument/Bond.chs.h qlConvertibleZeroCouponBond"
  convertibleZeroCouponBond'_ :: ((QlExercise) -> (C2HSImp.CDouble -> (C2HSImp.CUInt -> ((C2HSImp.Ptr (C2HSImp.Ptr (CQlCallability))) -> (C2HSImp.CInt -> (C2HSImp.CUInt -> ((C2HSImp.Ptr (CDayCounter)) -> ((C2HSImp.Ptr (CSchedule)) -> (C2HSImp.CDouble -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO (C2HSImp.Ptr (CConvertibleBond')))))))))))))

foreign import ccall safe "QuantLib/Instrument/Bond.chs.h qlRendistatoBasket"
  qlRendistatoBasket'_ :: (C2HSImp.CUInt -> ((C2HSImp.Ptr (C2HSImp.Ptr (CBTP'))) -> (C2HSImp.CUInt -> ((C2HSImp.Ptr C2HSImp.CDouble) -> (C2HSImp.CUInt -> ((C2HSImp.Ptr (C2HSImp.Ptr (CQuote'))) -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO (C2HSImp.Ptr (CRendistatoBasket))))))))))

foreign import ccall safe "QuantLib/Instrument/Bond.chs.h qlRendistatoCalculator"
  rendistatoCalculator'_ :: ((C2HSImp.Ptr (CRendistatoBasket)) -> (C2HSImp.CInt -> (C2HSImp.CInt -> ((C2HSImp.Ptr (CYieldTermStructure')) -> ((C2HSImp.Ptr (CYieldTermStructure')) -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO (C2HSImp.Ptr (CRendistatoCalculator)))))))))

foreign import ccall safe "QuantLib/Instrument/Bond.chs.h qlRendistatoCalculatorYield"
  rendistatoYield'_ :: ((C2HSImp.Ptr (CRendistatoCalculator)) -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO C2HSImp.CDouble)))

foreign import ccall safe "QuantLib/Instrument/Bond.chs.h qlRendistatoCalculatorDuration"
  rendistatoDuration'_ :: ((C2HSImp.Ptr (CRendistatoCalculator)) -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO C2HSImp.CDouble)))

foreign import ccall safe "QuantLib/Instrument/Bond.chs.h qlRendistatoCalculatorYields"
  rendistatoYields'_ :: ((C2HSImp.Ptr (CRendistatoCalculator)) -> ((C2HSImp.Ptr C2HSImp.CUInt) -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CDouble)) -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO ())))))

foreign import ccall safe "QuantLib/Instrument/Bond.chs.h qlRendistatoCalculatorDurations"
  rendistatoDurations'_ :: ((C2HSImp.Ptr (CRendistatoCalculator)) -> ((C2HSImp.Ptr C2HSImp.CUInt) -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CDouble)) -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO ())))))

foreign import ccall safe "QuantLib/Instrument/Bond.chs.h qlRendistatoCalculatorSwapLengths"
  rendistatoSwapLengths'_ :: ((C2HSImp.Ptr (CRendistatoCalculator)) -> ((C2HSImp.Ptr C2HSImp.CUInt) -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CDouble)) -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO ())))))

foreign import ccall safe "QuantLib/Instrument/Bond.chs.h qlRendistatoCalculatorSwapRates"
  rendistatoSwapRates'_ :: ((C2HSImp.Ptr (CRendistatoCalculator)) -> ((C2HSImp.Ptr C2HSImp.CUInt) -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CDouble)) -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO ())))))

foreign import ccall safe "QuantLib/Instrument/Bond.chs.h qlRendistatoCalculatorSwapYields"
  rendistatoSwapYields'_ :: ((C2HSImp.Ptr (CRendistatoCalculator)) -> ((C2HSImp.Ptr C2HSImp.CUInt) -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CDouble)) -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO ())))))

foreign import ccall safe "QuantLib/Instrument/Bond.chs.h qlRendistatoCalculatorSwapDurations"
  rendistatoSwapDurations'_ :: ((C2HSImp.Ptr (CRendistatoCalculator)) -> ((C2HSImp.Ptr C2HSImp.CUInt) -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CDouble)) -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO ())))))

foreign import ccall safe "QuantLib/Instrument/Bond.chs.h qlRendistatoCalculatorEquivalentSwap"
  rendistatoEquivalentSwap'_ :: ((C2HSImp.Ptr (CRendistatoCalculator)) -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO (C2HSImp.Ptr (CVanillaSwap')))))

foreign import ccall safe "QuantLib/Instrument/Bond.chs.h qlRendistatoCalculatorEquivalentSwapRate"
  rendistatoEquivalentSwapRate'_ :: ((C2HSImp.Ptr (CRendistatoCalculator)) -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO C2HSImp.CDouble)))

foreign import ccall safe "QuantLib/Instrument/Bond.chs.h qlRendistatoCalculatorEquivalentSwapYield"
  rendistatoEquivalentSwapYield'_ :: ((C2HSImp.Ptr (CRendistatoCalculator)) -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO C2HSImp.CDouble)))

foreign import ccall safe "QuantLib/Instrument/Bond.chs.h qlRendistatoCalculatorEquivalentSwapDuration"
  rendistatoEquivalentSwapDuration'_ :: ((C2HSImp.Ptr (CRendistatoCalculator)) -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO C2HSImp.CDouble)))

foreign import ccall safe "QuantLib/Instrument/Bond.chs.h qlRendistatoCalculatorEquivalentSwapLength"
  rendistatoEquivalentSwapLength'_ :: ((C2HSImp.Ptr (CRendistatoCalculator)) -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO C2HSImp.CDouble)))

foreign import ccall safe "QuantLib/Instrument/Bond.chs.h qlRendistatoCalculatorEquivalentSwapSpread"
  rendistatoEquivalentSwapSpread'_ :: ((C2HSImp.Ptr (CRendistatoCalculator)) -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO C2HSImp.CDouble)))

foreign import ccall safe "QuantLib/Instrument/Bond.chs.h qlRendistatoEquivalentSwapLengthQuote"
  rendistatoEquivalentSwapLengthQuote'_ :: ((C2HSImp.Ptr (CRendistatoCalculator)) -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO (C2HSImp.Ptr (CQuote')))))

foreign import ccall safe "QuantLib/Instrument/Bond.chs.h qlRendistatoEquivalentSwapSpreadQuote"
  rendistatoEquivalentSwapSpreadQuote'_ :: ((C2HSImp.Ptr (CRendistatoCalculator)) -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO (C2HSImp.Ptr (CQuote')))))