never executed always true always false
    1 -- GENERATED by C->Haskell Compiler, version 0.28.8 Switcheroo, 25 November 2017 (Haskell)
    2 -- Edit the ORIGNAL .chs file instead!
    3 
    4 
    5 {-# LANGUAGE FlexibleInstances #-}
    6 {-# LANGUAGE TemplateHaskell #-}
    7 module QuantLib.Instrument.Swap
    8   (
    9     Swaption
   10   , NonstandardSwaption
   11   , Swap
   12   , FixedVsFloatingSwap
   13   , VanillaSwap
   14   , NonstandardSwap
   15   , FloatFloatSwap
   16   , FloatFloatSwaption
   17   , AssetSwap
   18   , OvernightIndexedSwap
   19   , BMASwap
   20   , ZeroCouponInflationSwap
   21   , YearOnYearInflationSwap
   22   , CPISwap
   23   , ZeroCouponSwap
   24   , EquityTotalReturnSwap
   25   , VarianceSwap
   26   , VarianceOption
   27   , ConstNotionalCrossCurrencySwap
   28   , ConstNotionalCrossCurrencyBasisSwap
   29   , ConstNotionalCrossCurrencyFixedVsFloatingSwap
   30 
   31   , asSwap
   32 
   33   , impliedVolatility
   34   , SwapType(..)
   35   , SwaptionPriceType(..)
   36   , CPIInterpolationType(..)
   37   , CalibrationBasketType(..)
   38   , FloatFloatSwapOpts(..)
   39   , defaultFloatFloatSwapOpts
   40   , FloatFloatSwapVaryingOpts(..)
   41   , defaultFloatFloatSwapVaryingOpts
   42   , ConstNotionalCrossCurrencyBasisSwapOpts(..)
   43   , defaultConstNotionalCrossCurrencyBasisSwapOpts
   44 
   45   , swap'
   46   , swap
   47   , bmaSwap
   48   , vanillaSwap
   49   , nonstandardSwapFromVanilla
   50   , nonstandardSwap
   51   , nonstandardSwap'
   52   , floatFloatSwap
   53   , floatFloatSwap'
   54   , fairSpread1
   55   , fairSpread2
   56   , makeVanillaSwap
   57   , makeCms
   58   , zeroCouponInflationSwap
   59   , zcisFairRate
   60   , yearOnYearInflationSwap
   61   , yoyFairRate
   62   , cpiSwap
   63   , cpiSwapFairRate
   64   , zeroCouponSwap
   65   , zeroCouponSwap'
   66   , fairFixedPayment
   67   , fairFixedRate
   68   , equityTotalReturnSwapIbor
   69   , equityTotalReturnSwapOvernight
   70   , equityLegNPV
   71   , interestRateLegNPV
   72   , fairMargin
   73   , varianceSwap
   74   , variance
   75   , varianceOption
   76 
   77   , endDiscounts
   78   , leg
   79   , legBPS
   80   , legNPV
   81   , maturityDate
   82   , npvDateDiscount
   83   , startDate
   84   , startDiscounts
   85 
   86   -- ConstNotionalCrossCurrencySwap family
   87   , constNotionalCrossCurrencySwap
   88   , constNotionalCrossCurrencySwap'
   89   , legCurrency
   90   , inCcyLegBPS
   91   , inCcyLegNPV
   92   , npvDateDiscounts
   93   , constNotionalCrossCurrencyBasisSwap
   94   , fairPaySpread
   95   , fairRecSpread
   96   , constNotionalCrossCurrencyFixedVsFloatingSwap
   97   , xccyFairRate
   98 
   99   , bmaLeg
  100   , bmaLegBPS
  101   , bmaLegNPV
  102   , fairLiborFraction
  103   , fairLiborSpread
  104   , liborFraction
  105   , liborLeg
  106   , liborLegBPS
  107   , liborLegNPV
  108 
  109   , swaption
  110   , nonstandardSwaptionFromSwaption
  111   , nonstandardSwaption
  112   , floatFloatSwaption
  113   , calibrationBasket
  114   , floatFloatSwaptionCalibrationBasket
  115 
  116   -- AssetSwap
  117   , assetSwap
  118 
  119   , bondLeg
  120   , cleanPrice
  121   , fairCleanPrice
  122   , fairNonParRepayment
  123   , nonParRepayment
  124   , parSwap
  125   , payBondCoupon
  126 
  127   -- OvernightIndexedSwap
  128   , overnightIndexedSwap
  129   , overnightIndexedSwap'
  130 
  131   , overnightLeg
  132   , overnightLegBPS
  133   , overnightLegNPV
  134 
  135   , HasFixedLeg(..)
  136   , HasFloatingLeg(..)
  137   , HasSpread(..)
  138   ) where
  139 import qualified Foreign.C.Types as C2HSImp
  140 import qualified Foreign.ForeignPtr as C2HSImp
  141 import qualified Foreign.Marshal.Utils as C2HSImp
  142 import qualified Foreign.Ptr as C2HSImp
  143 
  144 
  145 import Data.Maybe(fromMaybe)
  146 import QuantLib.Internal.Syntax(deriveOptionsRecord)
  147 import QuantLib.Internal
  148 import QuantLib.Instrument
  149 
  150 import QuantLib.InterestRate(VolatilityType)
  151 import QuantLib.CashFlow(RateAveragingType(..))
  152 import QuantLib.CashFlow(cmsLeg, iborLeg)
  153 import QuantLib.Time.Calendar(adjust, advance)
  154 import QuantLib.Internal.Type
  155 import QuantLib.Internal.Common
  156 import QuantLib.Time.Schedule(schedule, DateGenerationRule(..))
  157 import QuantLib.Time.Date(addPeriod)
  158 import QuantLib.Settings(evaluationDate)
  159 import QuantLib.Index(fixingCalendar)
  160 import QuantLib.Index.InterestRate(tenor, dayCounter, businessDayConvention)
  161 
  162 
  163 
  164 
  165 
  166 
  167 
  168 
  169 
  170 
  171 
  172 
  173 
  174 
  175 
  176 
  177 
  178 
  179 
  180 
  181 
  182 
  183 
  184 
  185 
  186 
  187 
  188 
  189 
  190 
  191 
  192 
  193 data SwapType = Receiver
  194               | Payer
  195   deriving (Show,Eq,Read)
  196 instance Enum SwapType where
  197   succ Receiver = Payer
  198   succ Payer = error "SwapType.succ: Payer has no successor"
  199 
  200   pred Payer = Receiver
  201   pred Receiver = error "SwapType.pred: Receiver has no predecessor"
  202 
  203   enumFromTo from to = go from
  204     where
  205       end = fromEnum to
  206       go v = case compare (fromEnum v) end of
  207                  LT -> v : go (succ v)
  208                  EQ -> [v]
  209                  GT -> []
  210 
  211   enumFrom from = enumFromTo from Payer
  212 
  213   fromEnum Receiver = (-1)
  214   fromEnum Payer = 1
  215 
  216   toEnum (-1) = Receiver
  217   toEnum 1 = Payer
  218   toEnum unmatched = error ("SwapType.toEnum: Cannot match " ++ show unmatched)
  219 
  220 
  221 data SwaptionPriceType = SwaptionSpot
  222                        | SwaptionForward
  223   deriving (Enum,Show,Eq,Read)
  224 
  225 
  226 
  227 
  228 
  229 
  230 
  231 
  232 
  233 
  234 
  235 
  236 
  237 
  238 
  239 
  240 
  241 
  242 
  243 
  244 
  245 
  246 
  247 
  248 
  249 
  250 
  251 
  252 
  253 
  254 
  255 
  256 
  257 
  258 
  259 
  260 
  261 
  262 
  263 
  264 
  265 
  266 
  267 
  268 
  269 
  270 
  271 
  272 
  273 
  274 
  275 
  276 
  277 
  278 
  279 
  280 -- FloatFloatSwapOpts/FloatFloatSwapVaryingOpts bundle every trailing param of FloatFloatSwap's
  281 -- two constructors (floatfloatswap.hpp) -- 12 trailing defaulted params each, past the
  282 -- options-record threshold (see the add-quantlib-options-record skill). Two separate records
  283 -- (not one shared) since the scalar ctor's gearing/spread/cappedRate/flooredRate are plain
  284 -- Double/Maybe Double while the vector ctor's are [Double]. This splice must stay textually
  285 -- before every {#fun#}-generated binding in this file -- see OISRateHelperOpts in
  286 -- QuantLib/TermStructure/Yield.chs for why (c2hs always appends its raw foreign-import stubs at
  287 -- the physical end of the generated module regardless of where in the .chs a {#fun#} hook
  288 -- appears, so a top-level TH splice in between would split the file into declaration groups
  289 -- that can't see each other).
  290 $(deriveOptionsRecord "FloatFloatSwapOpts" []
  291   [ ("ffsIntermediateCapitalExchange", [t|Bool|], [|False|])
  292   , ("ffsFinalCapitalExchange", [t|Bool|], [|False|])
  293   , ("ffsGearing1", [t|Double|], [|1.0|])
  294   , ("ffsSpread1", [t|Double|], [|0.0|])
  295   , ("ffsCappedRate1", [t|Maybe Double|], [|Nothing|])
  296   , ("ffsFlooredRate1", [t|Maybe Double|], [|Nothing|])
  297   , ("ffsGearing2", [t|Double|], [|1.0|])
  298   , ("ffsSpread2", [t|Double|], [|0.0|])
  299   , ("ffsCappedRate2", [t|Maybe Double|], [|Nothing|])
  300   , ("ffsFlooredRate2", [t|Maybe Double|], [|Nothing|])
  301   , ("ffsPaymentConvention1", [t|Maybe BusinessDayConvention|], [|Nothing|])
  302   , ("ffsPaymentConvention2", [t|Maybe BusinessDayConvention|], [|Nothing|])
  303   ])
  304 $(deriveOptionsRecord "FloatFloatSwapVaryingOpts" []
  305   [ ("ffsvIntermediateCapitalExchange", [t|Bool|], [|False|])
  306   , ("ffsvFinalCapitalExchange", [t|Bool|], [|False|])
  307   , ("ffsvGearing1", [t|[Double]|], [|[]|])
  308   , ("ffsvSpread1", [t|[Double]|], [|[]|])
  309   , ("ffsvCappedRate1", [t|[Double]|], [|[]|])
  310   , ("ffsvFlooredRate1", [t|[Double]|], [|[]|])
  311   , ("ffsvGearing2", [t|[Double]|], [|[]|])
  312   , ("ffsvSpread2", [t|[Double]|], [|[]|])
  313   , ("ffsvCappedRate2", [t|[Double]|], [|[]|])
  314   , ("ffsvFlooredRate2", [t|[Double]|], [|[]|])
  315   , ("ffsvPaymentConvention1", [t|Maybe BusinessDayConvention|], [|Nothing|])
  316   , ("ffsvPaymentConvention2", [t|Maybe BusinessDayConvention|], [|Nothing|])
  317   ])
  318 
  319 -- ConstNotionalCrossCurrencyBasisSwapOpts bundles ConstNotionalCrossCurrencyBasisSwap's 13
  320 -- trailing defaulted params (per-leg OIS-only payment lag, compound-spread, lookback,
  321 -- observation shift, lockout, averaging method, plus a shared telescopicValueDates), past the
  322 -- options-record threshold -- see FloatFloatSwapOpts above for why this splice must stay
  323 -- textually before every {#fun#} in this file. ConstNotionalCrossCurrencyFixedVsFloatingSwap's
  324 -- constructor has only 6 trailing defaults (under the threshold), so it's widened in place
  325 -- instead -- see 'constNotionalCrossCurrencyFixedVsFloatingSwap' below.
  326 $(deriveOptionsRecord "ConstNotionalCrossCurrencyBasisSwapOpts" []
  327   [ ("cccbsPayPaymentLag", [t|Int|], [|0|])
  328   , ("cccbsRecPaymentLag", [t|Int|], [|0|])
  329   , ("cccbsPayCompoundSpread", [t|Bool|], [|False|])
  330   , ("cccbsPayLookbackDays", [t|Maybe Word|], [|Nothing|])
  331   , ("cccbsPayObservationShift", [t|Bool|], [|False|])
  332   , ("cccbsPayLockoutDays", [t|Word|], [|0|])
  333   , ("cccbsPayAveragingMethod", [t|RateAveragingType|], [|AveragingCompound|])
  334   , ("cccbsRecCompoundSpread", [t|Bool|], [|False|])
  335   , ("cccbsRecLookbackDays", [t|Maybe Word|], [|Nothing|])
  336   , ("cccbsRecObservationShift", [t|Bool|], [|False|])
  337   , ("cccbsRecLockoutDays", [t|Word|], [|0|])
  338   , ("cccbsRecAveragingMethod", [t|RateAveragingType|], [|AveragingCompound|])
  339   , ("cccbsTelescopicValueDates", [t|Bool|], [|False|])
  340   ])
  341 
  342 -- |implied volatility
  343 impliedVolatility :: (Swaption) -> (Double) -- ^price
  344  -> (GenYieldTermStructure y) -> (Double) -- ^guess
  345  -> (Double) -- ^accuracy
  346  -> (Word) -- ^maxEvaluations
  347  -> (Double) -- ^minVol
  348  -> (Double) -- ^maxVol
  349  -> (VolatilityType) -- ^type
  350  -> (Double) -- ^displacement
  351  -> (SwaptionPriceType) -- ^priceType
  352  -> IO ((Double))
  353 impliedVolatility a1 a2 a3 a4 a5 a6 a7 a8 a9 a10 a11 =
  354   withSwaption a1 $ \a1' -> 
  355   let {a2' = realToFrac a2} in 
  356   withYieldTermStructure a3 $ \a3' -> 
  357   let {a4' = realToFrac a4} in 
  358   let {a5' = realToFrac a5} in 
  359   let {a6' = fromIntegral a6} in 
  360   let {a7' = realToFrac a7} in 
  361   let {a8' = realToFrac a8} in 
  362   let {a9' = (fromIntegral . fromEnum) a9} in 
  363   let {a10' = realToFrac a10} in 
  364   let {a11' = (fromIntegral . fromEnum) a11} in 
  365   preErrorCheck $ \a12' -> 
  366   impliedVolatility'_ a1' a2' a3' a4' a5' a6' a7' a8' a9' a10' a11' a12' >>= \res ->
  367   let {res' = realToFrac res} in
  368   errorCheck  a12'>>
  369   return (res')
  370 
  371 
  372 
  373 -- |Multi leg constructor.
  374 swap' :: [(Leg, Bool)] -- ^(legs, payer)
  375   -> IO Swap
  376 swap' = (uncurry qlSwap1) . unzip
  377 qlSwap1 :: ([Leg]) -> ([Bool]) -> IO ((Swap))
  378 qlSwap1 a1 a2 =
  379   withLegArray a1 $ \(a1'1, a1'2) -> 
  380   withBoolArray a2 $ \(a2'1, a2'2) -> 
  381   preErrorCheck $ \a3' -> 
  382   qlSwap1'_ a1'1  a1'2 a2'1  a2'2 a3' >>= \res ->
  383   peekSwap res >>= \res' ->
  384   errorCheck  a3'>>
  385   return (res')
  386 
  387 
  388 
  389 -- |Swap paying Libor against BMA coupons
  390 bmaSwap :: (SwapType) -> (Double) -- ^nominal
  391  -> (Schedule) -- ^liborSchedule
  392  -> (Double) -- ^liborFraction
  393  -> (Double) -- ^liborSpread
  394  -> (GenIborIndex ibor) -> (DayCounter) -- ^liborDayCount
  395  -> (Schedule) -- ^bmaSchedule
  396  -> (BMAIndex) -> (DayCounter) -- ^bmaDayCount
  397  -> IO ((BMASwap))
  398 bmaSwap a1 a2 a3 a4 a5 a6 a7 a8 a9 a10 =
  399   let {a1' = (fromIntegral . fromEnum) a1} in 
  400   let {a2' = realToFrac a2} in 
  401   withSchedule a3 $ \a3' -> 
  402   let {a4' = realToFrac a4} in 
  403   let {a5' = realToFrac a5} in 
  404   withIborIndex a6 $ \a6' -> 
  405   withDayCounter a7 $ \a7' -> 
  406   withSchedule a8 $ \a8' -> 
  407   withBMAIndex a9 $ \a9' -> 
  408   withDayCounter a10 $ \a10' -> 
  409   preErrorCheck $ \a11' -> 
  410   bmaSwap'_ a1' a2' a3' a4' a5' a6' a7' a8' a9' a10' a11' >>= \res ->
  411   peekBMASwap res >>= \res' ->
  412   errorCheck  a11'>>
  413   return (res')
  414 
  415 
  416 
  417 -- |Fixed-rate vs floating-rate (Ibor) swap; if no payment convention is given, the floating leg's is used.
  418 vanillaSwap :: (SwapType) -> (Double) -- ^nominal
  419  -> (Schedule) -- ^fixedSchedule
  420  -> (Double) -- ^fixedRate
  421  -> (DayCounter) -- ^fixedDayCount
  422  -> (Schedule) -- ^floatSchedule
  423  -> (GenIborIndex ibor) -> (Double) -- ^spread
  424  -> (DayCounter) -- ^floatingDayCount
  425  -> (Maybe BusinessDayConvention) -- ^paymentConvention
  426  -> (Maybe Bool) -- ^useIndexedCoupons
  427  -> IO ((VanillaSwap))
  428 vanillaSwap a1 a2 a3 a4 a5 a6 a7 a8 a9 a10 a11 =
  429   let {a1' = (fromIntegral . fromEnum) a1} in 
  430   let {a2' = realToFrac a2} in 
  431   withSchedule a3 $ \a3' -> 
  432   let {a4' = realToFrac a4} in 
  433   withDayCounter a5 $ \a5' -> 
  434   withSchedule a6 $ \a6' -> 
  435   withIborIndex a7 $ \a7' -> 
  436   let {a8' = realToFrac a8} in 
  437   withDayCounter a9 $ \a9' -> 
  438   let {a10' = fromMaybeEnum a10} in 
  439   let {a11' = fromMaybeBool a11} in 
  440   preErrorCheck $ \a12' -> 
  441   vanillaSwap'_ a1' a2' a3' a4' a5' a6' a7' a8' a9' a10' a11' a12' >>= \res ->
  442   peekVanillaSwap res >>= \res' ->
  443   errorCheck  a12'>>
  444   return (res')
  445 
  446 
  447 
  448 -- |Converts an existing 'FixedVsFloatingSwap' (e.g. a 'VanillaSwap') into a 'NonstandardSwap'
  449 -- (upstream's own conversion constructor, @NonstandardSwap(const FixedVsFloatingSwap&)@).
  450 nonstandardSwapFromVanilla :: (GenFixedVsFloatingSwap f) -> IO ((NonstandardSwap))
  451 nonstandardSwapFromVanilla a1 =
  452   withFixedVsFloatingSwap a1 $ \a1' -> 
  453   preErrorCheck $ \a2' -> 
  454   nonstandardSwapFromVanilla'_ a1' a2' >>= \res ->
  455   peekNonstandardSwap res >>= \res' ->
  456   errorCheck  a2'>>
  457   return (res')
  458 
  459 
  460 
  461 -- |'VanillaSwap' generalized to per-period fixed/floating nominals and fixed rates, plus
  462 -- optional intermediate\/final notional exchange -- a single 'Double' gearing\/spread shared
  463 -- across all floating periods. See 'nonstandardSwap'' for a per-period gearing\/spread.
  464 nonstandardSwap :: (SwapType) -> ([Double]) -- ^fixedNominal
  465  -> ([Double]) -- ^floatingNominal
  466  -> (Schedule) -- ^fixedSchedule
  467  -> ([Double]) -- ^fixedRate
  468  -> (DayCounter) -- ^fixedDayCount
  469  -> (Schedule) -- ^floatingSchedule
  470  -> (GenIborIndex ibor) -> (Double) -- ^gearing
  471  -> (Double) -- ^spread
  472  -> (DayCounter) -- ^floatingDayCount
  473  -> (Bool) -- ^intermediateCapitalExchange
  474  -> (Bool) -- ^finalCapitalExchange
  475  -> (Maybe BusinessDayConvention) -- ^paymentConvention
  476  -> IO ((NonstandardSwap))
  477 nonstandardSwap a1 a2 a3 a4 a5 a6 a7 a8 a9 a10 a11 a12 a13 a14 =
  478   let {a1' = (fromIntegral . fromEnum) a1} in 
  479   withDoubleArray a2 $ \(a2'1, a2'2) -> 
  480   withDoubleArray a3 $ \(a3'1, a3'2) -> 
  481   withSchedule a4 $ \a4' -> 
  482   withDoubleArray a5 $ \(a5'1, a5'2) -> 
  483   withDayCounter a6 $ \a6' -> 
  484   withSchedule a7 $ \a7' -> 
  485   withIborIndex a8 $ \a8' -> 
  486   let {a9' = realToFrac a9} in 
  487   let {a10' = realToFrac a10} in 
  488   withDayCounter a11 $ \a11' -> 
  489   let {a12' = C2HSImp.fromBool a12} in 
  490   let {a13' = C2HSImp.fromBool a13} in 
  491   let {a14' = fromMaybeEnum a14} in 
  492   preErrorCheck $ \a15' -> 
  493   nonstandardSwap'_ a1' a2'1  a2'2 a3'1  a3'2 a4' a5'1  a5'2 a6' a7' a8' a9' a10' a11' a12' a13' a14' a15' >>= \res ->
  494   peekNonstandardSwap res >>= \res' ->
  495   errorCheck  a15'>>
  496   return (res')
  497 
  498 
  499 
  500 -- |As 'nonstandardSwap', but with a per-period gearing and spread instead of one shared value.
  501 nonstandardSwap' :: (SwapType) -> ([Double]) -- ^fixedNominal
  502  -> ([Double]) -- ^floatingNominal
  503  -> (Schedule) -- ^fixedSchedule
  504  -> ([Double]) -- ^fixedRate
  505  -> (DayCounter) -- ^fixedDayCount
  506  -> (Schedule) -- ^floatingSchedule
  507  -> (GenIborIndex ibor) -> ([Double]) -- ^gearing
  508  -> ([Double]) -- ^spread
  509  -> (DayCounter) -- ^floatingDayCount
  510  -> (Bool) -- ^intermediateCapitalExchange
  511  -> (Bool) -- ^finalCapitalExchange
  512  -> (Maybe BusinessDayConvention) -- ^paymentConvention
  513  -> IO ((NonstandardSwap))
  514 nonstandardSwap' a1 a2 a3 a4 a5 a6 a7 a8 a9 a10 a11 a12 a13 a14 =
  515   let {a1' = (fromIntegral . fromEnum) a1} in 
  516   withDoubleArray a2 $ \(a2'1, a2'2) -> 
  517   withDoubleArray a3 $ \(a3'1, a3'2) -> 
  518   withSchedule a4 $ \a4' -> 
  519   withDoubleArray a5 $ \(a5'1, a5'2) -> 
  520   withDayCounter a6 $ \a6' -> 
  521   withSchedule a7 $ \a7' -> 
  522   withIborIndex a8 $ \a8' -> 
  523   withDoubleArray a9 $ \(a9'1, a9'2) -> 
  524   withDoubleArray a10 $ \(a10'1, a10'2) -> 
  525   withDayCounter a11 $ \a11' -> 
  526   let {a12' = C2HSImp.fromBool a12} in 
  527   let {a13' = C2HSImp.fromBool a13} in 
  528   let {a14' = fromMaybeEnum a14} in 
  529   preErrorCheck $ \a15' -> 
  530   nonstandardSwap''_ a1' a2'1  a2'2 a3'1  a3'2 a4' a5'1  a5'2 a6' a7' a8' a9'1  a9'2 a10'1  a10'2 a11' a12' a13' a14' a15' >>= \res ->
  531   peekNonstandardSwap res >>= \res' ->
  532   errorCheck  a15'>>
  533   return (res')
  534 
  535 
  536 
  537 -- |Swap exchanging capped\/floored Libor or CMS coupons with a single flat nominal on each leg.
  538 -- 'FloatFloatSwapOpts' bundles every trailing param the C++ constructor defaults (gearing\/
  539 -- spread\/cap\/floor per leg, capital exchange, payment conventions); override only what's
  540 -- needed via record-update syntax on 'defaultFloatFloatSwapOpts'. See 'floatFloatSwap'' for the
  541 -- per-period-nominal overload.
  542 floatFloatSwap :: SwapType -> Double -> Double -> Schedule -> GenInterestRateIndex ridx1
  543   -> DayCounter -> Schedule -> GenInterestRateIndex ridx2 -> DayCounter -> FloatFloatSwapOpts
  544   -> IO FloatFloatSwap
  545 floatFloatSwap ty nominal1 nominal2 schedule1 index1 dayCount1 schedule2 index2 dayCount2 opts =
  546   floatFloatSwap_ ty nominal1 nominal2 schedule1 index1 dayCount1 schedule2 index2 dayCount2
  547     (ffsIntermediateCapitalExchange opts) (ffsFinalCapitalExchange opts)
  548     (ffsGearing1 opts) (ffsSpread1 opts) (ffsCappedRate1 opts) (ffsFlooredRate1 opts)
  549     (ffsGearing2 opts) (ffsSpread2 opts) (ffsCappedRate2 opts) (ffsFlooredRate2 opts)
  550     (ffsPaymentConvention1 opts) (ffsPaymentConvention2 opts)
  551 
  552 floatFloatSwap_ :: (SwapType) -> (Double) -- ^nominal1
  553  -> (Double) -- ^nominal2
  554  -> (Schedule) -- ^schedule1
  555  -> (GenInterestRateIndex ridx1) -> (DayCounter) -- ^dayCount1
  556  -> (Schedule) -- ^schedule2
  557  -> (GenInterestRateIndex ridx2) -> (DayCounter) -- ^dayCount2
  558  -> (Bool) -- ^intermediateCapitalExchange
  559  -> (Bool) -- ^finalCapitalExchange
  560  -> (Double) -- ^gearing1
  561  -> (Double) -- ^spread1
  562  -> (Maybe Double) -- ^cappedRate1
  563  -> (Maybe Double) -- ^flooredRate1
  564  -> (Double) -- ^gearing2
  565  -> (Double) -- ^spread2
  566  -> (Maybe Double) -- ^cappedRate2
  567  -> (Maybe Double) -- ^flooredRate2
  568  -> (Maybe BusinessDayConvention) -- ^paymentConvention1
  569  -> (Maybe BusinessDayConvention) -- ^paymentConvention2
  570  -> IO ((FloatFloatSwap))
  571 floatFloatSwap_ a1 a2 a3 a4 a5 a6 a7 a8 a9 a10 a11 a12 a13 a14 a15 a16 a17 a18 a19 a20 a21 =
  572   let {a1' = (fromIntegral . fromEnum) a1} in 
  573   let {a2' = realToFrac a2} in 
  574   let {a3' = realToFrac a3} in 
  575   withSchedule a4 $ \a4' -> 
  576   withInterestRateIndex a5 $ \a5' -> 
  577   withDayCounter a6 $ \a6' -> 
  578   withSchedule a7 $ \a7' -> 
  579   withInterestRateIndex a8 $ \a8' -> 
  580   withDayCounter a9 $ \a9' -> 
  581   let {a10' = C2HSImp.fromBool a10} in 
  582   let {a11' = C2HSImp.fromBool a11} in 
  583   let {a12' = realToFrac a12} in 
  584   let {a13' = realToFrac a13} in 
  585   let {a14' = fromMaybeDouble a14} in 
  586   let {a15' = fromMaybeDouble a15} in 
  587   let {a16' = realToFrac a16} in 
  588   let {a17' = realToFrac a17} in 
  589   let {a18' = fromMaybeDouble a18} in 
  590   let {a19' = fromMaybeDouble a19} in 
  591   let {a20' = fromMaybeEnum a20} in 
  592   let {a21' = fromMaybeEnum a21} in 
  593   preErrorCheck $ \a22' -> 
  594   floatFloatSwap_'_ a1' a2' a3' a4' a5' a6' a7' a8' a9' a10' a11' a12' a13' a14' a15' a16' a17' a18' a19' a20' a21' a22' >>= \res ->
  595   peekFloatFloatSwap res >>= \res' ->
  596   errorCheck  a22'>>
  597   return (res')
  598 
  599 
  600 
  601 -- |As 'floatFloatSwap', but with a per-period nominal on each leg instead of a single flat value
  602 -- (full coverage; not used by the upstream example).
  603 floatFloatSwap' :: SwapType -> [Double] -> [Double] -> Schedule -> GenInterestRateIndex ridx1
  604   -> DayCounter -> Schedule -> GenInterestRateIndex ridx2 -> DayCounter
  605   -> FloatFloatSwapVaryingOpts -> IO FloatFloatSwap
  606 floatFloatSwap' ty nominal1 nominal2 schedule1 index1 dayCount1 schedule2 index2 dayCount2 opts =
  607   floatFloatSwap2_ ty nominal1 nominal2 schedule1 index1 dayCount1 schedule2 index2 dayCount2
  608     (ffsvIntermediateCapitalExchange opts) (ffsvFinalCapitalExchange opts)
  609     (ffsvGearing1 opts) (ffsvSpread1 opts) (ffsvCappedRate1 opts) (ffsvFlooredRate1 opts)
  610     (ffsvGearing2 opts) (ffsvSpread2 opts) (ffsvCappedRate2 opts) (ffsvFlooredRate2 opts)
  611     (ffsvPaymentConvention1 opts) (ffsvPaymentConvention2 opts)
  612 
  613 floatFloatSwap2_ :: (SwapType) -> ([Double]) -- ^nominal1
  614  -> ([Double]) -- ^nominal2
  615  -> (Schedule) -- ^schedule1
  616  -> (GenInterestRateIndex ridx1) -> (DayCounter) -- ^dayCount1
  617  -> (Schedule) -- ^schedule2
  618  -> (GenInterestRateIndex ridx2) -> (DayCounter) -- ^dayCount2
  619  -> (Bool) -- ^intermediateCapitalExchange
  620  -> (Bool) -- ^finalCapitalExchange
  621  -> ([Double]) -- ^gearing1
  622  -> ([Double]) -- ^spread1
  623  -> ([Double]) -- ^cappedRate1
  624  -> ([Double]) -- ^flooredRate1
  625  -> ([Double]) -- ^gearing2
  626  -> ([Double]) -- ^spread2
  627  -> ([Double]) -- ^cappedRate2
  628  -> ([Double]) -- ^flooredRate2
  629  -> (Maybe BusinessDayConvention) -- ^paymentConvention1
  630  -> (Maybe BusinessDayConvention) -- ^paymentConvention2
  631  -> IO ((FloatFloatSwap))
  632 floatFloatSwap2_ a1 a2 a3 a4 a5 a6 a7 a8 a9 a10 a11 a12 a13 a14 a15 a16 a17 a18 a19 a20 a21 =
  633   let {a1' = (fromIntegral . fromEnum) a1} in 
  634   withDoubleArray a2 $ \(a2'1, a2'2) -> 
  635   withDoubleArray a3 $ \(a3'1, a3'2) -> 
  636   withSchedule a4 $ \a4' -> 
  637   withInterestRateIndex a5 $ \a5' -> 
  638   withDayCounter a6 $ \a6' -> 
  639   withSchedule a7 $ \a7' -> 
  640   withInterestRateIndex a8 $ \a8' -> 
  641   withDayCounter a9 $ \a9' -> 
  642   let {a10' = C2HSImp.fromBool a10} in 
  643   let {a11' = C2HSImp.fromBool a11} in 
  644   withDoubleArray a12 $ \(a12'1, a12'2) -> 
  645   withDoubleArray a13 $ \(a13'1, a13'2) -> 
  646   withDoubleArray a14 $ \(a14'1, a14'2) -> 
  647   withDoubleArray a15 $ \(a15'1, a15'2) -> 
  648   withDoubleArray a16 $ \(a16'1, a16'2) -> 
  649   withDoubleArray a17 $ \(a17'1, a17'2) -> 
  650   withDoubleArray a18 $ \(a18'1, a18'2) -> 
  651   withDoubleArray a19 $ \(a19'1, a19'2) -> 
  652   let {a20' = fromMaybeEnum a20} in 
  653   let {a21' = fromMaybeEnum a21} in 
  654   preErrorCheck $ \a22' -> 
  655   floatFloatSwap2_'_ a1' a2'1  a2'2 a3'1  a3'2 a4' a5' a6' a7' a8' a9' a10' a11' a12'1  a12'2 a13'1  a13'2 a14'1  a14'2 a15'1  a15'2 a16'1  a16'2 a17'1  a17'2 a18'1  a18'2 a19'1  a19'2 a20' a21' a22' >>= \res ->
  656   peekFloatFloatSwap res >>= \res' ->
  657   errorCheck  a22'>>
  658   return (res')
  659 
  660 
  661 
  662 -- |The spread on leg 1 that would make the swap's NPV zero.
  663 fairSpread1 :: (FloatFloatSwap) -> IO ((Double))
  664 fairSpread1 a1 =
  665   withFloatFloatSwap a1 $ \a1' -> 
  666   preErrorCheck $ \a2' -> 
  667   fairSpread1'_ a1' a2' >>= \res ->
  668   let {res' = realToFrac res} in
  669   errorCheck  a2'>>
  670   return (res')
  671 
  672 
  673 
  674 -- |The spread on leg 2 that would make the swap's NPV zero.
  675 fairSpread2 :: (FloatFloatSwap) -> IO ((Double))
  676 fairSpread2 a1 =
  677   withFloatFloatSwap a1 $ \a1' -> 
  678   preErrorCheck $ \a2' -> 
  679   fairSpread2'_ a1' a2' >>= \res ->
  680   let {res' = realToFrac res} in
  681   errorCheck  a2'>>
  682   return (res')
  683 
  684 
  685 
  686 -- | Haskell equivalent of QuantLib's fluent @MakeVanillaSwap@ builder -- a
  687 -- single function with 'Maybe'-wrapped optional parameters instead of
  688 -- chained @.with*@ calls, covering the subset of @makevanillaswap.hpp@'s
  689 -- fields named in the parameters below. Not covered at all (no parameter):
  690 -- explicit effective\/termination date overrides, a settlement calendar
  691 -- distinct from the floating-leg one, floating-leg tenor\/convention\/
  692 -- termination convention\/day count overrides (always taken from the
  693 -- index, matching upstream's own defaults), @withRule@ variants (always
  694 -- @DateGeneration::Backward@), end-of-month\/first-date\/next-to-last-date
  695 -- overrides, a floating-leg spread other than @0@, a discounting term
  696 -- structure or custom pricing engine (use 'setPricingEngine' on the
  697 -- result instead), indexed\/at-par coupon overrides, and payment
  698 -- convention (always the floating leg's, matching upstream's own default
  699 -- when unset). @fixedLegTenor@\/@fixedLegDayCount@ are required arguments
  700 -- here rather than optional with upstream's currency-based inference. A
  701 -- 'Nothing' @settlementDays@ behaves as @Just 0@, rather than replicating
  702 -- upstream's index-@valueDate@-based spot-date convention.
  703 makeVanillaSwap
  704   :: (Word, TimeUnit)             -- ^swapTenor
  705   -> GenIborIndex ibor
  706   -> Double                       -- ^fixedRate
  707   -> (Int, TimeUnit)              -- ^forwardStart
  708   -> Maybe Int                    -- ^settlementDays
  709   -> (Word, TimeUnit)             -- ^fixedLegTenor
  710   -> DayCounter                   -- ^fixedLegDayCount
  711   -> Maybe BusinessDayConvention  -- ^fixedLegConvention
  712   -> Maybe BusinessDayConvention  -- ^fixedLegTerminationDateConvention
  713   -> Maybe Calendar               -- ^fixedLegCalendar
  714   -> Maybe Calendar               -- ^floatingLegCalendar
  715   -> Maybe Double                 -- ^nominal
  716   -> Maybe SwapType
  717   -> IO VanillaSwap
  718 makeVanillaSwap (swLen, swUnit) index fixedRate forwardStart mSettlementDays
  719     fixedTenor fixedDayCount mFixedConvention mFixedTerminationConvention mFixedCalendar
  720     mFloatCalendar mNominal mType = do
  721   idxCalendar <- fixingCalendar index
  722   floatTenor <- tenor index
  723   floatDayCount <- dayCounter index
  724   refDate <- evaluationDate
  725   let floatConv = businessDayConvention index
  726       floatCalendar = fromMaybe idxCalendar mFloatCalendar
  727       fixedCalendar = fromMaybe idxCalendar mFixedCalendar
  728       fixedConvention = fromMaybe ModifiedFollowing mFixedConvention
  729       fixedTerminationConvention = fromMaybe ModifiedFollowing mFixedTerminationConvention
  730       settlementDays = fromMaybe 0 mSettlementDays
  731       nominal = fromMaybe 1.0 mNominal
  732       swapType = fromMaybe Payer mType
  733       (fsLen, _) = forwardStart
  734   spotDate <- advance floatCalendar refDate (settlementDays, Days) Following False
  735   startDate0 <- addPeriod spotDate forwardStart
  736   swapStartDate <- case compare fsLen 0 of
  737     LT -> adjust floatCalendar startDate0 Preceding
  738     GT -> adjust floatCalendar startDate0 Following
  739     EQ -> pure startDate0
  740   endDate <- addPeriod swapStartDate (fromIntegral swLen, swUnit)
  741   fixedSchedule <- schedule (Just swapStartDate) endDate fixedTenor fixedCalendar
  742     fixedConvention fixedTerminationConvention Backward False Nothing Nothing
  743   floatSchedule <- schedule (Just swapStartDate) endDate floatTenor floatCalendar
  744     floatConv floatConv Backward False Nothing Nothing
  745   vanillaSwap swapType nominal fixedSchedule fixedRate fixedDayCount
  746     floatSchedule index 0.0 floatDayCount (Just floatConv) Nothing
  747 
  748 -- |Haskell equivalent of QuantLib's fluent @MakeCms@ builder, in the style of
  749 -- 'makeVanillaSwap' above -- not a binding of the @MakeCms@ C++ class at all, but a plain
  750 -- function composing already-bound primitives ('QuantLib.Time.Schedule.schedule',
  751 -- 'QuantLib.CashFlow.cmsLeg', 'QuantLib.CashFlow.iborLeg', 'swap''). The result is a plain
  752 -- 'Swap' (a CMS swap has no calc\/getter of its own beyond generic 'Swap''s), with no
  753 -- 'FloatingRateCouponPricer' attached -- attach one to the CMS leg afterwards via
  754 -- @setCouponPricer =<< 'leg' result 0@ ('swap'' is used instead of 'swap' precisely so the
  755 -- CMS leg is always leg 0, regardless of 'SwapType') and 'QuantLib.CashFlow.setCouponPricer'
  756 -- before pricing.
  757 --
  758 -- Unlike @MakeCms@, @cmsLegTenor@\/@cmsLegDayCount@ are required arguments here rather than
  759 -- defaulted (upstream hardcodes 3 Months\/@Actual360@); pass those literals to reproduce
  760 -- @MakeCms@'s own defaults. Not covered at all (no parameter): an explicit effective date
  761 -- override, CMS-leg\/floating-leg termination-date-convention\/rule\/end-of-month\/
  762 -- first-date\/next-to-last-date overrides (always @ModifiedFollowing@\/@Backward@\/@False@\/
  763 -- unset, matching @MakeCms@'s own defaults for the CMS leg), CMS coupon gearing\/caps\/floors
  764 -- (use 'QuantLib.CashFlow.cmsLegFull' and 'swap' directly for those), an ATM-spread lookup, a
  765 -- discounting term structure or custom pricing engine (use 'QuantLib.Instrument.setPricingEngine'
  766 -- on the result instead). A 'Nothing' @settlementDays@ behaves as @Just 0@, rather than
  767 -- replicating upstream's index-@valueDate@-based spot-date convention (matching
  768 -- 'makeVanillaSwap''s own choice here).
  769 makeCms
  770   :: (Word, TimeUnit)             -- ^swapTenor
  771   -> GenSwapIndex sidx            -- ^cms index
  772   -> GenIborIndex ibor            -- ^floating-leg index
  773   -> Double                       -- ^floating-leg spread
  774   -> (Int, TimeUnit)              -- ^forwardStart
  775   -> Maybe Int                    -- ^settlementDays
  776   -> (Word, TimeUnit)             -- ^cmsLegTenor
  777   -> DayCounter                   -- ^cmsLegDayCount
  778   -> Maybe Calendar               -- ^cmsLegCalendar
  779   -> Maybe Calendar               -- ^floatingLegCalendar
  780   -> Maybe Double                 -- ^nominal
  781   -> Maybe SwapType                -- ^'Payer' pays the CMS leg (receives floating); 'Receiver' the reverse
  782   -> IO Swap
  783 makeCms (swLen, swUnit) swapIndex iborIndex iborSpread forwardStart mSettlementDays
  784     cmsTenor cmsDayCount mCmsCalendar mFloatCalendar mNominal mType = do
  785   idxCalendar <- fixingCalendar swapIndex
  786   floatTenor <- tenor iborIndex
  787   floatDayCount <- dayCounter iborIndex
  788   refDate <- evaluationDate
  789   let floatConv = businessDayConvention iborIndex
  790       floatCalendar = fromMaybe idxCalendar mFloatCalendar
  791       cmsCalendar = fromMaybe idxCalendar mCmsCalendar
  792       settlementDays = fromMaybe 0 mSettlementDays
  793       nominal = fromMaybe 1.0 mNominal
  794       swapType = fromMaybe Payer mType
  795       (fsLen, _) = forwardStart
  796   spotDate <- advance floatCalendar refDate (settlementDays, Days) Following False
  797   startDate0 <- addPeriod spotDate forwardStart
  798   swapStartDate <- case compare fsLen 0 of
  799     LT -> adjust floatCalendar startDate0 Preceding
  800     GT -> adjust floatCalendar startDate0 Following
  801     EQ -> pure startDate0
  802   endDate <- addPeriod swapStartDate (fromIntegral swLen, swUnit)
  803   cmsSchedule <- schedule (Just swapStartDate) endDate cmsTenor cmsCalendar
  804     ModifiedFollowing ModifiedFollowing Backward False Nothing Nothing
  805   floatSchedule <- schedule (Just swapStartDate) endDate floatTenor floatCalendar
  806     floatConv floatConv Backward False Nothing Nothing
  807   cmsLegResult <- cmsLeg cmsSchedule swapIndex [nominal] cmsDayCount ModifiedFollowing
  808     [] [] [] [] [] False False
  809   floatLegResult <- iborLeg floatSchedule iborIndex [nominal] floatDayCount floatConv
  810     [] [] [iborSpread] [] [] False False
  811   -- 'swap'' (not 'swap') so the CMS leg is always leg 0 of the result regardless of
  812   -- 'SwapType' -- attach a pricer via @setCouponPricer =<< 'leg' result 0@ before pricing.
  813   swap' [(cmsLegResult, swapType == Payer), (floatLegResult, swapType == Receiver)]
  814 
  815 -- |The cash flows belonging to the first leg are paid; the ones belonging to the second leg are received.
  816 swap :: (GenLeg l1) -> (GenLeg l2) -> IO ((Swap))
  817 swap a1 a2 =
  818   withLeg a1 $ \a1' -> 
  819   withLeg a2 $ \a2' -> 
  820   preErrorCheck $ \a3' -> 
  821   swap'_ a1' a2' a3' >>= \res ->
  822   peekSwap res >>= \res' ->
  823   errorCheck  a3'>>
  824   return (res')
  825 
  826 
  827 
  828 -- |Discount factor at leg j's end date.
  829 endDiscounts :: (GenSwap s) -> (Word) -> IO ((Double))
  830 endDiscounts a1 a2 =
  831   withSwap a1 $ \a1' -> 
  832   let {a2' = fromIntegral a2} in 
  833   preErrorCheck $ \a3' -> 
  834   endDiscounts'_ a1' a2' a3' >>= \res ->
  835   let {res' = realToFrac res} in
  836   errorCheck  a3'>>
  837   return (res')
  838 
  839 
  840 
  841 -- |The j-th leg's cash flows.
  842 leg :: (GenSwap s) -> (Word) -> IO ((Leg))
  843 leg a1 a2 =
  844   withSwap a1 $ \a1' -> 
  845   let {a2' = fromIntegral a2} in 
  846   preErrorCheck $ \a3' -> 
  847   leg'_ a1' a2' a3' >>= \res ->
  848   peekLeg res >>= \res' ->
  849   errorCheck  a3'>>
  850   return (res')
  851 
  852 
  853 
  854 -- |Basis-point sensitivity of leg j.
  855 legBPS :: (GenSwap s) -> (Word) -> IO ((Double))
  856 legBPS a1 a2 =
  857   withSwap a1 $ \a1' -> 
  858   let {a2' = fromIntegral a2} in 
  859   preErrorCheck $ \a3' -> 
  860   legBPS'_ a1' a2' a3' >>= \res ->
  861   let {res' = realToFrac res} in
  862   errorCheck  a3'>>
  863   return (res')
  864 
  865 
  866 
  867 -- |NPV of leg j.
  868 legNPV :: (GenSwap s) -> (Word) -> IO ((Double))
  869 legNPV a1 a2 =
  870   withSwap a1 $ \a1' -> 
  871   let {a2' = fromIntegral a2} in 
  872   preErrorCheck $ \a3' -> 
  873   legNPV'_ a1' a2' a3' >>= \res ->
  874   let {res' = realToFrac res} in
  875   errorCheck  a3'>>
  876   return (res')
  877 
  878 
  879 
  880 -- |Discount factor at leg j's start date.
  881 startDiscounts :: (GenSwap s) -> (Word) -> IO ((Double))
  882 startDiscounts a1 a2 =
  883   withSwap a1 $ \a1' -> 
  884   let {a2' = fromIntegral a2} in 
  885   preErrorCheck $ \a3' -> 
  886   startDiscounts'_ a1' a2' a3' >>= \res ->
  887   let {res' = realToFrac res} in
  888   errorCheck  a3'>>
  889   return (res')
  890 
  891 
  892 
  893 -- ConstNotionalCrossCurrencySwap
  894 -- |Constructs a cross-currency swap from two legs and their currencies; the first leg is paid, the second received.
  895 constNotionalCrossCurrencySwap :: (GenLeg l1) -> (Currency) -- ^firstLegCcy
  896  -> (GenLeg l2) -> (Currency) -- ^secondLegCcy
  897  -> IO ((ConstNotionalCrossCurrencySwap))
  898 constNotionalCrossCurrencySwap a1 a2 a3 a4 =
  899   withLeg a1 $ \a1' -> 
  900   withCurrency a2 $ \a2' -> 
  901   withLeg a3 $ \a3' -> 
  902   withCurrency a4 $ \a4' -> 
  903   preErrorCheck $ \a5' -> 
  904   constNotionalCrossCurrencySwap'_ a1' a2' a3' a4' a5' >>= \res ->
  905   peekConstNotionalCrossCurrencySwap res >>= \res' ->
  906   errorCheck  a5'>>
  907   return (res')
  908 
  909 
  910 
  911 -- |Multi-leg constructor.
  912 constNotionalCrossCurrencySwap' :: [(Leg, Bool)] -- ^(legs, payer)
  913   -> [Currency] -> IO ConstNotionalCrossCurrencySwap
  914 constNotionalCrossCurrencySwap' legsPayer = qlConstNotionalCrossCurrencySwap1 legs payer
  915   where (legs, payer) = unzip legsPayer
  916 qlConstNotionalCrossCurrencySwap1 :: ([Leg]) -> ([Bool]) -> ([Currency]) -> IO ((ConstNotionalCrossCurrencySwap))
  917 qlConstNotionalCrossCurrencySwap1 a1 a2 a3 =
  918   withLegArray a1 $ \(a1'1, a1'2) -> 
  919   withBoolArray a2 $ \(a2'1, a2'2) -> 
  920   withCurrencyArray a3 $ \(a3'1, a3'2) -> 
  921   preErrorCheck $ \a4' -> 
  922   qlConstNotionalCrossCurrencySwap1'_ a1'1  a1'2 a2'1  a2'2 a3'1  a3'2 a4' >>= \res ->
  923   peekConstNotionalCrossCurrencySwap res >>= \res' ->
  924   errorCheck  a4'>>
  925   return (res')
  926 
  927 
  928 
  929 -- |Leg j's currency.
  930 legCurrency :: (GenConstNotionalCrossCurrencySwap x) -> (Word) -> IO ((Currency))
  931 legCurrency a1 a2 =
  932   withConstNotionalCrossCurrencySwap a1 $ \a1' -> 
  933   let {a2' = fromIntegral a2} in 
  934   preErrorCheck $ \a3' -> 
  935   legCurrency'_ a1' a2' a3' >>= \res ->
  936   peekCurrency res >>= \res' ->
  937   errorCheck  a3'>>
  938   return (res')
  939 
  940 
  941 
  942 -- |Basis-point sensitivity of leg j, expressed in the leg's own currency (contrast 'legBPS', in the swap's NPV currency).
  943 inCcyLegBPS :: (GenConstNotionalCrossCurrencySwap x) -> (Word) -> IO ((Double))
  944 inCcyLegBPS a1 a2 =
  945   withConstNotionalCrossCurrencySwap a1 $ \a1' -> 
  946   let {a2' = fromIntegral a2} in 
  947   preErrorCheck $ \a3' -> 
  948   inCcyLegBPS'_ a1' a2' a3' >>= \res ->
  949   let {res' = realToFrac res} in
  950   errorCheck  a3'>>
  951   return (res')
  952 
  953 
  954 
  955 -- |NPV of leg j, expressed in the leg's own currency (contrast 'legNPV', in the swap's NPV currency).
  956 inCcyLegNPV :: (GenConstNotionalCrossCurrencySwap x) -> (Word) -> IO ((Double))
  957 inCcyLegNPV a1 a2 =
  958   withConstNotionalCrossCurrencySwap a1 $ \a1' -> 
  959   let {a2' = fromIntegral a2} in 
  960   preErrorCheck $ \a3' -> 
  961   inCcyLegNPV'_ a1' a2' a3' >>= \res ->
  962   let {res' = realToFrac res} in
  963   errorCheck  a3'>>
  964   return (res')
  965 
  966 
  967 
  968 -- |Discount factor at the instrument's NPV date, for leg j.
  969 npvDateDiscounts :: (GenConstNotionalCrossCurrencySwap x) -> (Word) -> IO ((Double))
  970 npvDateDiscounts a1 a2 =
  971   withConstNotionalCrossCurrencySwap a1 $ \a1' -> 
  972   let {a2' = fromIntegral a2} in 
  973   preErrorCheck $ \a3' -> 
  974   npvDateDiscounts'_ a1' a2' a3' >>= \res ->
  975   let {res' = realToFrac res} in
  976   errorCheck  a3'>>
  977   return (res')
  978 
  979 
  980 
  981 -- ConstNotionalCrossCurrencyBasisSwap
  982 -- |Cross-currency basis swap: pay-currency cashflows on leg 0, receive-currency on leg 1.
  983 -- 'ConstNotionalCrossCurrencyBasisSwapOpts' bundles every trailing param the C++ constructor
  984 -- defaults (all OIS-only -- payment lag, compound-spread, lookback, observation shift, lockout,
  985 -- averaging method per leg, plus a shared telescopic-value-dates flag; ignored for a plain Ibor
  986 -- 'payIndex'\/'recIndex', since upstream itself only consults them when the index is an overnight
  987 -- index); override only what's needed via record-update syntax on
  988 -- 'defaultConstNotionalCrossCurrencyBasisSwapOpts'.
  989 constNotionalCrossCurrencyBasisSwap :: Double -> Currency -> Schedule -> GenIborIndex ibor1 -> Double -> Double
  990   -> Double -> Currency -> Schedule -> GenIborIndex ibor2 -> Double -> Double
  991   -> ConstNotionalCrossCurrencyBasisSwapOpts -> IO ConstNotionalCrossCurrencyBasisSwap
  992 constNotionalCrossCurrencyBasisSwap payNominal payCurrency paySchedule payIndex paySpread payGearing
  993     recNominal recCurrency recSchedule recIndex recSpread recGearing opts =
  994   constNotionalCrossCurrencyBasisSwap_ payNominal payCurrency paySchedule payIndex paySpread payGearing
  995     recNominal recCurrency recSchedule recIndex recSpread recGearing
  996     (cccbsPayPaymentLag opts) (cccbsRecPaymentLag opts)
  997     (cccbsPayCompoundSpread opts) (cccbsPayLookbackDays opts) (cccbsPayObservationShift opts)
  998     (cccbsPayLockoutDays opts) (cccbsPayAveragingMethod opts)
  999     (cccbsRecCompoundSpread opts) (cccbsRecLookbackDays opts) (cccbsRecObservationShift opts)
 1000     (cccbsRecLockoutDays opts) (cccbsRecAveragingMethod opts)
 1001     (cccbsTelescopicValueDates opts)
 1002 
 1003 constNotionalCrossCurrencyBasisSwap_ :: (Double) -- ^payNominal
 1004  -> (Currency) -- ^payCurrency
 1005  -> (Schedule) -- ^paySchedule
 1006  -> (GenIborIndex ibor1) -- ^payIndex
 1007  -> (Double) -- ^paySpread
 1008  -> (Double) -- ^payGearing
 1009  -> (Double) -- ^recNominal
 1010  -> (Currency) -- ^recCurrency
 1011  -> (Schedule) -- ^recSchedule
 1012  -> (GenIborIndex ibor2) -- ^recIndex
 1013  -> (Double) -- ^recSpread
 1014  -> (Double) -- ^recGearing
 1015  -> (Int) -- ^payPaymentLag
 1016  -> (Int) -- ^recPaymentLag
 1017  -> (Bool) -- ^payCompoundSpread
 1018  -> (Maybe Word) -- ^payLookbackDays
 1019  -> (Bool) -- ^payObservationShift
 1020  -> (Word) -- ^payLockoutDays
 1021  -> (RateAveragingType) -- ^payAveragingMethod
 1022  -> (Bool) -- ^recCompoundSpread
 1023  -> (Maybe Word) -- ^recLookbackDays
 1024  -> (Bool) -- ^recObservationShift
 1025  -> (Word) -- ^recLockoutDays
 1026  -> (RateAveragingType) -- ^recAveragingMethod
 1027  -> (Bool) -- ^telescopicValueDates
 1028  -> IO ((ConstNotionalCrossCurrencyBasisSwap))
 1029 constNotionalCrossCurrencyBasisSwap_ a1 a2 a3 a4 a5 a6 a7 a8 a9 a10 a11 a12 a13 a14 a15 a16 a17 a18 a19 a20 a21 a22 a23 a24 a25 =
 1030   let {a1' = realToFrac a1} in 
 1031   withCurrency a2 $ \a2' -> 
 1032   withSchedule a3 $ \a3' -> 
 1033   withIborIndex a4 $ \a4' -> 
 1034   let {a5' = realToFrac a5} in 
 1035   let {a6' = realToFrac a6} in 
 1036   let {a7' = realToFrac a7} in 
 1037   withCurrency a8 $ \a8' -> 
 1038   withSchedule a9 $ \a9' -> 
 1039   withIborIndex a10 $ \a10' -> 
 1040   let {a11' = realToFrac a11} in 
 1041   let {a12' = realToFrac a12} in 
 1042   let {a13' = fromIntegral a13} in 
 1043   let {a14' = fromIntegral a14} in 
 1044   let {a15' = C2HSImp.fromBool a15} in 
 1045   let {a16' = fromMaybeInt a16} in 
 1046   let {a17' = C2HSImp.fromBool a17} in 
 1047   let {a18' = fromIntegral a18} in 
 1048   let {a19' = (fromIntegral . fromEnum) a19} in 
 1049   let {a20' = C2HSImp.fromBool a20} in 
 1050   let {a21' = fromMaybeInt a21} in 
 1051   let {a22' = C2HSImp.fromBool a22} in 
 1052   let {a23' = fromIntegral a23} in 
 1053   let {a24' = (fromIntegral . fromEnum) a24} in 
 1054   let {a25' = C2HSImp.fromBool a25} in 
 1055   preErrorCheck $ \a26' -> 
 1056   constNotionalCrossCurrencyBasisSwap_'_ a1' a2' a3' a4' a5' a6' a7' a8' a9' a10' a11' a12' a13' a14' a15' a16' a17' a18' a19' a20' a21' a22' a23' a24' a25' a26' >>= \res ->
 1057   peekConstNotionalCrossCurrencyBasisSwap res >>= \res' ->
 1058   errorCheck  a26'>>
 1059   return (res')
 1060 
 1061 
 1062 
 1063 -- |The pay-leg spread that would make the swap's NPV zero.
 1064 fairPaySpread :: (ConstNotionalCrossCurrencyBasisSwap) -> IO ((Double))
 1065 fairPaySpread a1 =
 1066   withConstNotionalCrossCurrencyBasisSwap a1 $ \a1' -> 
 1067   preErrorCheck $ \a2' -> 
 1068   fairPaySpread'_ a1' a2' >>= \res ->
 1069   let {res' = realToFrac res} in
 1070   errorCheck  a2'>>
 1071   return (res')
 1072 
 1073 
 1074 
 1075 -- |The receive-leg spread that would make the swap's NPV zero.
 1076 fairRecSpread :: (ConstNotionalCrossCurrencyBasisSwap) -> IO ((Double))
 1077 fairRecSpread a1 =
 1078   withConstNotionalCrossCurrencyBasisSwap a1 $ \a1' -> 
 1079   preErrorCheck $ \a2' -> 
 1080   fairRecSpread'_ a1' a2' >>= \res ->
 1081   let {res' = realToFrac res} in
 1082   errorCheck  a2'>>
 1083   return (res')
 1084 
 1085 
 1086 
 1087 -- ConstNotionalCrossCurrencyFixedVsFloatingSwap
 1088 -- |Cross-currency fixed-vs-floating swap: 'Payer' pays the fixed leg (leg 0) and receives the
 1089 -- floating leg (leg 1); 'Receiver' the reverse. Every trailing defaulted param of the upstream
 1090 -- constructor is a required argument here (only 6 trailing defaults, under the options-record
 1091 -- threshold -- see 'ConstNotionalCrossCurrencyBasisSwapOpts' above) -- pass @False@\/@False@\/
 1092 -- 'Nothing'\/@False@\/@0@\/'AveragingCompound' to reproduce upstream's own defaults; the
 1093 -- OIS-only ones are ignored for a plain Ibor 'floatIndex'.
 1094 constNotionalCrossCurrencyFixedVsFloatingSwap :: (SwapType) -> (Double) -- ^fixedNominal
 1095  -> (Currency) -- ^fixedCurrency
 1096  -> (Schedule) -- ^fixedSchedule
 1097  -> (Double) -- ^fixedRate
 1098  -> (DayCounter) -- ^fixedDayCount
 1099  -> (BusinessDayConvention) -- ^fixedPaymentBdc
 1100  -> (Word) -- ^fixedPaymentLag
 1101  -> (Calendar) -- ^fixedPaymentCalendar
 1102  -> (Double) -- ^floatNominal
 1103  -> (Currency) -- ^floatCurrency
 1104  -> (Schedule) -- ^floatSchedule
 1105  -> (GenIborIndex ibor) -- ^floatIndex
 1106  -> (Double) -- ^floatSpread
 1107  -> (BusinessDayConvention) -- ^floatPaymentBdc
 1108  -> (Word) -- ^floatPaymentLag
 1109  -> (Calendar) -- ^floatPaymentCalendar
 1110  -> (Bool) -- ^telescopicValueDates
 1111  -> (Bool) -- ^floatCompoundSpread
 1112  -> (Maybe Word) -- ^floatLookbackDays
 1113  -> (Bool) -- ^floatObservationShift
 1114  -> (Word) -- ^floatLockoutDays
 1115  -> (RateAveragingType) -- ^floatAveragingMethod
 1116  -> IO ((ConstNotionalCrossCurrencyFixedVsFloatingSwap))
 1117 constNotionalCrossCurrencyFixedVsFloatingSwap a1 a2 a3 a4 a5 a6 a7 a8 a9 a10 a11 a12 a13 a14 a15 a16 a17 a18 a19 a20 a21 a22 a23 =
 1118   let {a1' = (fromIntegral . fromEnum) a1} in 
 1119   let {a2' = realToFrac a2} in 
 1120   withCurrency a3 $ \a3' -> 
 1121   withSchedule a4 $ \a4' -> 
 1122   let {a5' = realToFrac a5} in 
 1123   withDayCounter a6 $ \a6' -> 
 1124   let {a7' = fromEnumC a7} in 
 1125   let {a8' = fromIntegral a8} in 
 1126   withCalendar a9 $ \a9' -> 
 1127   let {a10' = realToFrac a10} in 
 1128   withCurrency a11 $ \a11' -> 
 1129   withSchedule a12 $ \a12' -> 
 1130   withIborIndex a13 $ \a13' -> 
 1131   let {a14' = realToFrac a14} in 
 1132   let {a15' = fromEnumC a15} in 
 1133   let {a16' = fromIntegral a16} in 
 1134   withCalendar a17 $ \a17' -> 
 1135   let {a18' = C2HSImp.fromBool a18} in 
 1136   let {a19' = C2HSImp.fromBool a19} in 
 1137   let {a20' = fromMaybeInt a20} in 
 1138   let {a21' = C2HSImp.fromBool a21} in 
 1139   let {a22' = fromIntegral a22} in 
 1140   let {a23' = (fromIntegral . fromEnum) a23} in 
 1141   preErrorCheck $ \a24' -> 
 1142   constNotionalCrossCurrencyFixedVsFloatingSwap'_ a1' a2' a3' a4' a5' a6' a7' a8' a9' a10' a11' a12' a13' a14' a15' a16' a17' a18' a19' a20' a21' a22' a23' a24' >>= \res ->
 1143   peekConstNotionalCrossCurrencyFixedVsFloatingSwap res >>= \res' ->
 1144   errorCheck  a24'>>
 1145   return (res')
 1146 
 1147 
 1148 
 1149 -- |The fixed rate that would make the swap's NPV zero. Named distinctly from 'fairRate' -- that
 1150 -- name belongs to the 'HasFixedLeg' class, which this type doesn't implement (upstream gives it
 1151 -- no fixedLeg\/fixedLegBPS\/fixedLegNPV getters); 'fairSpread' (via 'HasSpread') is available.
 1152 xccyFairRate :: (ConstNotionalCrossCurrencyFixedVsFloatingSwap) -> IO ((Double))
 1153 xccyFairRate a1 =
 1154   withConstNotionalCrossCurrencyFixedVsFloatingSwap a1 $ \a1' -> 
 1155   preErrorCheck $ \a2' -> 
 1156   xccyFairRate'_ a1' a2' >>= \res ->
 1157   let {res' = realToFrac res} in
 1158   errorCheck  a2'>>
 1159   return (res')
 1160 
 1161 
 1162 
 1163 instance HasSpread ConstNotionalCrossCurrencyFixedVsFloatingSwap where
 1164   fairSpread = qlConstNotionalCrossCurrencyFixedVsFloatingSwapFairSpread
 1165 qlConstNotionalCrossCurrencyFixedVsFloatingSwapFairSpread :: (ConstNotionalCrossCurrencyFixedVsFloatingSwap) -> IO ((Double))
 1166 qlConstNotionalCrossCurrencyFixedVsFloatingSwapFairSpread a1 =
 1167   withConstNotionalCrossCurrencyFixedVsFloatingSwap a1 $ \a1' -> 
 1168   preErrorCheck $ \a2' -> 
 1169   qlConstNotionalCrossCurrencyFixedVsFloatingSwapFairSpread'_ a1' a2' >>= \res ->
 1170   let {res' = realToFrac res} in
 1171   errorCheck  a2'>>
 1172   return (res')
 1173 
 1174 
 1175 
 1176 -- |An option on a 'VanillaSwap'.
 1177 swaption :: (GenFixedVsFloatingSwap f) -> (Exercise) -> (SettlementType) -> (SettlementMethod) -> IO ((Swaption))
 1178 swaption a1 a2 a3 a4 =
 1179   withFixedVsFloatingSwap a1 $ \a1' -> 
 1180   withExercise a2 $ \a2' -> 
 1181   let {a3' = (fromIntegral . fromEnum) a3} in 
 1182   let {a4' = (fromIntegral . fromEnum) a4} in 
 1183   preErrorCheck $ \a5' -> 
 1184   swaption'_ a1' a2' a3' a4' a5' >>= \res ->
 1185   peekSwaption res >>= \res' ->
 1186   errorCheck  a5'>>
 1187   return (res')
 1188 
 1189 
 1190 
 1191 -- |Converts an existing 'Swaption' into a 'NonstandardSwaption' (upstream's own conversion
 1192 -- constructor).
 1193 nonstandardSwaptionFromSwaption :: (Swaption) -> IO ((NonstandardSwaption))
 1194 nonstandardSwaptionFromSwaption a1 =
 1195   withSwaption a1 $ \a1' -> 
 1196   preErrorCheck $ \a2' -> 
 1197   nonstandardSwaptionFromSwaption'_ a1' a2' >>= \res ->
 1198   peekNonstandardSwaption res >>= \res' ->
 1199   errorCheck  a2'>>
 1200   return (res')
 1201 
 1202 
 1203 
 1204 -- |An option on a 'NonstandardSwap'.
 1205 nonstandardSwaption :: (NonstandardSwap) -> (Exercise) -> (SettlementType) -> (SettlementMethod) -> IO ((NonstandardSwaption))
 1206 nonstandardSwaption a1 a2 a3 a4 =
 1207   withNonstandardSwap a1 $ \a1' -> 
 1208   withExercise a2 $ \a2' -> 
 1209   let {a3' = (fromIntegral . fromEnum) a3} in 
 1210   let {a4' = (fromIntegral . fromEnum) a4} in 
 1211   preErrorCheck $ \a5' -> 
 1212   nonstandardSwaption'_ a1' a2' a3' a4' a5' >>= \res ->
 1213   peekNonstandardSwaption res >>= \res' ->
 1214   errorCheck  a5'>>
 1215   return (res')
 1216 
 1217 
 1218 
 1219 -- |Auto-generates a basket of plain 'Swaption's used to calibrate a model to price a
 1220 -- 'NonstandardSwaption' -- either ATM swaptions adapted to the exercise dates ('Naive') or
 1221 -- swaptions whose maturity\/strike\/nominal match the underlying's NPV, delta and gamma at each
 1222 -- exercise date ('MaturityStrikeByDeltaGamma').
 1223 calibrationBasket :: (NonstandardSwaption) -> (GenSwapIndex sidx) -- ^standardSwapBase
 1224  -> (GenSwaptionVolatilityStructure sv) -- ^swaptionVolatility
 1225  -> (CalibrationBasketType) -> IO (([BlackCalibrationHelper]))
 1226 calibrationBasket a1 a2 a3 a4 =
 1227   withNonstandardSwaption a1 $ \a1' -> 
 1228   withSwapIndex a2 $ \a2' -> 
 1229   withSwaptionVolatilityStructure a3 $ \a3' -> 
 1230   let {a4' = fromEnumC a4} in 
 1231   preArray $ \(a5'1, a5'2) -> 
 1232   preErrorCheck $ \a6' -> 
 1233   calibrationBasket'_ a1' a2' a3' a4' a5'1  a5'2 a6' >>
 1234   peekBlackCalibrationHelperArray  a5'1  a5'2>>= \a5'' -> 
 1235   errorCheck  a6'>>
 1236   return (a5'')
 1237 
 1238 
 1239 
 1240 -- |An option on a 'FloatFloatSwap'.
 1241 floatFloatSwaption :: (FloatFloatSwap) -> (Exercise) -> (SettlementType) -> (SettlementMethod) -> IO ((FloatFloatSwaption))
 1242 floatFloatSwaption a1 a2 a3 a4 =
 1243   withFloatFloatSwap a1 $ \a1' -> 
 1244   withExercise a2 $ \a2' -> 
 1245   let {a3' = (fromIntegral . fromEnum) a3} in 
 1246   let {a4' = (fromIntegral . fromEnum) a4} in 
 1247   preErrorCheck $ \a5' -> 
 1248   floatFloatSwaption'_ a1' a2' a3' a4' a5' >>= \res ->
 1249   peekFloatFloatSwaption res >>= \res' ->
 1250   errorCheck  a5'>>
 1251   return (res')
 1252 
 1253 
 1254 
 1255 -- |As 'calibrationBasket', for a 'FloatFloatSwaption'.
 1256 floatFloatSwaptionCalibrationBasket :: (FloatFloatSwaption) -> (GenSwapIndex sidx) -- ^standardSwapBase
 1257  -> (GenSwaptionVolatilityStructure sv) -- ^swaptionVolatility
 1258  -> (CalibrationBasketType) -> IO (([BlackCalibrationHelper]))
 1259 floatFloatSwaptionCalibrationBasket a1 a2 a3 a4 =
 1260   withFloatFloatSwaption a1 $ \a1' -> 
 1261   withSwapIndex a2 $ \a2' -> 
 1262   withSwaptionVolatilityStructure a3 $ \a3' -> 
 1263   let {a4' = fromEnumC a4} in 
 1264   preArray $ \(a5'1, a5'2) -> 
 1265   preErrorCheck $ \a6' -> 
 1266   floatFloatSwaptionCalibrationBasket'_ a1' a2' a3' a4' a5'1  a5'2 a6' >>
 1267   peekBlackCalibrationHelperArray  a5'1  a5'2>>= \a5'' -> 
 1268   errorCheck  a6'>>
 1269   return (a5'')
 1270 
 1271 
 1272 
 1273 -- AssetSwap
 1274 -- |Bullet bond vs Libor swap (par or market asset swap, per /parAssetSwap/).
 1275 assetSwap :: (Bool) -- ^payBondCoupon
 1276  -> (Bond) -> (Double) -- ^bondCleanPrice
 1277  -> (GenIborIndex ibor) -> (Double) -- spread
 1278  -> (Schedule) -- ^floatSchedule
 1279  -> (DayCounter) -- ^floatingDayCount
 1280  -> (Bool) -- ^parAssetSwap
 1281  -> (Double) -- ^gearing
 1282  -> (Maybe Double) -- ^nonParRepayment
 1283  -> (Maybe Day) -- ^dealMaturity
 1284  -> IO ((AssetSwap))
 1285 assetSwap a1 a2 a3 a4 a5 a6 a7 a8 a9 a10 a11 =
 1286   let {a1' = C2HSImp.fromBool a1} in 
 1287   withBond a2 $ \a2' -> 
 1288   let {a3' = realToFrac a3} in 
 1289   withIborIndex a4 $ \a4' -> 
 1290   let {a5' = realToFrac a5} in 
 1291   withSchedule a6 $ \a6' -> 
 1292   withDayCounter a7 $ \a7' -> 
 1293   let {a8' = C2HSImp.fromBool a8} in 
 1294   let {a9' = realToFrac a9} in 
 1295   let {a10' = fromMaybeDouble a10} in 
 1296   withMaybeDay a11 $ \a11' -> 
 1297   preErrorCheck $ \a12' -> 
 1298   assetSwap'_ a1' a2' a3' a4' a5' a6' a7' a8' a9' a10' a11' a12' >>= \res ->
 1299   peekAssetSwap res >>= \res' ->
 1300   errorCheck  a12'>>
 1301   return (res')
 1302 
 1303 
 1304 -- OvernightIndexedSwap
 1305 -- |Fixed vs compounded-overnight-rate swap, with a single flat nominal for both legs.
 1306 overnightIndexedSwap :: (SwapType) -> (Double) -- ^nominal
 1307  -> (Schedule) -> (Double) -- ^fixedRate
 1308  -> (DayCounter) -- ^fixedDC
 1309  -> (OvernightIborIndex) -> (Double) -- ^spread
 1310  -> (Int) -- ^paymentLag
 1311  -> (BusinessDayConvention) -- ^paymentAdjustment
 1312  -> (Calendar) -- ^paymentCalendar
 1313  -> (Bool) -- ^telescopicValueDates
 1314  -> (RateAveragingType) -- ^averagingMethod
 1315  -> (Maybe Word) -- ^lookbackDays
 1316  -> (Word) -- ^lockoutDays
 1317  -> (Bool) -- ^applyObservationShift
 1318  -> IO ((OvernightIndexedSwap))
 1319 overnightIndexedSwap a1 a2 a3 a4 a5 a6 a7 a8 a9 a10 a11 a12 a13 a14 a15 =
 1320   let {a1' = (fromIntegral . fromEnum) a1} in 
 1321   let {a2' = realToFrac a2} in 
 1322   withSchedule a3 $ \a3' -> 
 1323   let {a4' = realToFrac a4} in 
 1324   withDayCounter a5 $ \a5' -> 
 1325   withOvernightIborIndex a6 $ \a6' -> 
 1326   let {a7' = realToFrac a7} in 
 1327   let {a8' = fromIntegral a8} in 
 1328   let {a9' = fromEnumC a9} in 
 1329   withCalendar a10 $ \a10' -> 
 1330   let {a11' = C2HSImp.fromBool a11} in 
 1331   let {a12' = (fromIntegral . fromEnum) a12} in 
 1332   let {a13' = fromMaybeInt a13} in 
 1333   let {a14' = fromIntegral a14} in 
 1334   let {a15' = C2HSImp.fromBool a15} in 
 1335   preErrorCheck $ \a16' -> 
 1336   overnightIndexedSwap'_ a1' a2' a3' a4' a5' a6' a7' a8' a9' a10' a11' a12' a13' a14' a15' a16' >>= \res ->
 1337   peekOvernightIndexedSwap res >>= \res' ->
 1338   errorCheck  a16'>>
 1339   return (res')
 1340 
 1341 
 1342 
 1343 -- |As 'overnightIndexedSwap', but with a per-period nominal schedule instead of a single flat nominal.
 1344 overnightIndexedSwap' :: (SwapType) -> ([Double]) -- ^nominals
 1345  -> (Schedule) -- ^schedule
 1346  -> (Double) -- ^fixedRate
 1347  -> (DayCounter) -- ^fixedDC
 1348  -> (OvernightIborIndex) -> (Double) -- ^spread
 1349  -> (Int) -- ^paymentLag
 1350  -> (BusinessDayConvention) -- ^paymentAdjustment
 1351  -> (Calendar) -- ^paymentCalendar
 1352  -> (Bool) -- ^telescopicValueDates
 1353  -> (RateAveragingType) -- ^averagingMethod
 1354  -> (Maybe Word) -- ^lookbackDays
 1355  -> (Word) -- ^lockoutDays
 1356  -> (Bool) -- ^applyObservationShift
 1357  -> IO ((OvernightIndexedSwap))
 1358 overnightIndexedSwap' a1 a2 a3 a4 a5 a6 a7 a8 a9 a10 a11 a12 a13 a14 a15 =
 1359   let {a1' = (fromIntegral . fromEnum) a1} in 
 1360   withDoubleArray a2 $ \(a2'1, a2'2) -> 
 1361   withSchedule a3 $ \a3' -> 
 1362   let {a4' = realToFrac a4} in 
 1363   withDayCounter a5 $ \a5' -> 
 1364   withOvernightIborIndex a6 $ \a6' -> 
 1365   let {a7' = realToFrac a7} in 
 1366   let {a8' = fromIntegral a8} in 
 1367   let {a9' = fromEnumC a9} in 
 1368   withCalendar a10 $ \a10' -> 
 1369   let {a11' = C2HSImp.fromBool a11} in 
 1370   let {a12' = (fromIntegral . fromEnum) a12} in 
 1371   let {a13' = fromMaybeInt a13} in 
 1372   let {a14' = fromIntegral a14} in 
 1373   let {a15' = C2HSImp.fromBool a15} in 
 1374   preErrorCheck $ \a16' -> 
 1375   overnightIndexedSwap''_ a1' a2'1  a2'2 a3' a4' a5' a6' a7' a8' a9' a10' a11' a12' a13' a14' a15' a16' >>= \res ->
 1376   peekOvernightIndexedSwap res >>= \res' ->
 1377   errorCheck  a16'>>
 1378   return (res')
 1379 
 1380 
 1381 
 1382 -- |The swap's maturity date, or 'Nothing' if the swap has no legs.
 1383 maturityDate :: (GenSwap s) -> IO (((Maybe Day)))
 1384 maturityDate a1 =
 1385   withSwap a1 $ \a1' -> 
 1386   preErrorCheck $ \a2' -> 
 1387   maturityDate'_ a1' a2' >>= \res ->
 1388   let {res' = toMaybeDay res} in
 1389   errorCheck  a2'>>
 1390   return (res')
 1391 
 1392 
 1393 
 1394 -- |The swap's start date, or 'Nothing' if the swap has no legs.
 1395 startDate :: (GenSwap s) -> IO (((Maybe Day)))
 1396 startDate a1 =
 1397   withSwap a1 $ \a1' -> 
 1398   preErrorCheck $ \a2' -> 
 1399   startDate'_ a1' a2' >>= \res ->
 1400   let {res' = toMaybeDay res} in
 1401   errorCheck  a2'>>
 1402   return (res')
 1403 
 1404 
 1405 
 1406 -- |Discount factor at the instrument's NPV date.
 1407 npvDateDiscount :: (GenSwap s) -> IO ((Double))
 1408 npvDateDiscount a1 =
 1409   withSwap a1 $ \a1' -> 
 1410   preErrorCheck $ \a2' -> 
 1411   npvDateDiscount'_ a1' a2' >>= \res ->
 1412   let {res' = realToFrac res} in
 1413   errorCheck  a2'>>
 1414   return (res')
 1415 
 1416 
 1417 
 1418 -- |The BMA leg's cash flows.
 1419 bmaLeg :: (BMASwap) -> IO ((Leg))
 1420 bmaLeg a1 =
 1421   withBMASwap a1 $ \a1' -> 
 1422   preErrorCheck $ \a2' -> 
 1423   bmaLeg'_ a1' a2' >>= \res ->
 1424   peekLeg res >>= \res' ->
 1425   errorCheck  a2'>>
 1426   return (res')
 1427 
 1428 
 1429 
 1430 -- |Basis-point sensitivity of the BMA leg.
 1431 bmaLegBPS :: (BMASwap) -> IO ((Double))
 1432 bmaLegBPS a1 =
 1433   withBMASwap a1 $ \a1' -> 
 1434   preErrorCheck $ \a2' -> 
 1435   bmaLegBPS'_ a1' a2' >>= \res ->
 1436   let {res' = realToFrac res} in
 1437   errorCheck  a2'>>
 1438   return (res')
 1439 
 1440 
 1441 
 1442 -- |NPV of the BMA leg.
 1443 bmaLegNPV :: (BMASwap) -> IO ((Double))
 1444 bmaLegNPV a1 =
 1445   withBMASwap a1 $ \a1' -> 
 1446   preErrorCheck $ \a2' -> 
 1447   bmaLegNPV'_ a1' a2' >>= \res ->
 1448   let {res' = realToFrac res} in
 1449   errorCheck  a2'>>
 1450   return (res')
 1451 
 1452 
 1453 
 1454 -- |The Libor fraction that would make the swap's NPV zero.
 1455 fairLiborFraction :: (BMASwap) -> IO ((Double))
 1456 fairLiborFraction a1 =
 1457   withBMASwap a1 $ \a1' -> 
 1458   preErrorCheck $ \a2' -> 
 1459   fairLiborFraction'_ a1' a2' >>= \res ->
 1460   let {res' = realToFrac res} in
 1461   errorCheck  a2'>>
 1462   return (res')
 1463 
 1464 
 1465 
 1466 -- |The Libor spread that would make the swap's NPV zero.
 1467 fairLiborSpread :: (BMASwap) -> IO ((Double))
 1468 fairLiborSpread a1 =
 1469   withBMASwap a1 $ \a1' -> 
 1470   preErrorCheck $ \a2' -> 
 1471   fairLiborSpread'_ a1' a2' >>= \res ->
 1472   let {res' = realToFrac res} in
 1473   errorCheck  a2'>>
 1474   return (res')
 1475 
 1476 
 1477 
 1478 -- |The fraction of the Libor rate paid on the Libor leg.
 1479 liborFraction :: (BMASwap) -> IO ((Double))
 1480 liborFraction a1 =
 1481   withBMASwap a1 $ \a1' -> 
 1482   preErrorCheck $ \a2' -> 
 1483   liborFraction'_ a1' a2' >>= \res ->
 1484   let {res' = realToFrac res} in
 1485   errorCheck  a2'>>
 1486   return (res')
 1487 
 1488 
 1489 
 1490 -- |The Libor leg's cash flows.
 1491 liborLeg :: (BMASwap) -> IO ((Leg))
 1492 liborLeg a1 =
 1493   withBMASwap a1 $ \a1' -> 
 1494   preErrorCheck $ \a2' -> 
 1495   liborLeg'_ a1' a2' >>= \res ->
 1496   peekLeg res >>= \res' ->
 1497   errorCheck  a2'>>
 1498   return (res')
 1499 
 1500 
 1501 
 1502 -- |Basis-point sensitivity of the Libor leg.
 1503 liborLegBPS :: (BMASwap) -> IO ((Double))
 1504 liborLegBPS a1 =
 1505   withBMASwap a1 $ \a1' -> 
 1506   preErrorCheck $ \a2' -> 
 1507   liborLegBPS'_ a1' a2' >>= \res ->
 1508   let {res' = realToFrac res} in
 1509   errorCheck  a2'>>
 1510   return (res')
 1511 
 1512 
 1513 
 1514 -- |NPV of the Libor leg.
 1515 liborLegNPV :: (BMASwap) -> IO ((Double))
 1516 liborLegNPV a1 =
 1517   withBMASwap a1 $ \a1' -> 
 1518   preErrorCheck $ \a2' -> 
 1519   liborLegNPV'_ a1' a2' >>= \res ->
 1520   let {res' = realToFrac res} in
 1521   errorCheck  a2'>>
 1522   return (res')
 1523 
 1524 
 1525 
 1526 -- |The underlying bond's cash flows.
 1527 bondLeg :: (AssetSwap) -> IO ((Leg))
 1528 bondLeg a1 =
 1529   withAssetSwap a1 $ \a1' -> 
 1530   preErrorCheck $ \a2' -> 
 1531   bondLeg'_ a1' a2' >>= \res ->
 1532   peekLeg res >>= \res' ->
 1533   errorCheck  a2'>>
 1534   return (res')
 1535 
 1536 
 1537 
 1538 -- |The bond's clean price, as passed to the constructor.
 1539 cleanPrice :: (AssetSwap) -> IO ((Double))
 1540 cleanPrice a1 =
 1541   withAssetSwap a1 $ \a1' -> 
 1542   preErrorCheck $ \a2' -> 
 1543   cleanPrice'_ a1' a2' >>= \res ->
 1544   let {res' = realToFrac res} in
 1545   errorCheck  a2'>>
 1546   return (res')
 1547 
 1548 
 1549 
 1550 -- |The clean price that would make the swap's NPV zero.
 1551 fairCleanPrice :: (AssetSwap) -> IO ((Double))
 1552 fairCleanPrice a1 =
 1553   withAssetSwap a1 $ \a1' -> 
 1554   preErrorCheck $ \a2' -> 
 1555   fairCleanPrice'_ a1' a2' >>= \res ->
 1556   let {res' = realToFrac res} in
 1557   errorCheck  a2'>>
 1558   return (res')
 1559 
 1560 
 1561 
 1562 -- |The non-par repayment that would make the swap's NPV zero.
 1563 fairNonParRepayment :: (AssetSwap) -> IO ((Double))
 1564 fairNonParRepayment a1 =
 1565   withAssetSwap a1 $ \a1' -> 
 1566   preErrorCheck $ \a2' -> 
 1567   fairNonParRepayment'_ a1' a2' >>= \res ->
 1568   let {res' = realToFrac res} in
 1569   errorCheck  a2'>>
 1570   return (res')
 1571 
 1572 
 1573 
 1574 -- |The non-par repayment, as passed to the constructor.
 1575 nonParRepayment :: (AssetSwap) -> IO ((Double))
 1576 nonParRepayment a1 =
 1577   withAssetSwap a1 $ \a1' -> 
 1578   preErrorCheck $ \a2' -> 
 1579   nonParRepayment'_ a1' a2' >>= \res ->
 1580   let {res' = realToFrac res} in
 1581   errorCheck  a2'>>
 1582   return (res')
 1583 
 1584 
 1585 
 1586 -- |Whether this is a par asset swap.
 1587 parSwap :: (AssetSwap) -> IO ((Bool))
 1588 parSwap a1 =
 1589   withAssetSwap a1 $ \a1' -> 
 1590   preErrorCheck $ \a2' -> 
 1591   parSwap'_ a1' a2' >>= \res ->
 1592   let {res' = C2HSImp.toBool res} in
 1593   errorCheck  a2'>>
 1594   return (res')
 1595 
 1596 
 1597 
 1598 -- |Whether the bond coupon is paid (rather than netted against the floating leg).
 1599 payBondCoupon :: (AssetSwap) -> IO ((Bool))
 1600 payBondCoupon a1 =
 1601   withAssetSwap a1 $ \a1' -> 
 1602   preErrorCheck $ \a2' -> 
 1603   payBondCoupon'_ a1' a2' >>= \res ->
 1604   let {res' = C2HSImp.toBool res} in
 1605   errorCheck  a2'>>
 1606   return (res')
 1607 
 1608 
 1609 
 1610 -- |The overnight leg's cash flows.
 1611 overnightLeg :: (OvernightIndexedSwap) -> IO ((Leg))
 1612 overnightLeg a1 =
 1613   withOvernightIndexedSwap a1 $ \a1' -> 
 1614   preErrorCheck $ \a2' -> 
 1615   overnightLeg'_ a1' a2' >>= \res ->
 1616   peekLeg res >>= \res' ->
 1617   errorCheck  a2'>>
 1618   return (res')
 1619 
 1620 
 1621 
 1622 -- |Basis-point sensitivity of the overnight leg.
 1623 overnightLegBPS :: (OvernightIndexedSwap) -> IO ((Double))
 1624 overnightLegBPS a1 =
 1625   withOvernightIndexedSwap a1 $ \a1' -> 
 1626   preErrorCheck $ \a2' -> 
 1627   overnightLegBPS'_ a1' a2' >>= \res ->
 1628   let {res' = realToFrac res} in
 1629   errorCheck  a2'>>
 1630   return (res')
 1631 
 1632 
 1633 
 1634 -- |NPV of the overnight leg.
 1635 overnightLegNPV :: (OvernightIndexedSwap) -> IO ((Double))
 1636 overnightLegNPV a1 =
 1637   withOvernightIndexedSwap a1 $ \a1' -> 
 1638   preErrorCheck $ \a2' -> 
 1639   overnightLegNPV'_ a1' a2' >>= \res ->
 1640   let {res' = realToFrac res} in
 1641   errorCheck  a2'>>
 1642   return (res')
 1643 
 1644 
 1645 
 1646 -- Inflation-linked swaps
 1647 -- |A zero-coupon inflation-indexed swap (ZCIIS): a single fixed-vs-CPI-ratio exchange at
 1648 -- maturity. Per-leg NPV\/BPS use the generic 'leg'\/'legNPV'\/'legBPS' (leg 0 = fixed, leg 1 =
 1649 -- inflation).
 1650 zeroCouponInflationSwap :: (SwapType) -> (Double) -- ^nominal
 1651  -> (Day) -- ^startDate
 1652  -> (Day) -- ^maturity
 1653  -> (Calendar) -> (BusinessDayConvention) -- ^paymentConvention
 1654  -> (DayCounter) -> (Double) -- ^fixedRate
 1655  -> (ZeroInflationIndex) -> ((Word,TimeUnit)) -- ^observationLag
 1656  -> (CPIInterpolationType) -- ^observationInterpolation
 1657  -> (Bool) -- ^adjustInfObsDates
 1658  -> (Calendar) -- ^infCalendar
 1659  -> (BusinessDayConvention) -- ^infConvention
 1660  -> IO ((ZeroCouponInflationSwap))
 1661 zeroCouponInflationSwap a1 a2 a3 a4 a5 a6 a7 a8 a9 a10 a11 a12 a13 a14 =
 1662   let {a1' = (fromIntegral . fromEnum) a1} in 
 1663   let {a2' = realToFrac a2} in 
 1664   withDay a3 $ \a3' -> 
 1665   withDay a4 $ \a4' -> 
 1666   withCalendar a5 $ \a5' -> 
 1667   let {a6' = fromEnumC a6} in 
 1668   withDayCounter a7 $ \a7' -> 
 1669   let {a8' = realToFrac a8} in 
 1670   withZeroInflationIndex a9 $ \a9' -> 
 1671   let {(a10'1, a10'2) = fromEnumQuantity a10} in 
 1672   let {a11' = fromEnumC a11} in 
 1673   let {a12' = C2HSImp.fromBool a12} in 
 1674   withCalendar a13 $ \a13' -> 
 1675   let {a14' = fromEnumC a14} in 
 1676   preErrorCheck $ \a15' -> 
 1677   zeroCouponInflationSwap'_ a1' a2' a3' a4' a5' a6' a7' a8' a9' a10'1  a10'2 a11' a12' a13' a14' a15' >>= \res ->
 1678   peekZeroCouponInflationSwap res >>= \res' ->
 1679   errorCheck  a15'>>
 1680   return (res')
 1681 
 1682 
 1683 
 1684 -- |The fixed rate that would make the swap's NPV zero.
 1685 zcisFairRate :: (ZeroCouponInflationSwap) -> IO ((Double))
 1686 zcisFairRate a1 =
 1687   withZeroCouponInflationSwap a1 $ \a1' -> 
 1688   preErrorCheck $ \a2' -> 
 1689   zcisFairRate'_ a1' a2' >>= \res ->
 1690   let {res' = realToFrac res} in
 1691   errorCheck  a2'>>
 1692   return (res')
 1693 
 1694 
 1695 
 1696 -- |A year-on-year inflation-indexed swap: fixed leg vs a YoY-inflation-linked leg. Per-leg
 1697 -- NPV\/BPS use the generic 'leg'\/'legNPV'\/'legBPS' (leg 0 = fixed, leg 1 = YoY).
 1698 yearOnYearInflationSwap :: (SwapType) -> (Double) -- ^nominal
 1699  -> (Schedule) -- ^fixedSchedule
 1700  -> (Double) -- ^fixedRate
 1701  -> (DayCounter) -- ^fixedDayCount
 1702  -> (Schedule) -- ^yoySchedule
 1703  -> (YoYInflationIndex) -> ((Word,TimeUnit)) -- ^observationLag
 1704  -> (CPIInterpolationType) -- ^interpolation
 1705  -> (Double) -- ^spread
 1706  -> (DayCounter) -- ^yoyDayCount
 1707  -> (Calendar) -- ^paymentCalendar
 1708  -> (BusinessDayConvention) -- ^paymentConvention
 1709  -> IO ((YearOnYearInflationSwap))
 1710 yearOnYearInflationSwap a1 a2 a3 a4 a5 a6 a7 a8 a9 a10 a11 a12 a13 =
 1711   let {a1' = (fromIntegral . fromEnum) a1} in 
 1712   let {a2' = realToFrac a2} in 
 1713   withSchedule a3 $ \a3' -> 
 1714   let {a4' = realToFrac a4} in 
 1715   withDayCounter a5 $ \a5' -> 
 1716   withSchedule a6 $ \a6' -> 
 1717   withYoYInflationIndex a7 $ \a7' -> 
 1718   let {(a8'1, a8'2) = fromEnumQuantity a8} in 
 1719   let {a9' = fromEnumC a9} in 
 1720   let {a10' = realToFrac a10} in 
 1721   withDayCounter a11 $ \a11' -> 
 1722   withCalendar a12 $ \a12' -> 
 1723   let {a13' = fromEnumC a13} in 
 1724   preErrorCheck $ \a14' -> 
 1725   yearOnYearInflationSwap'_ a1' a2' a3' a4' a5' a6' a7' a8'1  a8'2 a9' a10' a11' a12' a13' a14' >>= \res ->
 1726   peekYearOnYearInflationSwap res >>= \res' ->
 1727   errorCheck  a14'>>
 1728   return (res')
 1729 
 1730 
 1731 
 1732 -- |The fixed rate that would make the swap's NPV zero.
 1733 yoyFairRate :: (YearOnYearInflationSwap) -> IO ((Double))
 1734 yoyFairRate a1 =
 1735   withYearOnYearInflationSwap a1 $ \a1' -> 
 1736   preErrorCheck $ \a2' -> 
 1737   yoyFairRate'_ a1' a2' >>= \res ->
 1738   let {res' = realToFrac res} in
 1739   errorCheck  a2'>>
 1740   return (res')
 1741 
 1742 
 1743 
 1744 -- |The spread that would make the swap's NPV zero.
 1745 qlYearOnYearInflationSwapFairSpread :: (YearOnYearInflationSwap) -> IO ((Double))
 1746 qlYearOnYearInflationSwapFairSpread a1 =
 1747   withYearOnYearInflationSwap a1 $ \a1' -> 
 1748   preErrorCheck $ \a2' -> 
 1749   qlYearOnYearInflationSwapFairSpread'_ a1' a2' >>= \res ->
 1750   let {res' = realToFrac res} in
 1751   errorCheck  a2'>>
 1752   return (res')
 1753 
 1754 
 1755 
 1756 -- |A fixed-x-CPI-ratio leg (subtracting the inflation notional if
 1757 -- /subtractInflationNominal/) vs a float+spread leg -- QuantLib's general-purpose inflation
 1758 -- swap, also usable to replicate a single-cashflow ZCIIS (see 'zeroCouponInflationSwap').
 1759 -- Per-leg NPV\/BPS use the generic 'leg'\/'legNPV'\/'legBPS' (leg 0 = CPI, leg 1 = float).
 1760 cpiSwap :: (SwapType) -> (Double) -- ^nominal
 1761  -> (Bool) -- ^subtractInflationNominal
 1762  -> (Double) -- ^spread
 1763  -> (DayCounter) -- ^floatDayCount
 1764  -> (Schedule) -- ^floatSchedule
 1765  -> (BusinessDayConvention) -- ^floatRoll
 1766  -> (Word) -- ^fixingDays
 1767  -> (GenIborIndex ibor) -- ^floatIndex
 1768  -> (Double) -- ^fixedRate
 1769  -> (Double) -- ^baseCPI
 1770  -> (DayCounter) -- ^fixedDayCount
 1771  -> (Schedule) -- ^fixedSchedule
 1772  -> (BusinessDayConvention) -- ^fixedRoll
 1773  -> ((Word,TimeUnit)) -- ^observationLag
 1774  -> (ZeroInflationIndex) -- ^fixedIndex
 1775  -> (CPIInterpolationType) -- ^observationInterpolation
 1776  -> (Maybe Double) -- ^inflationNominal
 1777  -> IO ((CPISwap))
 1778 cpiSwap a1 a2 a3 a4 a5 a6 a7 a8 a9 a10 a11 a12 a13 a14 a15 a16 a17 a18 =
 1779   let {a1' = (fromIntegral . fromEnum) a1} in 
 1780   let {a2' = realToFrac a2} in 
 1781   let {a3' = C2HSImp.fromBool a3} in 
 1782   let {a4' = realToFrac a4} in 
 1783   withDayCounter a5 $ \a5' -> 
 1784   withSchedule a6 $ \a6' -> 
 1785   let {a7' = fromEnumC a7} in 
 1786   let {a8' = fromIntegral a8} in 
 1787   withIborIndex a9 $ \a9' -> 
 1788   let {a10' = realToFrac a10} in 
 1789   let {a11' = realToFrac a11} in 
 1790   withDayCounter a12 $ \a12' -> 
 1791   withSchedule a13 $ \a13' -> 
 1792   let {a14' = fromEnumC a14} in 
 1793   let {(a15'1, a15'2) = fromEnumQuantity a15} in 
 1794   withZeroInflationIndex a16 $ \a16' -> 
 1795   let {a17' = fromEnumC a17} in 
 1796   let {a18' = fromMaybeDouble a18} in 
 1797   preErrorCheck $ \a19' -> 
 1798   cpiSwap'_ a1' a2' a3' a4' a5' a6' a7' a8' a9' a10' a11' a12' a13' a14' a15'1  a15'2 a16' a17' a18' a19' >>= \res ->
 1799   peekCPISwap res >>= \res' ->
 1800   errorCheck  a19'>>
 1801   return (res')
 1802 
 1803 
 1804 
 1805 -- |The fixed rate that would make the swap's NPV zero.
 1806 cpiSwapFairRate :: (CPISwap) -> IO ((Double))
 1807 cpiSwapFairRate a1 =
 1808   withCPISwap a1 $ \a1' -> 
 1809   preErrorCheck $ \a2' -> 
 1810   cpiSwapFairRate'_ a1' a2' >>= \res ->
 1811   let {res' = realToFrac res} in
 1812   errorCheck  a2'>>
 1813   return (res')
 1814 
 1815 
 1816 
 1817 -- |The spread that would make the swap's NPV zero.
 1818 qlCPISwapFairSpread :: (CPISwap) -> IO ((Double))
 1819 qlCPISwapFairSpread a1 =
 1820   withCPISwap a1 $ \a1' -> 
 1821   preErrorCheck $ \a2' -> 
 1822   qlCPISwapFairSpread'_ a1' a2' >>= \res ->
 1823   let {res' = realToFrac res} in
 1824   errorCheck  a2'>>
 1825   return (res')
 1826 
 1827 
 1828 
 1829 -- |Zero-coupon swap quoted in terms of a known fixed cash flow. \"payer\"\/\"receiver\" refer to the fixed leg.
 1830 zeroCouponSwap :: (SwapType) -> (Double) -- ^baseNominal
 1831  -> (Day) -- ^startDate
 1832  -> (Day) -- ^maturityDate
 1833  -> (Double) -- ^fixedPayment
 1834  -> (GenIborIndex ibor) -> (Calendar) -- ^paymentCalendar
 1835  -> (BusinessDayConvention) -- ^paymentConvention
 1836  -> (Word) -- ^paymentDelay
 1837  -> IO ((ZeroCouponSwap))
 1838 zeroCouponSwap a1 a2 a3 a4 a5 a6 a7 a8 a9 =
 1839   let {a1' = (fromIntegral . fromEnum) a1} in 
 1840   let {a2' = realToFrac a2} in 
 1841   withDay a3 $ \a3' -> 
 1842   withDay a4 $ \a4' -> 
 1843   let {a5' = realToFrac a5} in 
 1844   withIborIndex a6 $ \a6' -> 
 1845   withCalendar a7 $ \a7' -> 
 1846   let {a8' = fromEnumC a8} in 
 1847   let {a9' = fromIntegral a9} in 
 1848   preErrorCheck $ \a10' -> 
 1849   zeroCouponSwap'_ a1' a2' a3' a4' a5' a6' a7' a8' a9' a10' >>= \res ->
 1850   peekZeroCouponSwap res >>= \res' ->
 1851   errorCheck  a10'>>
 1852   return (res')
 1853 
 1854 
 1855 
 1856 -- |Zero-coupon swap quoted in terms of a fixed rate.
 1857 zeroCouponSwap' :: (SwapType) -> (Double) -- ^baseNominal
 1858  -> (Day) -- ^startDate
 1859  -> (Day) -- ^maturityDate
 1860  -> (Double) -- ^fixedRate
 1861  -> (DayCounter) -- ^fixedDayCounter
 1862  -> (GenIborIndex ibor) -> (Calendar) -- ^paymentCalendar
 1863  -> (BusinessDayConvention) -- ^paymentConvention
 1864  -> (Word) -- ^paymentDelay
 1865  -> IO ((ZeroCouponSwap))
 1866 zeroCouponSwap' a1 a2 a3 a4 a5 a6 a7 a8 a9 a10 =
 1867   let {a1' = (fromIntegral . fromEnum) a1} in 
 1868   let {a2' = realToFrac a2} in 
 1869   withDay a3 $ \a3' -> 
 1870   withDay a4 $ \a4' -> 
 1871   let {a5' = realToFrac a5} in 
 1872   withDayCounter a6 $ \a6' -> 
 1873   withIborIndex a7 $ \a7' -> 
 1874   withCalendar a8 $ \a8' -> 
 1875   let {a9' = fromEnumC a9} in 
 1876   let {a10' = fromIntegral a10} in 
 1877   preErrorCheck $ \a11' -> 
 1878   zeroCouponSwap''_ a1' a2' a3' a4' a5' a6' a7' a8' a9' a10' a11' >>= \res ->
 1879   peekZeroCouponSwap res >>= \res' ->
 1880   errorCheck  a11'>>
 1881   return (res')
 1882 
 1883 
 1884 
 1885 -- |The fixed payment that would make the swap's NPV zero.
 1886 fairFixedPayment :: (ZeroCouponSwap) -> IO ((Double))
 1887 fairFixedPayment a1 =
 1888   withZeroCouponSwap a1 $ \a1' -> 
 1889   preErrorCheck $ \a2' -> 
 1890   fairFixedPayment'_ a1' a2' >>= \res ->
 1891   let {res' = realToFrac res} in
 1892   errorCheck  a2'>>
 1893   return (res')
 1894 
 1895 
 1896 
 1897 -- |The fixed rate, under the given day counter, that would make the swap's NPV zero.
 1898 fairFixedRate :: (ZeroCouponSwap) -> (DayCounter) -> IO ((Double))
 1899 fairFixedRate a1 a2 =
 1900   withZeroCouponSwap a1 $ \a1' -> 
 1901   withDayCounter a2 $ \a2' -> 
 1902   preErrorCheck $ \a3' -> 
 1903   fairFixedRate'_ a1' a2' a3' >>= \res ->
 1904   let {res' = realToFrac res} in
 1905   errorCheck  a3'>>
 1906   return (res')
 1907 
 1908 
 1909 
 1910 -- |Exchanges the total return of an 'EquityIndex' for a set of floating cash flows linked to an
 1911 -- 'IborIndex'. /type/ (payer\/receiver) refers to the equity leg.
 1912 equityTotalReturnSwapIbor :: (SwapType) -> (Double) -- ^nominal
 1913  -> (Schedule) -> (EquityIndex) -> (GenIborIndex ibor) -- ^interestRateIndex
 1914  -> (DayCounter) -> (Double) -- ^margin
 1915  -> (Double) -- ^gearing
 1916  -> (Calendar) -- ^paymentCalendar
 1917  -> (BusinessDayConvention) -- ^paymentConvention
 1918  -> (Word) -- ^paymentDelay
 1919  -> IO ((EquityTotalReturnSwap))
 1920 equityTotalReturnSwapIbor a1 a2 a3 a4 a5 a6 a7 a8 a9 a10 a11 =
 1921   let {a1' = (fromIntegral . fromEnum) a1} in 
 1922   let {a2' = realToFrac a2} in 
 1923   withSchedule a3 $ \a3' -> 
 1924   withEquityIndex a4 $ \a4' -> 
 1925   withIborIndex a5 $ \a5' -> 
 1926   withDayCounter a6 $ \a6' -> 
 1927   let {a7' = realToFrac a7} in 
 1928   let {a8' = realToFrac a8} in 
 1929   withCalendar a9 $ \a9' -> 
 1930   let {a10' = fromEnumC a10} in 
 1931   let {a11' = fromIntegral a11} in 
 1932   preErrorCheck $ \a12' -> 
 1933   equityTotalReturnSwapIbor'_ a1' a2' a3' a4' a5' a6' a7' a8' a9' a10' a11' a12' >>= \res ->
 1934   peekEquityTotalReturnSwap res >>= \res' ->
 1935   errorCheck  a12'>>
 1936   return (res')
 1937 
 1938 
 1939 
 1940 -- |As 'equityTotalReturnSwapIbor', but with the floating leg linked to an overnight index instead
 1941 -- -- fixings are compounded over the accrual period.
 1942 equityTotalReturnSwapOvernight :: (SwapType) -> (Double) -- ^nominal
 1943  -> (Schedule) -> (EquityIndex) -> (OvernightIborIndex) -- ^interestRateIndex
 1944  -> (DayCounter) -> (Double) -- ^margin
 1945  -> (Double) -- ^gearing
 1946  -> (Calendar) -- ^paymentCalendar
 1947  -> (BusinessDayConvention) -- ^paymentConvention
 1948  -> (Word) -- ^paymentDelay
 1949  -> IO ((EquityTotalReturnSwap))
 1950 equityTotalReturnSwapOvernight a1 a2 a3 a4 a5 a6 a7 a8 a9 a10 a11 =
 1951   let {a1' = (fromIntegral . fromEnum) a1} in 
 1952   let {a2' = realToFrac a2} in 
 1953   withSchedule a3 $ \a3' -> 
 1954   withEquityIndex a4 $ \a4' -> 
 1955   withOvernightIborIndex a5 $ \a5' -> 
 1956   withDayCounter a6 $ \a6' -> 
 1957   let {a7' = realToFrac a7} in 
 1958   let {a8' = realToFrac a8} in 
 1959   withCalendar a9 $ \a9' -> 
 1960   let {a10' = fromEnumC a10} in 
 1961   let {a11' = fromIntegral a11} in 
 1962   preErrorCheck $ \a12' -> 
 1963   equityTotalReturnSwapOvernight'_ a1' a2' a3' a4' a5' a6' a7' a8' a9' a10' a11' a12' >>= \res ->
 1964   peekEquityTotalReturnSwap res >>= \res' ->
 1965   errorCheck  a12'>>
 1966   return (res')
 1967 
 1968 
 1969 
 1970 -- |NPV of the equity total-return leg.
 1971 equityLegNPV :: (EquityTotalReturnSwap) -> IO ((Double))
 1972 equityLegNPV a1 =
 1973   withEquityTotalReturnSwap a1 $ \a1' -> 
 1974   preErrorCheck $ \a2' -> 
 1975   equityLegNPV'_ a1' a2' >>= \res ->
 1976   let {res' = realToFrac res} in
 1977   errorCheck  a2'>>
 1978   return (res')
 1979 
 1980 
 1981 
 1982 -- |NPV of the interest-rate leg.
 1983 interestRateLegNPV :: (EquityTotalReturnSwap) -> IO ((Double))
 1984 interestRateLegNPV a1 =
 1985   withEquityTotalReturnSwap a1 $ \a1' -> 
 1986   preErrorCheck $ \a2' -> 
 1987   interestRateLegNPV'_ a1' a2' >>= \res ->
 1988   let {res' = realToFrac res} in
 1989   errorCheck  a2'>>
 1990   return (res')
 1991 
 1992 
 1993 
 1994 -- |The margin that would make the swap's NPV zero.
 1995 fairMargin :: (EquityTotalReturnSwap) -> IO ((Double))
 1996 fairMargin a1 =
 1997   withEquityTotalReturnSwap a1 $ \a1' -> 
 1998   preErrorCheck $ \a2' -> 
 1999   fairMargin'_ a1' a2' >>= \res ->
 2000   let {res' = realToFrac res} in
 2001   errorCheck  a2'>>
 2002   return (res')
 2003 
 2004 
 2005 
 2006 class HasFixedLeg a where
 2007   fairRate :: a -> IO Double
 2008   fixedLeg :: a -> IO Leg
 2009   fixedLegBPS :: a -> IO Double
 2010   fixedLegNPV :: a -> IO Double
 2011 instance HasFixedLeg OvernightIndexedSwap where
 2012   fairRate = qlOvernightIndexedSwapFairRate
 2013   fixedLeg = qlOvernightIndexedSwapFixedLeg
 2014   fixedLegBPS = qlOvernightIndexedSwapFixedLegBPS
 2015   fixedLegNPV = qlOvernightIndexedSwapFixedLegNPV
 2016 instance HasFixedLeg (GenFixedVsFloatingSwap f) where
 2017   fairRate = qlFixedVsFloatingSwapFairRate
 2018   fixedLeg = qlFixedVsFloatingSwapFixedLeg
 2019   fixedLegBPS = qlFixedVsFloatingSwapFixedLegBPS
 2020   fixedLegNPV = qlFixedVsFloatingSwapFixedLegNPV
 2021 
 2022 class HasSpread a where
 2023   fairSpread :: a -> IO Double
 2024 instance HasSpread (GenFixedVsFloatingSwap f) where
 2025   fairSpread = qlFixedVsFloatingSwapFairSpread
 2026 instance HasSpread OvernightIndexedSwap where
 2027   fairSpread = qlOvernightIndexedSwapFairSpread
 2028 instance HasSpread AssetSwap where
 2029   fairSpread = qlAssetSwapFairSpread
 2030 instance HasSpread CreditDefaultSwap where
 2031   fairSpread = qlCreditDefaultSwapFairSpread
 2032 instance HasSpread YearOnYearInflationSwap where
 2033   fairSpread = qlYearOnYearInflationSwapFairSpread
 2034 instance HasSpread CPISwap where
 2035   fairSpread = qlCPISwapFairSpread
 2036 
 2037 class HasFloatingLeg a where
 2038   floatingLeg :: a -> IO Leg
 2039   floatingLegBPS :: a -> IO Double
 2040   floatingLegNPV :: a -> IO Double
 2041 instance HasFloatingLeg (GenFixedVsFloatingSwap f) where
 2042   floatingLeg = qlFixedVsFloatingSwapFloatingLeg
 2043   floatingLegBPS = qlFixedVsFloatingSwapFloatingLegBPS
 2044   floatingLegNPV = qlFixedVsFloatingSwapFloatingLegNPV
 2045 instance HasFloatingLeg AssetSwap where
 2046   floatingLeg = qlAssetSwapFloatingLeg
 2047   floatingLegBPS = qlAssetSwapFloatingLegBPS
 2048   floatingLegNPV = qlAssetSwapFloatingLegNPV
 2049 
 2050 -- |The spread that would make the swap's NPV zero.
 2051 qlFixedVsFloatingSwapFairSpread :: (GenFixedVsFloatingSwap f) -> IO ((Double))
 2052 qlFixedVsFloatingSwapFairSpread a1 =
 2053   withFixedVsFloatingSwap a1 $ \a1' -> 
 2054   preErrorCheck $ \a2' -> 
 2055   qlFixedVsFloatingSwapFairSpread'_ a1' a2' >>= \res ->
 2056   let {res' = realToFrac res} in
 2057   errorCheck  a2'>>
 2058   return (res')
 2059 
 2060 
 2061 
 2062 -- |The spread that would make the swap's NPV zero.
 2063 qlAssetSwapFairSpread :: (AssetSwap) -> IO ((Double))
 2064 qlAssetSwapFairSpread a1 =
 2065   withAssetSwap a1 $ \a1' -> 
 2066   preErrorCheck $ \a2' -> 
 2067   qlAssetSwapFairSpread'_ a1' a2' >>= \res ->
 2068   let {res' = realToFrac res} in
 2069   errorCheck  a2'>>
 2070   return (res')
 2071 
 2072 
 2073 
 2074 -- |The fixed rate that would make the swap's NPV zero.
 2075 qlFixedVsFloatingSwapFairRate :: (GenFixedVsFloatingSwap f) -> IO ((Double))
 2076 qlFixedVsFloatingSwapFairRate a1 =
 2077   withFixedVsFloatingSwap a1 $ \a1' -> 
 2078   preErrorCheck $ \a2' -> 
 2079   qlFixedVsFloatingSwapFairRate'_ a1' a2' >>= \res ->
 2080   let {res' = realToFrac res} in
 2081   errorCheck  a2'>>
 2082   return (res')
 2083 
 2084 
 2085 
 2086 -- |The fixed leg's cash flows.
 2087 qlFixedVsFloatingSwapFixedLeg :: (GenFixedVsFloatingSwap f) -> IO ((Leg))
 2088 qlFixedVsFloatingSwapFixedLeg a1 =
 2089   withFixedVsFloatingSwap a1 $ \a1' -> 
 2090   preErrorCheck $ \a2' -> 
 2091   qlFixedVsFloatingSwapFixedLeg'_ a1' a2' >>= \res ->
 2092   peekLeg res >>= \res' ->
 2093   errorCheck  a2'>>
 2094   return (res')
 2095 
 2096 
 2097 
 2098 -- |Basis-point sensitivity of the fixed leg.
 2099 qlFixedVsFloatingSwapFixedLegBPS :: (GenFixedVsFloatingSwap f) -> IO ((Double))
 2100 qlFixedVsFloatingSwapFixedLegBPS a1 =
 2101   withFixedVsFloatingSwap a1 $ \a1' -> 
 2102   preErrorCheck $ \a2' -> 
 2103   qlFixedVsFloatingSwapFixedLegBPS'_ a1' a2' >>= \res ->
 2104   let {res' = realToFrac res} in
 2105   errorCheck  a2'>>
 2106   return (res')
 2107 
 2108 
 2109 
 2110 -- |NPV of the fixed leg.
 2111 qlFixedVsFloatingSwapFixedLegNPV :: (GenFixedVsFloatingSwap f) -> IO ((Double))
 2112 qlFixedVsFloatingSwapFixedLegNPV a1 =
 2113   withFixedVsFloatingSwap a1 $ \a1' -> 
 2114   preErrorCheck $ \a2' -> 
 2115   qlFixedVsFloatingSwapFixedLegNPV'_ a1' a2' >>= \res ->
 2116   let {res' = realToFrac res} in
 2117   errorCheck  a2'>>
 2118   return (res')
 2119 
 2120 
 2121 
 2122 -- |The fixed rate that would make the swap's NPV zero.
 2123 qlOvernightIndexedSwapFairRate :: (OvernightIndexedSwap) -> IO ((Double))
 2124 qlOvernightIndexedSwapFairRate a1 =
 2125   withOvernightIndexedSwap a1 $ \a1' -> 
 2126   preErrorCheck $ \a2' -> 
 2127   qlOvernightIndexedSwapFairRate'_ a1' a2' >>= \res ->
 2128   let {res' = realToFrac res} in
 2129   errorCheck  a2'>>
 2130   return (res')
 2131 
 2132 
 2133 
 2134 -- |The fixed leg's cash flows.
 2135 qlOvernightIndexedSwapFixedLeg :: (OvernightIndexedSwap) -> IO ((Leg))
 2136 qlOvernightIndexedSwapFixedLeg a1 =
 2137   withOvernightIndexedSwap a1 $ \a1' -> 
 2138   preErrorCheck $ \a2' -> 
 2139   qlOvernightIndexedSwapFixedLeg'_ a1' a2' >>= \res ->
 2140   peekLeg res >>= \res' ->
 2141   errorCheck  a2'>>
 2142   return (res')
 2143 
 2144 
 2145 
 2146 -- |Basis-point sensitivity of the fixed leg.
 2147 qlOvernightIndexedSwapFixedLegBPS :: (OvernightIndexedSwap) -> IO ((Double))
 2148 qlOvernightIndexedSwapFixedLegBPS a1 =
 2149   withOvernightIndexedSwap a1 $ \a1' -> 
 2150   preErrorCheck $ \a2' -> 
 2151   qlOvernightIndexedSwapFixedLegBPS'_ a1' a2' >>= \res ->
 2152   let {res' = realToFrac res} in
 2153   errorCheck  a2'>>
 2154   return (res')
 2155 
 2156 
 2157 
 2158 -- |NPV of the fixed leg.
 2159 qlOvernightIndexedSwapFixedLegNPV :: (OvernightIndexedSwap) -> IO ((Double))
 2160 qlOvernightIndexedSwapFixedLegNPV a1 =
 2161   withOvernightIndexedSwap a1 $ \a1' -> 
 2162   preErrorCheck $ \a2' -> 
 2163   qlOvernightIndexedSwapFixedLegNPV'_ a1' a2' >>= \res ->
 2164   let {res' = realToFrac res} in
 2165   errorCheck  a2'>>
 2166   return (res')
 2167 
 2168 
 2169 
 2170 -- |The spread that would make the swap's NPV zero.
 2171 qlOvernightIndexedSwapFairSpread :: (OvernightIndexedSwap) -> IO ((Double))
 2172 qlOvernightIndexedSwapFairSpread a1 =
 2173   withOvernightIndexedSwap a1 $ \a1' -> 
 2174   preErrorCheck $ \a2' -> 
 2175   qlOvernightIndexedSwapFairSpread'_ a1' a2' >>= \res ->
 2176   let {res' = realToFrac res} in
 2177   errorCheck  a2'>>
 2178   return (res')
 2179 
 2180 
 2181 
 2182 -- |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.
 2183 qlCreditDefaultSwapFairSpread :: (CreditDefaultSwap) -> IO ((Double))
 2184 qlCreditDefaultSwapFairSpread a1 =
 2185   withGenInstrument a1 $ \a1' -> 
 2186   preErrorCheck $ \a2' -> 
 2187   qlCreditDefaultSwapFairSpread'_ a1' a2' >>= \res ->
 2188   let {res' = realToFrac res} in
 2189   errorCheck  a2'>>
 2190   return (res')
 2191 
 2192 
 2193 
 2194 -- |The floating leg's cash flows.
 2195 qlFixedVsFloatingSwapFloatingLeg :: (GenFixedVsFloatingSwap f) -> IO ((Leg))
 2196 qlFixedVsFloatingSwapFloatingLeg a1 =
 2197   withFixedVsFloatingSwap a1 $ \a1' -> 
 2198   preErrorCheck $ \a2' -> 
 2199   qlFixedVsFloatingSwapFloatingLeg'_ a1' a2' >>= \res ->
 2200   peekLeg res >>= \res' ->
 2201   errorCheck  a2'>>
 2202   return (res')
 2203 
 2204 
 2205 
 2206 -- |Basis-point sensitivity of the floating leg.
 2207 qlFixedVsFloatingSwapFloatingLegBPS :: (GenFixedVsFloatingSwap f) -> IO ((Double))
 2208 qlFixedVsFloatingSwapFloatingLegBPS a1 =
 2209   withFixedVsFloatingSwap a1 $ \a1' -> 
 2210   preErrorCheck $ \a2' -> 
 2211   qlFixedVsFloatingSwapFloatingLegBPS'_ a1' a2' >>= \res ->
 2212   let {res' = realToFrac res} in
 2213   errorCheck  a2'>>
 2214   return (res')
 2215 
 2216 
 2217 
 2218 -- |NPV of the floating leg.
 2219 qlFixedVsFloatingSwapFloatingLegNPV :: (GenFixedVsFloatingSwap f) -> IO ((Double))
 2220 qlFixedVsFloatingSwapFloatingLegNPV a1 =
 2221   withFixedVsFloatingSwap a1 $ \a1' -> 
 2222   preErrorCheck $ \a2' -> 
 2223   qlFixedVsFloatingSwapFloatingLegNPV'_ a1' a2' >>= \res ->
 2224   let {res' = realToFrac res} in
 2225   errorCheck  a2'>>
 2226   return (res')
 2227 
 2228 
 2229 
 2230 -- |The floating leg's cash flows.
 2231 qlAssetSwapFloatingLeg :: (AssetSwap) -> IO ((Leg))
 2232 qlAssetSwapFloatingLeg a1 =
 2233   withAssetSwap a1 $ \a1' -> 
 2234   preErrorCheck $ \a2' -> 
 2235   qlAssetSwapFloatingLeg'_ a1' a2' >>= \res ->
 2236   peekLeg res >>= \res' ->
 2237   errorCheck  a2'>>
 2238   return (res')
 2239 
 2240 
 2241 
 2242 -- |Basis-point sensitivity of the floating leg.
 2243 qlAssetSwapFloatingLegBPS :: (AssetSwap) -> IO ((Double))
 2244 qlAssetSwapFloatingLegBPS a1 =
 2245   withAssetSwap a1 $ \a1' -> 
 2246   preErrorCheck $ \a2' -> 
 2247   qlAssetSwapFloatingLegBPS'_ a1' a2' >>= \res ->
 2248   let {res' = realToFrac res} in
 2249   errorCheck  a2'>>
 2250   return (res')
 2251 
 2252 
 2253 
 2254 -- |NPV of the floating leg.
 2255 qlAssetSwapFloatingLegNPV :: (AssetSwap) -> IO ((Double))
 2256 qlAssetSwapFloatingLegNPV a1 =
 2257   withAssetSwap a1 $ \a1' -> 
 2258   preErrorCheck $ \a2' -> 
 2259   qlAssetSwapFloatingLegNPV'_ a1' a2' >>= \res ->
 2260   let {res' = realToFrac res} in
 2261   errorCheck  a2'>>
 2262   return (res')
 2263 
 2264 
 2265 
 2266 
 2267 
 2268 
 2269 -- |Variance swap: pays off the difference between realized and strike variance, scaled by notional. This class does not manage seasoned variance swaps.
 2270 varianceSwap :: (PositionType) -> (Double) -- ^strike
 2271  -> (Double) -- ^notional
 2272  -> (Day) -- ^startDate
 2273  -> (Day) -- ^maturityDate
 2274  -> IO ((VarianceSwap))
 2275 varianceSwap a1 a2 a3 a4 a5 =
 2276   let {a1' = fromEnumC a1} in 
 2277   let {a2' = realToFrac a2} in 
 2278   let {a3' = realToFrac a3} in 
 2279   withDay a4 $ \a4' -> 
 2280   withDay a5 $ \a5' -> 
 2281   preErrorCheck $ \a6' -> 
 2282   varianceSwap'_ a1' a2' a3' a4' a5' a6' >>= \res ->
 2283   peekVarianceSwap res >>= \res' ->
 2284   errorCheck  a6'>>
 2285   return (res')
 2286 
 2287 
 2288 
 2289 -- |Realized variance -- requires a pricing engine to be set first
 2290 variance :: (VarianceSwap) -> IO ((Double))
 2291 variance a1 =
 2292   withGenInstrument a1 $ \a1' -> 
 2293   preErrorCheck $ \a2' -> 
 2294   variance'_ a1' a2' >>= \res ->
 2295   let {res' = realToFrac res} in
 2296   errorCheck  a2'>>
 2297   return (res')
 2298 
 2299 
 2300 
 2301 
 2302 
 2303 
 2304 
 2305 
 2306 -- |Variance option: an option on realized variance, priced (e.g. via 'integralHestonVarianceOptionEngine')
 2307 -- against a payoff on the variance level rather than the underlying price. This class does not
 2308 -- manage seasoned variance options.
 2309 varianceOption :: (Payoff) -> (Double) -- ^notional
 2310  -> (Day) -- ^startDate
 2311  -> (Day) -- ^maturityDate
 2312  -> IO ((VarianceOption))
 2313 varianceOption a1 a2 a3 a4 =
 2314   withPayoff a1 $ \a1' -> 
 2315   let {a2' = realToFrac a2} in 
 2316   withDay a3 $ \a3' -> 
 2317   withDay a4 $ \a4' -> 
 2318   preErrorCheck $ \a5' -> 
 2319   varianceOption'_ a1' a2' a3' a4' a5' >>= \res ->
 2320   peekVarianceOption res >>= \res' ->
 2321   errorCheck  a5'>>
 2322   return (res')
 2323 
 2324 
 2325 
 2326 -- vim: set ff=unix ts=8 sts=2 sw=2 et:
 2327 
 2328 foreign import ccall safe "QuantLib/Instrument/Swap.chs.h qlSwaptionImpliedVolatility"
 2329   impliedVolatility'_ :: ((C2HSImp.Ptr (CSwaption')) -> (C2HSImp.CDouble -> ((C2HSImp.Ptr (CYieldTermStructure')) -> (C2HSImp.CDouble -> (C2HSImp.CDouble -> (C2HSImp.CUInt -> (C2HSImp.CDouble -> (C2HSImp.CDouble -> (C2HSImp.CInt -> (C2HSImp.CDouble -> (C2HSImp.CInt -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO C2HSImp.CDouble)))))))))))))
 2330 
 2331 foreign import ccall safe "QuantLib/Instrument/Swap.chs.h qlSwap1"
 2332   qlSwap1'_ :: (C2HSImp.CUInt -> ((C2HSImp.Ptr (C2HSImp.Ptr (CLeg'))) -> (C2HSImp.CUInt -> ((C2HSImp.Ptr C2HSImp.CInt) -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO (C2HSImp.Ptr (CSwap'))))))))
 2333 
 2334 foreign import ccall safe "QuantLib/Instrument/Swap.chs.h qlBMASwap"
 2335   bmaSwap'_ :: (C2HSImp.CInt -> (C2HSImp.CDouble -> ((C2HSImp.Ptr (CSchedule)) -> (C2HSImp.CDouble -> (C2HSImp.CDouble -> ((C2HSImp.Ptr (CIborIndex')) -> ((C2HSImp.Ptr (CDayCounter)) -> ((C2HSImp.Ptr (CSchedule)) -> ((C2HSImp.Ptr (CBMAIndex')) -> ((C2HSImp.Ptr (CDayCounter)) -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO (C2HSImp.Ptr (CBMASwap'))))))))))))))
 2336 
 2337 foreign import ccall safe "QuantLib/Instrument/Swap.chs.h qlVanillaSwap"
 2338   vanillaSwap'_ :: (C2HSImp.CInt -> (C2HSImp.CDouble -> ((C2HSImp.Ptr (CSchedule)) -> (C2HSImp.CDouble -> ((C2HSImp.Ptr (CDayCounter)) -> ((C2HSImp.Ptr (CSchedule)) -> ((C2HSImp.Ptr (CIborIndex')) -> (C2HSImp.CDouble -> ((C2HSImp.Ptr (CDayCounter)) -> (C2HSImp.CInt -> (C2HSImp.CInt -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO (C2HSImp.Ptr (CVanillaSwap')))))))))))))))
 2339 
 2340 foreign import ccall safe "QuantLib/Instrument/Swap.chs.h qlNonstandardSwap1"
 2341   nonstandardSwapFromVanilla'_ :: ((C2HSImp.Ptr (CFixedVsFloatingSwap')) -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO (C2HSImp.Ptr (CNonstandardSwap')))))
 2342 
 2343 foreign import ccall safe "QuantLib/Instrument/Swap.chs.h qlNonstandardSwap"
 2344   nonstandardSwap'_ :: (C2HSImp.CInt -> (C2HSImp.CUInt -> ((C2HSImp.Ptr C2HSImp.CDouble) -> (C2HSImp.CUInt -> ((C2HSImp.Ptr C2HSImp.CDouble) -> ((C2HSImp.Ptr (CSchedule)) -> (C2HSImp.CUInt -> ((C2HSImp.Ptr C2HSImp.CDouble) -> ((C2HSImp.Ptr (CDayCounter)) -> ((C2HSImp.Ptr (CSchedule)) -> ((C2HSImp.Ptr (CIborIndex')) -> (C2HSImp.CDouble -> (C2HSImp.CDouble -> ((C2HSImp.Ptr (CDayCounter)) -> (C2HSImp.CInt -> (C2HSImp.CInt -> (C2HSImp.CInt -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO (C2HSImp.Ptr (CNonstandardSwap')))))))))))))))))))))
 2345 
 2346 foreign import ccall safe "QuantLib/Instrument/Swap.chs.h qlNonstandardSwap2"
 2347   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.CUInt -> ((C2HSImp.Ptr C2HSImp.CDouble) -> (C2HSImp.CUInt -> ((C2HSImp.Ptr C2HSImp.CDouble) -> ((C2HSImp.Ptr (CDayCounter)) -> (C2HSImp.CInt -> (C2HSImp.CInt -> (C2HSImp.CInt -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO (C2HSImp.Ptr (CNonstandardSwap')))))))))))))))))))))))
 2348 
 2349 foreign import ccall safe "QuantLib/Instrument/Swap.chs.h qlFloatFloatSwap"
 2350   floatFloatSwap_'_ :: (C2HSImp.CInt -> (C2HSImp.CDouble -> (C2HSImp.CDouble -> ((C2HSImp.Ptr (CSchedule)) -> ((C2HSImp.Ptr (CInterestRateIndex')) -> ((C2HSImp.Ptr (CDayCounter)) -> ((C2HSImp.Ptr (CSchedule)) -> ((C2HSImp.Ptr (CInterestRateIndex')) -> ((C2HSImp.Ptr (CDayCounter)) -> (C2HSImp.CInt -> (C2HSImp.CInt -> (C2HSImp.CDouble -> (C2HSImp.CDouble -> (C2HSImp.CDouble -> (C2HSImp.CDouble -> (C2HSImp.CDouble -> (C2HSImp.CDouble -> (C2HSImp.CDouble -> (C2HSImp.CDouble -> (C2HSImp.CInt -> (C2HSImp.CInt -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO (C2HSImp.Ptr (CFloatFloatSwap')))))))))))))))))))))))))
 2351 
 2352 foreign import ccall safe "QuantLib/Instrument/Swap.chs.h qlFloatFloatSwap2"
 2353   floatFloatSwap2_'_ :: (C2HSImp.CInt -> (C2HSImp.CUInt -> ((C2HSImp.Ptr C2HSImp.CDouble) -> (C2HSImp.CUInt -> ((C2HSImp.Ptr C2HSImp.CDouble) -> ((C2HSImp.Ptr (CSchedule)) -> ((C2HSImp.Ptr (CInterestRateIndex')) -> ((C2HSImp.Ptr (CDayCounter)) -> ((C2HSImp.Ptr (CSchedule)) -> ((C2HSImp.Ptr (CInterestRateIndex')) -> ((C2HSImp.Ptr (CDayCounter)) -> (C2HSImp.CInt -> (C2HSImp.CInt -> (C2HSImp.CUInt -> ((C2HSImp.Ptr C2HSImp.CDouble) -> (C2HSImp.CUInt -> ((C2HSImp.Ptr C2HSImp.CDouble) -> (C2HSImp.CUInt -> ((C2HSImp.Ptr C2HSImp.CDouble) -> (C2HSImp.CUInt -> ((C2HSImp.Ptr C2HSImp.CDouble) -> (C2HSImp.CUInt -> ((C2HSImp.Ptr C2HSImp.CDouble) -> (C2HSImp.CUInt -> ((C2HSImp.Ptr C2HSImp.CDouble) -> (C2HSImp.CUInt -> ((C2HSImp.Ptr C2HSImp.CDouble) -> (C2HSImp.CUInt -> ((C2HSImp.Ptr C2HSImp.CDouble) -> (C2HSImp.CInt -> (C2HSImp.CInt -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO (C2HSImp.Ptr (CFloatFloatSwap')))))))))))))))))))))))))))))))))))
 2354 
 2355 foreign import ccall safe "QuantLib/Instrument/Swap.chs.h qlFloatFloatSwapFairSpread1"
 2356   fairSpread1'_ :: ((C2HSImp.Ptr (CFloatFloatSwap')) -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO C2HSImp.CDouble)))
 2357 
 2358 foreign import ccall safe "QuantLib/Instrument/Swap.chs.h qlFloatFloatSwapFairSpread2"
 2359   fairSpread2'_ :: ((C2HSImp.Ptr (CFloatFloatSwap')) -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO C2HSImp.CDouble)))
 2360 
 2361 foreign import ccall safe "QuantLib/Instrument/Swap.chs.h qlSwap"
 2362   swap'_ :: ((C2HSImp.Ptr (CLeg')) -> ((C2HSImp.Ptr (CLeg')) -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO (C2HSImp.Ptr (CSwap'))))))
 2363 
 2364 foreign import ccall safe "QuantLib/Instrument/Swap.chs.h qlSwapEndDiscounts"
 2365   endDiscounts'_ :: ((C2HSImp.Ptr (CSwap')) -> (C2HSImp.CUInt -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO C2HSImp.CDouble))))
 2366 
 2367 foreign import ccall safe "QuantLib/Instrument/Swap.chs.h qlSwapLeg"
 2368   leg'_ :: ((C2HSImp.Ptr (CSwap')) -> (C2HSImp.CUInt -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO (C2HSImp.Ptr (CLeg'))))))
 2369 
 2370 foreign import ccall safe "QuantLib/Instrument/Swap.chs.h qlSwapLegBPS"
 2371   legBPS'_ :: ((C2HSImp.Ptr (CSwap')) -> (C2HSImp.CUInt -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO C2HSImp.CDouble))))
 2372 
 2373 foreign import ccall safe "QuantLib/Instrument/Swap.chs.h qlSwapLegNPV"
 2374   legNPV'_ :: ((C2HSImp.Ptr (CSwap')) -> (C2HSImp.CUInt -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO C2HSImp.CDouble))))
 2375 
 2376 foreign import ccall safe "QuantLib/Instrument/Swap.chs.h qlSwapStartDiscounts"
 2377   startDiscounts'_ :: ((C2HSImp.Ptr (CSwap')) -> (C2HSImp.CUInt -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO C2HSImp.CDouble))))
 2378 
 2379 foreign import ccall safe "QuantLib/Instrument/Swap.chs.h qlConstNotionalCrossCurrencySwap"
 2380   constNotionalCrossCurrencySwap'_ :: ((C2HSImp.Ptr (CLeg')) -> ((C2HSImp.Ptr (CCurrency)) -> ((C2HSImp.Ptr (CLeg')) -> ((C2HSImp.Ptr (CCurrency)) -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO (C2HSImp.Ptr (CConstNotionalCrossCurrencySwap'))))))))
 2381 
 2382 foreign import ccall safe "QuantLib/Instrument/Swap.chs.h qlConstNotionalCrossCurrencySwap1"
 2383   qlConstNotionalCrossCurrencySwap1'_ :: (C2HSImp.CUInt -> ((C2HSImp.Ptr (C2HSImp.Ptr (CLeg'))) -> (C2HSImp.CUInt -> ((C2HSImp.Ptr C2HSImp.CInt) -> (C2HSImp.CUInt -> ((C2HSImp.Ptr (C2HSImp.Ptr (CCurrency))) -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO (C2HSImp.Ptr (CConstNotionalCrossCurrencySwap'))))))))))
 2384 
 2385 foreign import ccall safe "QuantLib/Instrument/Swap.chs.h qlConstNotionalCrossCurrencySwapLegCurrency"
 2386   legCurrency'_ :: ((C2HSImp.Ptr (CConstNotionalCrossCurrencySwap')) -> (C2HSImp.CUInt -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO (C2HSImp.Ptr (CCurrency))))))
 2387 
 2388 foreign import ccall safe "QuantLib/Instrument/Swap.chs.h qlConstNotionalCrossCurrencySwapInCcyLegBPS"
 2389   inCcyLegBPS'_ :: ((C2HSImp.Ptr (CConstNotionalCrossCurrencySwap')) -> (C2HSImp.CUInt -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO C2HSImp.CDouble))))
 2390 
 2391 foreign import ccall safe "QuantLib/Instrument/Swap.chs.h qlConstNotionalCrossCurrencySwapInCcyLegNPV"
 2392   inCcyLegNPV'_ :: ((C2HSImp.Ptr (CConstNotionalCrossCurrencySwap')) -> (C2HSImp.CUInt -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO C2HSImp.CDouble))))
 2393 
 2394 foreign import ccall safe "QuantLib/Instrument/Swap.chs.h qlConstNotionalCrossCurrencySwapNpvDateDiscounts"
 2395   npvDateDiscounts'_ :: ((C2HSImp.Ptr (CConstNotionalCrossCurrencySwap')) -> (C2HSImp.CUInt -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO C2HSImp.CDouble))))
 2396 
 2397 foreign import ccall safe "QuantLib/Instrument/Swap.chs.h qlConstNotionalCrossCurrencyBasisSwap"
 2398   constNotionalCrossCurrencyBasisSwap_'_ :: (C2HSImp.CDouble -> ((C2HSImp.Ptr (CCurrency)) -> ((C2HSImp.Ptr (CSchedule)) -> ((C2HSImp.Ptr (CIborIndex')) -> (C2HSImp.CDouble -> (C2HSImp.CDouble -> (C2HSImp.CDouble -> ((C2HSImp.Ptr (CCurrency)) -> ((C2HSImp.Ptr (CSchedule)) -> ((C2HSImp.Ptr (CIborIndex')) -> (C2HSImp.CDouble -> (C2HSImp.CDouble -> (C2HSImp.CInt -> (C2HSImp.CInt -> (C2HSImp.CInt -> (C2HSImp.CUInt -> (C2HSImp.CInt -> (C2HSImp.CUInt -> (C2HSImp.CInt -> (C2HSImp.CInt -> (C2HSImp.CUInt -> (C2HSImp.CInt -> (C2HSImp.CUInt -> (C2HSImp.CInt -> (C2HSImp.CInt -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO (C2HSImp.Ptr (CConstNotionalCrossCurrencyBasisSwap')))))))))))))))))))))))))))))
 2399 
 2400 foreign import ccall safe "QuantLib/Instrument/Swap.chs.h qlConstNotionalCrossCurrencyBasisSwapFairPaySpread"
 2401   fairPaySpread'_ :: ((C2HSImp.Ptr (CConstNotionalCrossCurrencyBasisSwap')) -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO C2HSImp.CDouble)))
 2402 
 2403 foreign import ccall safe "QuantLib/Instrument/Swap.chs.h qlConstNotionalCrossCurrencyBasisSwapFairRecSpread"
 2404   fairRecSpread'_ :: ((C2HSImp.Ptr (CConstNotionalCrossCurrencyBasisSwap')) -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO C2HSImp.CDouble)))
 2405 
 2406 foreign import ccall safe "QuantLib/Instrument/Swap.chs.h qlConstNotionalCrossCurrencyFixedVsFloatingSwap"
 2407   constNotionalCrossCurrencyFixedVsFloatingSwap'_ :: (C2HSImp.CInt -> (C2HSImp.CDouble -> ((C2HSImp.Ptr (CCurrency)) -> ((C2HSImp.Ptr (CSchedule)) -> (C2HSImp.CDouble -> ((C2HSImp.Ptr (CDayCounter)) -> (C2HSImp.CInt -> (C2HSImp.CUInt -> ((C2HSImp.Ptr (CCalendar)) -> (C2HSImp.CDouble -> ((C2HSImp.Ptr (CCurrency)) -> ((C2HSImp.Ptr (CSchedule)) -> ((C2HSImp.Ptr (CIborIndex')) -> (C2HSImp.CDouble -> (C2HSImp.CInt -> (C2HSImp.CUInt -> ((C2HSImp.Ptr (CCalendar)) -> (C2HSImp.CInt -> (C2HSImp.CInt -> (C2HSImp.CUInt -> (C2HSImp.CInt -> (C2HSImp.CUInt -> (C2HSImp.CInt -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO (C2HSImp.Ptr (CConstNotionalCrossCurrencyFixedVsFloatingSwap')))))))))))))))))))))))))))
 2408 
 2409 foreign import ccall safe "QuantLib/Instrument/Swap.chs.h qlConstNotionalCrossCurrencyFixedVsFloatingSwapFairRate"
 2410   xccyFairRate'_ :: ((C2HSImp.Ptr (CConstNotionalCrossCurrencyFixedVsFloatingSwap')) -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO C2HSImp.CDouble)))
 2411 
 2412 foreign import ccall safe "QuantLib/Instrument/Swap.chs.h qlConstNotionalCrossCurrencyFixedVsFloatingSwapFairSpread"
 2413   qlConstNotionalCrossCurrencyFixedVsFloatingSwapFairSpread'_ :: ((C2HSImp.Ptr (CConstNotionalCrossCurrencyFixedVsFloatingSwap')) -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO C2HSImp.CDouble)))
 2414 
 2415 foreign import ccall safe "QuantLib/Instrument/Swap.chs.h qlSwaption"
 2416   swaption'_ :: ((C2HSImp.Ptr (CFixedVsFloatingSwap')) -> ((QlExercise) -> (C2HSImp.CInt -> (C2HSImp.CInt -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO (C2HSImp.Ptr (CSwaption'))))))))
 2417 
 2418 foreign import ccall safe "QuantLib/Instrument/Swap.chs.h qlNonstandardSwaption1"
 2419   nonstandardSwaptionFromSwaption'_ :: ((C2HSImp.Ptr (CSwaption')) -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO (C2HSImp.Ptr (CNonstandardSwaption')))))
 2420 
 2421 foreign import ccall safe "QuantLib/Instrument/Swap.chs.h qlNonstandardSwaption"
 2422   nonstandardSwaption'_ :: ((C2HSImp.Ptr (CNonstandardSwap')) -> ((QlExercise) -> (C2HSImp.CInt -> (C2HSImp.CInt -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO (C2HSImp.Ptr (CNonstandardSwaption'))))))))
 2423 
 2424 foreign import ccall safe "QuantLib/Instrument/Swap.chs.h qlNonstandardSwaptionCalibrationBasket"
 2425   calibrationBasket'_ :: ((C2HSImp.Ptr (CNonstandardSwaption')) -> ((C2HSImp.Ptr (CSwapIndex')) -> ((C2HSImp.Ptr (CSwaptionVolatilityStructure')) -> (C2HSImp.CInt -> ((C2HSImp.Ptr C2HSImp.CUInt) -> ((C2HSImp.Ptr (C2HSImp.Ptr (C2HSImp.Ptr (CBlackCalibrationHelper')))) -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO ()))))))))
 2426 
 2427 foreign import ccall safe "QuantLib/Instrument/Swap.chs.h qlFloatFloatSwaption"
 2428   floatFloatSwaption'_ :: ((C2HSImp.Ptr (CFloatFloatSwap')) -> ((QlExercise) -> (C2HSImp.CInt -> (C2HSImp.CInt -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO (C2HSImp.Ptr (CFloatFloatSwaption'))))))))
 2429 
 2430 foreign import ccall safe "QuantLib/Instrument/Swap.chs.h qlFloatFloatSwaptionCalibrationBasket"
 2431   floatFloatSwaptionCalibrationBasket'_ :: ((C2HSImp.Ptr (CFloatFloatSwaption')) -> ((C2HSImp.Ptr (CSwapIndex')) -> ((C2HSImp.Ptr (CSwaptionVolatilityStructure')) -> (C2HSImp.CInt -> ((C2HSImp.Ptr C2HSImp.CUInt) -> ((C2HSImp.Ptr (C2HSImp.Ptr (C2HSImp.Ptr (CBlackCalibrationHelper')))) -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO ()))))))))
 2432 
 2433 foreign import ccall safe "QuantLib/Instrument/Swap.chs.h qlAssetSwap"
 2434   assetSwap'_ :: (C2HSImp.CInt -> ((C2HSImp.Ptr (CBond')) -> (C2HSImp.CDouble -> ((C2HSImp.Ptr (CIborIndex')) -> (C2HSImp.CDouble -> ((C2HSImp.Ptr (CSchedule)) -> ((C2HSImp.Ptr (CDayCounter)) -> (C2HSImp.CInt -> (C2HSImp.CDouble -> (C2HSImp.CDouble -> (C2HSImp.CInt -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO (C2HSImp.Ptr (CAssetSwap')))))))))))))))
 2435 
 2436 foreign import ccall safe "QuantLib/Instrument/Swap.chs.h qlOvernightIndexedSwap"
 2437   overnightIndexedSwap'_ :: (C2HSImp.CInt -> (C2HSImp.CDouble -> ((C2HSImp.Ptr (CSchedule)) -> (C2HSImp.CDouble -> ((C2HSImp.Ptr (CDayCounter)) -> ((C2HSImp.Ptr (COvernightIndex')) -> (C2HSImp.CDouble -> (C2HSImp.CInt -> (C2HSImp.CInt -> ((C2HSImp.Ptr (CCalendar)) -> (C2HSImp.CInt -> (C2HSImp.CInt -> (C2HSImp.CUInt -> (C2HSImp.CUInt -> (C2HSImp.CInt -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO (C2HSImp.Ptr (COvernightIndexedSwap')))))))))))))))))))
 2438 
 2439 foreign import ccall safe "QuantLib/Instrument/Swap.chs.h qlOvernightIndexedSwap1"
 2440   overnightIndexedSwap''_ :: (C2HSImp.CInt -> (C2HSImp.CUInt -> ((C2HSImp.Ptr C2HSImp.CDouble) -> ((C2HSImp.Ptr (CSchedule)) -> (C2HSImp.CDouble -> ((C2HSImp.Ptr (CDayCounter)) -> ((C2HSImp.Ptr (COvernightIndex')) -> (C2HSImp.CDouble -> (C2HSImp.CInt -> (C2HSImp.CInt -> ((C2HSImp.Ptr (CCalendar)) -> (C2HSImp.CInt -> (C2HSImp.CInt -> (C2HSImp.CUInt -> (C2HSImp.CUInt -> (C2HSImp.CInt -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO (C2HSImp.Ptr (COvernightIndexedSwap'))))))))))))))))))))
 2441 
 2442 foreign import ccall safe "QuantLib/Instrument/Swap.chs.h qlSwapMaturityDate"
 2443   maturityDate'_ :: ((C2HSImp.Ptr (CSwap')) -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO C2HSImp.CInt)))
 2444 
 2445 foreign import ccall safe "QuantLib/Instrument/Swap.chs.h qlSwapStartDate"
 2446   startDate'_ :: ((C2HSImp.Ptr (CSwap')) -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO C2HSImp.CInt)))
 2447 
 2448 foreign import ccall safe "QuantLib/Instrument/Swap.chs.h qlSwapNpvDateDiscount"
 2449   npvDateDiscount'_ :: ((C2HSImp.Ptr (CSwap')) -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO C2HSImp.CDouble)))
 2450 
 2451 foreign import ccall safe "QuantLib/Instrument/Swap.chs.h qlBMASwapBmaLeg"
 2452   bmaLeg'_ :: ((C2HSImp.Ptr (CBMASwap')) -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO (C2HSImp.Ptr (CLeg')))))
 2453 
 2454 foreign import ccall safe "QuantLib/Instrument/Swap.chs.h qlBMASwapBmaLegBPS"
 2455   bmaLegBPS'_ :: ((C2HSImp.Ptr (CBMASwap')) -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO C2HSImp.CDouble)))
 2456 
 2457 foreign import ccall safe "QuantLib/Instrument/Swap.chs.h qlBMASwapBmaLegNPV"
 2458   bmaLegNPV'_ :: ((C2HSImp.Ptr (CBMASwap')) -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO C2HSImp.CDouble)))
 2459 
 2460 foreign import ccall safe "QuantLib/Instrument/Swap.chs.h qlBMASwapFairLiborFraction"
 2461   fairLiborFraction'_ :: ((C2HSImp.Ptr (CBMASwap')) -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO C2HSImp.CDouble)))
 2462 
 2463 foreign import ccall safe "QuantLib/Instrument/Swap.chs.h qlBMASwapFairLiborSpread"
 2464   fairLiborSpread'_ :: ((C2HSImp.Ptr (CBMASwap')) -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO C2HSImp.CDouble)))
 2465 
 2466 foreign import ccall safe "QuantLib/Instrument/Swap.chs.h qlBMASwapLiborFraction"
 2467   liborFraction'_ :: ((C2HSImp.Ptr (CBMASwap')) -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO C2HSImp.CDouble)))
 2468 
 2469 foreign import ccall safe "QuantLib/Instrument/Swap.chs.h qlBMASwapLiborLeg"
 2470   liborLeg'_ :: ((C2HSImp.Ptr (CBMASwap')) -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO (C2HSImp.Ptr (CLeg')))))
 2471 
 2472 foreign import ccall safe "QuantLib/Instrument/Swap.chs.h qlBMASwapLiborLegBPS"
 2473   liborLegBPS'_ :: ((C2HSImp.Ptr (CBMASwap')) -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO C2HSImp.CDouble)))
 2474 
 2475 foreign import ccall safe "QuantLib/Instrument/Swap.chs.h qlBMASwapLiborLegNPV"
 2476   liborLegNPV'_ :: ((C2HSImp.Ptr (CBMASwap')) -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO C2HSImp.CDouble)))
 2477 
 2478 foreign import ccall safe "QuantLib/Instrument/Swap.chs.h qlAssetSwapBondLeg"
 2479   bondLeg'_ :: ((C2HSImp.Ptr (CAssetSwap')) -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO (C2HSImp.Ptr (CLeg')))))
 2480 
 2481 foreign import ccall safe "QuantLib/Instrument/Swap.chs.h qlAssetSwapCleanPrice"
 2482   cleanPrice'_ :: ((C2HSImp.Ptr (CAssetSwap')) -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO C2HSImp.CDouble)))
 2483 
 2484 foreign import ccall safe "QuantLib/Instrument/Swap.chs.h qlAssetSwapFairCleanPrice"
 2485   fairCleanPrice'_ :: ((C2HSImp.Ptr (CAssetSwap')) -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO C2HSImp.CDouble)))
 2486 
 2487 foreign import ccall safe "QuantLib/Instrument/Swap.chs.h qlAssetSwapFairNonParRepayment"
 2488   fairNonParRepayment'_ :: ((C2HSImp.Ptr (CAssetSwap')) -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO C2HSImp.CDouble)))
 2489 
 2490 foreign import ccall safe "QuantLib/Instrument/Swap.chs.h qlAssetSwapNonParRepayment"
 2491   nonParRepayment'_ :: ((C2HSImp.Ptr (CAssetSwap')) -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO C2HSImp.CDouble)))
 2492 
 2493 foreign import ccall safe "QuantLib/Instrument/Swap.chs.h qlAssetSwapParSwap"
 2494   parSwap'_ :: ((C2HSImp.Ptr (CAssetSwap')) -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO C2HSImp.CInt)))
 2495 
 2496 foreign import ccall safe "QuantLib/Instrument/Swap.chs.h qlAssetSwapPayBondCoupon"
 2497   payBondCoupon'_ :: ((C2HSImp.Ptr (CAssetSwap')) -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO C2HSImp.CInt)))
 2498 
 2499 foreign import ccall safe "QuantLib/Instrument/Swap.chs.h qlOvernightIndexedSwapOvernightLeg"
 2500   overnightLeg'_ :: ((C2HSImp.Ptr (COvernightIndexedSwap')) -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO (C2HSImp.Ptr (CLeg')))))
 2501 
 2502 foreign import ccall safe "QuantLib/Instrument/Swap.chs.h qlOvernightIndexedSwapOvernightLegBPS"
 2503   overnightLegBPS'_ :: ((C2HSImp.Ptr (COvernightIndexedSwap')) -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO C2HSImp.CDouble)))
 2504 
 2505 foreign import ccall safe "QuantLib/Instrument/Swap.chs.h qlOvernightIndexedSwapOvernightLegNPV"
 2506   overnightLegNPV'_ :: ((C2HSImp.Ptr (COvernightIndexedSwap')) -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO C2HSImp.CDouble)))
 2507 
 2508 foreign import ccall safe "QuantLib/Instrument/Swap.chs.h qlZeroCouponInflationSwap"
 2509   zeroCouponInflationSwap'_ :: (C2HSImp.CInt -> (C2HSImp.CDouble -> (C2HSImp.CInt -> (C2HSImp.CInt -> ((C2HSImp.Ptr (CCalendar)) -> (C2HSImp.CInt -> ((C2HSImp.Ptr (CDayCounter)) -> (C2HSImp.CDouble -> ((C2HSImp.Ptr (CZeroInflationIndex')) -> (C2HSImp.CInt -> (C2HSImp.CInt -> (C2HSImp.CInt -> (C2HSImp.CInt -> ((C2HSImp.Ptr (CCalendar)) -> (C2HSImp.CInt -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO (C2HSImp.Ptr (CZeroCouponInflationSwap')))))))))))))))))))
 2510 
 2511 foreign import ccall safe "QuantLib/Instrument/Swap.chs.h qlZeroCouponInflationSwapFairRate"
 2512   zcisFairRate'_ :: ((C2HSImp.Ptr (CZeroCouponInflationSwap')) -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO C2HSImp.CDouble)))
 2513 
 2514 foreign import ccall safe "QuantLib/Instrument/Swap.chs.h qlYearOnYearInflationSwap"
 2515   yearOnYearInflationSwap'_ :: (C2HSImp.CInt -> (C2HSImp.CDouble -> ((C2HSImp.Ptr (CSchedule)) -> (C2HSImp.CDouble -> ((C2HSImp.Ptr (CDayCounter)) -> ((C2HSImp.Ptr (CSchedule)) -> ((C2HSImp.Ptr (CYoYInflationIndex')) -> (C2HSImp.CInt -> (C2HSImp.CInt -> (C2HSImp.CInt -> (C2HSImp.CDouble -> ((C2HSImp.Ptr (CDayCounter)) -> ((C2HSImp.Ptr (CCalendar)) -> (C2HSImp.CInt -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO (C2HSImp.Ptr (CYearOnYearInflationSwap'))))))))))))))))))
 2516 
 2517 foreign import ccall safe "QuantLib/Instrument/Swap.chs.h qlYearOnYearInflationSwapFairRate"
 2518   yoyFairRate'_ :: ((C2HSImp.Ptr (CYearOnYearInflationSwap')) -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO C2HSImp.CDouble)))
 2519 
 2520 foreign import ccall safe "QuantLib/Instrument/Swap.chs.h qlYearOnYearInflationSwapFairSpread"
 2521   qlYearOnYearInflationSwapFairSpread'_ :: ((C2HSImp.Ptr (CYearOnYearInflationSwap')) -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO C2HSImp.CDouble)))
 2522 
 2523 foreign import ccall safe "QuantLib/Instrument/Swap.chs.h qlCPISwap"
 2524   cpiSwap'_ :: (C2HSImp.CInt -> (C2HSImp.CDouble -> (C2HSImp.CInt -> (C2HSImp.CDouble -> ((C2HSImp.Ptr (CDayCounter)) -> ((C2HSImp.Ptr (CSchedule)) -> (C2HSImp.CInt -> (C2HSImp.CUInt -> ((C2HSImp.Ptr (CIborIndex')) -> (C2HSImp.CDouble -> (C2HSImp.CDouble -> ((C2HSImp.Ptr (CDayCounter)) -> ((C2HSImp.Ptr (CSchedule)) -> (C2HSImp.CInt -> (C2HSImp.CInt -> (C2HSImp.CInt -> ((C2HSImp.Ptr (CZeroInflationIndex')) -> (C2HSImp.CInt -> (C2HSImp.CDouble -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO (C2HSImp.Ptr (CCPISwap')))))))))))))))))))))))
 2525 
 2526 foreign import ccall safe "QuantLib/Instrument/Swap.chs.h qlCPISwapFairRate"
 2527   cpiSwapFairRate'_ :: ((C2HSImp.Ptr (CCPISwap')) -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO C2HSImp.CDouble)))
 2528 
 2529 foreign import ccall safe "QuantLib/Instrument/Swap.chs.h qlCPISwapFairSpread"
 2530   qlCPISwapFairSpread'_ :: ((C2HSImp.Ptr (CCPISwap')) -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO C2HSImp.CDouble)))
 2531 
 2532 foreign import ccall safe "QuantLib/Instrument/Swap.chs.h qlZeroCouponSwap"
 2533   zeroCouponSwap'_ :: (C2HSImp.CInt -> (C2HSImp.CDouble -> (C2HSImp.CInt -> (C2HSImp.CInt -> (C2HSImp.CDouble -> ((C2HSImp.Ptr (CIborIndex')) -> ((C2HSImp.Ptr (CCalendar)) -> (C2HSImp.CInt -> (C2HSImp.CUInt -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO (C2HSImp.Ptr (CZeroCouponSwap')))))))))))))
 2534 
 2535 foreign import ccall safe "QuantLib/Instrument/Swap.chs.h qlZeroCouponSwap1"
 2536   zeroCouponSwap''_ :: (C2HSImp.CInt -> (C2HSImp.CDouble -> (C2HSImp.CInt -> (C2HSImp.CInt -> (C2HSImp.CDouble -> ((C2HSImp.Ptr (CDayCounter)) -> ((C2HSImp.Ptr (CIborIndex')) -> ((C2HSImp.Ptr (CCalendar)) -> (C2HSImp.CInt -> (C2HSImp.CUInt -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO (C2HSImp.Ptr (CZeroCouponSwap'))))))))))))))
 2537 
 2538 foreign import ccall safe "QuantLib/Instrument/Swap.chs.h qlZeroCouponSwapFairFixedPayment"
 2539   fairFixedPayment'_ :: ((C2HSImp.Ptr (CZeroCouponSwap')) -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO C2HSImp.CDouble)))
 2540 
 2541 foreign import ccall safe "QuantLib/Instrument/Swap.chs.h qlZeroCouponSwapFairFixedRate"
 2542   fairFixedRate'_ :: ((C2HSImp.Ptr (CZeroCouponSwap')) -> ((C2HSImp.Ptr (CDayCounter)) -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO C2HSImp.CDouble))))
 2543 
 2544 foreign import ccall safe "QuantLib/Instrument/Swap.chs.h qlEquityTotalReturnSwapIbor"
 2545   equityTotalReturnSwapIbor'_ :: (C2HSImp.CInt -> (C2HSImp.CDouble -> ((C2HSImp.Ptr (CSchedule)) -> ((C2HSImp.Ptr (CEquityIndex')) -> ((C2HSImp.Ptr (CIborIndex')) -> ((C2HSImp.Ptr (CDayCounter)) -> (C2HSImp.CDouble -> (C2HSImp.CDouble -> ((C2HSImp.Ptr (CCalendar)) -> (C2HSImp.CInt -> (C2HSImp.CUInt -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO (C2HSImp.Ptr (CEquityTotalReturnSwap')))))))))))))))
 2546 
 2547 foreign import ccall safe "QuantLib/Instrument/Swap.chs.h qlEquityTotalReturnSwapOvernight"
 2548   equityTotalReturnSwapOvernight'_ :: (C2HSImp.CInt -> (C2HSImp.CDouble -> ((C2HSImp.Ptr (CSchedule)) -> ((C2HSImp.Ptr (CEquityIndex')) -> ((C2HSImp.Ptr (COvernightIndex')) -> ((C2HSImp.Ptr (CDayCounter)) -> (C2HSImp.CDouble -> (C2HSImp.CDouble -> ((C2HSImp.Ptr (CCalendar)) -> (C2HSImp.CInt -> (C2HSImp.CUInt -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO (C2HSImp.Ptr (CEquityTotalReturnSwap')))))))))))))))
 2549 
 2550 foreign import ccall safe "QuantLib/Instrument/Swap.chs.h qlEquityTotalReturnSwapEquityLegNPV"
 2551   equityLegNPV'_ :: ((C2HSImp.Ptr (CEquityTotalReturnSwap')) -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO C2HSImp.CDouble)))
 2552 
 2553 foreign import ccall safe "QuantLib/Instrument/Swap.chs.h qlEquityTotalReturnSwapInterestRateLegNPV"
 2554   interestRateLegNPV'_ :: ((C2HSImp.Ptr (CEquityTotalReturnSwap')) -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO C2HSImp.CDouble)))
 2555 
 2556 foreign import ccall safe "QuantLib/Instrument/Swap.chs.h qlEquityTotalReturnSwapFairMargin"
 2557   fairMargin'_ :: ((C2HSImp.Ptr (CEquityTotalReturnSwap')) -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO C2HSImp.CDouble)))
 2558 
 2559 foreign import ccall safe "QuantLib/Instrument/Swap.chs.h qlFixedVsFloatingSwapFairSpread"
 2560   qlFixedVsFloatingSwapFairSpread'_ :: ((C2HSImp.Ptr (CFixedVsFloatingSwap')) -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO C2HSImp.CDouble)))
 2561 
 2562 foreign import ccall safe "QuantLib/Instrument/Swap.chs.h qlAssetSwapFairSpread"
 2563   qlAssetSwapFairSpread'_ :: ((C2HSImp.Ptr (CAssetSwap')) -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO C2HSImp.CDouble)))
 2564 
 2565 foreign import ccall safe "QuantLib/Instrument/Swap.chs.h qlFixedVsFloatingSwapFairRate"
 2566   qlFixedVsFloatingSwapFairRate'_ :: ((C2HSImp.Ptr (CFixedVsFloatingSwap')) -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO C2HSImp.CDouble)))
 2567 
 2568 foreign import ccall safe "QuantLib/Instrument/Swap.chs.h qlFixedVsFloatingSwapFixedLeg"
 2569   qlFixedVsFloatingSwapFixedLeg'_ :: ((C2HSImp.Ptr (CFixedVsFloatingSwap')) -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO (C2HSImp.Ptr (CLeg')))))
 2570 
 2571 foreign import ccall safe "QuantLib/Instrument/Swap.chs.h qlFixedVsFloatingSwapFixedLegBPS"
 2572   qlFixedVsFloatingSwapFixedLegBPS'_ :: ((C2HSImp.Ptr (CFixedVsFloatingSwap')) -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO C2HSImp.CDouble)))
 2573 
 2574 foreign import ccall safe "QuantLib/Instrument/Swap.chs.h qlFixedVsFloatingSwapFixedLegNPV"
 2575   qlFixedVsFloatingSwapFixedLegNPV'_ :: ((C2HSImp.Ptr (CFixedVsFloatingSwap')) -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO C2HSImp.CDouble)))
 2576 
 2577 foreign import ccall safe "QuantLib/Instrument/Swap.chs.h qlOvernightIndexedSwapFairRate"
 2578   qlOvernightIndexedSwapFairRate'_ :: ((C2HSImp.Ptr (COvernightIndexedSwap')) -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO C2HSImp.CDouble)))
 2579 
 2580 foreign import ccall safe "QuantLib/Instrument/Swap.chs.h qlOvernightIndexedSwapFixedLeg"
 2581   qlOvernightIndexedSwapFixedLeg'_ :: ((C2HSImp.Ptr (COvernightIndexedSwap')) -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO (C2HSImp.Ptr (CLeg')))))
 2582 
 2583 foreign import ccall safe "QuantLib/Instrument/Swap.chs.h qlOvernightIndexedSwapFixedLegBPS"
 2584   qlOvernightIndexedSwapFixedLegBPS'_ :: ((C2HSImp.Ptr (COvernightIndexedSwap')) -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO C2HSImp.CDouble)))
 2585 
 2586 foreign import ccall safe "QuantLib/Instrument/Swap.chs.h qlOvernightIndexedSwapFixedLegNPV"
 2587   qlOvernightIndexedSwapFixedLegNPV'_ :: ((C2HSImp.Ptr (COvernightIndexedSwap')) -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO C2HSImp.CDouble)))
 2588 
 2589 foreign import ccall safe "QuantLib/Instrument/Swap.chs.h qlOvernightIndexedSwapFairSpread"
 2590   qlOvernightIndexedSwapFairSpread'_ :: ((C2HSImp.Ptr (COvernightIndexedSwap')) -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO C2HSImp.CDouble)))
 2591 
 2592 foreign import ccall safe "QuantLib/Instrument/Swap.chs.h qlCreditDefaultSwapFairSpread"
 2593   qlCreditDefaultSwapFairSpread'_ :: ((C2HSImp.Ptr (CCreditDefaultSwap')) -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO C2HSImp.CDouble)))
 2594 
 2595 foreign import ccall safe "QuantLib/Instrument/Swap.chs.h qlFixedVsFloatingSwapFloatingLeg"
 2596   qlFixedVsFloatingSwapFloatingLeg'_ :: ((C2HSImp.Ptr (CFixedVsFloatingSwap')) -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO (C2HSImp.Ptr (CLeg')))))
 2597 
 2598 foreign import ccall safe "QuantLib/Instrument/Swap.chs.h qlFixedVsFloatingSwapFloatingLegBPS"
 2599   qlFixedVsFloatingSwapFloatingLegBPS'_ :: ((C2HSImp.Ptr (CFixedVsFloatingSwap')) -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO C2HSImp.CDouble)))
 2600 
 2601 foreign import ccall safe "QuantLib/Instrument/Swap.chs.h qlFixedVsFloatingSwapFloatingLegNPV"
 2602   qlFixedVsFloatingSwapFloatingLegNPV'_ :: ((C2HSImp.Ptr (CFixedVsFloatingSwap')) -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO C2HSImp.CDouble)))
 2603 
 2604 foreign import ccall safe "QuantLib/Instrument/Swap.chs.h qlAssetSwapFloatingLeg"
 2605   qlAssetSwapFloatingLeg'_ :: ((C2HSImp.Ptr (CAssetSwap')) -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO (C2HSImp.Ptr (CLeg')))))
 2606 
 2607 foreign import ccall safe "QuantLib/Instrument/Swap.chs.h qlAssetSwapFloatingLegBPS"
 2608   qlAssetSwapFloatingLegBPS'_ :: ((C2HSImp.Ptr (CAssetSwap')) -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO C2HSImp.CDouble)))
 2609 
 2610 foreign import ccall safe "QuantLib/Instrument/Swap.chs.h qlAssetSwapFloatingLegNPV"
 2611   qlAssetSwapFloatingLegNPV'_ :: ((C2HSImp.Ptr (CAssetSwap')) -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO C2HSImp.CDouble)))
 2612 
 2613 foreign import ccall safe "QuantLib/Instrument/Swap.chs.h qlVarianceSwap"
 2614   varianceSwap'_ :: (C2HSImp.CInt -> (C2HSImp.CDouble -> (C2HSImp.CDouble -> (C2HSImp.CInt -> (C2HSImp.CInt -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO (C2HSImp.Ptr (CVarianceSwap')))))))))
 2615 
 2616 foreign import ccall safe "QuantLib/Instrument/Swap.chs.h qlVarianceSwapVariance"
 2617   variance'_ :: ((C2HSImp.Ptr (CVarianceSwap')) -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO C2HSImp.CDouble)))
 2618 
 2619 foreign import ccall safe "QuantLib/Instrument/Swap.chs.h qlVarianceOption"
 2620   varianceOption'_ :: ((QlPayoff) -> (C2HSImp.CDouble -> (C2HSImp.CInt -> (C2HSImp.CInt -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO (C2HSImp.Ptr (CVarianceOption'))))))))