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


{-# LINE 1 "./QuantLib/Instrument/Swap.chs" #-}
{-# LANGUAGE TemplateHaskell, FlexibleInstances, TypeFamilies #-}
module QuantLib.Instrument.Swap
  (
    -- * Types
    -- ** Swap hierarchy
    GenSwap
  , Swap
  , GenFixedVsFloatingSwap
  , FixedVsFloatingSwap
  , VanillaSwap
  , NonstandardSwap
  , IrregularSwap
  , FloatFloatSwap
  , AssetSwap
  , OvernightIndexedSwap
  , BMASwap
  , ZeroCouponInflationSwap
  , YearOnYearInflationSwap
  , CPISwap
  , ZeroCouponSwap
  , EquityTotalReturnSwap
  , VarianceSwap
  , GenConstNotionalCrossCurrencySwap
  , ConstNotionalCrossCurrencySwap
  , ConstNotionalCrossCurrencyBasisSwap
  , ConstNotionalCrossCurrencyFixedVsFloatingSwap

    -- ** Swaptions and variance options
  , Swaption
  , IrregularSwaption
  , NonstandardSwaption
  , FloatFloatSwaption
  , VarianceOption

    -- ** Configuration
  , SwapType(..)
  , SwaptionPriceType(..)
  , IrregularSettlementType(..)
  , CPIInterpolationType(..)
  , CalibrationBasketType(..)
  , FloatFloatSwapOpts(..)
  , defaultFloatFloatSwapOpts
  , FloatFloatSwapVaryingOpts(..)
  , defaultFloatFloatSwapVaryingOpts
  , ConstNotionalCrossCurrencyBasisSwapOpts(..)
  , defaultConstNotionalCrossCurrencyBasisSwapOpts
  , OvernightObservation(..)
  , defaultOvernightObservation

    -- * Constructors
    -- ** Hierarchy conversion
  , asSwap

    -- ** Swaps
  , swapFromLegs
  , swap
  , bmaSwap
  , vanillaSwap
  , nonstandardSwapFromVanilla
  , nonstandardSwap
  , nonstandardSwapFromGearingsAndSpreads
  , floatFloatSwap
  , floatFloatSwapFromNominals
  , makeVanillaSwap
  , makeCms
  , zeroCouponInflationSwap
  , yearOnYearInflationSwap
  , cpiSwap
  , zeroCouponSwap
  , zeroCouponSwapFromRate
  , equityTotalReturnSwapIbor
  , equityTotalReturnSwapOvernight
  , varianceSwap
  , varianceOption

    -- ** Cross-currency swaps
  , constNotionalCrossCurrencySwap
  , constNotionalCrossCurrencySwapFromLegs
  , constNotionalCrossCurrencyBasisSwap
  , constNotionalCrossCurrencyFixedVsFloatingSwap

    -- ** Overnight-indexed and asset swaps
  , overnightIndexedSwap
  , overnightIndexedSwapFromNominals
  , assetSwap

    -- ** Swaptions
  , swaption
  , irregularSwaption
  , irregularSwap
  , nonstandardSwaptionFromSwaption
  , nonstandardSwaption
  , floatFloatSwaption

    -- * Inspectors
    -- ** Common swap inspectors
  , HasFixedLeg(..)
  , HasFloatingLeg(..)
  , HasFairRate(..)
  , HasFairSpread(..)
  , HasInstrumentUnderlying(..)
  , impliedVolatility
  , endDiscounts
  , leg
  , numberOfLegs
  , legBps
  , legNpv
  , maturityDate
  , npvDateDiscount
  , startDate
  , startDiscounts
  , nonstandardSwapFixedRate

    -- ** Cross-currency swaps
  , legCurrency
  , inCcyLegBps
  , inCcyLegNpv
  , npvDateDiscounts
  , fairPaySpread
  , fairRecSpread

    -- ** BMA swaps
  , bmaLeg
  , bmaLegBps
  , bmaLegNpv
  , fairLiborFraction
  , fairLiborSpread
  , liborFraction
  , liborLeg
  , liborLegBps
  , liborLegNpv

    -- ** Swaption calibration baskets
  , calibrationBasket
  , floatFloatSwaptionCalibrationBasket

    -- ** Asset swaps
  , bondLeg
  , cleanPrice
  , fairCleanPrice
  , fairNonParRepayment
  , nonParRepayment
  , parSwap
  , payBondCoupon

    -- ** Float-float swaps
  , firstLegFairSpread
  , secondLegFairSpread

    -- ** Zero-coupon, equity and variance swaps
  , fairFixedPayment
  , fairFixedRate
  , equityLegNpv
  , interestRateLegNpv
  , fairMargin
  , variance

    -- ** Overnight-indexed swaps
  , overnightLeg
  , overnightLegBps
  , overnightLegNpv

  ) 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 Data.Maybe(fromMaybe)
import QuantLib.Internal.Syntax(deriveOptionsRecord)
import QuantLib.Internal
import QuantLib.Instrument
{-# LINE 167 "./QuantLib/Instrument/Swap.chs" #-}

import QuantLib.InterestRate(VolatilityType)
import QuantLib.CashFlow(RateAveragingType(..))
import QuantLib.CashFlow(cmsLeg, iborLeg)
import QuantLib.Time.Calendar(adjust, advance)
import QuantLib.Internal.Type
import QuantLib.Internal.Common
import Data.List.NonEmpty(NonEmpty((:|)))
import QuantLib.Time.Schedule(schedule, DateGenerationRule(..))
import QuantLib.Time.Date(addPeriod)
import QuantLib.Context(evaluationDate)
import QuantLib.Index(fixingCalendar)
import QuantLib.Index.InterestRate(tenor, dayCounter, businessDayConvention)


{-# LINE 181 "./QuantLib/Instrument/Swap.chs" #-}


{-# LINE 182 "./QuantLib/Instrument/Swap.chs" #-}


{-# LINE 183 "./QuantLib/Instrument/Swap.chs" #-}


{-# LINE 184 "./QuantLib/Instrument/Swap.chs" #-}


{-# LINE 185 "./QuantLib/Instrument/Swap.chs" #-}


{-# LINE 186 "./QuantLib/Instrument/Swap.chs" #-}


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


{-# LINE 188 "./QuantLib/Instrument/Swap.chs" #-}


{-# LINE 189 "./QuantLib/Instrument/Swap.chs" #-}


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


{-# LINE 191 "./QuantLib/Instrument/Swap.chs" #-}


{-# LINE 192 "./QuantLib/Instrument/Swap.chs" #-}


{-# LINE 193 "./QuantLib/Instrument/Swap.chs" #-}


{-# LINE 194 "./QuantLib/Instrument/Swap.chs" #-}


{-# LINE 195 "./QuantLib/Instrument/Swap.chs" #-}


{-# LINE 196 "./QuantLib/Instrument/Swap.chs" #-}


{-# LINE 197 "./QuantLib/Instrument/Swap.chs" #-}


{-# LINE 198 "./QuantLib/Instrument/Swap.chs" #-}


{-# LINE 199 "./QuantLib/Instrument/Swap.chs" #-}


{-# LINE 200 "./QuantLib/Instrument/Swap.chs" #-}


{-# LINE 201 "./QuantLib/Instrument/Swap.chs" #-}


{-# LINE 202 "./QuantLib/Instrument/Swap.chs" #-}


{-# LINE 203 "./QuantLib/Instrument/Swap.chs" #-}


{-# LINE 204 "./QuantLib/Instrument/Swap.chs" #-}


{-# LINE 205 "./QuantLib/Instrument/Swap.chs" #-}


{-# LINE 206 "./QuantLib/Instrument/Swap.chs" #-}


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


{-# LINE 208 "./QuantLib/Instrument/Swap.chs" #-}


{-# LINE 209 "./QuantLib/Instrument/Swap.chs" #-}


{-# LINE 210 "./QuantLib/Instrument/Swap.chs" #-}


{-# LINE 211 "./QuantLib/Instrument/Swap.chs" #-}


{-# LINE 212 "./QuantLib/Instrument/Swap.chs" #-}


{-# LINE 213 "./QuantLib/Instrument/Swap.chs" #-}


{-# LINE 214 "./QuantLib/Instrument/Swap.chs" #-}


{-# LINE 215 "./QuantLib/Instrument/Swap.chs" #-}








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

  pred Payer = Receiver
  pred Receiver = error "SwapType.pred: Receiver has no predecessor"

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

  enumFrom from = enumFromTo from Payer

  fromEnum Receiver = (-1)
  fromEnum Payer = 1

  toEnum (-1) = Receiver
  toEnum 1 = Payer
  toEnum unmatched = error ("SwapType.toEnum: Cannot match " ++ show unmatched)

{-# LINE 223 "./QuantLib/Instrument/Swap.chs" #-}

data SwaptionPriceType = SwaptionSpot
                       | SwaptionForward
  deriving (Enum,Show,Eq,Read)

{-# LINE 224 "./QuantLib/Instrument/Swap.chs" #-}

data IrregularSettlementType = IrregularPhysical
                             | IrregularCash
  deriving (Show,Eq,Read)
instance Enum IrregularSettlementType where
  succ IrregularPhysical = IrregularCash
  succ IrregularCash = error "IrregularSettlementType.succ: IrregularCash has no successor"

  pred IrregularCash = IrregularPhysical
  pred IrregularPhysical = error "IrregularSettlementType.pred: IrregularPhysical has no predecessor"

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

  enumFrom from = enumFromTo from IrregularCash

  fromEnum IrregularPhysical = 0
  fromEnum IrregularCash = 1

  toEnum 0 = IrregularPhysical
  toEnum 1 = IrregularCash
  toEnum unmatched = error ("IrregularSettlementType.toEnum: Cannot match " ++ show unmatched)

{-# LINE 225 "./QuantLib/Instrument/Swap.chs" #-}


-- FloatFloatSwapOpts/FloatFloatSwapVaryingOpts bundle every trailing param of FloatFloatSwap's
-- two constructors (floatfloatswap.hpp) -- 12 trailing defaulted params each, past the
-- options-record threshold (see the add-quantlib-options-record skill). Two separate records
-- (not one shared) since the scalar ctor's gearing/spread/cappedRate/flooredRate are plain
-- Double/Maybe Double while the vector ctor's are [Double]. This splice must stay textually
-- before every {#fun#}-generated binding in this file -- see OISRateHelperOpts in
-- QuantLib/TermStructure/Yield.chs for why (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, so a top-level TH splice in between would split the file into declaration groups
-- that can't see each other).
$(deriveOptionsRecord "FloatFloatSwapOpts" []
  [ ("ffsIntermediateCapitalExchange", [t|Bool|], [|False|])
  , ("ffsFinalCapitalExchange", [t|Bool|], [|False|])
  , ("ffsFirstLegGearing", [t|Double|], [|1.0|])
  , ("ffsFirstLegSpread", [t|Double|], [|0.0|])
  , ("ffsFirstLegCappedRate", [t|Maybe Double|], [|Nothing|])
  , ("ffsFirstLegFlooredRate", [t|Maybe Double|], [|Nothing|])
  , ("ffsSecondLegGearing", [t|Double|], [|1.0|])
  , ("ffsSecondLegSpread", [t|Double|], [|0.0|])
  , ("ffsSecondLegCappedRate", [t|Maybe Double|], [|Nothing|])
  , ("ffsSecondLegFlooredRate", [t|Maybe Double|], [|Nothing|])
  , ("ffsFirstLegPaymentConvention", [t|Maybe BusinessDayConvention|], [|Nothing|])
  , ("ffsSecondLegPaymentConvention", [t|Maybe BusinessDayConvention|], [|Nothing|])
  ])
$(deriveOptionsRecord "FloatFloatSwapVaryingOpts" []
  [ ("ffsvIntermediateCapitalExchange", [t|Bool|], [|False|])
  , ("ffsvFinalCapitalExchange", [t|Bool|], [|False|])
  , ("ffsvFirstLegGearing", [t|[Double]|], [|[]|])
  , ("ffsvFirstLegSpread", [t|[Double]|], [|[]|])
  , ("ffsvFirstLegCappedRate", [t|[Double]|], [|[]|])
  , ("ffsvFirstLegFlooredRate", [t|[Double]|], [|[]|])
  , ("ffsvSecondLegGearing", [t|[Double]|], [|[]|])
  , ("ffsvSecondLegSpread", [t|[Double]|], [|[]|])
  , ("ffsvSecondLegCappedRate", [t|[Double]|], [|[]|])
  , ("ffsvSecondLegFlooredRate", [t|[Double]|], [|[]|])
  , ("ffsvFirstLegPaymentConvention", [t|Maybe BusinessDayConvention|], [|Nothing|])
  , ("ffsvSecondLegPaymentConvention", [t|Maybe BusinessDayConvention|], [|Nothing|])
  ])

-- ConstNotionalCrossCurrencyBasisSwapOpts bundles ConstNotionalCrossCurrencyBasisSwap's 13
-- trailing defaulted params (per-leg OIS-only payment lag, compound-spread, lookback,
-- observation shift, lockout, averaging method, plus a shared telescopicValueDates), past the
-- options-record threshold -- see FloatFloatSwapOpts above for why this splice must stay
-- textually before every {#fun#} in this file. ConstNotionalCrossCurrencyFixedVsFloatingSwap's
-- constructor has only 4 trailing defaults (under the threshold), so it's widened in place
-- instead -- see 'constNotionalCrossCurrencyFixedVsFloatingSwap' below.
$(deriveOptionsRecord "ConstNotionalCrossCurrencyBasisSwapOpts" []
  [ ("cccbsPayPaymentLag", [t|Int|], [|0|])
  , ("cccbsRecPaymentLag", [t|Int|], [|0|])
  , ("cccbsPayCompoundSpread", [t|Bool|], [|False|])
  , ("cccbsPayObservation", [t|OvernightObservation|], [|defaultOvernightObservation|])
  , ("cccbsPayAveragingMethod", [t|RateAveragingType|], [|AveragingCompound|])
  , ("cccbsRecCompoundSpread", [t|Bool|], [|False|])
  , ("cccbsRecObservation", [t|OvernightObservation|], [|defaultOvernightObservation|])
  , ("cccbsRecAveragingMethod", [t|RateAveragingType|], [|AveragingCompound|])
  , ("cccbsTelescopicValueDates", [t|Bool|], [|False|])
  ])

-- |implied volatility
impliedVolatility :: (Swaption) -> (Double) -- ^price
 -> (GenYieldTermStructure y) -> (Double) -- ^guess
 -> (Double) -- ^accuracy
 -> (Word) -- ^maxEvaluations
 -> (Double) -- ^minVol
 -> (Double) -- ^maxVol
 -> (VolatilityType) -- ^type
 -> (Double) -- ^displacement
 -> (SwaptionPriceType) -- ^priceType
 -> IO ((Double))
impliedVolatility :: forall y.
Swaption
-> Double
-> GenYieldTermStructure y
-> Double
-> Double
-> Word
-> Double
-> Double
-> VolatilityType
-> Double
-> SwaptionPriceType
-> IO Double
impliedVolatility Swaption
a1 Double
a2 GenYieldTermStructure y
a3 Double
a4 Double
a5 Word
a6 Double
a7 Double
a8 VolatilityType
a9 Double
a10 SwaptionPriceType
a11 =
  Swaption -> (Ptr CSwaption' -> IO Double) -> IO Double
forall b. Swaption -> (Ptr CSwaption' -> IO b) -> IO b
withSwaption Swaption
a1 ((Ptr CSwaption' -> IO Double) -> IO Double)
-> (Ptr CSwaption' -> IO Double) -> IO Double
forall a b. (a -> b) -> a -> b
$ \Ptr CSwaption'
a1' -> 
  let {a2' :: CDouble
a2' = Double -> CDouble
forall a b. (Real a, Fractional b) => a -> b
realToFrac Double
a2} in 
  GenYieldTermStructure y
-> (Ptr CYieldTermStructure' -> IO Double) -> IO Double
forall y b.
GenYieldTermStructure y
-> (Ptr CYieldTermStructure' -> IO b) -> IO b
withYieldTermStructure GenYieldTermStructure y
a3 ((Ptr CYieldTermStructure' -> IO Double) -> IO Double)
-> (Ptr CYieldTermStructure' -> IO Double) -> IO Double
forall a b. (a -> b) -> a -> b
$ \Ptr CYieldTermStructure'
a3' -> 
  let {a4' :: CDouble
a4' = Double -> CDouble
forall a b. (Real a, Fractional b) => a -> b
realToFrac Double
a4} in 
  let {a5' :: CDouble
a5' = Double -> CDouble
forall a b. (Real a, Fractional b) => a -> b
realToFrac Double
a5} in 
  let {a6' :: CUInt
a6' = Word -> CUInt
forall a b. (Integral a, Num b) => a -> b
fromIntegral Word
a6} in 
  let {a7' :: CDouble
a7' = Double -> CDouble
forall a b. (Real a, Fractional b) => a -> b
realToFrac Double
a7} in 
  let {a8' :: CDouble
a8' = Double -> CDouble
forall a b. (Real a, Fractional b) => a -> b
realToFrac Double
a8} in 
  let {a9' :: CInt
a9' = (Int -> CInt
forall a b. (Integral a, Num b) => a -> b
fromIntegral (Int -> CInt) -> (VolatilityType -> Int) -> VolatilityType -> CInt
forall b c a. (b -> c) -> (a -> b) -> a -> c
. VolatilityType -> Int
forall a. Enum a => a -> Int
fromEnum) VolatilityType
a9} in 
  let {a10' :: CDouble
a10' = Double -> CDouble
forall a b. (Real a, Fractional b) => a -> b
realToFrac Double
a10} in 
  let {a11' :: CInt
a11' = (Int -> CInt
forall a b. (Integral a, Num b) => a -> b
fromIntegral (Int -> CInt)
-> (SwaptionPriceType -> Int) -> SwaptionPriceType -> CInt
forall b c a. (b -> c) -> (a -> b) -> a -> c
. SwaptionPriceType -> Int
forall a. Enum a => a -> Int
fromEnum) SwaptionPriceType
a11} in 
  (Ptr (Ptr CChar) -> IO Double) -> IO Double
forall a b. (Ptr (Ptr a) -> IO b) -> IO b
preErrorCheck ((Ptr (Ptr CChar) -> IO Double) -> IO Double)
-> (Ptr (Ptr CChar) -> IO Double) -> IO Double
forall a b. (a -> b) -> a -> b
$ \Ptr (Ptr CChar)
a12' -> 
  Ptr CSwaption'
-> CDouble
-> Ptr CYieldTermStructure'
-> CDouble
-> CDouble
-> CUInt
-> CDouble
-> CDouble
-> CInt
-> CDouble
-> CInt
-> Ptr (Ptr CChar)
-> IO CDouble
impliedVolatility'_ Ptr CSwaption'
a1' CDouble
a2' Ptr CYieldTermStructure'
a3' CDouble
a4' CDouble
a5' CUInt
a6' CDouble
a7' CDouble
a8' CInt
a9' CDouble
a10' CInt
a11' Ptr (Ptr CChar)
a12' IO CDouble -> (CDouble -> IO Double) -> IO Double
forall a b. IO a -> (a -> IO b) -> IO b
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= \CDouble
res ->
  let {res' :: Double
res' = CDouble -> Double
forall a b. (Real a, Fractional b) => a -> b
realToFrac CDouble
res} in
  Ptr (Ptr CChar) -> IO ()
errorCheck  Ptr (Ptr CChar)
a12'IO () -> IO Double -> IO Double
forall a b. IO a -> IO b -> IO b
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>>
  Double -> IO Double
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return (Double
res')

{-# LINE 295 "./QuantLib/Instrument/Swap.chs" #-}


-- |Multi leg constructor.
swapFromLegs :: [(Leg, Bool)] -- ^(legs, payer)
  -> IO Swap
swapFromLegs = (uncurry qlSwap1) . unzip
qlSwap1 :: ([Leg]) -> ([Bool]) -> IO ((Swap))
qlSwap1 a1 a2 =
  withLegArray a1 $ \(a1'1, a1'2) -> 
  withBoolArray a2 $ \(a2'1, a2'2) -> 
  preErrorCheck $ \a3' -> 
  qlSwap1'_ a1'1  a1'2 a2'1  a2'2 a3' >>= \res ->
  peekSwap res >>= \res' ->
  errorCheck  a3'>>
  return (res')

{-# LINE 301 "./QuantLib/Instrument/Swap.chs" #-}


-- |Swap paying Libor against BMA coupons
bmaSwap :: (SwapType) -> (Double) -- ^nominal
 -> (Schedule) -- ^liborSchedule
 -> (Double) -- ^liborFraction
 -> (Double) -- ^liborSpread
 -> (GenIborIndex ibor) -> (DayCounter) -- ^liborDayCount
 -> (Schedule) -- ^bmaSchedule
 -> (BMAIndex) -> (DayCounter) -- ^bmaDayCount
 -> IO ((BMASwap))
bmaSwap a1 a2 a3 a4 a5 a6 a7 a8 a9 a10 =
  let {a1' = (fromIntegral . fromEnum) a1} in 
  let {a2' = realToFrac a2} in 
  withSchedule a3 $ \a3' -> 
  let {a4' = realToFrac a4} in 
  let {a5' = realToFrac a5} in 
  withIborIndex a6 $ \a6' -> 
  withDayCounter a7 $ \a7' -> 
  withSchedule a8 $ \a8' -> 
  withBMAIndex a9 $ \a9' -> 
  withDayCounter a10 $ \a10' -> 
  preErrorCheck $ \a11' -> 
  bmaSwap'_ a1' a2' a3' a4' a5' a6' a7' a8' a9' a10' a11' >>= \res ->
  peekBMASwap res >>= \res' ->
  errorCheck  a11'>>
  return (res')

{-# LINE 311 "./QuantLib/Instrument/Swap.chs" #-}


-- |Fixed-rate vs floating-rate (Ibor) swap; if no payment convention is given, the floating leg's is used.
vanillaSwap :: (SwapType) -> (Double) -- ^nominal
 -> (Schedule) -- ^fixedSchedule
 -> (Double) -- ^fixedRate
 -> (DayCounter) -- ^fixedDayCount
 -> (Schedule) -- ^floatSchedule
 -> (GenIborIndex ibor) -> (Double) -- ^spread
 -> (DayCounter) -- ^floatingDayCount
 -> (Maybe BusinessDayConvention) -- ^paymentConvention
 -> (Maybe Bool) -- ^useIndexedCoupons
 -> IO ((VanillaSwap))
vanillaSwap a1 a2 a3 a4 a5 a6 a7 a8 a9 a10 a11 =
  let {a1' = (fromIntegral . fromEnum) a1} in 
  let {a2' = realToFrac a2} in 
  withSchedule a3 $ \a3' -> 
  let {a4' = realToFrac a4} in 
  withDayCounter a5 $ \a5' -> 
  withSchedule a6 $ \a6' -> 
  withIborIndex a7 $ \a7' -> 
  let {a8' = realToFrac a8} in 
  withDayCounter a9 $ \a9' -> 
  let {a10' = fromMaybeEnum a10} in 
  let {a11' = fromMaybeBool a11} in 
  preErrorCheck $ \a12' -> 
  vanillaSwap'_ a1' a2' a3' a4' a5' a6' a7' a8' a9' a10' a11' a12' >>= \res ->
  peekVanillaSwap res >>= \res' ->
  errorCheck  a12'>>
  return (res')

{-# LINE 324 "./QuantLib/Instrument/Swap.chs" #-}


-- |Converts an existing 'FixedVsFloatingSwap' (e.g. a 'VanillaSwap') into a 'NonstandardSwap'
-- (upstream's own conversion constructor, @NonstandardSwap(const FixedVsFloatingSwap&)@).
nonstandardSwapFromVanilla :: (GenFixedVsFloatingSwap f) -> IO ((NonstandardSwap))
nonstandardSwapFromVanilla a1 =
  withFixedVsFloatingSwap a1 $ \a1' -> 
  preErrorCheck $ \a2' -> 
  nonstandardSwapFromVanilla'_ a1' a2' >>= \res ->
  peekNonstandardSwap res >>= \res' ->
  errorCheck  a2'>>
  return (res')

{-# LINE 329 "./QuantLib/Instrument/Swap.chs" #-}


-- |'VanillaSwap' generalized to per-period fixed/floating nominals and fixed rates, plus
-- optional intermediate\/final notional exchange -- a single 'Double' gearing\/spread shared
-- across all floating periods. See 'nonstandardSwapFromGearingsAndSpreads' for per-period gearing\/spread.
nonstandardSwap :: (SwapType) -> ([Double]) -- ^fixedNominal
 -> ([Double]) -- ^floatingNominal
 -> (Schedule) -- ^fixedSchedule
 -> ([Double]) -- ^fixedRate
 -> (DayCounter) -- ^fixedDayCount
 -> (Schedule) -- ^floatingSchedule
 -> (GenIborIndex ibor) -> (Double) -- ^gearing
 -> (Double) -- ^spread
 -> (DayCounter) -- ^floatingDayCount
 -> (Bool) -- ^intermediateCapitalExchange
 -> (Bool) -- ^finalCapitalExchange
 -> (Maybe BusinessDayConvention) -- ^paymentConvention
 -> IO ((NonstandardSwap))
nonstandardSwap :: forall ibor.
SwapType
-> [Double]
-> [Double]
-> Schedule
-> [Double]
-> DayCounter
-> Schedule
-> GenIborIndex ibor
-> Double
-> Double
-> DayCounter
-> Bool
-> Bool
-> Maybe BusinessDayConvention
-> IO NonstandardSwap
nonstandardSwap SwapType
a1 [Double]
a2 [Double]
a3 Schedule
a4 [Double]
a5 DayCounter
a6 Schedule
a7 GenIborIndex ibor
a8 Double
a9 Double
a10 DayCounter
a11 Bool
a12 Bool
a13 Maybe BusinessDayConvention
a14 =
  let {a1' :: CInt
a1' = (Int -> CInt
forall a b. (Integral a, Num b) => a -> b
fromIntegral (Int -> CInt) -> (SwapType -> Int) -> SwapType -> CInt
forall b c a. (b -> c) -> (a -> b) -> a -> c
. SwapType -> Int
forall a. Enum a => a -> Int
fromEnum) SwapType
a1} in 
  [Double]
-> ((CUInt, Ptr CDouble) -> IO NonstandardSwap)
-> IO NonstandardSwap
forall b. [Double] -> ((CUInt, Ptr CDouble) -> IO b) -> IO b
withDoubleArray [Double]
a2 (((CUInt, Ptr CDouble) -> IO NonstandardSwap)
 -> IO NonstandardSwap)
-> ((CUInt, Ptr CDouble) -> IO NonstandardSwap)
-> IO NonstandardSwap
forall a b. (a -> b) -> a -> b
$ \(CUInt
a2'1, Ptr CDouble
a2'2) -> 
  [Double]
-> ((CUInt, Ptr CDouble) -> IO NonstandardSwap)
-> IO NonstandardSwap
forall b. [Double] -> ((CUInt, Ptr CDouble) -> IO b) -> IO b
withDoubleArray [Double]
a3 (((CUInt, Ptr CDouble) -> IO NonstandardSwap)
 -> IO NonstandardSwap)
-> ((CUInt, Ptr CDouble) -> IO NonstandardSwap)
-> IO NonstandardSwap
forall a b. (a -> b) -> a -> b
$ \(CUInt
a3'1, Ptr CDouble
a3'2) -> 
  Schedule
-> (Ptr CSchedule -> IO NonstandardSwap) -> IO NonstandardSwap
forall b. Schedule -> (Ptr CSchedule -> IO b) -> IO b
withSchedule Schedule
a4 ((Ptr CSchedule -> IO NonstandardSwap) -> IO NonstandardSwap)
-> (Ptr CSchedule -> IO NonstandardSwap) -> IO NonstandardSwap
forall a b. (a -> b) -> a -> b
$ \Ptr CSchedule
a4' -> 
  [Double]
-> ((CUInt, Ptr CDouble) -> IO NonstandardSwap)
-> IO NonstandardSwap
forall b. [Double] -> ((CUInt, Ptr CDouble) -> IO b) -> IO b
withDoubleArray [Double]
a5 (((CUInt, Ptr CDouble) -> IO NonstandardSwap)
 -> IO NonstandardSwap)
-> ((CUInt, Ptr CDouble) -> IO NonstandardSwap)
-> IO NonstandardSwap
forall a b. (a -> b) -> a -> b
$ \(CUInt
a5'1, Ptr CDouble
a5'2) -> 
  DayCounter
-> (Ptr CDayCounter -> IO NonstandardSwap) -> IO NonstandardSwap
forall b. DayCounter -> (Ptr CDayCounter -> IO b) -> IO b
withDayCounter DayCounter
a6 ((Ptr CDayCounter -> IO NonstandardSwap) -> IO NonstandardSwap)
-> (Ptr CDayCounter -> IO NonstandardSwap) -> IO NonstandardSwap
forall a b. (a -> b) -> a -> b
$ \Ptr CDayCounter
a6' -> 
  Schedule
-> (Ptr CSchedule -> IO NonstandardSwap) -> IO NonstandardSwap
forall b. Schedule -> (Ptr CSchedule -> IO b) -> IO b
withSchedule Schedule
a7 ((Ptr CSchedule -> IO NonstandardSwap) -> IO NonstandardSwap)
-> (Ptr CSchedule -> IO NonstandardSwap) -> IO NonstandardSwap
forall a b. (a -> b) -> a -> b
$ \Ptr CSchedule
a7' -> 
  GenIborIndex ibor
-> (Ptr CIborIndex' -> IO NonstandardSwap) -> IO NonstandardSwap
forall ibor b.
GenIborIndex ibor -> (Ptr CIborIndex' -> IO b) -> IO b
withIborIndex GenIborIndex ibor
a8 ((Ptr CIborIndex' -> IO NonstandardSwap) -> IO NonstandardSwap)
-> (Ptr CIborIndex' -> IO NonstandardSwap) -> IO NonstandardSwap
forall a b. (a -> b) -> a -> b
$ \Ptr CIborIndex'
a8' -> 
  let {a9' :: CDouble
a9' = Double -> CDouble
forall a b. (Real a, Fractional b) => a -> b
realToFrac Double
a9} in 
  let {a10' :: CDouble
a10' = Double -> CDouble
forall a b. (Real a, Fractional b) => a -> b
realToFrac Double
a10} in 
  DayCounter
-> (Ptr CDayCounter -> IO NonstandardSwap) -> IO NonstandardSwap
forall b. DayCounter -> (Ptr CDayCounter -> IO b) -> IO b
withDayCounter DayCounter
a11 ((Ptr CDayCounter -> IO NonstandardSwap) -> IO NonstandardSwap)
-> (Ptr CDayCounter -> IO NonstandardSwap) -> IO NonstandardSwap
forall a b. (a -> b) -> a -> b
$ \Ptr CDayCounter
a11' -> 
  let {a12' :: CInt
a12' = Bool -> CInt
forall a. Num a => Bool -> a
C2HSImp.fromBool Bool
a12} in 
  let {a13' :: CInt
a13' = Bool -> CInt
forall a. Num a => Bool -> a
C2HSImp.fromBool Bool
a13} in 
  let {a14' :: CInt
a14' = Maybe BusinessDayConvention -> CInt
forall a. Enum a => Maybe a -> CInt
fromMaybeEnum Maybe BusinessDayConvention
a14} in 
  (Ptr (Ptr CChar) -> IO NonstandardSwap) -> IO NonstandardSwap
forall a b. (Ptr (Ptr a) -> IO b) -> IO b
preErrorCheck ((Ptr (Ptr CChar) -> IO NonstandardSwap) -> IO NonstandardSwap)
-> (Ptr (Ptr CChar) -> IO NonstandardSwap) -> IO NonstandardSwap
forall a b. (a -> b) -> a -> b
$ \Ptr (Ptr CChar)
a15' -> 
  CInt
-> CUInt
-> Ptr CDouble
-> CUInt
-> Ptr CDouble
-> Ptr CSchedule
-> CUInt
-> Ptr CDouble
-> Ptr CDayCounter
-> Ptr CSchedule
-> Ptr CIborIndex'
-> CDouble
-> CDouble
-> Ptr CDayCounter
-> CInt
-> CInt
-> CInt
-> Ptr (Ptr CChar)
-> IO (Ptr CNonstandardSwap')
nonstandardSwap'_ CInt
a1' CUInt
a2'1  Ptr CDouble
a2'2 CUInt
a3'1  Ptr CDouble
a3'2 Ptr CSchedule
a4' CUInt
a5'1  Ptr CDouble
a5'2 Ptr CDayCounter
a6' Ptr CSchedule
a7' Ptr CIborIndex'
a8' CDouble
a9' CDouble
a10' Ptr CDayCounter
a11' CInt
a12' CInt
a13' CInt
a14' Ptr (Ptr CChar)
a15' IO (Ptr CNonstandardSwap')
-> (Ptr CNonstandardSwap' -> IO NonstandardSwap)
-> IO NonstandardSwap
forall a b. IO a -> (a -> IO b) -> IO b
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= \Ptr CNonstandardSwap'
res ->
  Ptr CNonstandardSwap' -> IO NonstandardSwap
peekNonstandardSwap Ptr CNonstandardSwap'
res IO NonstandardSwap
-> (NonstandardSwap -> IO NonstandardSwap) -> IO NonstandardSwap
forall a b. IO a -> (a -> IO b) -> IO b
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= \NonstandardSwap
res' ->
  Ptr (Ptr CChar) -> IO ()
errorCheck  Ptr (Ptr CChar)
a15'IO () -> IO NonstandardSwap -> IO NonstandardSwap
forall a b. IO a -> IO b -> IO b
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>>
  NonstandardSwap -> IO NonstandardSwap
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return (NonstandardSwap
res')

{-# LINE 348 "./QuantLib/Instrument/Swap.chs" #-}


-- |As 'nonstandardSwap', but with a per-period gearing and spread instead of one shared value.
nonstandardSwapFromGearingsAndSpreads :: (SwapType) -> ([Double]) -- ^fixedNominal
 -> ([Double]) -- ^floatingNominal
 -> (Schedule) -- ^fixedSchedule
 -> ([Double]) -- ^fixedRate
 -> (DayCounter) -- ^fixedDayCount
 -> (Schedule) -- ^floatingSchedule
 -> (GenIborIndex ibor) -> ([Double]) -- ^gearing
 -> ([Double]) -- ^spread
 -> (DayCounter) -- ^floatingDayCount
 -> (Bool) -- ^intermediateCapitalExchange
 -> (Bool) -- ^finalCapitalExchange
 -> (Maybe BusinessDayConvention) -- ^paymentConvention
 -> IO ((NonstandardSwap))
nonstandardSwapFromGearingsAndSpreads a1 a2 a3 a4 a5 a6 a7 a8 a9 a10 a11 a12 a13 a14 =
  let {a1' = (fromIntegral . fromEnum) a1} in 
  withDoubleArray a2 $ \(a2'1, a2'2) -> 
  withDoubleArray a3 $ \(a3'1, a3'2) -> 
  withSchedule a4 $ \a4' -> 
  withDoubleArray a5 $ \(a5'1, a5'2) -> 
  withDayCounter a6 $ \a6' -> 
  withSchedule a7 $ \a7' -> 
  withIborIndex a8 $ \a8' -> 
  withDoubleArray a9 $ \(a9'1, a9'2) -> 
  withDoubleArray a10 $ \(a10'1, a10'2) -> 
  withDayCounter a11 $ \a11' -> 
  let {a12' = C2HSImp.fromBool a12} in 
  let {a13' = C2HSImp.fromBool a13} in 
  let {a14' = fromMaybeEnum a14} in 
  preErrorCheck $ \a15' -> 
  nonstandardSwapFromGearingsAndSpreads'_ a1' a2'1  a2'2 a3'1  a3'2 a4' a5'1  a5'2 a6' a7' a8' a9'1  a9'2 a10'1  a10'2 a11' a12' a13' a14' a15' >>= \res ->
  peekNonstandardSwap res >>= \res' ->
  errorCheck  a15'>>
  return (res')

{-# LINE 365 "./QuantLib/Instrument/Swap.chs" #-}


-- |Per-period fixed rate, one entry per fixed-leg accrual period. For a swap built via
-- 'nonstandardSwap'\/'nonstandardSwapFromGearingsAndSpreads', this simply echoes the constructor's @fixedRate@; for
-- one built via 'nonstandardSwapFromVanilla' it is derived from the underlying vanilla swap's
-- fixed leg coupons.
nonstandardSwapFixedRate :: (NonstandardSwap) -> IO (([Double]))
nonstandardSwapFixedRate a1 =
  withNonstandardSwap a1 $ \a1' -> 
  preArray $ \(a2'1, a2'2) -> 
  preErrorCheck $ \a3' -> 
  nonstandardSwapFixedRate'_ a1' a2'1  a2'2 a3' >>
  peekDoubleArray  a2'1  a2'2>>= \a2'' -> 
  errorCheck  a3'>>
  return (a2'')

{-# LINE 371 "./QuantLib/Instrument/Swap.chs" #-}


-- |Swap exchanging capped\/floored Libor or CMS coupons with a single flat nominal on each leg.
-- 'FloatFloatSwapOpts' bundles every trailing param the C++ constructor defaults (gearing\/
-- spread\/cap\/floor per leg, capital exchange, payment conventions); override only what's
-- needed via record-update syntax on 'defaultFloatFloatSwapOpts'. See 'floatFloatSwapFromNominals' for the
-- per-period-nominal overload.
floatFloatSwap :: SwapType -> Double -> Double -> Schedule -> GenInterestRateIndex ridx1
  -> DayCounter -> Schedule -> GenInterestRateIndex ridx2 -> DayCounter -> FloatFloatSwapOpts
  -> IO FloatFloatSwap
floatFloatSwap ty nominal1 nominal2 schedule1 index1 dayCount1 schedule2 index2 dayCount2 opts =
  floatFloatSwap_ ty nominal1 nominal2 schedule1 index1 dayCount1 schedule2 index2 dayCount2
    (ffsIntermediateCapitalExchange opts) (ffsFinalCapitalExchange opts)
    (ffsFirstLegGearing opts) (ffsFirstLegSpread opts) (ffsFirstLegCappedRate opts) (ffsFirstLegFlooredRate opts)
    (ffsSecondLegGearing opts) (ffsSecondLegSpread opts) (ffsSecondLegCappedRate opts) (ffsSecondLegFlooredRate opts)
    (ffsFirstLegPaymentConvention opts) (ffsSecondLegPaymentConvention opts)

floatFloatSwap_ :: (SwapType) -> (Double) -- ^nominal1
 -> (Double) -- ^nominal2
 -> (Schedule) -- ^schedule1
 -> (GenInterestRateIndex ridx1) -> (DayCounter) -- ^dayCount1
 -> (Schedule) -- ^schedule2
 -> (GenInterestRateIndex ridx2) -> (DayCounter) -- ^dayCount2
 -> (Bool) -- ^intermediateCapitalExchange
 -> (Bool) -- ^finalCapitalExchange
 -> (Double) -- ^gearing1
 -> (Double) -- ^spread1
 -> (Maybe Double) -- ^cappedRate1
 -> (Maybe Double) -- ^flooredRate1
 -> (Double) -- ^gearing2
 -> (Double) -- ^spread2
 -> (Maybe Double) -- ^cappedRate2
 -> (Maybe Double) -- ^flooredRate2
 -> (Maybe BusinessDayConvention) -- ^paymentConvention1
 -> (Maybe BusinessDayConvention) -- ^paymentConvention2
 -> IO ((FloatFloatSwap))
floatFloatSwap_ :: forall ridx1 ridx2.
SwapType
-> Double
-> Double
-> Schedule
-> GenInterestRateIndex ridx1
-> DayCounter
-> Schedule
-> GenInterestRateIndex ridx2
-> DayCounter
-> Bool
-> Bool
-> Double
-> Double
-> Maybe Double
-> Maybe Double
-> Double
-> Double
-> Maybe Double
-> Maybe Double
-> Maybe BusinessDayConvention
-> Maybe BusinessDayConvention
-> IO FloatFloatSwap
floatFloatSwap_ SwapType
a1 Double
a2 Double
a3 Schedule
a4 GenInterestRateIndex ridx1
a5 DayCounter
a6 Schedule
a7 GenInterestRateIndex ridx2
a8 DayCounter
a9 Bool
a10 Bool
a11 Double
a12 Double
a13 Maybe Double
a14 Maybe Double
a15 Double
a16 Double
a17 Maybe Double
a18 Maybe Double
a19 Maybe BusinessDayConvention
a20 Maybe BusinessDayConvention
a21 =
  let {a1' :: CInt
a1' = (Int -> CInt
forall a b. (Integral a, Num b) => a -> b
fromIntegral (Int -> CInt) -> (SwapType -> Int) -> SwapType -> CInt
forall b c a. (b -> c) -> (a -> b) -> a -> c
. SwapType -> Int
forall a. Enum a => a -> Int
fromEnum) SwapType
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 
  Schedule
-> (Ptr CSchedule -> IO FloatFloatSwap) -> IO FloatFloatSwap
forall b. Schedule -> (Ptr CSchedule -> IO b) -> IO b
withSchedule Schedule
a4 ((Ptr CSchedule -> IO FloatFloatSwap) -> IO FloatFloatSwap)
-> (Ptr CSchedule -> IO FloatFloatSwap) -> IO FloatFloatSwap
forall a b. (a -> b) -> a -> b
$ \Ptr CSchedule
a4' -> 
  GenInterestRateIndex ridx1
-> (Ptr CInterestRateIndex' -> IO FloatFloatSwap)
-> IO FloatFloatSwap
forall ridx b.
GenInterestRateIndex ridx
-> (Ptr CInterestRateIndex' -> IO b) -> IO b
withInterestRateIndex GenInterestRateIndex ridx1
a5 ((Ptr CInterestRateIndex' -> IO FloatFloatSwap)
 -> IO FloatFloatSwap)
-> (Ptr CInterestRateIndex' -> IO FloatFloatSwap)
-> IO FloatFloatSwap
forall a b. (a -> b) -> a -> b
$ \Ptr CInterestRateIndex'
a5' -> 
  DayCounter
-> (Ptr CDayCounter -> IO FloatFloatSwap) -> IO FloatFloatSwap
forall b. DayCounter -> (Ptr CDayCounter -> IO b) -> IO b
withDayCounter DayCounter
a6 ((Ptr CDayCounter -> IO FloatFloatSwap) -> IO FloatFloatSwap)
-> (Ptr CDayCounter -> IO FloatFloatSwap) -> IO FloatFloatSwap
forall a b. (a -> b) -> a -> b
$ \Ptr CDayCounter
a6' -> 
  Schedule
-> (Ptr CSchedule -> IO FloatFloatSwap) -> IO FloatFloatSwap
forall b. Schedule -> (Ptr CSchedule -> IO b) -> IO b
withSchedule Schedule
a7 ((Ptr CSchedule -> IO FloatFloatSwap) -> IO FloatFloatSwap)
-> (Ptr CSchedule -> IO FloatFloatSwap) -> IO FloatFloatSwap
forall a b. (a -> b) -> a -> b
$ \Ptr CSchedule
a7' -> 
  GenInterestRateIndex ridx2
-> (Ptr CInterestRateIndex' -> IO FloatFloatSwap)
-> IO FloatFloatSwap
forall ridx b.
GenInterestRateIndex ridx
-> (Ptr CInterestRateIndex' -> IO b) -> IO b
withInterestRateIndex GenInterestRateIndex ridx2
a8 ((Ptr CInterestRateIndex' -> IO FloatFloatSwap)
 -> IO FloatFloatSwap)
-> (Ptr CInterestRateIndex' -> IO FloatFloatSwap)
-> IO FloatFloatSwap
forall a b. (a -> b) -> a -> b
$ \Ptr CInterestRateIndex'
a8' -> 
  DayCounter
-> (Ptr CDayCounter -> IO FloatFloatSwap) -> IO FloatFloatSwap
forall b. DayCounter -> (Ptr CDayCounter -> IO b) -> IO b
withDayCounter DayCounter
a9 ((Ptr CDayCounter -> IO FloatFloatSwap) -> IO FloatFloatSwap)
-> (Ptr CDayCounter -> IO FloatFloatSwap) -> IO FloatFloatSwap
forall a b. (a -> b) -> a -> b
$ \Ptr CDayCounter
a9' -> 
  let {a10' :: CInt
a10' = Bool -> CInt
forall a. Num a => Bool -> a
C2HSImp.fromBool Bool
a10} in 
  let {a11' :: CInt
a11' = Bool -> CInt
forall a. Num a => Bool -> a
C2HSImp.fromBool Bool
a11} in 
  let {a12' :: CDouble
a12' = Double -> CDouble
forall a b. (Real a, Fractional b) => a -> b
realToFrac Double
a12} in 
  let {a13' :: CDouble
a13' = Double -> CDouble
forall a b. (Real a, Fractional b) => a -> b
realToFrac Double
a13} in 
  let {a14' :: CDouble
a14' = Maybe Double -> CDouble
fromMaybeDouble Maybe Double
a14} in 
  let {a15' :: CDouble
a15' = Maybe Double -> CDouble
fromMaybeDouble Maybe Double
a15} in 
  let {a16' :: CDouble
a16' = Double -> CDouble
forall a b. (Real a, Fractional b) => a -> b
realToFrac Double
a16} in 
  let {a17' :: CDouble
a17' = Double -> CDouble
forall a b. (Real a, Fractional b) => a -> b
realToFrac Double
a17} in 
  let {a18' :: CDouble
a18' = Maybe Double -> CDouble
fromMaybeDouble Maybe Double
a18} in 
  let {a19' :: CDouble
a19' = Maybe Double -> CDouble
fromMaybeDouble Maybe Double
a19} in 
  let {a20' :: CInt
a20' = Maybe BusinessDayConvention -> CInt
forall a. Enum a => Maybe a -> CInt
fromMaybeEnum Maybe BusinessDayConvention
a20} in 
  let {a21' :: CInt
a21' = Maybe BusinessDayConvention -> CInt
forall a. Enum a => Maybe a -> CInt
fromMaybeEnum Maybe BusinessDayConvention
a21} in 
  (Ptr (Ptr CChar) -> IO FloatFloatSwap) -> IO FloatFloatSwap
forall a b. (Ptr (Ptr a) -> IO b) -> IO b
preErrorCheck ((Ptr (Ptr CChar) -> IO FloatFloatSwap) -> IO FloatFloatSwap)
-> (Ptr (Ptr CChar) -> IO FloatFloatSwap) -> IO FloatFloatSwap
forall a b. (a -> b) -> a -> b
$ \Ptr (Ptr CChar)
a22' -> 
  CInt
-> CDouble
-> CDouble
-> Ptr CSchedule
-> Ptr CInterestRateIndex'
-> Ptr CDayCounter
-> Ptr CSchedule
-> Ptr CInterestRateIndex'
-> Ptr CDayCounter
-> CInt
-> CInt
-> CDouble
-> CDouble
-> CDouble
-> CDouble
-> CDouble
-> CDouble
-> CDouble
-> CDouble
-> CInt
-> CInt
-> Ptr (Ptr CChar)
-> IO (Ptr CFloatFloatSwap')
floatFloatSwap_'_ CInt
a1' CDouble
a2' CDouble
a3' Ptr CSchedule
a4' Ptr CInterestRateIndex'
a5' Ptr CDayCounter
a6' Ptr CSchedule
a7' Ptr CInterestRateIndex'
a8' Ptr CDayCounter
a9' CInt
a10' CInt
a11' CDouble
a12' CDouble
a13' CDouble
a14' CDouble
a15' CDouble
a16' CDouble
a17' CDouble
a18' CDouble
a19' CInt
a20' CInt
a21' Ptr (Ptr CChar)
a22' IO (Ptr CFloatFloatSwap')
-> (Ptr CFloatFloatSwap' -> IO FloatFloatSwap) -> IO FloatFloatSwap
forall a b. IO a -> (a -> IO b) -> IO b
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= \Ptr CFloatFloatSwap'
res ->
  Ptr CFloatFloatSwap' -> IO FloatFloatSwap
peekFloatFloatSwap Ptr CFloatFloatSwap'
res IO FloatFloatSwap
-> (FloatFloatSwap -> IO FloatFloatSwap) -> IO FloatFloatSwap
forall a b. IO a -> (a -> IO b) -> IO b
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= \FloatFloatSwap
res' ->
  Ptr (Ptr CChar) -> IO ()
errorCheck  Ptr (Ptr CChar)
a22'IO () -> IO FloatFloatSwap -> IO FloatFloatSwap
forall a b. IO a -> IO b -> IO b
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>>
  FloatFloatSwap -> IO FloatFloatSwap
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return (FloatFloatSwap
res')

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


-- |As 'floatFloatSwap', but with per-period nominals on each leg. 'FloatFloatSwapVaryingOpts'
-- also supplies the per-period gearings, spreads, caps, and floors for both legs.
floatFloatSwapFromNominals :: SwapType -> [Double] -> [Double] -> Schedule -> GenInterestRateIndex ridx1
  -> DayCounter -> Schedule -> GenInterestRateIndex ridx2 -> DayCounter
  -> FloatFloatSwapVaryingOpts -> IO FloatFloatSwap
floatFloatSwapFromNominals ty nominal1 nominal2 schedule1 index1 dayCount1 schedule2 index2 dayCount2 opts =
  floatFloatSwap2_ ty nominal1 nominal2 schedule1 index1 dayCount1 schedule2 index2 dayCount2
    (ffsvIntermediateCapitalExchange opts) (ffsvFinalCapitalExchange opts)
    (ffsvFirstLegGearing opts) (ffsvFirstLegSpread opts) (ffsvFirstLegCappedRate opts) (ffsvFirstLegFlooredRate opts)
    (ffsvSecondLegGearing opts) (ffsvSecondLegSpread opts) (ffsvSecondLegCappedRate opts) (ffsvSecondLegFlooredRate opts)
    (ffsvFirstLegPaymentConvention opts) (ffsvSecondLegPaymentConvention opts)

floatFloatSwap2_ :: (SwapType) -> ([Double]) -- ^nominal1
 -> ([Double]) -- ^nominal2
 -> (Schedule) -- ^schedule1
 -> (GenInterestRateIndex ridx1) -> (DayCounter) -- ^dayCount1
 -> (Schedule) -- ^schedule2
 -> (GenInterestRateIndex ridx2) -> (DayCounter) -- ^dayCount2
 -> (Bool) -- ^intermediateCapitalExchange
 -> (Bool) -- ^finalCapitalExchange
 -> ([Double]) -- ^gearing1
 -> ([Double]) -- ^spread1
 -> ([Double]) -- ^cappedRate1
 -> ([Double]) -- ^flooredRate1
 -> ([Double]) -- ^gearing2
 -> ([Double]) -- ^spread2
 -> ([Double]) -- ^cappedRate2
 -> ([Double]) -- ^flooredRate2
 -> (Maybe BusinessDayConvention) -- ^paymentConvention1
 -> (Maybe BusinessDayConvention) -- ^paymentConvention2
 -> IO ((FloatFloatSwap))
floatFloatSwap2_ :: forall ridx1 ridx2.
SwapType
-> [Double]
-> [Double]
-> Schedule
-> GenInterestRateIndex ridx1
-> DayCounter
-> Schedule
-> GenInterestRateIndex ridx2
-> DayCounter
-> Bool
-> Bool
-> [Double]
-> [Double]
-> [Double]
-> [Double]
-> [Double]
-> [Double]
-> [Double]
-> [Double]
-> Maybe BusinessDayConvention
-> Maybe BusinessDayConvention
-> IO FloatFloatSwap
floatFloatSwap2_ SwapType
a1 [Double]
a2 [Double]
a3 Schedule
a4 GenInterestRateIndex ridx1
a5 DayCounter
a6 Schedule
a7 GenInterestRateIndex ridx2
a8 DayCounter
a9 Bool
a10 Bool
a11 [Double]
a12 [Double]
a13 [Double]
a14 [Double]
a15 [Double]
a16 [Double]
a17 [Double]
a18 [Double]
a19 Maybe BusinessDayConvention
a20 Maybe BusinessDayConvention
a21 =
  let {a1' :: CInt
a1' = (Int -> CInt
forall a b. (Integral a, Num b) => a -> b
fromIntegral (Int -> CInt) -> (SwapType -> Int) -> SwapType -> CInt
forall b c a. (b -> c) -> (a -> b) -> a -> c
. SwapType -> Int
forall a. Enum a => a -> Int
fromEnum) SwapType
a1} in 
  [Double]
-> ((CUInt, Ptr CDouble) -> IO FloatFloatSwap) -> IO FloatFloatSwap
forall b. [Double] -> ((CUInt, Ptr CDouble) -> IO b) -> IO b
withDoubleArray [Double]
a2 (((CUInt, Ptr CDouble) -> IO FloatFloatSwap) -> IO FloatFloatSwap)
-> ((CUInt, Ptr CDouble) -> IO FloatFloatSwap) -> IO FloatFloatSwap
forall a b. (a -> b) -> a -> b
$ \(CUInt
a2'1, Ptr CDouble
a2'2) -> 
  [Double]
-> ((CUInt, Ptr CDouble) -> IO FloatFloatSwap) -> IO FloatFloatSwap
forall b. [Double] -> ((CUInt, Ptr CDouble) -> IO b) -> IO b
withDoubleArray [Double]
a3 (((CUInt, Ptr CDouble) -> IO FloatFloatSwap) -> IO FloatFloatSwap)
-> ((CUInt, Ptr CDouble) -> IO FloatFloatSwap) -> IO FloatFloatSwap
forall a b. (a -> b) -> a -> b
$ \(CUInt
a3'1, Ptr CDouble
a3'2) -> 
  Schedule
-> (Ptr CSchedule -> IO FloatFloatSwap) -> IO FloatFloatSwap
forall b. Schedule -> (Ptr CSchedule -> IO b) -> IO b
withSchedule Schedule
a4 ((Ptr CSchedule -> IO FloatFloatSwap) -> IO FloatFloatSwap)
-> (Ptr CSchedule -> IO FloatFloatSwap) -> IO FloatFloatSwap
forall a b. (a -> b) -> a -> b
$ \Ptr CSchedule
a4' -> 
  GenInterestRateIndex ridx1
-> (Ptr CInterestRateIndex' -> IO FloatFloatSwap)
-> IO FloatFloatSwap
forall ridx b.
GenInterestRateIndex ridx
-> (Ptr CInterestRateIndex' -> IO b) -> IO b
withInterestRateIndex GenInterestRateIndex ridx1
a5 ((Ptr CInterestRateIndex' -> IO FloatFloatSwap)
 -> IO FloatFloatSwap)
-> (Ptr CInterestRateIndex' -> IO FloatFloatSwap)
-> IO FloatFloatSwap
forall a b. (a -> b) -> a -> b
$ \Ptr CInterestRateIndex'
a5' -> 
  DayCounter
-> (Ptr CDayCounter -> IO FloatFloatSwap) -> IO FloatFloatSwap
forall b. DayCounter -> (Ptr CDayCounter -> IO b) -> IO b
withDayCounter DayCounter
a6 ((Ptr CDayCounter -> IO FloatFloatSwap) -> IO FloatFloatSwap)
-> (Ptr CDayCounter -> IO FloatFloatSwap) -> IO FloatFloatSwap
forall a b. (a -> b) -> a -> b
$ \Ptr CDayCounter
a6' -> 
  Schedule
-> (Ptr CSchedule -> IO FloatFloatSwap) -> IO FloatFloatSwap
forall b. Schedule -> (Ptr CSchedule -> IO b) -> IO b
withSchedule Schedule
a7 ((Ptr CSchedule -> IO FloatFloatSwap) -> IO FloatFloatSwap)
-> (Ptr CSchedule -> IO FloatFloatSwap) -> IO FloatFloatSwap
forall a b. (a -> b) -> a -> b
$ \Ptr CSchedule
a7' -> 
  GenInterestRateIndex ridx2
-> (Ptr CInterestRateIndex' -> IO FloatFloatSwap)
-> IO FloatFloatSwap
forall ridx b.
GenInterestRateIndex ridx
-> (Ptr CInterestRateIndex' -> IO b) -> IO b
withInterestRateIndex GenInterestRateIndex ridx2
a8 ((Ptr CInterestRateIndex' -> IO FloatFloatSwap)
 -> IO FloatFloatSwap)
-> (Ptr CInterestRateIndex' -> IO FloatFloatSwap)
-> IO FloatFloatSwap
forall a b. (a -> b) -> a -> b
$ \Ptr CInterestRateIndex'
a8' -> 
  DayCounter
-> (Ptr CDayCounter -> IO FloatFloatSwap) -> IO FloatFloatSwap
forall b. DayCounter -> (Ptr CDayCounter -> IO b) -> IO b
withDayCounter DayCounter
a9 ((Ptr CDayCounter -> IO FloatFloatSwap) -> IO FloatFloatSwap)
-> (Ptr CDayCounter -> IO FloatFloatSwap) -> IO FloatFloatSwap
forall a b. (a -> b) -> a -> b
$ \Ptr CDayCounter
a9' -> 
  let {a10' :: CInt
a10' = Bool -> CInt
forall a. Num a => Bool -> a
C2HSImp.fromBool Bool
a10} in 
  let {a11' :: CInt
a11' = Bool -> CInt
forall a. Num a => Bool -> a
C2HSImp.fromBool Bool
a11} in 
  [Double]
-> ((CUInt, Ptr CDouble) -> IO FloatFloatSwap) -> IO FloatFloatSwap
forall b. [Double] -> ((CUInt, Ptr CDouble) -> IO b) -> IO b
withDoubleArray [Double]
a12 (((CUInt, Ptr CDouble) -> IO FloatFloatSwap) -> IO FloatFloatSwap)
-> ((CUInt, Ptr CDouble) -> IO FloatFloatSwap) -> IO FloatFloatSwap
forall a b. (a -> b) -> a -> b
$ \(CUInt
a12'1, Ptr CDouble
a12'2) -> 
  [Double]
-> ((CUInt, Ptr CDouble) -> IO FloatFloatSwap) -> IO FloatFloatSwap
forall b. [Double] -> ((CUInt, Ptr CDouble) -> IO b) -> IO b
withDoubleArray [Double]
a13 (((CUInt, Ptr CDouble) -> IO FloatFloatSwap) -> IO FloatFloatSwap)
-> ((CUInt, Ptr CDouble) -> IO FloatFloatSwap) -> IO FloatFloatSwap
forall a b. (a -> b) -> a -> b
$ \(CUInt
a13'1, Ptr CDouble
a13'2) -> 
  [Double]
-> ((CUInt, Ptr CDouble) -> IO FloatFloatSwap) -> IO FloatFloatSwap
forall b. [Double] -> ((CUInt, Ptr CDouble) -> IO b) -> IO b
withDoubleArray [Double]
a14 (((CUInt, Ptr CDouble) -> IO FloatFloatSwap) -> IO FloatFloatSwap)
-> ((CUInt, Ptr CDouble) -> IO FloatFloatSwap) -> IO FloatFloatSwap
forall a b. (a -> b) -> a -> b
$ \(CUInt
a14'1, Ptr CDouble
a14'2) -> 
  [Double]
-> ((CUInt, Ptr CDouble) -> IO FloatFloatSwap) -> IO FloatFloatSwap
forall b. [Double] -> ((CUInt, Ptr CDouble) -> IO b) -> IO b
withDoubleArray [Double]
a15 (((CUInt, Ptr CDouble) -> IO FloatFloatSwap) -> IO FloatFloatSwap)
-> ((CUInt, Ptr CDouble) -> IO FloatFloatSwap) -> IO FloatFloatSwap
forall a b. (a -> b) -> a -> b
$ \(CUInt
a15'1, Ptr CDouble
a15'2) -> 
  [Double]
-> ((CUInt, Ptr CDouble) -> IO FloatFloatSwap) -> IO FloatFloatSwap
forall b. [Double] -> ((CUInt, Ptr CDouble) -> IO b) -> IO b
withDoubleArray [Double]
a16 (((CUInt, Ptr CDouble) -> IO FloatFloatSwap) -> IO FloatFloatSwap)
-> ((CUInt, Ptr CDouble) -> IO FloatFloatSwap) -> IO FloatFloatSwap
forall a b. (a -> b) -> a -> b
$ \(CUInt
a16'1, Ptr CDouble
a16'2) -> 
  [Double]
-> ((CUInt, Ptr CDouble) -> IO FloatFloatSwap) -> IO FloatFloatSwap
forall b. [Double] -> ((CUInt, Ptr CDouble) -> IO b) -> IO b
withDoubleArray [Double]
a17 (((CUInt, Ptr CDouble) -> IO FloatFloatSwap) -> IO FloatFloatSwap)
-> ((CUInt, Ptr CDouble) -> IO FloatFloatSwap) -> IO FloatFloatSwap
forall a b. (a -> b) -> a -> b
$ \(CUInt
a17'1, Ptr CDouble
a17'2) -> 
  [Double]
-> ((CUInt, Ptr CDouble) -> IO FloatFloatSwap) -> IO FloatFloatSwap
forall b. [Double] -> ((CUInt, Ptr CDouble) -> IO b) -> IO b
withDoubleArray [Double]
a18 (((CUInt, Ptr CDouble) -> IO FloatFloatSwap) -> IO FloatFloatSwap)
-> ((CUInt, Ptr CDouble) -> IO FloatFloatSwap) -> IO FloatFloatSwap
forall a b. (a -> b) -> a -> b
$ \(CUInt
a18'1, Ptr CDouble
a18'2) -> 
  [Double]
-> ((CUInt, Ptr CDouble) -> IO FloatFloatSwap) -> IO FloatFloatSwap
forall b. [Double] -> ((CUInt, Ptr CDouble) -> IO b) -> IO b
withDoubleArray [Double]
a19 (((CUInt, Ptr CDouble) -> IO FloatFloatSwap) -> IO FloatFloatSwap)
-> ((CUInt, Ptr CDouble) -> IO FloatFloatSwap) -> IO FloatFloatSwap
forall a b. (a -> b) -> a -> b
$ \(CUInt
a19'1, Ptr CDouble
a19'2) -> 
  let {a20' :: CInt
a20' = Maybe BusinessDayConvention -> CInt
forall a. Enum a => Maybe a -> CInt
fromMaybeEnum Maybe BusinessDayConvention
a20} in 
  let {a21' :: CInt
a21' = Maybe BusinessDayConvention -> CInt
forall a. Enum a => Maybe a -> CInt
fromMaybeEnum Maybe BusinessDayConvention
a21} in 
  (Ptr (Ptr CChar) -> IO FloatFloatSwap) -> IO FloatFloatSwap
forall a b. (Ptr (Ptr a) -> IO b) -> IO b
preErrorCheck ((Ptr (Ptr CChar) -> IO FloatFloatSwap) -> IO FloatFloatSwap)
-> (Ptr (Ptr CChar) -> IO FloatFloatSwap) -> IO FloatFloatSwap
forall a b. (a -> b) -> a -> b
$ \Ptr (Ptr CChar)
a22' -> 
  CInt
-> CUInt
-> Ptr CDouble
-> CUInt
-> Ptr CDouble
-> Ptr CSchedule
-> Ptr CInterestRateIndex'
-> Ptr CDayCounter
-> Ptr CSchedule
-> Ptr CInterestRateIndex'
-> Ptr CDayCounter
-> CInt
-> CInt
-> CUInt
-> Ptr CDouble
-> CUInt
-> Ptr CDouble
-> CUInt
-> Ptr CDouble
-> CUInt
-> Ptr CDouble
-> CUInt
-> Ptr CDouble
-> CUInt
-> Ptr CDouble
-> CUInt
-> Ptr CDouble
-> CUInt
-> Ptr CDouble
-> CInt
-> CInt
-> Ptr (Ptr CChar)
-> IO (Ptr CFloatFloatSwap')
floatFloatSwap2_'_ CInt
a1' CUInt
a2'1  Ptr CDouble
a2'2 CUInt
a3'1  Ptr CDouble
a3'2 Ptr CSchedule
a4' Ptr CInterestRateIndex'
a5' Ptr CDayCounter
a6' Ptr CSchedule
a7' Ptr CInterestRateIndex'
a8' Ptr CDayCounter
a9' CInt
a10' CInt
a11' CUInt
a12'1  Ptr CDouble
a12'2 CUInt
a13'1  Ptr CDouble
a13'2 CUInt
a14'1  Ptr CDouble
a14'2 CUInt
a15'1  Ptr CDouble
a15'2 CUInt
a16'1  Ptr CDouble
a16'2 CUInt
a17'1  Ptr CDouble
a17'2 CUInt
a18'1  Ptr CDouble
a18'2 CUInt
a19'1  Ptr CDouble
a19'2 CInt
a20' CInt
a21' Ptr (Ptr CChar)
a22' IO (Ptr CFloatFloatSwap')
-> (Ptr CFloatFloatSwap' -> IO FloatFloatSwap) -> IO FloatFloatSwap
forall a b. IO a -> (a -> IO b) -> IO b
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= \Ptr CFloatFloatSwap'
res ->
  Ptr CFloatFloatSwap' -> IO FloatFloatSwap
peekFloatFloatSwap Ptr CFloatFloatSwap'
res IO FloatFloatSwap
-> (FloatFloatSwap -> IO FloatFloatSwap) -> IO FloatFloatSwap
forall a b. IO a -> (a -> IO b) -> IO b
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= \FloatFloatSwap
res' ->
  Ptr (Ptr CChar) -> IO ()
errorCheck  Ptr (Ptr CChar)
a22'IO () -> IO FloatFloatSwap -> IO FloatFloatSwap
forall a b. IO a -> IO b -> IO b
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>>
  FloatFloatSwap -> IO FloatFloatSwap
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return (FloatFloatSwap
res')

{-# LINE 444 "./QuantLib/Instrument/Swap.chs" #-}


-- |The spread on leg 1 that would make the swap's NPV zero.
firstLegFairSpread :: (FloatFloatSwap) -> IO ((Double))
firstLegFairSpread a1 =
  withFloatFloatSwap a1 $ \a1' -> 
  preErrorCheck $ \a2' -> 
  firstLegFairSpread'_ a1' a2' >>= \res ->
  let {res' = realToFrac res} in
  errorCheck  a2'>>
  return (res')

{-# LINE 447 "./QuantLib/Instrument/Swap.chs" #-}


-- |The spread on leg 2 that would make the swap's NPV zero.
secondLegFairSpread :: (FloatFloatSwap) -> IO ((Double))
secondLegFairSpread a1 =
  withFloatFloatSwap a1 $ \a1' -> 
  preErrorCheck $ \a2' -> 
  secondLegFairSpread'_ a1' a2' >>= \res ->
  let {res' = realToFrac res} in
  errorCheck  a2'>>
  return (res')

{-# LINE 450 "./QuantLib/Instrument/Swap.chs" #-}


-- | Haskell equivalent of QuantLib's fluent @MakeVanillaSwap@ builder -- a
-- single function with 'Maybe'-wrapped optional parameters instead of
-- chained @.with*@ calls, covering the subset of @makevanillaswap.hpp@'s
-- fields named in the parameters below. Not covered at all (no parameter):
-- explicit effective\/termination date overrides, a settlement calendar
-- distinct from the floating-leg one, floating-leg tenor\/convention\/
-- termination convention\/day count overrides (always taken from the
-- index, matching upstream's own defaults), @withRule@ variants (always
-- @DateGeneration::Backward@), end-of-month\/first-date\/next-to-last-date
-- overrides, a floating-leg spread other than @0@, a discounting term
-- structure or custom pricing engine (use 'setPricingEngine' on the
-- result instead), indexed\/at-par coupon overrides, and payment
-- convention (always the floating leg's, matching upstream's own default
-- when unset). @fixedLegTenor@\/@fixedLegDayCount@ are required arguments
-- here rather than optional with upstream's currency-based inference. A
-- 'Nothing' @settlementDays@ behaves as @Just 0@, rather than replicating
-- upstream's index-@valueDate@-based spot-date convention.
makeVanillaSwap
  :: (Word, TimeUnit)             -- ^swapTenor
  -> GenIborIndex ibor
  -> Double                       -- ^fixedRate
  -> (Int, TimeUnit)              -- ^forwardStart
  -> Maybe Int                    -- ^settlementDays
  -> (Word, TimeUnit)             -- ^fixedLegTenor
  -> DayCounter                   -- ^fixedLegDayCount
  -> Maybe BusinessDayConvention  -- ^fixedLegConvention
  -> Maybe BusinessDayConvention  -- ^fixedLegTerminationDateConvention
  -> Maybe Calendar               -- ^fixedLegCalendar
  -> Maybe Calendar               -- ^floatingLegCalendar
  -> Maybe Double                 -- ^nominal
  -> Maybe SwapType
  -> IO VanillaSwap
makeVanillaSwap :: forall ibor.
(Word, TimeUnit)
-> GenIborIndex ibor
-> Double
-> (Int, TimeUnit)
-> Maybe Int
-> (Word, TimeUnit)
-> DayCounter
-> Maybe BusinessDayConvention
-> Maybe BusinessDayConvention
-> Maybe Calendar
-> Maybe Calendar
-> Maybe Double
-> Maybe SwapType
-> IO VanillaSwap
makeVanillaSwap (Word
swLen, TimeUnit
swUnit) GenIborIndex ibor
index Double
fixedRate (Int, TimeUnit)
forwardStart Maybe Int
mSettlementDays
    (Word, TimeUnit)
fixedTenor DayCounter
fixedDayCount Maybe BusinessDayConvention
mFixedConvention Maybe BusinessDayConvention
mFixedTerminationConvention Maybe Calendar
mFixedCalendar
    Maybe Calendar
mFloatCalendar Maybe Double
mNominal Maybe SwapType
mType = do
  idxCalendar <- GenIborIndex ibor -> IO Calendar
forall idx. GenIndex idx -> IO Calendar
fixingCalendar GenIborIndex ibor
index
  floatTenor <- tenor index
  floatDayCount <- dayCounter index
  refDate <- evaluationDate
  let floatConv = GenIborIndex ibor -> BusinessDayConvention
forall ibor. GenIborIndex ibor -> BusinessDayConvention
businessDayConvention GenIborIndex ibor
index
      floatCalendar = Calendar -> Maybe Calendar -> Calendar
forall a. a -> Maybe a -> a
fromMaybe Calendar
idxCalendar Maybe Calendar
mFloatCalendar
      fixedCalendar = Calendar -> Maybe Calendar -> Calendar
forall a. a -> Maybe a -> a
fromMaybe Calendar
idxCalendar Maybe Calendar
mFixedCalendar
      fixedConvention = BusinessDayConvention
-> Maybe BusinessDayConvention -> BusinessDayConvention
forall a. a -> Maybe a -> a
fromMaybe BusinessDayConvention
ModifiedFollowing Maybe BusinessDayConvention
mFixedConvention
      fixedTerminationConvention = BusinessDayConvention
-> Maybe BusinessDayConvention -> BusinessDayConvention
forall a. a -> Maybe a -> a
fromMaybe BusinessDayConvention
ModifiedFollowing Maybe BusinessDayConvention
mFixedTerminationConvention
      settlementDays = Int -> Maybe Int -> Int
forall a. a -> Maybe a -> a
fromMaybe Int
0 Maybe Int
mSettlementDays
      nominal = Double -> Maybe Double -> Double
forall a. a -> Maybe a -> a
fromMaybe Double
1.0 Maybe Double
mNominal
      swapType = SwapType -> Maybe SwapType -> SwapType
forall a. a -> Maybe a -> a
fromMaybe SwapType
Payer Maybe SwapType
mType
      (fsLen, _) = forwardStart
  spotDate <- advance floatCalendar refDate (settlementDays, Days) Following False
  startDate0 <- addPeriod spotDate forwardStart
  swapStartDate <- case compare fsLen 0 of
    Ordering
LT -> Calendar -> Day -> BusinessDayConvention -> IO Day
adjust Calendar
floatCalendar Day
startDate0 BusinessDayConvention
Preceding
    Ordering
GT -> Calendar -> Day -> BusinessDayConvention -> IO Day
adjust Calendar
floatCalendar Day
startDate0 BusinessDayConvention
Following
    Ordering
EQ -> Day -> IO Day
forall a. a -> IO a
forall (f :: * -> *) a. Applicative f => a -> f a
pure Day
startDate0
  endDate <- addPeriod swapStartDate (fromIntegral swLen, swUnit)
  fixedSchedule <- schedule (Just swapStartDate) endDate fixedTenor fixedCalendar
    fixedConvention fixedTerminationConvention Backward False Nothing Nothing
  floatSchedule <- schedule (Just swapStartDate) endDate floatTenor floatCalendar
    floatConv floatConv Backward False Nothing Nothing
  vanillaSwap swapType nominal fixedSchedule fixedRate fixedDayCount
    floatSchedule index 0.0 floatDayCount (Just floatConv) Nothing

-- |Haskell equivalent of QuantLib's fluent @MakeCms@ builder, in the style of
-- 'makeVanillaSwap' above -- not a binding of the @MakeCms@ C++ class at all, but a plain
-- function composing already-bound primitives ('QuantLib.Time.Schedule.schedule',
-- 'QuantLib.CashFlow.cmsLeg', 'QuantLib.CashFlow.iborLeg', 'swapFromLegs'). The result is a plain
-- 'Swap' (a CMS swap has no calc\/getter of its own beyond generic 'Swap''s), with no
-- 'FloatingRateCouponPricer' attached -- attach one to the CMS leg afterwards via
-- @setCouponPricer =<< 'leg' result 0@ ('swapFromLegs' is used instead of 'swap' precisely so the
-- CMS leg is always leg 0, regardless of 'SwapType') and 'QuantLib.CashFlow.setCouponPricer'
-- before pricing.
--
-- Unlike @MakeCms@, @cmsLegTenor@\/@cmsLegDayCount@ are required arguments here rather than
-- defaulted (upstream hardcodes 3 Months\/@Actual360@); pass those literals to reproduce
-- @MakeCms@'s own defaults. Not covered at all (no parameter): an explicit effective date
-- override, CMS-leg\/floating-leg termination-date-convention\/rule\/end-of-month\/
-- first-date\/next-to-last-date overrides (always @ModifiedFollowing@\/@Backward@\/@False@\/
-- unset, matching @MakeCms@'s own defaults for the CMS leg), CMS coupon gearing\/caps\/floors
-- (use 'QuantLib.CashFlow.cmsLegWithOptions' and 'swap' directly for those), an ATM-spread lookup, a
-- discounting term structure or custom pricing engine (use 'QuantLib.Instrument.setPricingEngine'
-- on the result instead). A 'Nothing' @settlementDays@ behaves as @Just 0@, rather than
-- replicating upstream's index-@valueDate@-based spot-date convention (matching
-- 'makeVanillaSwap''s own choice here).
makeCms
  :: (Word, TimeUnit)             -- ^swapTenor
  -> GenSwapIndex sidx            -- ^cms index
  -> GenIborIndex ibor            -- ^floating-leg index
  -> Double                       -- ^floating-leg spread
  -> (Int, TimeUnit)              -- ^forwardStart
  -> Maybe Int                    -- ^settlementDays
  -> (Word, TimeUnit)             -- ^cmsLegTenor
  -> DayCounter                   -- ^cmsLegDayCount
  -> Maybe Calendar               -- ^cmsLegCalendar
  -> Maybe Calendar               -- ^floatingLegCalendar
  -> Maybe Double                 -- ^nominal
  -> Maybe SwapType                -- ^'Payer' pays the CMS leg (receives floating); 'Receiver' the reverse
  -> IO Swap
makeCms :: forall sidx ibor.
(Word, TimeUnit)
-> GenSwapIndex sidx
-> GenIborIndex ibor
-> Double
-> (Int, TimeUnit)
-> Maybe Int
-> (Word, TimeUnit)
-> DayCounter
-> Maybe Calendar
-> Maybe Calendar
-> Maybe Double
-> Maybe SwapType
-> IO Swap
makeCms (Word
swLen, TimeUnit
swUnit) GenSwapIndex sidx
swapIndex GenIborIndex ibor
iborIndex Double
iborSpread (Int, TimeUnit)
forwardStart Maybe Int
mSettlementDays
    (Word, TimeUnit)
cmsTenor DayCounter
cmsDayCount Maybe Calendar
mCmsCalendar Maybe Calendar
mFloatCalendar Maybe Double
mNominal Maybe SwapType
mType = do
  idxCalendar <- GenSwapIndex sidx -> IO Calendar
forall idx. GenIndex idx -> IO Calendar
fixingCalendar GenSwapIndex sidx
swapIndex
  floatTenor <- tenor iborIndex
  floatDayCount <- dayCounter iborIndex
  refDate <- evaluationDate
  let floatConv = GenIborIndex ibor -> BusinessDayConvention
forall ibor. GenIborIndex ibor -> BusinessDayConvention
businessDayConvention GenIborIndex ibor
iborIndex
      floatCalendar = Calendar -> Maybe Calendar -> Calendar
forall a. a -> Maybe a -> a
fromMaybe Calendar
idxCalendar Maybe Calendar
mFloatCalendar
      cmsCalendar = Calendar -> Maybe Calendar -> Calendar
forall a. a -> Maybe a -> a
fromMaybe Calendar
idxCalendar Maybe Calendar
mCmsCalendar
      settlementDays = Int -> Maybe Int -> Int
forall a. a -> Maybe a -> a
fromMaybe Int
0 Maybe Int
mSettlementDays
      nominal = Double -> Maybe Double -> Double
forall a. a -> Maybe a -> a
fromMaybe Double
1.0 Maybe Double
mNominal
      swapType = SwapType -> Maybe SwapType -> SwapType
forall a. a -> Maybe a -> a
fromMaybe SwapType
Payer Maybe SwapType
mType
      (fsLen, _) = forwardStart
  spotDate <- advance floatCalendar refDate (settlementDays, Days) Following False
  startDate0 <- addPeriod spotDate forwardStart
  swapStartDate <- case compare fsLen 0 of
    Ordering
LT -> Calendar -> Day -> BusinessDayConvention -> IO Day
adjust Calendar
floatCalendar Day
startDate0 BusinessDayConvention
Preceding
    Ordering
GT -> Calendar -> Day -> BusinessDayConvention -> IO Day
adjust Calendar
floatCalendar Day
startDate0 BusinessDayConvention
Following
    Ordering
EQ -> Day -> IO Day
forall a. a -> IO a
forall (f :: * -> *) a. Applicative f => a -> f a
pure Day
startDate0
  endDate <- addPeriod swapStartDate (fromIntegral swLen, swUnit)
  cmsSchedule <- schedule (Just swapStartDate) endDate cmsTenor cmsCalendar
    ModifiedFollowing ModifiedFollowing Backward False Nothing Nothing
  floatSchedule <- schedule (Just swapStartDate) endDate floatTenor floatCalendar
    floatConv floatConv Backward False Nothing Nothing
  cmsLegResult <- cmsLeg cmsSchedule swapIndex (nominal :| []) cmsDayCount ModifiedFollowing
    [] [] [] [] [] False False
  floatLegResult <- iborLeg floatSchedule iborIndex (nominal :| []) floatDayCount floatConv
    [] [] [iborSpread] [] [] False False
  -- 'swapFromLegs' (not 'swap') so the CMS leg is always leg 0 of the result regardless of
  -- 'SwapType' -- attach a pricer via @setCouponPricer =<< 'leg' result 0@ before pricing.
  swapFromLegs [(cmsLegResult, swapType == Payer), (floatLegResult, swapType == Receiver)]

-- |The cash flows belonging to the first leg are paid; the ones belonging to the second leg are received.
swap :: (GenLeg l1) -> (GenLeg l2) -> IO ((Swap))
swap :: forall l1 l2. GenLeg l1 -> GenLeg l2 -> IO Swap
swap GenLeg l1
a1 GenLeg l2
a2 =
  GenLeg l1 -> (Ptr CLeg' -> IO Swap) -> IO Swap
forall l b. GenLeg l -> (Ptr CLeg' -> IO b) -> IO b
withLeg GenLeg l1
a1 ((Ptr CLeg' -> IO Swap) -> IO Swap)
-> (Ptr CLeg' -> IO Swap) -> IO Swap
forall a b. (a -> b) -> a -> b
$ \Ptr CLeg'
a1' -> 
  GenLeg l2 -> (Ptr CLeg' -> IO Swap) -> IO Swap
forall l b. GenLeg l -> (Ptr CLeg' -> IO b) -> IO b
withLeg GenLeg l2
a2 ((Ptr CLeg' -> IO Swap) -> IO Swap)
-> (Ptr CLeg' -> IO Swap) -> IO Swap
forall a b. (a -> b) -> a -> b
$ \Ptr CLeg'
a2' -> 
  (Ptr (Ptr CChar) -> IO Swap) -> IO Swap
forall a b. (Ptr (Ptr a) -> IO b) -> IO b
preErrorCheck ((Ptr (Ptr CChar) -> IO Swap) -> IO Swap)
-> (Ptr (Ptr CChar) -> IO Swap) -> IO Swap
forall a b. (a -> b) -> a -> b
$ \Ptr (Ptr CChar)
a3' -> 
  Ptr CLeg' -> Ptr CLeg' -> Ptr (Ptr CChar) -> IO (Ptr CSwap')
swap'_ Ptr CLeg'
a1' Ptr CLeg'
a2' Ptr (Ptr CChar)
a3' IO (Ptr CSwap') -> (Ptr CSwap' -> IO Swap) -> IO Swap
forall a b. IO a -> (a -> IO b) -> IO b
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= \Ptr CSwap'
res ->
  Ptr CSwap' -> IO Swap
peekSwap Ptr CSwap'
res IO Swap -> (Swap -> IO Swap) -> IO Swap
forall a b. IO a -> (a -> IO b) -> IO b
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= \Swap
res' ->
  Ptr (Ptr CChar) -> IO ()
errorCheck  Ptr (Ptr CChar)
a3'IO () -> IO Swap -> IO Swap
forall a b. IO a -> IO b -> IO b
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>>
  Swap -> IO Swap
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return (Swap
res')

{-# LINE 582 "./QuantLib/Instrument/Swap.chs" #-}


-- |Discount factor at leg j's end date.
endDiscounts :: (GenSwap s) -> (Word) -> IO ((Double))
endDiscounts a1 a2 =
  withSwap a1 $ \a1' -> 
  let {a2' = fromIntegral a2} in 
  preErrorCheck $ \a3' -> 
  endDiscounts'_ a1' a2' a3' >>= \res ->
  let {res' = realToFrac res} in
  errorCheck  a3'>>
  return (res')

{-# LINE 585 "./QuantLib/Instrument/Swap.chs" #-}


-- |How many legs this swap has; leg indexes run from 0 to one less than this.
numberOfLegs :: (GenSwap s) -> IO ((Word))
numberOfLegs a1 =
  withSwap a1 $ \a1' -> 
  preErrorCheck $ \a2' -> 
  numberOfLegs'_ a1' a2' >>= \res ->
  let {res' = fromIntegral res} in
  errorCheck  a2'>>
  return (res')

{-# LINE 588 "./QuantLib/Instrument/Swap.chs" #-}


-- |The j-th leg's cash flows.
leg :: (GenSwap s) -> (Word) -> IO ((Leg))
leg a1 a2 =
  withSwap a1 $ \a1' -> 
  let {a2' = fromIntegral a2} in 
  preErrorCheck $ \a3' -> 
  leg'_ a1' a2' a3' >>= \res ->
  peekLeg res >>= \res' ->
  errorCheck  a3'>>
  return (res')

{-# LINE 591 "./QuantLib/Instrument/Swap.chs" #-}


-- |Basis-point sensitivity of leg j.
legBps :: (GenSwap s) -> (Word) -> IO ((Double))
legBps a1 a2 =
  withSwap a1 $ \a1' -> 
  let {a2' = fromIntegral a2} in 
  preErrorCheck $ \a3' -> 
  legBps'_ a1' a2' a3' >>= \res ->
  let {res' = realToFrac res} in
  errorCheck  a3'>>
  return (res')

{-# LINE 594 "./QuantLib/Instrument/Swap.chs" #-}


-- |NPV of leg j.
legNpv :: (GenSwap s) -> (Word) -> IO ((Double))
legNpv a1 a2 =
  withSwap a1 $ \a1' -> 
  let {a2' = fromIntegral a2} in 
  preErrorCheck $ \a3' -> 
  legNpv'_ a1' a2' a3' >>= \res ->
  let {res' = realToFrac res} in
  errorCheck  a3'>>
  return (res')

{-# LINE 597 "./QuantLib/Instrument/Swap.chs" #-}


-- |Discount factor at leg j's start date.
startDiscounts :: (GenSwap s) -> (Word) -> IO ((Double))
startDiscounts a1 a2 =
  withSwap a1 $ \a1' -> 
  let {a2' = fromIntegral a2} in 
  preErrorCheck $ \a3' -> 
  startDiscounts'_ a1' a2' a3' >>= \res ->
  let {res' = realToFrac res} in
  errorCheck  a3'>>
  return (res')

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


-- |Constructs a cross-currency swap from two legs and their currencies; the first leg is paid, the second received.
constNotionalCrossCurrencySwap :: (GenLeg l1) -> (Currency) -- ^firstLegCcy
 -> (GenLeg l2) -> (Currency) -- ^secondLegCcy
 -> IO ((ConstNotionalCrossCurrencySwap))
constNotionalCrossCurrencySwap a1 a2 a3 a4 =
  withLeg a1 $ \a1' -> 
  withCurrency a2 $ \a2' -> 
  withLeg a3 $ \a3' -> 
  withCurrency a4 $ \a4' -> 
  preErrorCheck $ \a5' -> 
  constNotionalCrossCurrencySwap'_ a1' a2' a3' a4' a5' >>= \res ->
  peekConstNotionalCrossCurrencySwap res >>= \res' ->
  errorCheck  a5'>>
  return (res')

{-# LINE 607 "./QuantLib/Instrument/Swap.chs" #-}


-- |Multi-leg constructor.
constNotionalCrossCurrencySwapFromLegs :: [(Leg, Bool)] -- ^(legs, payer)
  -> [Currency] -> IO ConstNotionalCrossCurrencySwap
constNotionalCrossCurrencySwapFromLegs legsPayer = qlConstNotionalCrossCurrencySwap1 legs payer
  where (legs, payer) = unzip legsPayer
qlConstNotionalCrossCurrencySwap1 :: ([Leg]) -> ([Bool]) -> ([Currency]) -> IO ((ConstNotionalCrossCurrencySwap))
qlConstNotionalCrossCurrencySwap1 a1 a2 a3 =
  withLegArray a1 $ \(a1'1, a1'2) -> 
  withBoolArray a2 $ \(a2'1, a2'2) -> 
  withCurrencyArray a3 $ \(a3'1, a3'2) -> 
  preErrorCheck $ \a4' -> 
  qlConstNotionalCrossCurrencySwap1'_ a1'1  a1'2 a2'1  a2'2 a3'1  a3'2 a4' >>= \res ->
  peekConstNotionalCrossCurrencySwap res >>= \res' ->
  errorCheck  a4'>>
  return (res')

{-# LINE 614 "./QuantLib/Instrument/Swap.chs" #-}


-- |Leg j's currency.
legCurrency :: (GenConstNotionalCrossCurrencySwap x) -> (Word) -> IO ((Currency))
legCurrency a1 a2 =
  withConstNotionalCrossCurrencySwap a1 $ \a1' -> 
  let {a2' = fromIntegral a2} in 
  preErrorCheck $ \a3' -> 
  legCurrency'_ a1' a2' a3' >>= \res ->
  peekCurrency res >>= \res' ->
  errorCheck  a3'>>
  return (res')

{-# LINE 617 "./QuantLib/Instrument/Swap.chs" #-}


-- |Basis-point sensitivity of leg j, expressed in the leg's own currency (contrast 'legBps', in the swap's NPV currency).
inCcyLegBps :: (GenConstNotionalCrossCurrencySwap x) -> (Word) -> IO ((Double))
inCcyLegBps a1 a2 =
  withConstNotionalCrossCurrencySwap a1 $ \a1' -> 
  let {a2' = fromIntegral a2} in 
  preErrorCheck $ \a3' -> 
  inCcyLegBps'_ a1' a2' a3' >>= \res ->
  let {res' = realToFrac res} in
  errorCheck  a3'>>
  return (res')

{-# LINE 620 "./QuantLib/Instrument/Swap.chs" #-}


-- |NPV of leg j, expressed in the leg's own currency (contrast 'legNpv', in the swap's NPV currency).
inCcyLegNpv :: (GenConstNotionalCrossCurrencySwap x) -> (Word) -> IO ((Double))
inCcyLegNpv a1 a2 =
  withConstNotionalCrossCurrencySwap a1 $ \a1' -> 
  let {a2' = fromIntegral a2} in 
  preErrorCheck $ \a3' -> 
  inCcyLegNpv'_ a1' a2' a3' >>= \res ->
  let {res' = realToFrac res} in
  errorCheck  a3'>>
  return (res')

{-# LINE 623 "./QuantLib/Instrument/Swap.chs" #-}


-- |Discount factor at the instrument's NPV date, for leg j.
npvDateDiscounts :: (GenConstNotionalCrossCurrencySwap x) -> (Word) -> IO ((Double))
npvDateDiscounts a1 a2 =
  withConstNotionalCrossCurrencySwap a1 $ \a1' -> 
  let {a2' = fromIntegral a2} in 
  preErrorCheck $ \a3' -> 
  npvDateDiscounts'_ a1' a2' a3' >>= \res ->
  let {res' = realToFrac res} in
  errorCheck  a3'>>
  return (res')

{-# LINE 626 "./QuantLib/Instrument/Swap.chs" #-}


-- |Cross-currency basis swap: pay-currency cashflows on leg 0, receive-currency on leg 1.
-- 'ConstNotionalCrossCurrencyBasisSwapOpts' bundles every trailing param the C++ constructor
-- defaults (all OIS-only -- payment lag, compound-spread, lookback, observation shift, lockout,
-- averaging method per leg, plus a shared telescopic-value-dates flag; ignored for a plain Ibor
-- 'payIndex'\/'recIndex', since upstream itself only consults them when the index is an overnight
-- index); override only what's needed via record-update syntax on
-- 'defaultConstNotionalCrossCurrencyBasisSwapOpts'.
constNotionalCrossCurrencyBasisSwap :: Double -> Currency -> Schedule -> GenIborIndex ibor1 -> Double -> Double
  -> Double -> Currency -> Schedule -> GenIborIndex ibor2 -> Double -> Double
  -> ConstNotionalCrossCurrencyBasisSwapOpts -> IO ConstNotionalCrossCurrencyBasisSwap
constNotionalCrossCurrencyBasisSwap :: forall ibor1 ibor2.
Double
-> Currency
-> Schedule
-> GenIborIndex ibor1
-> Double
-> Double
-> Double
-> Currency
-> Schedule
-> GenIborIndex ibor2
-> Double
-> Double
-> ConstNotionalCrossCurrencyBasisSwapOpts
-> IO ConstNotionalCrossCurrencyBasisSwap
constNotionalCrossCurrencyBasisSwap Double
payNominal Currency
payCurrency Schedule
paySchedule GenIborIndex ibor1
payIndex Double
paySpread Double
payGearing
    Double
recNominal Currency
recCurrency Schedule
recSchedule GenIborIndex ibor2
recIndex Double
recSpread Double
recGearing ConstNotionalCrossCurrencyBasisSwapOpts
opts =
  Double
-> Currency
-> Schedule
-> GenIborIndex ibor1
-> Double
-> Double
-> Double
-> Currency
-> Schedule
-> GenIborIndex ibor2
-> Double
-> Double
-> Int
-> Int
-> Bool
-> Maybe Word
-> Bool
-> Word
-> RateAveragingType
-> Bool
-> Maybe Word
-> Bool
-> Word
-> RateAveragingType
-> Bool
-> IO ConstNotionalCrossCurrencyBasisSwap
forall ibor1 ibor2.
Double
-> Currency
-> Schedule
-> GenIborIndex ibor1
-> Double
-> Double
-> Double
-> Currency
-> Schedule
-> GenIborIndex ibor2
-> Double
-> Double
-> Int
-> Int
-> Bool
-> Maybe Word
-> Bool
-> Word
-> RateAveragingType
-> Bool
-> Maybe Word
-> Bool
-> Word
-> RateAveragingType
-> Bool
-> IO ConstNotionalCrossCurrencyBasisSwap
constNotionalCrossCurrencyBasisSwap_ Double
payNominal Currency
payCurrency Schedule
paySchedule GenIborIndex ibor1
payIndex Double
paySpread Double
payGearing
    Double
recNominal Currency
recCurrency Schedule
recSchedule GenIborIndex ibor2
recIndex Double
recSpread Double
recGearing
    (ConstNotionalCrossCurrencyBasisSwapOpts -> Int
cccbsPayPaymentLag ConstNotionalCrossCurrencyBasisSwapOpts
opts) (ConstNotionalCrossCurrencyBasisSwapOpts -> Int
cccbsRecPaymentLag ConstNotionalCrossCurrencyBasisSwapOpts
opts)
    (ConstNotionalCrossCurrencyBasisSwapOpts -> Bool
cccbsPayCompoundSpread ConstNotionalCrossCurrencyBasisSwapOpts
opts) (OvernightObservation -> Maybe Word
lookbackDays OvernightObservation
payObs) (OvernightObservation -> Bool
applyObservationShift OvernightObservation
payObs)
    (OvernightObservation -> Word
lockoutDays OvernightObservation
payObs) (ConstNotionalCrossCurrencyBasisSwapOpts -> RateAveragingType
cccbsPayAveragingMethod ConstNotionalCrossCurrencyBasisSwapOpts
opts)
    (ConstNotionalCrossCurrencyBasisSwapOpts -> Bool
cccbsRecCompoundSpread ConstNotionalCrossCurrencyBasisSwapOpts
opts) (OvernightObservation -> Maybe Word
lookbackDays OvernightObservation
recObs) (OvernightObservation -> Bool
applyObservationShift OvernightObservation
recObs)
    (OvernightObservation -> Word
lockoutDays OvernightObservation
recObs) (ConstNotionalCrossCurrencyBasisSwapOpts -> RateAveragingType
cccbsRecAveragingMethod ConstNotionalCrossCurrencyBasisSwapOpts
opts)
    (ConstNotionalCrossCurrencyBasisSwapOpts -> Bool
cccbsTelescopicValueDates ConstNotionalCrossCurrencyBasisSwapOpts
opts)
  where payObs :: OvernightObservation
payObs = ConstNotionalCrossCurrencyBasisSwapOpts -> OvernightObservation
cccbsPayObservation ConstNotionalCrossCurrencyBasisSwapOpts
opts
        recObs :: OvernightObservation
recObs = ConstNotionalCrossCurrencyBasisSwapOpts -> OvernightObservation
cccbsRecObservation ConstNotionalCrossCurrencyBasisSwapOpts
opts

constNotionalCrossCurrencyBasisSwap_ :: (Double) -- ^payNominal
 -> (Currency) -- ^payCurrency
 -> (Schedule) -- ^paySchedule
 -> (GenIborIndex ibor1) -- ^payIndex
 -> (Double) -- ^paySpread
 -> (Double) -- ^payGearing
 -> (Double) -- ^recNominal
 -> (Currency) -- ^recCurrency
 -> (Schedule) -- ^recSchedule
 -> (GenIborIndex ibor2) -- ^recIndex
 -> (Double) -- ^recSpread
 -> (Double) -- ^recGearing
 -> (Int) -- ^payPaymentLag
 -> (Int) -- ^recPaymentLag
 -> (Bool) -- ^payCompoundSpread
 -> (Maybe Word) -- ^payLookbackDays
 -> (Bool) -- ^payObservationShift
 -> (Word) -- ^payLockoutDays
 -> (RateAveragingType) -- ^payAveragingMethod
 -> (Bool) -- ^recCompoundSpread
 -> (Maybe Word) -- ^recLookbackDays
 -> (Bool) -- ^recObservationShift
 -> (Word) -- ^recLockoutDays
 -> (RateAveragingType) -- ^recAveragingMethod
 -> (Bool) -- ^telescopicValueDates
 -> IO ((ConstNotionalCrossCurrencyBasisSwap))
constNotionalCrossCurrencyBasisSwap_ :: forall ibor1 ibor2.
Double
-> Currency
-> Schedule
-> GenIborIndex ibor1
-> Double
-> Double
-> Double
-> Currency
-> Schedule
-> GenIborIndex ibor2
-> Double
-> Double
-> Int
-> Int
-> Bool
-> Maybe Word
-> Bool
-> Word
-> RateAveragingType
-> Bool
-> Maybe Word
-> Bool
-> Word
-> RateAveragingType
-> Bool
-> IO ConstNotionalCrossCurrencyBasisSwap
constNotionalCrossCurrencyBasisSwap_ Double
a1 Currency
a2 Schedule
a3 GenIborIndex ibor1
a4 Double
a5 Double
a6 Double
a7 Currency
a8 Schedule
a9 GenIborIndex ibor2
a10 Double
a11 Double
a12 Int
a13 Int
a14 Bool
a15 Maybe Word
a16 Bool
a17 Word
a18 RateAveragingType
a19 Bool
a20 Maybe Word
a21 Bool
a22 Word
a23 RateAveragingType
a24 Bool
a25 =
  let {a1' :: CDouble
a1' = Double -> CDouble
forall a b. (Real a, Fractional b) => a -> b
realToFrac Double
a1} in 
  Currency
-> (Ptr CCurrency -> IO ConstNotionalCrossCurrencyBasisSwap)
-> IO ConstNotionalCrossCurrencyBasisSwap
forall b. Currency -> (Ptr CCurrency -> IO b) -> IO b
withCurrency Currency
a2 ((Ptr CCurrency -> IO ConstNotionalCrossCurrencyBasisSwap)
 -> IO ConstNotionalCrossCurrencyBasisSwap)
-> (Ptr CCurrency -> IO ConstNotionalCrossCurrencyBasisSwap)
-> IO ConstNotionalCrossCurrencyBasisSwap
forall a b. (a -> b) -> a -> b
$ \Ptr CCurrency
a2' -> 
  Schedule
-> (Ptr CSchedule -> IO ConstNotionalCrossCurrencyBasisSwap)
-> IO ConstNotionalCrossCurrencyBasisSwap
forall b. Schedule -> (Ptr CSchedule -> IO b) -> IO b
withSchedule Schedule
a3 ((Ptr CSchedule -> IO ConstNotionalCrossCurrencyBasisSwap)
 -> IO ConstNotionalCrossCurrencyBasisSwap)
-> (Ptr CSchedule -> IO ConstNotionalCrossCurrencyBasisSwap)
-> IO ConstNotionalCrossCurrencyBasisSwap
forall a b. (a -> b) -> a -> b
$ \Ptr CSchedule
a3' -> 
  GenIborIndex ibor1
-> (Ptr CIborIndex' -> IO ConstNotionalCrossCurrencyBasisSwap)
-> IO ConstNotionalCrossCurrencyBasisSwap
forall ibor b.
GenIborIndex ibor -> (Ptr CIborIndex' -> IO b) -> IO b
withIborIndex GenIborIndex ibor1
a4 ((Ptr CIborIndex' -> IO ConstNotionalCrossCurrencyBasisSwap)
 -> IO ConstNotionalCrossCurrencyBasisSwap)
-> (Ptr CIborIndex' -> IO ConstNotionalCrossCurrencyBasisSwap)
-> IO ConstNotionalCrossCurrencyBasisSwap
forall a b. (a -> b) -> a -> b
$ \Ptr CIborIndex'
a4' -> 
  let {a5' :: CDouble
a5' = realToFrac a5} in 
  let {a6' = realToFrac a6} in 
  let {a7' = realToFrac a7} in 
  withCurrency a8 $ \a8' -> 
  withSchedule a9 $ \a9' -> 
  withIborIndex a10 $ \a10' -> 
  let {a11' = realToFrac a11} in 
  let {a12' = realToFrac a12} in 
  let {a13' = fromIntegral a13} in 
  let {a14' = fromIntegral a14} in 
  let {a15' = C2HSImp.fromBool a15} in 
  let {a16' = fromMaybeInt a16} in 
  let {a17' = C2HSImp.fromBool a17} in 
  let {a18' = fromIntegral a18} in 
  let {a19' = (fromIntegral . fromEnum) a19} in 
  let {a20' = C2HSImp.fromBool a20} in 
  let {a21' = fromMaybeInt a21} in 
  let {a22' = C2HSImp.fromBool a22} in 
  let {a23' = fromIntegral a23} in 
  let {a24' = (fromIntegral . fromEnum) a24} in 
  let {a25' = C2HSImp.fromBool a25} in 
  preErrorCheck $ \a26' -> 
  constNotionalCrossCurrencyBasisSwap_'_ a1' a2' a3' a4' a5' a6' a7' a8' a9' a10' a11' a12' a13' a14' a15' a16' a17' a18' a19' a20' a21' a22' a23' a24' a25' a26' >>= \res ->
  peekConstNotionalCrossCurrencyBasisSwap res >>= \res' ->
  errorCheck  a26'>>
  return (res')

{-# LINE 676 "./QuantLib/Instrument/Swap.chs" #-}


-- |The pay-leg spread that would make the swap's NPV zero.
fairPaySpread :: (ConstNotionalCrossCurrencyBasisSwap) -> IO ((Double))
fairPaySpread a1 =
  withConstNotionalCrossCurrencyBasisSwap a1 $ \a1' -> 
  preErrorCheck $ \a2' -> 
  fairPaySpread'_ a1' a2' >>= \res ->
  let {res' = realToFrac res} in
  errorCheck  a2'>>
  return (res')

{-# LINE 679 "./QuantLib/Instrument/Swap.chs" #-}


-- |The receive-leg spread that would make the swap's NPV zero.
fairRecSpread :: (ConstNotionalCrossCurrencyBasisSwap) -> IO ((Double))
fairRecSpread a1 =
  withConstNotionalCrossCurrencyBasisSwap a1 $ \a1' -> 
  preErrorCheck $ \a2' -> 
  fairRecSpread'_ a1' a2' >>= \res ->
  let {res' = realToFrac res} in
  errorCheck  a2'>>
  return (res')

{-# LINE 682 "./QuantLib/Instrument/Swap.chs" #-}


-- |Cross-currency fixed-vs-floating swap: 'Payer' pays the fixed leg (leg 0) and receives the
-- floating leg (leg 1); 'Receiver' the reverse. Every trailing defaulted param of the upstream
-- constructor is a required argument here (only 4 trailing defaults, under the options-record
-- threshold -- see 'ConstNotionalCrossCurrencyBasisSwapOpts' above) -- pass @False@\/@False@\/
-- 'defaultOvernightObservation'\/'AveragingCompound' to reproduce upstream's own defaults; the
-- OIS-only ones are ignored for a plain Ibor 'floatIndex'.
--
-- Upstream declares the three observation parameters as
-- @floatLookbackDays, floatObservationShift, floatLockoutDays@, inverting the order every
-- other overnight-leg producer uses; 'OvernightObservation' hides that.
constNotionalCrossCurrencyFixedVsFloatingSwap :: SwapType
  -> Double -- ^fixedNominal
  -> Currency -- ^fixedCurrency
  -> Schedule -- ^fixedSchedule
  -> Double -- ^fixedRate
  -> DayCounter -- ^fixedDayCount
  -> BusinessDayConvention -- ^fixedPaymentBdc
  -> Word -- ^fixedPaymentLag
  -> Calendar -- ^fixedPaymentCalendar
  -> Double -- ^floatNominal
  -> Currency -- ^floatCurrency
  -> Schedule -- ^floatSchedule
  -> GenIborIndex ibor -- ^floatIndex
  -> Double -- ^floatSpread
  -> BusinessDayConvention -- ^floatPaymentBdc
  -> Word -- ^floatPaymentLag
  -> Calendar -- ^floatPaymentCalendar
  -> Bool -- ^telescopicValueDates
  -> Bool -- ^floatCompoundSpread
  -> OvernightObservation -- ^floatObservation
  -> RateAveragingType -- ^floatAveragingMethod
  -> IO ConstNotionalCrossCurrencyFixedVsFloatingSwap
constNotionalCrossCurrencyFixedVsFloatingSwap :: forall ibor.
SwapType
-> Double
-> Currency
-> Schedule
-> Double
-> DayCounter
-> BusinessDayConvention
-> Word
-> Calendar
-> Double
-> Currency
-> Schedule
-> GenIborIndex ibor
-> Double
-> BusinessDayConvention
-> Word
-> Calendar
-> Bool
-> Bool
-> OvernightObservation
-> RateAveragingType
-> IO ConstNotionalCrossCurrencyFixedVsFloatingSwap
constNotionalCrossCurrencyFixedVsFloatingSwap SwapType
t Double
fxN Currency
fxC Schedule
fxS Double
fxR DayCounter
fxDc BusinessDayConvention
fxBdc Word
fxLag Calendar
fxCal
  Double
flN Currency
flC Schedule
flS GenIborIndex ibor
flIdx Double
flSprd BusinessDayConvention
flBdc Word
flLag Calendar
flCal Bool
telescopic Bool
compound OvernightObservation
obs RateAveragingType
avg =
  SwapType
-> Double
-> Currency
-> Schedule
-> Double
-> DayCounter
-> BusinessDayConvention
-> Word
-> Calendar
-> Double
-> Currency
-> Schedule
-> GenIborIndex ibor
-> Double
-> BusinessDayConvention
-> Word
-> Calendar
-> Bool
-> Bool
-> Maybe Word
-> Bool
-> Word
-> RateAveragingType
-> IO ConstNotionalCrossCurrencyFixedVsFloatingSwap
forall ibor.
SwapType
-> Double
-> Currency
-> Schedule
-> Double
-> DayCounter
-> BusinessDayConvention
-> Word
-> Calendar
-> Double
-> Currency
-> Schedule
-> GenIborIndex ibor
-> Double
-> BusinessDayConvention
-> Word
-> Calendar
-> Bool
-> Bool
-> Maybe Word
-> Bool
-> Word
-> RateAveragingType
-> IO ConstNotionalCrossCurrencyFixedVsFloatingSwap
constNotionalCrossCurrencyFixedVsFloatingSwapRaw SwapType
t Double
fxN Currency
fxC Schedule
fxS Double
fxR DayCounter
fxDc BusinessDayConvention
fxBdc Word
fxLag Calendar
fxCal
    Double
flN Currency
flC Schedule
flS GenIborIndex ibor
flIdx Double
flSprd BusinessDayConvention
flBdc Word
flLag Calendar
flCal Bool
telescopic Bool
compound
    (OvernightObservation -> Maybe Word
lookbackDays OvernightObservation
obs) (OvernightObservation -> Bool
applyObservationShift OvernightObservation
obs) (OvernightObservation -> Word
lockoutDays OvernightObservation
obs) RateAveragingType
avg

constNotionalCrossCurrencyFixedVsFloatingSwapRaw :: (SwapType) -> (Double) -- ^fixedNominal
 -> (Currency) -- ^fixedCurrency
 -> (Schedule) -- ^fixedSchedule
 -> (Double) -- ^fixedRate
 -> (DayCounter) -- ^fixedDayCount
 -> (BusinessDayConvention) -- ^fixedPaymentBdc
 -> (Word) -- ^fixedPaymentLag
 -> (Calendar) -- ^fixedPaymentCalendar
 -> (Double) -- ^floatNominal
 -> (Currency) -- ^floatCurrency
 -> (Schedule) -- ^floatSchedule
 -> (GenIborIndex ibor) -- ^floatIndex
 -> (Double) -- ^floatSpread
 -> (BusinessDayConvention) -- ^floatPaymentBdc
 -> (Word) -- ^floatPaymentLag
 -> (Calendar) -- ^floatPaymentCalendar
 -> (Bool) -- ^telescopicValueDates
 -> (Bool) -- ^floatCompoundSpread
 -> (Maybe Word) -- ^floatLookbackDays
 -> (Bool) -- ^floatObservationShift
 -> (Word) -- ^floatLockoutDays
 -> (RateAveragingType) -- ^floatAveragingMethod
 -> IO ((ConstNotionalCrossCurrencyFixedVsFloatingSwap))
constNotionalCrossCurrencyFixedVsFloatingSwapRaw :: forall ibor.
SwapType
-> Double
-> Currency
-> Schedule
-> Double
-> DayCounter
-> BusinessDayConvention
-> Word
-> Calendar
-> Double
-> Currency
-> Schedule
-> GenIborIndex ibor
-> Double
-> BusinessDayConvention
-> Word
-> Calendar
-> Bool
-> Bool
-> Maybe Word
-> Bool
-> Word
-> RateAveragingType
-> IO ConstNotionalCrossCurrencyFixedVsFloatingSwap
constNotionalCrossCurrencyFixedVsFloatingSwapRaw SwapType
a1 Double
a2 Currency
a3 Schedule
a4 Double
a5 DayCounter
a6 BusinessDayConvention
a7 Word
a8 Calendar
a9 Double
a10 Currency
a11 Schedule
a12 GenIborIndex ibor
a13 Double
a14 BusinessDayConvention
a15 Word
a16 Calendar
a17 Bool
a18 Bool
a19 Maybe Word
a20 Bool
a21 Word
a22 RateAveragingType
a23 =
  let {a1' :: CInt
a1' = (Int -> CInt
forall a b. (Integral a, Num b) => a -> b
fromIntegral (Int -> CInt) -> (SwapType -> Int) -> SwapType -> CInt
forall b c a. (b -> c) -> (a -> b) -> a -> c
. SwapType -> Int
forall a. Enum a => a -> Int
fromEnum) SwapType
a1} in 
  let {a2' :: CDouble
a2' = Double -> CDouble
forall a b. (Real a, Fractional b) => a -> b
realToFrac Double
a2} in 
  Currency
-> (Ptr CCurrency
    -> IO ConstNotionalCrossCurrencyFixedVsFloatingSwap)
-> IO ConstNotionalCrossCurrencyFixedVsFloatingSwap
forall b. Currency -> (Ptr CCurrency -> IO b) -> IO b
withCurrency Currency
a3 ((Ptr CCurrency
  -> IO ConstNotionalCrossCurrencyFixedVsFloatingSwap)
 -> IO ConstNotionalCrossCurrencyFixedVsFloatingSwap)
-> (Ptr CCurrency
    -> IO ConstNotionalCrossCurrencyFixedVsFloatingSwap)
-> IO ConstNotionalCrossCurrencyFixedVsFloatingSwap
forall a b. (a -> b) -> a -> b
$ \Ptr CCurrency
a3' -> 
  Schedule
-> (Ptr CSchedule
    -> IO ConstNotionalCrossCurrencyFixedVsFloatingSwap)
-> IO ConstNotionalCrossCurrencyFixedVsFloatingSwap
forall b. Schedule -> (Ptr CSchedule -> IO b) -> IO b
withSchedule Schedule
a4 ((Ptr CSchedule
  -> IO ConstNotionalCrossCurrencyFixedVsFloatingSwap)
 -> IO ConstNotionalCrossCurrencyFixedVsFloatingSwap)
-> (Ptr CSchedule
    -> IO ConstNotionalCrossCurrencyFixedVsFloatingSwap)
-> IO ConstNotionalCrossCurrencyFixedVsFloatingSwap
forall a b. (a -> b) -> a -> b
$ \Ptr CSchedule
a4' -> 
  let {a5' :: CDouble
a5' = Double -> CDouble
forall a b. (Real a, Fractional b) => a -> b
realToFrac Double
a5} in 
  DayCounter
-> (Ptr CDayCounter
    -> IO ConstNotionalCrossCurrencyFixedVsFloatingSwap)
-> IO ConstNotionalCrossCurrencyFixedVsFloatingSwap
forall b. DayCounter -> (Ptr CDayCounter -> IO b) -> IO b
withDayCounter DayCounter
a6 ((Ptr CDayCounter
  -> IO ConstNotionalCrossCurrencyFixedVsFloatingSwap)
 -> IO ConstNotionalCrossCurrencyFixedVsFloatingSwap)
-> (Ptr CDayCounter
    -> IO ConstNotionalCrossCurrencyFixedVsFloatingSwap)
-> IO ConstNotionalCrossCurrencyFixedVsFloatingSwap
forall a b. (a -> b) -> a -> b
$ \Ptr CDayCounter
a6' -> 
  let {a7' :: CInt
a7' = BusinessDayConvention -> CInt
forall a b. (Enum a, Integral b) => a -> b
fromEnumC BusinessDayConvention
a7} in 
  let {a8' :: CUInt
a8' = Word -> CUInt
forall a b. (Integral a, Num b) => a -> b
fromIntegral Word
a8} in 
  Calendar
-> (Ptr CCalendar
    -> IO ConstNotionalCrossCurrencyFixedVsFloatingSwap)
-> IO ConstNotionalCrossCurrencyFixedVsFloatingSwap
forall b. Calendar -> (Ptr CCalendar -> IO b) -> IO b
withCalendar Calendar
a9 ((Ptr CCalendar
  -> IO ConstNotionalCrossCurrencyFixedVsFloatingSwap)
 -> IO ConstNotionalCrossCurrencyFixedVsFloatingSwap)
-> (Ptr CCalendar
    -> IO ConstNotionalCrossCurrencyFixedVsFloatingSwap)
-> IO ConstNotionalCrossCurrencyFixedVsFloatingSwap
forall a b. (a -> b) -> a -> b
$ \Ptr CCalendar
a9' -> 
  let {a10' :: CDouble
a10' = Double -> CDouble
forall a b. (Real a, Fractional b) => a -> b
realToFrac Double
a10} in 
  Currency
-> (Ptr CCurrency
    -> IO ConstNotionalCrossCurrencyFixedVsFloatingSwap)
-> IO ConstNotionalCrossCurrencyFixedVsFloatingSwap
forall b. Currency -> (Ptr CCurrency -> IO b) -> IO b
withCurrency Currency
a11 ((Ptr CCurrency
  -> IO ConstNotionalCrossCurrencyFixedVsFloatingSwap)
 -> IO ConstNotionalCrossCurrencyFixedVsFloatingSwap)
-> (Ptr CCurrency
    -> IO ConstNotionalCrossCurrencyFixedVsFloatingSwap)
-> IO ConstNotionalCrossCurrencyFixedVsFloatingSwap
forall a b. (a -> b) -> a -> b
$ \Ptr CCurrency
a11' -> 
  Schedule
-> (Ptr CSchedule
    -> IO ConstNotionalCrossCurrencyFixedVsFloatingSwap)
-> IO ConstNotionalCrossCurrencyFixedVsFloatingSwap
forall b. Schedule -> (Ptr CSchedule -> IO b) -> IO b
withSchedule Schedule
a12 ((Ptr CSchedule
  -> IO ConstNotionalCrossCurrencyFixedVsFloatingSwap)
 -> IO ConstNotionalCrossCurrencyFixedVsFloatingSwap)
-> (Ptr CSchedule
    -> IO ConstNotionalCrossCurrencyFixedVsFloatingSwap)
-> IO ConstNotionalCrossCurrencyFixedVsFloatingSwap
forall a b. (a -> b) -> a -> b
$ \Ptr CSchedule
a12' -> 
  GenIborIndex ibor
-> (Ptr CIborIndex'
    -> IO ConstNotionalCrossCurrencyFixedVsFloatingSwap)
-> IO ConstNotionalCrossCurrencyFixedVsFloatingSwap
forall ibor b.
GenIborIndex ibor -> (Ptr CIborIndex' -> IO b) -> IO b
withIborIndex GenIborIndex ibor
a13 ((Ptr CIborIndex'
  -> IO ConstNotionalCrossCurrencyFixedVsFloatingSwap)
 -> IO ConstNotionalCrossCurrencyFixedVsFloatingSwap)
-> (Ptr CIborIndex'
    -> IO ConstNotionalCrossCurrencyFixedVsFloatingSwap)
-> IO ConstNotionalCrossCurrencyFixedVsFloatingSwap
forall a b. (a -> b) -> a -> b
$ \Ptr CIborIndex'
a13' -> 
  let {a14' :: CDouble
a14' = Double -> CDouble
forall a b. (Real a, Fractional b) => a -> b
realToFrac Double
a14} in 
  let {a15' :: CInt
a15' = BusinessDayConvention -> CInt
forall a b. (Enum a, Integral b) => a -> b
fromEnumC BusinessDayConvention
a15} in 
  let {a16' :: CUInt
a16' = Word -> CUInt
forall a b. (Integral a, Num b) => a -> b
fromIntegral Word
a16} in 
  Calendar
-> (Ptr CCalendar
    -> IO ConstNotionalCrossCurrencyFixedVsFloatingSwap)
-> IO ConstNotionalCrossCurrencyFixedVsFloatingSwap
forall b. Calendar -> (Ptr CCalendar -> IO b) -> IO b
withCalendar Calendar
a17 ((Ptr CCalendar
  -> IO ConstNotionalCrossCurrencyFixedVsFloatingSwap)
 -> IO ConstNotionalCrossCurrencyFixedVsFloatingSwap)
-> (Ptr CCalendar
    -> IO ConstNotionalCrossCurrencyFixedVsFloatingSwap)
-> IO ConstNotionalCrossCurrencyFixedVsFloatingSwap
forall a b. (a -> b) -> a -> b
$ \Ptr CCalendar
a17' -> 
  let {a18' :: CInt
a18' = Bool -> CInt
forall a. Num a => Bool -> a
C2HSImp.fromBool Bool
a18} in 
  let {a19' :: CInt
a19' = Bool -> CInt
forall a. Num a => Bool -> a
C2HSImp.fromBool Bool
a19} in 
  let {a20' :: CUInt
a20' = Maybe Word -> CUInt
forall a b. (Integral a, Integral b) => Maybe a -> b
fromMaybeInt Maybe Word
a20} in 
  let {a21' :: CInt
a21' = Bool -> CInt
forall a. Num a => Bool -> a
C2HSImp.fromBool Bool
a21} in 
  let {a22' :: CUInt
a22' = Word -> CUInt
forall a b. (Integral a, Num b) => a -> b
fromIntegral Word
a22} in 
  let {a23' :: CInt
a23' = (Int -> CInt
forall a b. (Integral a, Num b) => a -> b
fromIntegral (Int -> CInt)
-> (RateAveragingType -> Int) -> RateAveragingType -> CInt
forall b c a. (b -> c) -> (a -> b) -> a -> c
. RateAveragingType -> Int
forall a. Enum a => a -> Int
fromEnum) RateAveragingType
a23} in 
  (Ptr (Ptr CChar)
 -> IO ConstNotionalCrossCurrencyFixedVsFloatingSwap)
-> IO ConstNotionalCrossCurrencyFixedVsFloatingSwap
forall a b. (Ptr (Ptr a) -> IO b) -> IO b
preErrorCheck ((Ptr (Ptr CChar)
  -> IO ConstNotionalCrossCurrencyFixedVsFloatingSwap)
 -> IO ConstNotionalCrossCurrencyFixedVsFloatingSwap)
-> (Ptr (Ptr CChar)
    -> IO ConstNotionalCrossCurrencyFixedVsFloatingSwap)
-> IO ConstNotionalCrossCurrencyFixedVsFloatingSwap
forall a b. (a -> b) -> a -> b
$ \Ptr (Ptr CChar)
a24' -> 
  CInt
-> CDouble
-> Ptr CCurrency
-> Ptr CSchedule
-> CDouble
-> Ptr CDayCounter
-> CInt
-> CUInt
-> Ptr CCalendar
-> CDouble
-> Ptr CCurrency
-> Ptr CSchedule
-> Ptr CIborIndex'
-> CDouble
-> CInt
-> CUInt
-> Ptr CCalendar
-> CInt
-> CInt
-> CUInt
-> CInt
-> CUInt
-> CInt
-> Ptr (Ptr CChar)
-> IO (Ptr CConstNotionalCrossCurrencyFixedVsFloatingSwap')
constNotionalCrossCurrencyFixedVsFloatingSwapRaw'_ CInt
a1' CDouble
a2' Ptr CCurrency
a3' Ptr CSchedule
a4' CDouble
a5' Ptr CDayCounter
a6' CInt
a7' CUInt
a8' Ptr CCalendar
a9' CDouble
a10' Ptr CCurrency
a11' Ptr CSchedule
a12' Ptr CIborIndex'
a13' CDouble
a14' CInt
a15' CUInt
a16' Ptr CCalendar
a17' CInt
a18' CInt
a19' CUInt
a20' CInt
a21' CUInt
a22' CInt
a23' Ptr (Ptr CChar)
a24' IO (Ptr CConstNotionalCrossCurrencyFixedVsFloatingSwap')
-> (Ptr CConstNotionalCrossCurrencyFixedVsFloatingSwap'
    -> IO ConstNotionalCrossCurrencyFixedVsFloatingSwap)
-> IO ConstNotionalCrossCurrencyFixedVsFloatingSwap
forall a b. IO a -> (a -> IO b) -> IO b
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= \Ptr CConstNotionalCrossCurrencyFixedVsFloatingSwap'
res ->
  Ptr CConstNotionalCrossCurrencyFixedVsFloatingSwap'
-> IO ConstNotionalCrossCurrencyFixedVsFloatingSwap
peekConstNotionalCrossCurrencyFixedVsFloatingSwap Ptr CConstNotionalCrossCurrencyFixedVsFloatingSwap'
res IO ConstNotionalCrossCurrencyFixedVsFloatingSwap
-> (ConstNotionalCrossCurrencyFixedVsFloatingSwap
    -> IO ConstNotionalCrossCurrencyFixedVsFloatingSwap)
-> IO ConstNotionalCrossCurrencyFixedVsFloatingSwap
forall a b. IO a -> (a -> IO b) -> IO b
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= \ConstNotionalCrossCurrencyFixedVsFloatingSwap
res' ->
  Ptr (Ptr CChar) -> IO ()
errorCheck  Ptr (Ptr CChar)
a24'IO ()
-> IO ConstNotionalCrossCurrencyFixedVsFloatingSwap
-> IO ConstNotionalCrossCurrencyFixedVsFloatingSwap
forall a b. IO a -> IO b -> IO b
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>>
  ConstNotionalCrossCurrencyFixedVsFloatingSwap
-> IO ConstNotionalCrossCurrencyFixedVsFloatingSwap
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return (ConstNotionalCrossCurrencyFixedVsFloatingSwap
res')

{-# LINE 745 "./QuantLib/Instrument/Swap.chs" #-}


-- |The fixed rate that would make the swap's NPV zero.
qlConstNotionalCrossCurrencyFixedVsFloatingSwapFairRate :: (ConstNotionalCrossCurrencyFixedVsFloatingSwap) -> IO ((Double))
qlConstNotionalCrossCurrencyFixedVsFloatingSwapFairRate a1 =
  withConstNotionalCrossCurrencyFixedVsFloatingSwap a1 $ \a1' -> 
  preErrorCheck $ \a2' -> 
  qlConstNotionalCrossCurrencyFixedVsFloatingSwapFairRate'_ a1' a2' >>= \res ->
  let {res' = realToFrac res} in
  errorCheck  a2'>>
  return (res')

{-# LINE 748 "./QuantLib/Instrument/Swap.chs" #-}


instance HasFairRate ConstNotionalCrossCurrencyFixedVsFloatingSwap where
  fairRate = qlConstNotionalCrossCurrencyFixedVsFloatingSwapFairRate
instance HasFairSpread ConstNotionalCrossCurrencyFixedVsFloatingSwap where
  fairSpread = qlConstNotionalCrossCurrencyFixedVsFloatingSwapFairSpread
qlConstNotionalCrossCurrencyFixedVsFloatingSwapFairSpread :: (ConstNotionalCrossCurrencyFixedVsFloatingSwap) -> IO ((Double))
qlConstNotionalCrossCurrencyFixedVsFloatingSwapFairSpread a1 =
  withConstNotionalCrossCurrencyFixedVsFloatingSwap a1 $ \a1' -> 
  preErrorCheck $ \a2' -> 
  qlConstNotionalCrossCurrencyFixedVsFloatingSwapFairSpread'_ a1' a2' >>= \res ->
  let {res' = realToFrac res} in
  errorCheck  a2'>>
  return (res')

{-# LINE 754 "./QuantLib/Instrument/Swap.chs" #-}


-- |An option on a 'VanillaSwap'.
swaption :: (GenFixedVsFloatingSwap f) -> (Exercise) -> (SettlementType) -> (SettlementMethod) -> IO ((Swaption))
swaption a1 a2 a3 a4 =
  withFixedVsFloatingSwap a1 $ \a1' -> 
  withExercise a2 $ \a2' -> 
  let {a3' = (fromIntegral . fromEnum) a3} in 
  let {a4' = (fromIntegral . fromEnum) a4} in 
  preErrorCheck $ \a5' -> 
  swaption'_ a1' a2' a3' a4' a5' >>= \res ->
  peekSwaption res >>= \res' ->
  errorCheck  a5'>>
  return (res')

{-# LINE 757 "./QuantLib/Instrument/Swap.chs" #-}


-- |A priceable option on an 'IrregularSwap'.  Use 'haganIrregularSwaptionEngine'
-- as its pricing engine; QuantLib has no corresponding stock IrregularSwap engine.
irregularSwaption :: (IrregularSwap) -> (Exercise) -> (IrregularSettlementType) -> IO ((IrregularSwaption))
irregularSwaption a1 a2 a3 =
  withIrregularSwap a1 $ \a1' -> 
  withExercise a2 $ \a2' -> 
  let {a3' = fromEnumC a3} in 
  preErrorCheck $ \a4' -> 
  irregularSwaption'_ a1' a2' a3' a4' >>= \res ->
  peekIrregularSwaption res >>= \res' ->
  errorCheck  a4'>>
  return (res')

{-# LINE 761 "./QuantLib/Instrument/Swap.chs" #-}

irregularSwap :: (SwapType) -> (GenLeg fixed) -> (GenLeg float) -> IO ((IrregularSwap))
irregularSwap a1 a2 a3 =
  let {a1' = (fromIntegral . fromEnum) a1} in 
  withLeg a2 $ \a2' -> 
  withLeg a3 $ \a3' -> 
  preErrorCheck $ \a4' -> 
  irregularSwap'_ a1' a2' a3' a4' >>= \res ->
  peekIrregularSwap res >>= \res' ->
  errorCheck  a4'>>
  return (res')

{-# LINE 762 "./QuantLib/Instrument/Swap.chs" #-}

qlIrregularSwapFairRate :: (IrregularSwap) -> IO ((Double))
qlIrregularSwapFairRate a1 =
  withIrregularSwap a1 $ \a1' -> 
  preErrorCheck $ \a2' -> 
  qlIrregularSwapFairRate'_ a1' a2' >>= \res ->
  let {res' = realToFrac res} in
  errorCheck  a2'>>
  return (res')

{-# LINE 763 "./QuantLib/Instrument/Swap.chs" #-}

qlIrregularSwapFairSpread :: (IrregularSwap) -> IO ((Double))
qlIrregularSwapFairSpread a1 =
  withIrregularSwap a1 $ \a1' -> 
  preErrorCheck $ \a2' -> 
  qlIrregularSwapFairSpread'_ a1' a2' >>= \res ->
  let {res' = realToFrac res} in
  errorCheck  a2'>>
  return (res')

{-# LINE 764 "./QuantLib/Instrument/Swap.chs" #-}


-- |Converts an existing 'Swaption' into a 'NonstandardSwaption' (upstream's own conversion
-- constructor).
nonstandardSwaptionFromSwaption :: (Swaption) -> IO ((NonstandardSwaption))
nonstandardSwaptionFromSwaption a1 =
  withSwaption a1 $ \a1' -> 
  preErrorCheck $ \a2' -> 
  nonstandardSwaptionFromSwaption'_ a1' a2' >>= \res ->
  peekNonstandardSwaption res >>= \res' ->
  errorCheck  a2'>>
  return (res')

{-# LINE 769 "./QuantLib/Instrument/Swap.chs" #-}


-- |An option on a 'NonstandardSwap'.
nonstandardSwaption :: (NonstandardSwap) -> (Exercise) -> (SettlementType) -> (SettlementMethod) -> IO ((NonstandardSwaption))
nonstandardSwaption a1 a2 a3 a4 =
  withNonstandardSwap a1 $ \a1' -> 
  withExercise a2 $ \a2' -> 
  let {a3' = (fromIntegral . fromEnum) a3} in 
  let {a4' = (fromIntegral . fromEnum) a4} in 
  preErrorCheck $ \a5' -> 
  nonstandardSwaption'_ a1' a2' a3' a4' a5' >>= \res ->
  peekNonstandardSwaption res >>= \res' ->
  errorCheck  a5'>>
  return (res')

{-# LINE 772 "./QuantLib/Instrument/Swap.chs" #-}


-- |Auto-generates a basket of plain 'Swaption's used to calibrate a model to price a
-- 'NonstandardSwaption' -- either ATM swaptions adapted to the exercise dates ('Naive') or
-- swaptions whose maturity\/strike\/nominal match the underlying's NPV, delta and gamma at each
-- exercise date ('MaturityStrikeByDeltaGamma').
calibrationBasket :: (NonstandardSwaption) -> (GenSwapIndex sidx) -- ^standardSwapBase
 -> (GenSwaptionVolatilityStructure sv) -- ^swaptionVolatility
 -> (CalibrationBasketType) -> IO (([BlackCalibrationHelper]))
calibrationBasket a1 a2 a3 a4 =
  withNonstandardSwaption a1 $ \a1' -> 
  withSwapIndex a2 $ \a2' -> 
  withSwaptionVolatilityStructure a3 $ \a3' -> 
  let {a4' = fromEnumC a4} in 
  preArray $ \(a5'1, a5'2) -> 
  preErrorCheck $ \a6' -> 
  calibrationBasket'_ a1' a2' a3' a4' a5'1  a5'2 a6' >>
  peekBlackCalibrationHelperArray  a5'1  a5'2>>= \a5'' -> 
  errorCheck  a6'>>
  return (a5'')

{-# LINE 783 "./QuantLib/Instrument/Swap.chs" #-}


-- |An option on a 'FloatFloatSwap'.
floatFloatSwaption :: (FloatFloatSwap) -> (Exercise) -> (SettlementType) -> (SettlementMethod) -> IO ((FloatFloatSwaption))
floatFloatSwaption a1 a2 a3 a4 =
  withFloatFloatSwap a1 $ \a1' -> 
  withExercise a2 $ \a2' -> 
  let {a3' = (fromIntegral . fromEnum) a3} in 
  let {a4' = (fromIntegral . fromEnum) a4} in 
  preErrorCheck $ \a5' -> 
  floatFloatSwaption'_ a1' a2' a3' a4' a5' >>= \res ->
  peekFloatFloatSwaption res >>= \res' ->
  errorCheck  a5'>>
  return (res')

{-# LINE 786 "./QuantLib/Instrument/Swap.chs" #-}


-- |As 'calibrationBasket', for a 'FloatFloatSwaption'.
floatFloatSwaptionCalibrationBasket :: (FloatFloatSwaption) -> (GenSwapIndex sidx) -- ^standardSwapBase
 -> (GenSwaptionVolatilityStructure sv) -- ^swaptionVolatility
 -> (CalibrationBasketType) -> IO (([BlackCalibrationHelper]))
floatFloatSwaptionCalibrationBasket a1 a2 a3 a4 =
  withFloatFloatSwaption a1 $ \a1' -> 
  withSwapIndex a2 $ \a2' -> 
  withSwaptionVolatilityStructure a3 $ \a3' -> 
  let {a4' = fromEnumC a4} in 
  preArray $ \(a5'1, a5'2) -> 
  preErrorCheck $ \a6' -> 
  floatFloatSwaptionCalibrationBasket'_ a1' a2' a3' a4' a5'1  a5'2 a6' >>
  peekBlackCalibrationHelperArray  a5'1  a5'2>>= \a5'' -> 
  errorCheck  a6'>>
  return (a5'')

{-# LINE 794 "./QuantLib/Instrument/Swap.chs" #-}


-- |Bullet bond vs Libor swap (par or market asset swap, per /parAssetSwap/).
assetSwap :: (Bool) -- ^payBondCoupon
 -> (Bond) -> (Double) -- ^bondCleanPrice
 -> (GenIborIndex ibor) -> (Double) -- spread
 -> (Schedule) -- ^floatSchedule
 -> (DayCounter) -- ^floatingDayCount
 -> (Bool) -- ^parAssetSwap
 -> (Double) -- ^gearing
 -> (Maybe Double) -- ^nonParRepayment
 -> (Maybe Day) -- ^dealMaturity
 -> IO ((AssetSwap))
assetSwap :: forall ibor.
Bool
-> Bond
-> Double
-> GenIborIndex ibor
-> Double
-> Schedule
-> DayCounter
-> Bool
-> Double
-> Maybe Double
-> Maybe Day
-> IO AssetSwap
assetSwap Bool
a1 Bond
a2 Double
a3 GenIborIndex ibor
a4 Double
a5 Schedule
a6 DayCounter
a7 Bool
a8 Double
a9 Maybe Double
a10 Maybe Day
a11 =
  let {a1' :: CInt
a1' = Bool -> CInt
forall a. Num a => Bool -> a
C2HSImp.fromBool Bool
a1} in 
  Bond -> (Ptr CBond' -> IO AssetSwap) -> IO AssetSwap
forall b r. GenBond b -> (Ptr CBond' -> IO r) -> IO r
withBond Bond
a2 ((Ptr CBond' -> IO AssetSwap) -> IO AssetSwap)
-> (Ptr CBond' -> IO AssetSwap) -> IO AssetSwap
forall a b. (a -> b) -> a -> b
$ \Ptr CBond'
a2' -> 
  let {a3' :: CDouble
a3' = Double -> CDouble
forall a b. (Real a, Fractional b) => a -> b
realToFrac Double
a3} in 
  GenIborIndex ibor
-> (Ptr CIborIndex' -> IO AssetSwap) -> IO AssetSwap
forall ibor b.
GenIborIndex ibor -> (Ptr CIborIndex' -> IO b) -> IO b
withIborIndex GenIborIndex ibor
a4 ((Ptr CIborIndex' -> IO AssetSwap) -> IO AssetSwap)
-> (Ptr CIborIndex' -> IO AssetSwap) -> IO AssetSwap
forall a b. (a -> b) -> a -> b
$ \Ptr CIborIndex'
a4' -> 
  let {a5' :: CDouble
a5' = Double -> CDouble
forall a b. (Real a, Fractional b) => a -> b
realToFrac Double
a5} in 
  Schedule -> (Ptr CSchedule -> IO AssetSwap) -> IO AssetSwap
forall b. Schedule -> (Ptr CSchedule -> IO b) -> IO b
withSchedule Schedule
a6 ((Ptr CSchedule -> IO AssetSwap) -> IO AssetSwap)
-> (Ptr CSchedule -> IO AssetSwap) -> IO AssetSwap
forall a b. (a -> b) -> a -> b
$ \Ptr CSchedule
a6' -> 
  DayCounter -> (Ptr CDayCounter -> IO AssetSwap) -> IO AssetSwap
forall b. DayCounter -> (Ptr CDayCounter -> IO b) -> IO b
withDayCounter DayCounter
a7 ((Ptr CDayCounter -> IO AssetSwap) -> IO AssetSwap)
-> (Ptr CDayCounter -> IO AssetSwap) -> IO AssetSwap
forall a b. (a -> b) -> a -> b
$ \Ptr CDayCounter
a7' -> 
  let {a8' :: CInt
a8' = Bool -> CInt
forall a. Num a => Bool -> a
C2HSImp.fromBool Bool
a8} in 
  let {a9' :: CDouble
a9' = Double -> CDouble
forall a b. (Real a, Fractional b) => a -> b
realToFrac Double
a9} in 
  let {a10' :: CDouble
a10' = Maybe Double -> CDouble
fromMaybeDouble Maybe Double
a10} in 
  Maybe Day -> (CInt -> IO AssetSwap) -> IO AssetSwap
forall a. Maybe Day -> (CInt -> IO a) -> IO a
withMaybeDay Maybe Day
a11 ((CInt -> IO AssetSwap) -> IO AssetSwap)
-> (CInt -> IO AssetSwap) -> IO AssetSwap
forall a b. (a -> b) -> a -> b
$ \CInt
a11' -> 
  (Ptr (Ptr CChar) -> IO AssetSwap) -> IO AssetSwap
forall a b. (Ptr (Ptr a) -> IO b) -> IO b
preErrorCheck ((Ptr (Ptr CChar) -> IO AssetSwap) -> IO AssetSwap)
-> (Ptr (Ptr CChar) -> IO AssetSwap) -> IO AssetSwap
forall a b. (a -> b) -> a -> b
$ \Ptr (Ptr CChar)
a12' -> 
  CInt
-> Ptr CBond'
-> CDouble
-> Ptr CIborIndex'
-> CDouble
-> Ptr CSchedule
-> Ptr CDayCounter
-> CInt
-> CDouble
-> CDouble
-> CInt
-> Ptr (Ptr CChar)
-> IO (Ptr CAssetSwap')
assetSwap'_ CInt
a1' Ptr CBond'
a2' CDouble
a3' Ptr CIborIndex'
a4' CDouble
a5' Ptr CSchedule
a6' Ptr CDayCounter
a7' CInt
a8' CDouble
a9' CDouble
a10' CInt
a11' Ptr (Ptr CChar)
a12' IO (Ptr CAssetSwap')
-> (Ptr CAssetSwap' -> IO AssetSwap) -> IO AssetSwap
forall a b. IO a -> (a -> IO b) -> IO b
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= \Ptr CAssetSwap'
res ->
  Ptr CAssetSwap' -> IO AssetSwap
peekAssetSwap Ptr CAssetSwap'
res IO AssetSwap -> (AssetSwap -> IO AssetSwap) -> IO AssetSwap
forall a b. IO a -> (a -> IO b) -> IO b
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= \AssetSwap
res' ->
  Ptr (Ptr CChar) -> IO ()
errorCheck  Ptr (Ptr CChar)
a12'IO () -> IO AssetSwap -> IO AssetSwap
forall a b. IO a -> IO b -> IO b
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>>
  AssetSwap -> IO AssetSwap
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return (AssetSwap
res')

{-# LINE 806 "./QuantLib/Instrument/Swap.chs" #-}


-- |Fixed vs compounded-overnight-rate swap, with a single flat nominal for both legs.
overnightIndexedSwap :: SwapType
  -> Double -- ^nominal
  -> Schedule
  -> Double -- ^fixedRate
  -> DayCounter -- ^fixedDC
  -> OvernightIborIndex
  -> Double -- ^spread
  -> Int -- ^paymentLag
  -> BusinessDayConvention -- ^paymentAdjustment
  -> Calendar -- ^paymentCalendar
  -> Bool -- ^telescopicValueDates
  -> RateAveragingType -- ^averagingMethod
  -> OvernightObservation
  -> IO OvernightIndexedSwap
overnightIndexedSwap t n sch r dc idx sprd lag adj cal telescopic avg obs =
  overnightIndexedSwapRaw t n sch r dc idx sprd lag adj cal telescopic avg
    (lookbackDays obs) (lockoutDays obs) (applyObservationShift obs)

overnightIndexedSwapRaw :: (SwapType) -> (Double) -- ^nominal
 -> (Schedule) -> (Double) -- ^fixedRate
 -> (DayCounter) -- ^fixedDC
 -> (OvernightIborIndex) -> (Double) -- ^spread
 -> (Int) -- ^paymentLag
 -> (BusinessDayConvention) -- ^paymentAdjustment
 -> (Calendar) -- ^paymentCalendar
 -> (Bool) -- ^telescopicValueDates
 -> (RateAveragingType) -- ^averagingMethod
 -> (Maybe Word) -- ^lookbackDays
 -> (Word) -- ^lockoutDays
 -> (Bool) -- ^applyObservationShift
 -> IO ((OvernightIndexedSwap))
overnightIndexedSwapRaw :: SwapType
-> Double
-> Schedule
-> Double
-> DayCounter
-> OvernightIborIndex
-> Double
-> Int
-> BusinessDayConvention
-> Calendar
-> Bool
-> RateAveragingType
-> Maybe Word
-> Word
-> Bool
-> IO OvernightIndexedSwap
overnightIndexedSwapRaw SwapType
a1 Double
a2 Schedule
a3 Double
a4 DayCounter
a5 OvernightIborIndex
a6 Double
a7 Int
a8 BusinessDayConvention
a9 Calendar
a10 Bool
a11 RateAveragingType
a12 Maybe Word
a13 Word
a14 Bool
a15 =
  let {a1' :: CInt
a1' = (Int -> CInt
forall a b. (Integral a, Num b) => a -> b
fromIntegral (Int -> CInt) -> (SwapType -> Int) -> SwapType -> CInt
forall b c a. (b -> c) -> (a -> b) -> a -> c
. SwapType -> Int
forall a. Enum a => a -> Int
fromEnum) SwapType
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 OvernightIndexedSwap)
-> IO OvernightIndexedSwap
forall b. Schedule -> (Ptr CSchedule -> IO b) -> IO b
withSchedule Schedule
a3 ((Ptr CSchedule -> IO OvernightIndexedSwap)
 -> IO OvernightIndexedSwap)
-> (Ptr CSchedule -> IO OvernightIndexedSwap)
-> IO OvernightIndexedSwap
forall a b. (a -> b) -> a -> b
$ \Ptr CSchedule
a3' -> 
  let {a4' :: CDouble
a4' = Double -> CDouble
forall a b. (Real a, Fractional b) => a -> b
realToFrac Double
a4} in 
  DayCounter
-> (Ptr CDayCounter -> IO OvernightIndexedSwap)
-> IO OvernightIndexedSwap
forall b. DayCounter -> (Ptr CDayCounter -> IO b) -> IO b
withDayCounter DayCounter
a5 ((Ptr CDayCounter -> IO OvernightIndexedSwap)
 -> IO OvernightIndexedSwap)
-> (Ptr CDayCounter -> IO OvernightIndexedSwap)
-> IO OvernightIndexedSwap
forall a b. (a -> b) -> a -> b
$ \Ptr CDayCounter
a5' -> 
  OvernightIborIndex
-> (Ptr COvernightIndex' -> IO OvernightIndexedSwap)
-> IO OvernightIndexedSwap
forall b.
OvernightIborIndex -> (Ptr COvernightIndex' -> IO b) -> IO b
withOvernightIborIndex OvernightIborIndex
a6 ((Ptr COvernightIndex' -> IO OvernightIndexedSwap)
 -> IO OvernightIndexedSwap)
-> (Ptr COvernightIndex' -> IO OvernightIndexedSwap)
-> IO OvernightIndexedSwap
forall a b. (a -> b) -> a -> b
$ \Ptr COvernightIndex'
a6' -> 
  let {a7' :: CDouble
a7' = Double -> CDouble
forall a b. (Real a, Fractional b) => a -> b
realToFrac Double
a7} in 
  let {a8' :: CInt
a8' = Int -> CInt
forall a b. (Integral a, Num b) => a -> b
fromIntegral Int
a8} in 
  let {a9' :: CInt
a9' = BusinessDayConvention -> CInt
forall a b. (Enum a, Integral b) => a -> b
fromEnumC BusinessDayConvention
a9} in 
  Calendar
-> (Ptr CCalendar -> IO OvernightIndexedSwap)
-> IO OvernightIndexedSwap
forall b. Calendar -> (Ptr CCalendar -> IO b) -> IO b
withCalendar Calendar
a10 ((Ptr CCalendar -> IO OvernightIndexedSwap)
 -> IO OvernightIndexedSwap)
-> (Ptr CCalendar -> IO OvernightIndexedSwap)
-> IO OvernightIndexedSwap
forall a b. (a -> b) -> a -> b
$ \Ptr CCalendar
a10' -> 
  let {a11' :: CInt
a11' = Bool -> CInt
forall a. Num a => Bool -> a
C2HSImp.fromBool Bool
a11} in 
  let {a12' :: CInt
a12' = (Int -> CInt
forall a b. (Integral a, Num b) => a -> b
fromIntegral (Int -> CInt)
-> (RateAveragingType -> Int) -> RateAveragingType -> CInt
forall b c a. (b -> c) -> (a -> b) -> a -> c
. RateAveragingType -> Int
forall a. Enum a => a -> Int
fromEnum) RateAveragingType
a12} in 
  let {a13' :: CUInt
a13' = Maybe Word -> CUInt
forall a b. (Integral a, Integral b) => Maybe a -> b
fromMaybeInt Maybe Word
a13} in 
  let {a14' :: CUInt
a14' = Word -> CUInt
forall a b. (Integral a, Num b) => a -> b
fromIntegral Word
a14} in 
  let {a15' :: CInt
a15' = Bool -> CInt
forall a. Num a => Bool -> a
C2HSImp.fromBool Bool
a15} in 
  (Ptr (Ptr CChar) -> IO OvernightIndexedSwap)
-> IO OvernightIndexedSwap
forall a b. (Ptr (Ptr a) -> IO b) -> IO b
preErrorCheck ((Ptr (Ptr CChar) -> IO OvernightIndexedSwap)
 -> IO OvernightIndexedSwap)
-> (Ptr (Ptr CChar) -> IO OvernightIndexedSwap)
-> IO OvernightIndexedSwap
forall a b. (a -> b) -> a -> b
$ \Ptr (Ptr CChar)
a16' -> 
  CInt
-> CDouble
-> Ptr CSchedule
-> CDouble
-> Ptr CDayCounter
-> Ptr COvernightIndex'
-> CDouble
-> CInt
-> CInt
-> Ptr CCalendar
-> CInt
-> CInt
-> CUInt
-> CUInt
-> CInt
-> Ptr (Ptr CChar)
-> IO (Ptr COvernightIndexedSwap')
overnightIndexedSwapRaw'_ CInt
a1' CDouble
a2' Ptr CSchedule
a3' CDouble
a4' Ptr CDayCounter
a5' Ptr COvernightIndex'
a6' CDouble
a7' CInt
a8' CInt
a9' Ptr CCalendar
a10' CInt
a11' CInt
a12' CUInt
a13' CUInt
a14' CInt
a15' Ptr (Ptr CChar)
a16' IO (Ptr COvernightIndexedSwap')
-> (Ptr COvernightIndexedSwap' -> IO OvernightIndexedSwap)
-> IO OvernightIndexedSwap
forall a b. IO a -> (a -> IO b) -> IO b
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= \Ptr COvernightIndexedSwap'
res ->
  Ptr COvernightIndexedSwap' -> IO OvernightIndexedSwap
peekOvernightIndexedSwap Ptr COvernightIndexedSwap'
res IO OvernightIndexedSwap
-> (OvernightIndexedSwap -> IO OvernightIndexedSwap)
-> IO OvernightIndexedSwap
forall a b. IO a -> (a -> IO b) -> IO b
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= \OvernightIndexedSwap
res' ->
  Ptr (Ptr CChar) -> IO ()
errorCheck  Ptr (Ptr CChar)
a16'IO () -> IO OvernightIndexedSwap -> IO OvernightIndexedSwap
forall a b. IO a -> IO b -> IO b
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>>
  OvernightIndexedSwap -> IO OvernightIndexedSwap
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return (OvernightIndexedSwap
res')

{-# LINE 839 "./QuantLib/Instrument/Swap.chs" #-}


-- |As 'overnightIndexedSwap', but with a per-period nominal schedule instead of a single flat nominal.
overnightIndexedSwapFromNominals :: SwapType
  -> [Double] -- ^nominals
  -> Schedule
  -> Double -- ^fixedRate
  -> DayCounter -- ^fixedDC
  -> OvernightIborIndex
  -> Double -- ^spread
  -> Int -- ^paymentLag
  -> BusinessDayConvention -- ^paymentAdjustment
  -> Calendar -- ^paymentCalendar
  -> Bool -- ^telescopicValueDates
  -> RateAveragingType -- ^averagingMethod
  -> OvernightObservation
  -> IO OvernightIndexedSwap
overnightIndexedSwapFromNominals t ns sch r dc idx sprd lag adj cal telescopic avg obs =
  overnightIndexedSwapFromNominalsRaw t ns sch r dc idx sprd lag adj cal telescopic avg
    (lookbackDays obs) (lockoutDays obs) (applyObservationShift obs)

overnightIndexedSwapFromNominalsRaw :: (SwapType) -> ([Double]) -- ^nominals
 -> (Schedule) -- ^schedule
 -> (Double) -- ^fixedRate
 -> (DayCounter) -- ^fixedDC
 -> (OvernightIborIndex) -> (Double) -- ^spread
 -> (Int) -- ^paymentLag
 -> (BusinessDayConvention) -- ^paymentAdjustment
 -> (Calendar) -- ^paymentCalendar
 -> (Bool) -- ^telescopicValueDates
 -> (RateAveragingType) -- ^averagingMethod
 -> (Maybe Word) -- ^lookbackDays
 -> (Word) -- ^lockoutDays
 -> (Bool) -- ^applyObservationShift
 -> IO ((OvernightIndexedSwap))
overnightIndexedSwapFromNominalsRaw :: SwapType
-> [Double]
-> Schedule
-> Double
-> DayCounter
-> OvernightIborIndex
-> Double
-> Int
-> BusinessDayConvention
-> Calendar
-> Bool
-> RateAveragingType
-> Maybe Word
-> Word
-> Bool
-> IO OvernightIndexedSwap
overnightIndexedSwapFromNominalsRaw SwapType
a1 [Double]
a2 Schedule
a3 Double
a4 DayCounter
a5 OvernightIborIndex
a6 Double
a7 Int
a8 BusinessDayConvention
a9 Calendar
a10 Bool
a11 RateAveragingType
a12 Maybe Word
a13 Word
a14 Bool
a15 =
  let {a1' :: CInt
a1' = (Int -> CInt
forall a b. (Integral a, Num b) => a -> b
fromIntegral (Int -> CInt) -> (SwapType -> Int) -> SwapType -> CInt
forall b c a. (b -> c) -> (a -> b) -> a -> c
. SwapType -> Int
forall a. Enum a => a -> Int
fromEnum) SwapType
a1} in 
  [Double]
-> ((CUInt, Ptr CDouble) -> IO OvernightIndexedSwap)
-> IO OvernightIndexedSwap
forall b. [Double] -> ((CUInt, Ptr CDouble) -> IO b) -> IO b
withDoubleArray [Double]
a2 (((CUInt, Ptr CDouble) -> IO OvernightIndexedSwap)
 -> IO OvernightIndexedSwap)
-> ((CUInt, Ptr CDouble) -> IO OvernightIndexedSwap)
-> IO OvernightIndexedSwap
forall a b. (a -> b) -> a -> b
$ \(CUInt
a2'1, Ptr CDouble
a2'2) -> 
  Schedule
-> (Ptr CSchedule -> IO OvernightIndexedSwap)
-> IO OvernightIndexedSwap
forall b. Schedule -> (Ptr CSchedule -> IO b) -> IO b
withSchedule Schedule
a3 ((Ptr CSchedule -> IO OvernightIndexedSwap)
 -> IO OvernightIndexedSwap)
-> (Ptr CSchedule -> IO OvernightIndexedSwap)
-> IO OvernightIndexedSwap
forall a b. (a -> b) -> a -> b
$ \Ptr CSchedule
a3' -> 
  let {a4' :: CDouble
a4' = Double -> CDouble
forall a b. (Real a, Fractional b) => a -> b
realToFrac a4} in 
  withDayCounter a5 $ \a5' -> 
  withOvernightIborIndex a6 $ \a6' -> 
  let {a7' = realToFrac a7} in 
  let {a8' = fromIntegral a8} in 
  let {a9' = fromEnumC a9} in 
  withCalendar a10 $ \a10' -> 
  let {a11' = C2HSImp.fromBool a11} in 
  let {a12' = (fromIntegral . fromEnum) a12} in 
  let {a13' = fromMaybeInt a13} in 
  let {a14' = fromIntegral a14} in 
  let {a15' = C2HSImp.fromBool a15} in 
  preErrorCheck $ \a16' -> 
  overnightIndexedSwapFromNominalsRaw'_ a1' a2'1  a2'2 a3' a4' a5' a6' a7' a8' a9' a10' a11' a12' a13' a14' a15' a16' >>= \res ->
  peekOvernightIndexedSwap res >>= \res' ->
  errorCheck  a16'>>
  return (res')

{-# LINE 873 "./QuantLib/Instrument/Swap.chs" #-}


-- |The swap's maturity date, or 'Nothing' if the swap has no legs.
maturityDate :: (GenSwap s) -> IO (((Maybe Day)))
maturityDate a1 =
  withSwap a1 $ \a1' -> 
  preErrorCheck $ \a2' -> 
  maturityDate'_ a1' a2' >>= \res ->
  let {res' = toMaybeDay res} in
  errorCheck  a2'>>
  return (res')

{-# LINE 876 "./QuantLib/Instrument/Swap.chs" #-}


-- |The swap's start date, or 'Nothing' if the swap has no legs.
startDate :: (GenSwap s) -> IO (((Maybe Day)))
startDate a1 =
  withSwap a1 $ \a1' -> 
  preErrorCheck $ \a2' -> 
  startDate'_ a1' a2' >>= \res ->
  let {res' = toMaybeDay res} in
  errorCheck  a2'>>
  return (res')

{-# LINE 879 "./QuantLib/Instrument/Swap.chs" #-}


-- |Discount factor at the instrument's NPV date.
npvDateDiscount :: (GenSwap s) -> IO ((Double))
npvDateDiscount a1 =
  withSwap a1 $ \a1' -> 
  preErrorCheck $ \a2' -> 
  npvDateDiscount'_ a1' a2' >>= \res ->
  let {res' = realToFrac res} in
  errorCheck  a2'>>
  return (res')

{-# LINE 882 "./QuantLib/Instrument/Swap.chs" #-}


-- |The BMA leg's cash flows.
bmaLeg :: (BMASwap) -> IO ((Leg))
bmaLeg a1 =
  withBMASwap a1 $ \a1' -> 
  preErrorCheck $ \a2' -> 
  bmaLeg'_ a1' a2' >>= \res ->
  peekLeg res >>= \res' ->
  errorCheck  a2'>>
  return (res')

{-# LINE 885 "./QuantLib/Instrument/Swap.chs" #-}


-- |Basis-point sensitivity of the BMA leg.
bmaLegBps :: (BMASwap) -> IO ((Double))
bmaLegBps a1 =
  withBMASwap a1 $ \a1' -> 
  preErrorCheck $ \a2' -> 
  bmaLegBps'_ a1' a2' >>= \res ->
  let {res' = realToFrac res} in
  errorCheck  a2'>>
  return (res')

{-# LINE 888 "./QuantLib/Instrument/Swap.chs" #-}


-- |NPV of the BMA leg.
bmaLegNpv :: (BMASwap) -> IO ((Double))
bmaLegNpv a1 =
  withBMASwap a1 $ \a1' -> 
  preErrorCheck $ \a2' -> 
  bmaLegNpv'_ a1' a2' >>= \res ->
  let {res' = realToFrac res} in
  errorCheck  a2'>>
  return (res')

{-# LINE 891 "./QuantLib/Instrument/Swap.chs" #-}


-- |The Libor fraction that would make the swap's NPV zero.
fairLiborFraction :: (BMASwap) -> IO ((Double))
fairLiborFraction a1 =
  withBMASwap a1 $ \a1' -> 
  preErrorCheck $ \a2' -> 
  fairLiborFraction'_ a1' a2' >>= \res ->
  let {res' = realToFrac res} in
  errorCheck  a2'>>
  return (res')

{-# LINE 894 "./QuantLib/Instrument/Swap.chs" #-}


-- |The Libor spread that would make the swap's NPV zero.
fairLiborSpread :: (BMASwap) -> IO ((Double))
fairLiborSpread a1 =
  withBMASwap a1 $ \a1' -> 
  preErrorCheck $ \a2' -> 
  fairLiborSpread'_ a1' a2' >>= \res ->
  let {res' = realToFrac res} in
  errorCheck  a2'>>
  return (res')

{-# LINE 897 "./QuantLib/Instrument/Swap.chs" #-}


-- |The fraction of the Libor rate paid on the Libor leg.
liborFraction :: (BMASwap) -> IO ((Double))
liborFraction a1 =
  withBMASwap a1 $ \a1' -> 
  preErrorCheck $ \a2' -> 
  liborFraction'_ a1' a2' >>= \res ->
  let {res' = realToFrac res} in
  errorCheck  a2'>>
  return (res')

{-# LINE 900 "./QuantLib/Instrument/Swap.chs" #-}


-- |The Libor leg's cash flows.
liborLeg :: (BMASwap) -> IO ((Leg))
liborLeg a1 =
  withBMASwap a1 $ \a1' -> 
  preErrorCheck $ \a2' -> 
  liborLeg'_ a1' a2' >>= \res ->
  peekLeg res >>= \res' ->
  errorCheck  a2'>>
  return (res')

{-# LINE 903 "./QuantLib/Instrument/Swap.chs" #-}


-- |Basis-point sensitivity of the Libor leg.
liborLegBps :: (BMASwap) -> IO ((Double))
liborLegBps a1 =
  withBMASwap a1 $ \a1' -> 
  preErrorCheck $ \a2' -> 
  liborLegBps'_ a1' a2' >>= \res ->
  let {res' = realToFrac res} in
  errorCheck  a2'>>
  return (res')

{-# LINE 906 "./QuantLib/Instrument/Swap.chs" #-}


-- |NPV of the Libor leg.
liborLegNpv :: (BMASwap) -> IO ((Double))
liborLegNpv a1 =
  withBMASwap a1 $ \a1' -> 
  preErrorCheck $ \a2' -> 
  liborLegNpv'_ a1' a2' >>= \res ->
  let {res' = realToFrac res} in
  errorCheck  a2'>>
  return (res')

{-# LINE 909 "./QuantLib/Instrument/Swap.chs" #-}


-- |The underlying bond's cash flows.
bondLeg :: (AssetSwap) -> IO ((Leg))
bondLeg a1 =
  withAssetSwap a1 $ \a1' -> 
  preErrorCheck $ \a2' -> 
  bondLeg'_ a1' a2' >>= \res ->
  peekLeg res >>= \res' ->
  errorCheck  a2'>>
  return (res')

{-# LINE 912 "./QuantLib/Instrument/Swap.chs" #-}


-- |The bond's clean price, as passed to the constructor.
cleanPrice :: (AssetSwap) -> IO ((Double))
cleanPrice a1 =
  withAssetSwap a1 $ \a1' -> 
  preErrorCheck $ \a2' -> 
  cleanPrice'_ a1' a2' >>= \res ->
  let {res' = realToFrac res} in
  errorCheck  a2'>>
  return (res')

{-# LINE 915 "./QuantLib/Instrument/Swap.chs" #-}


-- |The clean price that would make the swap's NPV zero.
fairCleanPrice :: (AssetSwap) -> IO ((Double))
fairCleanPrice a1 =
  withAssetSwap a1 $ \a1' -> 
  preErrorCheck $ \a2' -> 
  fairCleanPrice'_ a1' a2' >>= \res ->
  let {res' = realToFrac res} in
  errorCheck  a2'>>
  return (res')

{-# LINE 918 "./QuantLib/Instrument/Swap.chs" #-}


-- |The non-par repayment that would make the swap's NPV zero.
fairNonParRepayment :: (AssetSwap) -> IO ((Double))
fairNonParRepayment a1 =
  withAssetSwap a1 $ \a1' -> 
  preErrorCheck $ \a2' -> 
  fairNonParRepayment'_ a1' a2' >>= \res ->
  let {res' = realToFrac res} in
  errorCheck  a2'>>
  return (res')

{-# LINE 921 "./QuantLib/Instrument/Swap.chs" #-}


-- |The non-par repayment, as passed to the constructor.
nonParRepayment :: (AssetSwap) -> IO ((Double))
nonParRepayment a1 =
  withAssetSwap a1 $ \a1' -> 
  preErrorCheck $ \a2' -> 
  nonParRepayment'_ a1' a2' >>= \res ->
  let {res' = realToFrac res} in
  errorCheck  a2'>>
  return (res')

{-# LINE 924 "./QuantLib/Instrument/Swap.chs" #-}


-- |Whether this is a par asset swap.
parSwap :: (AssetSwap) -> IO ((Bool))
parSwap a1 =
  withAssetSwap a1 $ \a1' -> 
  preErrorCheck $ \a2' -> 
  parSwap'_ a1' a2' >>= \res ->
  let {res' = C2HSImp.toBool res} in
  errorCheck  a2'>>
  return (res')

{-# LINE 927 "./QuantLib/Instrument/Swap.chs" #-}


-- |Whether the bond coupon is paid (rather than netted against the floating leg).
payBondCoupon :: (AssetSwap) -> IO ((Bool))
payBondCoupon a1 =
  withAssetSwap a1 $ \a1' -> 
  preErrorCheck $ \a2' -> 
  payBondCoupon'_ a1' a2' >>= \res ->
  let {res' = C2HSImp.toBool res} in
  errorCheck  a2'>>
  return (res')

{-# LINE 930 "./QuantLib/Instrument/Swap.chs" #-}


-- |The overnight leg's cash flows.
overnightLeg :: (OvernightIndexedSwap) -> IO ((Leg))
overnightLeg a1 =
  withOvernightIndexedSwap a1 $ \a1' -> 
  preErrorCheck $ \a2' -> 
  overnightLeg'_ a1' a2' >>= \res ->
  peekLeg res >>= \res' ->
  errorCheck  a2'>>
  return (res')

{-# LINE 933 "./QuantLib/Instrument/Swap.chs" #-}


-- |Basis-point sensitivity of the overnight leg.
overnightLegBps :: (OvernightIndexedSwap) -> IO ((Double))
overnightLegBps a1 =
  withOvernightIndexedSwap a1 $ \a1' -> 
  preErrorCheck $ \a2' -> 
  overnightLegBps'_ a1' a2' >>= \res ->
  let {res' = realToFrac res} in
  errorCheck  a2'>>
  return (res')

{-# LINE 936 "./QuantLib/Instrument/Swap.chs" #-}


-- |NPV of the overnight leg.
overnightLegNpv :: (OvernightIndexedSwap) -> IO ((Double))
overnightLegNpv a1 =
  withOvernightIndexedSwap a1 $ \a1' -> 
  preErrorCheck $ \a2' -> 
  overnightLegNpv'_ a1' a2' >>= \res ->
  let {res' = realToFrac res} in
  errorCheck  a2'>>
  return (res')

{-# LINE 939 "./QuantLib/Instrument/Swap.chs" #-}


-- |A zero-coupon inflation-indexed swap (ZCIIS): a single fixed-vs-CPI-ratio exchange at
-- maturity. Per-leg NPV\/BPS use the generic 'leg'\/'legNpv'\/'legBps' (leg 0 = fixed, leg 1 =
-- inflation).
zeroCouponInflationSwap :: (SwapType) -> (Double) -- ^nominal
 -> (Day) -- ^startDate
 -> (Day) -- ^maturity
 -> (Calendar) -> (BusinessDayConvention) -- ^paymentConvention
 -> (DayCounter) -> (Double) -- ^fixedRate
 -> (ZeroInflationIndex) -> ((Word,TimeUnit)) -- ^observationLag
 -> (CPIInterpolationType) -- ^observationInterpolation
 -> (Bool) -- ^adjustInfObsDates
 -> (Calendar) -- ^infCalendar
 -> (BusinessDayConvention) -- ^infConvention
 -> IO ((ZeroCouponInflationSwap))
zeroCouponInflationSwap :: SwapType
-> Double
-> Day
-> Day
-> Calendar
-> BusinessDayConvention
-> DayCounter
-> Double
-> ZeroInflationIndex
-> (Word, TimeUnit)
-> CPIInterpolationType
-> Bool
-> Calendar
-> BusinessDayConvention
-> IO ZeroCouponInflationSwap
zeroCouponInflationSwap SwapType
a1 Double
a2 Day
a3 Day
a4 Calendar
a5 BusinessDayConvention
a6 DayCounter
a7 Double
a8 ZeroInflationIndex
a9 (Word, TimeUnit)
a10 CPIInterpolationType
a11 Bool
a12 Calendar
a13 BusinessDayConvention
a14 =
  let {a1' :: CInt
a1' = (Int -> CInt
forall a b. (Integral a, Num b) => a -> b
fromIntegral (Int -> CInt) -> (SwapType -> Int) -> SwapType -> CInt
forall b c a. (b -> c) -> (a -> b) -> a -> c
. SwapType -> Int
forall a. Enum a => a -> Int
fromEnum) SwapType
a1} in 
  let {a2' :: CDouble
a2' = Double -> CDouble
forall a b. (Real a, Fractional b) => a -> b
realToFrac Double
a2} in 
  Day
-> (CInt -> IO ZeroCouponInflationSwap)
-> IO ZeroCouponInflationSwap
forall a. Day -> (CInt -> IO a) -> IO a
withDay Day
a3 ((CInt -> IO ZeroCouponInflationSwap)
 -> IO ZeroCouponInflationSwap)
-> (CInt -> IO ZeroCouponInflationSwap)
-> IO ZeroCouponInflationSwap
forall a b. (a -> b) -> a -> b
$ \CInt
a3' -> 
  Day
-> (CInt -> IO ZeroCouponInflationSwap)
-> IO ZeroCouponInflationSwap
forall a. Day -> (CInt -> IO a) -> IO a
withDay Day
a4 ((CInt -> IO ZeroCouponInflationSwap)
 -> IO ZeroCouponInflationSwap)
-> (CInt -> IO ZeroCouponInflationSwap)
-> IO ZeroCouponInflationSwap
forall a b. (a -> b) -> a -> b
$ \CInt
a4' -> 
  Calendar
-> (Ptr CCalendar -> IO ZeroCouponInflationSwap)
-> IO ZeroCouponInflationSwap
forall b. Calendar -> (Ptr CCalendar -> IO b) -> IO b
withCalendar Calendar
a5 ((Ptr CCalendar -> IO ZeroCouponInflationSwap)
 -> IO ZeroCouponInflationSwap)
-> (Ptr CCalendar -> IO ZeroCouponInflationSwap)
-> IO ZeroCouponInflationSwap
forall a b. (a -> b) -> a -> b
$ \Ptr CCalendar
a5' -> 
  let {a6' :: CInt
a6' = BusinessDayConvention -> CInt
forall a b. (Enum a, Integral b) => a -> b
fromEnumC BusinessDayConvention
a6} in 
  DayCounter
-> (Ptr CDayCounter -> IO ZeroCouponInflationSwap)
-> IO ZeroCouponInflationSwap
forall b. DayCounter -> (Ptr CDayCounter -> IO b) -> IO b
withDayCounter DayCounter
a7 ((Ptr CDayCounter -> IO ZeroCouponInflationSwap)
 -> IO ZeroCouponInflationSwap)
-> (Ptr CDayCounter -> IO ZeroCouponInflationSwap)
-> IO ZeroCouponInflationSwap
forall a b. (a -> b) -> a -> b
$ \Ptr CDayCounter
a7' -> 
  let {a8' :: CDouble
a8' = Double -> CDouble
forall a b. (Real a, Fractional b) => a -> b
realToFrac Double
a8} in 
  ZeroInflationIndex
-> (Ptr CZeroInflationIndex' -> IO ZeroCouponInflationSwap)
-> IO ZeroCouponInflationSwap
forall zidx b.
GenZeroInflationIndex zidx
-> (Ptr CZeroInflationIndex' -> IO b) -> IO b
withZeroInflationIndex ZeroInflationIndex
a9 ((Ptr CZeroInflationIndex' -> IO ZeroCouponInflationSwap)
 -> IO ZeroCouponInflationSwap)
-> (Ptr CZeroInflationIndex' -> IO ZeroCouponInflationSwap)
-> IO ZeroCouponInflationSwap
forall a b. (a -> b) -> a -> b
$ \Ptr CZeroInflationIndex'
a9' -> 
  let {(CInt
a10'1, CInt
a10'2) = (Word, TimeUnit) -> (CInt, CInt)
forall a b c.
(Enum a, Integral b, Integral c) =>
(b, a) -> (CInt, c)
fromEnumQuantity (Word, TimeUnit)
a10} in 
  let {a11' :: CInt
a11' = CPIInterpolationType -> CInt
forall a b. (Enum a, Integral b) => a -> b
fromEnumC CPIInterpolationType
a11} in 
  let {a12' :: CInt
a12' = Bool -> CInt
forall a. Num a => Bool -> a
C2HSImp.fromBool Bool
a12} in 
  Calendar
-> (Ptr CCalendar -> IO ZeroCouponInflationSwap)
-> IO ZeroCouponInflationSwap
forall b. Calendar -> (Ptr CCalendar -> IO b) -> IO b
withCalendar Calendar
a13 ((Ptr CCalendar -> IO ZeroCouponInflationSwap)
 -> IO ZeroCouponInflationSwap)
-> (Ptr CCalendar -> IO ZeroCouponInflationSwap)
-> IO ZeroCouponInflationSwap
forall a b. (a -> b) -> a -> b
$ \Ptr CCalendar
a13' -> 
  let {a14' :: CInt
a14' = BusinessDayConvention -> CInt
forall a b. (Enum a, Integral b) => a -> b
fromEnumC BusinessDayConvention
a14} in 
  (Ptr (Ptr CChar) -> IO ZeroCouponInflationSwap)
-> IO ZeroCouponInflationSwap
forall a b. (Ptr (Ptr a) -> IO b) -> IO b
preErrorCheck ((Ptr (Ptr CChar) -> IO ZeroCouponInflationSwap)
 -> IO ZeroCouponInflationSwap)
-> (Ptr (Ptr CChar) -> IO ZeroCouponInflationSwap)
-> IO ZeroCouponInflationSwap
forall a b. (a -> b) -> a -> b
$ \Ptr (Ptr CChar)
a15' -> 
  CInt
-> CDouble
-> CInt
-> CInt
-> Ptr CCalendar
-> CInt
-> Ptr CDayCounter
-> CDouble
-> Ptr CZeroInflationIndex'
-> CInt
-> CInt
-> CInt
-> CInt
-> Ptr CCalendar
-> CInt
-> Ptr (Ptr CChar)
-> IO (Ptr CZeroCouponInflationSwap')
zeroCouponInflationSwap'_ CInt
a1' CDouble
a2' CInt
a3' CInt
a4' Ptr CCalendar
a5' CInt
a6' Ptr CDayCounter
a7' CDouble
a8' Ptr CZeroInflationIndex'
a9' CInt
a10'1  CInt
a10'2 CInt
a11' CInt
a12' Ptr CCalendar
a13' CInt
a14' Ptr (Ptr CChar)
a15' IO (Ptr CZeroCouponInflationSwap')
-> (Ptr CZeroCouponInflationSwap' -> IO ZeroCouponInflationSwap)
-> IO ZeroCouponInflationSwap
forall a b. IO a -> (a -> IO b) -> IO b
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= \Ptr CZeroCouponInflationSwap'
res ->
  Ptr CZeroCouponInflationSwap' -> IO ZeroCouponInflationSwap
peekZeroCouponInflationSwap Ptr CZeroCouponInflationSwap'
res IO ZeroCouponInflationSwap
-> (ZeroCouponInflationSwap -> IO ZeroCouponInflationSwap)
-> IO ZeroCouponInflationSwap
forall a b. IO a -> (a -> IO b) -> IO b
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= \ZeroCouponInflationSwap
res' ->
  Ptr (Ptr CChar) -> IO ()
errorCheck  Ptr (Ptr CChar)
a15'IO () -> IO ZeroCouponInflationSwap -> IO ZeroCouponInflationSwap
forall a b. IO a -> IO b -> IO b
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>>
  ZeroCouponInflationSwap -> IO ZeroCouponInflationSwap
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return (ZeroCouponInflationSwap
res')

{-# LINE 957 "./QuantLib/Instrument/Swap.chs" #-}


-- |The fixed rate that would make the swap's NPV zero.
qlZeroCouponInflationSwapFairRate :: (ZeroCouponInflationSwap) -> IO ((Double))
qlZeroCouponInflationSwapFairRate a1 =
  withZeroCouponInflationSwap a1 $ \a1' -> 
  preErrorCheck $ \a2' -> 
  qlZeroCouponInflationSwapFairRate'_ a1' a2' >>= \res ->
  let {res' = realToFrac res} in
  errorCheck  a2'>>
  return (res')

{-# LINE 960 "./QuantLib/Instrument/Swap.chs" #-}


-- |A year-on-year inflation-indexed swap: fixed leg vs a YoY-inflation-linked leg. Per-leg
-- NPV\/BPS use the generic 'leg'\/'legNpv'\/'legBps' (leg 0 = fixed, leg 1 = YoY).
yearOnYearInflationSwap :: (SwapType) -> (Double) -- ^nominal
 -> (Schedule) -- ^fixedSchedule
 -> (Double) -- ^fixedRate
 -> (DayCounter) -- ^fixedDayCount
 -> (Schedule) -- ^yoySchedule
 -> (YoYInflationIndex) -> ((Word,TimeUnit)) -- ^observationLag
 -> (CPIInterpolationType) -- ^interpolation
 -> (Double) -- ^spread
 -> (DayCounter) -- ^yoyDayCount
 -> (Calendar) -- ^paymentCalendar
 -> (BusinessDayConvention) -- ^paymentConvention
 -> IO ((YearOnYearInflationSwap))
yearOnYearInflationSwap a1 a2 a3 a4 a5 a6 a7 a8 a9 a10 a11 a12 a13 =
  let {a1' = (fromIntegral . fromEnum) a1} in 
  let {a2' = realToFrac a2} in 
  withSchedule a3 $ \a3' -> 
  let {a4' = realToFrac a4} in 
  withDayCounter a5 $ \a5' -> 
  withSchedule a6 $ \a6' -> 
  withYoYInflationIndex a7 $ \a7' -> 
  let {(a8'1, a8'2) = fromEnumQuantity a8} in 
  let {a9' = fromEnumC a9} in 
  let {a10' = realToFrac a10} in 
  withDayCounter a11 $ \a11' -> 
  withCalendar a12 $ \a12' -> 
  let {a13' = fromEnumC a13} in 
  preErrorCheck $ \a14' -> 
  yearOnYearInflationSwap'_ a1' a2' a3' a4' a5' a6' a7' a8'1  a8'2 a9' a10' a11' a12' a13' a14' >>= \res ->
  peekYearOnYearInflationSwap res >>= \res' ->
  errorCheck  a14'>>
  return (res')

{-# LINE 976 "./QuantLib/Instrument/Swap.chs" #-}


-- |The fixed rate that would make the swap's NPV zero.
qlYearOnYearInflationSwapFairRate :: (YearOnYearInflationSwap) -> IO ((Double))
qlYearOnYearInflationSwapFairRate a1 =
  withYearOnYearInflationSwap a1 $ \a1' -> 
  preErrorCheck $ \a2' -> 
  qlYearOnYearInflationSwapFairRate'_ a1' a2' >>= \res ->
  let {res' = realToFrac res} in
  errorCheck  a2'>>
  return (res')

{-# LINE 979 "./QuantLib/Instrument/Swap.chs" #-}


-- |The spread that would make the swap's NPV zero.
qlYearOnYearInflationSwapFairSpread :: (YearOnYearInflationSwap) -> IO ((Double))
qlYearOnYearInflationSwapFairSpread a1 =
  withYearOnYearInflationSwap a1 $ \a1' -> 
  preErrorCheck $ \a2' -> 
  qlYearOnYearInflationSwapFairSpread'_ a1' a2' >>= \res ->
  let {res' = realToFrac res} in
  errorCheck  a2'>>
  return (res')

{-# LINE 982 "./QuantLib/Instrument/Swap.chs" #-}


-- |A fixed-x-CPI-ratio leg (subtracting the inflation notional if
-- /subtractInflationNominal/) vs a float+spread leg -- QuantLib's general-purpose inflation
-- swap, also usable to replicate a single-cashflow ZCIIS (see 'zeroCouponInflationSwap').
-- Per-leg NPV\/BPS use the generic 'leg'\/'legNpv'\/'legBps' (leg 0 = CPI, leg 1 = float).
cpiSwap :: (SwapType) -> (Double) -- ^nominal
 -> (Bool) -- ^subtractInflationNominal
 -> (Double) -- ^spread
 -> (DayCounter) -- ^floatDayCount
 -> (Schedule) -- ^floatSchedule
 -> (BusinessDayConvention) -- ^floatRoll
 -> (Word) -- ^fixingDays
 -> (GenIborIndex ibor) -- ^floatIndex
 -> (Double) -- ^fixedRate
 -> (Double) -- ^baseCPI
 -> (DayCounter) -- ^fixedDayCount
 -> (Schedule) -- ^fixedSchedule
 -> (BusinessDayConvention) -- ^fixedRoll
 -> ((Word,TimeUnit)) -- ^observationLag
 -> (ZeroInflationIndex) -- ^fixedIndex
 -> (CPIInterpolationType) -- ^observationInterpolation
 -> (Maybe Double) -- ^inflationNominal
 -> IO ((CPISwap))
cpiSwap :: forall ibor.
SwapType
-> Double
-> Bool
-> Double
-> DayCounter
-> Schedule
-> BusinessDayConvention
-> Word
-> GenIborIndex ibor
-> Double
-> Double
-> DayCounter
-> Schedule
-> BusinessDayConvention
-> (Word, TimeUnit)
-> ZeroInflationIndex
-> CPIInterpolationType
-> Maybe Double
-> IO CPISwap
cpiSwap SwapType
a1 Double
a2 Bool
a3 Double
a4 DayCounter
a5 Schedule
a6 BusinessDayConvention
a7 Word
a8 GenIborIndex ibor
a9 Double
a10 Double
a11 DayCounter
a12 Schedule
a13 BusinessDayConvention
a14 (Word, TimeUnit)
a15 ZeroInflationIndex
a16 CPIInterpolationType
a17 Maybe Double
a18 =
  let {a1' :: CInt
a1' = (Int -> CInt
forall a b. (Integral a, Num b) => a -> b
fromIntegral (Int -> CInt) -> (SwapType -> Int) -> SwapType -> CInt
forall b c a. (b -> c) -> (a -> b) -> a -> c
. SwapType -> Int
forall a. Enum a => a -> Int
fromEnum) SwapType
a1} in 
  let {a2' :: CDouble
a2' = Double -> CDouble
forall a b. (Real a, Fractional b) => a -> b
realToFrac Double
a2} in 
  let {a3' :: CInt
a3' = Bool -> CInt
forall a. Num a => Bool -> a
C2HSImp.fromBool Bool
a3} in 
  let {a4' :: CDouble
a4' = Double -> CDouble
forall a b. (Real a, Fractional b) => a -> b
realToFrac Double
a4} in 
  DayCounter -> (Ptr CDayCounter -> IO CPISwap) -> IO CPISwap
forall b. DayCounter -> (Ptr CDayCounter -> IO b) -> IO b
withDayCounter DayCounter
a5 ((Ptr CDayCounter -> IO CPISwap) -> IO CPISwap)
-> (Ptr CDayCounter -> IO CPISwap) -> IO CPISwap
forall a b. (a -> b) -> a -> b
$ \Ptr CDayCounter
a5' -> 
  Schedule -> (Ptr CSchedule -> IO CPISwap) -> IO CPISwap
forall b. Schedule -> (Ptr CSchedule -> IO b) -> IO b
withSchedule Schedule
a6 ((Ptr CSchedule -> IO CPISwap) -> IO CPISwap)
-> (Ptr CSchedule -> IO CPISwap) -> IO CPISwap
forall a b. (a -> b) -> a -> b
$ \Ptr CSchedule
a6' -> 
  let {a7' :: CInt
a7' = BusinessDayConvention -> CInt
forall a b. (Enum a, Integral b) => a -> b
fromEnumC BusinessDayConvention
a7} in 
  let {a8' :: CUInt
a8' = Word -> CUInt
forall a b. (Integral a, Num b) => a -> b
fromIntegral Word
a8} in 
  GenIborIndex ibor -> (Ptr CIborIndex' -> IO CPISwap) -> IO CPISwap
forall ibor b.
GenIborIndex ibor -> (Ptr CIborIndex' -> IO b) -> IO b
withIborIndex GenIborIndex ibor
a9 ((Ptr CIborIndex' -> IO CPISwap) -> IO CPISwap)
-> (Ptr CIborIndex' -> IO CPISwap) -> IO CPISwap
forall a b. (a -> b) -> a -> b
$ \Ptr CIborIndex'
a9' -> 
  let {a10' :: CDouble
a10' = Double -> CDouble
forall a b. (Real a, Fractional b) => a -> b
realToFrac Double
a10} in 
  let {a11' :: CDouble
a11' = Double -> CDouble
forall a b. (Real a, Fractional b) => a -> b
realToFrac Double
a11} in 
  DayCounter -> (Ptr CDayCounter -> IO CPISwap) -> IO CPISwap
forall b. DayCounter -> (Ptr CDayCounter -> IO b) -> IO b
withDayCounter DayCounter
a12 ((Ptr CDayCounter -> IO CPISwap) -> IO CPISwap)
-> (Ptr CDayCounter -> IO CPISwap) -> IO CPISwap
forall a b. (a -> b) -> a -> b
$ \Ptr CDayCounter
a12' -> 
  Schedule -> (Ptr CSchedule -> IO CPISwap) -> IO CPISwap
forall b. Schedule -> (Ptr CSchedule -> IO b) -> IO b
withSchedule Schedule
a13 ((Ptr CSchedule -> IO CPISwap) -> IO CPISwap)
-> (Ptr CSchedule -> IO CPISwap) -> IO CPISwap
forall a b. (a -> b) -> a -> b
$ \Ptr CSchedule
a13' -> 
  let {a14' :: CInt
a14' = BusinessDayConvention -> CInt
forall a b. (Enum a, Integral b) => a -> b
fromEnumC BusinessDayConvention
a14} in 
  let {(CInt
a15'1, CInt
a15'2) = (Word, TimeUnit) -> (CInt, CInt)
forall a b c.
(Enum a, Integral b, Integral c) =>
(b, a) -> (CInt, c)
fromEnumQuantity (Word, TimeUnit)
a15} in 
  ZeroInflationIndex
-> (Ptr CZeroInflationIndex' -> IO CPISwap) -> IO CPISwap
forall zidx b.
GenZeroInflationIndex zidx
-> (Ptr CZeroInflationIndex' -> IO b) -> IO b
withZeroInflationIndex ZeroInflationIndex
a16 ((Ptr CZeroInflationIndex' -> IO CPISwap) -> IO CPISwap)
-> (Ptr CZeroInflationIndex' -> IO CPISwap) -> IO CPISwap
forall a b. (a -> b) -> a -> b
$ \Ptr CZeroInflationIndex'
a16' -> 
  let {a17' :: CInt
a17' = CPIInterpolationType -> CInt
forall a b. (Enum a, Integral b) => a -> b
fromEnumC CPIInterpolationType
a17} in 
  let {a18' :: CDouble
a18' = Maybe Double -> CDouble
fromMaybeDouble Maybe Double
a18} in 
  (Ptr (Ptr CChar) -> IO CPISwap) -> IO CPISwap
forall a b. (Ptr (Ptr a) -> IO b) -> IO b
preErrorCheck ((Ptr (Ptr CChar) -> IO CPISwap) -> IO CPISwap)
-> (Ptr (Ptr CChar) -> IO CPISwap) -> IO CPISwap
forall a b. (a -> b) -> a -> b
$ \Ptr (Ptr CChar)
a19' -> 
  CInt
-> CDouble
-> CInt
-> CDouble
-> Ptr CDayCounter
-> Ptr CSchedule
-> CInt
-> CUInt
-> Ptr CIborIndex'
-> CDouble
-> CDouble
-> Ptr CDayCounter
-> Ptr CSchedule
-> CInt
-> CInt
-> CInt
-> Ptr CZeroInflationIndex'
-> CInt
-> CDouble
-> Ptr (Ptr CChar)
-> IO (Ptr CCPISwap')
cpiSwap'_ CInt
a1' CDouble
a2' CInt
a3' CDouble
a4' Ptr CDayCounter
a5' Ptr CSchedule
a6' CInt
a7' CUInt
a8' Ptr CIborIndex'
a9' CDouble
a10' CDouble
a11' Ptr CDayCounter
a12' Ptr CSchedule
a13' CInt
a14' CInt
a15'1  CInt
a15'2 Ptr CZeroInflationIndex'
a16' CInt
a17' CDouble
a18' Ptr (Ptr CChar)
a19' IO (Ptr CCPISwap') -> (Ptr CCPISwap' -> IO CPISwap) -> IO CPISwap
forall a b. IO a -> (a -> IO b) -> IO b
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= \Ptr CCPISwap'
res ->
  Ptr CCPISwap' -> IO CPISwap
peekCPISwap Ptr CCPISwap'
res IO CPISwap -> (CPISwap -> IO CPISwap) -> IO CPISwap
forall a b. IO a -> (a -> IO b) -> IO b
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= \CPISwap
res' ->
  Ptr (Ptr CChar) -> IO ()
errorCheck  Ptr (Ptr CChar)
a19'IO () -> IO CPISwap -> IO CPISwap
forall a b. IO a -> IO b -> IO b
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>>
  CPISwap -> IO CPISwap
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return (CPISwap
res')

{-# LINE 1005 "./QuantLib/Instrument/Swap.chs" #-}


-- |The fixed rate that would make the swap's NPV zero.
qlCPISwapFairRate :: (CPISwap) -> IO ((Double))
qlCPISwapFairRate a1 =
  withCPISwap a1 $ \a1' -> 
  preErrorCheck $ \a2' -> 
  qlCPISwapFairRate'_ a1' a2' >>= \res ->
  let {res' = realToFrac res} in
  errorCheck  a2'>>
  return (res')

{-# LINE 1008 "./QuantLib/Instrument/Swap.chs" #-}


-- |The spread that would make the swap's NPV zero.
qlCPISwapFairSpread :: (CPISwap) -> IO ((Double))
qlCPISwapFairSpread a1 =
  withCPISwap a1 $ \a1' -> 
  preErrorCheck $ \a2' -> 
  qlCPISwapFairSpread'_ a1' a2' >>= \res ->
  let {res' = realToFrac res} in
  errorCheck  a2'>>
  return (res')

{-# LINE 1011 "./QuantLib/Instrument/Swap.chs" #-}


-- |Zero-coupon swap quoted in terms of a known fixed cash flow. \"payer\"\/\"receiver\" refer to
-- the fixed leg. Per-leg NPV uses the generic 'leg'\/'legNpv' (leg 0 = fixed, leg 1 = floating).
zeroCouponSwap :: (SwapType) -> (Double) -- ^baseNominal
 -> (Day) -- ^startDate
 -> (Day) -- ^maturityDate
 -> (Double) -- ^fixedPayment
 -> (GenIborIndex ibor) -> (Calendar) -- ^paymentCalendar
 -> (BusinessDayConvention) -- ^paymentConvention
 -> (Word) -- ^paymentDelay
 -> IO ((ZeroCouponSwap))
zeroCouponSwap a1 a2 a3 a4 a5 a6 a7 a8 a9 =
  let {a1' = (fromIntegral . fromEnum) a1} in 
  let {a2' = realToFrac a2} in 
  withDay a3 $ \a3' -> 
  withDay a4 $ \a4' -> 
  let {a5' = realToFrac a5} in 
  withIborIndex a6 $ \a6' -> 
  withCalendar a7 $ \a7' -> 
  let {a8' = fromEnumC a8} in 
  let {a9' = fromIntegral a9} in 
  preErrorCheck $ \a10' -> 
  zeroCouponSwap'_ a1' a2' a3' a4' a5' a6' a7' a8' a9' a10' >>= \res ->
  peekZeroCouponSwap res >>= \res' ->
  errorCheck  a10'>>
  return (res')

{-# LINE 1022 "./QuantLib/Instrument/Swap.chs" #-}


-- |Zero-coupon swap quoted in terms of a fixed rate.
zeroCouponSwapFromRate :: (SwapType) -> (Double) -- ^baseNominal
 -> (Day) -- ^startDate
 -> (Day) -- ^maturityDate
 -> (Double) -- ^fixedRate
 -> (DayCounter) -- ^fixedDayCounter
 -> (GenIborIndex ibor) -> (Calendar) -- ^paymentCalendar
 -> (BusinessDayConvention) -- ^paymentConvention
 -> (Word) -- ^paymentDelay
 -> IO ((ZeroCouponSwap))
zeroCouponSwapFromRate a1 a2 a3 a4 a5 a6 a7 a8 a9 a10 =
  let {a1' = (fromIntegral . fromEnum) a1} in 
  let {a2' = realToFrac a2} in 
  withDay a3 $ \a3' -> 
  withDay a4 $ \a4' -> 
  let {a5' = realToFrac a5} in 
  withDayCounter a6 $ \a6' -> 
  withIborIndex a7 $ \a7' -> 
  withCalendar a8 $ \a8' -> 
  let {a9' = fromEnumC a9} in 
  let {a10' = fromIntegral a10} in 
  preErrorCheck $ \a11' -> 
  zeroCouponSwapFromRate'_ a1' a2' a3' a4' a5' a6' a7' a8' a9' a10' a11' >>= \res ->
  peekZeroCouponSwap res >>= \res' ->
  errorCheck  a11'>>
  return (res')

{-# LINE 1033 "./QuantLib/Instrument/Swap.chs" #-}


-- |The fixed payment that would make the swap's NPV zero.
fairFixedPayment :: (ZeroCouponSwap) -> IO ((Double))
fairFixedPayment a1 =
  withZeroCouponSwap a1 $ \a1' -> 
  preErrorCheck $ \a2' -> 
  fairFixedPayment'_ a1' a2' >>= \res ->
  let {res' = realToFrac res} in
  errorCheck  a2'>>
  return (res')

{-# LINE 1036 "./QuantLib/Instrument/Swap.chs" #-}


-- |The fixed rate, under the given day counter, that would make the swap's NPV zero.
fairFixedRate :: (ZeroCouponSwap) -> (DayCounter) -> IO ((Double))
fairFixedRate a1 a2 =
  withZeroCouponSwap a1 $ \a1' -> 
  withDayCounter a2 $ \a2' -> 
  preErrorCheck $ \a3' -> 
  fairFixedRate'_ a1' a2' a3' >>= \res ->
  let {res' = realToFrac res} in
  errorCheck  a3'>>
  return (res')

{-# LINE 1039 "./QuantLib/Instrument/Swap.chs" #-}


-- |Exchanges the total return of an 'EquityIndex' for a set of floating cash flows linked to an
-- 'IborIndex'. /type/ (payer\/receiver) refers to the equity leg.
equityTotalReturnSwapIbor :: (SwapType) -> (Double) -- ^nominal
 -> (Schedule) -> (EquityIndex) -> (GenIborIndex ibor) -- ^interestRateIndex
 -> (DayCounter) -> (Double) -- ^margin
 -> (Double) -- ^gearing
 -> (Calendar) -- ^paymentCalendar
 -> (BusinessDayConvention) -- ^paymentConvention
 -> (Word) -- ^paymentDelay
 -> IO ((EquityTotalReturnSwap))
equityTotalReturnSwapIbor :: forall ibor.
SwapType
-> Double
-> Schedule
-> EquityIndex
-> GenIborIndex ibor
-> DayCounter
-> Double
-> Double
-> Calendar
-> BusinessDayConvention
-> Word
-> IO EquityTotalReturnSwap
equityTotalReturnSwapIbor SwapType
a1 Double
a2 Schedule
a3 EquityIndex
a4 GenIborIndex ibor
a5 DayCounter
a6 Double
a7 Double
a8 Calendar
a9 BusinessDayConvention
a10 Word
a11 =
  let {a1' :: CInt
a1' = (Int -> CInt
forall a b. (Integral a, Num b) => a -> b
fromIntegral (Int -> CInt) -> (SwapType -> Int) -> SwapType -> CInt
forall b c a. (b -> c) -> (a -> b) -> a -> c
. SwapType -> Int
forall a. Enum a => a -> Int
fromEnum) SwapType
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 EquityTotalReturnSwap)
-> IO EquityTotalReturnSwap
forall b. Schedule -> (Ptr CSchedule -> IO b) -> IO b
withSchedule Schedule
a3 ((Ptr CSchedule -> IO EquityTotalReturnSwap)
 -> IO EquityTotalReturnSwap)
-> (Ptr CSchedule -> IO EquityTotalReturnSwap)
-> IO EquityTotalReturnSwap
forall a b. (a -> b) -> a -> b
$ \Ptr CSchedule
a3' -> 
  EquityIndex
-> (Ptr CEquityIndex' -> IO EquityTotalReturnSwap)
-> IO EquityTotalReturnSwap
forall b. EquityIndex -> (Ptr CEquityIndex' -> IO b) -> IO b
withEquityIndex EquityIndex
a4 ((Ptr CEquityIndex' -> IO EquityTotalReturnSwap)
 -> IO EquityTotalReturnSwap)
-> (Ptr CEquityIndex' -> IO EquityTotalReturnSwap)
-> IO EquityTotalReturnSwap
forall a b. (a -> b) -> a -> b
$ \Ptr CEquityIndex'
a4' -> 
  GenIborIndex ibor
-> (Ptr CIborIndex' -> IO EquityTotalReturnSwap)
-> IO EquityTotalReturnSwap
forall ibor b.
GenIborIndex ibor -> (Ptr CIborIndex' -> IO b) -> IO b
withIborIndex GenIborIndex ibor
a5 ((Ptr CIborIndex' -> IO EquityTotalReturnSwap)
 -> IO EquityTotalReturnSwap)
-> (Ptr CIborIndex' -> IO EquityTotalReturnSwap)
-> IO EquityTotalReturnSwap
forall a b. (a -> b) -> a -> b
$ \Ptr CIborIndex'
a5' -> 
  DayCounter
-> (Ptr CDayCounter -> IO EquityTotalReturnSwap)
-> IO EquityTotalReturnSwap
forall b. DayCounter -> (Ptr CDayCounter -> IO b) -> IO b
withDayCounter DayCounter
a6 ((Ptr CDayCounter -> IO EquityTotalReturnSwap)
 -> IO EquityTotalReturnSwap)
-> (Ptr CDayCounter -> IO EquityTotalReturnSwap)
-> IO EquityTotalReturnSwap
forall a b. (a -> b) -> a -> b
$ \Ptr CDayCounter
a6' -> 
  let {a7' :: CDouble
a7' = Double -> CDouble
forall a b. (Real a, Fractional b) => a -> b
realToFrac Double
a7} in 
  let {a8' :: CDouble
a8' = Double -> CDouble
forall a b. (Real a, Fractional b) => a -> b
realToFrac Double
a8} in 
  Calendar
-> (Ptr CCalendar -> IO EquityTotalReturnSwap)
-> IO EquityTotalReturnSwap
forall b. Calendar -> (Ptr CCalendar -> IO b) -> IO b
withCalendar Calendar
a9 ((Ptr CCalendar -> IO EquityTotalReturnSwap)
 -> IO EquityTotalReturnSwap)
-> (Ptr CCalendar -> IO EquityTotalReturnSwap)
-> IO EquityTotalReturnSwap
forall a b. (a -> b) -> a -> b
$ \Ptr CCalendar
a9' -> 
  let {a10' :: CInt
a10' = BusinessDayConvention -> CInt
forall a b. (Enum a, Integral b) => a -> b
fromEnumC BusinessDayConvention
a10} in 
  let {a11' :: CUInt
a11' = Word -> CUInt
forall a b. (Integral a, Num b) => a -> b
fromIntegral Word
a11} in 
  (Ptr (Ptr CChar) -> IO EquityTotalReturnSwap)
-> IO EquityTotalReturnSwap
forall a b. (Ptr (Ptr a) -> IO b) -> IO b
preErrorCheck ((Ptr (Ptr CChar) -> IO EquityTotalReturnSwap)
 -> IO EquityTotalReturnSwap)
-> (Ptr (Ptr CChar) -> IO EquityTotalReturnSwap)
-> IO EquityTotalReturnSwap
forall a b. (a -> b) -> a -> b
$ \Ptr (Ptr CChar)
a12' -> 
  CInt
-> CDouble
-> Ptr CSchedule
-> Ptr CEquityIndex'
-> Ptr CIborIndex'
-> Ptr CDayCounter
-> CDouble
-> CDouble
-> Ptr CCalendar
-> CInt
-> CUInt
-> Ptr (Ptr CChar)
-> IO (Ptr CEquityTotalReturnSwap')
equityTotalReturnSwapIbor'_ CInt
a1' CDouble
a2' Ptr CSchedule
a3' Ptr CEquityIndex'
a4' Ptr CIborIndex'
a5' Ptr CDayCounter
a6' CDouble
a7' CDouble
a8' Ptr CCalendar
a9' CInt
a10' CUInt
a11' Ptr (Ptr CChar)
a12' IO (Ptr CEquityTotalReturnSwap')
-> (Ptr CEquityTotalReturnSwap' -> IO EquityTotalReturnSwap)
-> IO EquityTotalReturnSwap
forall a b. IO a -> (a -> IO b) -> IO b
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= \Ptr CEquityTotalReturnSwap'
res ->
  Ptr CEquityTotalReturnSwap' -> IO EquityTotalReturnSwap
peekEquityTotalReturnSwap Ptr CEquityTotalReturnSwap'
res IO EquityTotalReturnSwap
-> (EquityTotalReturnSwap -> IO EquityTotalReturnSwap)
-> IO EquityTotalReturnSwap
forall a b. IO a -> (a -> IO b) -> IO b
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= \EquityTotalReturnSwap
res' ->
  Ptr (Ptr CChar) -> IO ()
errorCheck  Ptr (Ptr CChar)
a12'IO () -> IO EquityTotalReturnSwap -> IO EquityTotalReturnSwap
forall a b. IO a -> IO b -> IO b
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>>
  EquityTotalReturnSwap -> IO EquityTotalReturnSwap
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return (EquityTotalReturnSwap
res')

{-# LINE 1053 "./QuantLib/Instrument/Swap.chs" #-}


-- |As 'equityTotalReturnSwapIbor', but with the floating leg linked to an overnight index instead
-- -- fixings are compounded over the accrual period.
equityTotalReturnSwapOvernight :: (SwapType) -> (Double) -- ^nominal
 -> (Schedule) -> (EquityIndex) -> (OvernightIborIndex) -- ^interestRateIndex
 -> (DayCounter) -> (Double) -- ^margin
 -> (Double) -- ^gearing
 -> (Calendar) -- ^paymentCalendar
 -> (BusinessDayConvention) -- ^paymentConvention
 -> (Word) -- ^paymentDelay
 -> IO ((EquityTotalReturnSwap))
equityTotalReturnSwapOvernight a1 a2 a3 a4 a5 a6 a7 a8 a9 a10 a11 =
  let {a1' = (fromIntegral . fromEnum) a1} in 
  let {a2' = realToFrac a2} in 
  withSchedule a3 $ \a3' -> 
  withEquityIndex a4 $ \a4' -> 
  withOvernightIborIndex a5 $ \a5' -> 
  withDayCounter a6 $ \a6' -> 
  let {a7' = realToFrac a7} in 
  let {a8' = realToFrac a8} in 
  withCalendar a9 $ \a9' -> 
  let {a10' = fromEnumC a10} in 
  let {a11' = fromIntegral a11} in 
  preErrorCheck $ \a12' -> 
  equityTotalReturnSwapOvernight'_ a1' a2' a3' a4' a5' a6' a7' a8' a9' a10' a11' a12' >>= \res ->
  peekEquityTotalReturnSwap res >>= \res' ->
  errorCheck  a12'>>
  return (res')

{-# LINE 1067 "./QuantLib/Instrument/Swap.chs" #-}


-- |NPV of the equity total-return leg.
equityLegNpv :: (EquityTotalReturnSwap) -> IO ((Double))
equityLegNpv a1 =
  withEquityTotalReturnSwap a1 $ \a1' -> 
  preErrorCheck $ \a2' -> 
  equityLegNpv'_ a1' a2' >>= \res ->
  let {res' = realToFrac res} in
  errorCheck  a2'>>
  return (res')

{-# LINE 1070 "./QuantLib/Instrument/Swap.chs" #-}


-- |NPV of the interest-rate leg.
interestRateLegNpv :: (EquityTotalReturnSwap) -> IO ((Double))
interestRateLegNpv a1 =
  withEquityTotalReturnSwap a1 $ \a1' -> 
  preErrorCheck $ \a2' -> 
  interestRateLegNpv'_ a1' a2' >>= \res ->
  let {res' = realToFrac res} in
  errorCheck  a2'>>
  return (res')

{-# LINE 1073 "./QuantLib/Instrument/Swap.chs" #-}


-- |The margin that would make the swap's NPV zero.
fairMargin :: (EquityTotalReturnSwap) -> IO ((Double))
fairMargin a1 =
  withEquityTotalReturnSwap a1 $ \a1' -> 
  preErrorCheck $ \a2' -> 
  fairMargin'_ a1' a2' >>= \res ->
  let {res' = realToFrac res} in
  errorCheck  a2'>>
  return (res')

{-# LINE 1076 "./QuantLib/Instrument/Swap.chs" #-}


class HasFixedLeg a where
  fixedLeg :: a -> IO Leg
  fixedLegBps :: a -> IO Double
  fixedLegNpv :: a -> IO Double
instance HasFixedLeg OvernightIndexedSwap where
  fixedLeg = qlOvernightIndexedSwapFixedLeg
  fixedLegBps = qlOvernightIndexedSwapFixedLegBPS
  fixedLegNpv = qlOvernightIndexedSwapFixedLegNPV
instance HasFixedLeg (GenFixedVsFloatingSwap f) where
  fixedLeg :: GenFixedVsFloatingSwap f -> IO Leg
fixedLeg = GenFixedVsFloatingSwap f -> IO Leg
forall f. GenFixedVsFloatingSwap f -> IO Leg
qlFixedVsFloatingSwapFixedLeg
  fixedLegBps :: GenFixedVsFloatingSwap f -> IO Double
fixedLegBps = GenFixedVsFloatingSwap f -> IO Double
forall f. GenFixedVsFloatingSwap f -> IO Double
qlFixedVsFloatingSwapFixedLegBPS
  fixedLegNpv :: GenFixedVsFloatingSwap f -> IO Double
fixedLegNpv = GenFixedVsFloatingSwap f -> IO Double
forall f. GenFixedVsFloatingSwap f -> IO Double
qlFixedVsFloatingSwapFixedLegNPV

class HasFairRate a where
  fairRate :: a -> IO Double
instance HasFairRate OvernightIndexedSwap where
  fairRate :: OvernightIndexedSwap -> IO Double
fairRate = OvernightIndexedSwap -> IO Double
qlOvernightIndexedSwapFairRate
instance HasFairRate (GenFixedVsFloatingSwap f) where
  fairRate :: GenFixedVsFloatingSwap f -> IO Double
fairRate = GenFixedVsFloatingSwap f -> IO Double
forall f. GenFixedVsFloatingSwap f -> IO Double
qlFixedVsFloatingSwapFairRate
instance HasFairRate IrregularSwap where
  fairRate :: IrregularSwap -> IO Double
fairRate = IrregularSwap -> IO Double
qlIrregularSwapFairRate
instance HasFairRate ZeroCouponInflationSwap where
  fairRate :: ZeroCouponInflationSwap -> IO Double
fairRate = ZeroCouponInflationSwap -> IO Double
qlZeroCouponInflationSwapFairRate
instance HasFairRate YearOnYearInflationSwap where
  fairRate :: YearOnYearInflationSwap -> IO Double
fairRate = YearOnYearInflationSwap -> IO Double
qlYearOnYearInflationSwapFairRate
instance HasFairRate CPISwap where
  fairRate :: CPISwap -> IO Double
fairRate = CPISwap -> IO Double
qlCPISwapFairRate

class HasFairSpread a where
  fairSpread :: a -> IO Double
instance HasFairSpread (GenFixedVsFloatingSwap f) where
  fairSpread :: GenFixedVsFloatingSwap f -> IO Double
fairSpread = GenFixedVsFloatingSwap f -> IO Double
forall f. GenFixedVsFloatingSwap f -> IO Double
qlFixedVsFloatingSwapFairSpread
instance HasFairSpread OvernightIndexedSwap where
  fairSpread :: OvernightIndexedSwap -> IO Double
fairSpread = OvernightIndexedSwap -> IO Double
qlOvernightIndexedSwapFairSpread
instance HasFairSpread AssetSwap where
  fairSpread :: AssetSwap -> IO Double
fairSpread = AssetSwap -> IO Double
qlAssetSwapFairSpread
instance HasFairSpread CreditDefaultSwap where
  fairSpread :: CreditDefaultSwap -> IO Double
fairSpread = CreditDefaultSwap -> IO Double
qlCreditDefaultSwapFairSpread
instance HasFairSpread YearOnYearInflationSwap where
  fairSpread :: YearOnYearInflationSwap -> IO Double
fairSpread = YearOnYearInflationSwap -> IO Double
qlYearOnYearInflationSwapFairSpread
instance HasFairSpread CPISwap where
  fairSpread :: CPISwap -> IO Double
fairSpread = CPISwap -> IO Double
qlCPISwapFairSpread
instance HasFairSpread IrregularSwap where
  fairSpread :: IrregularSwap -> IO Double
fairSpread = IrregularSwap -> IO Double
qlIrregularSwapFairSpread

-- |Options that hold the swap they are written on. 'CdsOption' is constructed in
-- "QuantLib.Instrument.Credit"; import this module as well to reach its underlying swap.
class HasInstrumentUnderlying a where
  type InstrumentUnderlying a
  underlyingSwap :: a -> IO (InstrumentUnderlying a)
instance HasInstrumentUnderlying Swaption where
  type InstrumentUnderlying Swaption = FixedVsFloatingSwap
  underlyingSwap :: Swaption -> IO (InstrumentUnderlying Swaption)
underlyingSwap = Swaption -> IO FixedVsFloatingSwap
Swaption -> IO (InstrumentUnderlying Swaption)
qlSwaptionUnderlying
instance HasInstrumentUnderlying NonstandardSwaption where
  type InstrumentUnderlying NonstandardSwaption = NonstandardSwap
  underlyingSwap :: NonstandardSwaption
-> IO (InstrumentUnderlying NonstandardSwaption)
underlyingSwap = NonstandardSwaption -> IO NonstandardSwap
NonstandardSwaption
-> IO (InstrumentUnderlying NonstandardSwaption)
qlNonstandardSwaptionUnderlyingSwap
instance HasInstrumentUnderlying FloatFloatSwaption where
  type InstrumentUnderlying FloatFloatSwaption = FloatFloatSwap
  underlyingSwap :: FloatFloatSwaption -> IO (InstrumentUnderlying FloatFloatSwaption)
underlyingSwap = FloatFloatSwaption -> IO FloatFloatSwap
FloatFloatSwaption -> IO (InstrumentUnderlying FloatFloatSwaption)
qlFloatFloatSwaptionUnderlyingSwap
instance HasInstrumentUnderlying IrregularSwaption where
  type InstrumentUnderlying IrregularSwaption = IrregularSwap
  underlyingSwap :: IrregularSwaption -> IO (InstrumentUnderlying IrregularSwaption)
underlyingSwap = IrregularSwaption -> IO IrregularSwap
IrregularSwaption -> IO (InstrumentUnderlying IrregularSwaption)
qlIrregularSwaptionUnderlyingSwap
instance HasInstrumentUnderlying CdsOption where
  type InstrumentUnderlying CdsOption = CreditDefaultSwap
  underlyingSwap :: CdsOption -> IO (InstrumentUnderlying CdsOption)
underlyingSwap = CdsOption -> IO CreditDefaultSwap
CdsOption -> IO (InstrumentUnderlying CdsOption)
qlCdsOptionUnderlyingSwap

qlSwaptionUnderlying :: (Swaption) -> IO ((FixedVsFloatingSwap))
qlSwaptionUnderlying :: Swaption -> IO FixedVsFloatingSwap
qlSwaptionUnderlying Swaption
a1 =
  Swaption
-> (Ptr CSwaption' -> IO FixedVsFloatingSwap)
-> IO FixedVsFloatingSwap
forall b. Swaption -> (Ptr CSwaption' -> IO b) -> IO b
withSwaption Swaption
a1 ((Ptr CSwaption' -> IO FixedVsFloatingSwap)
 -> IO FixedVsFloatingSwap)
-> (Ptr CSwaption' -> IO FixedVsFloatingSwap)
-> IO FixedVsFloatingSwap
forall a b. (a -> b) -> a -> b
$ \Ptr CSwaption'
a1' -> 
  (Ptr (Ptr CChar) -> IO FixedVsFloatingSwap)
-> IO FixedVsFloatingSwap
forall a b. (Ptr (Ptr a) -> IO b) -> IO b
preErrorCheck ((Ptr (Ptr CChar) -> IO FixedVsFloatingSwap)
 -> IO FixedVsFloatingSwap)
-> (Ptr (Ptr CChar) -> IO FixedVsFloatingSwap)
-> IO FixedVsFloatingSwap
forall a b. (a -> b) -> a -> b
$ \Ptr (Ptr CChar)
a2' -> 
  Ptr CSwaption' -> Ptr (Ptr CChar) -> IO (Ptr CFixedVsFloatingSwap')
qlSwaptionUnderlying'_ Ptr CSwaption'
a1' Ptr (Ptr CChar)
a2' IO (Ptr CFixedVsFloatingSwap')
-> (Ptr CFixedVsFloatingSwap' -> IO FixedVsFloatingSwap)
-> IO FixedVsFloatingSwap
forall a b. IO a -> (a -> IO b) -> IO b
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= \Ptr CFixedVsFloatingSwap'
res ->
  Ptr CFixedVsFloatingSwap' -> IO FixedVsFloatingSwap
peekFixedVsFloatingSwap Ptr CFixedVsFloatingSwap'
res IO FixedVsFloatingSwap
-> (FixedVsFloatingSwap -> IO FixedVsFloatingSwap)
-> IO FixedVsFloatingSwap
forall a b. IO a -> (a -> IO b) -> IO b
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= \FixedVsFloatingSwap
res' ->
  Ptr (Ptr CChar) -> IO ()
errorCheck  Ptr (Ptr CChar)
a2'IO () -> IO FixedVsFloatingSwap -> IO FixedVsFloatingSwap
forall a b. IO a -> IO b -> IO b
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>>
  FixedVsFloatingSwap -> IO FixedVsFloatingSwap
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return (FixedVsFloatingSwap
res')

{-# LINE 1144 "./QuantLib/Instrument/Swap.chs" #-}

qlNonstandardSwaptionUnderlyingSwap :: (NonstandardSwaption) -> IO ((NonstandardSwap))
qlNonstandardSwaptionUnderlyingSwap a1 =
  withNonstandardSwaption a1 $ \a1' -> 
  preErrorCheck $ \a2' -> 
  qlNonstandardSwaptionUnderlyingSwap'_ a1' a2' >>= \res ->
  peekNonstandardSwap res >>= \res' ->
  errorCheck  a2'>>
  return (res')

{-# LINE 1145 "./QuantLib/Instrument/Swap.chs" #-}

qlFloatFloatSwaptionUnderlyingSwap :: (FloatFloatSwaption) -> IO ((FloatFloatSwap))
qlFloatFloatSwaptionUnderlyingSwap a1 =
  withFloatFloatSwaption a1 $ \a1' -> 
  preErrorCheck $ \a2' -> 
  qlFloatFloatSwaptionUnderlyingSwap'_ a1' a2' >>= \res ->
  peekFloatFloatSwap res >>= \res' ->
  errorCheck  a2'>>
  return (res')

{-# LINE 1146 "./QuantLib/Instrument/Swap.chs" #-}

qlIrregularSwaptionUnderlyingSwap :: (IrregularSwaption) -> IO ((IrregularSwap))
qlIrregularSwaptionUnderlyingSwap a1 =
  withIrregularSwaption a1 $ \a1' -> 
  preErrorCheck $ \a2' -> 
  qlIrregularSwaptionUnderlyingSwap'_ a1' a2' >>= \res ->
  peekIrregularSwap res >>= \res' ->
  errorCheck  a2'>>
  return (res')

{-# LINE 1147 "./QuantLib/Instrument/Swap.chs" #-}

qlCdsOptionUnderlyingSwap :: (CdsOption) -> IO ((CreditDefaultSwap))
qlCdsOptionUnderlyingSwap a1 =
  withCdsOption a1 $ \a1' -> 
  preErrorCheck $ \a2' -> 
  qlCdsOptionUnderlyingSwap'_ a1' a2' >>= \res ->
  peekCreditDefaultSwap res >>= \res' ->
  errorCheck  a2'>>
  return (res')

{-# LINE 1148 "./QuantLib/Instrument/Swap.chs" #-}


class HasFloatingLeg a where
  floatingLeg :: a -> IO Leg
  floatingLegBps :: a -> IO Double
  floatingLegNpv :: a -> IO Double
instance HasFloatingLeg (GenFixedVsFloatingSwap f) where
  floatingLeg = qlFixedVsFloatingSwapFloatingLeg
  floatingLegBps = qlFixedVsFloatingSwapFloatingLegBPS
  floatingLegNpv = qlFixedVsFloatingSwapFloatingLegNPV
instance HasFloatingLeg AssetSwap where
  floatingLeg :: AssetSwap -> IO Leg
floatingLeg = AssetSwap -> IO Leg
qlAssetSwapFloatingLeg
  floatingLegBps :: AssetSwap -> IO Double
floatingLegBps = AssetSwap -> IO Double
qlAssetSwapFloatingLegBPS
  floatingLegNpv :: AssetSwap -> IO Double
floatingLegNpv = AssetSwap -> IO Double
qlAssetSwapFloatingLegNPV

-- |The spread that would make the swap's NPV zero.
qlFixedVsFloatingSwapFairSpread :: (GenFixedVsFloatingSwap f) -> IO ((Double))
qlFixedVsFloatingSwapFairSpread :: forall f. GenFixedVsFloatingSwap f -> IO Double
qlFixedVsFloatingSwapFairSpread GenFixedVsFloatingSwap f
a1 =
  GenFixedVsFloatingSwap f
-> (Ptr CFixedVsFloatingSwap' -> IO Double) -> IO Double
forall f b.
GenFixedVsFloatingSwap f
-> (Ptr CFixedVsFloatingSwap' -> IO b) -> IO b
withFixedVsFloatingSwap GenFixedVsFloatingSwap f
a1 ((Ptr CFixedVsFloatingSwap' -> IO Double) -> IO Double)
-> (Ptr CFixedVsFloatingSwap' -> IO Double) -> IO Double
forall a b. (a -> b) -> a -> b
$ \Ptr CFixedVsFloatingSwap'
a1' -> 
  (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)
a2' -> 
  Ptr CFixedVsFloatingSwap' -> Ptr (Ptr CChar) -> IO CDouble
qlFixedVsFloatingSwapFairSpread'_ Ptr CFixedVsFloatingSwap'
a1' Ptr (Ptr CChar)
a2' 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)
a2'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 1164 "./QuantLib/Instrument/Swap.chs" #-}


-- |The spread that would make the swap's NPV zero.
qlAssetSwapFairSpread :: (AssetSwap) -> IO ((Double))
qlAssetSwapFairSpread a1 =
  withAssetSwap a1 $ \a1' -> 
  preErrorCheck $ \a2' -> 
  qlAssetSwapFairSpread'_ a1' a2' >>= \res ->
  let {res' = realToFrac res} in
  errorCheck  a2'>>
  return (res')

{-# LINE 1167 "./QuantLib/Instrument/Swap.chs" #-}


-- |The fixed rate that would make the swap's NPV zero.
qlFixedVsFloatingSwapFairRate :: (GenFixedVsFloatingSwap f) -> IO ((Double))
qlFixedVsFloatingSwapFairRate a1 =
  withFixedVsFloatingSwap a1 $ \a1' -> 
  preErrorCheck $ \a2' -> 
  qlFixedVsFloatingSwapFairRate'_ a1' a2' >>= \res ->
  let {res' = realToFrac res} in
  errorCheck  a2'>>
  return (res')

{-# LINE 1170 "./QuantLib/Instrument/Swap.chs" #-}


-- |The fixed leg's cash flows.
qlFixedVsFloatingSwapFixedLeg :: (GenFixedVsFloatingSwap f) -> IO ((Leg))
qlFixedVsFloatingSwapFixedLeg a1 =
  withFixedVsFloatingSwap a1 $ \a1' -> 
  preErrorCheck $ \a2' -> 
  qlFixedVsFloatingSwapFixedLeg'_ a1' a2' >>= \res ->
  peekLeg res >>= \res' ->
  errorCheck  a2'>>
  return (res')

{-# LINE 1173 "./QuantLib/Instrument/Swap.chs" #-}


-- |Basis-point sensitivity of the fixed leg.
qlFixedVsFloatingSwapFixedLegBPS :: (GenFixedVsFloatingSwap f) -> IO ((Double))
qlFixedVsFloatingSwapFixedLegBPS a1 =
  withFixedVsFloatingSwap a1 $ \a1' -> 
  preErrorCheck $ \a2' -> 
  qlFixedVsFloatingSwapFixedLegBPS'_ a1' a2' >>= \res ->
  let {res' = realToFrac res} in
  errorCheck  a2'>>
  return (res')

{-# LINE 1176 "./QuantLib/Instrument/Swap.chs" #-}


-- |NPV of the fixed leg.
qlFixedVsFloatingSwapFixedLegNPV :: (GenFixedVsFloatingSwap f) -> IO ((Double))
qlFixedVsFloatingSwapFixedLegNPV a1 =
  withFixedVsFloatingSwap a1 $ \a1' -> 
  preErrorCheck $ \a2' -> 
  qlFixedVsFloatingSwapFixedLegNPV'_ a1' a2' >>= \res ->
  let {res' = realToFrac res} in
  errorCheck  a2'>>
  return (res')

{-# LINE 1179 "./QuantLib/Instrument/Swap.chs" #-}


-- |The fixed rate that would make the swap's NPV zero.
qlOvernightIndexedSwapFairRate :: (OvernightIndexedSwap) -> IO ((Double))
qlOvernightIndexedSwapFairRate a1 =
  withOvernightIndexedSwap a1 $ \a1' -> 
  preErrorCheck $ \a2' -> 
  qlOvernightIndexedSwapFairRate'_ a1' a2' >>= \res ->
  let {res' = realToFrac res} in
  errorCheck  a2'>>
  return (res')

{-# LINE 1182 "./QuantLib/Instrument/Swap.chs" #-}


-- |The fixed leg's cash flows.
qlOvernightIndexedSwapFixedLeg :: (OvernightIndexedSwap) -> IO ((Leg))
qlOvernightIndexedSwapFixedLeg a1 =
  withOvernightIndexedSwap a1 $ \a1' -> 
  preErrorCheck $ \a2' -> 
  qlOvernightIndexedSwapFixedLeg'_ a1' a2' >>= \res ->
  peekLeg res >>= \res' ->
  errorCheck  a2'>>
  return (res')

{-# LINE 1185 "./QuantLib/Instrument/Swap.chs" #-}


-- |Basis-point sensitivity of the fixed leg.
qlOvernightIndexedSwapFixedLegBPS :: (OvernightIndexedSwap) -> IO ((Double))
qlOvernightIndexedSwapFixedLegBPS a1 =
  withOvernightIndexedSwap a1 $ \a1' -> 
  preErrorCheck $ \a2' -> 
  qlOvernightIndexedSwapFixedLegBPS'_ a1' a2' >>= \res ->
  let {res' = realToFrac res} in
  errorCheck  a2'>>
  return (res')

{-# LINE 1188 "./QuantLib/Instrument/Swap.chs" #-}


-- |NPV of the fixed leg.
qlOvernightIndexedSwapFixedLegNPV :: (OvernightIndexedSwap) -> IO ((Double))
qlOvernightIndexedSwapFixedLegNPV a1 =
  withOvernightIndexedSwap a1 $ \a1' -> 
  preErrorCheck $ \a2' -> 
  qlOvernightIndexedSwapFixedLegNPV'_ a1' a2' >>= \res ->
  let {res' = realToFrac res} in
  errorCheck  a2'>>
  return (res')

{-# LINE 1191 "./QuantLib/Instrument/Swap.chs" #-}


-- |The spread that would make the swap's NPV zero.
qlOvernightIndexedSwapFairSpread :: (OvernightIndexedSwap) -> IO ((Double))
qlOvernightIndexedSwapFairSpread a1 =
  withOvernightIndexedSwap a1 $ \a1' -> 
  preErrorCheck $ \a2' -> 
  qlOvernightIndexedSwapFairSpread'_ a1' a2' >>= \res ->
  let {res' = realToFrac res} in
  errorCheck  a2'>>
  return (res')

{-# LINE 1194 "./QuantLib/Instrument/Swap.chs" #-}


-- |Returns the running spread that, given the quoted recovery rate, will make the running-only CDS have an NPV of 0.This calculation does not take any upfront into account, even if one was given.
qlCreditDefaultSwapFairSpread :: (CreditDefaultSwap) -> IO ((Double))
qlCreditDefaultSwapFairSpread a1 =
  withGenInstrument a1 $ \a1' -> 
  preErrorCheck $ \a2' -> 
  qlCreditDefaultSwapFairSpread'_ a1' a2' >>= \res ->
  let {res' = realToFrac res} in
  errorCheck  a2'>>
  return (res')

{-# LINE 1197 "./QuantLib/Instrument/Swap.chs" #-}


-- |The floating leg's cash flows.
qlFixedVsFloatingSwapFloatingLeg :: (GenFixedVsFloatingSwap f) -> IO ((Leg))
qlFixedVsFloatingSwapFloatingLeg a1 =
  withFixedVsFloatingSwap a1 $ \a1' -> 
  preErrorCheck $ \a2' -> 
  qlFixedVsFloatingSwapFloatingLeg'_ a1' a2' >>= \res ->
  peekLeg res >>= \res' ->
  errorCheck  a2'>>
  return (res')

{-# LINE 1200 "./QuantLib/Instrument/Swap.chs" #-}


-- |Basis-point sensitivity of the floating leg.
qlFixedVsFloatingSwapFloatingLegBPS :: (GenFixedVsFloatingSwap f) -> IO ((Double))
qlFixedVsFloatingSwapFloatingLegBPS a1 =
  withFixedVsFloatingSwap a1 $ \a1' -> 
  preErrorCheck $ \a2' -> 
  qlFixedVsFloatingSwapFloatingLegBPS'_ a1' a2' >>= \res ->
  let {res' = realToFrac res} in
  errorCheck  a2'>>
  return (res')

{-# LINE 1203 "./QuantLib/Instrument/Swap.chs" #-}


-- |NPV of the floating leg.
qlFixedVsFloatingSwapFloatingLegNPV :: (GenFixedVsFloatingSwap f) -> IO ((Double))
qlFixedVsFloatingSwapFloatingLegNPV a1 =
  withFixedVsFloatingSwap a1 $ \a1' -> 
  preErrorCheck $ \a2' -> 
  qlFixedVsFloatingSwapFloatingLegNPV'_ a1' a2' >>= \res ->
  let {res' = realToFrac res} in
  errorCheck  a2'>>
  return (res')

{-# LINE 1206 "./QuantLib/Instrument/Swap.chs" #-}


-- |The floating leg's cash flows.
qlAssetSwapFloatingLeg :: (AssetSwap) -> IO ((Leg))
qlAssetSwapFloatingLeg a1 =
  withAssetSwap a1 $ \a1' -> 
  preErrorCheck $ \a2' -> 
  qlAssetSwapFloatingLeg'_ a1' a2' >>= \res ->
  peekLeg res >>= \res' ->
  errorCheck  a2'>>
  return (res')

{-# LINE 1209 "./QuantLib/Instrument/Swap.chs" #-}


-- |Basis-point sensitivity of the floating leg.
qlAssetSwapFloatingLegBPS :: (AssetSwap) -> IO ((Double))
qlAssetSwapFloatingLegBPS a1 =
  withAssetSwap a1 $ \a1' -> 
  preErrorCheck $ \a2' -> 
  qlAssetSwapFloatingLegBPS'_ a1' a2' >>= \res ->
  let {res' = realToFrac res} in
  errorCheck  a2'>>
  return (res')

{-# LINE 1212 "./QuantLib/Instrument/Swap.chs" #-}


-- |NPV of the floating leg.
qlAssetSwapFloatingLegNPV :: (AssetSwap) -> IO ((Double))
qlAssetSwapFloatingLegNPV a1 =
  withAssetSwap a1 $ \a1' -> 
  preErrorCheck $ \a2' -> 
  qlAssetSwapFloatingLegNPV'_ a1' a2' >>= \res ->
  let {res' = realToFrac res} in
  errorCheck  a2'>>
  return (res')

{-# LINE 1215 "./QuantLib/Instrument/Swap.chs" #-}



{-# LINE 1217 "./QuantLib/Instrument/Swap.chs" #-}


-- |Variance swap: pays off the difference between realized and strike variance, scaled by notional. This class does not manage seasoned variance swaps.
varianceSwap :: (PositionType) -> (Double) -- ^strike
 -> (Double) -- ^notional
 -> (Day) -- ^startDate
 -> (Day) -- ^maturityDate
 -> IO ((VarianceSwap))
varianceSwap :: PositionType -> Double -> Double -> Day -> Day -> IO VarianceSwap
varianceSwap PositionType
a1 Double
a2 Double
a3 Day
a4 Day
a5 =
  let {a1' :: CInt
a1' = PositionType -> CInt
forall a b. (Enum a, Integral b) => a -> b
fromEnumC PositionType
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 
  Day -> (CInt -> IO VarianceSwap) -> IO VarianceSwap
forall a. Day -> (CInt -> IO a) -> IO a
withDay Day
a4 ((CInt -> IO VarianceSwap) -> IO VarianceSwap)
-> (CInt -> IO VarianceSwap) -> IO VarianceSwap
forall a b. (a -> b) -> a -> b
$ \CInt
a4' -> 
  Day -> (CInt -> IO VarianceSwap) -> IO VarianceSwap
forall a. Day -> (CInt -> IO a) -> IO a
withDay Day
a5 ((CInt -> IO VarianceSwap) -> IO VarianceSwap)
-> (CInt -> IO VarianceSwap) -> IO VarianceSwap
forall a b. (a -> b) -> a -> b
$ \CInt
a5' -> 
  (Ptr (Ptr CChar) -> IO VarianceSwap) -> IO VarianceSwap
forall a b. (Ptr (Ptr a) -> IO b) -> IO b
preErrorCheck ((Ptr (Ptr CChar) -> IO VarianceSwap) -> IO VarianceSwap)
-> (Ptr (Ptr CChar) -> IO VarianceSwap) -> IO VarianceSwap
forall a b. (a -> b) -> a -> b
$ \Ptr (Ptr CChar)
a6' -> 
  CInt
-> CDouble
-> CDouble
-> CInt
-> CInt
-> Ptr (Ptr CChar)
-> IO (Ptr CVarianceSwap')
varianceSwap'_ CInt
a1' CDouble
a2' CDouble
a3' CInt
a4' CInt
a5' Ptr (Ptr CChar)
a6' IO (Ptr CVarianceSwap')
-> (Ptr CVarianceSwap' -> IO VarianceSwap) -> IO VarianceSwap
forall a b. IO a -> (a -> IO b) -> IO b
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= \Ptr CVarianceSwap'
res ->
  Ptr CVarianceSwap' -> IO VarianceSwap
peekVarianceSwap Ptr CVarianceSwap'
res IO VarianceSwap
-> (VarianceSwap -> IO VarianceSwap) -> IO VarianceSwap
forall a b. IO a -> (a -> IO b) -> IO b
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= \VarianceSwap
res' ->
  Ptr (Ptr CChar) -> IO ()
errorCheck  Ptr (Ptr CChar)
a6'IO () -> IO VarianceSwap -> IO VarianceSwap
forall a b. IO a -> IO b -> IO b
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>>
  VarianceSwap -> IO VarianceSwap
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return (VarianceSwap
res')

{-# LINE 1224 "./QuantLib/Instrument/Swap.chs" #-}


-- |Realized variance -- requires a pricing engine to be set first
variance :: (VarianceSwap) -> IO ((Double))
variance a1 =
  withGenInstrument a1 $ \a1' -> 
  preErrorCheck $ \a2' -> 
  variance'_ a1' a2' >>= \res ->
  let {res' = realToFrac res} in
  errorCheck  a2'>>
  return (res')

{-# LINE 1227 "./QuantLib/Instrument/Swap.chs" #-}



{-# LINE 1229 "./QuantLib/Instrument/Swap.chs" #-}


{-# LINE 1230 "./QuantLib/Instrument/Swap.chs" #-}


-- |Variance option: an option on realized variance, priced (e.g. via 'integralHestonVarianceOptionEngine')
-- against a payoff on the variance level rather than the underlying price. This class does not
-- manage seasoned variance options.
varianceOption :: (Payoff) -> (Double) -- ^notional
 -> (Day) -- ^startDate
 -> (Day) -- ^maturityDate
 -> IO ((VarianceOption))
varianceOption :: Payoff -> Double -> Day -> Day -> IO VarianceOption
varianceOption Payoff
a1 Double
a2 Day
a3 Day
a4 =
  Payoff -> (QlPayoff -> IO VarianceOption) -> IO VarianceOption
forall a. Payoff -> (QlPayoff -> IO a) -> IO a
withPayoff Payoff
a1 ((QlPayoff -> IO VarianceOption) -> IO VarianceOption)
-> (QlPayoff -> IO VarianceOption) -> IO VarianceOption
forall a b. (a -> b) -> a -> b
$ \QlPayoff
a1' -> 
  let {a2' :: CDouble
a2' = Double -> CDouble
forall a b. (Real a, Fractional b) => a -> b
realToFrac Double
a2} in 
  Day -> (CInt -> IO VarianceOption) -> IO VarianceOption
forall a. Day -> (CInt -> IO a) -> IO a
withDay Day
a3 ((CInt -> IO VarianceOption) -> IO VarianceOption)
-> (CInt -> IO VarianceOption) -> IO VarianceOption
forall a b. (a -> b) -> a -> b
$ \CInt
a3' -> 
  Day -> (CInt -> IO VarianceOption) -> IO VarianceOption
forall a. Day -> (CInt -> IO a) -> IO a
withDay Day
a4 ((CInt -> IO VarianceOption) -> IO VarianceOption)
-> (CInt -> IO VarianceOption) -> IO VarianceOption
forall a b. (a -> b) -> a -> b
$ \CInt
a4' -> 
  (Ptr (Ptr CChar) -> IO VarianceOption) -> IO VarianceOption
forall a b. (Ptr (Ptr a) -> IO b) -> IO b
preErrorCheck ((Ptr (Ptr CChar) -> IO VarianceOption) -> IO VarianceOption)
-> (Ptr (Ptr CChar) -> IO VarianceOption) -> IO VarianceOption
forall a b. (a -> b) -> a -> b
$ \Ptr (Ptr CChar)
a5' -> 
  QlPayoff
-> CDouble
-> CInt
-> CInt
-> Ptr (Ptr CChar)
-> IO (Ptr CVarianceOption')
varianceOption'_ QlPayoff
a1' CDouble
a2' CInt
a3' CInt
a4' Ptr (Ptr CChar)
a5' IO (Ptr CVarianceOption')
-> (Ptr CVarianceOption' -> IO VarianceOption) -> IO VarianceOption
forall a b. IO a -> (a -> IO b) -> IO b
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= \Ptr CVarianceOption'
res ->
  Ptr CVarianceOption' -> IO VarianceOption
peekVarianceOption Ptr CVarianceOption'
res IO VarianceOption
-> (VarianceOption -> IO VarianceOption) -> IO VarianceOption
forall a b. IO a -> (a -> IO b) -> IO b
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= \VarianceOption
res' ->
  Ptr (Ptr CChar) -> IO ()
errorCheck  Ptr (Ptr CChar)
a5'IO () -> IO VarianceOption -> IO VarianceOption
forall a b. IO a -> IO b -> IO b
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>>
  VarianceOption -> IO VarianceOption
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return (VarianceOption
res')

{-# LINE 1239 "./QuantLib/Instrument/Swap.chs" #-}


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

foreign import ccall safe "QuantLib/Instrument/Swap.chs.h qlSwaptionImpliedVolatility"
  impliedVolatility'_ :: ((C2HSImp.Ptr (CSwaption')) -> (C2HSImp.CDouble -> ((C2HSImp.Ptr (CYieldTermStructure')) -> (C2HSImp.CDouble -> (C2HSImp.CDouble -> (C2HSImp.CUInt -> (C2HSImp.CDouble -> (C2HSImp.CDouble -> (C2HSImp.CInt -> (C2HSImp.CDouble -> (C2HSImp.CInt -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO C2HSImp.CDouble)))))))))))))

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

foreign import ccall safe "QuantLib/Instrument/Swap.chs.h qlBMASwap"
  bmaSwap'_ :: (C2HSImp.CInt -> (C2HSImp.CDouble -> ((C2HSImp.Ptr (CSchedule)) -> (C2HSImp.CDouble -> (C2HSImp.CDouble -> ((C2HSImp.Ptr (CIborIndex')) -> ((C2HSImp.Ptr (CDayCounter)) -> ((C2HSImp.Ptr (CSchedule)) -> ((C2HSImp.Ptr (CBMAIndex')) -> ((C2HSImp.Ptr (CDayCounter)) -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO (C2HSImp.Ptr (CBMASwap'))))))))))))))

foreign import ccall safe "QuantLib/Instrument/Swap.chs.h qlVanillaSwap"
  vanillaSwap'_ :: (C2HSImp.CInt -> (C2HSImp.CDouble -> ((C2HSImp.Ptr (CSchedule)) -> (C2HSImp.CDouble -> ((C2HSImp.Ptr (CDayCounter)) -> ((C2HSImp.Ptr (CSchedule)) -> ((C2HSImp.Ptr (CIborIndex')) -> (C2HSImp.CDouble -> ((C2HSImp.Ptr (CDayCounter)) -> (C2HSImp.CInt -> (C2HSImp.CInt -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO (C2HSImp.Ptr (CVanillaSwap')))))))))))))))

foreign import ccall safe "QuantLib/Instrument/Swap.chs.h qlNonstandardSwap1"
  nonstandardSwapFromVanilla'_ :: ((C2HSImp.Ptr (CFixedVsFloatingSwap')) -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO (C2HSImp.Ptr (CNonstandardSwap')))))

foreign import ccall safe "QuantLib/Instrument/Swap.chs.h qlNonstandardSwap"
  nonstandardSwap'_ :: (C2HSImp.CInt -> (C2HSImp.CUInt -> ((C2HSImp.Ptr C2HSImp.CDouble) -> (C2HSImp.CUInt -> ((C2HSImp.Ptr C2HSImp.CDouble) -> ((C2HSImp.Ptr (CSchedule)) -> (C2HSImp.CUInt -> ((C2HSImp.Ptr C2HSImp.CDouble) -> ((C2HSImp.Ptr (CDayCounter)) -> ((C2HSImp.Ptr (CSchedule)) -> ((C2HSImp.Ptr (CIborIndex')) -> (C2HSImp.CDouble -> (C2HSImp.CDouble -> ((C2HSImp.Ptr (CDayCounter)) -> (C2HSImp.CInt -> (C2HSImp.CInt -> (C2HSImp.CInt -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO (C2HSImp.Ptr (CNonstandardSwap')))))))))))))))))))))

foreign import ccall safe "QuantLib/Instrument/Swap.chs.h qlNonstandardSwap2"
  nonstandardSwapFromGearingsAndSpreads'_ :: (C2HSImp.CInt -> (C2HSImp.CUInt -> ((C2HSImp.Ptr C2HSImp.CDouble) -> (C2HSImp.CUInt -> ((C2HSImp.Ptr C2HSImp.CDouble) -> ((C2HSImp.Ptr (CSchedule)) -> (C2HSImp.CUInt -> ((C2HSImp.Ptr C2HSImp.CDouble) -> ((C2HSImp.Ptr (CDayCounter)) -> ((C2HSImp.Ptr (CSchedule)) -> ((C2HSImp.Ptr (CIborIndex')) -> (C2HSImp.CUInt -> ((C2HSImp.Ptr C2HSImp.CDouble) -> (C2HSImp.CUInt -> ((C2HSImp.Ptr C2HSImp.CDouble) -> ((C2HSImp.Ptr (CDayCounter)) -> (C2HSImp.CInt -> (C2HSImp.CInt -> (C2HSImp.CInt -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO (C2HSImp.Ptr (CNonstandardSwap')))))))))))))))))))))))

foreign import ccall safe "QuantLib/Instrument/Swap.chs.h qlNonstandardSwapFixedRate"
  nonstandardSwapFixedRate'_ :: ((C2HSImp.Ptr (CNonstandardSwap')) -> ((C2HSImp.Ptr C2HSImp.CUInt) -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CDouble)) -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO ())))))

foreign import ccall safe "QuantLib/Instrument/Swap.chs.h qlFloatFloatSwap"
  floatFloatSwap_'_ :: (C2HSImp.CInt -> (C2HSImp.CDouble -> (C2HSImp.CDouble -> ((C2HSImp.Ptr (CSchedule)) -> ((C2HSImp.Ptr (CInterestRateIndex')) -> ((C2HSImp.Ptr (CDayCounter)) -> ((C2HSImp.Ptr (CSchedule)) -> ((C2HSImp.Ptr (CInterestRateIndex')) -> ((C2HSImp.Ptr (CDayCounter)) -> (C2HSImp.CInt -> (C2HSImp.CInt -> (C2HSImp.CDouble -> (C2HSImp.CDouble -> (C2HSImp.CDouble -> (C2HSImp.CDouble -> (C2HSImp.CDouble -> (C2HSImp.CDouble -> (C2HSImp.CDouble -> (C2HSImp.CDouble -> (C2HSImp.CInt -> (C2HSImp.CInt -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO (C2HSImp.Ptr (CFloatFloatSwap')))))))))))))))))))))))))

foreign import ccall safe "QuantLib/Instrument/Swap.chs.h qlFloatFloatSwap2"
  floatFloatSwap2_'_ :: (C2HSImp.CInt -> (C2HSImp.CUInt -> ((C2HSImp.Ptr C2HSImp.CDouble) -> (C2HSImp.CUInt -> ((C2HSImp.Ptr C2HSImp.CDouble) -> ((C2HSImp.Ptr (CSchedule)) -> ((C2HSImp.Ptr (CInterestRateIndex')) -> ((C2HSImp.Ptr (CDayCounter)) -> ((C2HSImp.Ptr (CSchedule)) -> ((C2HSImp.Ptr (CInterestRateIndex')) -> ((C2HSImp.Ptr (CDayCounter)) -> (C2HSImp.CInt -> (C2HSImp.CInt -> (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.CUInt -> ((C2HSImp.Ptr C2HSImp.CDouble) -> (C2HSImp.CUInt -> ((C2HSImp.Ptr C2HSImp.CDouble) -> (C2HSImp.CUInt -> ((C2HSImp.Ptr C2HSImp.CDouble) -> (C2HSImp.CUInt -> ((C2HSImp.Ptr C2HSImp.CDouble) -> (C2HSImp.CInt -> (C2HSImp.CInt -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO (C2HSImp.Ptr (CFloatFloatSwap')))))))))))))))))))))))))))))))))))

foreign import ccall safe "QuantLib/Instrument/Swap.chs.h qlFloatFloatSwapFairSpread1"
  firstLegFairSpread'_ :: ((C2HSImp.Ptr (CFloatFloatSwap')) -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO C2HSImp.CDouble)))

foreign import ccall safe "QuantLib/Instrument/Swap.chs.h qlFloatFloatSwapFairSpread2"
  secondLegFairSpread'_ :: ((C2HSImp.Ptr (CFloatFloatSwap')) -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO C2HSImp.CDouble)))

foreign import ccall safe "QuantLib/Instrument/Swap.chs.h qlSwap"
  swap'_ :: ((C2HSImp.Ptr (CLeg')) -> ((C2HSImp.Ptr (CLeg')) -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO (C2HSImp.Ptr (CSwap'))))))

foreign import ccall safe "QuantLib/Instrument/Swap.chs.h qlSwapEndDiscounts"
  endDiscounts'_ :: ((C2HSImp.Ptr (CSwap')) -> (C2HSImp.CUInt -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO C2HSImp.CDouble))))

foreign import ccall safe "QuantLib/Instrument/Swap.chs.h qlSwapNumberOfLegs"
  numberOfLegs'_ :: ((C2HSImp.Ptr (CSwap')) -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO C2HSImp.CUInt)))

foreign import ccall safe "QuantLib/Instrument/Swap.chs.h qlSwapLeg"
  leg'_ :: ((C2HSImp.Ptr (CSwap')) -> (C2HSImp.CUInt -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO (C2HSImp.Ptr (CLeg'))))))

foreign import ccall safe "QuantLib/Instrument/Swap.chs.h qlSwapLegBPS"
  legBps'_ :: ((C2HSImp.Ptr (CSwap')) -> (C2HSImp.CUInt -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO C2HSImp.CDouble))))

foreign import ccall safe "QuantLib/Instrument/Swap.chs.h qlSwapLegNPV"
  legNpv'_ :: ((C2HSImp.Ptr (CSwap')) -> (C2HSImp.CUInt -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO C2HSImp.CDouble))))

foreign import ccall safe "QuantLib/Instrument/Swap.chs.h qlSwapStartDiscounts"
  startDiscounts'_ :: ((C2HSImp.Ptr (CSwap')) -> (C2HSImp.CUInt -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO C2HSImp.CDouble))))

foreign import ccall safe "QuantLib/Instrument/Swap.chs.h qlConstNotionalCrossCurrencySwap"
  constNotionalCrossCurrencySwap'_ :: ((C2HSImp.Ptr (CLeg')) -> ((C2HSImp.Ptr (CCurrency)) -> ((C2HSImp.Ptr (CLeg')) -> ((C2HSImp.Ptr (CCurrency)) -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO (C2HSImp.Ptr (CConstNotionalCrossCurrencySwap'))))))))

foreign import ccall safe "QuantLib/Instrument/Swap.chs.h qlConstNotionalCrossCurrencySwap1"
  qlConstNotionalCrossCurrencySwap1'_ :: (C2HSImp.CUInt -> ((C2HSImp.Ptr (C2HSImp.Ptr (CLeg'))) -> (C2HSImp.CUInt -> ((C2HSImp.Ptr C2HSImp.CInt) -> (C2HSImp.CUInt -> ((C2HSImp.Ptr (C2HSImp.Ptr (CCurrency))) -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO (C2HSImp.Ptr (CConstNotionalCrossCurrencySwap'))))))))))

foreign import ccall safe "QuantLib/Instrument/Swap.chs.h qlConstNotionalCrossCurrencySwapLegCurrency"
  legCurrency'_ :: ((C2HSImp.Ptr (CConstNotionalCrossCurrencySwap')) -> (C2HSImp.CUInt -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO (C2HSImp.Ptr (CCurrency))))))

foreign import ccall safe "QuantLib/Instrument/Swap.chs.h qlConstNotionalCrossCurrencySwapInCcyLegBPS"
  inCcyLegBps'_ :: ((C2HSImp.Ptr (CConstNotionalCrossCurrencySwap')) -> (C2HSImp.CUInt -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO C2HSImp.CDouble))))

foreign import ccall safe "QuantLib/Instrument/Swap.chs.h qlConstNotionalCrossCurrencySwapInCcyLegNPV"
  inCcyLegNpv'_ :: ((C2HSImp.Ptr (CConstNotionalCrossCurrencySwap')) -> (C2HSImp.CUInt -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO C2HSImp.CDouble))))

foreign import ccall safe "QuantLib/Instrument/Swap.chs.h qlConstNotionalCrossCurrencySwapNpvDateDiscounts"
  npvDateDiscounts'_ :: ((C2HSImp.Ptr (CConstNotionalCrossCurrencySwap')) -> (C2HSImp.CUInt -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO C2HSImp.CDouble))))

foreign import ccall safe "QuantLib/Instrument/Swap.chs.h qlConstNotionalCrossCurrencyBasisSwap"
  constNotionalCrossCurrencyBasisSwap_'_ :: (C2HSImp.CDouble -> ((C2HSImp.Ptr (CCurrency)) -> ((C2HSImp.Ptr (CSchedule)) -> ((C2HSImp.Ptr (CIborIndex')) -> (C2HSImp.CDouble -> (C2HSImp.CDouble -> (C2HSImp.CDouble -> ((C2HSImp.Ptr (CCurrency)) -> ((C2HSImp.Ptr (CSchedule)) -> ((C2HSImp.Ptr (CIborIndex')) -> (C2HSImp.CDouble -> (C2HSImp.CDouble -> (C2HSImp.CInt -> (C2HSImp.CInt -> (C2HSImp.CInt -> (C2HSImp.CUInt -> (C2HSImp.CInt -> (C2HSImp.CUInt -> (C2HSImp.CInt -> (C2HSImp.CInt -> (C2HSImp.CUInt -> (C2HSImp.CInt -> (C2HSImp.CUInt -> (C2HSImp.CInt -> (C2HSImp.CInt -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO (C2HSImp.Ptr (CConstNotionalCrossCurrencyBasisSwap')))))))))))))))))))))))))))))

foreign import ccall safe "QuantLib/Instrument/Swap.chs.h qlConstNotionalCrossCurrencyBasisSwapFairPaySpread"
  fairPaySpread'_ :: ((C2HSImp.Ptr (CConstNotionalCrossCurrencyBasisSwap')) -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO C2HSImp.CDouble)))

foreign import ccall safe "QuantLib/Instrument/Swap.chs.h qlConstNotionalCrossCurrencyBasisSwapFairRecSpread"
  fairRecSpread'_ :: ((C2HSImp.Ptr (CConstNotionalCrossCurrencyBasisSwap')) -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO C2HSImp.CDouble)))

foreign import ccall safe "QuantLib/Instrument/Swap.chs.h qlConstNotionalCrossCurrencyFixedVsFloatingSwap"
  constNotionalCrossCurrencyFixedVsFloatingSwapRaw'_ :: (C2HSImp.CInt -> (C2HSImp.CDouble -> ((C2HSImp.Ptr (CCurrency)) -> ((C2HSImp.Ptr (CSchedule)) -> (C2HSImp.CDouble -> ((C2HSImp.Ptr (CDayCounter)) -> (C2HSImp.CInt -> (C2HSImp.CUInt -> ((C2HSImp.Ptr (CCalendar)) -> (C2HSImp.CDouble -> ((C2HSImp.Ptr (CCurrency)) -> ((C2HSImp.Ptr (CSchedule)) -> ((C2HSImp.Ptr (CIborIndex')) -> (C2HSImp.CDouble -> (C2HSImp.CInt -> (C2HSImp.CUInt -> ((C2HSImp.Ptr (CCalendar)) -> (C2HSImp.CInt -> (C2HSImp.CInt -> (C2HSImp.CUInt -> (C2HSImp.CInt -> (C2HSImp.CUInt -> (C2HSImp.CInt -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO (C2HSImp.Ptr (CConstNotionalCrossCurrencyFixedVsFloatingSwap')))))))))))))))))))))))))))

foreign import ccall safe "QuantLib/Instrument/Swap.chs.h qlConstNotionalCrossCurrencyFixedVsFloatingSwapFairRate"
  qlConstNotionalCrossCurrencyFixedVsFloatingSwapFairRate'_ :: ((C2HSImp.Ptr (CConstNotionalCrossCurrencyFixedVsFloatingSwap')) -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO C2HSImp.CDouble)))

foreign import ccall safe "QuantLib/Instrument/Swap.chs.h qlConstNotionalCrossCurrencyFixedVsFloatingSwapFairSpread"
  qlConstNotionalCrossCurrencyFixedVsFloatingSwapFairSpread'_ :: ((C2HSImp.Ptr (CConstNotionalCrossCurrencyFixedVsFloatingSwap')) -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO C2HSImp.CDouble)))

foreign import ccall safe "QuantLib/Instrument/Swap.chs.h qlSwaption"
  swaption'_ :: ((C2HSImp.Ptr (CFixedVsFloatingSwap')) -> ((QlExercise) -> (C2HSImp.CInt -> (C2HSImp.CInt -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO (C2HSImp.Ptr (CSwaption'))))))))

foreign import ccall safe "QuantLib/Instrument/Swap.chs.h qlIrregularSwaption"
  irregularSwaption'_ :: ((C2HSImp.Ptr (CIrregularSwap')) -> ((QlExercise) -> (C2HSImp.CInt -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO (C2HSImp.Ptr (CIrregularSwaption')))))))

foreign import ccall safe "QuantLib/Instrument/Swap.chs.h qlIrregularSwap"
  irregularSwap'_ :: (C2HSImp.CInt -> ((C2HSImp.Ptr (CLeg')) -> ((C2HSImp.Ptr (CLeg')) -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO (C2HSImp.Ptr (CIrregularSwap')))))))

foreign import ccall safe "QuantLib/Instrument/Swap.chs.h qlIrregularSwapFairRate"
  qlIrregularSwapFairRate'_ :: ((C2HSImp.Ptr (CIrregularSwap')) -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO C2HSImp.CDouble)))

foreign import ccall safe "QuantLib/Instrument/Swap.chs.h qlIrregularSwapFairSpread"
  qlIrregularSwapFairSpread'_ :: ((C2HSImp.Ptr (CIrregularSwap')) -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO C2HSImp.CDouble)))

foreign import ccall safe "QuantLib/Instrument/Swap.chs.h qlNonstandardSwaption1"
  nonstandardSwaptionFromSwaption'_ :: ((C2HSImp.Ptr (CSwaption')) -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO (C2HSImp.Ptr (CNonstandardSwaption')))))

foreign import ccall safe "QuantLib/Instrument/Swap.chs.h qlNonstandardSwaption"
  nonstandardSwaption'_ :: ((C2HSImp.Ptr (CNonstandardSwap')) -> ((QlExercise) -> (C2HSImp.CInt -> (C2HSImp.CInt -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO (C2HSImp.Ptr (CNonstandardSwaption'))))))))

foreign import ccall safe "QuantLib/Instrument/Swap.chs.h qlNonstandardSwaptionCalibrationBasket"
  calibrationBasket'_ :: ((C2HSImp.Ptr (CNonstandardSwaption')) -> ((C2HSImp.Ptr (CSwapIndex')) -> ((C2HSImp.Ptr (CSwaptionVolatilityStructure')) -> (C2HSImp.CInt -> ((C2HSImp.Ptr C2HSImp.CUInt) -> ((C2HSImp.Ptr (C2HSImp.Ptr (C2HSImp.Ptr (CBlackCalibrationHelper')))) -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO ()))))))))

foreign import ccall safe "QuantLib/Instrument/Swap.chs.h qlFloatFloatSwaption"
  floatFloatSwaption'_ :: ((C2HSImp.Ptr (CFloatFloatSwap')) -> ((QlExercise) -> (C2HSImp.CInt -> (C2HSImp.CInt -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO (C2HSImp.Ptr (CFloatFloatSwaption'))))))))

foreign import ccall safe "QuantLib/Instrument/Swap.chs.h qlFloatFloatSwaptionCalibrationBasket"
  floatFloatSwaptionCalibrationBasket'_ :: ((C2HSImp.Ptr (CFloatFloatSwaption')) -> ((C2HSImp.Ptr (CSwapIndex')) -> ((C2HSImp.Ptr (CSwaptionVolatilityStructure')) -> (C2HSImp.CInt -> ((C2HSImp.Ptr C2HSImp.CUInt) -> ((C2HSImp.Ptr (C2HSImp.Ptr (C2HSImp.Ptr (CBlackCalibrationHelper')))) -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO ()))))))))

foreign import ccall safe "QuantLib/Instrument/Swap.chs.h qlAssetSwap"
  assetSwap'_ :: (C2HSImp.CInt -> ((C2HSImp.Ptr (CBond')) -> (C2HSImp.CDouble -> ((C2HSImp.Ptr (CIborIndex')) -> (C2HSImp.CDouble -> ((C2HSImp.Ptr (CSchedule)) -> ((C2HSImp.Ptr (CDayCounter)) -> (C2HSImp.CInt -> (C2HSImp.CDouble -> (C2HSImp.CDouble -> (C2HSImp.CInt -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO (C2HSImp.Ptr (CAssetSwap')))))))))))))))

foreign import ccall safe "QuantLib/Instrument/Swap.chs.h qlOvernightIndexedSwap"
  overnightIndexedSwapRaw'_ :: (C2HSImp.CInt -> (C2HSImp.CDouble -> ((C2HSImp.Ptr (CSchedule)) -> (C2HSImp.CDouble -> ((C2HSImp.Ptr (CDayCounter)) -> ((C2HSImp.Ptr (COvernightIndex')) -> (C2HSImp.CDouble -> (C2HSImp.CInt -> (C2HSImp.CInt -> ((C2HSImp.Ptr (CCalendar)) -> (C2HSImp.CInt -> (C2HSImp.CInt -> (C2HSImp.CUInt -> (C2HSImp.CUInt -> (C2HSImp.CInt -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO (C2HSImp.Ptr (COvernightIndexedSwap')))))))))))))))))))

foreign import ccall safe "QuantLib/Instrument/Swap.chs.h qlOvernightIndexedSwap1"
  overnightIndexedSwapFromNominalsRaw'_ :: (C2HSImp.CInt -> (C2HSImp.CUInt -> ((C2HSImp.Ptr C2HSImp.CDouble) -> ((C2HSImp.Ptr (CSchedule)) -> (C2HSImp.CDouble -> ((C2HSImp.Ptr (CDayCounter)) -> ((C2HSImp.Ptr (COvernightIndex')) -> (C2HSImp.CDouble -> (C2HSImp.CInt -> (C2HSImp.CInt -> ((C2HSImp.Ptr (CCalendar)) -> (C2HSImp.CInt -> (C2HSImp.CInt -> (C2HSImp.CUInt -> (C2HSImp.CUInt -> (C2HSImp.CInt -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO (C2HSImp.Ptr (COvernightIndexedSwap'))))))))))))))))))))

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

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

foreign import ccall safe "QuantLib/Instrument/Swap.chs.h qlSwapNpvDateDiscount"
  npvDateDiscount'_ :: ((C2HSImp.Ptr (CSwap')) -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO C2HSImp.CDouble)))

foreign import ccall safe "QuantLib/Instrument/Swap.chs.h qlBMASwapBmaLeg"
  bmaLeg'_ :: ((C2HSImp.Ptr (CBMASwap')) -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO (C2HSImp.Ptr (CLeg')))))

foreign import ccall safe "QuantLib/Instrument/Swap.chs.h qlBMASwapBmaLegBPS"
  bmaLegBps'_ :: ((C2HSImp.Ptr (CBMASwap')) -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO C2HSImp.CDouble)))

foreign import ccall safe "QuantLib/Instrument/Swap.chs.h qlBMASwapBmaLegNPV"
  bmaLegNpv'_ :: ((C2HSImp.Ptr (CBMASwap')) -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO C2HSImp.CDouble)))

foreign import ccall safe "QuantLib/Instrument/Swap.chs.h qlBMASwapFairLiborFraction"
  fairLiborFraction'_ :: ((C2HSImp.Ptr (CBMASwap')) -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO C2HSImp.CDouble)))

foreign import ccall safe "QuantLib/Instrument/Swap.chs.h qlBMASwapFairLiborSpread"
  fairLiborSpread'_ :: ((C2HSImp.Ptr (CBMASwap')) -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO C2HSImp.CDouble)))

foreign import ccall safe "QuantLib/Instrument/Swap.chs.h qlBMASwapLiborFraction"
  liborFraction'_ :: ((C2HSImp.Ptr (CBMASwap')) -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO C2HSImp.CDouble)))

foreign import ccall safe "QuantLib/Instrument/Swap.chs.h qlBMASwapLiborLeg"
  liborLeg'_ :: ((C2HSImp.Ptr (CBMASwap')) -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO (C2HSImp.Ptr (CLeg')))))

foreign import ccall safe "QuantLib/Instrument/Swap.chs.h qlBMASwapLiborLegBPS"
  liborLegBps'_ :: ((C2HSImp.Ptr (CBMASwap')) -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO C2HSImp.CDouble)))

foreign import ccall safe "QuantLib/Instrument/Swap.chs.h qlBMASwapLiborLegNPV"
  liborLegNpv'_ :: ((C2HSImp.Ptr (CBMASwap')) -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO C2HSImp.CDouble)))

foreign import ccall safe "QuantLib/Instrument/Swap.chs.h qlAssetSwapBondLeg"
  bondLeg'_ :: ((C2HSImp.Ptr (CAssetSwap')) -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO (C2HSImp.Ptr (CLeg')))))

foreign import ccall safe "QuantLib/Instrument/Swap.chs.h qlAssetSwapCleanPrice"
  cleanPrice'_ :: ((C2HSImp.Ptr (CAssetSwap')) -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO C2HSImp.CDouble)))

foreign import ccall safe "QuantLib/Instrument/Swap.chs.h qlAssetSwapFairCleanPrice"
  fairCleanPrice'_ :: ((C2HSImp.Ptr (CAssetSwap')) -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO C2HSImp.CDouble)))

foreign import ccall safe "QuantLib/Instrument/Swap.chs.h qlAssetSwapFairNonParRepayment"
  fairNonParRepayment'_ :: ((C2HSImp.Ptr (CAssetSwap')) -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO C2HSImp.CDouble)))

foreign import ccall safe "QuantLib/Instrument/Swap.chs.h qlAssetSwapNonParRepayment"
  nonParRepayment'_ :: ((C2HSImp.Ptr (CAssetSwap')) -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO C2HSImp.CDouble)))

foreign import ccall safe "QuantLib/Instrument/Swap.chs.h qlAssetSwapParSwap"
  parSwap'_ :: ((C2HSImp.Ptr (CAssetSwap')) -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO C2HSImp.CInt)))

foreign import ccall safe "QuantLib/Instrument/Swap.chs.h qlAssetSwapPayBondCoupon"
  payBondCoupon'_ :: ((C2HSImp.Ptr (CAssetSwap')) -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO C2HSImp.CInt)))

foreign import ccall safe "QuantLib/Instrument/Swap.chs.h qlOvernightIndexedSwapOvernightLeg"
  overnightLeg'_ :: ((C2HSImp.Ptr (COvernightIndexedSwap')) -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO (C2HSImp.Ptr (CLeg')))))

foreign import ccall safe "QuantLib/Instrument/Swap.chs.h qlOvernightIndexedSwapOvernightLegBPS"
  overnightLegBps'_ :: ((C2HSImp.Ptr (COvernightIndexedSwap')) -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO C2HSImp.CDouble)))

foreign import ccall safe "QuantLib/Instrument/Swap.chs.h qlOvernightIndexedSwapOvernightLegNPV"
  overnightLegNpv'_ :: ((C2HSImp.Ptr (COvernightIndexedSwap')) -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO C2HSImp.CDouble)))

foreign import ccall safe "QuantLib/Instrument/Swap.chs.h qlZeroCouponInflationSwap"
  zeroCouponInflationSwap'_ :: (C2HSImp.CInt -> (C2HSImp.CDouble -> (C2HSImp.CInt -> (C2HSImp.CInt -> ((C2HSImp.Ptr (CCalendar)) -> (C2HSImp.CInt -> ((C2HSImp.Ptr (CDayCounter)) -> (C2HSImp.CDouble -> ((C2HSImp.Ptr (CZeroInflationIndex')) -> (C2HSImp.CInt -> (C2HSImp.CInt -> (C2HSImp.CInt -> (C2HSImp.CInt -> ((C2HSImp.Ptr (CCalendar)) -> (C2HSImp.CInt -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO (C2HSImp.Ptr (CZeroCouponInflationSwap')))))))))))))))))))

foreign import ccall safe "QuantLib/Instrument/Swap.chs.h qlZeroCouponInflationSwapFairRate"
  qlZeroCouponInflationSwapFairRate'_ :: ((C2HSImp.Ptr (CZeroCouponInflationSwap')) -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO C2HSImp.CDouble)))

foreign import ccall safe "QuantLib/Instrument/Swap.chs.h qlYearOnYearInflationSwap"
  yearOnYearInflationSwap'_ :: (C2HSImp.CInt -> (C2HSImp.CDouble -> ((C2HSImp.Ptr (CSchedule)) -> (C2HSImp.CDouble -> ((C2HSImp.Ptr (CDayCounter)) -> ((C2HSImp.Ptr (CSchedule)) -> ((C2HSImp.Ptr (CYoYInflationIndex')) -> (C2HSImp.CInt -> (C2HSImp.CInt -> (C2HSImp.CInt -> (C2HSImp.CDouble -> ((C2HSImp.Ptr (CDayCounter)) -> ((C2HSImp.Ptr (CCalendar)) -> (C2HSImp.CInt -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO (C2HSImp.Ptr (CYearOnYearInflationSwap'))))))))))))))))))

foreign import ccall safe "QuantLib/Instrument/Swap.chs.h qlYearOnYearInflationSwapFairRate"
  qlYearOnYearInflationSwapFairRate'_ :: ((C2HSImp.Ptr (CYearOnYearInflationSwap')) -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO C2HSImp.CDouble)))

foreign import ccall safe "QuantLib/Instrument/Swap.chs.h qlYearOnYearInflationSwapFairSpread"
  qlYearOnYearInflationSwapFairSpread'_ :: ((C2HSImp.Ptr (CYearOnYearInflationSwap')) -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO C2HSImp.CDouble)))

foreign import ccall safe "QuantLib/Instrument/Swap.chs.h qlCPISwap"
  cpiSwap'_ :: (C2HSImp.CInt -> (C2HSImp.CDouble -> (C2HSImp.CInt -> (C2HSImp.CDouble -> ((C2HSImp.Ptr (CDayCounter)) -> ((C2HSImp.Ptr (CSchedule)) -> (C2HSImp.CInt -> (C2HSImp.CUInt -> ((C2HSImp.Ptr (CIborIndex')) -> (C2HSImp.CDouble -> (C2HSImp.CDouble -> ((C2HSImp.Ptr (CDayCounter)) -> ((C2HSImp.Ptr (CSchedule)) -> (C2HSImp.CInt -> (C2HSImp.CInt -> (C2HSImp.CInt -> ((C2HSImp.Ptr (CZeroInflationIndex')) -> (C2HSImp.CInt -> (C2HSImp.CDouble -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO (C2HSImp.Ptr (CCPISwap')))))))))))))))))))))))

foreign import ccall safe "QuantLib/Instrument/Swap.chs.h qlCPISwapFairRate"
  qlCPISwapFairRate'_ :: ((C2HSImp.Ptr (CCPISwap')) -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO C2HSImp.CDouble)))

foreign import ccall safe "QuantLib/Instrument/Swap.chs.h qlCPISwapFairSpread"
  qlCPISwapFairSpread'_ :: ((C2HSImp.Ptr (CCPISwap')) -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO C2HSImp.CDouble)))

foreign import ccall safe "QuantLib/Instrument/Swap.chs.h qlZeroCouponSwap"
  zeroCouponSwap'_ :: (C2HSImp.CInt -> (C2HSImp.CDouble -> (C2HSImp.CInt -> (C2HSImp.CInt -> (C2HSImp.CDouble -> ((C2HSImp.Ptr (CIborIndex')) -> ((C2HSImp.Ptr (CCalendar)) -> (C2HSImp.CInt -> (C2HSImp.CUInt -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO (C2HSImp.Ptr (CZeroCouponSwap')))))))))))))

foreign import ccall safe "QuantLib/Instrument/Swap.chs.h qlZeroCouponSwap1"
  zeroCouponSwapFromRate'_ :: (C2HSImp.CInt -> (C2HSImp.CDouble -> (C2HSImp.CInt -> (C2HSImp.CInt -> (C2HSImp.CDouble -> ((C2HSImp.Ptr (CDayCounter)) -> ((C2HSImp.Ptr (CIborIndex')) -> ((C2HSImp.Ptr (CCalendar)) -> (C2HSImp.CInt -> (C2HSImp.CUInt -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO (C2HSImp.Ptr (CZeroCouponSwap'))))))))))))))

foreign import ccall safe "QuantLib/Instrument/Swap.chs.h qlZeroCouponSwapFairFixedPayment"
  fairFixedPayment'_ :: ((C2HSImp.Ptr (CZeroCouponSwap')) -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO C2HSImp.CDouble)))

foreign import ccall safe "QuantLib/Instrument/Swap.chs.h qlZeroCouponSwapFairFixedRate"
  fairFixedRate'_ :: ((C2HSImp.Ptr (CZeroCouponSwap')) -> ((C2HSImp.Ptr (CDayCounter)) -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO C2HSImp.CDouble))))

foreign import ccall safe "QuantLib/Instrument/Swap.chs.h qlEquityTotalReturnSwapIbor"
  equityTotalReturnSwapIbor'_ :: (C2HSImp.CInt -> (C2HSImp.CDouble -> ((C2HSImp.Ptr (CSchedule)) -> ((C2HSImp.Ptr (CEquityIndex')) -> ((C2HSImp.Ptr (CIborIndex')) -> ((C2HSImp.Ptr (CDayCounter)) -> (C2HSImp.CDouble -> (C2HSImp.CDouble -> ((C2HSImp.Ptr (CCalendar)) -> (C2HSImp.CInt -> (C2HSImp.CUInt -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO (C2HSImp.Ptr (CEquityTotalReturnSwap')))))))))))))))

foreign import ccall safe "QuantLib/Instrument/Swap.chs.h qlEquityTotalReturnSwapOvernight"
  equityTotalReturnSwapOvernight'_ :: (C2HSImp.CInt -> (C2HSImp.CDouble -> ((C2HSImp.Ptr (CSchedule)) -> ((C2HSImp.Ptr (CEquityIndex')) -> ((C2HSImp.Ptr (COvernightIndex')) -> ((C2HSImp.Ptr (CDayCounter)) -> (C2HSImp.CDouble -> (C2HSImp.CDouble -> ((C2HSImp.Ptr (CCalendar)) -> (C2HSImp.CInt -> (C2HSImp.CUInt -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO (C2HSImp.Ptr (CEquityTotalReturnSwap')))))))))))))))

foreign import ccall safe "QuantLib/Instrument/Swap.chs.h qlEquityTotalReturnSwapEquityLegNPV"
  equityLegNpv'_ :: ((C2HSImp.Ptr (CEquityTotalReturnSwap')) -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO C2HSImp.CDouble)))

foreign import ccall safe "QuantLib/Instrument/Swap.chs.h qlEquityTotalReturnSwapInterestRateLegNPV"
  interestRateLegNpv'_ :: ((C2HSImp.Ptr (CEquityTotalReturnSwap')) -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO C2HSImp.CDouble)))

foreign import ccall safe "QuantLib/Instrument/Swap.chs.h qlEquityTotalReturnSwapFairMargin"
  fairMargin'_ :: ((C2HSImp.Ptr (CEquityTotalReturnSwap')) -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO C2HSImp.CDouble)))

foreign import ccall safe "QuantLib/Instrument/Swap.chs.h qlSwaptionUnderlying"
  qlSwaptionUnderlying'_ :: ((C2HSImp.Ptr (CSwaption')) -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO (C2HSImp.Ptr (CFixedVsFloatingSwap')))))

foreign import ccall safe "QuantLib/Instrument/Swap.chs.h qlNonstandardSwaptionUnderlyingSwap"
  qlNonstandardSwaptionUnderlyingSwap'_ :: ((C2HSImp.Ptr (CNonstandardSwaption')) -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO (C2HSImp.Ptr (CNonstandardSwap')))))

foreign import ccall safe "QuantLib/Instrument/Swap.chs.h qlFloatFloatSwaptionUnderlyingSwap"
  qlFloatFloatSwaptionUnderlyingSwap'_ :: ((C2HSImp.Ptr (CFloatFloatSwaption')) -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO (C2HSImp.Ptr (CFloatFloatSwap')))))

foreign import ccall safe "QuantLib/Instrument/Swap.chs.h qlIrregularSwaptionUnderlyingSwap"
  qlIrregularSwaptionUnderlyingSwap'_ :: ((C2HSImp.Ptr (CIrregularSwaption')) -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO (C2HSImp.Ptr (CIrregularSwap')))))

foreign import ccall safe "QuantLib/Instrument/Swap.chs.h qlCdsOptionUnderlyingSwap"
  qlCdsOptionUnderlyingSwap'_ :: ((C2HSImp.Ptr (CCdsOption')) -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO (C2HSImp.Ptr (CCreditDefaultSwap')))))

foreign import ccall safe "QuantLib/Instrument/Swap.chs.h qlFixedVsFloatingSwapFairSpread"
  qlFixedVsFloatingSwapFairSpread'_ :: ((C2HSImp.Ptr (CFixedVsFloatingSwap')) -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO C2HSImp.CDouble)))

foreign import ccall safe "QuantLib/Instrument/Swap.chs.h qlAssetSwapFairSpread"
  qlAssetSwapFairSpread'_ :: ((C2HSImp.Ptr (CAssetSwap')) -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO C2HSImp.CDouble)))

foreign import ccall safe "QuantLib/Instrument/Swap.chs.h qlFixedVsFloatingSwapFairRate"
  qlFixedVsFloatingSwapFairRate'_ :: ((C2HSImp.Ptr (CFixedVsFloatingSwap')) -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO C2HSImp.CDouble)))

foreign import ccall safe "QuantLib/Instrument/Swap.chs.h qlFixedVsFloatingSwapFixedLeg"
  qlFixedVsFloatingSwapFixedLeg'_ :: ((C2HSImp.Ptr (CFixedVsFloatingSwap')) -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO (C2HSImp.Ptr (CLeg')))))

foreign import ccall safe "QuantLib/Instrument/Swap.chs.h qlFixedVsFloatingSwapFixedLegBPS"
  qlFixedVsFloatingSwapFixedLegBPS'_ :: ((C2HSImp.Ptr (CFixedVsFloatingSwap')) -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO C2HSImp.CDouble)))

foreign import ccall safe "QuantLib/Instrument/Swap.chs.h qlFixedVsFloatingSwapFixedLegNPV"
  qlFixedVsFloatingSwapFixedLegNPV'_ :: ((C2HSImp.Ptr (CFixedVsFloatingSwap')) -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO C2HSImp.CDouble)))

foreign import ccall safe "QuantLib/Instrument/Swap.chs.h qlOvernightIndexedSwapFairRate"
  qlOvernightIndexedSwapFairRate'_ :: ((C2HSImp.Ptr (COvernightIndexedSwap')) -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO C2HSImp.CDouble)))

foreign import ccall safe "QuantLib/Instrument/Swap.chs.h qlOvernightIndexedSwapFixedLeg"
  qlOvernightIndexedSwapFixedLeg'_ :: ((C2HSImp.Ptr (COvernightIndexedSwap')) -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO (C2HSImp.Ptr (CLeg')))))

foreign import ccall safe "QuantLib/Instrument/Swap.chs.h qlOvernightIndexedSwapFixedLegBPS"
  qlOvernightIndexedSwapFixedLegBPS'_ :: ((C2HSImp.Ptr (COvernightIndexedSwap')) -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO C2HSImp.CDouble)))

foreign import ccall safe "QuantLib/Instrument/Swap.chs.h qlOvernightIndexedSwapFixedLegNPV"
  qlOvernightIndexedSwapFixedLegNPV'_ :: ((C2HSImp.Ptr (COvernightIndexedSwap')) -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO C2HSImp.CDouble)))

foreign import ccall safe "QuantLib/Instrument/Swap.chs.h qlOvernightIndexedSwapFairSpread"
  qlOvernightIndexedSwapFairSpread'_ :: ((C2HSImp.Ptr (COvernightIndexedSwap')) -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO C2HSImp.CDouble)))

foreign import ccall safe "QuantLib/Instrument/Swap.chs.h qlCreditDefaultSwapFairSpread"
  qlCreditDefaultSwapFairSpread'_ :: ((C2HSImp.Ptr (CCreditDefaultSwap')) -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO C2HSImp.CDouble)))

foreign import ccall safe "QuantLib/Instrument/Swap.chs.h qlFixedVsFloatingSwapFloatingLeg"
  qlFixedVsFloatingSwapFloatingLeg'_ :: ((C2HSImp.Ptr (CFixedVsFloatingSwap')) -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO (C2HSImp.Ptr (CLeg')))))

foreign import ccall safe "QuantLib/Instrument/Swap.chs.h qlFixedVsFloatingSwapFloatingLegBPS"
  qlFixedVsFloatingSwapFloatingLegBPS'_ :: ((C2HSImp.Ptr (CFixedVsFloatingSwap')) -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO C2HSImp.CDouble)))

foreign import ccall safe "QuantLib/Instrument/Swap.chs.h qlFixedVsFloatingSwapFloatingLegNPV"
  qlFixedVsFloatingSwapFloatingLegNPV'_ :: ((C2HSImp.Ptr (CFixedVsFloatingSwap')) -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO C2HSImp.CDouble)))

foreign import ccall safe "QuantLib/Instrument/Swap.chs.h qlAssetSwapFloatingLeg"
  qlAssetSwapFloatingLeg'_ :: ((C2HSImp.Ptr (CAssetSwap')) -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO (C2HSImp.Ptr (CLeg')))))

foreign import ccall safe "QuantLib/Instrument/Swap.chs.h qlAssetSwapFloatingLegBPS"
  qlAssetSwapFloatingLegBPS'_ :: ((C2HSImp.Ptr (CAssetSwap')) -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO C2HSImp.CDouble)))

foreign import ccall safe "QuantLib/Instrument/Swap.chs.h qlAssetSwapFloatingLegNPV"
  qlAssetSwapFloatingLegNPV'_ :: ((C2HSImp.Ptr (CAssetSwap')) -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO C2HSImp.CDouble)))

foreign import ccall safe "QuantLib/Instrument/Swap.chs.h qlVarianceSwap"
  varianceSwap'_ :: (C2HSImp.CInt -> (C2HSImp.CDouble -> (C2HSImp.CDouble -> (C2HSImp.CInt -> (C2HSImp.CInt -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO (C2HSImp.Ptr (CVarianceSwap')))))))))

foreign import ccall safe "QuantLib/Instrument/Swap.chs.h qlVarianceSwapVariance"
  variance'_ :: ((C2HSImp.Ptr (CVarianceSwap')) -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO C2HSImp.CDouble)))

foreign import ccall safe "QuantLib/Instrument/Swap.chs.h qlVarianceOption"
  varianceOption'_ :: ((QlPayoff) -> (C2HSImp.CDouble -> (C2HSImp.CInt -> (C2HSImp.CInt -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO (C2HSImp.Ptr (CVarianceOption'))))))))