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


{-# LINE 1 "./QuantLib/Instrument/Credit.chs" #-}
module QuantLib.Instrument.Credit
  (
    -- * Types
    CreditDefaultSwap
  , SyntheticCDO
  , NthToDefault
  , ProtectionSide(..)
  , Claim(..)

    -- * Constructors
    -- ** Credit-default swaps and options
  , creditDefaultSwap
  , creditDefaultSwapWithUpfront
  , cdsOption
    -- ** Portfolio credit
  , syntheticCdo
  , nthToDefault

    -- * Inspectors
    -- ** Credit-default swaps and options
  , atmRate
  , impliedVolatility
  , riskyAnnuity
  , accrualRebateNpv
  , conventionalSpread
  , couponLegBps
  , couponLegNpv
  , coupons
  , defaultLegNpv
  , fairUpfront
  , impliedHazardRate
  , upfrontBps
  , upfrontNpv
    -- ** Synthetic CDOs
  , fairPremium
  , fairUpfrontPremium
  , premiumValue
  , protectionValue
  , premiumLegNpv
  , protectionLegNpv
  , cdoRemainingNotional
  , implicitCorrelation
    -- ** Nth-to-default
  , ntdFairPremium
  ) where
import qualified Foreign.C.Types as C2HSImp
import qualified Foreign.ForeignPtr as C2HSImp
import qualified Foreign.Marshal.Utils as C2HSImp
import qualified Foreign.Ptr as C2HSImp


import Data.List.NonEmpty(NonEmpty)

import QuantLib.Internal
import QuantLib.Internal.Common
import QuantLib.Internal.Type
import QuantLib.Instrument(PricingModel)







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

{-# LINE 59 "./QuantLib/Instrument/Credit.chs" #-}



{-# LINE 61 "./QuantLib/Instrument/Credit.chs" #-}


{-# LINE 62 "./QuantLib/Instrument/Credit.chs" #-}


{-# LINE 63 "./QuantLib/Instrument/Credit.chs" #-}


{-# LINE 64 "./QuantLib/Instrument/Credit.chs" #-}


{-# LINE 65 "./QuantLib/Instrument/Credit.chs" #-}


{-# LINE 66 "./QuantLib/Instrument/Credit.chs" #-}


{-# LINE 67 "./QuantLib/Instrument/Credit.chs" #-}


{-# LINE 68 "./QuantLib/Instrument/Credit.chs" #-}


{-# LINE 69 "./QuantLib/Instrument/Credit.chs" #-}


{-# LINE 70 "./QuantLib/Instrument/Credit.chs" #-}


{-# LINE 71 "./QuantLib/Instrument/Credit.chs" #-}


{-# LINE 72 "./QuantLib/Instrument/Credit.chs" #-}


{-# LINE 73 "./QuantLib/Instrument/Credit.chs" #-}


-- |CDS quoted as running-spread only.
-- side Whether the protection is bought or sold. notional Notional value spread Running spread in fractional units. schedule Coupon schedule. paymentConvention Business-day convention for payment-date adjustment. dayCounter Day-count convention for accrual. settlesAccrual Whether or not the accrued coupon is due in the event of a default. paysAtDefaultTime If set to true, any payments triggered by a default event are due at default time. If set to false, they are due at the end of the accrual period. protectionStart The first date where a default event will trigger the contract.
creditDefaultSwap :: (ProtectionSide) -> (Double) -- ^notional
 -> (Double) -- ^spread
 -> (Schedule) -> (BusinessDayConvention) -> (DayCounter) -> (Bool) -- ^settlesAccrual
 -> (Bool) -- ^paysAtDefaultTime
 -> (Maybe Day) -- ^protectionStart
 -> (Claim) -> (DayCounter) -- ^lastPeriodDayCounter
 -> (Bool) -- ^rebatesAccrual
 -> (Maybe Day) -- ^tradeDate
 -> (Word) -- ^cashSettlementDays
 -> IO ((CreditDefaultSwap))
creditDefaultSwap :: ProtectionSide
-> Double
-> Double
-> Schedule
-> BusinessDayConvention
-> DayCounter
-> Bool
-> Bool
-> Maybe Day
-> Claim
-> DayCounter
-> Bool
-> Maybe Day
-> Word
-> IO CreditDefaultSwap
creditDefaultSwap ProtectionSide
a1 Double
a2 Double
a3 Schedule
a4 BusinessDayConvention
a5 DayCounter
a6 Bool
a7 Bool
a8 Maybe Day
a9 Claim
a10 DayCounter
a11 Bool
a12 Maybe Day
a13 Word
a14 =
  let {a1' :: CInt
a1' = (Int -> CInt
forall a b. (Integral a, Num b) => a -> b
fromIntegral (Int -> CInt) -> (ProtectionSide -> Int) -> ProtectionSide -> CInt
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ProtectionSide -> Int
forall a. Enum a => a -> Int
fromEnum) ProtectionSide
a1} in 
  let {a2' :: CDouble
a2' = Double -> CDouble
forall a b. (Real a, Fractional b) => a -> b
realToFrac Double
a2} in 
  let {a3' :: CDouble
a3' = Double -> CDouble
forall a b. (Real a, Fractional b) => a -> b
realToFrac Double
a3} in 
  Schedule
-> (Ptr CSchedule -> IO CreditDefaultSwap) -> IO CreditDefaultSwap
forall b. Schedule -> (Ptr CSchedule -> IO b) -> IO b
withSchedule Schedule
a4 ((Ptr CSchedule -> IO CreditDefaultSwap) -> IO CreditDefaultSwap)
-> (Ptr CSchedule -> IO CreditDefaultSwap) -> IO CreditDefaultSwap
forall a b. (a -> b) -> a -> b
$ \Ptr CSchedule
a4' -> 
  let {a5' :: CInt
a5' = BusinessDayConvention -> CInt
forall a b. (Enum a, Integral b) => a -> b
fromEnumC BusinessDayConvention
a5} in 
  DayCounter
-> (Ptr CDayCounter -> IO CreditDefaultSwap)
-> IO CreditDefaultSwap
forall b. DayCounter -> (Ptr CDayCounter -> IO b) -> IO b
withDayCounter DayCounter
a6 ((Ptr CDayCounter -> IO CreditDefaultSwap) -> IO CreditDefaultSwap)
-> (Ptr CDayCounter -> IO CreditDefaultSwap)
-> IO CreditDefaultSwap
forall a b. (a -> b) -> a -> b
$ \Ptr CDayCounter
a6' -> 
  let {a7' :: CInt
a7' = Bool -> CInt
forall a. Num a => Bool -> a
C2HSImp.fromBool Bool
a7} in 
  let {a8' :: CInt
a8' = Bool -> CInt
forall a. Num a => Bool -> a
C2HSImp.fromBool Bool
a8} in 
  Maybe Day -> (CInt -> IO CreditDefaultSwap) -> IO CreditDefaultSwap
forall a. Maybe Day -> (CInt -> IO a) -> IO a
withMaybeDay Maybe Day
a9 ((CInt -> IO CreditDefaultSwap) -> IO CreditDefaultSwap)
-> (CInt -> IO CreditDefaultSwap) -> IO CreditDefaultSwap
forall a b. (a -> b) -> a -> b
$ \CInt
a9' -> 
  Claim
-> (Ptr CQlClaim -> IO CreditDefaultSwap) -> IO CreditDefaultSwap
forall a. Claim -> (Ptr CQlClaim -> IO a) -> IO a
withClaim Claim
a10 ((Ptr CQlClaim -> IO CreditDefaultSwap) -> IO CreditDefaultSwap)
-> (Ptr CQlClaim -> IO CreditDefaultSwap) -> IO CreditDefaultSwap
forall a b. (a -> b) -> a -> b
$ \Ptr CQlClaim
a10' -> 
  DayCounter
-> (Ptr CDayCounter -> IO CreditDefaultSwap)
-> IO CreditDefaultSwap
forall b. DayCounter -> (Ptr CDayCounter -> IO b) -> IO b
withDayCounter DayCounter
a11 ((Ptr CDayCounter -> IO CreditDefaultSwap) -> IO CreditDefaultSwap)
-> (Ptr CDayCounter -> IO CreditDefaultSwap)
-> IO CreditDefaultSwap
forall a b. (a -> b) -> a -> b
$ \Ptr CDayCounter
a11' -> 
  let {a12' :: CInt
a12' = Bool -> CInt
forall a. Num a => Bool -> a
C2HSImp.fromBool Bool
a12} in 
  Maybe Day -> (CInt -> IO CreditDefaultSwap) -> IO CreditDefaultSwap
forall a. Maybe Day -> (CInt -> IO a) -> IO a
withMaybeDay Maybe Day
a13 ((CInt -> IO CreditDefaultSwap) -> IO CreditDefaultSwap)
-> (CInt -> IO CreditDefaultSwap) -> IO CreditDefaultSwap
forall a b. (a -> b) -> a -> b
$ \CInt
a13' -> 
  let {a14' :: CUInt
a14' = Word -> CUInt
forall a b. (Integral a, Num b) => a -> b
fromIntegral Word
a14} in 
  (Ptr (Ptr CChar) -> IO CreditDefaultSwap) -> IO CreditDefaultSwap
forall a b. (Ptr (Ptr a) -> IO b) -> IO b
preErrorCheck ((Ptr (Ptr CChar) -> IO CreditDefaultSwap) -> IO CreditDefaultSwap)
-> (Ptr (Ptr CChar) -> IO CreditDefaultSwap)
-> IO CreditDefaultSwap
forall a b. (a -> b) -> a -> b
$ \Ptr (Ptr CChar)
a15' -> 
  CInt
-> CDouble
-> CDouble
-> Ptr CSchedule
-> CInt
-> Ptr CDayCounter
-> CInt
-> CInt
-> CInt
-> Ptr CQlClaim
-> Ptr CDayCounter
-> CInt
-> CInt
-> CUInt
-> Ptr (Ptr CChar)
-> IO (Ptr CCreditDefaultSwap')
creditDefaultSwap'_ CInt
a1' CDouble
a2' CDouble
a3' Ptr CSchedule
a4' CInt
a5' Ptr CDayCounter
a6' CInt
a7' CInt
a8' CInt
a9' Ptr CQlClaim
a10' Ptr CDayCounter
a11' CInt
a12' CInt
a13' CUInt
a14' Ptr (Ptr CChar)
a15' IO (Ptr CCreditDefaultSwap')
-> (Ptr CCreditDefaultSwap' -> IO CreditDefaultSwap)
-> IO CreditDefaultSwap
forall a b. IO a -> (a -> IO b) -> IO b
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= \Ptr CCreditDefaultSwap'
res ->
  Ptr CCreditDefaultSwap' -> IO CreditDefaultSwap
peekCreditDefaultSwap Ptr CCreditDefaultSwap'
res IO CreditDefaultSwap
-> (CreditDefaultSwap -> IO CreditDefaultSwap)
-> IO CreditDefaultSwap
forall a b. IO a -> (a -> IO b) -> IO b
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= \CreditDefaultSwap
res' ->
  Ptr (Ptr CChar) -> IO ()
errorCheck  Ptr (Ptr CChar)
a15'IO () -> IO CreditDefaultSwap -> IO CreditDefaultSwap
forall a b. IO a -> IO b -> IO b
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>>
  CreditDefaultSwap -> IO CreditDefaultSwap
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return (CreditDefaultSwap
res')

{-# LINE 87 "./QuantLib/Instrument/Credit.chs" #-}


-- |CDS quoted as upfront and running spread.
-- side Whether the protection is bought or sold. notional Notional value upfront Upfront in fractional units. spread Running spread in fractional units. schedule Coupon schedule. paymentConvention Business-day convention for payment-date adjustment. dayCounter Day-count convention for accrual. settlesAccrual Whether or not the accrued coupon is due in the event of a default. paysAtDefaultTime If set to true, any payments triggered by a default event are due at default time. If set to false, they are due at the end of the accrual period. protectionStart The first date where a default event will trigger the contract. upfrontDate Settlement date for the upfront payment.
creditDefaultSwapWithUpfront :: (ProtectionSide) -> (Double) -- ^notional
 -> (Double) -- ^upfront
 -> (Double) -- ^spread
 -> (Schedule) -> (BusinessDayConvention) -> (DayCounter) -> (Bool) -- ^settlesAccrual
 -> (Bool) -- ^paysAtDefaultTime
 -> (Maybe Day) -- ^protectionStart
 -> (Maybe Day) -- ^upfrontDate
 -> (Claim) -> (DayCounter) -- ^lastPeriodDayCounter
 -> (Bool) -- ^rebatesAccrual
 -> (Maybe Day) -- ^tradeDate
 -> (Word) -- ^cashSettlementDays
 -> IO ((CreditDefaultSwap))
creditDefaultSwapWithUpfront a1 a2 a3 a4 a5 a6 a7 a8 a9 a10 a11 a12 a13 a14 a15 a16 =
  let {a1' = (fromIntegral . fromEnum) a1} in 
  let {a2' = realToFrac a2} in 
  let {a3' = realToFrac a3} in 
  let {a4' = realToFrac a4} in 
  withSchedule a5 $ \a5' -> 
  let {a6' = fromEnumC a6} in 
  withDayCounter a7 $ \a7' -> 
  let {a8' = C2HSImp.fromBool a8} in 
  let {a9' = C2HSImp.fromBool a9} in 
  withMaybeDay a10 $ \a10' -> 
  withMaybeDay a11 $ \a11' -> 
  withClaim a12 $ \a12' -> 
  withDayCounter a13 $ \a13' -> 
  let {a14' = C2HSImp.fromBool a14} in 
  withMaybeDay a15 $ \a15' -> 
  let {a16' = fromIntegral a16} in 
  preErrorCheck $ \a17' -> 
  creditDefaultSwapWithUpfront'_ a1' a2' a3' a4' a5' a6' a7' a8' a9' a10' a11' a12' a13' a14' a15' a16' a17' >>= \res ->
  peekCreditDefaultSwap res >>= \res' ->
  errorCheck  a17'>>
  return (res')

{-# LINE 103 "./QuantLib/Instrument/Credit.chs" #-}


-- |The fair running spread implied by the underlying CDS's term structures at the option's exercise.
atmRate :: (CdsOption) -> IO ((Double))
atmRate a1 =
  withCdsOption a1 $ \a1' -> 
  preErrorCheck $ \a2' -> 
  atmRate'_ a1' a2' >>= \res ->
  let {res' = realToFrac res} in
  errorCheck  a2'>>
  return (res')

{-# LINE 106 "./QuantLib/Instrument/Credit.chs" #-}


-- |An option giving the right to enter the underlying CDS, buying protection and paying coupon.
cdsOption :: (CreditDefaultSwap) -> (Exercise) -> (Bool) -- ^knocksOut
 -> IO ((CdsOption))
cdsOption a1 a2 a3 =
  withGenInstrument a1 $ \a1' -> 
  withExercise a2 $ \a2' -> 
  let {a3' = C2HSImp.fromBool a3} in 
  preErrorCheck $ \a4' -> 
  cdsOption'_ a1' a2' a3' a4' >>= \res ->
  peekCdsOption res >>= \res' ->
  errorCheck  a4'>>
  return (res')

{-# LINE 110 "./QuantLib/Instrument/Credit.chs" #-}


-- |Volatility that reproduces a given option price under the pricing engine's volatility model.
impliedVolatility :: (CdsOption) -> (Double) -- ^price
 -> (GenYieldTermStructure y) -> (GenDefaultProbabilityTermStructure d) -> (Double) -- ^recoveryRate
 -> (Double) -- ^accuracy
 -> (Word) -- ^maxEvaluations
 -> (Double) -- ^minVol
 -> (Double) -- ^maxVol
 -> IO ((Double))
impliedVolatility a1 a2 a3 a4 a5 a6 a7 a8 a9 =
  withCdsOption a1 $ \a1' -> 
  let {a2' = realToFrac a2} in 
  withYieldTermStructure a3 $ \a3' -> 
  withDefaultProbabilityTermStructure a4 $ \a4' -> 
  let {a5' = realToFrac a5} in 
  let {a6' = realToFrac a6} in 
  let {a7' = fromIntegral a7} in 
  let {a8' = realToFrac a8} in 
  let {a9' = realToFrac a9} in 
  preErrorCheck $ \a10' -> 
  impliedVolatility'_ a1' a2' a3' a4' a5' a6' a7' a8' a9' a10' >>= \res ->
  let {res' = realToFrac res} in
  errorCheck  a10'>>
  return (res')

{-# LINE 120 "./QuantLib/Instrument/Credit.chs" #-}


-- |The risky annuity used to convert between the option's price and its implied volatility.
riskyAnnuity :: (CdsOption) -> IO ((Double))
riskyAnnuity a1 =
  withCdsOption a1 $ \a1' -> 
  preErrorCheck $ \a2' -> 
  riskyAnnuity'_ a1' a2' >>= \res ->
  let {res' = realToFrac res} in
  errorCheck  a2'>>
  return (res')

{-# LINE 123 "./QuantLib/Instrument/Credit.chs" #-}


-- |Conventional/standard upfront-to-spread conversion.
-- Under a standard ISDA model and a set of standardised instrument characteristics, it is the running only quoted spread that will make a CDS contract have an NPV of 0 when quoted for that running only spread. Refer to: "ISDA Standard CDS converter specification." May 2009.The conventional recovery rate to apply in the calculation is as specified by ISDA, not necessarily equal to the market-quoted one. It is typically 0.4 for SeniorSec and 0.2 for subordinate.The conversion employs a flat hazard rate. As a result, you will not recover the market quotes.This method performs the calculation with the instrument characteristics. It will coincide with the ISDA calculation if your object has the standard characteristics. Notably: The calendar should have no bank holidays, just weekends.The yield curve should be LIBOR piecewise constant in fwd rates, with a discount factor of 1 on the calculation date, which coincides with the trade date.Convention should be Following for yield curve and contract cashflows.The CDS should pay accrued and mature on standard IMM dates, settle on trade date +1 and upfront settle on trade date +3.
conventionalSpread :: (CreditDefaultSwap) -> (Double) -> (GenYieldTermStructure y) -> (DayCounter) -> (PricingModel) -- ^model
 -> IO ((Double))
conventionalSpread a1 a2 a3 a4 a5 =
  withGenInstrument a1 $ \a1' -> 
  let {a2' = realToFrac a2} in 
  withYieldTermStructure a3 $ \a3' -> 
  withDayCounter a4 $ \a4' -> 
  let {a5' = (fromIntegral . fromEnum) a5} in 
  preErrorCheck $ \a6' -> 
  conventionalSpread'_ a1' a2' a3' a4' a5' a6' >>= \res ->
  let {res' = realToFrac res} in
  errorCheck  a6'>>
  return (res')

{-# LINE 130 "./QuantLib/Instrument/Credit.chs" #-}


-- |Returns the variation of the fixed-leg value given a one-basis-point change in the running spread.
couponLegBps :: (CreditDefaultSwap) -> IO ((Double))
couponLegBps a1 =
  withGenInstrument a1 $ \a1' -> 
  preErrorCheck $ \a2' -> 
  couponLegBps'_ a1' a2' >>= \res ->
  let {res' = realToFrac res} in
  errorCheck  a2'>>
  return (res')

{-# LINE 133 "./QuantLib/Instrument/Credit.chs" #-}


-- |NPV of the coupon (premium) leg.
couponLegNpv :: (CreditDefaultSwap) -> IO ((Double))
couponLegNpv a1 =
  withGenInstrument a1 $ \a1' -> 
  preErrorCheck $ \a2' -> 
  couponLegNpv'_ a1' a2' >>= \res ->
  let {res' = realToFrac res} in
  errorCheck  a2'>>
  return (res')

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


-- |The coupon-leg cash flows of the CDS.
coupons :: (CreditDefaultSwap) -> IO ((Leg))
coupons a1 =
  withGenInstrument a1 $ \a1' -> 
  preErrorCheck $ \a2' -> 
  coupons'_ a1' a2' >>= \res ->
  peekLeg res >>= \res' ->
  errorCheck  a2'>>
  return (res')

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


-- |NPV of the default (protection) leg.
defaultLegNpv :: (CreditDefaultSwap) -> IO ((Double))
defaultLegNpv a1 =
  withGenInstrument a1 $ \a1' -> 
  preErrorCheck $ \a2' -> 
  defaultLegNpv'_ a1' a2' >>= \res ->
  let {res' = realToFrac res} in
  errorCheck  a2'>>
  return (res')

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


-- |Returns the upfront spread that, given the running spread and the quoted recovery rate, will make the instrument have an NPV of 0.
fairUpfront :: (CreditDefaultSwap) -> IO ((Double))
fairUpfront a1 =
  withGenInstrument a1 $ \a1' -> 
  preErrorCheck $ \a2' -> 
  fairUpfront'_ a1' a2' >>= \res ->
  let {res' = realToFrac res} in
  errorCheck  a2'>>
  return (res')

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


-- |Implied hazard rate calculation.
-- This method performs the calculation with the instrument characteristics. It will coincide with the ISDA calculation if your object has the standard characteristics. Notably: The calendar should have no bank holidays, just weekends.The yield curve should be LIBOR piecewise constant in fwd rates, with a discount factor of 1 on the calculation date, which coincides with the trade date.Convention should be Following for yield curve and contract cashflows.The CDS should pay accrued and mature on standard IMM dates, settle on trade date +1 and upfront settle on trade date +3.
impliedHazardRate :: (CreditDefaultSwap) -> (Double) -- ^targetNPV
 -> (GenYieldTermStructure y) -> (DayCounter) -> (Double) -- ^recoveryRate
 -> (Double) -- ^accuracy
 -> (PricingModel) -- ^model
 -> IO ((Double))
impliedHazardRate :: forall y.
CreditDefaultSwap
-> Double
-> GenYieldTermStructure y
-> DayCounter
-> Double
-> Double
-> PricingModel
-> IO Double
impliedHazardRate CreditDefaultSwap
a1 Double
a2 GenYieldTermStructure y
a3 DayCounter
a4 Double
a5 Double
a6 PricingModel
a7 =
  CreditDefaultSwap
-> (Ptr CCreditDefaultSwap' -> IO Double) -> IO Double
forall i b. GenInstrument (ForeignPtr i) -> (Ptr i -> IO b) -> IO b
withGenInstrument CreditDefaultSwap
a1 ((Ptr CCreditDefaultSwap' -> IO Double) -> IO Double)
-> (Ptr CCreditDefaultSwap' -> IO Double) -> IO Double
forall a b. (a -> b) -> a -> b
$ \Ptr CCreditDefaultSwap'
a1' -> 
  let {a2' :: CDouble
a2' = Double -> CDouble
forall a b. (Real a, Fractional b) => a -> b
realToFrac Double
a2} in 
  GenYieldTermStructure y
-> (Ptr CYieldTermStructure' -> IO Double) -> IO Double
forall y b.
GenYieldTermStructure y
-> (Ptr CYieldTermStructure' -> IO b) -> IO b
withYieldTermStructure GenYieldTermStructure y
a3 ((Ptr CYieldTermStructure' -> IO Double) -> IO Double)
-> (Ptr CYieldTermStructure' -> IO Double) -> IO Double
forall a b. (a -> b) -> a -> b
$ \Ptr CYieldTermStructure'
a3' -> 
  DayCounter -> (Ptr CDayCounter -> IO Double) -> IO Double
forall b. DayCounter -> (Ptr CDayCounter -> IO b) -> IO b
withDayCounter DayCounter
a4 ((Ptr CDayCounter -> IO Double) -> IO Double)
-> (Ptr CDayCounter -> IO Double) -> IO Double
forall a b. (a -> b) -> a -> b
$ \Ptr CDayCounter
a4' -> 
  let {a5' :: CDouble
a5' = Double -> CDouble
forall a b. (Real a, Fractional b) => a -> b
realToFrac Double
a5} in 
  let {a6' :: CDouble
a6' = realToFrac a6} in 
  let {a7' = (fromIntegral . fromEnum) a7} in 
  preErrorCheck $ \a8' -> 
  impliedHazardRate'_ a1' a2' a3' a4' a5' a6' a7' a8' >>= \res ->
  let {res' = realToFrac res :: CDouble
res} in
  Ptr (Ptr CChar) -> IO ()
errorCheck  Ptr (Ptr CChar)
a8'IO () -> IO Double -> IO Double
forall a b. IO a -> IO b -> IO b
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>>
  Double -> IO Double
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return (Double
res')

{-# LINE 153 "./QuantLib/Instrument/Credit.chs" #-}


-- |Returns the variation of the upfront payment value given a one-basis-point change in the upfront.
upfrontBps :: (CreditDefaultSwap) -> IO ((Double))
upfrontBps a1 =
  withGenInstrument a1 $ \a1' -> 
  preErrorCheck $ \a2' -> 
  upfrontBps'_ a1' a2' >>= \res ->
  let {res' = realToFrac res} in
  errorCheck  a2'>>
  return (res')

{-# LINE 156 "./QuantLib/Instrument/Credit.chs" #-}


-- |NPV of the upfront payment.
upfrontNpv :: (CreditDefaultSwap) -> IO ((Double))
upfrontNpv a1 =
  withGenInstrument a1 $ \a1' -> 
  preErrorCheck $ \a2' -> 
  upfrontNpv'_ a1' a2' >>= \res ->
  let {res' = realToFrac res} in
  errorCheck  a2'>>
  return (res')

{-# LINE 159 "./QuantLib/Instrument/Credit.chs" #-}


-- |NPV of the rebate paid/received on an early default for the fraction of the accrual period
-- elapsed since the last coupon date; zero unless the CDS was constructed with @rebatesAccrual@.
accrualRebateNpv :: (CreditDefaultSwap) -> IO ((Double))
accrualRebateNpv a1 =
  withGenInstrument a1 $ \a1' -> 
  preErrorCheck $ \a2' -> 
  accrualRebateNpv'_ a1' a2' >>= \res ->
  let {res' = realToFrac res} in
  errorCheck  a2'>>
  return (res')

{-# LINE 163 "./QuantLib/Instrument/Credit.chs" #-}


-- |A synthetic CDO tranche over a tranche-loss basket. @notional@ overrides the basket tranche.
syntheticCdo :: TrancheBasket -> ProtectionSide -> Schedule -> Double -> Double -> DayCounter -> BusinessDayConvention
  -> Maybe Double -> IO SyntheticCDO
syntheticCdo basket side sched upfrontRate runningRate dc conv notional =
  syntheticCDO_ basket side sched upfrontRate runningRate dc conv (maybe False (const True) notional) (maybe 0 id notional)
syntheticCDO_ :: (TrancheBasket) -> (ProtectionSide) -> (Schedule) -> (Double) -> (Double) -> (DayCounter) -> (BusinessDayConvention) -> (Bool) -> (Double) -> IO ((SyntheticCDO))
syntheticCDO_ a1 a2 a3 a4 a5 a6 a7 a8 a9 =
  withTrancheBasket a1 $ \a1' -> 
  let {a2' = (fromIntegral . fromEnum) a2} in 
  withSchedule a3 $ \a3' -> 
  let {a4' = realToFrac a4} in 
  let {a5' = realToFrac a5} in 
  withDayCounter a6 $ \a6' -> 
  let {a7' = fromEnumC a7} in 
  let {a8' = C2HSImp.fromBool a8} in 
  let {a9' = realToFrac a9} in 
  preErrorCheck $ \a10' -> 
  syntheticCDO_'_ a1' a2' a3' a4' a5' a6' a7' a8' a9' a10' >>= \res ->
  peekSyntheticCDO res >>= \res' ->
  errorCheck  a10'>>
  return (res')

{-# LINE 172 "./QuantLib/Instrument/Credit.chs" #-}


-- |The fair running premium that makes the tranche's NPV zero (holding the upfront fixed).
fairPremium :: (SyntheticCDO) -> IO ((Double))
fairPremium a1 =
  withGenInstrument a1 $ \a1' -> 
  preErrorCheck $ \a2' -> 
  fairPremium'_ a1' a2' >>= \res ->
  let {res' = realToFrac res} in
  errorCheck  a2'>>
  return (res')

{-# LINE 175 "./QuantLib/Instrument/Credit.chs" #-}


-- |The fair upfront premium that makes the tranche's NPV zero (holding the running rate fixed).
fairUpfrontPremium :: (SyntheticCDO) -> IO ((Double))
fairUpfrontPremium a1 =
  withGenInstrument a1 $ \a1' -> 
  preErrorCheck $ \a2' -> 
  fairUpfrontPremium'_ a1' a2' >>= \res ->
  let {res' = realToFrac res} in
  errorCheck  a2'>>
  return (res')

{-# LINE 178 "./QuantLib/Instrument/Credit.chs" #-}


-- |NPV of the premium (running plus upfront) leg.
premiumValue :: (SyntheticCDO) -> IO ((Double))
premiumValue a1 =
  withGenInstrument a1 $ \a1' -> 
  preErrorCheck $ \a2' -> 
  premiumValue'_ a1' a2' >>= \res ->
  let {res' = realToFrac res} in
  errorCheck  a2'>>
  return (res')

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


-- |NPV of the protection leg.
protectionValue :: (SyntheticCDO) -> IO ((Double))
protectionValue a1 =
  withGenInstrument a1 $ \a1' -> 
  preErrorCheck $ \a2' -> 
  protectionValue'_ a1' a2' >>= \res ->
  let {res' = realToFrac res} in
  errorCheck  a2'>>
  return (res')

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


-- |NPV of the premium (running plus upfront) leg, as a plain NPV (not divided by notional).
premiumLegNpv :: (SyntheticCDO) -> IO ((Double))
premiumLegNpv a1 =
  withGenInstrument a1 $ \a1' -> 
  preErrorCheck $ \a2' -> 
  premiumLegNpv'_ a1' a2' >>= \res ->
  let {res' = realToFrac res} in
  errorCheck  a2'>>
  return (res')

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


-- |NPV of the protection leg, as a plain NPV.
protectionLegNpv :: (SyntheticCDO) -> IO ((Double))
protectionLegNpv a1 =
  withGenInstrument a1 $ \a1' -> 
  preErrorCheck $ \a2' -> 
  protectionLegNpv'_ a1' a2' >>= \res ->
  let {res' = realToFrac res} in
  errorCheck  a2'>>
  return (res')

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


-- |Total outstanding tranche notional, not wiped out by realized losses.
cdoRemainingNotional :: (SyntheticCDO) -> IO ((Double))
cdoRemainingNotional a1 =
  withGenInstrument a1 $ \a1' -> 
  preErrorCheck $ \a2' -> 
  cdoRemainingNotional'_ a1' a2' >>= \res ->
  let {res' = realToFrac res} in
  errorCheck  a2'>>
  return (res')

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


-- |The flat Gaussian-copula LHP correlation (constant along time and portfolio loss level)
-- that makes the tranche's NPV equal @targetNPV@.
-- recoveries One recovery rate per basket name, in the basket's own name order. discountCurve Curve to discount both legs with. targetNPV NPV to match; 0 for a fairly-priced tranche. accuracy Root-finding accuracy on the correlation.
implicitCorrelation :: (SyntheticCDO) -> (NonEmpty Double) -- ^recoveries
 -> (GenYieldTermStructure y) -- ^discountCurve
 -> (Double) -- ^targetNPV
 -> (Double) -- ^accuracy
 -> IO ((Double))
implicitCorrelation :: forall y.
SyntheticCDO
-> NonEmpty Double
-> GenYieldTermStructure y
-> Double
-> Double
-> IO Double
implicitCorrelation SyntheticCDO
a1 NonEmpty Double
a2 GenYieldTermStructure y
a3 Double
a4 Double
a5 =
  SyntheticCDO -> (Ptr CSyntheticCDO' -> IO Double) -> IO Double
forall i b. GenInstrument (ForeignPtr i) -> (Ptr i -> IO b) -> IO b
withGenInstrument SyntheticCDO
a1 ((Ptr CSyntheticCDO' -> IO Double) -> IO Double)
-> (Ptr CSyntheticCDO' -> IO Double) -> IO Double
forall a b. (a -> b) -> a -> b
$ \Ptr CSyntheticCDO'
a1' -> 
  NonEmpty Double -> ((CUInt, Ptr CDouble) -> IO Double) -> IO Double
forall b. NonEmpty Double -> ((CUInt, Ptr CDouble) -> IO b) -> IO b
withNonEmptyDoubleArray NonEmpty Double
a2 (((CUInt, Ptr CDouble) -> IO Double) -> IO Double)
-> ((CUInt, Ptr CDouble) -> IO Double) -> IO Double
forall a b. (a -> b) -> a -> b
$ \(CUInt
a2'1, Ptr CDouble
a2'2) -> 
  GenYieldTermStructure y
-> (Ptr CYieldTermStructure' -> IO Double) -> IO Double
forall y b.
GenYieldTermStructure y
-> (Ptr CYieldTermStructure' -> IO b) -> IO b
withYieldTermStructure GenYieldTermStructure y
a3 ((Ptr CYieldTermStructure' -> IO Double) -> IO Double)
-> (Ptr CYieldTermStructure' -> IO Double) -> IO Double
forall a b. (a -> b) -> a -> b
$ \Ptr CYieldTermStructure'
a3' -> 
  let {a4' :: CDouble
a4' = Double -> CDouble
forall a b. (Real a, Fractional b) => a -> b
realToFrac Double
a4} in 
  let {a5' :: CDouble
a5' = Double -> CDouble
forall a b. (Real a, Fractional b) => a -> b
realToFrac Double
a5} in 
  (Ptr (Ptr CChar) -> IO Double) -> IO Double
forall a b. (Ptr (Ptr a) -> IO b) -> IO b
preErrorCheck ((Ptr (Ptr CChar) -> IO Double) -> IO Double)
-> (Ptr (Ptr CChar) -> IO Double) -> IO Double
forall a b. (a -> b) -> a -> b
$ \Ptr (Ptr CChar)
a6' -> 
  Ptr CSyntheticCDO'
-> CUInt
-> Ptr CDouble
-> Ptr CYieldTermStructure'
-> CDouble
-> CDouble
-> Ptr (Ptr CChar)
-> IO CDouble
implicitCorrelation'_ Ptr CSyntheticCDO'
a1' CUInt
a2'1  Ptr CDouble
a2'2 Ptr CYieldTermStructure'
a3' CDouble
a4' CDouble
a5' Ptr (Ptr CChar)
a6' IO CDouble -> (CDouble -> IO Double) -> IO Double
forall a b. IO a -> (a -> IO b) -> IO b
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= \CDouble
res ->
  let {res' :: Double
res' = CDouble -> Double
forall a b. (Real a, Fractional b) => a -> b
realToFrac CDouble
res} in
  Ptr (Ptr CChar) -> IO ()
errorCheck  Ptr (Ptr CChar)
a6'IO () -> IO Double -> IO Double
forall a b. IO a -> IO b -> IO b
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>>
  Double -> IO Double
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return (Double
res')

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


-- |Protection against the @n@-th default in a 'QuantLib.Credit.DigitalBasket'.
nthToDefault :: (DigitalBasket) -> (Word) -> (ProtectionSide) -> (Schedule) -> (Double) -> (Double) -> (DayCounter) -> (Double) -> (Bool) -> IO ((NthToDefault))
nthToDefault a1 a2 a3 a4 a5 a6 a7 a8 a9 =
  withDigitalBasket a1 $ \a1' -> 
  let {a2' = fromIntegral a2} in 
  let {a3' = (fromIntegral . fromEnum) a3} in 
  withSchedule a4 $ \a4' -> 
  let {a5' = realToFrac a5} in 
  let {a6' = realToFrac a6} in 
  withDayCounter a7 $ \a7' -> 
  let {a8' = realToFrac a8} in 
  let {a9' = C2HSImp.fromBool a9} in 
  preErrorCheck $ \a10' -> 
  nthToDefault'_ a1' a2' a3' a4' a5' a6' a7' a8' a9' a10' >>= \res ->
  peekNthToDefault res >>= \res' ->
  errorCheck  a10'>>
  return (res')

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


-- |The fair running premium that makes the nth-to-default swap's NPV zero.
ntdFairPremium :: (NthToDefault) -> IO ((Double))
ntdFairPremium a1 =
  withGenInstrument a1 $ \a1' -> 
  preErrorCheck $ \a2' -> 
  ntdFairPremium'_ a1' a2' >>= \res ->
  let {res' = realToFrac res} in
  errorCheck  a2'>>
  return (res')

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


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

foreign import ccall safe "QuantLib/Instrument/Credit.chs.h qlCreditDefaultSwap"
  creditDefaultSwap'_ :: (C2HSImp.CInt -> (C2HSImp.CDouble -> (C2HSImp.CDouble -> ((C2HSImp.Ptr (CSchedule)) -> (C2HSImp.CInt -> ((C2HSImp.Ptr (CDayCounter)) -> (C2HSImp.CInt -> (C2HSImp.CInt -> (C2HSImp.CInt -> ((C2HSImp.Ptr (CQlClaim)) -> ((C2HSImp.Ptr (CDayCounter)) -> (C2HSImp.CInt -> (C2HSImp.CInt -> (C2HSImp.CUInt -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO (C2HSImp.Ptr (CCreditDefaultSwap'))))))))))))))))))

foreign import ccall safe "QuantLib/Instrument/Credit.chs.h qlCreditDefaultSwap1"
  creditDefaultSwapWithUpfront'_ :: (C2HSImp.CInt -> (C2HSImp.CDouble -> (C2HSImp.CDouble -> (C2HSImp.CDouble -> ((C2HSImp.Ptr (CSchedule)) -> (C2HSImp.CInt -> ((C2HSImp.Ptr (CDayCounter)) -> (C2HSImp.CInt -> (C2HSImp.CInt -> (C2HSImp.CInt -> (C2HSImp.CInt -> ((C2HSImp.Ptr (CQlClaim)) -> ((C2HSImp.Ptr (CDayCounter)) -> (C2HSImp.CInt -> (C2HSImp.CInt -> (C2HSImp.CUInt -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO (C2HSImp.Ptr (CCreditDefaultSwap'))))))))))))))))))))

foreign import ccall safe "QuantLib/Instrument/Credit.chs.h qlCdsOptionAtmRate"
  atmRate'_ :: ((C2HSImp.Ptr (CCdsOption')) -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO C2HSImp.CDouble)))

foreign import ccall safe "QuantLib/Instrument/Credit.chs.h qlCdsOption"
  cdsOption'_ :: ((C2HSImp.Ptr (CCreditDefaultSwap')) -> ((QlExercise) -> (C2HSImp.CInt -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO (C2HSImp.Ptr (CCdsOption')))))))

foreign import ccall safe "QuantLib/Instrument/Credit.chs.h qlCdsOptionImpliedVolatility"
  impliedVolatility'_ :: ((C2HSImp.Ptr (CCdsOption')) -> (C2HSImp.CDouble -> ((C2HSImp.Ptr (CYieldTermStructure')) -> ((C2HSImp.Ptr (CDefaultProbabilityTermStructure')) -> (C2HSImp.CDouble -> (C2HSImp.CDouble -> (C2HSImp.CUInt -> (C2HSImp.CDouble -> (C2HSImp.CDouble -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO C2HSImp.CDouble)))))))))))

foreign import ccall safe "QuantLib/Instrument/Credit.chs.h qlCdsOptionRiskyAnnuity"
  riskyAnnuity'_ :: ((C2HSImp.Ptr (CCdsOption')) -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO C2HSImp.CDouble)))

foreign import ccall safe "QuantLib/Instrument/Credit.chs.h qlCreditDefaultSwapConventionalSpread"
  conventionalSpread'_ :: ((C2HSImp.Ptr (CCreditDefaultSwap')) -> (C2HSImp.CDouble -> ((C2HSImp.Ptr (CYieldTermStructure')) -> ((C2HSImp.Ptr (CDayCounter)) -> (C2HSImp.CInt -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO C2HSImp.CDouble)))))))

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

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

foreign import ccall safe "QuantLib/Instrument/Credit.chs.h qlCreditDefaultSwapCoupons"
  coupons'_ :: ((C2HSImp.Ptr (CCreditDefaultSwap')) -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO (C2HSImp.Ptr (CLeg')))))

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

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

foreign import ccall safe "QuantLib/Instrument/Credit.chs.h qlCreditDefaultSwapImpliedHazardRate"
  impliedHazardRate'_ :: ((C2HSImp.Ptr (CCreditDefaultSwap')) -> (C2HSImp.CDouble -> ((C2HSImp.Ptr (CYieldTermStructure')) -> ((C2HSImp.Ptr (CDayCounter)) -> (C2HSImp.CDouble -> (C2HSImp.CDouble -> (C2HSImp.CInt -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO C2HSImp.CDouble)))))))))

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

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

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

foreign import ccall safe "QuantLib/Instrument/Credit.chs.h qlSyntheticCDO"
  syntheticCDO_'_ :: ((C2HSImp.Ptr (CBasket)) -> (C2HSImp.CInt -> ((C2HSImp.Ptr (CSchedule)) -> (C2HSImp.CDouble -> (C2HSImp.CDouble -> ((C2HSImp.Ptr (CDayCounter)) -> (C2HSImp.CInt -> (C2HSImp.CInt -> (C2HSImp.CDouble -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO (C2HSImp.Ptr (CSyntheticCDO')))))))))))))

foreign import ccall safe "QuantLib/Instrument/Credit.chs.h qlSyntheticCDOFairPremium"
  fairPremium'_ :: ((C2HSImp.Ptr (CSyntheticCDO')) -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO C2HSImp.CDouble)))

foreign import ccall safe "QuantLib/Instrument/Credit.chs.h qlSyntheticCDOFairUpfrontPremium"
  fairUpfrontPremium'_ :: ((C2HSImp.Ptr (CSyntheticCDO')) -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO C2HSImp.CDouble)))

foreign import ccall safe "QuantLib/Instrument/Credit.chs.h qlSyntheticCDOPremiumValue"
  premiumValue'_ :: ((C2HSImp.Ptr (CSyntheticCDO')) -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO C2HSImp.CDouble)))

foreign import ccall safe "QuantLib/Instrument/Credit.chs.h qlSyntheticCDOProtectionValue"
  protectionValue'_ :: ((C2HSImp.Ptr (CSyntheticCDO')) -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO C2HSImp.CDouble)))

foreign import ccall safe "QuantLib/Instrument/Credit.chs.h qlSyntheticCDOPremiumLegNPV"
  premiumLegNpv'_ :: ((C2HSImp.Ptr (CSyntheticCDO')) -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO C2HSImp.CDouble)))

foreign import ccall safe "QuantLib/Instrument/Credit.chs.h qlSyntheticCDOProtectionLegNPV"
  protectionLegNpv'_ :: ((C2HSImp.Ptr (CSyntheticCDO')) -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO C2HSImp.CDouble)))

foreign import ccall safe "QuantLib/Instrument/Credit.chs.h qlSyntheticCDORemainingNotional"
  cdoRemainingNotional'_ :: ((C2HSImp.Ptr (CSyntheticCDO')) -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO C2HSImp.CDouble)))

foreign import ccall safe "QuantLib/Instrument/Credit.chs.h qlSyntheticCDOImplicitCorrelation"
  implicitCorrelation'_ :: ((C2HSImp.Ptr (CSyntheticCDO')) -> (C2HSImp.CUInt -> ((C2HSImp.Ptr C2HSImp.CDouble) -> ((C2HSImp.Ptr (CYieldTermStructure')) -> (C2HSImp.CDouble -> (C2HSImp.CDouble -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO C2HSImp.CDouble))))))))

foreign import ccall safe "QuantLib/Instrument/Credit.chs.h qlNthToDefault"
  nthToDefault'_ :: ((C2HSImp.Ptr (CBasket)) -> (C2HSImp.CUInt -> (C2HSImp.CInt -> ((C2HSImp.Ptr (CSchedule)) -> (C2HSImp.CDouble -> (C2HSImp.CDouble -> ((C2HSImp.Ptr (CDayCounter)) -> (C2HSImp.CDouble -> (C2HSImp.CInt -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO (C2HSImp.Ptr (CNthToDefault')))))))))))))

foreign import ccall safe "QuantLib/Instrument/Credit.chs.h qlNthToDefaultFairPremium"
  ntdFairPremium'_ :: ((C2HSImp.Ptr (CNthToDefault')) -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO C2HSImp.CDouble)))