-- 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
  , OvernightIndexedSwap
  , NonstandardSwap
  , IrregularSwap
  , FloatFloatSwap
  , AssetSwap
  , BMASwap
  , ZeroCouponInflationSwap
  , YearOnYearInflationSwap
  , CPISwap
  , ZeroCouponSwap
  , EquityTotalReturnSwap
  , VarianceSwap
  , GenConstNotionalCrossCurrencySwap
  , ConstNotionalCrossCurrencySwap
  , ConstNotionalCrossCurrencyBasisSwap
  , MtMCrossCurrencyBasisSwap
  , ConstNotionalCrossCurrencyFixedVsFloatingSwap

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

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

  , StubIndexSelection(..)

    -- * 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
  , mtmCrossCurrencyBasisSwap
  , mtmCrossCurrencyBasisSwapWithOptions
  , constNotionalCrossCurrencyFixedVsFloatingSwap

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

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

    -- * Inspectors
  , HasCrossCurrencyResults(..)
  , HasFairLegSpreads(..)
  , fairFxBaseSpread
  , fairFxQuoteSpread
  , fxResetRates
  , fxResetNotionals
    -- ** Common swap inspectors
  , HasFixedLeg(..)
  , HasFloatingLeg(..)
  , HasFairRate(..)
  , HasFairSpread(..)
  , HasInstrumentUnderlying(..)
  , impliedVolatility
  , endDiscounts
  , leg
  , numberOfLegs
  , legBps
  , legNpv
  , maturityDate
  , npvDateDiscount
  , startDate
  , startDiscounts
  , fixedRates

    -- ** Cross-currency swaps

    -- ** 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 Language.Haskell.TH(mkName, varT)
