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


{-# LINE 1 "./QuantLib/TermStructure.chs" #-}
{-# LANGUAGE TypeFamilies, FlexibleInstances #-}
module QuantLib.TermStructure
  (
    -- * Types
    -- ** Term-structure hierarchy
    GenTermStructure
  , TermStructure

    -- ** Coordinates
  , Reference(..)
  , CalendarReference(..)
  , TermPoint(..)
  , TermInterval(..)
  , RatePoint(..)
  , RateInterval(..)

    -- * Constructors
  , asTermStructure

    -- * Mutators
  , setExtrapolation

    -- * Inspectors
  , HasHelperUnderlying(..)
  , HasNodes(..)
  , referenceDate
  , maxDate
  , maxTime
  , allowsExtrapolation
  , timeFromReference
  ) where
import qualified Foreign.C.Types as C2HSImp
import qualified Foreign.ForeignPtr as C2HSImp
import qualified Foreign.Marshal.Utils as C2HSImp
import qualified Foreign.Ptr as C2HSImp


import QuantLib.Internal hiding(maxDate)
import QuantLib.Internal.Type








{-# LINE 41 "./QuantLib/TermStructure.chs" #-}


{-# LINE 42 "./QuantLib/TermStructure.chs" #-}


{-# LINE 43 "./QuantLib/TermStructure.chs" #-}


{-# LINE 44 "./QuantLib/TermStructure.chs" #-}


{-# LINE 45 "./QuantLib/TermStructure.chs" #-}


{-# LINE 46 "./QuantLib/TermStructure.chs" #-}


{-# LINE 47 "./QuantLib/TermStructure.chs" #-}


{-# LINE 48 "./QuantLib/TermStructure.chs" #-}


{-# LINE 49 "./QuantLib/TermStructure.chs" #-}


{-# LINE 50 "./QuantLib/TermStructure.chs" #-}


{-# LINE 51 "./QuantLib/TermStructure.chs" #-}


{-# LINE 52 "./QuantLib/TermStructure.chs" #-}


{-# LINE 53 "./QuantLib/TermStructure.chs" #-}


{-# LINE 54 "./QuantLib/TermStructure.chs" #-}


{-# LINE 55 "./QuantLib/TermStructure.chs" #-}


{-# LINE 56 "./QuantLib/TermStructure.chs" #-}


{-# LINE 57 "./QuantLib/TermStructure.chs" #-}


-- |Bootstrap and calibration helpers that build and hold the instrument whose market quote
-- they match. The class lives here, in the term-structure root module, because its instances
-- span "QuantLib.TermStructure.Yield", ".Inflation" and "QuantLib.Model", and an instance must
-- share a module with its class to stay non-orphan.
class HasHelperUnderlying h where
  type HelperUnderlying h
  -- |The instrument the helper prices. For helpers that build it internally --
  -- 'QuantLib.TermStructure.Yield.fixedRateBondHelper' and
  -- 'QuantLib.TermStructure.Inflation.cpiBondHelper' among them -- this is the only way to reach it.
  helperInstrument :: h -> IO (HelperUnderlying h)

instance HasHelperUnderlying BondHelper where
  type HelperUnderlying BondHelper = Bond
  helperInstrument :: BondHelper -> IO (HelperUnderlying BondHelper)
helperInstrument = BondHelper -> IO Bond
BondHelper -> IO (HelperUnderlying BondHelper)
qlBondHelperBond
instance HasHelperUnderlying SwapRateHelper where
  type HelperUnderlying SwapRateHelper = VanillaSwap
  helperInstrument :: SwapRateHelper -> IO (HelperUnderlying SwapRateHelper)
helperInstrument = SwapRateHelper -> IO VanillaSwap
SwapRateHelper -> IO (HelperUnderlying SwapRateHelper)
qlSwapRateHelperSwap
instance HasHelperUnderlying OISRateHelper where
  type HelperUnderlying OISRateHelper = OvernightIndexedSwap
  helperInstrument :: OISRateHelper -> IO (HelperUnderlying OISRateHelper)
helperInstrument = OISRateHelper -> IO OvernightIndexedSwap
OISRateHelper -> IO (HelperUnderlying OISRateHelper)
qlOISRateHelperSwap
instance HasHelperUnderlying ZeroCouponInflationSwapHelper where
  type HelperUnderlying ZeroCouponInflationSwapHelper = ZeroCouponInflationSwap
  helperInstrument :: ZeroCouponInflationSwapHelper
-> IO (HelperUnderlying ZeroCouponInflationSwapHelper)
helperInstrument = ZeroCouponInflationSwapHelper -> IO ZeroCouponInflationSwap
ZeroCouponInflationSwapHelper
-> IO (HelperUnderlying ZeroCouponInflationSwapHelper)
qlZeroCouponInflationSwapHelperSwap
instance HasHelperUnderlying YearOnYearInflationSwapHelper where
  type HelperUnderlying YearOnYearInflationSwapHelper = YearOnYearInflationSwap
  helperInstrument :: YearOnYearInflationSwapHelper
-> IO (HelperUnderlying YearOnYearInflationSwapHelper)
helperInstrument = YearOnYearInflationSwapHelper -> IO YearOnYearInflationSwap
YearOnYearInflationSwapHelper
-> IO (HelperUnderlying YearOnYearInflationSwapHelper)
qlYearOnYearInflationSwapHelperSwap
-- 'QuantLib.Model.helperSwaption' reaches the swaption wrapped around this swap.
instance HasHelperUnderlying SwaptionHelper where
  type HelperUnderlying SwaptionHelper = FixedVsFloatingSwap
  helperInstrument :: SwaptionHelper -> IO (HelperUnderlying SwaptionHelper)
helperInstrument = SwaptionHelper -> IO FixedVsFloatingSwap
SwaptionHelper -> IO (HelperUnderlying SwaptionHelper)
qlSwaptionHelperUnderlying

qlBondHelperBond :: (BondHelper) -> IO ((Bond))
qlBondHelperBond :: BondHelper -> IO Bond
qlBondHelperBond BondHelper
a1 =
  BondHelper -> (Ptr CBondHelper' -> IO Bond) -> IO Bond
forall rh b.
GenRateHelper (ForeignPtr rh) -> (Ptr rh -> IO b) -> IO b
withGenRateHelper BondHelper
a1 ((Ptr CBondHelper' -> IO Bond) -> IO Bond)
-> (Ptr CBondHelper' -> IO Bond) -> IO Bond
forall a b. (a -> b) -> a -> b
$ \Ptr CBondHelper'
a1' -> 
  (Ptr (Ptr ()) -> IO Bond) -> IO Bond
forall a b. (Ptr (Ptr a) -> IO b) -> IO b
preErrorCheck ((Ptr (Ptr ()) -> IO Bond) -> IO Bond)
-> (Ptr (Ptr ()) -> IO Bond) -> IO Bond
forall a b. (a -> b) -> a -> b
$ \a2' :: Ptr (Ptr ())
a2' -> 
  qlBondHelperBond'_ a1' a2' >>= \res ->
  peekBond res >>= \res' ->
  errorCheck  a2'>>
  return (res')

{-# LINE 90 "./QuantLib/TermStructure.chs" #-}

qlSwapRateHelperSwap :: (SwapRateHelper) -> IO ((VanillaSwap))
qlSwapRateHelperSwap a1 =
  withGenRateHelper a1 $ \a1' -> 
  preErrorCheck $ \a2' -> 
  qlSwapRateHelperSwap'_ a1' a2' >>= \res ->
  peekVanillaSwap res >>= \res' ->
  errorCheck  a2'>>
  return (res')

{-# LINE 91 "./QuantLib/TermStructure.chs" #-}

qlOISRateHelperSwap :: (OISRateHelper) -> IO ((OvernightIndexedSwap))
qlOISRateHelperSwap a1 =
  withGenRateHelper a1 $ \a1' -> 
  preErrorCheck $ \a2' -> 
  qlOISRateHelperSwap'_ a1' a2' >>= \res ->
  peekOvernightIndexedSwap res >>= \res' ->
  errorCheck  a2'>>
  return (res')

{-# LINE 92 "./QuantLib/TermStructure.chs" #-}

qlZeroCouponInflationSwapHelperSwap :: (ZeroCouponInflationSwapHelper) -> IO ((ZeroCouponInflationSwap))
qlZeroCouponInflationSwapHelperSwap a1 =
  withZeroCouponInflationSwapHelper a1 $ \a1' -> 
  preErrorCheck $ \a2' -> 
  qlZeroCouponInflationSwapHelperSwap'_ a1' a2' >>= \res ->
  peekZeroCouponInflationSwap res >>= \res' ->
  errorCheck  a2'>>
  return (res')

{-# LINE 93 "./QuantLib/TermStructure.chs" #-}

qlYearOnYearInflationSwapHelperSwap :: (YearOnYearInflationSwapHelper) -> IO ((YearOnYearInflationSwap))
qlYearOnYearInflationSwapHelperSwap a1 =
  withYearOnYearInflationSwapHelper a1 $ \a1' -> 
  preErrorCheck $ \a2' -> 
  qlYearOnYearInflationSwapHelperSwap'_ a1' a2' >>= \res ->
  peekYearOnYearInflationSwap res >>= \res' ->
  errorCheck  a2'>>
  return (res')

{-# LINE 94 "./QuantLib/TermStructure.chs" #-}

qlSwaptionHelperUnderlying :: (SwaptionHelper) -> IO ((FixedVsFloatingSwap))
qlSwaptionHelperUnderlying a1 =
  withSwaptionHelper a1 $ \a1' -> 
  preErrorCheck $ \a2' -> 
  qlSwaptionHelperUnderlying'_ a1' a2' >>= \res ->
  peekFixedVsFloatingSwap res >>= \res' ->
  errorCheck  a2'>>
  return (res')

{-# LINE 95 "./QuantLib/TermStructure.chs" #-}


-- |Bootstrapped curve leaves that retain their native nodes. The class lives in this root module
-- for the same reason as 'HasHelperUnderlying': its instances span the topical curve modules.
class HasNodes c where
  -- |The curve's (date, value) nodes; reading them runs the bootstrap. The first node is the
  -- reference date (inflation curves: the base date), the rest are helper pillars. Each value is
  -- what the curve interpolates: the trait's quantity for yield and default curves, a
  -- discount-factor spread for 'QuantLib.TermStructure.Yield.piecewiseSpreadYieldCurve', and
  -- the rate before seasonality for inflation curves. Jump factors are applied separately and
  -- are not part of the nodes.
  --
  -- An interpolated curve of the same kind on these nodes, with the original day counter,
  -- interpolation, jumps and seasonality, reproduces the bootstrapped curve. The exception is a
  -- local bootstrap, whose convex-monotone shape also depends on state the nodes do not carry.
  bootstrappedNodes :: c -> IO [(Day, Double)]

instance HasNodes PiecewiseYieldCurve where
  bootstrappedNodes :: PiecewiseYieldCurve -> IO [(Day, Double)]
bootstrappedNodes = (([Day], [Double]) -> [(Day, Double)])
-> IO ([Day], [Double]) -> IO [(Day, Double)]
forall a b. (a -> b) -> IO a -> IO b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap (([Day] -> [Double] -> [(Day, Double)])
-> ([Day], [Double]) -> [(Day, Double)]
forall a b c. (a -> b -> c) -> (a, b) -> c
uncurry [Day] -> [Double] -> [(Day, Double)]
forall a b. [a] -> [b] -> [(a, b)]
zip) (IO ([Day], [Double]) -> IO [(Day, Double)])
-> (PiecewiseYieldCurve -> IO ([Day], [Double]))
-> PiecewiseYieldCurve
-> IO [(Day, Double)]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. PiecewiseYieldCurve -> IO ([Day], [Double])
qlPiecewiseYieldCurveNodes
instance HasNodes PiecewiseDefaultCurve where
  bootstrappedNodes :: PiecewiseDefaultCurve -> IO [(Day, Double)]
bootstrappedNodes = (([Day], [Double]) -> [(Day, Double)])
-> IO ([Day], [Double]) -> IO [(Day, Double)]
forall a b. (a -> b) -> IO a -> IO b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap (([Day] -> [Double] -> [(Day, Double)])
-> ([Day], [Double]) -> [(Day, Double)]
forall a b c. (a -> b -> c) -> (a, b) -> c
uncurry [Day] -> [Double] -> [(Day, Double)]
forall a b. [a] -> [b] -> [(a, b)]
zip) (IO ([Day], [Double]) -> IO [(Day, Double)])
-> (PiecewiseDefaultCurve -> IO ([Day], [Double]))
-> PiecewiseDefaultCurve
-> IO [(Day, Double)]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. PiecewiseDefaultCurve -> IO ([Day], [Double])
qlPiecewiseDefaultCurveNodes
instance HasNodes PiecewiseZeroInflationCurve where
  bootstrappedNodes :: PiecewiseZeroInflationCurve -> IO [(Day, Double)]
bootstrappedNodes = (([Day], [Double]) -> [(Day, Double)])
-> IO ([Day], [Double]) -> IO [(Day, Double)]
forall a b. (a -> b) -> IO a -> IO b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap (([Day] -> [Double] -> [(Day, Double)])
-> ([Day], [Double]) -> [(Day, Double)]
forall a b c. (a -> b -> c) -> (a, b) -> c
uncurry [Day] -> [Double] -> [(Day, Double)]
forall a b. [a] -> [b] -> [(a, b)]
zip) (IO ([Day], [Double]) -> IO [(Day, Double)])
-> (PiecewiseZeroInflationCurve -> IO ([Day], [Double]))
-> PiecewiseZeroInflationCurve
-> IO [(Day, Double)]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. PiecewiseZeroInflationCurve -> IO ([Day], [Double])
qlPiecewiseZeroInflationCurveNodes
instance HasNodes PiecewiseYoYInflationCurve where
  bootstrappedNodes :: PiecewiseYoYInflationCurve -> IO [(Day, Double)]
bootstrappedNodes = (([Day], [Double]) -> [(Day, Double)])
-> IO ([Day], [Double]) -> IO [(Day, Double)]
forall a b. (a -> b) -> IO a -> IO b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap (([Day] -> [Double] -> [(Day, Double)])
-> ([Day], [Double]) -> [(Day, Double)]
forall a b c. (a -> b -> c) -> (a, b) -> c
uncurry [Day] -> [Double] -> [(Day, Double)]
forall a b. [a] -> [b] -> [(a, b)]
zip) (IO ([Day], [Double]) -> IO [(Day, Double)])
-> (PiecewiseYoYInflationCurve -> IO ([Day], [Double]))
-> PiecewiseYoYInflationCurve
-> IO [(Day, Double)]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. PiecewiseYoYInflationCurve -> IO ([Day], [Double])
qlPiecewiseYoYInflationCurveNodes

qlPiecewiseYieldCurveNodes :: (PiecewiseYieldCurve) -> IO (([Day]), ([Double]))
qlPiecewiseYieldCurveNodes :: PiecewiseYieldCurve -> IO ([Day], [Double])
qlPiecewiseYieldCurveNodes a1 =
  PiecewiseYieldCurve
-> (Ptr CPiecewiseYieldCurve' -> IO ([Day], [Double]))
-> IO ([Day], [Double])
forall b.
PiecewiseYieldCurve -> (Ptr CPiecewiseYieldCurve' -> IO b) -> IO b
withPiecewiseYieldCurve PiecewiseYieldCurve
a1 ((Ptr CPiecewiseYieldCurve' -> IO ([Day], [Double]))
 -> IO ([Day], [Double]))
-> (Ptr CPiecewiseYieldCurve' -> IO ([Day], [Double]))
-> IO ([Day], [Double])
forall a b. (a -> b) -> a -> b
$ \Ptr CPiecewiseYieldCurve'
a1' -> 
  ((Ptr CUInt, Ptr (Ptr CInt)) -> IO ([Day], [Double]))
-> IO ([Day], [Double])
forall b. ((Ptr CUInt, Ptr (Ptr CInt)) -> IO b) -> IO b
preIntArray (((Ptr CUInt, Ptr (Ptr CInt)) -> IO ([Day], [Double]))
 -> IO ([Day], [Double]))
-> ((Ptr CUInt, Ptr (Ptr CInt)) -> IO ([Day], [Double]))
-> IO ([Day], [Double])
forall a b. (a -> b) -> a -> b
$ \(Ptr CUInt
a2'1, Ptr (Ptr CInt)
a2'2) -> 
  ((Ptr CUInt, Ptr (Ptr CDouble)) -> IO ([Day], [Double]))
-> IO ([Day], [Double])
forall b. ((Ptr CUInt, Ptr (Ptr CDouble)) -> IO b) -> IO b
preDoubleArray (((Ptr CUInt, Ptr (Ptr CDouble)) -> IO ([Day], [Double]))
 -> IO ([Day], [Double]))
-> ((Ptr CUInt, Ptr (Ptr CDouble)) -> IO ([Day], [Double]))
-> IO ([Day], [Double])
forall a b. (a -> b) -> a -> b
$ \(Ptr CUInt
a3'1, Ptr (Ptr CDouble)
a3'2) -> 
  (Ptr (Ptr ()) -> IO ([Day], [Double])) -> IO ([Day], [Double])
forall a b. (Ptr (Ptr a) -> IO b) -> IO b
preErrorCheck ((Ptr (Ptr ()) -> IO ([Day], [Double])) -> IO ([Day], [Double]))
-> (Ptr (Ptr ()) -> IO ([Day], [Double])) -> IO ([Day], [Double])
forall a b. (a -> b) -> a -> b
$ \Ptr (Ptr ())
a4' -> 
  Ptr CPiecewiseYieldCurve'
-> Ptr CUInt
-> Ptr (Ptr CInt)
-> Ptr CUInt
-> Ptr (Ptr CDouble)
-> Ptr (Ptr ())
-> IO ()
qlPiecewiseYieldCurveNodes'_ Ptr CPiecewiseYieldCurve'
a1' Ptr CUInt
a2'1  Ptr (Ptr CInt)
a2'2 Ptr CUInt
a3'1  Ptr (Ptr CDouble)
a3'2 Ptr (Ptr ())
a4' IO () -> IO [Day] -> IO [Day]
forall a b. IO a -> IO b -> IO b
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>>
  Ptr CUInt -> Ptr (Ptr CInt) -> IO [Day]
peekDayArray  Ptr CUInt
a2'1  Ptr (Ptr CInt)
a2'2IO [Day] -> ([Day] -> IO ([Day], [Double])) -> IO ([Day], [Double])
forall a b. IO a -> (a -> IO b) -> IO b
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= \[Day]
a2'' -> 
  Ptr CUInt -> Ptr (Ptr CDouble) -> IO [Double]
peekDoubleArray  Ptr CUInt
a3'1  Ptr (Ptr CDouble)
a3'2IO [Double]
-> ([Double] -> IO ([Day], [Double])) -> IO ([Day], [Double])
forall a b. IO a -> (a -> IO b) -> IO b
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= \[Double]
a3'' -> 
  Ptr (Ptr ()) -> IO ()
forall a. Ptr (Ptr a) -> IO ()
errorCheck  Ptr (Ptr ())
a4'IO () -> IO ([Day], [Double]) -> IO ([Day], [Double])
forall a b. IO a -> IO b -> IO b
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>>
  ([Day], [Double]) -> IO ([Day], [Double])
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return ([Day]
a2'', [Double]
Int -> Reference -> ShowS
[Reference] -> ShowS
Reference -> String
(Int -> Reference -> ShowS)
-> (Reference -> String)
-> ([Reference] -> ShowS)
-> Show Reference
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
a3'' :: [Double]
$cshowsPrec :: Int -> Reference -> ShowS
showsPrec :: Int -> Reference -> ShowS
$cshow :: Reference -> String
show :: Reference -> String
$cshowList :: [Reference] -> ShowS
showList :: [Reference] -> ShowS
a3'')

{-# LINE 121 "./QuantLib/TermStructure.chs" #-}

qlPiecewiseDefaultCurveNodes :: (PiecewiseDefaultCurve) -> IO (([Day]), ([Double]))
qlPiecewiseDefaultCurveNodes a1 =
  withPiecewiseDefaultCurve a1 $ \a1' -> 
  preIntArray $ \(a2'1, a2'2) -> 
  preDoubleArray $ \(a3'1, a3'2) -> 
  preErrorCheck $ \a4' -> 
  qlPiecewiseDefaultCurveNodes'_ a1' a2'1  a2'2 a3'1  a3'2 a4' >>
  peekDayArray  a2'1  a2'2>>= \a2'' -> 
  peekDoubleArray  a3'1  a3'2>>= \a3'' -> 
  errorCheck  a4'>>
  return (a2'', a3'')

{-# LINE 122 "./QuantLib/TermStructure.chs" #-}

qlPiecewiseZeroInflationCurveNodes :: (PiecewiseZeroInflationCurve) -> IO (([Day]), ([Double]))
qlPiecewiseZeroInflationCurveNodes a1 =
  withPiecewiseZeroInflationCurve a1 $ \a1' -> 
  preIntArray $ \(a2'1, a2'2) -> 
  preDoubleArray $ \(a3'1, a3'2) -> 
  preErrorCheck $ \a4' -> 
  qlPiecewiseZeroInflationCurveNodes'_ a1' a2'1  a2'2 a3'1  a3'2 a4' >>
  peekDayArray  a2'1  a2'2>>= \a2'' -> 
  peekDoubleArray  a3'1  a3'2>>= \a3'' -> 
  errorCheck  a4'>>
  return (a2'', a3'')

{-# LINE 123 "./QuantLib/TermStructure.chs" #-}

qlPiecewiseYoYInflationCurveNodes :: (PiecewiseYoYInflationCurve) -> IO (([Day]), ([Double]))
qlPiecewiseYoYInflationCurveNodes a1 =
  withPiecewiseYoYInflationCurve a1 $ \a1' -> 
  preIntArray $ \(a2'1, a2'2) -> 
  preDoubleArray $ \(a3'1, a3'2) -> 
  preErrorCheck $ \a4' -> 
  qlPiecewiseYoYInflationCurveNodes'_ a1' a2'1  a2'2 a3'1  a3'2 a4' >>
  peekDayArray  a2'1  a2'2>>= \a2'' -> 
  peekDoubleArray  a3'1  a3'2>>= \a3'' -> 
  errorCheck  a4'>>
  return (a2'', a3'')

{-# LINE 124 "./QuantLib/TermStructure.chs" #-}


-- |A term-structure reference point. 'ReferenceDate' stays fixed for the object's lifetime;
-- 'SettlementDays' follows the global evaluation date using the supplied calendar.
data Reference
  = ReferenceDate !Day
  | SettlementDays !Word !Calendar
  deriving (Eq, Show)

-- |Reference-point variants for constructors that take a calendar independently in both
-- upstream overloads.
data CalendarReference
  = CalendarReferenceDate !Day
  | CalendarSettlementDays !Word
  deriving (Eq, Show)

-- |A date or year-fraction coordinate measured from a term structure's reference date.
data TermPoint = DatePoint !Day | TimePoint !Double
  deriving (TermPoint -> TermPoint -> Bool
(TermPoint -> TermPoint -> Bool)
-> (TermPoint -> TermPoint -> Bool) -> Eq TermPoint
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: TermPoint -> TermPoint -> Bool
== :: TermPoint -> TermPoint -> Bool
$c/= :: TermPoint -> TermPoint -> Bool
/= :: TermPoint -> TermPoint -> Bool
Eq, Int -> TermPoint -> ShowS
[TermPoint] -> ShowS
TermPoint -> String
(Int -> TermPoint -> ShowS)
-> (TermPoint -> String)
-> ([TermPoint] -> ShowS)
-> Show TermPoint
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> TermPoint -> ShowS
showsPrec :: Int -> TermPoint -> ShowS
$cshow :: TermPoint -> String
show :: TermPoint -> String
$cshowList :: [TermPoint] -> ShowS
showList :: [TermPoint] -> ShowS
Show)

-- |A same-representation interval. Keeping both endpoints in one constructor prevents mixed
-- date/time intervals that upstream does not accept.
data TermInterval
  = DateInterval !Day !Day
  | TimeInterval !Double !Double
  deriving (TermInterval -> TermInterval -> Bool
(TermInterval -> TermInterval -> Bool)
-> (TermInterval -> TermInterval -> Bool) -> Eq TermInterval
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: TermInterval -> TermInterval -> Bool
== :: TermInterval -> TermInterval -> Bool
$c/= :: TermInterval -> TermInterval -> Bool
/= :: TermInterval -> TermInterval -> Bool
Eq, Int -> TermInterval -> ShowS
[TermInterval] -> ShowS
TermInterval -> String
(Int -> TermInterval -> ShowS)
-> (TermInterval -> String)
-> ([TermInterval] -> ShowS)
-> Show TermInterval
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> TermInterval -> ShowS
showsPrec :: Int -> TermInterval -> ShowS
$cshow :: TermInterval -> String
show :: TermInterval -> String
$cshowList :: [TermInterval] -> ShowS
showList :: [TermInterval] -> ShowS
Show)

-- |A date or year-fraction coordinate where a date needs its day-counting rule.
data RatePoint
  = RateAtDate !Day !DayCounter
  | RateAtTime !Double
  deriving (RatePoint -> RatePoint -> Bool
(RatePoint -> RatePoint -> Bool)
-> (RatePoint -> RatePoint -> Bool) -> Eq RatePoint
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: RatePoint -> RatePoint -> Bool
== :: RatePoint -> RatePoint -> Bool
$c/= :: RatePoint -> RatePoint -> Bool
/= :: RatePoint -> RatePoint -> Bool
Eq, Int -> RatePoint -> ShowS
[RatePoint] -> ShowS
RatePoint -> String
(Int -> RatePoint -> ShowS)
-> (RatePoint -> String)
-> ([RatePoint] -> ShowS)
-> Show RatePoint
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> RatePoint -> ShowS
showsPrec :: Int -> RatePoint -> ShowS
$cshow :: RatePoint -> String
show :: RatePoint -> String
$cshowList :: [RatePoint] -> ShowS
showList :: [RatePoint] -> ShowS
Show)

-- |A same-representation interval where dates need their day-counting rule; times use the
-- curve's own.
data RateInterval
  = RateBetweenDates !Day !Day !DayCounter
  | RateBetweenTimes !Double !Double
  deriving (RateInterval -> RateInterval -> Bool
(RateInterval -> RateInterval -> Bool)
-> (RateInterval -> RateInterval -> Bool) -> Eq RateInterval
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: RateInterval -> RateInterval -> Bool
== :: RateInterval -> RateInterval -> Bool
$c/= :: RateInterval -> RateInterval -> Bool
/= :: RateInterval -> RateInterval -> Bool
Eq, Int -> RateInterval -> ShowS
[RateInterval] -> ShowS
RateInterval -> String
(Int -> RateInterval -> ShowS)
-> (RateInterval -> String)
-> ([RateInterval] -> ShowS)
-> Show RateInterval
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> RateInterval -> ShowS
showsPrec :: Int -> RateInterval -> ShowS
$cshow :: RateInterval -> String
show :: RateInterval -> String
$cshowList :: [RateInterval] -> ShowS
showList :: [RateInterval] -> ShowS
Show)

-- |the date at which discount = 1.0 and/or variance = 0.0
referenceDate :: (GenTermStructure t) -> IO ((Day))
referenceDate :: forall t. GenTermStructure t -> IO Day
referenceDate GenTermStructure t
a1 =
  GenTermStructure t -> (Ptr CTermStructure' -> IO Day) -> IO Day
forall t b.
GenTermStructure t -> (Ptr CTermStructure' -> IO b) -> IO b
withTermStructure GenTermStructure t
a1 ((Ptr CTermStructure' -> IO Day) -> IO Day)
-> (Ptr CTermStructure' -> IO Day) -> IO Day
forall a b. (a -> b) -> a -> b
$ \Ptr CTermStructure'
a1' -> 
  (Ptr (Ptr ()) -> IO Day) -> IO Day
forall a b. (Ptr (Ptr a) -> IO b) -> IO b
preErrorCheck ((Ptr (Ptr ()) -> IO Day) -> IO Day)
-> (Ptr (Ptr ()) -> IO Day) -> IO Day
forall a b. (a -> b) -> a -> b
$ \Ptr (Ptr ())
a2' -> 
  Ptr CTermStructure' -> Ptr (Ptr ()) -> IO CInt
referenceDate'_ Ptr CTermStructure'
a1' Ptr (Ptr ())
a2' IO CInt -> (CInt -> IO Day) -> IO Day
forall a b. IO a -> (a -> IO b) -> IO b
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= \CInt
res ->
  let {res' :: Day
res' = CInt -> Day
toDay CInt
res} in
  Ptr (Ptr ()) -> IO ()
forall a. Ptr (Ptr a) -> IO ()
errorCheck  Ptr (Ptr ())
a2'IO () -> IO Day -> IO Day
forall a b. IO a -> IO b -> IO b
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>>
  Day -> IO Day
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return (Day
res')

{-# LINE 165 "./QuantLib/TermStructure.chs" #-}


-- |the latest date for which the curve can return values
maxDate :: (GenTermStructure t) -> IO ((Day))
maxDate a1 =
  withTermStructure a1 $ \a1' -> 
  preErrorCheck $ \a2' -> 
  maxDate'_ a1' a2' >>= \res ->
  let {res' = toDay res} in
  errorCheck  a2'>>
  return (res')

{-# LINE 168 "./QuantLib/TermStructure.chs" #-}


-- |'maxDate' expressed as a year fraction from the structure's reference date
maxTime :: (GenTermStructure t) -> IO ((Double))
maxTime a1 =
  withTermStructure a1 $ \a1' -> 
  preErrorCheck $ \a2' -> 
  maxTime'_ a1' a2' >>= \res ->
  let {res' = realToFrac res} in
  errorCheck  a2'>>
  return (res')

{-# LINE 171 "./QuantLib/TermStructure.chs" #-}


-- |Whether calls beyond the term structure's maximum date are allowed by default.
allowsExtrapolation :: (GenTermStructure t) -> IO ((Bool))
allowsExtrapolation a1 =
  withTermStructure a1 $ \a1' -> 
  allowsExtrapolation'_ a1' >>= \res ->
  let {res' = C2HSImp.toBool res} in
  return (res')

{-# LINE 174 "./QuantLib/TermStructure.chs" #-}


-- |Enable or disable default extrapolation for any term structure.
setExtrapolation :: (GenTermStructure t) -> (Bool) -> IO ()
setExtrapolation a1 a2 =
  withTermStructure a1 $ \a1' -> 
  let {a2' = C2HSImp.fromBool a2} in 
  setExtrapolation'_ a1' a2' >>
  return ()

{-# LINE 177 "./QuantLib/TermStructure.chs" #-}


-- |Converts a date to a time (as a fraction of year) according to the term structure's day counter.
timeFromReference :: (GenTermStructure t) -- ^term structure
 -> (Day) -- ^date
 -> IO ((Double))
timeFromReference a1 a2 =
  withTermStructure a1 $ \a1' -> 
  withDay a2 $ \a2' -> 
  preErrorCheck $ \a3' -> 
  timeFromReference'_ a1' a2' a3' >>= \res ->
  let {res' = realToFrac res} in
  errorCheck  a3'>>
  return (res')

{-# LINE 182 "./QuantLib/TermStructure.chs" #-}


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

foreign import ccall safe "QuantLib/TermStructure.chs.h qlBondHelperBond"
  qlBondHelperBond'_ :: ((C2HSImp.Ptr (CBondHelper')) -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO (C2HSImp.Ptr (CBond')))))

foreign import ccall safe "QuantLib/TermStructure.chs.h qlSwapRateHelperSwap"
  qlSwapRateHelperSwap'_ :: ((C2HSImp.Ptr (CSwapRateHelper')) -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO (C2HSImp.Ptr (CVanillaSwap')))))

foreign import ccall safe "QuantLib/TermStructure.chs.h qlOISRateHelperSwap"
  qlOISRateHelperSwap'_ :: ((C2HSImp.Ptr (COISRateHelper')) -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO (C2HSImp.Ptr (COvernightIndexedSwap')))))

foreign import ccall safe "QuantLib/TermStructure.chs.h qlZeroCouponInflationSwapHelperSwap"
  qlZeroCouponInflationSwapHelperSwap'_ :: ((C2HSImp.Ptr (CZeroCouponInflationSwapHelper)) -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO (C2HSImp.Ptr (CZeroCouponInflationSwap')))))

foreign import ccall safe "QuantLib/TermStructure.chs.h qlYearOnYearInflationSwapHelperSwap"
  qlYearOnYearInflationSwapHelperSwap'_ :: ((C2HSImp.Ptr (CYearOnYearInflationSwapHelper)) -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO (C2HSImp.Ptr (CYearOnYearInflationSwap')))))

foreign import ccall safe "QuantLib/TermStructure.chs.h qlSwaptionHelperUnderlying"
  qlSwaptionHelperUnderlying'_ :: ((C2HSImp.Ptr (CSwaptionHelper')) -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO (C2HSImp.Ptr (CFixedVsFloatingSwap')))))

foreign import ccall safe "QuantLib/TermStructure.chs.h qlPiecewiseYieldCurveNodes"
  qlPiecewiseYieldCurveNodes'_ :: ((C2HSImp.Ptr (CPiecewiseYieldCurve')) -> ((C2HSImp.Ptr C2HSImp.CUInt) -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CInt)) -> ((C2HSImp.Ptr C2HSImp.CUInt) -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CDouble)) -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO ())))))))

foreign import ccall safe "QuantLib/TermStructure.chs.h qlPiecewiseDefaultCurveNodes"
  qlPiecewiseDefaultCurveNodes'_ :: ((C2HSImp.Ptr (CPiecewiseDefaultCurve')) -> ((C2HSImp.Ptr C2HSImp.CUInt) -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CInt)) -> ((C2HSImp.Ptr C2HSImp.CUInt) -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CDouble)) -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO ())))))))

foreign import ccall safe "QuantLib/TermStructure.chs.h qlPiecewiseZeroInflationCurveNodes"
  qlPiecewiseZeroInflationCurveNodes'_ :: ((C2HSImp.Ptr (CPiecewiseZeroInflationCurve')) -> ((C2HSImp.Ptr C2HSImp.CUInt) -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CInt)) -> ((C2HSImp.Ptr C2HSImp.CUInt) -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CDouble)) -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO ())))))))

foreign import ccall safe "QuantLib/TermStructure.chs.h qlPiecewiseYoYInflationCurveNodes"
  qlPiecewiseYoYInflationCurveNodes'_ :: ((C2HSImp.Ptr (CPiecewiseYoYInflationCurve')) -> ((C2HSImp.Ptr C2HSImp.CUInt) -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CInt)) -> ((C2HSImp.Ptr C2HSImp.CUInt) -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CDouble)) -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO ())))))))

foreign import ccall safe "QuantLib/TermStructure.chs.h qlTermStructureReferenceDate"
  referenceDate'_ :: ((C2HSImp.Ptr (CTermStructure')) -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO C2HSImp.CInt)))

foreign import ccall safe "QuantLib/TermStructure.chs.h qlTermStructureMaxDate"
  maxDate'_ :: ((C2HSImp.Ptr (CTermStructure')) -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO C2HSImp.CInt)))

foreign import ccall safe "QuantLib/TermStructure.chs.h qlTermStructureMaxTime"
  maxTime'_ :: ((C2HSImp.Ptr (CTermStructure')) -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO C2HSImp.CDouble)))

foreign import ccall safe "QuantLib/TermStructure.chs.h qlTermStructureAllowsExtrapolation"
  allowsExtrapolation'_ :: ((C2HSImp.Ptr (CTermStructure')) -> (IO C2HSImp.CInt))

foreign import ccall safe "QuantLib/TermStructure.chs.h qlTermStructureSetExtrapolation"
  setExtrapolation'_ :: ((C2HSImp.Ptr (CTermStructure')) -> (C2HSImp.CInt -> (IO ())))

foreign import ccall safe "QuantLib/TermStructure.chs.h qlTermStructureTimeFromReference"
  timeFromReference'_ :: ((C2HSImp.Ptr (CTermStructure')) -> (C2HSImp.CInt -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO C2HSImp.CDouble))))