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 -- |global repository for run-time library settings
6 module QuantLib.Settings
7 (
8 evaluationDate
9 , setEvaluationDate
10 , enforceTodaysHistoricFixings
11 , setEnforceTodaysHistoricFixings
12 , includeTodaysCashFlows
13 , setIncludeTodaysCashFlows
14 , includeReferenceDateEvents
15 , setIncludeReferenceDateEvents
16
17 , keepingSettings
18 , keepingSettings'
19 , version
20 , boostVersion
21 , epsilon
22 ) where
23 import qualified Foreign.C.Types as C2HSImp
24 import qualified Foreign.Marshal.Utils as C2HSImp
25 import qualified Foreign.Ptr as C2HSImp
26
27
28 import Foreign.C.Types(CDouble)
29 import Foreign.C.String(CString, peekCString)
30 import System.IO.Unsafe(unsafePerformIO)
31 import System.Mem(performGC)
32 import Control.Exception(bracket)
33
34 import QuantLib.Time.Date
35 import QuantLib.Internal
36
37
38
39
40 -- |returns the current value of the Evaluation Date:
41 -- the date at which pricing is to be performed
42 evaluationDate :: IO ((Day))
43 evaluationDate =
44 evaluationDate'_ >>= \res ->
45 let {res' = toDay res} in
46 return (res')
47
48
49
50 -- |sets the value of the Evaluation Date
51 -- |Nothing sets the evaluation date to Date::todaysDate() and allow it to change at midnight. This comes at the price of losing some performance, since the evaluation date is re-evaluated each time it is read.
52 setEvaluationDate :: (Maybe Day) -> IO ()
53 setEvaluationDate a1 =
54 withMaybeDay a1 $ \a1' ->
55 preErrorCheck $ \a2' ->
56 setEvaluationDate'_ a1' a2' >>
57 errorCheck a2'>>
58 return ()
59
60
61
62 -- |returns the current value of the boolean which enforce the usage of historic
63 -- fixings for today's date
64 enforceTodaysHistoricFixings :: IO ((Bool))
65 enforceTodaysHistoricFixings =
66 enforceTodaysHistoricFixings'_ >>= \res ->
67 let {res' = C2HSImp.toBool res} in
68 return (res')
69
70
71
72 -- |sets the value of the boolean which enforce the usage of historic fixings
73 -- for today's date
74 setEnforceTodaysHistoricFixings :: (Bool) -> IO ()
75 setEnforceTodaysHistoricFixings a1 =
76 let {a1' = C2HSImp.fromBool a1} in
77 setEnforceTodaysHistoricFixings'_ a1' >>
78 return ()
79
80
81
82 -- |if set, whether CashFlows occurring on today's date should enter the NPV; when the NPV date
83 -- equals today's date this overrides includeReferenceDateEvents and cannot be overridden locally
84 includeTodaysCashFlows :: IO ((Maybe Bool))
85 includeTodaysCashFlows =
86 includeTodaysCashFlows'_ >>= \res ->
87 let {res' = toMaybeBool res} in
88 return (res')
89
90
91
92 -- |sets whether CashFlows occurring on today's date should enter the NPV
93 setIncludeTodaysCashFlows :: (Maybe Bool) -> IO ()
94 setIncludeTodaysCashFlows a1 =
95 let {a1' = fromMaybeBool a1} in
96 setIncludeTodaysCashFlows'_ a1' >>
97 return ()
98
99
100
101 -- |This flag specifies whether or not Events occurring on the reference date should, by default, be taken into account as not happened yet. It can be overridden locally when calling the Event::hasOccurred method.
102 includeReferenceDateEvents :: IO ((Bool))
103 includeReferenceDateEvents =
104 includeReferenceDateEvents'_ >>= \res ->
105 let {res' = C2HSImp.toBool res} in
106 return (res')
107
108
109
110 -- |sets whether Events occurring on the reference date should, by default, be taken into account as not happened yet
111 setIncludeReferenceDateEvents :: (Bool) -> IO ()
112 setIncludeReferenceDateEvents a1 =
113 let {a1' = C2HSImp.fromBool a1} in
114 setIncludeReferenceDateEvents'_ a1' >>
115 return ()
116
117
118
119 -- |brackets to restore settings once action has completed or raised an exception
120 keepingSettings :: IO b -> IO b
121 keepingSettings = bracket qlSavedSettings qlFreeSavedSettings . const
122 -- SavedSettings destructor suppresses all exceptions
123
124 -- |brackets to restore settings once action has completed or raised an exception. Before restoring settings
125 -- garbage collection is run to avoid problems with market data objects watching evaluation date
126 keepingSettings' :: IO b -> IO b
127 keepingSettings' = bracket qlSavedSettings (\s -> performGC >> qlFreeSavedSettings s) . const
128
129 foreign import ccall safe "ql.h qlVersion" qlVersion :: IO CString
130 foreign import ccall safe "ql.h qlBoostVersion" qlBoostVersion :: IO CString
131 foreign import ccall safe "ql.h qlEpsilon" qlEpsilon :: CDouble
132
133 {-# NOINLINE version #-}
134 version :: String
135 version = unsafePerformIO $ qlVersion >>= peekCString
136
137 {-# NOINLINE boostVersion #-}
138 boostVersion :: String
139 boostVersion = unsafePerformIO $ qlBoostVersion >>= peekCString
140
141 epsilon :: Double
142 epsilon = realToFrac qlEpsilon
143
144 -- vim: set ff=unix ts=8 sts=2 sw=2 et:
145
146 foreign import ccall safe "QuantLib/Settings.chs.h qlSettingsEvaluationDate"
147 evaluationDate'_ :: (IO C2HSImp.CInt)
148
149 foreign import ccall safe "QuantLib/Settings.chs.h qlSettingsSetEvaluationDate"
150 setEvaluationDate'_ :: (C2HSImp.CInt -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO ())))
151
152 foreign import ccall safe "QuantLib/Settings.chs.h qlSettingsEnforceTodaysHistoricFixings"
153 enforceTodaysHistoricFixings'_ :: (IO C2HSImp.CInt)
154
155 foreign import ccall safe "QuantLib/Settings.chs.h qlSettingsSetEnforceTodaysHistoricFixings"
156 setEnforceTodaysHistoricFixings'_ :: (C2HSImp.CInt -> (IO ()))
157
158 foreign import ccall safe "QuantLib/Settings.chs.h qlSettingsIncludeTodaysCashFlows"
159 includeTodaysCashFlows'_ :: (IO C2HSImp.CInt)
160
161 foreign import ccall safe "QuantLib/Settings.chs.h qlSettingsSetIncludeTodaysCashFlows"
162 setIncludeTodaysCashFlows'_ :: (C2HSImp.CInt -> (IO ()))
163
164 foreign import ccall safe "QuantLib/Settings.chs.h qlSettingsIncludeReferenceDateEvents"
165 includeReferenceDateEvents'_ :: (IO C2HSImp.CInt)
166
167 foreign import ccall safe "QuantLib/Settings.chs.h qlSettingsSetIncludeReferenceDateEvents"
168 setIncludeReferenceDateEvents'_ :: (C2HSImp.CInt -> (IO ()))