import Data.Maybe(fromMaybe)
import QuantLib.Internal.Syntax(deriveOptionsRecord)
import QuantLib.Internal
import QuantLib.Instrument
{-# LINE 176 "./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 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" #-}


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


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


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


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


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


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


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


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


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


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








{-# LINE 232 "./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 = Payer
  succ SwapType
Payer = String -> SwapType
forall a. HasCallStack => String -> a
error String
"SwapType.succ: Payer has no successor"

  pred :: SwapType -> SwapType
pred SwapType
Payer = SwapType
Receiver
  pred SwapType
Receiver = String -> SwapType
forall a. HasCallStack => String -> a
error String
"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

  enumFrom :: IrregularSettlementType -> [IrregularSettlementType]
fromEnum :: SwapType -> Int
fromEnum SwapType
Receiver = (-Int
1)
  fromEnum SwapType
Payer = Int
1

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

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

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

{-# LINE 235 "./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 236 "./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).
-- |Direction of the FX-base currency leg, independent of the resettable-leg choice.
data MtmCrossCurrencySwapType = PayFxBaseCurrency | ReceiveFxBaseCurrency deriving (Eq, Show, Read)

$(deriveOptionsRecord "MtMCrossCurrencyBasisSwapOpts" ["ibor3", "ibor4"]
  [ ("mtmFxResetFixingDays", [t|Word|], [|0|])
  , ("mtmFxResetFixingCalendar", [t|Maybe Calendar|], [|Nothing|])
  , ("mtmFxBasePaymentLag", [t|Int|], [|0|])
  , ("mtmFxQuotePaymentLag", [t|Int|], [|0|])
  , ("mtmFxBasePaymentConvention", [t|BusinessDayConvention|], [|Following|])
  , ("mtmFxQuotePaymentConvention", [t|BusinessDayConvention|], [|Following|])
  , ("mtmFxBaseCompoundSpread", [t|Bool|], [|False|])
  , ("mtmFxBaseObservation", [t|OvernightObservation|], [|defaultOvernightObservation|])
  , ("mtmFxBaseAveragingMethod", [t|RateAveragingType|], [|AveragingCompound|])
  , ("mtmFxQuoteCompoundSpread", [t|Bool|], [|False|])
  , ("mtmFxQuoteObservation", [t|OvernightObservation|], [|defaultOvernightObservation|])
  , ("mtmFxQuoteAveragingMethod", [t|RateAveragingType|], [|AveragingCompound|])
  , ("mtmTelescopicValueDates", [t|Bool|], [|False|])
  , ("mtmUseIndexedCoupons", [t|Maybe Bool|], [|Nothing|])
  , ("mtmFxBaseStubIndexSelection", [t|Maybe (StubIndexSelection $(varT (mkName "ibor3")))|], [|Nothing|])
  , ("mtmFxQuoteStubIndexSelection", [t|Maybe (StubIndexSelection $(varT (mkName "ibor4")))|], [|Nothing|])
  ])

$(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" ["ibor3", "ibor4"]
  [ ("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|])
  , ("cccbsUseIndexedCoupons", [t|Maybe Bool|], [|Nothing|])
  , ("cccbsPaymentLagOnNotionalExchanges", [t|Bool|], [|False|])
  , ("cccbsPayStubIndexSelection", [t|Maybe (StubIndexSelection $(varT (mkName "ibor3")))|], [|Nothing|])
  , ("cccbsRecStubIndexSelection", [t|Maybe (StubIndexSelection $(varT (mkName "ibor4")))|], [|Nothing|])
  ])

-- |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' = 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 ()) -> IO Double) -> IO Double
forall a b. (Ptr (Ptr a) -> IO b) -> IO b
preErrorCheck ((Ptr (Ptr ()) -> IO Double) -> IO Double)
-> (Ptr (Ptr ()) -> IO Double) -> IO Double
forall a b. (a -> b) -> a -> b
$ \Ptr (Ptr ())
a12' -> 
  Ptr CSwaption'
-> CDouble
-> Ptr CYieldTermStructure'
-> CDouble
-> CDouble
-> CUInt
-> CDouble
-> CDouble
-> CInt
-> CDouble
-> CInt
-> Ptr (Ptr ())
-> 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 ())
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 ()) -> IO ()
forall a. Ptr (Ptr a) -> IO ()
errorCheck  Ptr (Ptr ())
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 332 "./QuantLib/Instrument/Swap.chs" #-}


-- |Multi leg constructor.
swapFromLegs :: [(GenLeg l, Bool)] -- ^(legs, payer)
  -> IO Swap
swapFromLegs = (uncurry qlSwap1) . unzip
qlSwap1 :: ([GenLeg l]) -> ([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 338 "./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 348 "./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 361 "./QuantLib/Instrument/Swap.chs" #-}


-- |Converts an existing 'FixedVsFloatingSwap' (e.g. a 'VanillaSwap') into a 'NonstandardSwap'
-- (upstream's own conversion constructor, @NonstandardSwap(const FixedVsFloatingSwap&)@).
-- An 'OvernightIndexedSwap' keeps its compounded coupons, payment lag and observation
-- conventions; converting one requires QuantLib 1.44.
nonstandardSwapFromVanilla :: (GenFixedVsFloatingSwap f) -> IO ((NonstandardSwap))
nonstandardSwapFromVanilla a1 =
  withFixedVsFloatingSwap a1 $ \a1' -> 
  preErrorCheck $ \a2' -> 
  nonstandardSwapFromVanilla'_ a1' a2' >>= \res ->
  peekNonstandardSwap res >>= \res' ->
  errorCheck  a2'>>
  return (res')

{-# LINE 368 "./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.
-- QuantLib 1.44 builds compounded coupons for an overnight index; 1.43 builds Ibor coupons.
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
 -> (Int) -- ^paymentLag (1.44; QuantLib 1.43 requires 0)
 -> (Maybe Calendar) -- ^paymentCalendar, 'Nothing' for each leg's schedule calendar (1.44; QuantLib 1.43 requires 'Nothing')
 -> IO ((NonstandardSwap))
nonstandardSwap :: forall ibor.
SwapType
-> [Double]
-> [Double]
-> Schedule
-> [Double]
-> DayCounter
-> Schedule
-> GenIborIndex ibor
-> Double
-> Double
-> DayCounter
-> Bool
-> Bool
-> Maybe BusinessDayConvention
-> Int
-> Maybe Calendar
-> 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 Int
a15 Maybe Calendar
a16 =
  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 
  let {a15' :: CInt
a15' = Int -> CInt
forall a b. (Integral a, Num b) => a -> b
fromIntegral Int
a15} in 
  Maybe Calendar
-> (Ptr CCalendar -> IO NonstandardSwap) -> IO NonstandardSwap
forall r. Maybe Calendar -> (Ptr CCalendar -> IO r) -> IO r
withMaybeCalendar Maybe Calendar
a16 ((Ptr CCalendar -> IO NonstandardSwap) -> IO NonstandardSwap)
-> (Ptr CCalendar -> IO NonstandardSwap) -> IO NonstandardSwap
forall a b. (a -> b) -> a -> b
$ \Ptr CCalendar
a16' -> 
  (Ptr (Ptr ()) -> IO NonstandardSwap) -> IO NonstandardSwap
forall a b. (Ptr (Ptr a) -> IO b) -> IO b
preErrorCheck ((Ptr (Ptr ()) -> IO NonstandardSwap) -> IO NonstandardSwap)
-> (Ptr (Ptr ()) -> IO NonstandardSwap) -> IO NonstandardSwap
forall a b. (a -> b) -> a -> b
$ \Ptr (Ptr ())
a17' -> 
  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
-> CInt
-> Ptr CCalendar
-> Ptr (Ptr ())
-> 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' CInt
a15' Ptr CCalendar
a16' Ptr (Ptr ())
a17' 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 ()) -> IO ()
forall a. Ptr (Ptr a) -> IO ()
errorCheck  Ptr (Ptr ())
a17'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 390 "./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
 -> (Int) -- ^paymentLag (1.44; QuantLib 1.43 requires 0)
 -> (Maybe Calendar) -- ^paymentCalendar, 'Nothing' for each leg's schedule calendar (1.44; QuantLib 1.43 requires 'Nothing')
 -> IO ((NonstandardSwap))
nonstandardSwapFromGearingsAndSpreads a1 a2 a3 a4 a5 a6 a7 a8 a9 a10 a11 a12 a13 a14 a15 a16 =
  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 
  let {a15' = fromIntegral a15} in 
  withMaybeCalendar a16 $ \a16' -> 
  preErrorCheck $ \a17' -> 
  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' a16' a17' >>= \res ->
  peekNonstandardSwap res >>= \res' ->
  errorCheck  a17'>>
  return (res')

{-# LINE 409 "./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.
fixedRates :: (NonstandardSwap) -> IO (([Double]))
fixedRates a1 =
  withNonstandardSwap a1 $ \a1' -> 
  preDoubleArray $ \(a2'1, a2'2) -> 
  preErrorCheck $ \a3' -> 
  fixedRates'_ a1' a2'1  a2'2 a3' >>
  peekDoubleArray  a2'1  a2'2>>= \a2'' -> 
  errorCheck  a3'>>
  return (a2'')

{-# LINE 415 "./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' = realToFrac a13} in 
  let {a14' = fromMaybeDouble 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 ()) -> IO FloatFloatSwap) -> IO FloatFloatSwap
forall a b. (Ptr (Ptr a) -> IO b) -> IO b
preErrorCheck ((Ptr (Ptr ()) -> IO FloatFloatSwap) -> IO FloatFloatSwap)
-> (Ptr (Ptr ()) -> IO FloatFloatSwap) -> IO FloatFloatSwap
forall a b. (a -> b) -> a -> b
$ \Ptr (Ptr ())
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 ())
-> 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 ())
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 ()) -> IO ()
forall a. Ptr (Ptr a) -> IO ()
errorCheck  Ptr (Ptr ())
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 453 "./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 ()) -> IO FloatFloatSwap) -> IO FloatFloatSwap
forall a b. (Ptr (Ptr a) -> IO b) -> IO b
preErrorCheck ((Ptr (Ptr ()) -> IO FloatFloatSwap) -> IO FloatFloatSwap)
-> (Ptr (Ptr ()) -> IO FloatFloatSwap) -> IO FloatFloatSwap
forall a b. (a -> b) -> a -> b
$ \Ptr (Ptr ())
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 ())
-> 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 ())
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 ()) -> IO ()
forall a. Ptr (Ptr a) -> IO ()
errorCheck  Ptr (Ptr ())
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 488 "./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 491 "./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 494 "./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
  floatConv <- businessDayConvention index
  let 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
  floatConv <- businessDayConvention iborIndex
  let 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 ()) -> IO Swap) -> IO Swap
forall a b. (Ptr (Ptr a) -> IO b) -> IO b
preErrorCheck ((Ptr (Ptr ()) -> IO Swap) -> IO Swap)
-> (Ptr (Ptr ()) -> IO Swap) -> IO Swap
forall a b. (a -> b) -> a -> b
$ \Ptr (Ptr ())
a3' -> 
  Ptr CLeg' -> Ptr CLeg' -> Ptr (Ptr ()) -> IO (Ptr CSwap')
swap'_ Ptr CLeg'
a1' Ptr CLeg'
a2' Ptr (Ptr ())
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 ()) -> IO ()
forall a. Ptr (Ptr a) -> IO ()
errorCheck  Ptr (Ptr ())
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 626 "./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 629 "./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 632 "./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 635 "./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 638 "./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 641 "./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 644 "./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 651 "./QuantLib/Instrument/Swap.chs" #-}


-- |Multi-leg constructor.
constNotionalCrossCurrencySwapFromLegs :: [(GenLeg l, Bool)] -- ^(legs, payer)
  -> [Currency] -> IO ConstNotionalCrossCurrencySwap
constNotionalCrossCurrencySwapFromLegs legsPayer = qlConstNotionalCrossCurrencySwap1 legs payer
  where (legs, payer) = unzip legsPayer
qlConstNotionalCrossCurrencySwap1 :: ([GenLeg l]) -> ([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 658 "./QuantLib/Instrument/Swap.chs" #-}


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

{-# LINE 661 "./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).
constNotionalInCcyLegBPS :: (GenConstNotionalCrossCurrencySwap x) -> (Word) -> IO ((Double))
constNotionalInCcyLegBPS a1 a2 =
  withConstNotionalCrossCurrencySwap a1 $ \a1' -> 
  let {a2' = fromIntegral a2} in 
  preErrorCheck $ \a3' -> 
  constNotionalInCcyLegBPS'_ a1' a2' a3' >>= \res ->
  let {res' = realToFrac res} in
  errorCheck  a3'>>
  return (res')

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


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

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


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

{-# LINE 670 "./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 (OIS 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'). Indexed coupons, lagged notional exchanges and stub selections are
-- available on QuantLib 1.44; 1.43 accepts only their defaults. Override only what's needed on
-- 'defaultConstNotionalCrossCurrencyBasisSwapOpts'.
constNotionalCrossCurrencyBasisSwap :: Double -> Currency -> Schedule -> GenIborIndex ibor1 -> Double -> Double
  -> Double -> Currency -> Schedule -> GenIborIndex ibor2 -> Double -> Double
  -> ConstNotionalCrossCurrencyBasisSwapOpts ibor3 ibor4 -> IO ConstNotionalCrossCurrencyBasisSwap
constNotionalCrossCurrencyBasisSwap :: forall ibor1 ibor2 ibor3 ibor4.
Double
-> Currency
-> Schedule
-> GenIborIndex ibor1
-> Double
-> Double
-> Double
-> Currency
-> Schedule
-> GenIborIndex ibor2
-> Double
-> Double
-> ConstNotionalCrossCurrencyBasisSwapOpts ibor3 ibor4
-> 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 ibor3 ibor4
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
-> Maybe Bool
-> Bool
-> Maybe (StubIndexSelection ibor3)
-> Maybe (StubIndexSelection ibor4)
-> IO ConstNotionalCrossCurrencyBasisSwap
forall ibor1 ibor2 ibor3 ibor4.
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
-> Maybe Bool
-> Bool
-> Maybe (StubIndexSelection ibor3)
-> Maybe (StubIndexSelection ibor4)
-> 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 ibor3 ibor4 -> Int
forall ibor3 ibor4.
ConstNotionalCrossCurrencyBasisSwapOpts ibor3 ibor4 -> Int
cccbsPayPaymentLag ConstNotionalCrossCurrencyBasisSwapOpts ibor3 ibor4
opts) (ConstNotionalCrossCurrencyBasisSwapOpts ibor3 ibor4 -> Int
forall ibor3 ibor4.
ConstNotionalCrossCurrencyBasisSwapOpts ibor3 ibor4 -> Int
cccbsRecPaymentLag ConstNotionalCrossCurrencyBasisSwapOpts ibor3 ibor4
opts)
    (ConstNotionalCrossCurrencyBasisSwapOpts ibor3 ibor4 -> Bool
forall ibor3 ibor4.
ConstNotionalCrossCurrencyBasisSwapOpts ibor3 ibor4 -> Bool
cccbsPayCompoundSpread ConstNotionalCrossCurrencyBasisSwapOpts ibor3 ibor4
opts) (OvernightObservation -> Maybe Word
lookbackDays OvernightObservation
payObs) (OvernightObservation -> Bool
applyObservationShift OvernightObservation
payObs)
    (OvernightObservation -> Word
lockoutDays OvernightObservation
payObs) (ConstNotionalCrossCurrencyBasisSwapOpts ibor3 ibor4
-> RateAveragingType
forall ibor3 ibor4.
ConstNotionalCrossCurrencyBasisSwapOpts ibor3 ibor4
-> RateAveragingType
cccbsPayAveragingMethod ConstNotionalCrossCurrencyBasisSwapOpts ibor3 ibor4
opts)
    (ConstNotionalCrossCurrencyBasisSwapOpts ibor3 ibor4 -> Bool
forall ibor3 ibor4.
ConstNotionalCrossCurrencyBasisSwapOpts ibor3 ibor4 -> Bool
cccbsRecCompoundSpread ConstNotionalCrossCurrencyBasisSwapOpts ibor3 ibor4
opts) (OvernightObservation -> Maybe Word
lookbackDays OvernightObservation
recObs) (OvernightObservation -> Bool
applyObservationShift OvernightObservation
recObs)
    (OvernightObservation -> Word
lockoutDays OvernightObservation
recObs) (ConstNotionalCrossCurrencyBasisSwapOpts ibor3 ibor4
-> RateAveragingType
forall ibor3 ibor4.
ConstNotionalCrossCurrencyBasisSwapOpts ibor3 ibor4
-> RateAveragingType
cccbsRecAveragingMethod ConstNotionalCrossCurrencyBasisSwapOpts ibor3 ibor4
opts)
    (ConstNotionalCrossCurrencyBasisSwapOpts ibor3 ibor4 -> Bool
forall ibor3 ibor4.
ConstNotionalCrossCurrencyBasisSwapOpts ibor3 ibor4 -> Bool
cccbsTelescopicValueDates ConstNotionalCrossCurrencyBasisSwapOpts ibor3 ibor4
opts)
    (ConstNotionalCrossCurrencyBasisSwapOpts ibor3 ibor4 -> Maybe Bool
forall ibor3 ibor4.
ConstNotionalCrossCurrencyBasisSwapOpts ibor3 ibor4 -> Maybe Bool
cccbsUseIndexedCoupons ConstNotionalCrossCurrencyBasisSwapOpts ibor3 ibor4
opts) (ConstNotionalCrossCurrencyBasisSwapOpts ibor3 ibor4 -> Bool
forall ibor3 ibor4.
ConstNotionalCrossCurrencyBasisSwapOpts ibor3 ibor4 -> Bool
cccbsPaymentLagOnNotionalExchanges ConstNotionalCrossCurrencyBasisSwapOpts ibor3 ibor4
opts)
    (ConstNotionalCrossCurrencyBasisSwapOpts ibor3 ibor4
-> Maybe (StubIndexSelection ibor3)
forall ibor3 ibor4.
ConstNotionalCrossCurrencyBasisSwapOpts ibor3 ibor4
-> Maybe (StubIndexSelection ibor3)
cccbsPayStubIndexSelection ConstNotionalCrossCurrencyBasisSwapOpts ibor3 ibor4
opts) (ConstNotionalCrossCurrencyBasisSwapOpts ibor3 ibor4
-> Maybe (StubIndexSelection ibor4)
forall ibor3 ibor4.
ConstNotionalCrossCurrencyBasisSwapOpts ibor3 ibor4
-> Maybe (StubIndexSelection ibor4)
cccbsRecStubIndexSelection ConstNotionalCrossCurrencyBasisSwapOpts ibor3 ibor4
opts)
  where payObs :: OvernightObservation
payObs = ConstNotionalCrossCurrencyBasisSwapOpts ibor3 ibor4
-> OvernightObservation
forall ibor3 ibor4.
ConstNotionalCrossCurrencyBasisSwapOpts ibor3 ibor4
-> OvernightObservation
cccbsPayObservation ConstNotionalCrossCurrencyBasisSwapOpts ibor3 ibor4
opts
        recObs :: OvernightObservation
recObs = ConstNotionalCrossCurrencyBasisSwapOpts ibor3 ibor4
-> OvernightObservation
forall ibor3 ibor4.
ConstNotionalCrossCurrencyBasisSwapOpts ibor3 ibor4
-> OvernightObservation
cccbsRecObservation ConstNotionalCrossCurrencyBasisSwapOpts ibor3 ibor4
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
 -> (Maybe Bool) -- ^useIndexedCoupons (1.44; QuantLib 1.43 requires 'Nothing')
 -> (Bool) -- ^paymentLagOnNotionalExchanges (1.44; QuantLib 1.43 requires 'False')
 -> (Maybe (StubIndexSelection ibor3)) -- ^payStub (1.44; QuantLib 1.43 requires 'Nothing')
 -> (Maybe (StubIndexSelection ibor4)) -- ^recStub (1.44; QuantLib 1.43 requires 'Nothing')
 -> IO ((ConstNotionalCrossCurrencyBasisSwap))
constNotionalCrossCurrencyBasisSwap_ :: forall ibor1 ibor2 ibor3 ibor4.
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
-> Maybe Bool
-> Bool
-> Maybe (StubIndexSelection ibor3)
-> Maybe (StubIndexSelection ibor4)
-> 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 Maybe Bool
a26 Bool
a27 Maybe (StubIndexSelection ibor3)
a28 Maybe (StubIndexSelection ibor4)
a29 =
  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' = Double -> CDouble
forall a b. (Real a, Fractional b) => a -> b
realToFrac Double
a5} in 
  let {a6' :: CDouble
a6' = Double -> CDouble
forall a b. (Real a, Fractional b) => a -> b
realToFrac Double
a6} in 
  let {a7' :: CDouble
a7' = Double -> CDouble
forall a b. (Real a, Fractional b) => a -> b
realToFrac Double
a7} in 
  Currency
-> (Ptr CCurrency -> IO ConstNotionalCrossCurrencyBasisSwap)
-> IO ConstNotionalCrossCurrencyBasisSwap
forall b. Currency -> (Ptr CCurrency -> IO b) -> IO b
withCurrency Currency
a8 ((Ptr CCurrency -> IO ConstNotionalCrossCurrencyBasisSwap)
 -> IO ConstNotionalCrossCurrencyBasisSwap)
-> (Ptr CCurrency -> IO ConstNotionalCrossCurrencyBasisSwap)
-> IO ConstNotionalCrossCurrencyBasisSwap
forall a b. (a -> b) -> a -> b
$ \a8' -> 
  withSchedule Schedule
a9 ((Ptr CSchedule -> IO ConstNotionalCrossCurrencyBasisSwap)
 -> IO ConstNotionalCrossCurrencyBasisSwap)
-> (Ptr CSchedule -> IO ConstNotionalCrossCurrencyBasisSwap)
-> IO ConstNotionalCrossCurrencyBasisSwap
forall a b. (a -> b) -> a -> b
$ \Ptr CSchedule
a9' -> 
  GenIborIndex ibor2
-> (Ptr CIborIndex' -> IO ConstNotionalCrossCurrencyBasisSwap)
-> IO ConstNotionalCrossCurrencyBasisSwap
forall ibor b.
GenIborIndex ibor -> (Ptr CIborIndex' -> IO b) -> IO b
withIborIndex GenIborIndex ibor2
a10 ((Ptr CIborIndex' -> IO ConstNotionalCrossCurrencyBasisSwap)
 -> IO ConstNotionalCrossCurrencyBasisSwap)
-> (Ptr CIborIndex' -> IO ConstNotionalCrossCurrencyBasisSwap)
-> IO ConstNotionalCrossCurrencyBasisSwap
forall a b. (a -> b) -> a -> b
$ \Ptr CIborIndex'
a10' -> 
  let {a11' :: CDouble
a11' = Double -> CDouble
forall a b. (Real a, Fractional b) => a -> b
realToFrac Double
a11} in 
  let {a12' :: CDouble
a12' = Double -> CDouble
forall a b. (Real a, Fractional b) => a -> b
realToFrac Double
a12} in 
  let {a13' :: CInt
a13' = Int -> CInt
forall a b. (Integral a, Num b) => a -> b
fromIntegral Int
a13} in 
  let {a14' :: CInt
a14' = Int -> CInt
forall a b. (Integral a, Num b) => a -> b
fromIntegral Int
a14} in 
  let {a15' :: CInt
a15' = Bool -> CInt
forall a. Num a => Bool -> a
C2HSImp.fromBool Bool
a15} in 
  let {a16' :: CUInt
a16' = Maybe Word -> CUInt
forall a b. (Integral a, Integral b) => Maybe a -> b
fromMaybeInt Maybe Word
a16} in 
  let {a17' :: CInt
a17' = Bool -> CInt
forall a. Num a => Bool -> a
C2HSImp.fromBool Bool
a17} in 
  let {a18' :: CUInt
a18' = Word -> CUInt
forall a b. (Integral a, Num b) => a -> b
fromIntegral Word
a18} in 
  let {a19' :: CInt
a19' = (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
a19} in 
  let {a20' :: CInt
a20' = Bool -> CInt
forall a. Num a => Bool -> a
C2HSImp.fromBool Bool
a20} in 
  let {a21' :: CUInt
a21' = Maybe Word -> CUInt
forall a b. (Integral a, Integral b) => Maybe a -> b
fromMaybeInt Maybe Word
a21} in 
  let {a22' :: CInt
a22' = Bool -> CInt
forall a. Num a => Bool -> a
C2HSImp.fromBool Bool
a22} in 
  let {a23' :: CUInt
a23' = Word -> CUInt
forall a b. (Integral a, Num b) => a -> b
fromIntegral Word
a23} in 
  let {a24' :: CInt
a24' = (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
a24} in 
  let {a25' :: CInt
a25' = Bool -> CInt
forall a. Num a => Bool -> a
C2HSImp.fromBool Bool
a25} in 
  let {a26' :: CInt
a26' = Maybe Bool -> CInt
fromMaybeBool Maybe Bool
a26} in 
  let {a27' :: CInt
a27' = Bool -> CInt
forall a. Num a => Bool -> a
C2HSImp.fromBool Bool
a27} in 
  Maybe (StubIndexSelection ibor3)
-> (Ptr CStubIndexSelection'
    -> IO ConstNotionalCrossCurrencyBasisSwap)
-> IO ConstNotionalCrossCurrencyBasisSwap
forall ibor r.
Maybe (StubIndexSelection ibor)
-> (Ptr CStubIndexSelection' -> IO r) -> IO r
withStubIndexSelection Maybe (StubIndexSelection ibor3)
a28 ((Ptr CStubIndexSelection'
  -> IO ConstNotionalCrossCurrencyBasisSwap)
 -> IO ConstNotionalCrossCurrencyBasisSwap)
-> (Ptr CStubIndexSelection'
    -> IO ConstNotionalCrossCurrencyBasisSwap)
-> IO ConstNotionalCrossCurrencyBasisSwap
forall a b. (a -> b) -> a -> b
$ \Ptr CStubIndexSelection'
a28' -> 
  Maybe (StubIndexSelection ibor4)
-> (Ptr CStubIndexSelection'
    -> IO ConstNotionalCrossCurrencyBasisSwap)
-> IO ConstNotionalCrossCurrencyBasisSwap
forall ibor r.
Maybe (StubIndexSelection ibor)
-> (Ptr CStubIndexSelection' -> IO r) -> IO r
withStubIndexSelection Maybe (StubIndexSelection ibor4)
a29 ((Ptr CStubIndexSelection'
  -> IO ConstNotionalCrossCurrencyBasisSwap)
 -> IO ConstNotionalCrossCurrencyBasisSwap)
-> (Ptr CStubIndexSelection'
    -> IO ConstNotionalCrossCurrencyBasisSwap)
-> IO ConstNotionalCrossCurrencyBasisSwap
forall a b. (a -> b) -> a -> b
$ \Ptr CStubIndexSelection'
a29' -> 
  (Ptr (Ptr ()) -> IO ConstNotionalCrossCurrencyBasisSwap)
-> IO ConstNotionalCrossCurrencyBasisSwap
forall a b. (Ptr (Ptr a) -> IO b) -> IO b
preErrorCheck ((Ptr (Ptr ()) -> IO ConstNotionalCrossCurrencyBasisSwap)
 -> IO ConstNotionalCrossCurrencyBasisSwap)
-> (Ptr (Ptr ()) -> IO ConstNotionalCrossCurrencyBasisSwap)
-> IO ConstNotionalCrossCurrencyBasisSwap
forall a b. (a -> b) -> a -> b
$ \Ptr (Ptr ())
a30' -> 
  CDouble
-> Ptr CCurrency
-> Ptr CSchedule
-> Ptr CIborIndex'
-> CDouble
-> CDouble
-> CDouble
-> Ptr CCurrency
-> Ptr CSchedule
-> Ptr CIborIndex'
-> CDouble
-> CDouble
-> CInt
-> CInt
-> CInt
-> CUInt
-> CInt
-> CUInt
-> CInt
-> CInt
-> CUInt
-> CInt
-> CUInt
-> CInt
-> CInt
-> CInt
-> CInt
-> Ptr CStubIndexSelection'
-> Ptr CStubIndexSelection'
-> Ptr (Ptr ())
-> IO (Ptr CConstNotionalCrossCurrencyBasisSwap')
constNotionalCrossCurrencyBasisSwap_'_ CDouble
a1' Ptr CCurrency
a2' Ptr CSchedule
a3' Ptr CIborIndex'
a4' CDouble
a5' CDouble
a6' CDouble
a7' Ptr CCurrency
a8' Ptr CSchedule
a9' Ptr CIborIndex'
a10' CDouble
a11' CDouble
a12' CInt
a13' CInt
a14' CInt
a15' CUInt
a16' CInt
a17' CUInt
a18' CInt
a19' CInt
a20' CUInt
a21' CInt
a22' CUInt
a23' CInt
a24' CInt
a25' CInt
a26' CInt
a27' Ptr CStubIndexSelection'
a28' Ptr CStubIndexSelection'
a29' Ptr (Ptr ())
a30' IO (Ptr CConstNotionalCrossCurrencyBasisSwap')
-> (Ptr CConstNotionalCrossCurrencyBasisSwap'
    -> IO ConstNotionalCrossCurrencyBasisSwap)
-> IO ConstNotionalCrossCurrencyBasisSwap
forall a b. IO a -> (a -> IO b) -> IO b
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= \Ptr CConstNotionalCrossCurrencyBasisSwap'
res ->
  Ptr CConstNotionalCrossCurrencyBasisSwap'
-> IO ConstNotionalCrossCurrencyBasisSwap
peekConstNotionalCrossCurrencyBasisSwap Ptr CConstNotionalCrossCurrencyBasisSwap'
res IO ConstNotionalCrossCurrencyBasisSwap
-> (ConstNotionalCrossCurrencyBasisSwap
    -> IO ConstNotionalCrossCurrencyBasisSwap)
-> IO ConstNotionalCrossCurrencyBasisSwap
forall a b. IO a -> (a -> IO b) -> IO b
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= \ConstNotionalCrossCurrencyBasisSwap
res' ->
  Ptr (Ptr ()) -> IO ()
forall a. Ptr (Ptr a) -> IO ()
errorCheck  Ptr (Ptr ())
a30'IO ()
-> IO ConstNotionalCrossCurrencyBasisSwap
-> IO ConstNotionalCrossCurrencyBasisSwap
forall a b. IO a -> IO b -> IO b
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>>
  ConstNotionalCrossCurrencyBasisSwap
-> IO ConstNotionalCrossCurrencyBasisSwap
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return (ConstNotionalCrossCurrencyBasisSwap
res')

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


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

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


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

{-# LINE 732 "./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
  -> Maybe Bool -- ^useIndexedCoupons (1.44; QuantLib 1.43 requires 'Nothing')
  -> Maybe (StubIndexSelection ibor2) -- ^floatStubIndexSelection (1.44; QuantLib 1.43 requires 'Nothing')
  -> IO ConstNotionalCrossCurrencyFixedVsFloatingSwap
constNotionalCrossCurrencyFixedVsFloatingSwap :: forall ibor ibor2.
SwapType
-> Double
-> Currency
-> Schedule
-> Double
-> DayCounter
-> BusinessDayConvention
-> Word
-> Calendar
-> Double
-> Currency
-> Schedule
-> GenIborIndex ibor
-> Double
-> BusinessDayConvention
-> Word
-> Calendar
-> Bool
-> Bool
-> OvernightObservation
-> RateAveragingType
-> Maybe Bool
-> Maybe (StubIndexSelection ibor2)
-> 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 Maybe Bool
indexed Maybe (StubIndexSelection ibor2)
stub =
  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
-> Maybe Bool
-> Maybe (StubIndexSelection ibor2)
-> IO ConstNotionalCrossCurrencyFixedVsFloatingSwap
forall ibor ibor2.
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
-> Maybe Bool
-> Maybe (StubIndexSelection ibor2)
-> 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 Maybe Bool
indexed Maybe (StubIndexSelection ibor2)
stub

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
 -> (Maybe Bool) -- ^useIndexedCoupons (1.44; QuantLib 1.43 requires 'Nothing')
 -> (Maybe (StubIndexSelection ibor2)) -- ^floatStub (1.44; QuantLib 1.43 requires 'Nothing')
 -> IO ((ConstNotionalCrossCurrencyFixedVsFloatingSwap))
constNotionalCrossCurrencyFixedVsFloatingSwapRaw :: forall ibor ibor2.
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
-> Maybe Bool
-> Maybe (StubIndexSelection ibor2)
-> 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 Maybe Bool
a24 Maybe (StubIndexSelection ibor2)
a25 =
  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' = 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 
  let {a24' :: CInt
a24' = Maybe Bool -> CInt
fromMaybeBool Maybe Bool
a24} in 
  Maybe (StubIndexSelection ibor2)
-> (Ptr CStubIndexSelection'
    -> IO ConstNotionalCrossCurrencyFixedVsFloatingSwap)
-> IO ConstNotionalCrossCurrencyFixedVsFloatingSwap
forall ibor r.
Maybe (StubIndexSelection ibor)
-> (Ptr CStubIndexSelection' -> IO r) -> IO r
withStubIndexSelection Maybe (StubIndexSelection ibor2)
a25 ((Ptr CStubIndexSelection'
  -> IO ConstNotionalCrossCurrencyFixedVsFloatingSwap)
 -> IO ConstNotionalCrossCurrencyFixedVsFloatingSwap)
-> (Ptr CStubIndexSelection'
    -> IO ConstNotionalCrossCurrencyFixedVsFloatingSwap)
-> IO ConstNotionalCrossCurrencyFixedVsFloatingSwap
forall a b. (a -> b) -> a -> b
$ \Ptr CStubIndexSelection'
a25' -> 
  (Ptr (Ptr ()) -> IO ConstNotionalCrossCurrencyFixedVsFloatingSwap)
-> IO ConstNotionalCrossCurrencyFixedVsFloatingSwap
forall a b. (Ptr (Ptr a) -> IO b) -> IO b
preErrorCheck ((Ptr (Ptr ()) -> IO ConstNotionalCrossCurrencyFixedVsFloatingSwap)
 -> IO ConstNotionalCrossCurrencyFixedVsFloatingSwap)
-> (Ptr (Ptr ())
    -> IO ConstNotionalCrossCurrencyFixedVsFloatingSwap)
-> IO ConstNotionalCrossCurrencyFixedVsFloatingSwap
forall a b. (a -> b) -> a -> b
$ \Ptr (Ptr ())
a26' -> 
  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
-> CInt
-> Ptr CStubIndexSelection'
-> Ptr (Ptr ())
-> 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' CInt
a24' Ptr CStubIndexSelection'
a25' Ptr (Ptr ())
a26' 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 ()) -> IO ()
forall a. Ptr (Ptr a) -> IO ()
errorCheck  Ptr (Ptr ())
a26'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 799 "./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 802 "./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 808 "./QuantLib/Instrument/Swap.chs" #-}


-- |An option on a 'VanillaSwap' or an 'OvernightIndexedSwap'; the latter requires QuantLib 1.44.
-- The Gaussian1d swaption engines then compound overnight coupons exactly, approximate lookback
-- without observation shift and lockout, and do not support arithmetic averaging.
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 813 "./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 817 "./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 818 "./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 819 "./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 820 "./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 825 "./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 828 "./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 
  preBlackCalibrationHelperArray $ \(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 839 "./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 842 "./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 
  preBlackCalibrationHelperArray $ \(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 850 "./QuantLib/Instrument/Swap.chs" #-}


-- |Bullet bond vs Libor swap (par or market asset swap, per /parAssetSwap/).
assetSwap :: (Bool) -- ^payBondCoupon
 -> (GenBond b) -> (Double) -- ^bondCleanPrice
 -> (GenIborIndex ibor) -> (Double) -- spread
 -> (Schedule) -- ^floatSchedule
 -> (DayCounter) -- ^floatingDayCount
 -> (Bool) -- ^parAssetSwap
 -> (Double) -- ^gearing
 -> (Maybe Double) -- ^nonParRepayment
 -> (Maybe Day) -- ^dealMaturity
 -> IO ((AssetSwap))
assetSwap :: forall b ibor.
Bool
-> GenBond b
-> Double
-> GenIborIndex ibor
-> Double
-> Schedule
-> DayCounter
-> Bool
-> Double
-> Maybe Double
-> Maybe Day
-> IO AssetSwap
assetSwap Bool
a1 GenBond b
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 
  GenBond b -> (Ptr CBond' -> IO AssetSwap) -> IO AssetSwap
forall b r. GenBond b -> (Ptr CBond' -> IO r) -> IO r
withBond GenBond b
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 ()) -> IO AssetSwap) -> IO AssetSwap
forall a b. (Ptr (Ptr a) -> IO b) -> IO b
preErrorCheck ((Ptr (Ptr ()) -> IO AssetSwap) -> IO AssetSwap)
-> (Ptr (Ptr ()) -> IO AssetSwap) -> IO AssetSwap
forall a b. (a -> b) -> a -> b
$ \Ptr (Ptr ())
a12' -> 
  CInt
-> Ptr CBond'
-> CDouble
-> Ptr CIborIndex'
-> CDouble
-> Ptr CSchedule
-> Ptr CDayCounter
-> CInt
-> CDouble
-> CDouble
-> CInt
-> Ptr (Ptr ())
-> 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 ())
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 ()) -> IO ()
forall a. Ptr (Ptr a) -> IO ()
errorCheck  Ptr (Ptr ())
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 862 "./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
  -> Maybe Int -- ^roundingPrecision (1.44; QuantLib 1.43 requires 'Nothing')
  -> IO OvernightIndexedSwap
overnightIndexedSwap t n sch r dc idx sprd lag adj cal telescopic avg obs precision =
  overnightIndexedSwapRaw t n sch r dc idx sprd lag adj cal telescopic avg
    (lookbackDays obs) (lockoutDays obs) (applyObservationShift obs) precision

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
 -> (Maybe Int) -- ^roundingPrecision (1.44; QuantLib 1.43 requires 'Nothing')
 -> IO ((OvernightIndexedSwap))
overnightIndexedSwapRaw :: SwapType
-> Double
-> Schedule
-> Double
-> DayCounter
-> OvernightIborIndex
-> Double
-> Int
-> BusinessDayConvention
-> Calendar
-> Bool
-> RateAveragingType
-> Maybe Word
-> Word
-> Bool
-> Maybe Int
-> 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 Maybe Int
a16 =
  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 
  let {a16' :: CInt
a16' = Maybe Int -> CInt
forall a b. (Integral a, Integral b) => Maybe a -> b
fromMaybeInt Maybe Int
a16} in 
  preErrorCheck $ \a17' -> 
  overnightIndexedSwapRaw'_ a1' a2' a3' a4' a5' a6' a7' a8' a9' a10' a11' a12' a13' a14' a15' a16' a17' >>= \res ->
  peekOvernightIndexedSwap res >>= \res' ->
  errorCheck  a17'>>
  return (res')

{-# LINE 897 "./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
  -> Maybe Int -- ^roundingPrecision (1.44; QuantLib 1.43 requires 'Nothing')
  -> IO OvernightIndexedSwap
overnightIndexedSwapFromNominals t ns sch r dc idx sprd lag adj cal telescopic avg obs precision =
  overnightIndexedSwapFromNominalsRaw t ns sch r dc idx sprd lag adj cal telescopic avg
    (lookbackDays obs) (lockoutDays obs) (applyObservationShift obs) precision

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
 -> (Maybe Int) -- ^roundingPrecision (1.44; QuantLib 1.43 requires 'Nothing')
 -> IO ((OvernightIndexedSwap))
overnightIndexedSwapFromNominalsRaw :: SwapType
-> [Double]
-> Schedule
-> Double
-> DayCounter
-> OvernightIborIndex
-> Double
-> Int
-> BusinessDayConvention
-> Calendar
-> Bool
-> RateAveragingType
-> Maybe Word
-> Word
-> Bool
-> Maybe Int
-> 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 Maybe Int
a16 =
  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 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 
  let {a16' :: CInt
a16' = Maybe Int -> CInt
forall a b. (Integral a, Integral b) => Maybe a -> b
fromMaybeInt Maybe Int
a16} in 
  (Ptr (Ptr ()) -> IO OvernightIndexedSwap)
-> IO OvernightIndexedSwap
forall a b. (Ptr (Ptr a) -> IO b) -> IO b
preErrorCheck ((Ptr (Ptr ()) -> IO OvernightIndexedSwap)
 -> IO OvernightIndexedSwap)
-> (Ptr (Ptr ()) -> IO OvernightIndexedSwap)
-> IO OvernightIndexedSwap
forall a b. (a -> b) -> a -> b
$ \Ptr (Ptr ())
a17' -> 
  overnightIndexedSwapFromNominalsRaw'_ a1' a2'1  a2'2 a3' a4' a5' a6' a7' a8' a9' a10' a11' a12' a13' a14' a15' a16' a17' >>= \res ->
  peekOvernightIndexedSwap res >>= \res' ->
  errorCheck  a17'>>
  return (res')

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


-- |The swap's maturity date: the latest across its legs. Throws if the swap has no legs.
maturityDate :: (GenSwap s) -> IO ((Day))
maturityDate a1 =
  withSwap a1 $ \a1' -> 
  preErrorCheck $ \a2' -> 
  maturityDate'_ a1' a2' >>= \res ->
  let {res' = toDay res} in
  errorCheck  a2'>>
  return (res')

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


-- |The swap's start date: the earliest across its legs. Throws if the swap has no legs.
startDate :: (GenSwap s) -> IO ((Day))
startDate a1 =
  withSwap a1 $ \a1' -> 
  preErrorCheck $ \a2' -> 
  startDate'_ a1' a2' >>= \res ->
  let {res' = toDay res} in
  errorCheck  a2'>>
  return (res')

{-# LINE 939 "./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 942 "./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 945 "./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 948 "./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 951 "./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 954 "./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 957 "./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 960 "./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 963 "./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 966 "./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 969 "./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 972 "./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 975 "./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 978 "./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 981 "./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 984 "./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 987 "./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 990 "./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 993 "./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 996 "./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 999 "./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
 -> (GenZeroInflationIndex zidx) -> ((Word,TimeUnit)) -- ^observationLag
 -> (CPIInterpolationType) -- ^observationInterpolation
 -> (Bool) -- ^adjustInfObsDates
 -> (Calendar) -- ^infCalendar
 -> (BusinessDayConvention) -- ^infConvention
 -> IO ((ZeroCouponInflationSwap))
zeroCouponInflationSwap :: forall zidx.
SwapType
-> Double
-> Day
-> Day
-> Calendar
-> BusinessDayConvention
-> DayCounter
-> Double
-> GenZeroInflationIndex zidx
-> (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 GenZeroInflationIndex zidx
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 a7 ((Ptr CDayCounter -> IO ZeroCouponInflationSwap)
 -> IO ZeroCouponInflationSwap)
-> (Ptr CDayCounter -> IO ZeroCouponInflationSwap)
-> IO ZeroCouponInflationSwap
forall a b. (a -> b) -> a -> b
$ \a7' -> 
  let {a8' = realToFrac a8} in 
  withZeroInflationIndex a9 $ \a9' -> 
  let {(a10'1, a10'2) = fromEnumQuantity a10} in 
  let {a11' = fromEnumC a11} in 
  let {a12' = C2HSImp.fromBool a12} in 
  withCalendar a13 $ \a13' -> 
  let {a14' = fromEnumC a14} in 
  preErrorCheck $ \a15' -> 
  zeroCouponInflationSwap'_ a1' a2' a3' a4' a5' a6' a7' a8' a9' a10'1  a10'2 a11' a12' a13' a14' a15' >>= \res ->
  peekZeroCouponInflationSwap res >>= \res' ->
  errorCheck  a15'>>
  return (res')

{-# LINE 1017 "./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 1020 "./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
 -> (GenYoYInflationIndex yidx) -> ((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 1036 "./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 1039 "./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 1042 "./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
 -> (GenZeroInflationIndex zidx) -- ^fixedIndex
 -> (CPIInterpolationType) -- ^observationInterpolation
 -> (Maybe Double) -- ^inflationNominal
 -> IO ((CPISwap))
cpiSwap :: forall ibor zidx.
SwapType
-> Double
-> Bool
-> Double
-> DayCounter
-> Schedule
-> BusinessDayConvention
-> Word
-> GenIborIndex ibor
-> Double
-> Double
-> DayCounter
-> Schedule
-> BusinessDayConvention
-> (Word, TimeUnit)
-> GenZeroInflationIndex zidx
-> 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 GenZeroInflationIndex zidx
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' = realToFrac a4} in 
  withDayCounter a5 $ \a5' -> 
  withSchedule a6 $ \a6' -> 
  let {a7' = fromEnumC a7} in 
  let {a8' = fromIntegral a8} in 
  withIborIndex a9 $ \a9' -> 
  let {a10' = realToFrac a10} in 
  let {a11' = realToFrac a11} in 
  withDayCounter a12 $ \a12' -> 
  withSchedule a13 $ \a13' -> 
  let {a14' = fromEnumC a14} in 
  let {(a15'1, a15'2) = fromEnumQuantity a15} in 
  withZeroInflationIndex a16 $ \a16' -> 
  let {a17' = fromEnumC a17} in 
  let {a18' = fromMaybeDouble a18} in 
  preErrorCheck $ \a19' -> 
  cpiSwap'_ a1' a2' a3' a4' a5' a6' a7' a8' a9' a10' a11' a12' a13' a14' a15'1  a15'2 a16' a17' a18' a19' >>= \res ->
  peekCPISwap res >>= \res' ->
  errorCheck  a19'>>
  return (res')

{-# LINE 1065 "./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 1068 "./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 1071 "./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 1082 "./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 1093 "./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 1096 "./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 1099 "./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 ()) -> IO EquityTotalReturnSwap)
-> IO EquityTotalReturnSwap
forall a b. (Ptr (Ptr a) -> IO b) -> IO b
preErrorCheck ((Ptr (Ptr ()) -> IO EquityTotalReturnSwap)
 -> IO EquityTotalReturnSwap)
-> (Ptr (Ptr ()) -> IO EquityTotalReturnSwap)
-> IO EquityTotalReturnSwap
forall a b. (a -> b) -> a -> b
$ \Ptr (Ptr ())
a12' -> 
  CInt
-> CDouble
-> Ptr CSchedule
-> Ptr CEquityIndex'
-> Ptr CIborIndex'
-> Ptr CDayCounter
-> CDouble
-> CDouble
-> Ptr CCalendar
-> CInt
-> CUInt
-> Ptr (Ptr ())
-> 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 ())
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 ()) -> IO ()
forall a. Ptr (Ptr a) -> IO ()
errorCheck  Ptr (Ptr ())
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 1113 "./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 1127 "./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 1130 "./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 1133 "./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 1136 "./QuantLib/Instrument/Swap.chs" #-}


class HasFixedLeg a where
  fixedLeg :: a -> IO Leg
  fixedLegBps :: a -> IO Double
  fixedLegNpv :: a -> IO Double
instance HasFixedLeg (GenFixedVsFloatingSwap f) where
  fixedLeg = qlFixedVsFloatingSwapFixedLeg
  fixedLegBps = qlFixedVsFloatingSwapFixedLegBPS
  fixedLegNpv = qlFixedVsFloatingSwapFixedLegNPV

class HasFairRate a where
  fairRate :: a -> IO Double
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 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 ()) -> IO FixedVsFloatingSwap) -> IO FixedVsFloatingSwap
forall a b. (Ptr (Ptr a) -> IO b) -> IO b
preErrorCheck ((Ptr (Ptr ()) -> IO FixedVsFloatingSwap)
 -> IO FixedVsFloatingSwap)
-> (Ptr (Ptr ()) -> IO FixedVsFloatingSwap)
-> IO FixedVsFloatingSwap
forall a b. (a -> b) -> a -> b
$ \Ptr (Ptr ())
a2' -> 
  Ptr CSwaption' -> Ptr (Ptr ()) -> IO (Ptr CFixedVsFloatingSwap')
qlSwaptionUnderlying'_ Ptr CSwaption'
a1' Ptr (Ptr ())
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 ()) -> IO ()
forall a. Ptr (Ptr a) -> IO ()
errorCheck  Ptr (Ptr ())
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 1196 "./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 1197 "./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 1198 "./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 1199 "./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 1200 "./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 ()) -> IO Double) -> IO Double
forall a b. (Ptr (Ptr a) -> IO b) -> IO b
preErrorCheck ((Ptr (Ptr ()) -> IO Double) -> IO Double)
-> (Ptr (Ptr ()) -> IO Double) -> IO Double
forall a b. (a -> b) -> a -> b
$ \Ptr (Ptr ())
a2' -> 
  Ptr CFixedVsFloatingSwap' -> Ptr (Ptr ()) -> IO CDouble
qlFixedVsFloatingSwapFairSpread'_ Ptr CFixedVsFloatingSwap'
a1' Ptr (Ptr ())
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 ()) -> IO ()
forall a. Ptr (Ptr a) -> IO ()
errorCheck  Ptr (Ptr ())
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 1216 "./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 1219 "./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 1222 "./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 1225 "./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 1228 "./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 1231 "./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 1234 "./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 1237 "./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 1240 "./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 1243 "./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 1246 "./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 1249 "./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 1252 "./QuantLib/Instrument/Swap.chs" #-}



{-# LINE 1254 "./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 ()) -> IO VarianceSwap) -> IO VarianceSwap
forall a b. (Ptr (Ptr a) -> IO b) -> IO b
preErrorCheck ((Ptr (Ptr ()) -> IO VarianceSwap) -> IO VarianceSwap)
-> (Ptr (Ptr ()) -> IO VarianceSwap) -> IO VarianceSwap
forall a b. (a -> b) -> a -> b
$ \a6' -> 
  varianceSwap'_ a1' a2' a3' a4' a5' a6' >>= \res ->
  peekVarianceSwap res >>= \res' ->
  errorCheck  a6'>>
  return (res')

{-# LINE 1261 "./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 1264 "./QuantLib/Instrument/Swap.chs" #-}



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


{-# LINE 1267 "./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 ()) -> IO VarianceOption) -> IO VarianceOption
forall a b. (Ptr (Ptr a) -> IO b) -> IO b
preErrorCheck ((Ptr (Ptr ()) -> IO VarianceOption) -> IO VarianceOption)
-> (Ptr (Ptr ()) -> IO VarianceOption) -> IO VarianceOption
forall a b. (a -> b) -> a -> b
$ \Ptr (Ptr ())
a5' -> 
  QlPayoff
-> CDouble
-> CInt
-> CInt
-> Ptr (Ptr ())
-> IO (Ptr CVarianceOption')
varianceOption'_ QlPayoff
a1' CDouble
a2' CInt
a3' CInt
a4' Ptr (Ptr ())
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 ()) -> IO ()
forall a. Ptr (Ptr a) -> IO ()
errorCheck  Ptr (Ptr ())
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 1276 "./QuantLib/Instrument/Swap.chs" #-}


-- |Native MTM product construction.
mtmCrossCurrencyBasisSwapRaw :: (Int) -- ^type
 -> (Double) -- ^fxBaseNominal
 -> (Currency) -- ^fxBaseCurrency
 -> (Schedule) -- ^fxBaseSchedule
 -> (GenIborIndex ibor1) -- ^fxBaseIndex
 -> (Double) -- ^fxBaseSpread
 -> (Double) -- ^fxBaseGearing
 -> (Double) -- ^fxQuoteNominal
 -> (Currency) -- ^fxQuoteCurrency
 -> (Schedule) -- ^fxQuoteSchedule
 -> (GenIborIndex ibor2) -- ^fxQuoteIndex
 -> (Double) -- ^fxQuoteSpread
 -> (Double) -- ^fxQuoteGearing
 -> (Bool) -- ^isFxBaseCurrencyLegResettable
 -> (Word) -- ^fxResetFixingDays
 -> (Maybe Calendar) -- ^fxResetFixingCalendar
 -> (Int) -- ^fxBasePaymentLag
 -> (Int) -- ^fxQuotePaymentLag
 -> (BusinessDayConvention) -- ^fxBasePaymentConvention
 -> (BusinessDayConvention) -- ^fxQuotePaymentConvention
 -> (Bool) -- ^fxBaseCompoundSpread
 -> (Maybe Word) -- ^fxBaseLookbackDays
 -> (Bool) -- ^fxBaseObservationShift
 -> (Word) -- ^fxBaseLockoutDays
 -> (RateAveragingType) -- ^fxBaseAveragingMethod
 -> (Bool) -- ^fxQuoteCompoundSpread
 -> (Maybe Word) -- ^fxQuoteLookbackDays
 -> (Bool) -- ^fxQuoteObservationShift
 -> (Word) -- ^fxQuoteLockoutDays
 -> (RateAveragingType) -- ^fxQuoteAveragingMethod
 -> (Bool) -- ^telescopicValueDates
 -> (Maybe Bool) -- ^useIndexedCoupons
 -> (Maybe (StubIndexSelection ibor3)) -- ^fxBaseStubIndexSelection
 -> (Maybe (StubIndexSelection ibor4)) -- ^fxQuoteStubIndexSelection
 -> IO ((MtMCrossCurrencyBasisSwap))
mtmCrossCurrencyBasisSwapRaw :: forall ibor1 ibor2 ibor3 ibor4.
Int
-> Double
-> Currency
-> Schedule
-> GenIborIndex ibor1
-> Double
-> Double
-> Double
-> Currency
-> Schedule
-> GenIborIndex ibor2
-> Double
-> Double
-> Bool
-> Word
-> Maybe Calendar
-> Int
-> Int
-> BusinessDayConvention
-> BusinessDayConvention
-> Bool
-> Maybe Word
-> Bool
-> Word
-> RateAveragingType
-> Bool
-> Maybe Word
-> Bool
-> Word
-> RateAveragingType
-> Bool
-> Maybe Bool
-> Maybe (StubIndexSelection ibor3)
-> Maybe (StubIndexSelection ibor4)
-> IO MtMCrossCurrencyBasisSwap
mtmCrossCurrencyBasisSwapRaw Int
a1 Double
a2 Currency
a3 Schedule
a4 GenIborIndex ibor1
a5 Double
a6 Double
a7 Double
a8 Currency
a9 Schedule
a10 GenIborIndex ibor2
a11 Double
a12 Double
a13 Bool
a14 Word
a15 Maybe Calendar
a16 Int
a17 Int
a18 BusinessDayConvention
a19 BusinessDayConvention
a20 Bool
a21 Maybe Word
a22 Bool
a23 Word
a24 RateAveragingType
a25 Bool
a26 Maybe Word
a27 Bool
a28 Word
a29 RateAveragingType
a30 Bool
a31 Maybe Bool
a32 Maybe (StubIndexSelection ibor3)
a33 Maybe (StubIndexSelection ibor4)
a34 =
  let {a1' :: CInt
a1' = Int -> CInt
forall a b. (Integral a, Num b) => a -> b
fromIntegral Int
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 MtMCrossCurrencyBasisSwap)
-> IO MtMCrossCurrencyBasisSwap
forall b. Currency -> (Ptr CCurrency -> IO b) -> IO b
withCurrency Currency
a3 ((Ptr CCurrency -> IO MtMCrossCurrencyBasisSwap)
 -> IO MtMCrossCurrencyBasisSwap)
-> (Ptr CCurrency -> IO MtMCrossCurrencyBasisSwap)
-> IO MtMCrossCurrencyBasisSwap
forall a b. (a -> b) -> a -> b
$ \Ptr CCurrency
a3' -> 
  Schedule
-> (Ptr CSchedule -> IO MtMCrossCurrencyBasisSwap)
-> IO MtMCrossCurrencyBasisSwap
forall b. Schedule -> (Ptr CSchedule -> IO b) -> IO b
withSchedule Schedule
a4 ((Ptr CSchedule -> IO MtMCrossCurrencyBasisSwap)
 -> IO MtMCrossCurrencyBasisSwap)
-> (Ptr CSchedule -> IO MtMCrossCurrencyBasisSwap)
-> IO MtMCrossCurrencyBasisSwap
forall a b. (a -> b) -> a -> b
$ \Ptr CSchedule
a4' -> 
  GenIborIndex ibor1
-> (Ptr CIborIndex' -> IO MtMCrossCurrencyBasisSwap)
-> IO MtMCrossCurrencyBasisSwap
forall ibor b.
GenIborIndex ibor -> (Ptr CIborIndex' -> IO b) -> IO b
withIborIndex GenIborIndex ibor1
a5 ((Ptr CIborIndex' -> IO MtMCrossCurrencyBasisSwap)
 -> IO MtMCrossCurrencyBasisSwap)
-> (Ptr CIborIndex' -> IO MtMCrossCurrencyBasisSwap)
-> IO MtMCrossCurrencyBasisSwap
forall a b. (a -> b) -> a -> b
$ \Ptr CIborIndex'
a5' -> 
  let {a6' :: CDouble
a6' = Double -> CDouble
forall a b. (Real a, Fractional b) => a -> b
realToFrac Double
a6} in 
  let {a7' :: CDouble
a7' = Double -> CDouble
forall a b. (Real a, Fractional b) => a -> b
realToFrac Double
a7} in 
  let {a8' :: CDouble
a8' = Double -> CDouble
forall a b. (Real a, Fractional b) => a -> b
realToFrac Double
a8} in 
  Currency
-> (Ptr CCurrency -> IO MtMCrossCurrencyBasisSwap)
-> IO MtMCrossCurrencyBasisSwap
forall b. Currency -> (Ptr CCurrency -> IO b) -> IO b
withCurrency Currency
a9 ((Ptr CCurrency -> IO MtMCrossCurrencyBasisSwap)
 -> IO MtMCrossCurrencyBasisSwap)
-> (Ptr CCurrency -> IO MtMCrossCurrencyBasisSwap)
-> IO MtMCrossCurrencyBasisSwap
forall a b. (a -> b) -> a -> b
$ \Ptr CCurrency
a9' -> 
  Schedule
-> (Ptr CSchedule -> IO MtMCrossCurrencyBasisSwap)
-> IO MtMCrossCurrencyBasisSwap
forall b. Schedule -> (Ptr CSchedule -> IO b) -> IO b
withSchedule Schedule
a10 ((Ptr CSchedule -> IO MtMCrossCurrencyBasisSwap)
 -> IO MtMCrossCurrencyBasisSwap)
-> (Ptr CSchedule -> IO MtMCrossCurrencyBasisSwap)
-> IO MtMCrossCurrencyBasisSwap
forall a b. (a -> b) -> a -> b
$ \Ptr CSchedule
a10' -> 
  GenIborIndex ibor2
-> (Ptr CIborIndex' -> IO MtMCrossCurrencyBasisSwap)
-> IO MtMCrossCurrencyBasisSwap
forall ibor b.
GenIborIndex ibor -> (Ptr CIborIndex' -> IO b) -> IO b
withIborIndex GenIborIndex ibor2
a11 ((Ptr CIborIndex' -> IO MtMCrossCurrencyBasisSwap)
 -> IO MtMCrossCurrencyBasisSwap)
-> (Ptr CIborIndex' -> IO MtMCrossCurrencyBasisSwap)
-> IO MtMCrossCurrencyBasisSwap
forall a b. (a -> b) -> a -> b
$ \Ptr CIborIndex'
a11' -> 
  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' :: CInt
a14' = Bool -> CInt
forall a. Num a => Bool -> a
C2HSImp.fromBool Bool
a14} in 
  let {a15' :: CUInt
a15' = Word -> CUInt
forall a b. (Integral a, Num b) => a -> b
fromIntegral Word
a15} in 
  Maybe Calendar
-> (Ptr CCalendar -> IO MtMCrossCurrencyBasisSwap)
-> IO MtMCrossCurrencyBasisSwap
forall r. Maybe Calendar -> (Ptr CCalendar -> IO r) -> IO r
withMaybeCalendar Maybe Calendar
a16 ((Ptr CCalendar -> IO MtMCrossCurrencyBasisSwap)
 -> IO MtMCrossCurrencyBasisSwap)
-> (Ptr CCalendar -> IO MtMCrossCurrencyBasisSwap)
-> IO MtMCrossCurrencyBasisSwap
forall a b. (a -> b) -> a -> b
$ \Ptr CCalendar
a16' -> 
  let {a17' :: CInt
a17' = Int -> CInt
forall a b. (Integral a, Num b) => a -> b
fromIntegral Int
a17} in 
  let {a18' :: CInt
a18' = Int -> CInt
forall a b. (Integral a, Num b) => a -> b
fromIntegral Int
a18} in 
  let {a19' :: CInt
a19' = BusinessDayConvention -> CInt
forall a b. (Enum a, Integral b) => a -> b
fromEnumC BusinessDayConvention
a19} in 
  let {a20' :: CInt
a20' = BusinessDayConvention -> CInt
forall a b. (Enum a, Integral b) => a -> b
fromEnumC BusinessDayConvention
a20} in 
  let {a21' :: CInt
a21' = Bool -> CInt
forall a. Num a => Bool -> a
C2HSImp.fromBool Bool
a21} in 
  let {a22' :: CUInt
a22' = Maybe Word -> CUInt
forall a b. (Integral a, Integral b) => Maybe a -> b
fromMaybeInt Maybe Word
a22} in 
  let {a23' :: CInt
a23' = Bool -> CInt
forall a. Num a => Bool -> a
C2HSImp.fromBool Bool
a23} in 
  let {a24' :: CUInt
a24' = Word -> CUInt
forall a b. (Integral a, Num b) => a -> b
fromIntegral Word
a24} in 
  let {a25' :: CInt
a25' = (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
a25} in 
  let {a26' :: CInt
a26' = Bool -> CInt
forall a. Num a => Bool -> a
C2HSImp.fromBool Bool
a26} in 
  let {a27' :: CUInt
a27' = Maybe Word -> CUInt
forall a b. (Integral a, Integral b) => Maybe a -> b
fromMaybeInt Maybe Word
a27} in 
  let {a28' :: CInt
a28' = Bool -> CInt
forall a. Num a => Bool -> a
C2HSImp.fromBool Bool
a28} in 
  let {a29' :: CUInt
a29' = Word -> CUInt
forall a b. (Integral a, Num b) => a -> b
fromIntegral Word
a29} in 
  let {a30' :: CInt
a30' = (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
a30} in 
  let {a31' :: CInt
a31' = Bool -> CInt
forall a. Num a => Bool -> a
C2HSImp.fromBool Bool
a31} in 
  let {a32' :: CInt
a32' = Maybe Bool -> CInt
fromMaybeBool Maybe Bool
a32} in 
  Maybe (StubIndexSelection ibor3)
-> (Ptr CStubIndexSelection' -> IO MtMCrossCurrencyBasisSwap)
-> IO MtMCrossCurrencyBasisSwap
forall ibor r.
Maybe (StubIndexSelection ibor)
-> (Ptr CStubIndexSelection' -> IO r) -> IO r
withStubIndexSelection Maybe (StubIndexSelection ibor3)
a33 ((Ptr CStubIndexSelection' -> IO MtMCrossCurrencyBasisSwap)
 -> IO MtMCrossCurrencyBasisSwap)
-> (Ptr CStubIndexSelection' -> IO MtMCrossCurrencyBasisSwap)
-> IO MtMCrossCurrencyBasisSwap
forall a b. (a -> b) -> a -> b
$ \Ptr CStubIndexSelection'
a33' -> 
  Maybe (StubIndexSelection ibor4)
-> (Ptr CStubIndexSelection' -> IO MtMCrossCurrencyBasisSwap)
-> IO MtMCrossCurrencyBasisSwap
forall ibor r.
Maybe (StubIndexSelection ibor)
-> (Ptr CStubIndexSelection' -> IO r) -> IO r
withStubIndexSelection Maybe (StubIndexSelection ibor4)
a34 ((Ptr CStubIndexSelection' -> IO MtMCrossCurrencyBasisSwap)
 -> IO MtMCrossCurrencyBasisSwap)
-> (Ptr CStubIndexSelection' -> IO MtMCrossCurrencyBasisSwap)
-> IO MtMCrossCurrencyBasisSwap
forall a b. (a -> b) -> a -> b
$ \Ptr CStubIndexSelection'
a34' -> 
  (Ptr (Ptr ()) -> IO MtMCrossCurrencyBasisSwap)
-> IO MtMCrossCurrencyBasisSwap
forall a b. (Ptr (Ptr a) -> IO b) -> IO b
preErrorCheck ((Ptr (Ptr ()) -> IO MtMCrossCurrencyBasisSwap)
 -> IO MtMCrossCurrencyBasisSwap)
-> (Ptr (Ptr ()) -> IO MtMCrossCurrencyBasisSwap)
-> IO MtMCrossCurrencyBasisSwap
forall a b. (a -> b) -> a -> b
$ \Ptr (Ptr ())
a35' -> 
  CInt
-> CDouble
-> Ptr CCurrency
-> Ptr CSchedule
-> Ptr CIborIndex'
-> CDouble
-> CDouble
-> CDouble
-> Ptr CCurrency
-> Ptr CSchedule
-> Ptr CIborIndex'
-> CDouble
-> CDouble
-> CInt
-> CUInt
-> Ptr CCalendar
-> CInt
-> CInt
-> CInt
-> CInt
-> CInt
-> CUInt
-> CInt
-> CUInt
-> CInt
-> CInt
-> CUInt
-> CInt
-> CUInt
-> CInt
-> CInt
-> CInt
-> Ptr CStubIndexSelection'
-> Ptr CStubIndexSelection'
-> Ptr (Ptr ())
-> IO (Ptr CMtMCrossCurrencyBasisSwap')
mtmCrossCurrencyBasisSwapRaw'_ CInt
a1' CDouble
a2' Ptr CCurrency
a3' Ptr CSchedule
a4' Ptr CIborIndex'
a5' CDouble
a6' CDouble
a7' CDouble
a8' Ptr CCurrency
a9' Ptr CSchedule
a10' Ptr CIborIndex'
a11' CDouble
a12' CDouble
a13' CInt
a14' CUInt
a15' Ptr CCalendar
a16' CInt
a17' CInt
a18' CInt
a19' CInt
a20' CInt
a21' CUInt
a22' CInt
a23' CUInt
a24' CInt
a25' CInt
a26' CUInt
a27' CInt
a28' CUInt
a29' CInt
a30' CInt
a31' CInt
a32' Ptr CStubIndexSelection'
a33' Ptr CStubIndexSelection'
a34' Ptr (Ptr ())
a35' IO (Ptr CMtMCrossCurrencyBasisSwap')
-> (Ptr CMtMCrossCurrencyBasisSwap'
    -> IO MtMCrossCurrencyBasisSwap)
-> IO MtMCrossCurrencyBasisSwap
forall a b. IO a -> (a -> IO b) -> IO b
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= \Ptr CMtMCrossCurrencyBasisSwap'
res ->
  Ptr CMtMCrossCurrencyBasisSwap' -> IO MtMCrossCurrencyBasisSwap
peekMtMCrossCurrencyBasisSwap Ptr CMtMCrossCurrencyBasisSwap'
res IO MtMCrossCurrencyBasisSwap
-> (MtMCrossCurrencyBasisSwap -> IO MtMCrossCurrencyBasisSwap)
-> IO MtMCrossCurrencyBasisSwap
forall a b. IO a -> (a -> IO b) -> IO b
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= \MtMCrossCurrencyBasisSwap
res' ->
  Ptr (Ptr ()) -> IO ()
forall a. Ptr (Ptr a) -> IO ()
errorCheck  Ptr (Ptr ())
a35'IO ()
-> IO MtMCrossCurrencyBasisSwap -> IO MtMCrossCurrencyBasisSwap
forall a b. IO a -> IO b -> IO b
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>>
  MtMCrossCurrencyBasisSwap -> IO MtMCrossCurrencyBasisSwap
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return (MtMCrossCurrencyBasisSwap
res')

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


-- |Resetting-notional cross-currency basis swap with upstream defaults (1.44).
-- Base is leg 0 and quote is leg 1. The Bool chooses whether base resets.
mtmCrossCurrencyBasisSwap :: MtmCrossCurrencySwapType -- ^Pay/receive FX base currency; base is leg 0, quote leg 1
  -> Double -- ^FX base nominal
  -> Currency -- ^FX base currency
  -> Schedule -- ^FX base schedule
  -> GenIborIndex ibor1 -- ^FX base IBOR or overnight index
  -> Double -- ^FX base spread
  -> Double -- ^FX base gearing
  -> Double -- ^FX quote nominal
  -> Currency -- ^FX quote currency
  -> Schedule -- ^FX quote schedule
  -> GenIborIndex ibor2 -- ^FX quote IBOR or overnight index
  -> Double -- ^FX quote spread
  -> Double -- ^FX quote gearing
  -> Bool -- ^True resets the FX base leg; False resets the FX quote leg
  -> IO MtMCrossCurrencyBasisSwap
mtmCrossCurrencyBasisSwap direction fxBaseNominal fxBaseCurrency fxBaseSchedule fxBaseIndex fxBaseSpread fxBaseGearing fxQuoteNominal fxQuoteCurrency fxQuoteSchedule fxQuoteIndex fxQuoteSpread fxQuoteGearing resetBase =
  mtmCrossCurrencyBasisSwapWithOptions direction fxBaseNominal fxBaseCurrency fxBaseSchedule fxBaseIndex fxBaseSpread fxBaseGearing fxQuoteNominal fxQuoteCurrency fxQuoteSchedule fxQuoteIndex fxQuoteSpread fxQuoteGearing resetBase defaultMtmCrossCurrencyBasisSwapOpts

-- |Full MTM construction (1.44). Payment lags affect coupons, not principal exchanges.
-- Empty FX fixing calendars use the resetting schedule calendar when the fixing lag is nonzero.
mtmCrossCurrencyBasisSwapWithOptions :: MtmCrossCurrencySwapType -- ^Pay/receive FX base currency; base is leg 0, quote leg 1
  -> Double -- ^FX base nominal
  -> Currency -- ^FX base currency
  -> Schedule -- ^FX base schedule
  -> GenIborIndex ibor1 -- ^FX base IBOR or overnight index
  -> Double -- ^FX base spread
  -> Double -- ^FX base gearing
  -> Double -- ^FX quote nominal
  -> Currency -- ^FX quote currency
  -> Schedule -- ^FX quote schedule
  -> GenIborIndex ibor2 -- ^FX quote IBOR or overnight index
  -> Double -- ^FX quote spread
  -> Double -- ^FX quote gearing
  -> Bool -- ^True resets the FX base leg; False resets the FX quote leg
  -> MtMCrossCurrencyBasisSwapOpts ibor3 ibor4 -- ^Payment, reset, overnight and stub options
  -> IO MtMCrossCurrencyBasisSwap
mtmCrossCurrencyBasisSwapWithOptions direction fxBaseNominal fxBaseCurrency fxBaseSchedule fxBaseIndex fxBaseSpread fxBaseGearing fxQuoteNominal fxQuoteCurrency fxQuoteSchedule fxQuoteIndex fxQuoteSpread fxQuoteGearing resetBase opts =
  mtmCrossCurrencyBasisSwapRaw (case direction of PayFxBaseCurrency -> 0; ReceiveFxBaseCurrency -> 1)
    fxBaseNominal fxBaseCurrency fxBaseSchedule fxBaseIndex fxBaseSpread fxBaseGearing fxQuoteNominal fxQuoteCurrency fxQuoteSchedule fxQuoteIndex fxQuoteSpread fxQuoteGearing resetBase
    (mtmFxResetFixingDays opts) (mtmFxResetFixingCalendar opts)
    (mtmFxBasePaymentLag opts) (mtmFxQuotePaymentLag opts)
    (mtmFxBasePaymentConvention opts) (mtmFxQuotePaymentConvention opts)
    (mtmFxBaseCompoundSpread opts) (lookbackDays baseObs) (applyObservationShift baseObs) (lockoutDays baseObs) (mtmFxBaseAveragingMethod opts)
    (mtmFxQuoteCompoundSpread opts) (lookbackDays quoteObs) (applyObservationShift quoteObs) (lockoutDays quoteObs) (mtmFxQuoteAveragingMethod opts)
    (mtmTelescopicValueDates opts) (mtmUseIndexedCoupons opts)
    (mtmFxBaseStubIndexSelection opts) (mtmFxQuoteStubIndexSelection opts)
  where baseObs :: OvernightObservation
baseObs = MtMCrossCurrencyBasisSwapOpts ibor3 ibor4 -> OvernightObservation
forall ibor3 ibor4.
MtMCrossCurrencyBasisSwapOpts ibor3 ibor4 -> OvernightObservation
mtmFxBaseObservation MtMCrossCurrencyBasisSwapOpts ibor3 ibor4
opts
        quoteObs :: OvernightObservation
quoteObs = MtMCrossCurrencyBasisSwapOpts ibor3 ibor4 -> OvernightObservation
forall ibor3 ibor4.
MtMCrossCurrencyBasisSwapOpts ibor3 ibor4 -> OvernightObservation
mtmFxQuoteObservation MtMCrossCurrencyBasisSwapOpts ibor3 ibor4
opts

-- |Currency-denominated results shared by cross-currency swaps.
class HasCrossCurrencyResults s where
  -- |Currency of a leg, selected by zero-based index.
  legCurrency :: s -> Word -> IO Currency
  -- |Signed basis-point sensitivity in the leg currency.
  inCcyLegBps :: s -> Word -> IO Double
  -- |Signed NPV in the leg currency.
  inCcyLegNpv :: s -> Word -> IO Double
  -- |Discount factor at the NPV date for the selected currency.
  npvDateDiscounts :: s -> Word -> IO Double

instance HasCrossCurrencyResults (GenConstNotionalCrossCurrencySwap x) where
  legCurrency :: GenConstNotionalCrossCurrencySwap x -> Word -> IO Currency
legCurrency = GenConstNotionalCrossCurrencySwap x -> Word -> IO Currency
forall x.
GenConstNotionalCrossCurrencySwap x -> Word -> IO Currency
constNotionalLegCurrency
  inCcyLegBps :: GenConstNotionalCrossCurrencySwap x -> Word -> IO Double
inCcyLegBps = GenConstNotionalCrossCurrencySwap x -> Word -> IO Double
forall x. GenConstNotionalCrossCurrencySwap x -> Word -> IO Double
constNotionalInCcyLegBPS
  inCcyLegNpv :: GenConstNotionalCrossCurrencySwap x -> Word -> IO Double
inCcyLegNpv = GenConstNotionalCrossCurrencySwap x -> Word -> IO Double
forall x. GenConstNotionalCrossCurrencySwap x -> Word -> IO Double
constNotionalInCcyLegNPV
  npvDateDiscounts :: GenConstNotionalCrossCurrencySwap x -> Word -> IO Double
npvDateDiscounts = GenConstNotionalCrossCurrencySwap x -> Word -> IO Double
forall x. GenConstNotionalCrossCurrencySwap x -> Word -> IO Double
constNotionalNpvDateDiscounts

instance HasCrossCurrencyResults MtMCrossCurrencyBasisSwap where
  legCurrency :: MtMCrossCurrencyBasisSwap -> Word -> IO Currency
legCurrency = MtMCrossCurrencyBasisSwap -> Word -> IO Currency
mtmLegCurrency
  inCcyLegBps :: MtMCrossCurrencyBasisSwap -> Word -> IO Double
inCcyLegBps = MtMCrossCurrencyBasisSwap -> Word -> IO Double
mtmInCcyLegBPS
  inCcyLegNpv :: MtMCrossCurrencyBasisSwap -> Word -> IO Double
inCcyLegNpv = MtMCrossCurrencyBasisSwap -> Word -> IO Double
mtmInCcyLegNPV
  npvDateDiscounts :: MtMCrossCurrencyBasisSwap -> Word -> IO Double
npvDateDiscounts = MtMCrossCurrencyBasisSwap -> Word -> IO Double
mtmNpvDateDiscounts

-- |MTM legCurrency (1.44).
mtmLegCurrency :: (MtMCrossCurrencyBasisSwap) -- ^swap
 -> (Word) -- ^legIndex
 -> IO ((Currency))
mtmLegCurrency :: MtMCrossCurrencyBasisSwap -> Word -> IO Currency
mtmLegCurrency MtMCrossCurrencyBasisSwap
a1 Word
a2 =
  MtMCrossCurrencyBasisSwap
-> (Ptr CMtMCrossCurrencyBasisSwap' -> IO Currency) -> IO Currency
forall b.
MtMCrossCurrencyBasisSwap
-> (Ptr CMtMCrossCurrencyBasisSwap' -> IO b) -> IO b
withMtMCrossCurrencyBasisSwap MtMCrossCurrencyBasisSwap
a1 ((Ptr CMtMCrossCurrencyBasisSwap' -> IO Currency) -> IO Currency)
-> (Ptr CMtMCrossCurrencyBasisSwap' -> IO Currency) -> IO Currency
forall a b. (a -> b) -> a -> b
$ \Ptr CMtMCrossCurrencyBasisSwap'
a1' -> 
  let {a2' :: CUInt
a2' = Word -> CUInt
forall a b. (Integral a, Num b) => a -> b
fromIntegral Word
a2} in 
  (Ptr (Ptr ()) -> IO Currency) -> IO Currency
forall a b. (Ptr (Ptr a) -> IO b) -> IO b
preErrorCheck ((Ptr (Ptr ()) -> IO Currency) -> IO Currency)
-> (Ptr (Ptr ()) -> IO Currency) -> IO Currency
forall a b. (a -> b) -> a -> b
$ \Ptr (Ptr ())
a3' -> 
  Ptr CMtMCrossCurrencyBasisSwap'
-> CUInt -> Ptr (Ptr ()) -> IO (Ptr CCurrency)
mtmLegCurrency'_ Ptr CMtMCrossCurrencyBasisSwap'
a1' CUInt
a2' Ptr (Ptr ())
a3' IO (Ptr CCurrency) -> (Ptr CCurrency -> IO Currency) -> IO Currency
forall a b. IO a -> (a -> IO b) -> IO b
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= \Ptr CCurrency
res ->
  Ptr CCurrency -> IO Currency
peekCurrency Ptr CCurrency
res IO Currency -> (Currency -> IO Currency) -> IO Currency
forall a b. IO a -> (a -> IO b) -> IO b
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= \Currency
res' ->
  Ptr (Ptr ()) -> IO ()
forall a. Ptr (Ptr a) -> IO ()
errorCheck  Ptr (Ptr ())
a3'IO () -> IO Currency -> IO Currency
forall a b. IO a -> IO b -> IO b
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>>
  Currency -> IO Currency
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return (Currency
res')

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


-- |MTM inCcyLegBPS (1.44).
mtmInCcyLegBPS :: (MtMCrossCurrencyBasisSwap) -- ^swap
 -> (Word) -- ^legIndex
 -> IO ((Double))
mtmInCcyLegBPS a1 a2 =
  withMtMCrossCurrencyBasisSwap a1 $ \a1' -> 
  let {a2' = fromIntegral a2} in 
  preErrorCheck $ \a3' -> 
  mtmInCcyLegBPS'_ a1' a2' a3' >>= \res ->
  let {res' = realToFrac res} in
  errorCheck  a3'>>
  return (res')

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


-- |MTM inCcyLegNPV (1.44).
mtmInCcyLegNPV :: (MtMCrossCurrencyBasisSwap) -- ^swap
 -> (Word) -- ^legIndex
 -> IO ((Double))
mtmInCcyLegNPV a1 a2 =
  withMtMCrossCurrencyBasisSwap a1 $ \a1' -> 
  let {a2' = fromIntegral a2} in 
  preErrorCheck $ \a3' -> 
  mtmInCcyLegNPV'_ a1' a2' a3' >>= \res ->
  let {res' = realToFrac res} in
  errorCheck  a3'>>
  return (res')

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


-- |MTM npvDateDiscounts (1.44).
mtmNpvDateDiscounts :: (MtMCrossCurrencyBasisSwap) -- ^swap
 -> (Word) -- ^legIndex
 -> IO ((Double))
mtmNpvDateDiscounts a1 a2 =
  withMtMCrossCurrencyBasisSwap a1 $ \a1' -> 
  let {a2' = fromIntegral a2} in 
  preErrorCheck $ \a3' -> 
  mtmNpvDateDiscounts'_ a1' a2' a3' >>= \res ->
  let {res' = realToFrac res} in
  errorCheck  a3'>>
  return (res')

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


-- |Native NPV/BPS par spread (1.44).
-- Compounded overnight spreads can leave a repricing residual.
fairFxBaseSpread :: (MtMCrossCurrencyBasisSwap) -- ^swap
 -> IO ((Double))
fairFxBaseSpread a1 =
  withMtMCrossCurrencyBasisSwap a1 $ \a1' -> 
  preErrorCheck $ \a2' -> 
  fairFxBaseSpread'_ a1' a2' >>= \res ->
  let {res' = realToFrac res} in
  errorCheck  a2'>>
  return (res')

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


-- |Native NPV/BPS par spread (1.44).
-- Compounded overnight spreads can leave a repricing residual.
fairFxQuoteSpread :: (MtMCrossCurrencyBasisSwap) -- ^swap
 -> IO ((Double))
fairFxQuoteSpread a1 =
  withMtMCrossCurrencyBasisSwap a1 $ \a1' -> 
  preErrorCheck $ \a2' -> 
  fairFxQuoteSpread'_ a1' a2' >>= \res ->
  let {res' = realToFrac res} in
  errorCheck  a2'>>
  return (res')

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


-- |Native NPV/BPS par spread (1.44).
-- Compounded overnight spreads can leave a repricing residual.
mtmFairPaySpread :: (MtMCrossCurrencyBasisSwap) -- ^swap
 -> IO ((Double))
mtmFairPaySpread a1 =
  withMtMCrossCurrencyBasisSwap a1 $ \a1' -> 
  preErrorCheck $ \a2' -> 
  mtmFairPaySpread'_ a1' a2' >>= \res ->
  let {res' = realToFrac res} in
  errorCheck  a2'>>
  return (res')

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


-- |Native NPV/BPS par spread (1.44).
-- Compounded overnight spreads can leave a repricing residual.
mtmFairRecSpread :: (MtMCrossCurrencyBasisSwap) -- ^swap
 -> IO ((Double))
mtmFairRecSpread a1 =
  withMtMCrossCurrencyBasisSwap a1 $ \a1' -> 
  preErrorCheck $ \a2' -> 
  mtmFairRecSpread'_ a1' a2' >>= \res ->
  let {res' = realToFrac res} in
  errorCheck  a2'>>
  return (res')

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


-- |Native NPV/BPS par spreads for paid and received legs of basis swaps.
-- Compounded overnight spreads can leave a repricing residual.
class HasFairLegSpreads s where
  -- |Par spread of the paid leg.
  fairPaySpread :: s -> IO Double
  -- |Par spread of the received leg.
  fairRecSpread :: s -> IO Double
instance HasFairLegSpreads ConstNotionalCrossCurrencyBasisSwap where
  fairPaySpread = constNotionalFairPaySpread
  fairRecSpread = constNotionalFairRecSpread
instance HasFairLegSpreads MtMCrossCurrencyBasisSwap where
  fairPaySpread :: MtMCrossCurrencyBasisSwap -> IO Double
fairPaySpread = MtMCrossCurrencyBasisSwap -> IO Double
mtmFairPaySpread
  fairRecSpread :: MtMCrossCurrencyBasisSwap -> IO Double
fairRecSpread = MtMCrossCurrencyBasisSwap -> IO Double
mtmFairRecSpread

-- |Calculated reset rates for non-occurred coupons in leg order (1.44).
fxResetRates :: (MtMCrossCurrencyBasisSwap) -- ^swap
 -> IO (([Double]))
fxResetRates :: MtMCrossCurrencyBasisSwap -> IO [Double]
fxResetRates MtMCrossCurrencyBasisSwap
a1 =
  MtMCrossCurrencyBasisSwap
-> (Ptr CMtMCrossCurrencyBasisSwap' -> IO [Double]) -> IO [Double]
forall b.
MtMCrossCurrencyBasisSwap
-> (Ptr CMtMCrossCurrencyBasisSwap' -> IO b) -> IO b
withMtMCrossCurrencyBasisSwap MtMCrossCurrencyBasisSwap
a1 ((Ptr CMtMCrossCurrencyBasisSwap' -> IO [Double]) -> IO [Double])
-> (Ptr CMtMCrossCurrencyBasisSwap' -> IO [Double]) -> IO [Double]
forall a b. (a -> b) -> a -> b
$ \Ptr CMtMCrossCurrencyBasisSwap'
a1' -> 
  ((Ptr CUInt, Ptr (Ptr CDouble)) -> IO [Double]) -> IO [Double]
forall b. ((Ptr CUInt, Ptr (Ptr CDouble)) -> IO b) -> IO b
preDoubleArray (((Ptr CUInt, Ptr (Ptr CDouble)) -> IO [Double]) -> IO [Double])
-> ((Ptr CUInt, Ptr (Ptr CDouble)) -> IO [Double]) -> IO [Double]
forall a b. (a -> b) -> a -> b
$ \(Ptr CUInt
a2'1, Ptr (Ptr CDouble)
a2'2) -> 
  (Ptr (Ptr ()) -> IO [Double]) -> IO [Double]
forall a b. (Ptr (Ptr a) -> IO b) -> IO b
preErrorCheck ((Ptr (Ptr ()) -> IO [Double]) -> IO [Double])
-> (Ptr (Ptr ()) -> IO [Double]) -> IO [Double]
forall a b. (a -> b) -> a -> b
$ \Ptr (Ptr ())
a3' -> 
  Ptr CMtMCrossCurrencyBasisSwap'
-> Ptr CUInt -> Ptr (Ptr CDouble) -> Ptr (Ptr ()) -> IO ()
fxResetRates'_ Ptr CMtMCrossCurrencyBasisSwap'
a1' Ptr CUInt
a2'1  Ptr (Ptr CDouble)
a2'2 Ptr (Ptr ())
a3' IO () -> IO [Double] -> IO [Double]
forall a b. IO a -> IO b -> IO b
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>>
  Ptr CUInt -> Ptr (Ptr CDouble) -> IO [Double]
peekDoubleArray  Ptr CUInt
a2'1  Ptr (Ptr CDouble)
a2'2IO [Double] -> ([Double] -> 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
>>= \[Double]
a2'' -> 
  Ptr (Ptr ()) -> IO ()
forall a. Ptr (Ptr a) -> IO ()
errorCheck  Ptr (Ptr ())
a3'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]
a2'')

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


-- |Calculated reset notionals for non-occurred coupons in leg order (1.44).
fxResetNotionals :: (MtMCrossCurrencyBasisSwap) -- ^swap
 -> IO (([Double]))
fxResetNotionals a1 =
  withMtMCrossCurrencyBasisSwap a1 $ \a1' -> 
  preDoubleArray $ \(a2'1, a2'2) -> 
  preErrorCheck $ \a3' -> 
  fxResetNotionals'_ a1' a2'1  a2'2 a3' >>
  peekDoubleArray  a2'1  a2'2>>= \a2'' -> 
  errorCheck  a3'>>
  return (a2'')

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


-- |Upstream defaults for MTM cross-currency construction.
defaultMtmCrossCurrencyBasisSwapOpts :: MtMCrossCurrencyBasisSwapOpts ibor3 ibor4
defaultMtmCrossCurrencyBasisSwapOpts = defaultMtMCrossCurrencyBasisSwapOpts

-- 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 ())) -> (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 ())) -> (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 ())) -> (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 ())) -> (IO (C2HSImp.Ptr (CVanillaSwap')))))))))))))))

foreign import ccall safe "QuantLib/Instrument/Swap.chs.h qlNonstandardSwap1"
  nonstandardSwapFromVanilla'_ :: ((C2HSImp.Ptr (CFixedVsFloatingSwap')) -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (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.CInt -> ((C2HSImp.Ptr (CCalendar)) -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (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.CInt -> ((C2HSImp.Ptr (CCalendar)) -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO (C2HSImp.Ptr (CNonstandardSwap')))))))))))))))))))))))))

foreign import ccall safe "QuantLib/Instrument/Swap.chs.h qlNonstandardSwapFixedRate"
  fixedRates'_ :: ((C2HSImp.Ptr (CNonstandardSwap')) -> ((C2HSImp.Ptr C2HSImp.CUInt) -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CDouble)) -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (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 ())) -> (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 ())) -> (IO (C2HSImp.Ptr (CFloatFloatSwap')))))))))))))))))))))))))))))))))))

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

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

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

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

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

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

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

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

foreign import ccall safe "QuantLib/Instrument/Swap.chs.h qlSwapStartDiscounts"
  startDiscounts'_ :: ((C2HSImp.Ptr (CSwap')) -> (C2HSImp.CUInt -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (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 ())) -> (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 ())) -> (IO (C2HSImp.Ptr (CConstNotionalCrossCurrencySwap'))))))))))

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

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

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

foreign import ccall safe "QuantLib/Instrument/Swap.chs.h qlConstNotionalCrossCurrencySwapNpvDateDiscounts"
  constNotionalNpvDateDiscounts'_ :: ((C2HSImp.Ptr (CConstNotionalCrossCurrencySwap')) -> (C2HSImp.CUInt -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (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.CInt -> (C2HSImp.CInt -> ((QlStubIndexSelection) -> ((QlStubIndexSelection) -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO (C2HSImp.Ptr (CConstNotionalCrossCurrencyBasisSwap')))))))))))))))))))))))))))))))))

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

foreign import ccall safe "QuantLib/Instrument/Swap.chs.h qlConstNotionalCrossCurrencyBasisSwapFairRecSpread"
  constNotionalFairRecSpread'_ :: ((C2HSImp.Ptr (CConstNotionalCrossCurrencyBasisSwap')) -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (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.CInt -> ((QlStubIndexSelection) -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO (C2HSImp.Ptr (CConstNotionalCrossCurrencyFixedVsFloatingSwap')))))))))))))))))))))))))))))

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

foreign import ccall safe "QuantLib/Instrument/Swap.chs.h qlConstNotionalCrossCurrencyFixedVsFloatingSwapFairSpread"
  qlConstNotionalCrossCurrencyFixedVsFloatingSwapFairSpread'_ :: ((C2HSImp.Ptr (CConstNotionalCrossCurrencyFixedVsFloatingSwap')) -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (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 ())) -> (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 ())) -> (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 ())) -> (IO (C2HSImp.Ptr (CIrregularSwap')))))))

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

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

foreign import ccall safe "QuantLib/Instrument/Swap.chs.h qlNonstandardSwaption1"
  nonstandardSwaptionFromSwaption'_ :: ((C2HSImp.Ptr (CSwaption')) -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (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 ())) -> (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 ())) -> (IO ()))))))))

foreign import ccall safe "QuantLib/Instrument/Swap.chs.h qlFloatFloatSwaption"
  floatFloatSwaption'_ :: ((C2HSImp.Ptr (CFloatFloatSwap')) -> ((QlExercise) -> (C2HSImp.CInt -> (C2HSImp.CInt -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (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 ())) -> (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 ())) -> (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.CInt -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (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.CInt -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO (C2HSImp.Ptr (COvernightIndexedSwap')))))))))))))))))))))

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

foreign import ccall safe "QuantLib/Instrument/Swap.chs.h qlOvernightIndexedSwapOvernightLegNPV"
  overnightLegNpv'_ :: ((C2HSImp.Ptr (COvernightIndexedSwap')) -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (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 ())) -> (IO (C2HSImp.Ptr (CZeroCouponInflationSwap')))))))))))))))))))

foreign import ccall safe "QuantLib/Instrument/Swap.chs.h qlZeroCouponInflationSwapFairRate"
  qlZeroCouponInflationSwapFairRate'_ :: ((C2HSImp.Ptr (CZeroCouponInflationSwap')) -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (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 ())) -> (IO (C2HSImp.Ptr (CYearOnYearInflationSwap'))))))))))))))))))

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

foreign import ccall safe "QuantLib/Instrument/Swap.chs.h qlYearOnYearInflationSwapFairSpread"
  qlYearOnYearInflationSwapFairSpread'_ :: ((C2HSImp.Ptr (CYearOnYearInflationSwap')) -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (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 ())) -> (IO (C2HSImp.Ptr (CCPISwap')))))))))))))))))))))))

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

foreign import ccall safe "QuantLib/Instrument/Swap.chs.h qlCPISwapFairSpread"
  qlCPISwapFairSpread'_ :: ((C2HSImp.Ptr (CCPISwap')) -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (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 ())) -> (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 ())) -> (IO (C2HSImp.Ptr (CZeroCouponSwap'))))))))))))))

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

foreign import ccall safe "QuantLib/Instrument/Swap.chs.h qlZeroCouponSwapFairFixedRate"
  fairFixedRate'_ :: ((C2HSImp.Ptr (CZeroCouponSwap')) -> ((C2HSImp.Ptr (CDayCounter)) -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (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 ())) -> (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 ())) -> (IO (C2HSImp.Ptr (CEquityTotalReturnSwap')))))))))))))))

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

foreign import ccall safe "QuantLib/Instrument/Swap.chs.h qlAssetSwapFloatingLegNPV"
  qlAssetSwapFloatingLegNPV'_ :: ((C2HSImp.Ptr (CAssetSwap')) -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (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 ())) -> (IO (C2HSImp.Ptr (CVarianceSwap')))))))))

foreign import ccall safe "QuantLib/Instrument/Swap.chs.h qlVarianceSwapVariance"
  variance'_ :: ((C2HSImp.Ptr (CVarianceSwap')) -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (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 ())) -> (IO (C2HSImp.Ptr (CVarianceOption'))))))))

foreign import ccall safe "QuantLib/Instrument/Swap.chs.h qlMtMCrossCurrencyBasisSwap"
  mtmCrossCurrencyBasisSwapRaw'_ :: (C2HSImp.CInt -> (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.CUInt -> ((C2HSImp.Ptr (CCalendar)) -> (C2HSImp.CInt -> (C2HSImp.CInt -> (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.CInt -> ((QlStubIndexSelection) -> ((QlStubIndexSelection) -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO (C2HSImp.Ptr (CMtMCrossCurrencyBasisSwap'))))))))))))))))))))))))))))))))))))))

foreign import ccall safe "QuantLib/Instrument/Swap.chs.h qlMtMLegCurrency"
  mtmLegCurrency'_ :: ((C2HSImp.Ptr (CMtMCrossCurrencyBasisSwap')) -> (C2HSImp.CUInt -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO (C2HSImp.Ptr (CCurrency))))))

foreign import ccall safe "QuantLib/Instrument/Swap.chs.h qlMtMInCcyLegBPS"
  mtmInCcyLegBPS'_ :: ((C2HSImp.Ptr (CMtMCrossCurrencyBasisSwap')) -> (C2HSImp.CUInt -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO C2HSImp.CDouble))))

foreign import ccall safe "QuantLib/Instrument/Swap.chs.h qlMtMInCcyLegNPV"
  mtmInCcyLegNPV'_ :: ((C2HSImp.Ptr (CMtMCrossCurrencyBasisSwap')) -> (C2HSImp.CUInt -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO C2HSImp.CDouble))))

foreign import ccall safe "QuantLib/Instrument/Swap.chs.h qlMtMNpvDateDiscounts"
  mtmNpvDateDiscounts'_ :: ((C2HSImp.Ptr (CMtMCrossCurrencyBasisSwap')) -> (C2HSImp.CUInt -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO C2HSImp.CDouble))))

foreign import ccall safe "QuantLib/Instrument/Swap.chs.h qlMtMFairFxBaseSpread"
  fairFxBaseSpread'_ :: ((C2HSImp.Ptr (CMtMCrossCurrencyBasisSwap')) -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO C2HSImp.CDouble)))

foreign import ccall safe "QuantLib/Instrument/Swap.chs.h qlMtMFairFxQuoteSpread"
  fairFxQuoteSpread'_ :: ((C2HSImp.Ptr (CMtMCrossCurrencyBasisSwap')) -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO C2HSImp.CDouble)))

foreign import ccall safe "QuantLib/Instrument/Swap.chs.h qlMtMFairPaySpread"
  mtmFairPaySpread'_ :: ((C2HSImp.Ptr (CMtMCrossCurrencyBasisSwap')) -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO C2HSImp.CDouble)))

foreign import ccall safe "QuantLib/Instrument/Swap.chs.h qlMtMFairRecSpread"
  mtmFairRecSpread'_ :: ((C2HSImp.Ptr (CMtMCrossCurrencyBasisSwap')) -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO C2HSImp.CDouble)))

foreign import ccall safe "QuantLib/Instrument/Swap.chs.h qlMtMFxResetRates"
  fxResetRates'_ :: ((C2HSImp.Ptr (CMtMCrossCurrencyBasisSwap')) -> ((C2HSImp.Ptr C2HSImp.CUInt) -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CDouble)) -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO ())))))

foreign import ccall safe "QuantLib/Instrument/Swap.chs.h qlMtMFxResetNotionals"
  fxResetNotionals'_ :: ((C2HSImp.Ptr (CMtMCrossCurrencyBasisSwap')) -> ((C2HSImp.Ptr C2HSImp.CUInt) -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CDouble)) -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO ())))))