{-# LINE 1 "./QuantLib/TermStructure/Commodity.chs" #-}
module QuantLib.TermStructure.Commodity
(
CommodityCurve
, ExchangeContract
, ExchangeContracts
, commodityCurve
, setBasisOfCurve
, name
, commodityType
, unitOfMeasure
, currency
, nodes
, isEmpty
, basisOfCurve
, price
, basisOfPrice
, priceNearby
, underlyingPriceDate
) where
import qualified Foreign.C.String as C2HSImp
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 qualified System.IO.Unsafe as C2HSImp
import QuantLib.Internal
import QuantLib.Internal.Type
import Data.List.NonEmpty(NonEmpty, toList)
{-# LINE 39 "./QuantLib/TermStructure/Commodity.chs" #-}
{-# LINE 40 "./QuantLib/TermStructure/Commodity.chs" #-}
{-# LINE 41 "./QuantLib/TermStructure/Commodity.chs" #-}
{-# LINE 42 "./QuantLib/TermStructure/Commodity.chs" #-}
{-# LINE 43 "./QuantLib/TermStructure/Commodity.chs" #-}
{-# LINE 44 "./QuantLib/TermStructure/Commodity.chs" #-}
commodityCurve :: String -> CommodityType -> Currency -> UnitOfMeasure -> Calendar
-> NonEmpty (Day, Double) -> DayCounter -> IO CommodityCurve
commodityCurve :: String
-> CommodityType
-> Currency
-> UnitOfMeasure
-> Calendar
-> NonEmpty (Day, Double)
-> DayCounter
-> IO CommodityCurve
commodityCurve String
curveName CommodityType
ct Currency
ccy UnitOfMeasure
uom Calendar
cal NonEmpty (Day, Double)
curveNodes DayCounter
dc =
String
-> CommodityType
-> Currency
-> UnitOfMeasure
-> Calendar
-> [Day]
-> [Double]
-> DayCounter
-> IO CommodityCurve
qlCommodityCurve String
curveName CommodityType
ct Currency
ccy UnitOfMeasure
uom Calendar
cal [Day]
dates [Double]
prices DayCounter
dc
where ([Day]
dates, [Double]
prices) = [(Day, Double)] -> ([Day], [Double])
forall a b. [(a, b)] -> ([a], [b])
unzip (NonEmpty (Day, Double) -> [(Day, Double)]
forall a. NonEmpty a -> [a]
toList NonEmpty (Day, Double)
curveNodes)
qlCommodityCurve :: (String)
-> (CommodityType) -> (Currency) -> (UnitOfMeasure) -> (Calendar) -> ([Day]) -> ([Double]) -> (DayCounter) -> IO ((CommodityCurve))
qlCommodityCurve :: String
-> CommodityType
-> Currency
-> UnitOfMeasure
-> Calendar
-> [Day]
-> [Double]
-> DayCounter
-> IO CommodityCurve
qlCommodityCurve String
a1 CommodityType
a2 Currency
a3 UnitOfMeasure
a4 Calendar
a5 [Day]
a6 [Double]
a7 DayCounter
a8 =
String -> (CString -> IO CommodityCurve) -> IO CommodityCurve
forall a. String -> (CString -> IO a) -> IO a
C2HSImp.withCString String
a1 ((CString -> IO CommodityCurve) -> IO CommodityCurve)
-> (CString -> IO CommodityCurve) -> IO CommodityCurve
forall a b. (a -> b) -> a -> b
$ \CString
a1' ->
CommodityType
-> (Ptr CCommodityType -> IO CommodityCurve) -> IO CommodityCurve
forall b. CommodityType -> (Ptr CCommodityType -> IO b) -> IO b
withCommodityType CommodityType
a2 ((Ptr CCommodityType -> IO CommodityCurve) -> IO CommodityCurve)
-> (Ptr CCommodityType -> IO CommodityCurve) -> IO CommodityCurve
forall a b. (a -> b) -> a -> b
$ \Ptr CCommodityType
a2' ->
Currency
-> (Ptr CCurrency -> IO CommodityCurve) -> IO CommodityCurve
forall b. Currency -> (Ptr CCurrency -> IO b) -> IO b
withCurrency Currency
a3 ((Ptr CCurrency -> IO CommodityCurve) -> IO CommodityCurve)
-> (Ptr CCurrency -> IO CommodityCurve) -> IO CommodityCurve
forall a b. (a -> b) -> a -> b
$ \Ptr CCurrency
a3' ->
UnitOfMeasure
-> (Ptr CUnitOfMeasure -> IO CommodityCurve) -> IO CommodityCurve
forall b. UnitOfMeasure -> (Ptr CUnitOfMeasure -> IO b) -> IO b
withUnitOfMeasure UnitOfMeasure
a4 ((Ptr CUnitOfMeasure -> IO CommodityCurve) -> IO CommodityCurve)
-> (Ptr CUnitOfMeasure -> IO CommodityCurve) -> IO CommodityCurve
forall a b. (a -> b) -> a -> b
$ \Ptr CUnitOfMeasure
a4' ->
Calendar
-> (Ptr CCalendar -> IO CommodityCurve) -> IO CommodityCurve
forall b. Calendar -> (Ptr CCalendar -> IO b) -> IO b
withCalendar Calendar
a5 ((Ptr CCalendar -> IO CommodityCurve) -> IO CommodityCurve)
-> (Ptr CCalendar -> IO CommodityCurve) -> IO CommodityCurve
forall a b. (a -> b) -> a -> b
$ \Ptr CCalendar
a5' ->
[Day]
-> ((CUInt, Ptr CInt) -> IO CommodityCurve) -> IO CommodityCurve
forall b. [Day] -> ((CUInt, Ptr CInt) -> IO b) -> IO b
withDayArray [Day]
a6 (((CUInt, Ptr CInt) -> IO CommodityCurve) -> IO CommodityCurve)
-> ((CUInt, Ptr CInt) -> IO CommodityCurve) -> IO CommodityCurve
forall a b. (a -> b) -> a -> b
$ \(CUInt
a6'1, Ptr CInt
a6'2) ->
[Double]
-> ((CUInt, Ptr CDouble) -> IO CommodityCurve) -> IO CommodityCurve
forall b. [Double] -> ((CUInt, Ptr CDouble) -> IO b) -> IO b
withDoubleArray [Double]
a7 (((CUInt, Ptr CDouble) -> IO CommodityCurve) -> IO CommodityCurve)
-> ((CUInt, Ptr CDouble) -> IO CommodityCurve) -> IO CommodityCurve
forall a b. (a -> b) -> a -> b
$ \(CUInt
a7'1, Ptr CDouble
a7'2) ->
DayCounter
-> (Ptr CDayCounter -> IO CommodityCurve) -> IO CommodityCurve
forall b. DayCounter -> (Ptr CDayCounter -> IO b) -> IO b
withDayCounter DayCounter
a8 ((Ptr CDayCounter -> IO CommodityCurve) -> IO CommodityCurve)
-> (Ptr CDayCounter -> IO CommodityCurve) -> IO CommodityCurve
forall a b. (a -> b) -> a -> b
$ \Ptr CDayCounter
a8' ->
(Ptr CString -> IO CommodityCurve) -> IO CommodityCurve
forall a b. (Ptr (Ptr a) -> IO b) -> IO b
preErrorCheck ((Ptr CString -> IO CommodityCurve) -> IO CommodityCurve)
-> (Ptr CString -> IO CommodityCurve) -> IO CommodityCurve
forall a b. (a -> b) -> a -> b
$ \Ptr CString
a9' ->
CString
-> Ptr CCommodityType
-> Ptr CCurrency
-> Ptr CUnitOfMeasure
-> Ptr CCalendar
-> CUInt
-> Ptr CInt
-> CUInt
-> Ptr CDouble
-> Ptr CDayCounter
-> Ptr CString
-> IO (Ptr CCommodityCurve')
qlCommodityCurve'_ CString
a1' Ptr CCommodityType
a2' Ptr CCurrency
a3' Ptr CUnitOfMeasure
a4' Ptr CCalendar
a5' CUInt
a6'1 Ptr CInt
a6'2 CUInt
a7'1 Ptr CDouble
a7'2 Ptr CDayCounter
a8' Ptr CString
a9' IO (Ptr CCommodityCurve')
-> (Ptr CCommodityCurve' -> IO CommodityCurve) -> IO CommodityCurve
forall a b. IO a -> (a -> IO b) -> IO b
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= \Ptr CCommodityCurve'
res ->
Ptr CCommodityCurve' -> IO CommodityCurve
peekCommodityCurve Ptr CCommodityCurve'
res IO CommodityCurve
-> (CommodityCurve -> IO CommodityCurve) -> IO CommodityCurve
forall a b. IO a -> (a -> IO b) -> IO b
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= \CommodityCurve
res' ->
Ptr CString -> IO ()
errorCheck Ptr CString
a9'IO () -> IO CommodityCurve -> IO CommodityCurve
forall a b. IO a -> IO b -> IO b
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>>
CommodityCurve -> IO CommodityCurve
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return (CommodityCurve
res')
{-# LINE 64 "./QuantLib/TermStructure/Commodity.chs" #-}
name :: (CommodityCurve) -> IO ((String))
name a1 =
withGenTermStructure a1 $ \a1' ->
name'_ a1' >>= \res ->
peekDynString res >>= \res' ->
return (res')
{-# LINE 67 "./QuantLib/TermStructure/Commodity.chs" #-}
commodityType :: (CommodityCurve) -> IO ((CommodityType))
commodityType a1 =
withGenTermStructure a1 $ \a1' ->
preErrorCheck $ \a2' ->
commodityType'_ a1' a2' >>= \res ->
peekCommodityType res >>= \res' ->
errorCheck a2'>>
return (res')
{-# LINE 70 "./QuantLib/TermStructure/Commodity.chs" #-}
unitOfMeasure :: (CommodityCurve) -> IO ((UnitOfMeasure))
unitOfMeasure a1 =
withGenTermStructure a1 $ \a1' ->
preErrorCheck $ \a2' ->
unitOfMeasure'_ a1' a2' >>= \res ->
peekUnitOfMeasure res >>= \res' ->
errorCheck a2'>>
return (res')
{-# LINE 73 "./QuantLib/TermStructure/Commodity.chs" #-}
currency :: (CommodityCurve) -> IO ((Currency))
currency a1 =
withGenTermStructure a1 $ \a1' ->
preErrorCheck $ \a2' ->
currency'_ a1' a2' >>= \res ->
peekCurrency res >>= \res' ->
errorCheck a2'>>
return (res')
{-# LINE 76 "./QuantLib/TermStructure/Commodity.chs" #-}
nodes :: CommodityCurve -> IO [(Day, Double)]
nodes curve = do
dates <- qlCommodityCurveDates curve
prices <- qlCommodityCurvePrices curve
pure (zip dates prices)
qlCommodityCurveDates :: (CommodityCurve) -> IO (([Day]))
qlCommodityCurveDates :: CommodityCurve -> IO [Day]
qlCommodityCurveDates CommodityCurve
a1 =
CommodityCurve -> (Ptr CCommodityCurve' -> IO [Day]) -> IO [Day]
forall t b.
GenTermStructure (ForeignPtr t) -> (Ptr t -> IO b) -> IO b
withGenTermStructure CommodityCurve
a1 ((Ptr CCommodityCurve' -> IO [Day]) -> IO [Day])
-> (Ptr CCommodityCurve' -> IO [Day]) -> IO [Day]
forall a b. (a -> b) -> a -> b
$ \Ptr CCommodityCurve'
a1' ->
((Ptr CUInt, Ptr (Ptr CInt)) -> IO [Day]) -> IO [Day]
forall a b. ((Ptr CUInt, Ptr (Ptr a)) -> IO b) -> IO b
preArray (((Ptr CUInt, Ptr (Ptr CInt)) -> IO [Day]) -> IO [Day])
-> ((Ptr CUInt, Ptr (Ptr CInt)) -> IO [Day]) -> IO [Day]
forall a b. (a -> b) -> a -> b
$ \(a2'1, a2'2) ->
(Ptr CString -> IO [Day]) -> IO [Day]
forall a b. (Ptr (Ptr a) -> IO b) -> IO b
preErrorCheck ((Ptr CString -> IO [Day]) -> IO [Day])
-> (Ptr CString -> IO [Day]) -> IO [Day]
forall a b. (a -> b) -> a -> b
$ \Ptr CString
a3' ->
Ptr CCommodityCurve'
-> Ptr CUInt -> Ptr (Ptr CInt) -> Ptr CString -> IO ()
qlCommodityCurveDates'_ Ptr CCommodityCurve'
a1' Ptr CUInt
a2'1 Ptr (Ptr CInt)
a2'2 Ptr CString
a3' 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]) -> 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
>>= \[Day]
a2'' ->
Ptr CString -> IO ()
errorCheck Ptr CString
a3'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]
a2'')
{-# LINE 84 "./QuantLib/TermStructure/Commodity.chs" #-}
qlCommodityCurvePrices :: (CommodityCurve) -> IO (([Double]))
qlCommodityCurvePrices a1 =
withGenTermStructure a1 $ \a1' ->
preArray $ \(a2'1, a2'2) ->
preErrorCheck $ \a3' ->
qlCommodityCurvePrices'_ a1' a2'1 a2'2 a3' >>
peekDoubleArray a2'1 a2'2>>= \a2'' ->
errorCheck a3'>>
return (a2'')
{-# LINE 85 "./QuantLib/TermStructure/Commodity.chs" #-}
isEmpty :: (CommodityCurve) -> (Bool)
isEmpty a1 =
C2HSImp.unsafePerformIO $
withGenTermStructure a1 $ \a1' ->
isEmpty'_ a1' >>= \res ->
let {res' = C2HSImp.toBool res} in
return (res')
{-# LINE 88 "./QuantLib/TermStructure/Commodity.chs" #-}
basisOfCurve :: (CommodityCurve) -> IO ((Maybe CommodityCurve))
basisOfCurve a1 =
withGenTermStructure a1 $ \a1' ->
basisOfCurve'_ a1' >>= \res ->
peekMaybeCommodityCurve res >>= \res' ->
return (res')
{-# LINE 91 "./QuantLib/TermStructure/Commodity.chs" #-}
setBasisOfCurve :: (CommodityCurve) -> (CommodityCurve) -> IO ()
setBasisOfCurve a1 a2 =
withGenTermStructure a1 $ \a1' ->
withGenTermStructure a2 $ \a2' ->
preErrorCheck $ \a3' ->
setBasisOfCurve'_ a1' a2' a3' >>
errorCheck a3'>>
return ()
{-# LINE 95 "./QuantLib/TermStructure/Commodity.chs" #-}
type ExchangeContract = (String, Day, Day, Day)
type ExchangeContracts = [(Day, ExchangeContract)]
splitExchangeContracts :: ExchangeContracts -> ([Day], [String], [Day], [Day], [Day])
splitExchangeContracts :: ExchangeContracts -> ([Day], [String], [Day], [Day], [Day])
splitExchangeContracts ExchangeContracts
ecs =
( ((Day, ExchangeContract) -> Day) -> ExchangeContracts -> [Day]
forall a b. (a -> b) -> [a] -> [b]
map (Day, ExchangeContract) -> Day
forall a b. (a, b) -> a
fst ExchangeContracts
ecs
, [String
c | (Day
_, (String
c, Day
_, Day
_, Day
_)) <- ExchangeContracts
ecs]
, [Day
x | (Day
_, (String
_, Day
x, Day
_, Day
_)) <- ExchangeContracts
ecs]
, [Day
s | (Day
_, (String
_, Day
_, Day
s, Day
_)) <- ExchangeContracts
ecs]
, [Day
e | (Day
_, (String
_, Day
_, Day
_, Day
e)) <- ExchangeContracts
ecs] )
qlCommodityCurvePrice_ :: (CommodityCurve) -> (Day) -> ([Day]) -> ([String]) -> ([Day]) -> ([Day]) -> ([Day]) -> (Int)
-> IO ((Double))
qlCommodityCurvePrice_ :: CommodityCurve
-> Day
-> [Day]
-> [String]
-> [Day]
-> [Day]
-> [Day]
-> Int
-> IO Double
qlCommodityCurvePrice_ CommodityCurve
a1 Day
a2 [Day]
a3 [String]
a4 [Day]
a5 [Day]
a6 [Day]
a7 Int
a8 =
CommodityCurve -> (Ptr CCommodityCurve' -> IO Double) -> IO Double
forall t b.
GenTermStructure (ForeignPtr t) -> (Ptr t -> IO b) -> IO b
withGenTermStructure CommodityCurve
a1 ((Ptr CCommodityCurve' -> IO Double) -> IO Double)
-> (Ptr CCommodityCurve' -> IO Double) -> IO Double
forall a b. (a -> b) -> a -> b
$ \Ptr CCommodityCurve'
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' ->
[Day] -> ((CUInt, Ptr CInt) -> IO Double) -> IO Double
forall b. [Day] -> ((CUInt, Ptr CInt) -> IO b) -> IO b
withDayArray [Day]
a3 (((CUInt, Ptr CInt) -> IO Double) -> IO Double)
-> ((CUInt, Ptr CInt) -> IO Double) -> IO Double
forall a b. (a -> b) -> a -> b
$ \(CUInt
a3'1, Ptr CInt
a3'2) ->
[String] -> ((CUInt, Ptr CString) -> IO Double) -> IO Double
forall b. [String] -> ((CUInt, Ptr CString) -> IO b) -> IO b
withStringArray [String]
a4 (((CUInt, Ptr CString) -> IO Double) -> IO Double)
-> ((CUInt, Ptr CString) -> IO Double) -> IO Double
forall a b. (a -> b) -> a -> b
$ \(CUInt
a4'1, Ptr CString
a4'2) ->
[Day] -> ((CUInt, Ptr CInt) -> IO Double) -> IO Double
forall b. [Day] -> ((CUInt, Ptr CInt) -> IO b) -> IO b
withDayArray [Day]
a5 (((CUInt, Ptr CInt) -> IO Double) -> IO Double)
-> ((CUInt, Ptr CInt) -> IO Double) -> IO Double
forall a b. (a -> b) -> a -> b
$ \(CUInt
a5'1, Ptr CInt
a5'2) ->
[Day] -> ((CUInt, Ptr CInt) -> IO Double) -> IO Double
forall b. [Day] -> ((CUInt, Ptr CInt) -> IO b) -> IO b
withDayArray [Day]
a6 (((CUInt, Ptr CInt) -> IO Double) -> IO Double)
-> ((CUInt, Ptr CInt) -> IO Double) -> IO Double
forall a b. (a -> b) -> a -> b
$ \(CUInt
a6'1, Ptr CInt
a6'2) ->
[Day] -> ((CUInt, Ptr CInt) -> IO Double) -> IO Double
forall b. [Day] -> ((CUInt, Ptr CInt) -> IO b) -> IO b
withDayArray [Day]
a7 (((CUInt, Ptr CInt) -> IO Double) -> IO Double)
-> ((CUInt, Ptr CInt) -> IO Double) -> IO Double
forall a b. (a -> b) -> a -> b
$ \(CUInt
a7'1, Ptr CInt
a7'2) ->
let {a8' :: CInt
a8' = Int -> CInt
forall a b. (Integral a, Num b) => a -> b
fromIntegral Int
a8} in
(Ptr CString -> IO Double) -> IO Double
forall a b. (Ptr (Ptr a) -> IO b) -> IO b
preErrorCheck ((Ptr CString -> IO Double) -> IO Double)
-> (Ptr CString -> IO Double) -> IO Double
forall a b. (a -> b) -> a -> b
$ \Ptr CString
a9' ->
Ptr CCommodityCurve'
-> CInt
-> CUInt
-> Ptr CInt
-> CUInt
-> Ptr CString
-> CUInt
-> Ptr CInt
-> CUInt
-> Ptr CInt
-> CUInt
-> Ptr CInt
-> CInt
-> Ptr CString
-> IO CDouble
qlCommodityCurvePrice_'_ Ptr CCommodityCurve'
a1' CInt
a2' CUInt
a3'1 Ptr CInt
a3'2 CUInt
a4'1 Ptr CString
a4'2 CUInt
a5'1 Ptr CInt
a5'2 CUInt
a6'1 Ptr CInt
a6'2 CUInt
a7'1 Ptr CInt
a7'2 CInt
a8' Ptr CString
a9' 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 CString -> IO ()
errorCheck Ptr CString
a9'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 130 "./QuantLib/TermStructure/Commodity.chs" #-}
priceNearby :: CommodityCurve -> Day -> ExchangeContracts -> Int -> IO Double
priceNearby curve date ecs nearbyOffset =
qlCommodityCurvePrice_ curve date keys codes expirations starts ends nearbyOffset
where (keys, codes, expirations, starts, ends) = splitExchangeContracts ecs
price :: CommodityCurve -> Day -> IO Double
price :: CommodityCurve -> Day -> IO Double
price CommodityCurve
curve Day
date = CommodityCurve -> Day -> ExchangeContracts -> Int -> IO Double
priceNearby CommodityCurve
curve Day
date [] Int
0
basisOfPrice :: (CommodityCurve) -> (Day) -> IO ((Double))
basisOfPrice :: CommodityCurve -> Day -> IO Double
basisOfPrice CommodityCurve
a1 Day
a2 =
CommodityCurve -> (Ptr CCommodityCurve' -> IO Double) -> IO Double
forall t b.
GenTermStructure (ForeignPtr t) -> (Ptr t -> IO b) -> IO b
withGenTermStructure CommodityCurve
a1 ((Ptr CCommodityCurve' -> IO Double) -> IO Double)
-> (Ptr CCommodityCurve' -> IO Double) -> IO Double
forall a b. (a -> b) -> a -> b
$ \Ptr CCommodityCurve'
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' ->
(Ptr CString -> IO Double) -> IO Double
forall a b. (Ptr (Ptr a) -> IO b) -> IO b
preErrorCheck ((Ptr CString -> IO Double) -> IO Double)
-> (Ptr CString -> IO Double) -> IO Double
forall a b. (a -> b) -> a -> b
$ \Ptr CString
a3' ->
Ptr CCommodityCurve' -> CInt -> Ptr CString -> IO CDouble
basisOfPrice'_ Ptr CCommodityCurve'
a1' CInt
a2' Ptr CString
a3' 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 CString -> IO ()
errorCheck Ptr CString
a3'IO () -> IO Double -> IO Double
forall a b. IO a -> IO b -> IO b
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>>
Double -> IO Double
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return (Double
res')
{-# LINE 148 "./QuantLib/TermStructure/Commodity.chs" #-}
qlCommodityCurveUnderlyingPriceDate_ :: (CommodityCurve) -> (Day) -> ([Day]) -> ([String]) -> ([Day]) -> ([Day]) -> ([Day]) -> (Int)
-> IO ((Day))
qlCommodityCurveUnderlyingPriceDate_ a1 a2 a3 a4 a5 a6 a7 a8 =
withGenTermStructure a1 $ \a1' ->
withDay a2 $ \a2' ->
withDayArray a3 $ \(a3'1, a3'2) ->
withStringArray a4 $ \(a4'1, a4'2) ->
withDayArray a5 $ \(a5'1, a5'2) ->
withDayArray a6 $ \(a6'1, a6'2) ->
withDayArray a7 $ \(a7'1, a7'2) ->
let {a8' = fromIntegral a8} in
preErrorCheck $ \a9' ->
qlCommodityCurveUnderlyingPriceDate_'_ a1' a2' a3'1 a3'2 a4'1 a4'2 a5'1 a5'2 a6'1 a6'2 a7'1 a7'2 a8' a9' >>= \res ->
let {res' = toDay res} in
errorCheck a9'>>
return (res')
{-# LINE 159 "./QuantLib/TermStructure/Commodity.chs" #-}
underlyingPriceDate :: CommodityCurve -> Day -> ExchangeContracts -> Int -> IO Day
underlyingPriceDate curve date ecs nearbyOffset =
qlCommodityCurveUnderlyingPriceDate_ curve date keys codes expirations starts ends nearbyOffset
where (keys, codes, expirations, starts, ends) = splitExchangeContracts ecs
foreign import ccall safe "QuantLib/TermStructure/Commodity.chs.h qlCommodityCurve"
qlCommodityCurve'_ :: ((C2HSImp.Ptr C2HSImp.CChar) -> ((C2HSImp.Ptr (CCommodityType)) -> ((C2HSImp.Ptr (CCurrency)) -> ((C2HSImp.Ptr (CUnitOfMeasure)) -> ((C2HSImp.Ptr (CCalendar)) -> (C2HSImp.CUInt -> ((C2HSImp.Ptr C2HSImp.CInt) -> (C2HSImp.CUInt -> ((C2HSImp.Ptr C2HSImp.CDouble) -> ((C2HSImp.Ptr (CDayCounter)) -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO (C2HSImp.Ptr (CCommodityCurve'))))))))))))))
foreign import ccall safe "QuantLib/TermStructure/Commodity.chs.h qlCommodityCurveName"
name'_ :: ((C2HSImp.Ptr (CCommodityCurve')) -> (IO (C2HSImp.Ptr C2HSImp.CChar)))
foreign import ccall safe "QuantLib/TermStructure/Commodity.chs.h qlCommodityCurveCommodityType"
commodityType'_ :: ((C2HSImp.Ptr (CCommodityCurve')) -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO (C2HSImp.Ptr (CCommodityType)))))
foreign import ccall safe "QuantLib/TermStructure/Commodity.chs.h qlCommodityCurveUnitOfMeasure"
unitOfMeasure'_ :: ((C2HSImp.Ptr (CCommodityCurve')) -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO (C2HSImp.Ptr (CUnitOfMeasure)))))
foreign import ccall safe "QuantLib/TermStructure/Commodity.chs.h qlCommodityCurveCurrency"
currency'_ :: ((C2HSImp.Ptr (CCommodityCurve')) -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO (C2HSImp.Ptr (CCurrency)))))
foreign import ccall safe "QuantLib/TermStructure/Commodity.chs.h qlCommodityCurveDates"
qlCommodityCurveDates'_ :: ((C2HSImp.Ptr (CCommodityCurve')) -> ((C2HSImp.Ptr C2HSImp.CUInt) -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CInt)) -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO ())))))
foreign import ccall safe "QuantLib/TermStructure/Commodity.chs.h qlCommodityCurvePrices"
qlCommodityCurvePrices'_ :: ((C2HSImp.Ptr (CCommodityCurve')) -> ((C2HSImp.Ptr C2HSImp.CUInt) -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CDouble)) -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO ())))))
foreign import ccall safe "QuantLib/TermStructure/Commodity.chs.h qlCommodityCurveEmpty"
isEmpty'_ :: ((C2HSImp.Ptr (CCommodityCurve')) -> (IO C2HSImp.CInt))
foreign import ccall safe "QuantLib/TermStructure/Commodity.chs.h qlCommodityCurveBasisOfCurve"
basisOfCurve'_ :: ((C2HSImp.Ptr (CCommodityCurve')) -> (IO (C2HSImp.Ptr (CCommodityCurve'))))
foreign import ccall safe "QuantLib/TermStructure/Commodity.chs.h qlCommodityCurveSetBasisOfCurve"
setBasisOfCurve'_ :: ((C2HSImp.Ptr (CCommodityCurve')) -> ((C2HSImp.Ptr (CCommodityCurve')) -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO ()))))
foreign import ccall safe "QuantLib/TermStructure/Commodity.chs.h qlCommodityCurvePrice"
qlCommodityCurvePrice_'_ :: ((C2HSImp.Ptr (CCommodityCurve')) -> (C2HSImp.CInt -> (C2HSImp.CUInt -> ((C2HSImp.Ptr C2HSImp.CInt) -> (C2HSImp.CUInt -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (C2HSImp.CUInt -> ((C2HSImp.Ptr C2HSImp.CInt) -> (C2HSImp.CUInt -> ((C2HSImp.Ptr C2HSImp.CInt) -> (C2HSImp.CUInt -> ((C2HSImp.Ptr C2HSImp.CInt) -> (C2HSImp.CInt -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO C2HSImp.CDouble)))))))))))))))
foreign import ccall safe "QuantLib/TermStructure/Commodity.chs.h qlCommodityCurveBasisOfPrice"
basisOfPrice'_ :: ((C2HSImp.Ptr (CCommodityCurve')) -> (C2HSImp.CInt -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO C2HSImp.CDouble))))
foreign import ccall safe "QuantLib/TermStructure/Commodity.chs.h qlCommodityCurveUnderlyingPriceDate"
qlCommodityCurveUnderlyingPriceDate_'_ :: ((C2HSImp.Ptr (CCommodityCurve')) -> (C2HSImp.CInt -> (C2HSImp.CUInt -> ((C2HSImp.Ptr C2HSImp.CInt) -> (C2HSImp.CUInt -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (C2HSImp.CUInt -> ((C2HSImp.Ptr C2HSImp.CInt) -> (C2HSImp.CUInt -> ((C2HSImp.Ptr C2HSImp.CInt) -> (C2HSImp.CUInt -> ((C2HSImp.Ptr C2HSImp.CInt) -> (C2HSImp.CInt -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO C2HSImp.CInt)))))))))))))))