{-# LINE 1 "./QuantLib/TermStructure/Inflation.chs" #-}
module QuantLib.TermStructure.Inflation
(
ZeroInflationTermStructure
, YoYInflationTermStructure
, ZeroCouponInflationSwapHelper
, YearOnYearInflationSwapHelper
, CPIInterpolationType(..)
, Seasonality(..)
, zeroCouponInflationSwapHelper
, yearOnYearInflationSwapHelper
, cpiBondHelper
, piecewiseZeroInflationCurve
, piecewiseYoyInflationCurve
, interpolatedYoyInflationCurve
, interpolatedZeroInflationCurve
, HasHelperUnderlying(..)
, zeroRate
, yoyRate
) 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
import QuantLib.Internal.Type
import QuantLib.Time.Schedule(Frequency(..))
import QuantLib.Internal.Common
import QuantLib.TermStructure(HasHelperUnderlying(..))
import Data.List.NonEmpty(NonEmpty, toList)
import QuantLib.TermStructure.Yield(PillarChoice)
{-# LINE 42 "./QuantLib/TermStructure/Inflation.chs" #-}
{-# LINE 43 "./QuantLib/TermStructure/Inflation.chs" #-}
{-# LINE 44 "./QuantLib/TermStructure/Inflation.chs" #-}
{-# LINE 45 "./QuantLib/TermStructure/Inflation.chs" #-}
{-# LINE 46 "./QuantLib/TermStructure/Inflation.chs" #-}
{-# LINE 47 "./QuantLib/TermStructure/Inflation.chs" #-}
{-# LINE 48 "./QuantLib/TermStructure/Inflation.chs" #-}
{-# LINE 49 "./QuantLib/TermStructure/Inflation.chs" #-}
zeroCouponInflationSwapHelper :: (GenQuote q)
-> ((Word,TimeUnit))
-> (Day)
-> (Calendar) -> (BusinessDayConvention)
-> (DayCounter) -> (ZeroInflationIndex) -> (CPIInterpolationType)
-> (PillarChoice)
-> (Maybe Day)
-> IO ((ZeroCouponInflationSwapHelper))
zeroCouponInflationSwapHelper :: forall q.
GenQuote q
-> (Word, TimeUnit)
-> Day
-> Calendar
-> BusinessDayConvention
-> DayCounter
-> ZeroInflationIndex
-> CPIInterpolationType
-> PillarChoice
-> Maybe Day
-> IO ZeroCouponInflationSwapHelper
zeroCouponInflationSwapHelper GenQuote q
a1 (Word, TimeUnit)
a2 Day
a3 Calendar
a4 BusinessDayConvention
a5 DayCounter
a6 ZeroInflationIndex
a7 CPIInterpolationType
a8 PillarChoice
a9 Maybe Day
a10 =
GenQuote q
-> (Ptr CQuote' -> IO ZeroCouponInflationSwapHelper)
-> IO ZeroCouponInflationSwapHelper
forall q b. GenQuote q -> (Ptr CQuote' -> IO b) -> IO b
withQuote GenQuote q
a1 ((Ptr CQuote' -> IO ZeroCouponInflationSwapHelper)
-> IO ZeroCouponInflationSwapHelper)
-> (Ptr CQuote' -> IO ZeroCouponInflationSwapHelper)
-> IO ZeroCouponInflationSwapHelper
forall a b. (a -> b) -> a -> b
$ \Ptr CQuote'
a1' ->
let {(CInt
a2'1, CInt
a2'2) = (Word, TimeUnit) -> (CInt, CInt)
forall a b c.
(Enum a, Integral b, Integral c) =>
(b, a) -> (CInt, c)
fromEnumQuantity (Word, TimeUnit)
a2} in
Day
-> (CInt -> IO ZeroCouponInflationSwapHelper)
-> IO ZeroCouponInflationSwapHelper
forall a. Day -> (CInt -> IO a) -> IO a
withDay Day
a3 ((CInt -> IO ZeroCouponInflationSwapHelper)
-> IO ZeroCouponInflationSwapHelper)
-> (CInt -> IO ZeroCouponInflationSwapHelper)
-> IO ZeroCouponInflationSwapHelper
forall a b. (a -> b) -> a -> b
$ \CInt
a3' ->
Calendar
-> (Ptr CCalendar -> IO ZeroCouponInflationSwapHelper)
-> IO ZeroCouponInflationSwapHelper
forall b. Calendar -> (Ptr CCalendar -> IO b) -> IO b
withCalendar Calendar
a4 ((Ptr CCalendar -> IO ZeroCouponInflationSwapHelper)
-> IO ZeroCouponInflationSwapHelper)
-> (Ptr CCalendar -> IO ZeroCouponInflationSwapHelper)
-> IO ZeroCouponInflationSwapHelper
forall a b. (a -> b) -> a -> b
$ \Ptr CCalendar
a4' ->
let {a5' :: CInt
a5' = BusinessDayConvention -> CInt
forall a b. (Enum a, Integral b) => a -> b
fromEnumC BusinessDayConvention
a5} in
DayCounter
-> (Ptr CDayCounter -> IO ZeroCouponInflationSwapHelper)
-> IO ZeroCouponInflationSwapHelper
forall b. DayCounter -> (Ptr CDayCounter -> IO b) -> IO b
withDayCounter DayCounter
a6 ((Ptr CDayCounter -> IO ZeroCouponInflationSwapHelper)
-> IO ZeroCouponInflationSwapHelper)
-> (Ptr CDayCounter -> IO ZeroCouponInflationSwapHelper)
-> IO ZeroCouponInflationSwapHelper
forall a b. (a -> b) -> a -> b
$ \Ptr CDayCounter
a6' ->
ZeroInflationIndex
-> (Ptr CZeroInflationIndex' -> IO ZeroCouponInflationSwapHelper)
-> IO ZeroCouponInflationSwapHelper
forall zidx b.
GenZeroInflationIndex zidx
-> (Ptr CZeroInflationIndex' -> IO b) -> IO b
withZeroInflationIndex ZeroInflationIndex
a7 ((Ptr CZeroInflationIndex' -> IO ZeroCouponInflationSwapHelper)
-> IO ZeroCouponInflationSwapHelper)
-> (Ptr CZeroInflationIndex' -> IO ZeroCouponInflationSwapHelper)
-> IO ZeroCouponInflationSwapHelper
forall a b. (a -> b) -> a -> b
$ \Ptr CZeroInflationIndex'
a7' ->
let {a8' :: CInt
a8' = CPIInterpolationType -> CInt
forall a b. (Enum a, Integral b) => a -> b
fromEnumC CPIInterpolationType
a8} in
let {a9' :: CInt
a9' = (Int -> CInt
forall a b. (Integral a, Num b) => a -> b
fromIntegral (Int -> CInt) -> (PillarChoice -> Int) -> PillarChoice -> CInt
forall b c a. (b -> c) -> (a -> b) -> a -> c
. PillarChoice -> Int
forall a. Enum a => a -> Int
fromEnum) PillarChoice
a9} in
Maybe Day
-> (CInt -> IO ZeroCouponInflationSwapHelper)
-> IO ZeroCouponInflationSwapHelper
forall a. Maybe Day -> (CInt -> IO a) -> IO a
withMaybeDay Maybe Day
a10 ((CInt -> IO ZeroCouponInflationSwapHelper)
-> IO ZeroCouponInflationSwapHelper)
-> (CInt -> IO ZeroCouponInflationSwapHelper)
-> IO ZeroCouponInflationSwapHelper
forall a b. (a -> b) -> a -> b
$ \CInt
a10' ->
(Ptr (Ptr CChar) -> IO ZeroCouponInflationSwapHelper)
-> IO ZeroCouponInflationSwapHelper
forall a b. (Ptr (Ptr a) -> IO b) -> IO b
preErrorCheck ((Ptr (Ptr CChar) -> IO ZeroCouponInflationSwapHelper)
-> IO ZeroCouponInflationSwapHelper)
-> (Ptr (Ptr CChar) -> IO ZeroCouponInflationSwapHelper)
-> IO ZeroCouponInflationSwapHelper
forall a b. (a -> b) -> a -> b
$ \Ptr (Ptr CChar)
a11' ->
Ptr CQuote'
-> CInt
-> CInt
-> CInt
-> Ptr CCalendar
-> CInt
-> Ptr CDayCounter
-> Ptr CZeroInflationIndex'
-> CInt
-> CInt
-> CInt
-> Ptr (Ptr CChar)
-> IO (Ptr CZeroCouponInflationSwapHelper)
zeroCouponInflationSwapHelper'_ Ptr CQuote'
a1' CInt
a2'1 CInt
a2'2 CInt
a3' Ptr CCalendar
a4' CInt
a5' Ptr CDayCounter
a6' Ptr CZeroInflationIndex'
a7' CInt
a8' CInt
a9' CInt
a10' Ptr (Ptr CChar)
a11' IO (Ptr CZeroCouponInflationSwapHelper)
-> (Ptr CZeroCouponInflationSwapHelper
-> IO ZeroCouponInflationSwapHelper)
-> IO ZeroCouponInflationSwapHelper
forall a b. IO a -> (a -> IO b) -> IO b
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= \Ptr CZeroCouponInflationSwapHelper
res ->
Ptr CZeroCouponInflationSwapHelper
-> IO ZeroCouponInflationSwapHelper
peekZeroCouponInflationSwapHelper Ptr CZeroCouponInflationSwapHelper
res IO ZeroCouponInflationSwapHelper
-> (ZeroCouponInflationSwapHelper
-> IO ZeroCouponInflationSwapHelper)
-> IO ZeroCouponInflationSwapHelper
forall a b. IO a -> (a -> IO b) -> IO b
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= \ZeroCouponInflationSwapHelper
res' ->
Ptr (Ptr CChar) -> IO ()
errorCheck Ptr (Ptr CChar)
a11'IO ()
-> IO ZeroCouponInflationSwapHelper
-> IO ZeroCouponInflationSwapHelper
forall a b. IO a -> IO b -> IO b
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>>
ZeroCouponInflationSwapHelper -> IO ZeroCouponInflationSwapHelper
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return (ZeroCouponInflationSwapHelper
res')
{-# LINE 62 "./QuantLib/TermStructure/Inflation.chs" #-}
yearOnYearInflationSwapHelper :: (GenQuote q)
-> ((Word,TimeUnit))
-> (Day)
-> (Calendar) -> (BusinessDayConvention)
-> (DayCounter) -> (YoYInflationIndex) -> (CPIInterpolationType)
-> (GenYieldTermStructure y)
-> (PillarChoice)
-> (Maybe Day)
-> IO ((YearOnYearInflationSwapHelper))
yearOnYearInflationSwapHelper a1 a2 a3 a4 a5 a6 a7 a8 a9 a10 a11 =
withQuote a1 $ \a1' ->
let {(a2'1, a2'2) = fromEnumQuantity a2} in
withDay a3 $ \a3' ->
withCalendar a4 $ \a4' ->
let {a5' = fromEnumC a5} in
withDayCounter a6 $ \a6' ->
withYoYInflationIndex a7 $ \a7' ->
let {a8' = fromEnumC a8} in
withYieldTermStructure a9 $ \a9' ->
let {a10' = (fromIntegral . fromEnum) a10} in
withMaybeDay a11 $ \a11' ->
preErrorCheck $ \a12' ->
yearOnYearInflationSwapHelper'_ a1' a2'1 a2'2 a3' a4' a5' a6' a7' a8' a9' a10' a11' a12' >>= \res ->
peekYearOnYearInflationSwapHelper res >>= \res' ->
errorCheck a12'>>
return (res')
{-# LINE 77 "./QuantLib/TermStructure/Inflation.chs" #-}
cpiBondHelper :: (GenQuote q) -> (Word)
-> (Double)
-> (Double)
-> ((Word,TimeUnit))
-> (ZeroInflationIndex) -> (CPIInterpolationType)
-> (Schedule) -> (NonEmpty Double)
-> (DayCounter)
-> (BusinessDayConvention)
-> (Maybe Day)
-> (Calendar)
-> IO ((BondHelper))
cpiBondHelper :: forall q.
GenQuote q
-> Word
-> Double
-> Double
-> (Word, TimeUnit)
-> ZeroInflationIndex
-> CPIInterpolationType
-> Schedule
-> NonEmpty Double
-> DayCounter
-> BusinessDayConvention
-> Maybe Day
-> Calendar
-> IO BondHelper
cpiBondHelper GenQuote q
a1 Word
a2 Double
a3 Double
a4 (Word, TimeUnit)
a5 ZeroInflationIndex
a6 CPIInterpolationType
a7 Schedule
a8 NonEmpty Double
a9 DayCounter
a10 BusinessDayConvention
a11 Maybe Day
a12 Calendar
a13 =
GenQuote q -> (Ptr CQuote' -> IO BondHelper) -> IO BondHelper
forall q b. GenQuote q -> (Ptr CQuote' -> IO b) -> IO b
withQuote GenQuote q
a1 ((Ptr CQuote' -> IO BondHelper) -> IO BondHelper)
-> (Ptr CQuote' -> IO BondHelper) -> IO BondHelper
forall a b. (a -> b) -> a -> b
$ \Ptr CQuote'
a1' ->
let {a2' :: CUInt
a2' = Word -> CUInt
forall a b. (Integral a, Num b) => a -> b
fromIntegral Word
a2} in
let {a3' :: CDouble
a3' = Double -> CDouble
forall a b. (Real a, Fractional b) => a -> b
realToFrac Double
a3} in
let {a4' :: CDouble
a4' = Double -> CDouble
forall a b. (Real a, Fractional b) => a -> b
realToFrac Double
a4} in
let {(CInt
a5'1, CInt
a5'2) = (Word, TimeUnit) -> (CInt, CInt)
forall a b c.
(Enum a, Integral b, Integral c) =>
(b, a) -> (CInt, c)
fromEnumQuantity (Word, TimeUnit)
a5} in
ZeroInflationIndex
-> (Ptr CZeroInflationIndex' -> IO BondHelper) -> IO BondHelper
forall zidx b.
GenZeroInflationIndex zidx
-> (Ptr CZeroInflationIndex' -> IO b) -> IO b
withZeroInflationIndex ZeroInflationIndex
a6 ((Ptr CZeroInflationIndex' -> IO BondHelper) -> IO BondHelper)
-> (Ptr CZeroInflationIndex' -> IO BondHelper) -> IO BondHelper
forall a b. (a -> b) -> a -> b
$ \Ptr CZeroInflationIndex'
a6' ->
let {a7' :: CInt
a7' = CPIInterpolationType -> CInt
forall a b. (Enum a, Integral b) => a -> b
fromEnumC CPIInterpolationType
a7} in
Schedule -> (Ptr CSchedule -> IO BondHelper) -> IO BondHelper
forall b. Schedule -> (Ptr CSchedule -> IO b) -> IO b
withSchedule Schedule
a8 ((Ptr CSchedule -> IO BondHelper) -> IO BondHelper)
-> (Ptr CSchedule -> IO BondHelper) -> IO BondHelper
forall a b. (a -> b) -> a -> b
$ \Ptr CSchedule
a8' ->
NonEmpty Double
-> ((CUInt, Ptr CDouble) -> IO BondHelper) -> IO BondHelper
forall b. NonEmpty Double -> ((CUInt, Ptr CDouble) -> IO b) -> IO b
withNonEmptyDoubleArray NonEmpty Double
a9 (((CUInt, Ptr CDouble) -> IO BondHelper) -> IO BondHelper)
-> ((CUInt, Ptr CDouble) -> IO BondHelper) -> IO BondHelper
forall a b. (a -> b) -> a -> b
$ \(CUInt
a9'1, Ptr CDouble
a9'2) ->
DayCounter -> (Ptr CDayCounter -> IO BondHelper) -> IO BondHelper
forall b. DayCounter -> (Ptr CDayCounter -> IO b) -> IO b
withDayCounter DayCounter
a10 ((Ptr CDayCounter -> IO BondHelper) -> IO BondHelper)
-> (Ptr CDayCounter -> IO BondHelper) -> IO BondHelper
forall a b. (a -> b) -> a -> b
$ \Ptr CDayCounter
a10' ->
let {a11' :: CInt
a11' = BusinessDayConvention -> CInt
forall a b. (Enum a, Integral b) => a -> b
fromEnumC BusinessDayConvention
a11} in
Maybe Day -> (CInt -> IO BondHelper) -> IO BondHelper
forall a. Maybe Day -> (CInt -> IO a) -> IO a
withMaybeDay Maybe Day
a12 ((CInt -> IO BondHelper) -> IO BondHelper)
-> (CInt -> IO BondHelper) -> IO BondHelper
forall a b. (a -> b) -> a -> b
$ \CInt
a12' ->
Calendar -> (Ptr CCalendar -> IO BondHelper) -> IO BondHelper
forall b. Calendar -> (Ptr CCalendar -> IO b) -> IO b
withCalendar Calendar
a13 ((Ptr CCalendar -> IO BondHelper) -> IO BondHelper)
-> (Ptr CCalendar -> IO BondHelper) -> IO BondHelper
forall a b. (a -> b) -> a -> b
$ \Ptr CCalendar
a13' ->
(Ptr (Ptr CChar) -> IO BondHelper) -> IO BondHelper
forall a b. (Ptr (Ptr a) -> IO b) -> IO b
preErrorCheck ((Ptr (Ptr CChar) -> IO BondHelper) -> IO BondHelper)
-> (Ptr (Ptr CChar) -> IO BondHelper) -> IO BondHelper
forall a b. (a -> b) -> a -> b
$ \Ptr (Ptr CChar)
a14' ->
Ptr CQuote'
-> CUInt
-> CDouble
-> CDouble
-> CInt
-> CInt
-> Ptr CZeroInflationIndex'
-> CInt
-> Ptr CSchedule
-> CUInt
-> Ptr CDouble
-> Ptr CDayCounter
-> CInt
-> CInt
-> Ptr CCalendar
-> Ptr (Ptr CChar)
-> IO (Ptr CBondHelper')
cpiBondHelper'_ Ptr CQuote'
a1' CUInt
a2' CDouble
a3' CDouble
a4' CInt
a5'1 CInt
a5'2 Ptr CZeroInflationIndex'
a6' CInt
a7' Ptr CSchedule
a8' CUInt
a9'1 Ptr CDouble
a9'2 Ptr CDayCounter
a10' CInt
a11' CInt
a12' Ptr CCalendar
a13' Ptr (Ptr CChar)
a14' IO (Ptr CBondHelper')
-> (Ptr CBondHelper' -> IO BondHelper) -> IO BondHelper
forall a b. IO a -> (a -> IO b) -> IO b
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= \Ptr CBondHelper'
res ->
Ptr CBondHelper' -> IO BondHelper
peekBondHelper Ptr CBondHelper'
res IO BondHelper -> (BondHelper -> IO BondHelper) -> IO BondHelper
forall a b. IO a -> (a -> IO b) -> IO b
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= \BondHelper
res' ->
Ptr (Ptr CChar) -> IO ()
errorCheck Ptr (Ptr CChar)
a14'IO () -> IO BondHelper -> IO BondHelper
forall a b. IO a -> IO b -> IO b
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>>
BondHelper -> IO BondHelper
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return (BondHelper
res')
{-# LINE 93 "./QuantLib/TermStructure/Inflation.chs" #-}
piecewiseZeroInflationCurve :: Day
-> Day
-> Frequency -> DayCounter -> NonEmpty ZeroCouponInflationSwapHelper -> Maybe Seasonality -> Interpolation
-> IO ZeroInflationTermStructure
piecewiseZeroInflationCurve r b f dc h s i = seasonalityArgs r s $ \sk sd sf sfs ->
uncurryNested (qlPiecewiseZeroInflationCurve r b f dc (toList h) sk sd sf sfs) (qlInterpolation i)
qlPiecewiseZeroInflationCurve :: (Day) -> (Day) -> (Frequency) -> (DayCounter) -> ([ZeroCouponInflationSwapHelper]) -> (Int) -> (Day) -> (Frequency) -> ([Double]) -> (Int) -> (Int) -> (Int) -> IO ((ZeroInflationTermStructure))
qlPiecewiseZeroInflationCurve a1 a2 a3 a4 a5 a6 a7 a8 a9 a10 a11 a12 =
withDay a1 $ \a1' ->
withDay a2 $ \a2' ->
let {a3' = (fromIntegral . fromEnum) a3} in
withDayCounter a4 $ \a4' ->
withZeroCouponInflationSwapHelperArray a5 $ \(a5'1, a5'2) ->
let {a6' = fromIntegral a6} in
withDay a7 $ \a7' ->
let {a8' = (fromIntegral . fromEnum) a8} in
withDoubleArray a9 $ \(a9'1, a9'2) ->
let {a10' = fromIntegral a10} in
let {a11' = fromIntegral a11} in
let {a12' = fromIntegral a12} in
preErrorCheck $ \a13' ->
qlPiecewiseZeroInflationCurve'_ a1' a2' a3' a4' a5'1 a5'2 a6' a7' a8' a9'1 a9'2 a10' a11' a12' a13' >>= \res ->
peekZeroInflationTermStructure res >>= \res' ->
errorCheck a13'>>
return (res')
{-# LINE 107 "./QuantLib/TermStructure/Inflation.chs" #-}
piecewiseYoyInflationCurve :: Day
-> Day
-> Double
-> Frequency -> DayCounter -> NonEmpty YearOnYearInflationSwapHelper -> Maybe Seasonality -> Interpolation
-> IO YoYInflationTermStructure
piecewiseYoyInflationCurve r b y f dc h s i = seasonalityArgs r s $ \sk sd sf sfs ->
uncurryNested (qlPiecewiseYoYInflationCurve r b y f dc (toList h) sk sd sf sfs) (qlInterpolation i)
qlPiecewiseYoYInflationCurve :: (Day) -> (Day) -> (Double) -> (Frequency) -> (DayCounter) -> ([YearOnYearInflationSwapHelper]) -> (Int) -> (Day) -> (Frequency) -> ([Double]) -> (Int) -> (Int) -> (Int) -> IO ((YoYInflationTermStructure))
qlPiecewiseYoYInflationCurve a1 a2 a3 a4 a5 a6 a7 a8 a9 a10 a11 a12 a13 =
withDay a1 $ \a1' ->
withDay a2 $ \a2' ->
let {a3' = realToFrac a3} in
let {a4' = (fromIntegral . fromEnum) a4} in
withDayCounter a5 $ \a5' ->
withYearOnYearInflationSwapHelperArray a6 $ \(a6'1, a6'2) ->
let {a7' = fromIntegral a7} in
withDay a8 $ \a8' ->
let {a9' = (fromIntegral . fromEnum) a9} in
withDoubleArray a10 $ \(a10'1, a10'2) ->
let {a11' = fromIntegral a11} in
let {a12' = fromIntegral a12} in
let {a13' = fromIntegral a13} in
preErrorCheck $ \a14' ->
qlPiecewiseYoYInflationCurve'_ a1' a2' a3' a4' a5' a6'1 a6'2 a7' a8' a9' a10'1 a10'2 a11' a12' a13' a14' >>= \res ->
peekYoYInflationTermStructure res >>= \res' ->
errorCheck a14'>>
return (res')
{-# LINE 122 "./QuantLib/TermStructure/Inflation.chs" #-}
interpolatedYoyInflationCurve :: Day
-> NonEmpty (Day, Double)
-> Frequency -> DayCounter -> Maybe Seasonality -> Interpolation
-> IO YoYInflationTermStructure
interpolatedYoyInflationCurve r dr f dc s i = seasonalityArgs r s $ \sk sd sf sfs ->
uncurryNested (qlInterpolatedYoYInflationCurve r ds rs f dc sk sd sf sfs) (qlInterpolation i)
where (ds, rs) = unzip (toList dr)
qlInterpolatedYoYInflationCurve :: (Day) -> ([Day]) -> ([Double]) -> (Frequency) -> (DayCounter) -> (Int) -> (Day) -> (Frequency) -> ([Double]) -> (Int) -> (Int) -> (Int) -> IO ((YoYInflationTermStructure))
qlInterpolatedYoYInflationCurve a1 a2 a3 a4 a5 a6 a7 a8 a9 a10 a11 a12 =
withDay a1 $ \a1' ->
withDayArray a2 $ \(a2'1, a2'2) ->
withDoubleArrayRaw a3 $ \a3' ->
let {a4' = (fromIntegral . fromEnum) a4} in
withDayCounter a5 $ \a5' ->
let {a6' = fromIntegral a6} in
withDay a7 $ \a7' ->
let {a8' = (fromIntegral . fromEnum) a8} in
withDoubleArray a9 $ \(a9'1, a9'2) ->
let {a10' = fromIntegral a10} in
let {a11' = fromIntegral a11} in
let {a12' = fromIntegral a12} in
preErrorCheck $ \a13' ->
qlInterpolatedYoYInflationCurve'_ a1' a2'1 a2'2 a3' a4' a5' a6' a7' a8' a9'1 a9'2 a10' a11' a12' a13' >>= \res ->
peekYoYInflationTermStructure res >>= \res' ->
errorCheck a13'>>
return (res')
{-# LINE 138 "./QuantLib/TermStructure/Inflation.chs" #-}
interpolatedZeroInflationCurve :: Day
-> NonEmpty (Day, Double)
-> Frequency -> DayCounter -> Maybe Seasonality -> Interpolation
-> IO ZeroInflationTermStructure
interpolatedZeroInflationCurve r dr f dc s i = seasonalityArgs r s $ \sk sd sf sfs ->
uncurryNested (qlInterpolatedZeroInflationCurve r ds rs f dc sk sd sf sfs) (qlInterpolation i)
where (ds, rs) = unzip (toList dr)
qlInterpolatedZeroInflationCurve :: (Day) -> ([Day]) -> ([Double]) -> (Frequency) -> (DayCounter) -> (Int) -> (Day) -> (Frequency) -> ([Double]) -> (Int) -> (Int) -> (Int) -> IO ((ZeroInflationTermStructure))
qlInterpolatedZeroInflationCurve a1 a2 a3 a4 a5 a6 a7 a8 a9 a10 a11 a12 =
withDay a1 $ \a1' ->
withDayArray a2 $ \(a2'1, a2'2) ->
withDoubleArrayRaw a3 $ \a3' ->
let {a4' = (fromIntegral . fromEnum) a4} in
withDayCounter a5 $ \a5' ->
let {a6' = fromIntegral a6} in
withDay a7 $ \a7' ->
let {a8' = (fromIntegral . fromEnum) a8} in
withDoubleArray a9 $ \(a9'1, a9'2) ->
let {a10' = fromIntegral a10} in
let {a11' = fromIntegral a11} in
let {a12' = fromIntegral a12} in
preErrorCheck $ \a13' ->
qlInterpolatedZeroInflationCurve'_ a1' a2'1 a2'2 a3' a4' a5' a6' a7' a8' a9'1 a9'2 a10' a11' a12' a13' >>= \res ->
peekZeroInflationTermStructure res >>= \res' ->
errorCheck a13'>>
return (res')
{-# LINE 152 "./QuantLib/TermStructure/Inflation.chs" #-}
data Seasonality
= MultiplicativePriceSeasonality !Day !Frequency ![Double]
| KerkhofSeasonality !Day ![Double]
seasonalityArgs :: Day -> Maybe Seasonality -> (Int -> Day -> Frequency -> [Double] -> r) -> r
seasonalityArgs d s k = case s of
Nothing -> k (-1) d NoFrequency []
Just (MultiplicativePriceSeasonality b f fs) -> k 0 b f fs
Just (KerkhofSeasonality b fs) -> k 1 b Monthly fs
zeroRate :: (ZeroInflationTermStructure) -> (Day) -> (Bool)
-> IO ((Double))
zeroRate :: ZeroInflationTermStructure -> Day -> Bool -> IO Double
zeroRate ZeroInflationTermStructure
a1 Day
a2 Bool
a3 =
ZeroInflationTermStructure
-> (Ptr CZeroInflationTermStructure' -> IO Double) -> IO Double
forall t b.
GenTermStructure (ForeignPtr t) -> (Ptr t -> IO b) -> IO b
withGenTermStructure ZeroInflationTermStructure
a1 ((Ptr CZeroInflationTermStructure' -> IO Double) -> IO Double)
-> (Ptr CZeroInflationTermStructure' -> IO Double) -> IO Double
forall a b. (a -> b) -> a -> b
$ \Ptr CZeroInflationTermStructure'
a1' ->
Day -> (CInt -> IO Double) -> IO Double
forall a. Day -> (CInt -> IO a) -> IO a
withDay Day
a2 ((CInt -> IO Double) -> IO Double)
-> (CInt -> IO Double) -> IO Double
forall a b. (a -> b) -> a -> b
$ \CInt
a2' ->
let {a3' :: CInt
a3' = Bool -> CInt
forall a. Num a => Bool -> a
C2HSImp.fromBool Bool
a3} 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)
a4' ->
Ptr CZeroInflationTermStructure'
-> CInt -> CInt -> Ptr (Ptr CChar) -> IO CDouble
zeroRate'_ Ptr CZeroInflationTermStructure'
a1' CInt
a2' CInt
a3' Ptr (Ptr CChar)
a4' 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)
a4'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 170 "./QuantLib/TermStructure/Inflation.chs" #-}
yoyRate :: (YoYInflationTermStructure) -> (Day) -> (Bool)
-> IO ((Double))
yoyRate a1 a2 a3 =
withGenTermStructure a1 $ \a1' ->
withDay a2 $ \a2' ->
let {a3' = C2HSImp.fromBool a3} in
preErrorCheck $ \a4' ->
yoyRate'_ a1' a2' a3' a4' >>= \res ->
let {res' = realToFrac res} in
errorCheck a4'>>
return (res')
{-# LINE 174 "./QuantLib/TermStructure/Inflation.chs" #-}
foreign import ccall safe "QuantLib/TermStructure/Inflation.chs.h qlZeroCouponInflationSwapHelper"
zeroCouponInflationSwapHelper'_ :: ((C2HSImp.Ptr (CQuote')) -> (C2HSImp.CInt -> (C2HSImp.CInt -> (C2HSImp.CInt -> ((C2HSImp.Ptr (CCalendar)) -> (C2HSImp.CInt -> ((C2HSImp.Ptr (CDayCounter)) -> ((C2HSImp.Ptr (CZeroInflationIndex')) -> (C2HSImp.CInt -> (C2HSImp.CInt -> (C2HSImp.CInt -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO (C2HSImp.Ptr (CZeroCouponInflationSwapHelper)))))))))))))))
foreign import ccall safe "QuantLib/TermStructure/Inflation.chs.h qlYearOnYearInflationSwapHelper"
yearOnYearInflationSwapHelper'_ :: ((C2HSImp.Ptr (CQuote')) -> (C2HSImp.CInt -> (C2HSImp.CInt -> (C2HSImp.CInt -> ((C2HSImp.Ptr (CCalendar)) -> (C2HSImp.CInt -> ((C2HSImp.Ptr (CDayCounter)) -> ((C2HSImp.Ptr (CYoYInflationIndex')) -> (C2HSImp.CInt -> ((C2HSImp.Ptr (CYieldTermStructure')) -> (C2HSImp.CInt -> (C2HSImp.CInt -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO (C2HSImp.Ptr (CYearOnYearInflationSwapHelper))))))))))))))))
foreign import ccall safe "QuantLib/TermStructure/Inflation.chs.h qlCPIBondHelper"
cpiBondHelper'_ :: ((C2HSImp.Ptr (CQuote')) -> (C2HSImp.CUInt -> (C2HSImp.CDouble -> (C2HSImp.CDouble -> (C2HSImp.CInt -> (C2HSImp.CInt -> ((C2HSImp.Ptr (CZeroInflationIndex')) -> (C2HSImp.CInt -> ((C2HSImp.Ptr (CSchedule)) -> (C2HSImp.CUInt -> ((C2HSImp.Ptr C2HSImp.CDouble) -> ((C2HSImp.Ptr (CDayCounter)) -> (C2HSImp.CInt -> (C2HSImp.CInt -> ((C2HSImp.Ptr (CCalendar)) -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO (C2HSImp.Ptr (CBondHelper')))))))))))))))))))
foreign import ccall safe "QuantLib/TermStructure/Inflation.chs.h qlPiecewiseZeroInflationCurve"
qlPiecewiseZeroInflationCurve'_ :: (C2HSImp.CInt -> (C2HSImp.CInt -> (C2HSImp.CInt -> ((C2HSImp.Ptr (CDayCounter)) -> (C2HSImp.CUInt -> ((C2HSImp.Ptr (C2HSImp.Ptr (CZeroCouponInflationSwapHelper))) -> (C2HSImp.CInt -> (C2HSImp.CInt -> (C2HSImp.CInt -> (C2HSImp.CUInt -> ((C2HSImp.Ptr C2HSImp.CDouble) -> (C2HSImp.CInt -> (C2HSImp.CInt -> (C2HSImp.CInt -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO (C2HSImp.Ptr (CZeroInflationTermStructure'))))))))))))))))))
foreign import ccall safe "QuantLib/TermStructure/Inflation.chs.h qlPiecewiseYoYInflationCurve"
qlPiecewiseYoYInflationCurve'_ :: (C2HSImp.CInt -> (C2HSImp.CInt -> (C2HSImp.CDouble -> (C2HSImp.CInt -> ((C2HSImp.Ptr (CDayCounter)) -> (C2HSImp.CUInt -> ((C2HSImp.Ptr (C2HSImp.Ptr (CYearOnYearInflationSwapHelper))) -> (C2HSImp.CInt -> (C2HSImp.CInt -> (C2HSImp.CInt -> (C2HSImp.CUInt -> ((C2HSImp.Ptr C2HSImp.CDouble) -> (C2HSImp.CInt -> (C2HSImp.CInt -> (C2HSImp.CInt -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO (C2HSImp.Ptr (CYoYInflationTermStructure')))))))))))))))))))
foreign import ccall safe "QuantLib/TermStructure/Inflation.chs.h qlInterpolatedYoYInflationCurve"
qlInterpolatedYoYInflationCurve'_ :: (C2HSImp.CInt -> (C2HSImp.CUInt -> ((C2HSImp.Ptr C2HSImp.CInt) -> ((C2HSImp.Ptr C2HSImp.CDouble) -> (C2HSImp.CInt -> ((C2HSImp.Ptr (CDayCounter)) -> (C2HSImp.CInt -> (C2HSImp.CInt -> (C2HSImp.CInt -> (C2HSImp.CUInt -> ((C2HSImp.Ptr C2HSImp.CDouble) -> (C2HSImp.CInt -> (C2HSImp.CInt -> (C2HSImp.CInt -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO (C2HSImp.Ptr (CYoYInflationTermStructure'))))))))))))))))))
foreign import ccall safe "QuantLib/TermStructure/Inflation.chs.h qlInterpolatedZeroInflationCurve"
qlInterpolatedZeroInflationCurve'_ :: (C2HSImp.CInt -> (C2HSImp.CUInt -> ((C2HSImp.Ptr C2HSImp.CInt) -> ((C2HSImp.Ptr C2HSImp.CDouble) -> (C2HSImp.CInt -> ((C2HSImp.Ptr (CDayCounter)) -> (C2HSImp.CInt -> (C2HSImp.CInt -> (C2HSImp.CInt -> (C2HSImp.CUInt -> ((C2HSImp.Ptr C2HSImp.CDouble) -> (C2HSImp.CInt -> (C2HSImp.CInt -> (C2HSImp.CInt -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO (C2HSImp.Ptr (CZeroInflationTermStructure'))))))))))))))))))
foreign import ccall safe "QuantLib/TermStructure/Inflation.chs.h qlZeroInflationTermStructureZeroRate"
zeroRate'_ :: ((C2HSImp.Ptr (CZeroInflationTermStructure')) -> (C2HSImp.CInt -> (C2HSImp.CInt -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO C2HSImp.CDouble)))))
foreign import ccall safe "QuantLib/TermStructure/Inflation.chs.h qlYoYInflationTermStructureYoYRate"
yoyRate'_ :: ((C2HSImp.Ptr (CYoYInflationTermStructure')) -> (C2HSImp.CInt -> (C2HSImp.CInt -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO C2HSImp.CDouble)))))