never executed always true always false
1 -- GENERATED by C->Haskell Compiler, version 0.28.8 Switcheroo, 25 November 2017 (Haskell)
2 -- Edit the ORIGNAL .chs file instead!
3
4
5 module QuantLib.Index.Commodity
6 (
7 CommodityIndex
8
9 , commodityIndex
10
11 , commodityIndexForwardPrice
12 , commodityIndexLastQuoteDate
13 , commodityIndexEmpty
14 ) where
15 import qualified Foreign.C.String as C2HSImp
16 import qualified Foreign.C.Types as C2HSImp
17 import qualified Foreign.ForeignPtr as C2HSImp
18 import qualified Foreign.Marshal.Utils as C2HSImp
19 import qualified Foreign.Ptr as C2HSImp
20 import qualified System.IO.Unsafe as C2HSImp
21
22
23 import QuantLib.Internal
24 import QuantLib.Internal.Type
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45 -- |A named commodity index, whose fixings forecast from an optional forward 'CommodityCurve'
46 -- (or fall back to a stored historical fixing when none is given -- add one via
47 -- 'QuantLib.Index.addFixing'). Upstream's constructor also takes an
48 -- @ExchangeContracts@\/nearby-offset pair for rolling onto nearby exchange contracts; this binds
49 -- only the no-rolling case (a null @exchangeContracts@ and offset 0), the same scope this module's
50 -- 'QuantLib.TermStructure.Commodity.CommodityCurve' already narrowed 'commodityCurvePrice' to.
51 -- No inspector is bound for commodity type\/currency\/unit of measure\/lot quantity\/forward
52 -- curve: each is a plain, never-mutated echo of this constructor's own argument -- the caller
53 -- already holds whatever it passed in, so a getter would tell it nothing new.
54 commodityIndex :: (String) -- ^name
55 -> (CommodityType) -> (Currency) -> (UnitOfMeasure) -> (Calendar) -> (Double) -- ^lotQuantity
56 -> (Maybe CommodityCurve) -- ^forwardCurve
57 -> IO ((CommodityIndex))
58 commodityIndex a1 a2 a3 a4 a5 a6 a7 =
59 C2HSImp.withCString a1 $ \a1' ->
60 withCommodityType a2 $ \a2' ->
61 withCurrency a3 $ \a3' ->
62 withUnitOfMeasure a4 $ \a4' ->
63 withCalendar a5 $ \a5' ->
64 let {a6' = realToFrac a6} in
65 withMaybeCommodityCurve a7 $ \a7' ->
66 preErrorCheck $ \a8' ->
67 commodityIndex'_ a1' a2' a3' a4' a5' a6' a7' a8' >>= \res ->
68 peekCommodityIndex res >>= \res' ->
69 errorCheck a8'>>
70 return (res')
71
72
73
74 -- |The forecast forward price for a date, from the forward curve.
75 commodityIndexForwardPrice :: (CommodityIndex) -> (Day) -> IO ((Double))
76 commodityIndexForwardPrice a1 a2 =
77 withCommodityIndex a1 $ \a1' ->
78 withDay a2 $ \a2' ->
79 preErrorCheck $ \a3' ->
80 commodityIndexForwardPrice'_ a1' a2' a3' >>= \res ->
81 let {res' = realToFrac res} in
82 errorCheck a3'>>
83 return (res')
84
85
86
87 -- |The most recent date with a stored historical fixing. Throws if none has been added yet --
88 -- check 'commodityIndexEmpty' first if that's a possibility.
89 commodityIndexLastQuoteDate :: (CommodityIndex) -> IO ((Day))
90 commodityIndexLastQuoteDate a1 =
91 withCommodityIndex a1 $ \a1' ->
92 preErrorCheck $ \a2' ->
93 commodityIndexLastQuoteDate'_ a1' a2' >>= \res ->
94 let {res' = toDay res} in
95 errorCheck a2'>>
96 return (res')
97
98
99
100 -- |Whether this index has any stored historical fixings.
101 commodityIndexEmpty :: (CommodityIndex) -> (Bool)
102 commodityIndexEmpty a1 =
103 C2HSImp.unsafePerformIO $
104 withCommodityIndex a1 $ \a1' ->
105 commodityIndexEmpty'_ a1' >>= \res ->
106 let {res' = C2HSImp.toBool res} in
107 return (res')
108
109
110
111 -- vim: set ff=unix ts=8 sts=2 sw=2 et:
112
113 foreign import ccall safe "QuantLib/Index/Commodity.chs.h qlCommodityIndex"
114 commodityIndex'_ :: ((C2HSImp.Ptr C2HSImp.CChar) -> ((C2HSImp.Ptr (CCommodityType)) -> ((C2HSImp.Ptr (CCurrency)) -> ((C2HSImp.Ptr (CUnitOfMeasure)) -> ((C2HSImp.Ptr (CCalendar)) -> (C2HSImp.CDouble -> ((C2HSImp.Ptr (CCommodityCurve')) -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO (C2HSImp.Ptr (CCommodityIndex')))))))))))
115
116 foreign import ccall safe "QuantLib/Index/Commodity.chs.h qlCommodityIndexForwardPrice"
117 commodityIndexForwardPrice'_ :: ((C2HSImp.Ptr (CCommodityIndex')) -> (C2HSImp.CInt -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO C2HSImp.CDouble))))
118
119 foreign import ccall safe "QuantLib/Index/Commodity.chs.h qlCommodityIndexLastQuoteDate"
120 commodityIndexLastQuoteDate'_ :: ((C2HSImp.Ptr (CCommodityIndex')) -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO C2HSImp.CInt)))
121
122 foreign import ccall safe "QuantLib/Index/Commodity.chs.h qlCommodityIndexEmpty"
123 commodityIndexEmpty'_ :: ((C2HSImp.Ptr (CCommodityIndex')) -> (IO C2HSImp.CInt))