never executed always true always false
1 {-# LANGUAGE RankNTypes, TypeFamilies, TypeOperators, FlexibleContexts, FlexibleInstances #-}
2 module QuantLib.Internal.Type where
3 import Foreign.Ptr(Ptr, FunPtr, nullPtr, nullFunPtr, freeHaskellFunPtr)
4 import Foreign.ForeignPtr(ForeignPtr, FinalizerPtr, newForeignPtr, withForeignPtr)
5 import Foreign.C.Types(CUInt(..), CInt, CDouble(..))
6 import Foreign.C.String(CString)
7 import Foreign.Marshal.Array(withArray, peekArray, pokeArray)
8 import Foreign.Marshal.Utils(withMany)
9 import Foreign.Storable(peek)
10
11 import Control.Monad((>=>))
12 import System.IO.Unsafe(unsafePerformIO)
13
14 import QuantLib.Internal(peekDynString, preArray, peekDayArray, peekPtrArray)
15 import Control.Exception (finally, mask)
16
17 (<.>) :: Functor f => (b -> r) -> (a -> f b) -> a -> f r
18 f1 <.> f2 = fmap f1 . f2
19
20 -- STANDALONE TYPES
21 newtype Standalone a = Standalone (ForeignPtr a)
22 foreign import ccall "dynamic" callFinalizer :: FinalizerPtr a -> Ptr a -> IO ()
23 class Finalizable a where
24 finalize :: FinalizerPtr a
25 peekStandalone :: Finalizable a => Ptr a -> IO (Standalone a)
26 peekStandalone = Standalone <.> newForeignPtr finalize
27 withStandalone :: Standalone a -> (Ptr a -> IO b) -> IO b
28 withStandalone (Standalone p) = withForeignPtr p
29 withMaybeStandalone :: Maybe (Standalone a) -> (Ptr a -> IO b) -> IO b
30 withMaybeStandalone x f = maybe (f nullPtr) (`withStandalone` f) x
31 withStandaloneArray :: (t -> Standalone a) -> [t] -> ((CUInt, Ptr (Ptr a)) -> IO b) -> IO b
32 withStandaloneArray c x f = withMany withStandalone (map c x) (`withArray` (\px -> f (fromIntegral $ length x, px)))
33 -- The name of a QuantLib object is fixed for its lifetime, so reading it through
34 -- unsafePerformIO is safe; NOINLINE keeps GHC from duplicating or floating the C++
35 -- call, matching how QuantLib.Settings guards its own unsafePerformIO sites.
36 showStandalone :: (Ptr a -> IO CString) -> Standalone a -> String
37 showStandalone f x = unsafePerformIO $ withStandalone x (f >=> peekDynString)
38 {-# NOINLINE showStandalone #-}
39
40 -- On `safe' vs `unsafe' imports, file-wide (this was an open TODO; it is settled):
41 -- * The `&qlFreeX' finalizer imports below take a symbol *address*, not a call, so their
42 -- `unsafe' annotation is inert. The call that matters is `callFinalizer' above, plus
43 -- whatever the GC runs; both are safe.
44 -- * Everything that runs QuantLib logic stays `safe'. Under the non-threaded RTS an
45 -- `unsafe' call blocks GC and the scheduler for its whole duration, and pricing or
46 -- bootstrapping is unbounded.
47 -- * The qlXAsY upcast shims are the one legitimate `unsafe' candidate -- bare
48 -- `ret(new QlY(*arg(o)))', no callback into Haskell, bounded work -- but they are
49 -- already dominated by the QuantLib call they precede, so leave them `safe' absent a
50 -- measurement; a per-shim rule would break the first time one grows logic.
51 -- If a Haskell callback is ever passed into C++, every import on that path must be `safe'.
52 --
53 -- 'withCostFunction' below is the first such callback: it turns a Haskell @[Double] -> Double@
54 -- into a C function pointer QuantLib's optimizer calls back into once per outer iteration (the
55 -- whole parameter vector, not per component) -- the coarsened-callback shape documented in
56 -- CLAUDE.md's "coarsen the language-boundary crossing" bullet, modeled on QuantLib-SWIG's own
57 -- @PyCostFunction@ (@SWIG/functions.i@).
58 foreign import ccall "wrapper" mkCostFunPtr
59 :: (Ptr CDouble -> CUInt -> IO CDouble) -> IO (FunPtr (Ptr CDouble -> CUInt -> IO CDouble))
60 -- Build a C function pointer around a Haskell cost function for the duration of one 'optimize'
61 -- call, freeing it with 'freeHaskellFunPtr' once the continuation returns, whether normally or
62 -- via exception.
63 withCostFunction :: ([Double] -> Double) -> (FunPtr (Ptr CDouble -> CUInt -> IO CDouble) -> IO b) -> IO b
64 withCostFunction f g = mask $ \restore -> do
65 fp <- mkCostFunPtr call
66 restore (g fp) `finally` freeHaskellFunPtr fp
67 where
68 call xs n = do
69 x <- peekArray (fromIntegral n) xs
70 pure (realToFrac (f (map realToFrac x)))
71
72 -- 'fdmRollback' (QuantLib.Method) is the second callback-into-Haskell hook, driving
73 -- @FdmBackwardSolver::rollback@ with a Haskell-defined 'FdmLinearOpComposite' (three callbacks:
74 -- apply/apply_direction/solve_splitting) and an optional step condition -- see CLAUDE.md's
75 -- "coarsen the language-boundary crossing" bullet and 'withCostFunction' above, whose
76 -- mask\/finally\/freeHaskellFunPtr bracket this reuses verbatim, once per callback (four
77 -- independent with-style marshallers, not a single tuple-returning one, so each composes as an
78 -- ordinary c2hs @{#fun#}@ argument exactly like 'withCostFunction' does for 'optimize').
79 --
80 -- Every callback's raw C signature is @(in, n, <extra scalar args>, out)@: a caller-owned input
81 -- buffer of length @n@, then whatever scalars the specific virtual takes (direction, the
82 -- splitting parameter @s@, the @(t1,t2)@ time pair QuantLib's own @setTime@ stashes and threads
83 -- through -- never a callback of its own, since it only ever stores two doubles), then a
84 -- caller-owned *output* buffer also of length @n@. 'pokeBoundedFdmResult' is the one new safety
85 -- property beyond 'withCostFunction' (which returns a single scalar, so has no analogous hazard):
86 -- the C++ side's output buffer is exactly @n@ doubles, so a too-long Haskell result list must
87 -- never be poked past that -- 'pokeBoundedFdmResult' truncates (a too-short list numerically
88 -- wrong but safe, implicit-zero-padded).
89 pokeBoundedFdmResult :: CUInt -> Ptr CDouble -> [Double] -> IO ()
90 pokeBoundedFdmResult n out result = pokeArray out (map realToFrac (take (fromIntegral n) (result ++ repeat 0)))
91
92 type FdmApplyFun = Ptr CDouble -> CUInt -> CDouble -> CDouble -> Ptr CDouble -> IO ()
93 foreign import ccall "wrapper" mkFdmApplyFunPtr :: FdmApplyFun -> IO (FunPtr FdmApplyFun)
94 -- |Wrap a Haskell @(t1,t2) -> grid -> grid'@ function (QuantLib's @FdmLinearOp::apply@\/
95 -- @FdmLinearOpComposite::apply@, no direction argument) as a 'FdmApplyFun' C callback for the
96 -- duration of one 'QuantLib.Method.fdmRollback' call.
97 withFdmApply :: ((Double, Double) -> [Double] -> [Double]) -> (FunPtr FdmApplyFun -> IO b) -> IO b
98 withFdmApply f g = mask $ \restore -> do
99 fp <- mkFdmApplyFunPtr call
100 restore (g fp) `finally` freeHaskellFunPtr fp
101 where
102 call xs n t1 t2 out = do
103 x <- peekArray (fromIntegral n) xs
104 pokeBoundedFdmResult n out (f (realToFrac t1, realToFrac t2) (map realToFrac x))
105
106 type FdmApplyDirectionFun = Ptr CDouble -> CUInt -> CUInt -> CDouble -> CDouble -> Ptr CDouble -> IO ()
107 foreign import ccall "wrapper" mkFdmApplyDirectionFunPtr :: FdmApplyDirectionFun -> IO (FunPtr FdmApplyDirectionFun)
108 -- |Wrap a Haskell @direction -> (t1,t2) -> grid -> grid'@ function
109 -- (@FdmLinearOpComposite::apply_direction@) as an 'FdmApplyDirectionFun' C callback.
110 withFdmApplyDirection :: (Int -> (Double, Double) -> [Double] -> [Double]) -> (FunPtr FdmApplyDirectionFun -> IO b) -> IO b
111 withFdmApplyDirection f g = mask $ \restore -> do
112 fp <- mkFdmApplyDirectionFunPtr call
113 restore (g fp) `finally` freeHaskellFunPtr fp
114 where
115 call xs n dir t1 t2 out = do
116 x <- peekArray (fromIntegral n) xs
117 pokeBoundedFdmResult n out (f (fromIntegral dir) (realToFrac t1, realToFrac t2) (map realToFrac x))
118
119 type FdmSolveSplittingFun = Ptr CDouble -> CUInt -> CUInt -> CDouble -> CDouble -> CDouble -> Ptr CDouble -> IO ()
120 foreign import ccall "wrapper" mkFdmSolveSplittingFunPtr :: FdmSolveSplittingFun -> IO (FunPtr FdmSolveSplittingFun)
121 -- |Wrap a Haskell @direction -> s -> (t1,t2) -> grid -> grid'@ function
122 -- (@FdmLinearOpComposite::solve_splitting@) as an 'FdmSolveSplittingFun' C callback.
123 withFdmSolveSplitting :: (Int -> Double -> (Double, Double) -> [Double] -> [Double]) -> (FunPtr FdmSolveSplittingFun -> IO b) -> IO b
124 withFdmSolveSplitting f g = mask $ \restore -> do
125 fp <- mkFdmSolveSplittingFunPtr call
126 restore (g fp) `finally` freeHaskellFunPtr fp
127 where
128 call xs n dir s t1 t2 out = do
129 x <- peekArray (fromIntegral n) xs
130 pokeBoundedFdmResult n out (f (fromIntegral dir) (realToFrac s) (realToFrac t1, realToFrac t2) (map realToFrac x))
131
132 type FdmStepConditionFun = Ptr CDouble -> CUInt -> CDouble -> Ptr CDouble -> IO ()
133 foreign import ccall "wrapper" mkFdmStepConditionFunPtr :: FdmStepConditionFun -> IO (FunPtr FdmStepConditionFun)
134 -- |Wrap an optional Haskell @t -> grid -> grid'@ early-exercise\/barrier-style step condition
135 -- (@StepCondition\<Array\>::applyTo@) as an 'FdmStepConditionFun' C callback, or a null 'FunPtr'
136 -- when there is no step condition -- mirrors the existing @withMaybeX@ convention (e.g.
137 -- 'withMaybeCurrency' above) of passing a null pointer for 'Nothing' rather than a separate
138 -- present\/absent flag.
139 withMaybeFdmStepCondition :: Maybe (Double -> [Double] -> [Double]) -> (FunPtr FdmStepConditionFun -> IO b) -> IO b
140 withMaybeFdmStepCondition Nothing g = g nullFunPtr
141 withMaybeFdmStepCondition (Just f) g = mask $ \restore -> do
142 fp <- mkFdmStepConditionFunPtr call
143 restore (g fp) `finally` freeHaskellFunPtr fp
144 where
145 call xs n t out = do
146 x <- peekArray (fromIntegral n) xs
147 pokeBoundedFdmResult n out (f (realToFrac t) (map realToFrac x))
148
149 type FdmInnerValueFun = Ptr CDouble -> CUInt -> CDouble -> IO CDouble
150 foreign import ccall "wrapper" mkFdmInnerValueFunPtr :: FdmInnerValueFun -> IO (FunPtr FdmInnerValueFun)
151 -- |Wrap a Haskell @t -> nodeLocation -> value@ function as an 'FdmInnerValueFun' C callback, for
152 -- either of @FdmInnerValueCalculator::innerValue@\/@avgInnerValue@ -- the one hook in this file
153 -- that is a genuine, uncoarsened per-grid-node callback rather than a whole-grid one (see
154 -- 'QuantLib.Method.fdmSolve' and its accompanying haddock for why no batched shape exists here,
155 -- matching QuantLib-SWIG's own @FdmInnerValueCalculatorDelegate@). Reuses the same
156 -- mask\/finally\/freeHaskellFunPtr bracket as 'withCostFunction' above; unlike the
157 -- 'FdmApplyFun'-family callbacks, this one returns a single scalar so has no
158 -- 'pokeBoundedFdmResult'-style output-length hazard.
159 withFdmInnerValue :: (Double -> [Double] -> Double) -> (FunPtr FdmInnerValueFun -> IO b) -> IO b
160 withFdmInnerValue f g = mask $ \restore -> do
161 fp <- mkFdmInnerValueFunPtr call
162 restore (g fp) `finally` freeHaskellFunPtr fp
163 where
164 call locPtr n t = do
165 loc <- peekArray (fromIntegral n) locPtr
166 pure (realToFrac (f (realToFrac t) (map realToFrac loc)))
167
168 type FdmGridMappingFun = CDouble -> IO CDouble
169 foreign import ccall "wrapper" mkFdmGridMappingFunPtr :: FdmGridMappingFun -> IO (FunPtr FdmGridMappingFun)
170 -- |Wrap a Haskell @Double -> Double@ function as an 'FdmGridMappingFun' C callback, for
171 -- @FdmCellAveragingInnerValue@'s optional @gridMapping@ (@QuantLib.Method.withCustomCellAveragingInnerValue@)
172 -- -- another genuine per-node callback (invoked from inside @avgInnerValueCalc@'s Simpson
173 -- integration and from every @innerValue@ call), same reasoning as 'withFdmInnerValue' above.
174 withFdmGridMapping :: (Double -> Double) -> (FunPtr FdmGridMappingFun -> IO b) -> IO b
175 withFdmGridMapping f g = mask $ \restore -> do
176 fp <- mkFdmGridMappingFunPtr call
177 restore (g fp) `finally` freeHaskellFunPtr fp
178 where
179 call x = pure (realToFrac (f (realToFrac x)))
180
181 type PayoffFun = CDouble -> IO CDouble
182 foreign import ccall "wrapper" mkPayoffFunPtr :: PayoffFun -> IO (FunPtr PayoffFun)
183 -- |Wrap a Haskell @price -> value@ function as a 'PayoffFun' C callback, for
184 -- @QuantLib.Internal.Common.withCustomPayoff@. Another genuine, uncoarsened callback: QuantLib's
185 -- @Payoff::operator()@ takes one scalar price everywhere it is called -- per tree node in
186 -- @DiscretizedVanillaOption@, inside @FdmCellAveragingInnerValue@'s per-cell Simpson integral, per
187 -- path per exercise index in @AmericanPathPricer@ -- and nothing upstream batches an @Array@, so
188 -- there is no whole-vector shape to coarsen to (same situation as 'withFdmInnerValue' above).
189 withPayoffFun :: (Double -> Double) -> (FunPtr PayoffFun -> IO b) -> IO b
190 withPayoffFun f g = mask $ \restore -> do
191 fp <- mkPayoffFunPtr call
192 restore (g fp) `finally` freeHaskellFunPtr fp
193 where
194 call x = pure (realToFrac (f (realToFrac x)))
195
196 type BasketAccumulateFun = Ptr CDouble -> CUInt -> IO CDouble
197 foreign import ccall "wrapper" mkBasketAccumulateFunPtr :: BasketAccumulateFun -> IO (FunPtr BasketAccumulateFun)
198 -- |Wrap a Haskell @underlyings -> accumulated@ function as a 'BasketAccumulateFun' C callback, for
199 -- @QuantLib.Internal.Common.withCustomBasketPayoff@. Unlike 'withPayoffFun' this one /is/ already
200 -- coarsened by upstream's own interface: @BasketPayoff::accumulate@ takes the whole underlying-state
201 -- @Array@ per call, not one component at a time.
202 withBasketAccumulateFun :: ([Double] -> Double) -> (FunPtr BasketAccumulateFun -> IO b) -> IO b
203 withBasketAccumulateFun f g = mask $ \restore -> do
204 fp <- mkBasketAccumulateFunPtr call
205 restore (g fp) `finally` freeHaskellFunPtr fp
206 where
207 call xs n = do
208 x <- peekArray (fromIntegral n) xs
209 pure (realToFrac (f (map realToFrac x)))
210
211 -- |The unary callback a Haskell-defined @DerivedQuote@ crosses on, for
212 -- @QuantLib.Quote.withDerivedQuote@. Same C signature as 'PayoffFun', so it reuses
213 -- 'withPayoffFun' rather than duplicating the @wrapper@ import; the alias exists so the quote
214 -- bindings read in their own terms.
215 type QuoteUnaryFun = PayoffFun
216
217 -- |As 'QuoteUnaryFun', but for @MultiCompositeQuote@ (@QuantLib.Quote.withMultiCompositeQuote@):
218 -- same C signature as 'BasketAccumulateFun', and coarsened the same way -- upstream hands the
219 -- whole element vector over per evaluation.
220 type QuoteArrayFun = BasketAccumulateFun
221
222 type QuoteBinaryFun = CDouble -> CDouble -> IO CDouble
223 foreign import ccall "wrapper" mkQuoteBinaryFunPtr :: QuoteBinaryFun -> IO (FunPtr QuoteBinaryFun)
224 -- |Wrap a Haskell @value1 -> value2 -> value@ function as a 'QuoteBinaryFun' C callback, for
225 -- @QuantLib.Quote.withCompositeQuote@. The genuinely new arity of the three: @CompositeQuote@'s
226 -- @BinaryFunction@ takes both element values at once, so there is nothing to coarsen -- one
227 -- crossing per @Quote::value()@ evaluation is already the whole computation.
228 withQuoteBinaryFun :: (Double -> Double -> Double) -> (FunPtr QuoteBinaryFun -> IO b) -> IO b
229 withQuoteBinaryFun f g = mask $ \restore -> do
230 fp <- mkQuoteBinaryFunPtr call
231 restore (g fp) `finally` freeHaskellFunPtr fp
232 where
233 call x y = pure (realToFrac (f (realToFrac x) (realToFrac y)))
234
235 data CCalendar
236 newtype Calendar = Calendar {getCCalendar :: Standalone CCalendar}
237 instance Finalizable CCalendar where finalize = qlFreeCalendar
238 foreign import ccall unsafe "ql.h &qlFreeCalendar" qlFreeCalendar :: FinalizerPtr CCalendar
239 peekCalendar :: Ptr CCalendar -> IO Calendar
240 peekCalendar = Calendar <.> peekStandalone
241 withCalendar :: Calendar -> (Ptr CCalendar -> IO b) -> IO b
242 withCalendar = withStandalone . getCCalendar
243 foreign import ccall safe "ql.h qlCalendarName" qlCalendarName :: Ptr CCalendar -> IO CString
244 instance Show Calendar where show x = showStandalone qlCalendarName (getCCalendar x)
245 -- Equality by name, here and for the Currency/Region/DayCounter/Schedule instances
246 -- below. This is deliberate: it is how QuantLib itself compares these types.
247 instance Eq Calendar where x == y = show x == show y
248
249 data CCurrency
250 newtype Currency = Currency {getCCurrency :: Standalone CCurrency}
251 foreign import ccall unsafe "ql.h &qlFreeCurrency" qlFreeCurrency :: FinalizerPtr CCurrency
252 instance Finalizable CCurrency where finalize = qlFreeCurrency
253 peekCurrency :: Ptr CCurrency -> IO Currency
254 peekCurrency = Currency <.> peekStandalone
255 withCurrency :: Currency -> (Ptr CCurrency -> IO b) -> IO b
256 withCurrency = withStandalone . getCCurrency
257 withMaybeCurrency :: Maybe Currency -> (Ptr CCurrency -> IO b) -> IO b
258 withMaybeCurrency = withMaybeStandalone . (getCCurrency <$>)
259 peekMaybeCurrency :: Ptr CCurrency -> IO (Maybe Currency)
260 peekMaybeCurrency p
261 | p == nullPtr = pure Nothing
262 | otherwise = Just <$> peekCurrency p
263 -- |Peek a 'Currency' out of a @Currency**@ out-parameter (as opposed to 'peekCurrency', which
264 -- peeks it directly out of a @Currency*@ primary return).
265 peekCurrencyPtr :: Ptr (Ptr CCurrency) -> IO Currency
266 peekCurrencyPtr = peek >=> peekCurrency
267 -- |Split a @(Double, Currency)@ cash amount (QuantLib's 'Money', per the @Period@-as-tuple
268 -- convention) into the @(double, Currency*)@ pair of C arguments it marshals to, for use with
269 -- the c2hs @&@ splitter -- the input-direction counterpart of 'peekCurrencyPtr'.
270 withMoney :: (Double, Currency) -> ((CDouble, Ptr CCurrency) -> IO b) -> IO b
271 withMoney (amount, ccy) f = withCurrency ccy (\p -> f (realToFrac amount, p))
272 foreign import ccall safe "ql.h qlCurrencyName" qlCurrencyName :: Ptr CCurrency -> IO CString
273 instance Show Currency where show x = showStandalone qlCurrencyName (getCCurrency x)
274 instance Eq Currency where x == y = show x == show y
275
276 data CCommodityType
277 newtype CommodityType = CommodityType {getCCommodityType :: Standalone CCommodityType}
278 foreign import ccall unsafe "ql.h &qlFreeCommodityType" qlFreeCommodityType :: FinalizerPtr CCommodityType
279 instance Finalizable CCommodityType where finalize = qlFreeCommodityType
280 peekCommodityType :: Ptr CCommodityType -> IO CommodityType
281 peekCommodityType = CommodityType <.> peekStandalone
282 withCommodityType :: CommodityType -> (Ptr CCommodityType -> IO b) -> IO b
283 withCommodityType = withStandalone . getCCommodityType
284 withMaybeCommodityType :: Maybe CommodityType -> (Ptr CCommodityType -> IO b) -> IO b
285 withMaybeCommodityType = withMaybeStandalone . (getCCommodityType <$>)
286 peekMaybeCommodityType :: Ptr CCommodityType -> IO (Maybe CommodityType)
287 peekMaybeCommodityType p
288 | p == nullPtr = pure Nothing
289 | otherwise = Just <$> peekCommodityType p
290 foreign import ccall safe "ql.h qlCommodityTypeCode" qlCommodityTypeCode :: Ptr CCommodityType -> IO CString
291 instance Show CommodityType where show x = showStandalone qlCommodityTypeCode (getCCommodityType x)
292 instance Eq CommodityType where x == y = show x == show y
293 -- |Peek a 'CommodityType' out of a @CommodityType**@ out-parameter (as opposed to
294 -- 'peekCommodityType', which peeks it directly out of a @CommodityType*@ primary return).
295 peekCommodityTypePtr :: Ptr (Ptr CCommodityType) -> IO CommodityType
296 peekCommodityTypePtr = peek >=> peekCommodityType
297
298 data CUnitOfMeasure
299 newtype UnitOfMeasure = UnitOfMeasure {getCUnitOfMeasure :: Standalone CUnitOfMeasure}
300 foreign import ccall unsafe "ql.h &qlFreeUnitOfMeasure" qlFreeUnitOfMeasure :: FinalizerPtr CUnitOfMeasure
301 instance Finalizable CUnitOfMeasure where finalize = qlFreeUnitOfMeasure
302 peekUnitOfMeasure :: Ptr CUnitOfMeasure -> IO UnitOfMeasure
303 peekUnitOfMeasure = UnitOfMeasure <.> peekStandalone
304 withUnitOfMeasure :: UnitOfMeasure -> (Ptr CUnitOfMeasure -> IO b) -> IO b
305 withUnitOfMeasure = withStandalone . getCUnitOfMeasure
306 withMaybeUnitOfMeasure :: Maybe UnitOfMeasure -> (Ptr CUnitOfMeasure -> IO b) -> IO b
307 withMaybeUnitOfMeasure = withMaybeStandalone . (getCUnitOfMeasure <$>)
308 peekMaybeUnitOfMeasure :: Ptr CUnitOfMeasure -> IO (Maybe UnitOfMeasure)
309 peekMaybeUnitOfMeasure p
310 | p == nullPtr = pure Nothing
311 | otherwise = Just <$> peekUnitOfMeasure p
312 foreign import ccall safe "ql.h qlUnitOfMeasureCode" qlUnitOfMeasureCode :: Ptr CUnitOfMeasure -> IO CString
313 instance Show UnitOfMeasure where show x = showStandalone qlUnitOfMeasureCode (getCUnitOfMeasure x)
314 instance Eq UnitOfMeasure where x == y = show x == show y
315 -- |Peek a 'UnitOfMeasure' out of a @UnitOfMeasure**@ out-parameter (as opposed to
316 -- 'peekUnitOfMeasure', which peeks it directly out of a @UnitOfMeasure*@ primary return).
317 peekUnitOfMeasurePtr :: Ptr (Ptr CUnitOfMeasure) -> IO UnitOfMeasure
318 peekUnitOfMeasurePtr = peek >=> peekUnitOfMeasure
319
320 data CPaymentTerm
321 newtype PaymentTerm = PaymentTerm {getCPaymentTerm :: Standalone CPaymentTerm}
322 foreign import ccall unsafe "ql.h &qlFreePaymentTerm" qlFreePaymentTerm :: FinalizerPtr CPaymentTerm
323 instance Finalizable CPaymentTerm where finalize = qlFreePaymentTerm
324 peekPaymentTerm :: Ptr CPaymentTerm -> IO PaymentTerm
325 peekPaymentTerm = PaymentTerm <.> peekStandalone
326 withPaymentTerm :: PaymentTerm -> (Ptr CPaymentTerm -> IO b) -> IO b
327 withPaymentTerm = withStandalone . getCPaymentTerm
328 withMaybePaymentTerm :: Maybe PaymentTerm -> (Ptr CPaymentTerm -> IO b) -> IO b
329 withMaybePaymentTerm = withMaybeStandalone . (getCPaymentTerm <$>)
330 peekMaybePaymentTerm :: Ptr CPaymentTerm -> IO (Maybe PaymentTerm)
331 peekMaybePaymentTerm p
332 | p == nullPtr = pure Nothing
333 | otherwise = Just <$> peekPaymentTerm p
334 foreign import ccall safe "ql.h qlPaymentTermName" qlPaymentTermName :: Ptr CPaymentTerm -> IO CString
335 instance Show PaymentTerm where show x = showStandalone qlPaymentTermName (getCPaymentTerm x)
336 instance Eq PaymentTerm where x == y = show x == show y
337
338 data CUnitOfMeasureConversion
339 newtype UnitOfMeasureConversion = UnitOfMeasureConversion {getCUnitOfMeasureConversion :: Standalone CUnitOfMeasureConversion}
340 foreign import ccall unsafe "ql.h &qlFreeUnitOfMeasureConversion" qlFreeUnitOfMeasureConversion :: FinalizerPtr CUnitOfMeasureConversion
341 instance Finalizable CUnitOfMeasureConversion where finalize = qlFreeUnitOfMeasureConversion
342 peekUnitOfMeasureConversion :: Ptr CUnitOfMeasureConversion -> IO UnitOfMeasureConversion
343 peekUnitOfMeasureConversion = UnitOfMeasureConversion <.> peekStandalone
344 withUnitOfMeasureConversion :: UnitOfMeasureConversion -> (Ptr CUnitOfMeasureConversion -> IO b) -> IO b
345 withUnitOfMeasureConversion = withStandalone . getCUnitOfMeasureConversion
346 foreign import ccall safe "ql.h qlUnitOfMeasureConversionCode" qlUnitOfMeasureConversionCode :: Ptr CUnitOfMeasureConversion -> IO CString
347 instance Show UnitOfMeasureConversion where show x = showStandalone qlUnitOfMeasureConversionCode (getCUnitOfMeasureConversion x)
348 instance Eq UnitOfMeasureConversion where x == y = show x == show y
349
350 data CExchangeRate
351 newtype ExchangeRate = ExchangeRate {getCExchangeRate :: Standalone CExchangeRate}
352 foreign import ccall unsafe "ql.h &qlFreeExchangeRate" qlFreeExchangeRate :: FinalizerPtr CExchangeRate
353 instance Finalizable CExchangeRate where finalize = qlFreeExchangeRate
354 peekExchangeRate :: Ptr CExchangeRate -> IO ExchangeRate
355 peekExchangeRate = ExchangeRate <.> peekStandalone
356 withExchangeRate :: ExchangeRate -> (Ptr CExchangeRate -> IO b) -> IO b
357 withExchangeRate = withStandalone . getCExchangeRate
358
359 data CRegion
360 newtype Region = Region {getCRegion :: Standalone CRegion}
361 foreign import ccall unsafe "ql.h &qlFreeRegion" qlFreeRegion :: FinalizerPtr CRegion
362 instance Finalizable CRegion where finalize = qlFreeRegion
363 peekRegion :: Ptr CRegion -> IO Region
364 peekRegion = Region <.> peekStandalone
365 withRegion :: Region -> (Ptr CRegion -> IO b) -> IO b
366 withRegion = withStandalone . getCRegion
367 foreign import ccall safe "ql.h qlRegionName" qlRegionName :: Ptr CRegion -> IO CString
368 instance Show Region where show x = showStandalone qlRegionName (getCRegion x)
369 instance Eq Region where x == y = show x == show y
370
371 data CDayCounter
372 newtype DayCounter = DayCounter {getCDayCounter :: Standalone CDayCounter}
373 foreign import ccall unsafe "ql.h &qlFreeDayCounter" qlFreeDayCounter :: FinalizerPtr CDayCounter
374 instance Finalizable CDayCounter where finalize = qlFreeDayCounter
375 peekDayCounter :: Ptr CDayCounter -> IO DayCounter
376 peekDayCounter = DayCounter <.> peekStandalone
377 withDayCounter :: DayCounter -> (Ptr CDayCounter -> IO b) -> IO b
378 withDayCounter = withStandalone . getCDayCounter
379 foreign import ccall safe "ql.h qlDayCounterName" qlDayCounterName :: Ptr CDayCounter -> IO CString
380 instance Show DayCounter where show x = showStandalone qlDayCounterName (getCDayCounter x)
381 instance Eq DayCounter where x == y = show x == show y
382
383 data CSchedule
384 newtype Schedule = Schedule {getCSchedule :: Standalone CSchedule}
385 foreign import ccall unsafe "ql.h &qlFreeSchedule" qlFreeSchedule :: FinalizerPtr CSchedule
386 instance Finalizable CSchedule where finalize = qlFreeSchedule
387 peekSchedule :: Ptr CSchedule -> IO Schedule
388 peekSchedule = Schedule <.> peekStandalone
389 withSchedule :: Schedule -> (Ptr CSchedule -> IO b) -> IO b
390 withSchedule = withStandalone . getCSchedule
391 foreign import ccall safe "ql.h qlScheduleDates" qlScheduleDates :: Ptr CSchedule -> Ptr CUInt -> Ptr (Ptr CInt) -> IO ()
392 showSchedule :: Schedule -> String
393 showSchedule x = unsafePerformIO $ withSchedule x $ \p ->
394 show <$> preArray (\(cp, ap) -> qlScheduleDates p cp ap >> peekDayArray cp ap)
395 {-# NOINLINE showSchedule #-}
396
397 instance Show Schedule where
398 show = showSchedule
399 instance Eq Schedule where
400 x == y = show x == show y
401
402 data CInterestRate
403 newtype InterestRate = InterestRate {getCInterestRate :: Standalone CInterestRate}
404 foreign import ccall unsafe "ql.h &qlFreeInterestRate" qlFreeInterestRate :: FinalizerPtr CInterestRate
405 instance Finalizable CInterestRate where finalize = qlFreeInterestRate
406 peekInterestRate :: Ptr CInterestRate -> IO InterestRate
407 peekInterestRate = InterestRate <.> peekStandalone
408 withInterestRate :: InterestRate -> (Ptr CInterestRate -> IO b) -> IO b
409 withInterestRate = withStandalone . getCInterestRate
410 withInterestRateArray :: [InterestRate] -> ((CUInt, Ptr (Ptr CInterestRate)) -> IO b) -> IO b
411 withInterestRateArray = withStandaloneArray getCInterestRate
412
413 data CTimeGrid
414 newtype TimeGrid = TimeGrid {getCTimeGrid :: Standalone CTimeGrid}
415 foreign import ccall unsafe "ql.h &qlFreeTimeGrid" qlFreeTimeGrid :: FinalizerPtr CTimeGrid
416 instance Finalizable CTimeGrid where finalize = qlFreeTimeGrid
417 peekTimeGrid :: Ptr CTimeGrid -> IO TimeGrid
418 peekTimeGrid = TimeGrid <.> peekStandalone
419 withTimeGrid :: TimeGrid -> (Ptr CTimeGrid -> IO b) -> IO b
420 withTimeGrid = withStandalone . getCTimeGrid
421
422 -- |Never subclassed and never passed polymorphically elsewhere, so it gets the plain
423 -- 'Standalone' shape (like 'TimeGrid') rather than a 'GenX'/'AnyOf' hierarchy root.
424 data CHistoricalIndexAnalysis
425 newtype HistoricalIndexAnalysis = HistoricalIndexAnalysis {getCHistoricalIndexAnalysis :: Standalone CHistoricalIndexAnalysis}
426 foreign import ccall unsafe "ql.h &qlFreeHistoricalIndexAnalysis" qlFreeHistoricalIndexAnalysis :: FinalizerPtr CHistoricalIndexAnalysis
427 instance Finalizable CHistoricalIndexAnalysis where finalize = qlFreeHistoricalIndexAnalysis
428 peekHistoricalIndexAnalysis :: Ptr CHistoricalIndexAnalysis -> IO HistoricalIndexAnalysis
429 peekHistoricalIndexAnalysis = HistoricalIndexAnalysis <.> peekStandalone
430 withHistoricalIndexAnalysis :: HistoricalIndexAnalysis -> (Ptr CHistoricalIndexAnalysis -> IO b) -> IO b
431 withHistoricalIndexAnalysis = withStandalone . getCHistoricalIndexAnalysis
432
433 data CDividend
434 newtype Dividend = Dividend {getCDividend :: Standalone CDividend}
435 foreign import ccall unsafe "ql.h &qlFreeDividend" qlFreeDividend :: FinalizerPtr CDividend
436 instance Finalizable CDividend where finalize = qlFreeDividend
437 peekDividend :: Ptr CDividend -> IO Dividend
438 peekDividend = Dividend <.> peekStandalone
439 withDividend :: Dividend -> (Ptr CDividend -> IO b) -> IO b
440 withDividend = withStandalone . getCDividend
441 withDividendArray :: [Dividend] -> ((CUInt, Ptr (Ptr CDividend)) -> IO b) -> IO b
442 withDividendArray = withStandaloneArray getCDividend
443
444 data CFdmQuantoHelper
445 newtype FdmQuantoHelper = FdmQuantoHelper {getCFdmQuantoHelper :: Standalone CFdmQuantoHelper}
446 foreign import ccall unsafe "ql.h &qlFreeFdmQuantoHelper" qlFreeFdmQuantoHelper :: FinalizerPtr CFdmQuantoHelper
447 instance Finalizable CFdmQuantoHelper where finalize = qlFreeFdmQuantoHelper
448 peekFdmQuantoHelper :: Ptr CFdmQuantoHelper -> IO FdmQuantoHelper
449 peekFdmQuantoHelper = FdmQuantoHelper <.> peekStandalone
450 withFdmQuantoHelper :: FdmQuantoHelper -> (Ptr CFdmQuantoHelper -> IO b) -> IO b
451 withFdmQuantoHelper = withStandalone . getCFdmQuantoHelper
452 withMaybeFdmQuantoHelper :: Maybe FdmQuantoHelper -> (Ptr CFdmQuantoHelper -> IO b) -> IO b
453 withMaybeFdmQuantoHelper = withMaybeStandalone . (getCFdmQuantoHelper <$>)
454
455 data CFdm1dMesher
456 newtype Fdm1dMesher = Fdm1dMesher {getCFdm1dMesher :: Standalone CFdm1dMesher}
457 foreign import ccall unsafe "ql.h &qlFreeFdm1dMesher" qlFreeFdm1dMesher :: FinalizerPtr CFdm1dMesher
458 instance Finalizable CFdm1dMesher where finalize = qlFreeFdm1dMesher
459 peekFdm1dMesher :: Ptr CFdm1dMesher -> IO Fdm1dMesher
460 peekFdm1dMesher = Fdm1dMesher <.> peekStandalone
461 withFdm1dMesher :: Fdm1dMesher -> (Ptr CFdm1dMesher -> IO b) -> IO b
462 withFdm1dMesher = withStandalone . getCFdm1dMesher
463 withFdm1dMesherArray :: [Fdm1dMesher] -> ((CUInt, Ptr (Ptr CFdm1dMesher)) -> IO b) -> IO b
464 withFdm1dMesherArray = withStandaloneArray getCFdm1dMesher
465
466 data CFdmMesher
467 newtype FdmMesher = FdmMesher {getCFdmMesher :: Standalone CFdmMesher}
468 foreign import ccall unsafe "ql.h &qlFreeFdmMesher" qlFreeFdmMesher :: FinalizerPtr CFdmMesher
469 instance Finalizable CFdmMesher where finalize = qlFreeFdmMesher
470 peekFdmMesher :: Ptr CFdmMesher -> IO FdmMesher
471 peekFdmMesher = FdmMesher <.> peekStandalone
472 withFdmMesher :: FdmMesher -> (Ptr CFdmMesher -> IO b) -> IO b
473 withFdmMesher = withStandalone . getCFdmMesher
474
475 data CFdmInnerValueCalculator
476 newtype FdmInnerValueCalculator = FdmInnerValueCalculator {getCFdmInnerValueCalculator :: Standalone CFdmInnerValueCalculator}
477 foreign import ccall unsafe "ql.h &qlFreeFdmInnerValueCalculator" qlFreeFdmInnerValueCalculator :: FinalizerPtr CFdmInnerValueCalculator
478 instance Finalizable CFdmInnerValueCalculator where finalize = qlFreeFdmInnerValueCalculator
479 peekFdmInnerValueCalculator :: Ptr CFdmInnerValueCalculator -> IO FdmInnerValueCalculator
480 peekFdmInnerValueCalculator = FdmInnerValueCalculator <.> peekStandalone
481 withFdmInnerValueCalculator :: FdmInnerValueCalculator -> (Ptr CFdmInnerValueCalculator -> IO b) -> IO b
482 withFdmInnerValueCalculator = withStandalone . getCFdmInnerValueCalculator
483
484 data CZeroInflationCashFlow
485 newtype ZeroInflationCashFlow = ZeroInflationCashFlow {getCZeroInflationCashFlow :: Standalone CZeroInflationCashFlow}
486 foreign import ccall unsafe "ql.h &qlFreeZeroInflationCashFlow" qlFreeZeroInflationCashFlow :: FinalizerPtr CZeroInflationCashFlow
487 instance Finalizable CZeroInflationCashFlow where finalize = qlFreeZeroInflationCashFlow
488 peekZeroInflationCashFlow :: Ptr CZeroInflationCashFlow -> IO ZeroInflationCashFlow
489 peekZeroInflationCashFlow = ZeroInflationCashFlow <.> peekStandalone
490 withZeroInflationCashFlow :: ZeroInflationCashFlow -> (Ptr CZeroInflationCashFlow -> IO b) -> IO b
491 withZeroInflationCashFlow = withStandalone . getCZeroInflationCashFlow
492
493 data CCPICashFlow
494 newtype CPICashFlow = CPICashFlow {getCCPICashFlow :: Standalone CCPICashFlow}
495 foreign import ccall unsafe "ql.h &qlFreeCPICashFlow" qlFreeCPICashFlow :: FinalizerPtr CCPICashFlow
496 instance Finalizable CCPICashFlow where finalize = qlFreeCPICashFlow
497 peekCPICashFlow :: Ptr CCPICashFlow -> IO CPICashFlow
498 peekCPICashFlow = CPICashFlow <.> peekStandalone
499 withCPICashFlow :: CPICashFlow -> (Ptr CCPICashFlow -> IO b) -> IO b
500 withCPICashFlow = withStandalone . getCCPICashFlow
501
502 data CEquityCashFlow
503 newtype EquityCashFlow = EquityCashFlow {getCEquityCashFlow :: Standalone CEquityCashFlow}
504 foreign import ccall unsafe "ql.h &qlFreeEquityCashFlow" qlFreeEquityCashFlow :: FinalizerPtr CEquityCashFlow
505 instance Finalizable CEquityCashFlow where finalize = qlFreeEquityCashFlow
506 peekEquityCashFlow :: Ptr CEquityCashFlow -> IO EquityCashFlow
507 peekEquityCashFlow = EquityCashFlow <.> peekStandalone
508 withEquityCashFlow :: EquityCashFlow -> (Ptr CEquityCashFlow -> IO b) -> IO b
509 withEquityCashFlow = withStandalone . getCEquityCashFlow
510
511 data CSmileSection
512 newtype SmileSection = SmileSection {getCSmileSection :: Standalone CSmileSection}
513 foreign import ccall unsafe "ql.h &qlFreeSmileSection" qlFreeSmileSection :: FinalizerPtr CSmileSection
514 instance Finalizable CSmileSection where finalize = qlFreeSmileSection
515 peekSmileSection :: Ptr CSmileSection -> IO SmileSection
516 peekSmileSection = SmileSection <.> peekStandalone
517 withSmileSection :: SmileSection -> (Ptr CSmileSection -> IO b) -> IO b
518 withSmileSection = withStandalone . getCSmileSection
519
520 -- |a dedicated leaf, not a downcast target: 'QuantLib.TermStructure.Volatility.sabrInterpolatedSmileSection'
521 -- returns this concrete type directly so its alpha\/beta\/nu\/rho\/etc getters need no
522 -- runtime cast to reach them (see CLAUDE.md's "avoid dynamic_cast unless upstream forces it"
523 -- rule). Use 'QuantLib.TermStructure.Volatility.sabrInterpolatedSmileSectionAsSmileSection' to
524 -- pass one into anything that wants the generic 'SmileSection' interface.
525 data CSabrInterpolatedSmileSection
526 newtype SabrInterpolatedSmileSection = SabrInterpolatedSmileSection {getCSabrInterpolatedSmileSection :: Standalone CSabrInterpolatedSmileSection}
527 foreign import ccall unsafe "ql.h &qlFreeSabrInterpolatedSmileSection" qlFreeSabrInterpolatedSmileSection :: FinalizerPtr CSabrInterpolatedSmileSection
528 instance Finalizable CSabrInterpolatedSmileSection where finalize = qlFreeSabrInterpolatedSmileSection
529 peekSabrInterpolatedSmileSection :: Ptr CSabrInterpolatedSmileSection -> IO SabrInterpolatedSmileSection
530 peekSabrInterpolatedSmileSection = SabrInterpolatedSmileSection <.> peekStandalone
531 withSabrInterpolatedSmileSection :: SabrInterpolatedSmileSection -> (Ptr CSabrInterpolatedSmileSection -> IO b) -> IO b
532 withSabrInterpolatedSmileSection = withStandalone . getCSabrInterpolatedSmileSection
533
534 -- |a dedicated leaf, not a downcast target: 'QuantLib.TermStructure.Volatility.optionletStripper2'
535 -- fuses construction of an 'OptionletStripper1' underneath (never exposed to Haskell, mirroring
536 -- 'QuantLib.TermStructure.Volatility.optionletStripper1') and stores the resulting
537 -- @OptionletStripper2@ itself, so its own diagnostic getters (atmCapFloorStrikes\/atmCapFloorPrices\/
538 -- spreadsVol) need no runtime cast. Use
539 -- 'QuantLib.TermStructure.Volatility.optionletStripper2AsOptionletVolatilityStructure' to pass one
540 -- into anything that wants the generic 'OptionletVolatilityStructure' interface.
541 data COptionletStripper2
542 newtype OptionletStripper2 = OptionletStripper2 {getCOptionletStripper2 :: Standalone COptionletStripper2}
543 foreign import ccall unsafe "ql.h &qlFreeOptionletStripper2" qlFreeOptionletStripper2 :: FinalizerPtr COptionletStripper2
544 instance Finalizable COptionletStripper2 where finalize = qlFreeOptionletStripper2
545 peekOptionletStripper2 :: Ptr COptionletStripper2 -> IO OptionletStripper2
546 peekOptionletStripper2 = OptionletStripper2 <.> peekStandalone
547 withOptionletStripper2 :: OptionletStripper2 -> (Ptr COptionletStripper2 -> IO b) -> IO b
548 withOptionletStripper2 = withStandalone . getCOptionletStripper2
549
550 data CPricingEngine
551 newtype PricingEngine = PricingEngine {getCPricingEngine :: Standalone CPricingEngine}
552 foreign import ccall unsafe "ql.h &qlFreePricingEngine" qlFreePricingEngine :: FinalizerPtr CPricingEngine
553 instance Finalizable CPricingEngine where finalize = qlFreePricingEngine
554 peekPricingEngine :: Ptr CPricingEngine -> IO PricingEngine
555 peekPricingEngine = PricingEngine <.> peekStandalone
556 withPricingEngine :: PricingEngine -> (Ptr CPricingEngine -> IO b) -> IO b
557 withPricingEngine = withStandalone . getCPricingEngine
558
559 data CBlackDeltaCalculator
560 newtype BlackDeltaCalculator = BlackDeltaCalculator {getCBlackDeltaCalculator :: Standalone CBlackDeltaCalculator}
561 foreign import ccall unsafe "ql.h &qlFreeBlackDeltaCalculator" qlFreeBlackDeltaCalculator :: FinalizerPtr CBlackDeltaCalculator
562 instance Finalizable CBlackDeltaCalculator where finalize = qlFreeBlackDeltaCalculator
563 peekBlackDeltaCalculator :: Ptr CBlackDeltaCalculator -> IO BlackDeltaCalculator
564 peekBlackDeltaCalculator = BlackDeltaCalculator <.> peekStandalone
565 withBlackDeltaCalculator :: BlackDeltaCalculator -> (Ptr CBlackDeltaCalculator -> IO b) -> IO b
566 withBlackDeltaCalculator = withStandalone . getCBlackDeltaCalculator
567
568 data CFloatingRateCouponPricer
569 newtype FloatingRateCouponPricer = FloatingRateCouponPricer {getCFloatingRateCouponPricer :: Standalone CFloatingRateCouponPricer}
570 foreign import ccall unsafe "ql.h &qlFreeFloatingCouponPricer" qlFreeFloatingRateCouponPricer :: FinalizerPtr CFloatingRateCouponPricer
571 instance Finalizable CFloatingRateCouponPricer where finalize = qlFreeFloatingRateCouponPricer
572 peekFloatingRateCouponPricer :: Ptr CFloatingRateCouponPricer -> IO FloatingRateCouponPricer
573 peekFloatingRateCouponPricer = FloatingRateCouponPricer <.> peekStandalone
574 withFloatingRateCouponPricer :: FloatingRateCouponPricer -> (Ptr CFloatingRateCouponPricer -> IO b) -> IO b
575 withFloatingRateCouponPricer = withStandalone . getCFloatingRateCouponPricer
576 withFloatingRateCouponPricerArray :: [FloatingRateCouponPricer] -> ((CUInt, Ptr (Ptr CFloatingRateCouponPricer)) -> IO b) -> IO b
577 withFloatingRateCouponPricerArray = withStandaloneArray getCFloatingRateCouponPricer
578 withMaybeFloatingRateCouponPricer :: Maybe FloatingRateCouponPricer -> (Ptr CFloatingRateCouponPricer -> IO b) -> IO b
579 withMaybeFloatingRateCouponPricer = maybe ($ nullPtr) withFloatingRateCouponPricer
580
581 data CEquityCashFlowPricer
582 newtype EquityCashFlowPricer = EquityCashFlowPricer {getCEquityCashFlowPricer :: Standalone CEquityCashFlowPricer}
583 foreign import ccall unsafe "ql.h &qlFreeEquityCashFlowPricer" qlFreeEquityCashFlowPricer :: FinalizerPtr CEquityCashFlowPricer
584 instance Finalizable CEquityCashFlowPricer where finalize = qlFreeEquityCashFlowPricer
585 peekEquityCashFlowPricer :: Ptr CEquityCashFlowPricer -> IO EquityCashFlowPricer
586 peekEquityCashFlowPricer = EquityCashFlowPricer <.> peekStandalone
587 withEquityCashFlowPricer :: EquityCashFlowPricer -> (Ptr CEquityCashFlowPricer -> IO b) -> IO b
588 withEquityCashFlowPricer = withStandalone . getCEquityCashFlowPricer
589
590 data CYoYInflationCouponPricer
591 -- | Pricer for capped\/floored 'QuantLib.CashFlow.yoyInflationLeg' coupons. All 3 concrete
592 -- upstream pricers (Black\/UnitDisplacedBlack\/Bachelier) share one ctor shape and are bound as
593 -- constructors of this single type, mirroring 'FloatingRateCouponPricer'\/'EquityCashFlowPricer'
594 -- (a standalone pricer type, not part of any 'GenX' hierarchy).
595 newtype YoYInflationCouponPricer = YoYInflationCouponPricer {getCYoYInflationCouponPricer :: Standalone CYoYInflationCouponPricer}
596 foreign import ccall unsafe "ql.h &qlFreeYoYInflationCouponPricer" qlFreeYoYInflationCouponPricer :: FinalizerPtr CYoYInflationCouponPricer
597 instance Finalizable CYoYInflationCouponPricer where finalize = qlFreeYoYInflationCouponPricer
598 peekYoYInflationCouponPricer :: Ptr CYoYInflationCouponPricer -> IO YoYInflationCouponPricer
599 peekYoYInflationCouponPricer = YoYInflationCouponPricer <.> peekStandalone
600 withYoYInflationCouponPricer :: YoYInflationCouponPricer -> (Ptr CYoYInflationCouponPricer -> IO b) -> IO b
601 withYoYInflationCouponPricer = withStandalone . getCYoYInflationCouponPricer
602
603 data CDefaultProbabilityHelper
604 newtype DefaultProbabilityHelper = DefaultProbabilityHelper {getCDefaultProbabilityHelper :: Standalone CDefaultProbabilityHelper}
605 foreign import ccall unsafe "ql.h &qlFreeDefaultProbabilityHelper" qlFreeDefaultProbabilityHelper :: FinalizerPtr CDefaultProbabilityHelper
606 instance Finalizable CDefaultProbabilityHelper where finalize = qlFreeDefaultProbabilityHelper
607 peekDefaultProbabilityHelper :: Ptr CDefaultProbabilityHelper -> IO DefaultProbabilityHelper
608 peekDefaultProbabilityHelper = DefaultProbabilityHelper <.> peekStandalone
609 withDefaultProbabilityHelper :: DefaultProbabilityHelper -> (Ptr CDefaultProbabilityHelper -> IO b) -> IO b
610 withDefaultProbabilityHelper = withStandalone . getCDefaultProbabilityHelper
611 withDefaultProbabilityHelperArray :: [DefaultProbabilityHelper] -> ((CUInt, Ptr (Ptr CDefaultProbabilityHelper)) -> IO b) -> IO b
612 withDefaultProbabilityHelperArray = withStandaloneArray getCDefaultProbabilityHelper
613
614 data CZeroCouponInflationSwapHelper
615 newtype ZeroCouponInflationSwapHelper = ZeroCouponInflationSwapHelper {getCZeroCouponInflationSwapHelper :: Standalone CZeroCouponInflationSwapHelper}
616 foreign import ccall unsafe "ql.h &qlFreeZeroCouponInflationSwapHelper" qlFreeZeroCouponInflationSwapHelper :: FinalizerPtr CZeroCouponInflationSwapHelper
617 instance Finalizable CZeroCouponInflationSwapHelper where finalize = qlFreeZeroCouponInflationSwapHelper
618 peekZeroCouponInflationSwapHelper :: Ptr CZeroCouponInflationSwapHelper -> IO ZeroCouponInflationSwapHelper
619 peekZeroCouponInflationSwapHelper = ZeroCouponInflationSwapHelper <.> peekStandalone
620 withZeroCouponInflationSwapHelper :: ZeroCouponInflationSwapHelper -> (Ptr CZeroCouponInflationSwapHelper -> IO b) -> IO b
621 withZeroCouponInflationSwapHelper = withStandalone . getCZeroCouponInflationSwapHelper
622 withZeroCouponInflationSwapHelperArray :: [ZeroCouponInflationSwapHelper] -> ((CUInt, Ptr (Ptr CZeroCouponInflationSwapHelper)) -> IO b) -> IO b
623 withZeroCouponInflationSwapHelperArray = withStandaloneArray getCZeroCouponInflationSwapHelper
624
625 data CYearOnYearInflationSwapHelper
626 newtype YearOnYearInflationSwapHelper = YearOnYearInflationSwapHelper {getCYearOnYearInflationSwapHelper :: Standalone CYearOnYearInflationSwapHelper}
627 foreign import ccall unsafe "ql.h &qlFreeYearOnYearInflationSwapHelper" qlFreeYearOnYearInflationSwapHelper :: FinalizerPtr CYearOnYearInflationSwapHelper
628 instance Finalizable CYearOnYearInflationSwapHelper where finalize = qlFreeYearOnYearInflationSwapHelper
629 peekYearOnYearInflationSwapHelper :: Ptr CYearOnYearInflationSwapHelper -> IO YearOnYearInflationSwapHelper
630 peekYearOnYearInflationSwapHelper = YearOnYearInflationSwapHelper <.> peekStandalone
631 withYearOnYearInflationSwapHelper :: YearOnYearInflationSwapHelper -> (Ptr CYearOnYearInflationSwapHelper -> IO b) -> IO b
632 withYearOnYearInflationSwapHelper = withStandalone . getCYearOnYearInflationSwapHelper
633 withYearOnYearInflationSwapHelperArray :: [YearOnYearInflationSwapHelper] -> ((CUInt, Ptr (Ptr CYearOnYearInflationSwapHelper)) -> IO b) -> IO b
634 withYearOnYearInflationSwapHelperArray = withStandaloneArray getCYearOnYearInflationSwapHelper
635
636 data CPathGenerator
637 newtype PathGenerator = PathGenerator {getCPathGenerator :: Standalone CPathGenerator}
638 foreign import ccall unsafe "ql.h &qlFreePathGenerator" qlFreePathGenerator :: FinalizerPtr CPathGenerator
639 instance Finalizable CPathGenerator where finalize = qlFreePathGenerator
640 peekPathGenerator :: Ptr CPathGenerator -> IO PathGenerator
641 peekPathGenerator = PathGenerator <.> peekStandalone
642 withPathGenerator :: PathGenerator -> (Ptr CPathGenerator -> IO b) -> IO b
643 withPathGenerator = withStandalone . getCPathGenerator
644
645 data CSamplePath
646 newtype SamplePath = SamplePath {getCSamplePath :: Standalone CSamplePath}
647 foreign import ccall unsafe "ql.h &qlFreeSamplePath" qlFreeSamplePath :: FinalizerPtr CSamplePath
648 instance Finalizable CSamplePath where finalize = qlFreeSamplePath
649 peekSamplePath :: Ptr CSamplePath -> IO SamplePath
650 peekSamplePath = SamplePath <.> peekStandalone
651 withSamplePath :: SamplePath -> (Ptr CSamplePath -> IO b) -> IO b
652 withSamplePath = withStandalone . getCSamplePath
653
654 -- The gaussian sequence generator a 'PathGenerator' consumes internally, exposed on its own so a
655 -- Haskell-defined SDE can be evolved without a per-timestep callback -- see
656 -- 'QuantLib.Method.gaussianRsg'. A plain standalone object like 'PathGenerator', not a hierarchy
657 -- root: it has no bound subtypes and is never an argument type elsewhere.
658 data CGaussianRsg
659 newtype GaussianRsg = GaussianRsg {getCGaussianRsg :: Standalone CGaussianRsg}
660 foreign import ccall unsafe "ql.h &qlFreeGaussianRsg" qlFreeGaussianRsg :: FinalizerPtr CGaussianRsg
661 instance Finalizable CGaussianRsg where finalize = qlFreeGaussianRsg
662 peekGaussianRsg :: Ptr CGaussianRsg -> IO GaussianRsg
663 peekGaussianRsg = GaussianRsg <.> peekStandalone
664 withGaussianRsg :: GaussianRsg -> (Ptr CGaussianRsg -> IO b) -> IO b
665 withGaussianRsg = withStandalone . getCGaussianRsg
666
667 -- MultiCurve is enable_shared_from_this upstream ("This must be a shared pointer") and builds a
668 -- set of curves that form a genuine dependency cycle; bound as a standalone leaf, not part of
669 -- the TermStructure hierarchy (it isn't a TermStructure itself), mirroring PricingEngine above.
670 data CMultiCurve
671 newtype MultiCurve = MultiCurve {getCMultiCurve :: Standalone CMultiCurve}
672 foreign import ccall unsafe "ql.h &qlFreeMultiCurve" qlFreeMultiCurve :: FinalizerPtr CMultiCurve
673 instance Finalizable CMultiCurve where finalize = qlFreeMultiCurve
674 peekMultiCurve :: Ptr CMultiCurve -> IO MultiCurve
675 peekMultiCurve = MultiCurve <.> peekStandalone
676 withMultiCurve :: MultiCurve -> (Ptr CMultiCurve -> IO b) -> IO b
677 withMultiCurve = withStandalone . getCMultiCurve
678
679 -- special cases: those types will be represented as enums so no need to wrap them
680 data CQlClaim
681 type QlClaim = Standalone CQlClaim
682 foreign import ccall unsafe "ql.h &qlFreeClaim" qlFreeClaim :: FinalizerPtr CQlClaim
683 instance Finalizable CQlClaim where finalize = qlFreeClaim
684 peekClaim :: Ptr CQlClaim -> IO (Standalone CQlClaim)
685 peekClaim = peekStandalone
686
687 data CQlCallability
688 type QlCallability = Standalone CQlCallability
689 foreign import ccall unsafe "ql.h &qlFreeCallability" qlFreeCallability :: FinalizerPtr CQlCallability
690 instance Finalizable CQlCallability where finalize = qlFreeCallability
691 peekCallability :: Ptr CQlCallability -> IO (Standalone CQlCallability)
692 peekCallability = peekStandalone
693
694 data CConstraint
695 type QlConstraint = Standalone CConstraint
696 foreign import ccall unsafe "ql.h &qlFreeConstraint" qlFreeConstraint :: FinalizerPtr CConstraint
697 instance Finalizable CConstraint where finalize = qlFreeConstraint
698 peekConstraint :: Ptr CConstraint -> IO (Standalone CConstraint)
699 peekConstraint = peekStandalone
700
701 data CEndCriteria
702 type QlEndCriteria = Standalone CEndCriteria
703 foreign import ccall unsafe "ql.h &qlFreeEndCriteria" qlFreeEndCriteria :: FinalizerPtr CEndCriteria
704 instance Finalizable CEndCriteria where finalize = qlFreeEndCriteria
705 peekEndCriteria :: Ptr CEndCriteria -> IO (Standalone CEndCriteria)
706 peekEndCriteria = peekStandalone
707
708 data CFdmSchemeDesc
709 type QlFdmSchemeDesc = Standalone CFdmSchemeDesc
710 foreign import ccall unsafe "ql.h &qlFreeFdmSchemeDesc" qlFreeFdmSchemeDesc :: FinalizerPtr CFdmSchemeDesc
711 instance Finalizable CFdmSchemeDesc where finalize = qlFreeFdmSchemeDesc
712 peekFdmSchemeDesc :: Ptr CFdmSchemeDesc -> IO (Standalone CFdmSchemeDesc)
713 peekFdmSchemeDesc = peekStandalone
714
715 data CFittedBondDiscountCurveFittingMethod
716 type QlFittedBondDiscountCurveFittingMethod = Standalone CFittedBondDiscountCurveFittingMethod
717 foreign import ccall unsafe "ql.h &qlFreeFittedBondDiscountCurveFittingMethod" qlFreeFittedBondDiscountCurveFittingMethod :: FinalizerPtr CFittedBondDiscountCurveFittingMethod
718 instance Finalizable CFittedBondDiscountCurveFittingMethod where finalize = qlFreeFittedBondDiscountCurveFittingMethod
719 peekFittedBondDiscountCurveFittingMethod :: Ptr CFittedBondDiscountCurveFittingMethod -> IO (Standalone CFittedBondDiscountCurveFittingMethod)
720 peekFittedBondDiscountCurveFittingMethod = peekStandalone
721
722 data COptimizationMethod
723 type QlOptimizationMethod = Standalone COptimizationMethod
724 foreign import ccall unsafe "ql.h &qlFreeOptimizationMethod" qlFreeOptimizationMethod :: FinalizerPtr COptimizationMethod
725 instance Finalizable COptimizationMethod where finalize = qlFreeOptimizationMethod
726 peekOptimizationMethod :: Ptr COptimizationMethod -> IO (Standalone COptimizationMethod)
727 peekOptimizationMethod = peekStandalone
728
729 data CRounding
730 type QlRounding = Standalone CRounding
731 foreign import ccall unsafe "ql.h &qlFreeRounding" qlFreeRounding :: FinalizerPtr CRounding
732 instance Finalizable CRounding where finalize = qlFreeRounding
733 peekRounding :: Ptr CRounding -> IO (Standalone CRounding)
734 peekRounding = peekStandalone
735
736 data CLmCorrelationModel
737 type QlLmCorrelationModel = Standalone CLmCorrelationModel
738 foreign import ccall unsafe "ql.h &qlFreeLmCorrelationModel" qlFreeLmCorrelationModel :: FinalizerPtr CLmCorrelationModel
739 instance Finalizable CLmCorrelationModel where finalize = qlFreeLmCorrelationModel
740 peekLmCorrelationModel :: Ptr CLmCorrelationModel -> IO (Standalone CLmCorrelationModel)
741 peekLmCorrelationModel = peekStandalone
742
743 data CLmVolatilityModel
744 type QlLmVolatilityModel = Standalone CLmVolatilityModel
745 foreign import ccall unsafe "ql.h &qlFreeLmVolatilityModel" qlFreeLmVolatilityModel :: FinalizerPtr CLmVolatilityModel
746 instance Finalizable CLmVolatilityModel where finalize = qlFreeLmVolatilityModel
747 peekLmVolatilityModel :: Ptr CLmVolatilityModel -> IO (Standalone CLmVolatilityModel)
748 peekLmVolatilityModel = peekStandalone
749
750 -- TYPE HIERARCHIES
751 --
752 -- Each hierarchy root below carries a haddock tree listing every member. Notation:
753 -- indentation parent/child
754 -- `X*' abstract *here*: hasquant binds no constructor returning an X, you only
755 -- obtain one by upcasting. This is not the same as C++ abstractness and
756 -- cannot be derived from it -- Option and Swap are concrete classes
757 -- upstream but unconstructible here, while Quote/Index/TermStructure are
758 -- pure-virtual upstream yet routinely returned by bindings. Marks are
759 -- added where established; an unmarked node is not a claim of the opposite.
760 -- `X + Y' X also reaches secondary interface Y, via the standalone qlXAsY shim,
761 -- materialized eagerly into a `Standalone Y' value by a per-leaf `xAsY'
762 -- function (see CAffineModel' below), not via Upcastable.
763 -- X (CFoo') X's C type, given only where it is not the expected C<X>'.
764 -- Payoff and Exercise are documented in the files that define them, not here.
765 -- the original pointer to `a' with a way to marshal it to `b'
766 -- The access/free pair IS derivable from the structure of `a' (each nested AnyOf layer is
767 -- one upcast; the innermost ForeignPtr is identity or one upcast). It stays a stored
768 -- dictionary because the alternative -- an `Access a b' class -- becomes a constraint at
769 -- every polymorphic use site, and c2hs emits an explicit signature for every {#fun#}: 363
770 -- of 880 hooks take a polymorphic `GenX a' and would each need a hand-written context,
771 -- which would also leak into public API signatures. It buys no correctness -- the smart
772 -- constructors below are already pinned by their result types.
773 data GenForeignPtr a b = GenForeignPtr {
774 ptr :: !a
775 , _access :: !(forall r. a -> (Ptr b -> IO r) -> IO r)
776 , _mayFree :: !(Maybe (Ptr b -> IO ())) -- `free' after upcast is needed
777 }
778
779 freeUpcast :: Finalizable b => Ptr b -> IO ()
780 freeUpcast = callFinalizer finalize
781
782 newtype AnyOf b a = AnyOf { getAnyOf :: GenForeignPtr a b }
783 newAnyOf :: (Upcastable b, Finalizable (Base b)) => GenForeignPtr a b -> GenForeignPtr (AnyOf b a) (Base b)
784 newAnyOf x = GenForeignPtr (AnyOf x)
785 (\(AnyOf i) f -> withGenForeignPtr i (upcast >=> f))
786 (Just freeUpcast)
787
788 class Upcastable a where
789 type Base a
790 upcast :: Ptr a -> IO (Ptr (Base a))
791
792 newGenForeignPtr :: (Finalizable a, Upcastable a, Finalizable (Base a)) => Ptr a -> IO (GenForeignPtr (ForeignPtr a) (Base a))
793 newGenForeignPtr x = do
794 fp <- newForeignPtr finalize x
795 pure $ GenForeignPtr fp (\a f -> withForeignPtr a (upcast >=> f)) (Just freeUpcast)
796
797 newCastForeignPtr :: Finalizable a => Ptr a -> IO (GenForeignPtr (ForeignPtr a) a)
798 newCastForeignPtr x = do
799 fp <- newForeignPtr finalize x
800 pure $ GenForeignPtr fp withForeignPtr Nothing
801
802 -- `access' performs the upcast, which allocates a fresh handle that `mfree' must release, so
803 -- acquiring it and installing the handler have to be atomic -- `mask' covers the upcast
804 -- happening inside `access', and `restore' hands `f' back the caller's masking state. This
805 -- is `bracket' semantics expressed around a continuation that
806 -- allocates internally. Nesting is fine: an inner level's `restore' only wraps the
807 -- continuation that contains the outer `restore', so `f' still runs unmasked.
808 withGenForeignPtr :: GenForeignPtr a b -> (Ptr b -> IO r) -> IO r
809 withGenForeignPtr (GenForeignPtr p access Nothing) f = access p f
810 withGenForeignPtr (GenForeignPtr p access (Just free)) f =
811 mask $ \restore -> access p $ \bp -> restore (f bp) `finally` free bp
812
813 transferGenForeignPtr :: (Ptr b -> IO r) -> GenForeignPtr a b -> IO r
814 transferGenForeignPtr f (GenForeignPtr p access _) = access p f
815
816 withGenArray :: (a -> (Ptr c -> IO r) -> IO r) -> [a] -> ((CUInt, Ptr (Ptr c)) -> IO r) -> IO r
817 withGenArray m x f = withMany m x (`withArray` (\p -> f (fromIntegral $ length x, p)))
818
819 peel :: GenForeignPtr (AnyOf b a) c -> GenForeignPtr a b
820 peel = getAnyOf . ptr
821
822 -- |Arrays of 'CommodityType'\/'UnitOfMeasure' values, first needed by 'QuantLib.Instrument.Energy'
823 -- for marshalling a 'QuantLib.Commodity.PricingPeriods' list to\/from its C-side
824 -- structure-of-parallel-arrays representation (@Quantity@'s @CommodityType@\/@UnitOfMeasure@
825 -- component, split out one array per field, alongside 'QuantLib.Internal.withDayArray'\/'peekDayArray'
826 -- for the date fields and 'QuantLib.Internal.withDoubleArray'\/'peekDoubleArray' for the amount) --
827 -- reusing 'withGenArray'\/'peekPtrArray' exactly as 'withBlackCalibrationHelperArray' does.
828 withCommodityTypeArray :: [CommodityType] -> ((CUInt, Ptr (Ptr CCommodityType)) -> IO b) -> IO b
829 withCommodityTypeArray = withGenArray withCommodityType
830 -- |Output side, first needed by 'QuantLib.Instrument.Energy.createPricingPeriods' (the only
831 -- producer of a fresh 'QuantLib.Commodity.PricingPeriods' list -- every constructor instead
832 -- *consumes* one via 'withCommodityTypeArray').
833 peekCommodityTypeArray :: Ptr CUInt -> Ptr (Ptr (Ptr CCommodityType)) -> IO [CommodityType]
834 peekCommodityTypeArray = peekPtrArray peekCommodityType
835
836 withUnitOfMeasureArray :: [UnitOfMeasure] -> ((CUInt, Ptr (Ptr CUnitOfMeasure)) -> IO b) -> IO b
837 withUnitOfMeasureArray = withGenArray withUnitOfMeasure
838 peekUnitOfMeasureArray :: Ptr CUInt -> Ptr (Ptr (Ptr CUnitOfMeasure)) -> IO [UnitOfMeasure]
839 peekUnitOfMeasureArray = peekPtrArray peekUnitOfMeasure
840
841 -- |A nullable-per-entry array of 'UnitOfMeasure's -- @SecondaryCosts@' per-entry unit of measure,
842 -- present only for its @CommodityUnitCost@ alternative (null for its @Money@ alternative).
843 withMaybeUnitOfMeasureArray :: [Maybe UnitOfMeasure] -> ((CUInt, Ptr (Ptr CUnitOfMeasure)) -> IO b) -> IO b
844 withMaybeUnitOfMeasureArray = withGenArray withMaybeUnitOfMeasure
845
846 -- |An array of 'Currency' values -- @SecondaryCosts@'\/@SecondaryCostAmounts@'s per-entry currency.
847 withCurrencyArray :: [Currency] -> ((CUInt, Ptr (Ptr CCurrency)) -> IO b) -> IO b
848 withCurrencyArray = withGenArray withCurrency
849 peekCurrencyArray :: Ptr CUInt -> Ptr (Ptr (Ptr CCurrency)) -> IO [Currency]
850 peekCurrencyArray = peekPtrArray peekCurrency
851
852 -- | > Quote
853 -- > SimpleQuote
854 -- > DeltaVolQuote
855 -- > RelinkableQuote
856 type Quote = GenQuote CQuote
857 data CQuote'
858 data CSimpleQuote'
859 data CDeltaVolQuote'
860 data CRelinkableQuote'
861 newtype GenQuote q = GenQuote {getQuote :: GenForeignPtr q CQuote'}
862 type CQuote = ForeignPtr CQuote'
863 type CSimpleQuote = ForeignPtr CSimpleQuote'
864 type SimpleQuote = GenQuote CSimpleQuote
865 type CDeltaVolQuote = ForeignPtr CDeltaVolQuote'
866 type DeltaVolQuote = GenQuote CDeltaVolQuote
867 type CRelinkableQuote = ForeignPtr CRelinkableQuote'
868 type RelinkableQuote = GenQuote CRelinkableQuote
869 foreign import ccall unsafe "ql.h &qlFreeQuote" qlFreeQuote :: FinalizerPtr CQuote'
870 foreign import ccall unsafe "ql.h &qlFreeSimpleQuote" qlFreeSimpleQuote :: FinalizerPtr CSimpleQuote'
871 foreign import ccall unsafe "ql.h &qlFreeDeltaVolQuote" qlFreeDeltaVolQuote :: FinalizerPtr CDeltaVolQuote'
872 foreign import ccall unsafe "ql.h &qlFreeRelinkableQuote" qlFreeRelinkableQuote :: FinalizerPtr CRelinkableQuote'
873 instance Finalizable CQuote' where finalize = qlFreeQuote
874 instance Finalizable CSimpleQuote' where finalize = qlFreeSimpleQuote
875 instance Finalizable CDeltaVolQuote' where finalize = qlFreeDeltaVolQuote
876 instance Finalizable CRelinkableQuote' where finalize = qlFreeRelinkableQuote
877 instance Upcastable CSimpleQuote' where {type Base CSimpleQuote' = CQuote'; upcast = qlSimpleQuoteAsQuote}
878 instance Upcastable CDeltaVolQuote' where {type Base CDeltaVolQuote' = CQuote'; upcast = qlDeltaVolQuoteAsQuote}
879 instance Upcastable CRelinkableQuote' where {type Base CRelinkableQuote' = CQuote'; upcast = qlRelinkableQuoteAsQuote}
880 foreign import ccall "ql.h qlSimpleQuoteAsQuote" qlSimpleQuoteAsQuote :: Ptr CSimpleQuote' -> IO (Ptr CQuote')
881 foreign import ccall "ql.h qlDeltaVolQuoteAsQuote" qlDeltaVolQuoteAsQuote :: Ptr CDeltaVolQuote' -> IO (Ptr CQuote')
882 foreign import ccall "ql.h qlRelinkableQuoteAsQuote" qlRelinkableQuoteAsQuote :: Ptr CRelinkableQuote' -> IO (Ptr CQuote')
883 -- Haskell does not allow function arguments like [forall q.GenQuote q]
884 -- let's at least provide a way to convert all quote classes to the most generic one
885 asQuote :: GenQuote q -> IO Quote
886 asQuote = transferGenForeignPtr peekQuote . getQuote
887 peekQuote :: Ptr CQuote' -> IO Quote
888 peekQuote = GenQuote <.> newCastForeignPtr
889 withQuote :: GenQuote q -> (Ptr CQuote' -> IO b) -> IO b
890 withQuote = withGenForeignPtr . getQuote
891 withGenQuote :: GenQuote (ForeignPtr q) -> (Ptr q -> IO b) -> IO b
892 withGenQuote = withForeignPtr . ptr . getQuote
893 peekSimpleQuote :: Ptr CSimpleQuote' -> IO SimpleQuote
894 peekSimpleQuote = GenQuote <.> newGenForeignPtr
895 peekDeltaVolQuote :: Ptr CDeltaVolQuote' -> IO DeltaVolQuote
896 peekDeltaVolQuote = GenQuote <.> newGenForeignPtr
897 peekRelinkableQuote :: Ptr CRelinkableQuote' -> IO RelinkableQuote
898 peekRelinkableQuote = GenQuote <.> newGenForeignPtr
899 withRelinkableQuote :: RelinkableQuote -> (Ptr CRelinkableQuote' -> IO b) -> IO b
900 withRelinkableQuote = withGenQuote
901 withMaybeQuote :: Maybe (GenQuote q) -> (Ptr CQuote' -> IO b) -> IO b
902 withMaybeQuote x f = maybe (f nullPtr) (`withQuote` f) x
903 withQuoteArray :: [GenQuote q] -> ((CUInt, Ptr (Ptr CQuote')) -> IO b) -> IO b
904 withQuoteArray = withGenArray withQuote
905 withQuoteArrayRaw :: [GenQuote q] -> (Ptr (Ptr CQuote') -> IO b) -> IO b
906 withQuoteArrayRaw x f = withMany withQuote x (`withArray` f)
907
908 -- PAYOFF/EXERCISE upcast targets used by QuantLib.Internal.Common's Payoff/Exercise ADT dispatch
909 -- (the ADTs themselves stay in Enum.chs; only the pointer hierarchy plumbing lives here,
910 -- matching every other hierarchy in this module)
911 data CPayoff'
912 foreign import ccall unsafe "ql.h &qlFreePayoff" qlFreePayoff :: FinalizerPtr CPayoff'
913 instance Finalizable CPayoff' where finalize = qlFreePayoff
914
915 data CBasketPayoff'
916 foreign import ccall unsafe "ql.h &qlFreeBasketPayoff" qlFreeBasketPayoff :: FinalizerPtr CBasketPayoff'
917 instance Finalizable CBasketPayoff' where finalize = qlFreeBasketPayoff
918 instance Upcastable CBasketPayoff' where {type Base CBasketPayoff' = CPayoff'; upcast = qlBasketPayoffAsPayoff}
919 foreign import ccall "ql.h qlBasketPayoffAsPayoff" qlBasketPayoffAsPayoff :: Ptr CBasketPayoff' -> IO (Ptr CPayoff')
920
921 data CTypePayoff'
922 foreign import ccall unsafe "ql.h &qlFreeTypePayoff" qlFreeTypePayoff :: FinalizerPtr CTypePayoff'
923 instance Finalizable CTypePayoff' where finalize = qlFreeTypePayoff
924 instance Upcastable CTypePayoff' where {type Base CTypePayoff' = CPayoff'; upcast = qlTypePayoffAsPayoff}
925 foreign import ccall "ql.h qlTypePayoffAsPayoff" qlTypePayoffAsPayoff :: Ptr CTypePayoff' -> IO (Ptr CPayoff')
926
927 data CStrikedTypePayoff'
928 foreign import ccall unsafe "ql.h &qlFreeStrikedTypePayoff" qlFreeStrikedTypePayoff :: FinalizerPtr CStrikedTypePayoff'
929 instance Finalizable CStrikedTypePayoff' where finalize = qlFreeStrikedTypePayoff
930 instance Upcastable CStrikedTypePayoff' where {type Base CStrikedTypePayoff' = CTypePayoff'; upcast = qlStrikedTypePayoffAsTypePayoff}
931 foreign import ccall "ql.h qlStrikedTypePayoffAsTypePayoff" qlStrikedTypePayoffAsTypePayoff :: Ptr CStrikedTypePayoff' -> IO (Ptr CTypePayoff')
932
933 data CPercentageStrikePayoff'
934 foreign import ccall unsafe "ql.h &qlFreePercentageStrikePayoff" qlFreePercentageStrikePayoff :: FinalizerPtr CPercentageStrikePayoff'
935 instance Finalizable CPercentageStrikePayoff' where finalize = qlFreePercentageStrikePayoff
936 instance Upcastable CPercentageStrikePayoff' where {type Base CPercentageStrikePayoff' = CStrikedTypePayoff'; upcast = qlPercentageStrikePayoffAsStrikedTypePayoff}
937 foreign import ccall "ql.h qlPercentageStrikePayoffAsStrikedTypePayoff" qlPercentageStrikePayoffAsStrikedTypePayoff :: Ptr CPercentageStrikePayoff' -> IO (Ptr CStrikedTypePayoff')
938
939 data CPlainVanillaPayoff'
940 foreign import ccall unsafe "ql.h &qlFreePlainVanillaPayoff" qlFreePlainVanillaPayoff :: FinalizerPtr CPlainVanillaPayoff'
941 instance Finalizable CPlainVanillaPayoff' where finalize = qlFreePlainVanillaPayoff
942 instance Upcastable CPlainVanillaPayoff' where {type Base CPlainVanillaPayoff' = CStrikedTypePayoff'; upcast = qlPlainVanillaPayoffAsStrikedTypePayoff}
943 foreign import ccall "ql.h qlPlainVanillaPayoffAsStrikedTypePayoff" qlPlainVanillaPayoffAsStrikedTypePayoff :: Ptr CPlainVanillaPayoff' -> IO (Ptr CStrikedTypePayoff')
944
945 data CExercise'
946 foreign import ccall unsafe "ql.h &qlFreeExercise" qlFreeExercise :: FinalizerPtr CExercise'
947 instance Finalizable CExercise' where finalize = qlFreeExercise
948
949 data CAmericanExercise'
950 foreign import ccall unsafe "ql.h &qlFreeAmericanExercise" qlFreeAmericanExercise :: FinalizerPtr CAmericanExercise'
951 instance Finalizable CAmericanExercise' where finalize = qlFreeAmericanExercise
952 instance Upcastable CAmericanExercise' where {type Base CAmericanExercise' = CExercise'; upcast = qlAmericanExerciseAsExercise}
953 foreign import ccall "ql.h qlAmericanExerciseAsExercise" qlAmericanExerciseAsExercise :: Ptr CAmericanExercise' -> IO (Ptr CExercise')
954
955 data CEuropeanExercise'
956 foreign import ccall unsafe "ql.h &qlFreeEuropeanExercise" qlFreeEuropeanExercise :: FinalizerPtr CEuropeanExercise'
957 instance Finalizable CEuropeanExercise' where finalize = qlFreeEuropeanExercise
958 instance Upcastable CEuropeanExercise' where {type Base CEuropeanExercise' = CExercise'; upcast = qlEuropeanExerciseAsExercise}
959 foreign import ccall "ql.h qlEuropeanExerciseAsExercise" qlEuropeanExerciseAsExercise :: Ptr CEuropeanExercise' -> IO (Ptr CExercise')
960
961 data CBermudanExercise'
962 foreign import ccall unsafe "ql.h &qlFreeBermudanExercise" qlFreeBermudanExercise :: FinalizerPtr CBermudanExercise'
963 instance Finalizable CBermudanExercise' where finalize = qlFreeBermudanExercise
964 instance Upcastable CBermudanExercise' where {type Base CBermudanExercise' = CExercise'; upcast = qlBermudanExerciseAsExercise}
965 foreign import ccall "ql.h qlBermudanExerciseAsExercise" qlBermudanExerciseAsExercise :: Ptr CBermudanExercise' -> IO (Ptr CExercise')
966
967 data CSwingExercise'
968 foreign import ccall unsafe "ql.h &qlFreeSwingExercise" qlFreeSwingExercise :: FinalizerPtr CSwingExercise'
969 instance Finalizable CSwingExercise' where finalize = qlFreeSwingExercise
970 instance Upcastable CSwingExercise' where {type Base CSwingExercise' = CBermudanExercise'; upcast = qlSwingExerciseAsBermudanExercise}
971 foreign import ccall "ql.h qlSwingExerciseAsBermudanExercise" qlSwingExerciseAsBermudanExercise :: Ptr CSwingExercise' -> IO (Ptr CBermudanExercise')
972
973 data CRebatedExercise'
974 foreign import ccall unsafe "ql.h &qlFreeRebatedExercise" qlFreeRebatedExercise :: FinalizerPtr CRebatedExercise'
975 instance Finalizable CRebatedExercise' where finalize = qlFreeRebatedExercise
976 instance Upcastable CRebatedExercise' where {type Base CRebatedExercise' = CExercise'; upcast = qlRebatedExerciseAsExercise}
977 foreign import ccall "ql.h qlRebatedExerciseAsExercise" qlRebatedExerciseAsExercise :: Ptr CRebatedExercise' -> IO (Ptr CExercise')
978
979 data CLeg'
980 data CCouponLeg'
981 newtype GenLeg l = GenLeg {getLeg :: GenForeignPtr l CLeg'}
982 type CLeg = ForeignPtr CLeg'
983 type Leg = GenLeg CLeg
984 type CCouponLeg = ForeignPtr CCouponLeg'
985 type CouponLeg = GenLeg CCouponLeg
986 foreign import ccall unsafe "ql.h &qlFreeLeg" qlFreeLeg :: FinalizerPtr CLeg'
987 foreign import ccall unsafe "ql.h &qlFreeCouponLeg" qlFreeCouponLeg :: FinalizerPtr CCouponLeg'
988 instance Finalizable CLeg' where finalize = qlFreeLeg
989 instance Finalizable CCouponLeg' where finalize = qlFreeCouponLeg
990 foreign import ccall "ql.h qlCouponLegAsLeg" qlCouponLegAsLeg :: Ptr CCouponLeg' -> IO (Ptr CLeg')
991 instance Upcastable CCouponLeg' where {type Base CCouponLeg' = CLeg'; upcast = qlCouponLegAsLeg}
992 asLeg :: GenLeg l -> IO Leg
993 asLeg = transferGenForeignPtr peekLeg . getLeg
994 peekLeg :: Ptr CLeg' -> IO Leg
995 peekLeg = GenLeg <.> newCastForeignPtr
996 withLeg :: GenLeg l -> (Ptr CLeg' -> IO b) -> IO b
997 withLeg = withGenForeignPtr . getLeg
998 withLegArray :: [GenLeg l] -> ((CUInt, Ptr (Ptr CLeg')) -> IO b) -> IO b
999 withLegArray = withGenArray withLeg
1000 withGenLeg :: GenLeg (ForeignPtr l) -> (Ptr l -> IO b) -> IO b
1001 withGenLeg = withForeignPtr . ptr . getLeg
1002 peekCouponLeg :: Ptr CCouponLeg' -> IO CouponLeg
1003 peekCouponLeg = GenLeg <.> newGenForeignPtr
1004
1005 -- | > RateHelper
1006 -- > BondHelper
1007 -- > SwapRateHelper
1008 -- > OISRateHelper
1009 type RateHelper = GenRateHelper CRateHelper
1010 data CRateHelper'
1011 newtype GenRateHelper rh = GenRateHelper {getRateHelper :: GenForeignPtr rh CRateHelper'}
1012 type CRateHelper = ForeignPtr CRateHelper'
1013 foreign import ccall unsafe "ql.h &qlFreeRateHelper" qlFreeRateHelper :: FinalizerPtr CRateHelper'
1014 instance Finalizable CRateHelper' where finalize = qlFreeRateHelper
1015 asRateHelper :: GenRateHelper rh -> IO RateHelper
1016 asRateHelper = transferGenForeignPtr peekRateHelper . getRateHelper
1017 peekRateHelper :: Ptr CRateHelper' -> IO RateHelper
1018 peekRateHelper = GenRateHelper <.> newCastForeignPtr
1019 withRateHelper :: GenRateHelper rh -> (Ptr CRateHelper' -> IO b) -> IO b
1020 withRateHelper = withGenForeignPtr . getRateHelper
1021 withGenRateHelper :: GenRateHelper (ForeignPtr rh) -> (Ptr rh -> IO b) -> IO b
1022 withGenRateHelper = withForeignPtr . ptr . getRateHelper
1023 withRateHelperArray :: [GenRateHelper rh] -> ((CUInt, Ptr (Ptr CRateHelper')) -> IO b) -> IO b
1024 withRateHelperArray = withGenArray withRateHelper
1025 data CBondHelper'
1026 type CBondHelper = ForeignPtr CBondHelper'
1027 type BondHelper = GenRateHelper CBondHelper
1028 foreign import ccall unsafe "ql.h &qlFreeBondHelper" qlFreeBondHelper :: FinalizerPtr CBondHelper'
1029 instance Finalizable CBondHelper' where finalize = qlFreeBondHelper
1030 foreign import ccall "ql.h qlBondHelperAsRateHelper" qlBondHelperAsRateHelper :: Ptr CBondHelper' -> IO (Ptr CRateHelper')
1031 instance Upcastable CBondHelper' where {type Base CBondHelper' = CRateHelper'; upcast = qlBondHelperAsRateHelper}
1032 peekBondHelper :: Ptr CBondHelper' -> IO BondHelper
1033 peekBondHelper = GenRateHelper <.> newGenForeignPtr
1034 withBondHelperArray :: [BondHelper] -> ((CUInt, Ptr (Ptr CBondHelper')) -> IO b) -> IO b
1035 withBondHelperArray = withGenArray withGenRateHelper
1036 data CSwapRateHelper'
1037 type CSwapRateHelper = ForeignPtr CSwapRateHelper'
1038 type SwapRateHelper = GenRateHelper CSwapRateHelper
1039 foreign import ccall unsafe "ql.h &qlFreeSwapRateHelper" qlFreeSwapRateHelper :: FinalizerPtr CSwapRateHelper'
1040 instance Finalizable CSwapRateHelper' where finalize = qlFreeSwapRateHelper
1041 foreign import ccall "ql.h qlSwapRateHelperAsRateHelper" qlSwapRateHelperAsRateHelper :: Ptr CSwapRateHelper' -> IO (Ptr CRateHelper')
1042 instance Upcastable CSwapRateHelper' where {type Base CSwapRateHelper' = CRateHelper'; upcast = qlSwapRateHelperAsRateHelper}
1043 peekSwapRateHelper :: Ptr CSwapRateHelper' -> IO SwapRateHelper
1044 peekSwapRateHelper = GenRateHelper <.> newGenForeignPtr
1045 data COISRateHelper'
1046 type COISRateHelper = ForeignPtr COISRateHelper'
1047 type OISRateHelper = GenRateHelper COISRateHelper
1048 foreign import ccall unsafe "ql.h &qlFreeOISRateHelper" qlFreeOISRateHelper :: FinalizerPtr COISRateHelper'
1049 instance Finalizable COISRateHelper' where finalize = qlFreeOISRateHelper
1050 foreign import ccall "ql.h qlOISRateHelperAsRateHelper" qlOISRateHelperAsRateHelper :: Ptr COISRateHelper' -> IO (Ptr CRateHelper')
1051 instance Upcastable COISRateHelper' where {type Base COISRateHelper' = CRateHelper'; upcast = qlOISRateHelperAsRateHelper}
1052 peekOISRateHelper :: Ptr COISRateHelper' -> IO OISRateHelper
1053 peekOISRateHelper = GenRateHelper <.> newGenForeignPtr
1054
1055 -- | > CalibrationHelper
1056 -- > BlackCalibrationHelper*
1057 -- > SwaptionHelper
1058 -- BlackCalibrationHelper is a proper one-AnyOf-layer family (mirrors GenSwap/GenOption under
1059 -- GenInstrument), not a plain leaf directly under CalibrationHelper as before, so a concrete
1060 -- subtype (SwaptionHelper) can be given its own getters without a runtime cast: SwaptionHelper's
1061 -- own underlying()/swaption() need the real SwaptionHelper pointer, while the pre-existing
1062 -- BlackCalibrationHelper-level accessors (times, blackPrice, impliedVolatility, ...) are
1063 -- generalized to 'GenBlackCalibrationHelper bch' so they keep working on any leaf, SwaptionHelper
1064 -- included, without an explicit upcast at each call site.
1065 type CalibrationHelper = GenCalibrationHelper CCalibrationHelper
1066 data CCalibrationHelper'
1067 data CBlackCalibrationHelper'
1068 newtype GenCalibrationHelper ch = GenCalibrationHelper {getCalibrationHelper :: GenForeignPtr ch CCalibrationHelper'}
1069 type CCalibrationHelper = ForeignPtr CCalibrationHelper'
1070 type GenBlackCalibrationHelper bch = GenCalibrationHelper (AnyOf CBlackCalibrationHelper' bch)
1071 type CBlackCalibrationHelper = ForeignPtr CBlackCalibrationHelper'
1072 type BlackCalibrationHelper = GenBlackCalibrationHelper CBlackCalibrationHelper
1073 foreign import ccall unsafe "ql.h &qlFreeCalibrationHelper" qlFreeCalibrationHelper :: FinalizerPtr CCalibrationHelper'
1074 foreign import ccall unsafe "ql.h &qlFreeBlackCalibrationHelper" qlFreeBlackCalibrationHelper :: FinalizerPtr CBlackCalibrationHelper'
1075 instance Finalizable CCalibrationHelper' where finalize = qlFreeCalibrationHelper
1076 instance Finalizable CBlackCalibrationHelper' where finalize = qlFreeBlackCalibrationHelper
1077 foreign import ccall "ql.h qlBlackCalibrationHelperAsCalibrationHelper" qlBlackCalibrationHelperAsCalibrationHelper :: Ptr CBlackCalibrationHelper' -> IO (Ptr CCalibrationHelper')
1078 instance Upcastable CBlackCalibrationHelper' where {type Base CBlackCalibrationHelper' = CCalibrationHelper'; upcast = qlBlackCalibrationHelperAsCalibrationHelper}
1079 asCalibrationHelper :: GenCalibrationHelper ch -> IO CalibrationHelper
1080 asCalibrationHelper = transferGenForeignPtr peekCalibrationHelper . getCalibrationHelper
1081 peekCalibrationHelper :: Ptr CCalibrationHelper' -> IO CalibrationHelper
1082 peekCalibrationHelper = GenCalibrationHelper <.> newCastForeignPtr
1083 withCalibrationHelper :: GenCalibrationHelper ch -> (Ptr CCalibrationHelper' -> IO b) -> IO b
1084 withCalibrationHelper = withGenForeignPtr . getCalibrationHelper
1085 -- hands back the raw stored leaf pointer (e.g. Ptr CSwaptionHelper'); for a marshaller that
1086 -- upcasts to the concrete Ptr CBlackCalibrationHelper', see 'withBlackCalibrationHelper' below.
1087 withGenCalibrationHelper :: GenBlackCalibrationHelper (ForeignPtr ch) -> (Ptr ch -> IO b) -> IO b
1088 withGenCalibrationHelper = withForeignPtr . ptr . peel . getCalibrationHelper
1089 asBlackCalibrationHelper :: GenBlackCalibrationHelper bch -> IO BlackCalibrationHelper
1090 asBlackCalibrationHelper = transferGenForeignPtr peekBlackCalibrationHelper . peel . getCalibrationHelper
1091 peekBlackCalibrationHelper :: Ptr CBlackCalibrationHelper' -> IO BlackCalibrationHelper
1092 peekBlackCalibrationHelper = newCastForeignPtr >=> newGenBlackCalibrationHelper
1093 withBlackCalibrationHelper :: GenBlackCalibrationHelper bch -> (Ptr CBlackCalibrationHelper' -> IO b) -> IO b
1094 withBlackCalibrationHelper = withGenForeignPtr . peel . getCalibrationHelper
1095 newGenBlackCalibrationHelper :: GenForeignPtr bch CBlackCalibrationHelper' -> IO (GenBlackCalibrationHelper bch)
1096 newGenBlackCalibrationHelper = pure . GenCalibrationHelper . newAnyOf
1097 withCalibrationHelperArray :: [GenCalibrationHelper ch] -> ((CUInt, Ptr (Ptr CCalibrationHelper')) -> IO b) -> IO b
1098 withCalibrationHelperArray = withGenArray withCalibrationHelper
1099 withBlackCalibrationHelperArray :: [GenBlackCalibrationHelper bch] -> ((CUInt, Ptr (Ptr CBlackCalibrationHelper')) -> IO b) -> IO b
1100 withBlackCalibrationHelperArray = withGenArray withBlackCalibrationHelper
1101 peekBlackCalibrationHelperArray :: Ptr CUInt -> Ptr (Ptr (Ptr CBlackCalibrationHelper')) -> IO [BlackCalibrationHelper]
1102 peekBlackCalibrationHelperArray = peekPtrArray peekBlackCalibrationHelper
1103
1104 -- SwaptionHelper is only reachable as this concrete type when hasquant itself constructs it
1105 -- (Model.chs's swaptionHelper/swaptionHelperFromDate/swaptionHelperFromDates); a basket returned
1106 -- by NonstandardSwaption/FloatFloatSwaption's calibrationBasket is erased to plain
1107 -- BlackCalibrationHelper by QuantLib's own calibrationBasket signature before it ever reaches
1108 -- this binding, so underlying/swaption are not reachable on basket elements without a cast --
1109 -- deliberately not offered there.
1110 data CSwaptionHelper'
1111 type CSwaptionHelper = ForeignPtr CSwaptionHelper'
1112 type SwaptionHelper = GenBlackCalibrationHelper CSwaptionHelper
1113 foreign import ccall unsafe "ql.h &qlFreeSwaptionHelper" qlFreeSwaptionHelper :: FinalizerPtr CSwaptionHelper'
1114 instance Finalizable CSwaptionHelper' where finalize = qlFreeSwaptionHelper
1115 foreign import ccall "ql.h qlSwaptionHelperAsBlackCalibrationHelper" qlSwaptionHelperAsBlackCalibrationHelper :: Ptr CSwaptionHelper' -> IO (Ptr CBlackCalibrationHelper')
1116 instance Upcastable CSwaptionHelper' where {type Base CSwaptionHelper' = CBlackCalibrationHelper'; upcast = qlSwaptionHelperAsBlackCalibrationHelper}
1117 peekSwaptionHelper :: Ptr CSwaptionHelper' -> IO SwaptionHelper
1118 peekSwaptionHelper = newGenForeignPtr >=> newGenBlackCalibrationHelper
1119 withSwaptionHelper :: SwaptionHelper -> (Ptr CSwaptionHelper' -> IO b) -> IO b
1120 withSwaptionHelper = withForeignPtr . ptr . peel . getCalibrationHelper
1121
1122 -- | > BlackCalculator
1123 -- > BlackScholesCalculator
1124 type BlackCalculator = GenBlackCalculator CBlackCalculator
1125 data CBlackCalculator'
1126 data CBlackScholesCalculator'
1127 newtype GenBlackCalculator bc = GenBlackCalculator {getBlackCalculator :: GenForeignPtr bc CBlackCalculator'}
1128 type CBlackCalculator = ForeignPtr CBlackCalculator'
1129 type CBlackScholesCalculator = ForeignPtr CBlackScholesCalculator'
1130 type BlackScholesCalculator = GenBlackCalculator CBlackScholesCalculator
1131 foreign import ccall unsafe "ql.h &qlFreeBlackCalculator" qlFreeBlackCalculator :: FinalizerPtr CBlackCalculator'
1132 foreign import ccall unsafe "ql.h &qlFreeBlackScholesCalculator" qlFreeBlackScholesCalculator :: FinalizerPtr CBlackScholesCalculator'
1133 instance Finalizable CBlackCalculator' where finalize = qlFreeBlackCalculator
1134 instance Finalizable CBlackScholesCalculator' where finalize = qlFreeBlackScholesCalculator
1135 foreign import ccall "ql.h qlBlackScholesCalculatorAsBlackCalculator" qlBlackScholesCalculatorAsBlackCalculator :: Ptr CBlackScholesCalculator' -> IO (Ptr CBlackCalculator')
1136 instance Upcastable CBlackScholesCalculator' where {type Base CBlackScholesCalculator' = CBlackCalculator'; upcast = qlBlackScholesCalculatorAsBlackCalculator}
1137 asBlackCalculator :: GenBlackCalculator bc -> IO BlackCalculator
1138 asBlackCalculator = transferGenForeignPtr peekBlackCalculator . getBlackCalculator
1139 peekBlackCalculator :: Ptr CBlackCalculator' -> IO BlackCalculator
1140 peekBlackCalculator = GenBlackCalculator <.> newCastForeignPtr
1141 withBlackCalculator :: GenBlackCalculator bc -> (Ptr CBlackCalculator' -> IO b) -> IO b
1142 withBlackCalculator = withGenForeignPtr . getBlackCalculator
1143 withGenBlackCalculator :: GenBlackCalculator (ForeignPtr bc) -> (Ptr bc -> IO b) -> IO b
1144 withGenBlackCalculator = withForeignPtr . ptr . getBlackCalculator
1145 peekBlackScholesCalculator :: Ptr CBlackScholesCalculator' -> IO BlackScholesCalculator
1146 peekBlackScholesCalculator = GenBlackCalculator <.> newGenForeignPtr
1147
1148 -- | > BachelierCalculator
1149 -- no subclasses upstream, unlike BlackCalculator/BlackScholesCalculator above, so this is a
1150 -- plain leaf (Standalone), not a GenX/Upcastable hierarchy
1151 data CBachelierCalculator
1152 newtype BachelierCalculator = BachelierCalculator {getCBachelierCalculator :: Standalone CBachelierCalculator}
1153 foreign import ccall unsafe "ql.h &qlFreeBachelierCalculator" qlFreeBachelierCalculator :: FinalizerPtr CBachelierCalculator
1154 instance Finalizable CBachelierCalculator where finalize = qlFreeBachelierCalculator
1155 peekBachelierCalculator :: Ptr CBachelierCalculator -> IO BachelierCalculator
1156 peekBachelierCalculator = BachelierCalculator <.> peekStandalone
1157 withBachelierCalculator :: BachelierCalculator -> (Ptr CBachelierCalculator -> IO b) -> IO b
1158 withBachelierCalculator = withStandalone . getCBachelierCalculator
1159
1160 -- MULTILEVEL HIERARCHIES
1161 -- | > Index
1162 -- > InterestRateIndex
1163 -- > BMAIndex
1164 -- > IborIndex
1165 -- > OvernightIborIndex (COvernightIndex')
1166 -- > SwapIndex
1167 -- > OvernightIndexedSwapIndex
1168 -- > InflationIndex
1169 -- > YoYInflationIndex
1170 -- > ZeroInflationIndex
1171 -- > EquityIndex
1172 -- > CommodityIndex
1173 type Index = GenIndex CIndex
1174 data CIndex'
1175 data CInterestRateIndex'
1176 data CInflationIndex'
1177 data CZeroInflationIndex'
1178 data CYoYInflationIndex'
1179 data CBMAIndex'
1180 data CIborIndex'
1181 data COvernightIndex'
1182 data CSwapIndex'
1183 data COvernightIndexedSwapIndex'
1184 newtype GenIndex idx = GenIndex {getIndex :: GenForeignPtr idx CIndex'}
1185 type CIndex = ForeignPtr CIndex'
1186
1187 foreign import ccall safe "ql.h qlIndexName" qlIndexName :: Ptr CIndex' -> IO CString
1188 showIndex :: GenIndex idx -> String
1189 showIndex = unsafePerformIO . (`withIndex` (qlIndexName >=> peekDynString))
1190 {-# NOINLINE showIndex #-}
1191
1192 instance Show (GenIndex idx) where show = showIndex
1193
1194 type GenInterestRateIndex ridx = GenIndex (AnyOf CInterestRateIndex' ridx)
1195 type CInterestRateIndex = ForeignPtr CInterestRateIndex'
1196 type InterestRateIndex = GenInterestRateIndex CInterestRateIndex
1197 type GenInflationIndex iidx = GenIndex (AnyOf CInflationIndex' iidx)
1198 type CInflationIndex = ForeignPtr CInflationIndex'
1199 type InflationIndex = GenInflationIndex CInflationIndex
1200 type GenZeroInflationIndex zidx = GenInflationIndex (AnyOf CZeroInflationIndex' zidx)
1201 type CZeroInflationIndex = ForeignPtr CZeroInflationIndex'
1202 type ZeroInflationIndex = GenZeroInflationIndex CZeroInflationIndex
1203 type GenYoYInflationIndex yidx = GenInflationIndex (AnyOf CYoYInflationIndex' yidx)
1204 type CYoYInflationIndex = ForeignPtr CYoYInflationIndex'
1205 type YoYInflationIndex = GenYoYInflationIndex CYoYInflationIndex
1206 type CBMAIndex = ForeignPtr CBMAIndex'
1207 type BMAIndex = GenInterestRateIndex CBMAIndex
1208 type CIborIndex = ForeignPtr CIborIndex'
1209 type IborIndex = GenIborIndex CIborIndex
1210 type COvernightIndex = ForeignPtr COvernightIndex'
1211 type OvernightIborIndex = GenIborIndex COvernightIndex
1212 type CSwapIndex = ForeignPtr CSwapIndex'
1213 type SwapIndex = GenSwapIndex CSwapIndex
1214 type GenIborIndex ibor = GenInterestRateIndex (AnyOf CIborIndex' ibor)
1215 type GenSwapIndex sidx = GenInterestRateIndex (AnyOf CSwapIndex' sidx)
1216 type COvernightIndexedSwapIndex = ForeignPtr COvernightIndexedSwapIndex'
1217 type OvernightIndexedSwapIndex = GenSwapIndex COvernightIndexedSwapIndex
1218 foreign import ccall unsafe "ql.h &qlFreeIndex" qlFreeIndex :: FinalizerPtr CIndex'
1219 foreign import ccall unsafe "ql.h &qlFreeInterestRateIndex" qlFreeInterestRateIndex :: FinalizerPtr CInterestRateIndex'
1220 foreign import ccall unsafe "ql.h &qlFreeInflationIndex" qlFreeInflationIndex :: FinalizerPtr CInflationIndex'
1221 foreign import ccall unsafe "ql.h &qlFreeZeroInflationIndex" qlFreeZeroInflationIndex :: FinalizerPtr CZeroInflationIndex'
1222 foreign import ccall unsafe "ql.h &qlFreeYoYInflationIndex" qlFreeYoYInflationIndex :: FinalizerPtr CYoYInflationIndex'
1223 foreign import ccall unsafe "ql.h &qlFreeBMAIndex" qlFreeBMAIndex :: FinalizerPtr CBMAIndex'
1224 foreign import ccall unsafe "ql.h &qlFreeIborIndex" qlFreeIborIndex :: FinalizerPtr CIborIndex'
1225 foreign import ccall unsafe "ql.h &qlFreeOvernightIndex" qlFreeOvernightIborIndex :: FinalizerPtr COvernightIndex'
1226 foreign import ccall unsafe "ql.h &qlFreeSwapIndex" qlFreeSwapIndex :: FinalizerPtr CSwapIndex'
1227 foreign import ccall unsafe "ql.h &qlFreeOvernightIndexedSwapIndex" qlFreeOvernightIndexedSwapIndex :: FinalizerPtr COvernightIndexedSwapIndex'
1228 instance Finalizable CIndex' where finalize = qlFreeIndex
1229 instance Finalizable CInterestRateIndex' where finalize = qlFreeInterestRateIndex
1230 instance Finalizable CInflationIndex' where finalize = qlFreeInflationIndex
1231 instance Finalizable CZeroInflationIndex' where finalize = qlFreeZeroInflationIndex
1232 instance Finalizable CYoYInflationIndex' where finalize = qlFreeYoYInflationIndex
1233 instance Finalizable CBMAIndex' where finalize = qlFreeBMAIndex
1234 instance Finalizable CIborIndex' where finalize = qlFreeIborIndex
1235 instance Finalizable COvernightIndex' where finalize = qlFreeOvernightIborIndex
1236 instance Finalizable CSwapIndex' where finalize = qlFreeSwapIndex
1237 instance Finalizable COvernightIndexedSwapIndex' where finalize = qlFreeOvernightIndexedSwapIndex
1238 foreign import ccall "ql.h qlInterestRateIndexAsIndex" qlInterestRateIndexAsIndex :: Ptr CInterestRateIndex' -> IO (Ptr CIndex')
1239 foreign import ccall "ql.h qlInflationIndexAsIndex" qlInflationIndexAsIndex :: Ptr CInflationIndex' -> IO (Ptr CIndex')
1240 foreign import ccall "ql.h qlZeroInflationIndexAsInflationIndex" qlZeroInflationIndexAsInflationIndex :: Ptr CZeroInflationIndex' -> IO (Ptr CInflationIndex')
1241 foreign import ccall "ql.h qlYoYInflationIndexAsInflationIndex" qlYoYInflationIndexAsInflationIndex :: Ptr CYoYInflationIndex' -> IO (Ptr CInflationIndex')
1242 foreign import ccall "ql.h qlBMAIndexAsInterestRateIndex" qlBMAIndexAsInterestRateIndex :: Ptr CBMAIndex' -> IO (Ptr CInterestRateIndex')
1243 foreign import ccall "ql.h qlIborIndexAsInterestRateIndex" qlIborIndexAsInterestRateIndex :: Ptr CIborIndex' -> IO (Ptr CInterestRateIndex')
1244 foreign import ccall "ql.h qlOvernightIndexAsIborIndex" qlOvernightIndexAsIborIndex :: Ptr COvernightIndex' -> IO (Ptr CIborIndex')
1245 foreign import ccall "ql.h qlSwapIndexAsInterestRateIndex" qlSwapIndexAsInterestRateIndex :: Ptr CSwapIndex' -> IO (Ptr CInterestRateIndex')
1246 foreign import ccall "ql.h qlOvernightIndexedSwapIndexAsSwapIndex" qlOvernightIndexedSwapIndexAsSwapIndex :: Ptr COvernightIndexedSwapIndex' -> IO (Ptr CSwapIndex')
1247 instance Upcastable CInterestRateIndex' where {type Base CInterestRateIndex' = CIndex'; upcast = qlInterestRateIndexAsIndex}
1248 instance Upcastable CInflationIndex' where {type Base CInflationIndex' = CIndex'; upcast = qlInflationIndexAsIndex}
1249 instance Upcastable CZeroInflationIndex' where {type Base CZeroInflationIndex' = CInflationIndex'; upcast = qlZeroInflationIndexAsInflationIndex}
1250 instance Upcastable CYoYInflationIndex' where {type Base CYoYInflationIndex' = CInflationIndex'; upcast = qlYoYInflationIndexAsInflationIndex}
1251 instance Upcastable CBMAIndex' where {type Base CBMAIndex' = CInterestRateIndex'; upcast = qlBMAIndexAsInterestRateIndex}
1252 instance Upcastable CIborIndex' where {type Base CIborIndex' = CInterestRateIndex'; upcast = qlIborIndexAsInterestRateIndex}
1253 instance Upcastable COvernightIndex' where {type Base COvernightIndex' = CIborIndex'; upcast = qlOvernightIndexAsIborIndex}
1254 instance Upcastable CSwapIndex' where {type Base CSwapIndex' = CInterestRateIndex'; upcast = qlSwapIndexAsInterestRateIndex}
1255 instance Upcastable COvernightIndexedSwapIndex' where {type Base COvernightIndexedSwapIndex' = CSwapIndex'; upcast = qlOvernightIndexedSwapIndexAsSwapIndex}
1256
1257 asIndex :: GenIndex idx -> IO Index
1258 asIndex = transferGenForeignPtr peekIndex . getIndex
1259 withIndex :: GenIndex idx -> (Ptr CIndex' -> IO b) -> IO b
1260 withIndex = withGenForeignPtr . getIndex
1261 peekIndex :: Ptr CIndex' -> IO Index
1262 peekIndex = GenIndex <.> newCastForeignPtr
1263 withIndexArray :: [Index] -> ((CUInt, Ptr (Ptr CIndex')) -> IO b) -> IO b
1264 withIndexArray = withGenArray withIndex
1265
1266 asInterestRateIndex :: GenInterestRateIndex ridx -> IO InterestRateIndex
1267 asInterestRateIndex = transferGenForeignPtr peekInterestRateIndex . peel . getIndex
1268 peekInterestRateIndex :: Ptr CInterestRateIndex' -> IO InterestRateIndex
1269 peekInterestRateIndex = newCastForeignPtr >=> newGenInterestRateIndex
1270 newGenInterestRateIndex :: GenForeignPtr ridx CInterestRateIndex' -> IO (GenInterestRateIndex ridx)
1271 newGenInterestRateIndex = pure . GenIndex . newAnyOf
1272 withInterestRateIndex :: GenInterestRateIndex ridx -> (Ptr CInterestRateIndex' -> IO b) -> IO b
1273 withInterestRateIndex = withGenForeignPtr . peel . getIndex
1274 withInterestRateIndexArray :: [GenInterestRateIndex ridx] -> ((CUInt, Ptr (Ptr CInterestRateIndex')) -> IO b) -> IO b
1275 withInterestRateIndexArray = withGenArray withInterestRateIndex
1276
1277 asInflationIndex :: GenInflationIndex iidx -> IO InflationIndex
1278 asInflationIndex = transferGenForeignPtr peekInflationIndex . peel . getIndex
1279 peekInflationIndex :: Ptr CInflationIndex' -> IO InflationIndex
1280 peekInflationIndex = newCastForeignPtr >=> newGenInflationIndex
1281 newGenInflationIndex :: GenForeignPtr iidx CInflationIndex' -> IO (GenInflationIndex iidx)
1282 newGenInflationIndex = pure . GenIndex . newAnyOf
1283 withInflationIndex :: GenInflationIndex iidx -> (Ptr CInflationIndex' -> IO b) -> IO b
1284 withInflationIndex = withGenForeignPtr . peel . getIndex
1285
1286 peekZeroInflationIndex :: Ptr CZeroInflationIndex' -> IO ZeroInflationIndex
1287 peekZeroInflationIndex = newCastForeignPtr >=> newGenZeroInflationIndex
1288 withZeroInflationIndex :: GenZeroInflationIndex zidx -> (Ptr CZeroInflationIndex' -> IO b) -> IO b
1289 withZeroInflationIndex = withGenForeignPtr . peel . peel . getIndex
1290 newGenZeroInflationIndex :: GenForeignPtr zidx CZeroInflationIndex' -> IO (GenZeroInflationIndex zidx)
1291 newGenZeroInflationIndex = pure . GenIndex . newAnyOf . newAnyOf
1292
1293 peekYoYInflationIndex :: Ptr CYoYInflationIndex' -> IO YoYInflationIndex
1294 peekYoYInflationIndex = newCastForeignPtr >=> newGenYoYInflationIndex
1295 withYoYInflationIndex :: GenYoYInflationIndex yidx -> (Ptr CYoYInflationIndex' -> IO b) -> IO b
1296 withYoYInflationIndex = withGenForeignPtr . peel . peel . getIndex
1297 newGenYoYInflationIndex :: GenForeignPtr yidx CYoYInflationIndex' -> IO (GenYoYInflationIndex yidx)
1298 newGenYoYInflationIndex = pure . GenIndex . newAnyOf . newAnyOf
1299
1300 peekBMAIndex :: Ptr CBMAIndex' -> IO BMAIndex
1301 peekBMAIndex = newGenForeignPtr >=> newGenInterestRateIndex
1302 withBMAIndex :: BMAIndex -> (Ptr CBMAIndex' -> IO b) -> IO b
1303 withBMAIndex = withForeignPtr . ptr . peel . getIndex
1304
1305 asIborIndex :: GenIborIndex ibor -> IO IborIndex
1306 asIborIndex = transferGenForeignPtr peekIborIndex . peel . peel . getIndex
1307 peekIborIndex :: Ptr CIborIndex' -> IO IborIndex
1308 peekIborIndex = newCastForeignPtr >=> newGenIborIndex
1309 withIborIndex :: GenIborIndex ibor -> (Ptr CIborIndex' -> IO b) -> IO b
1310 withIborIndex = withGenForeignPtr . peel . peel . getIndex
1311 newGenIborIndex :: GenForeignPtr ibor CIborIndex' -> IO (GenIborIndex ibor)
1312 newGenIborIndex = pure . GenIndex . newAnyOf . newAnyOf
1313
1314 peekOvernightIborIndex :: Ptr COvernightIndex' -> IO OvernightIborIndex
1315 peekOvernightIborIndex = newGenForeignPtr >=> newGenIborIndex
1316 withOvernightIborIndex :: OvernightIborIndex -> (Ptr COvernightIndex' -> IO b) -> IO b
1317 withOvernightIborIndex = withForeignPtr . ptr . peel . peel . getIndex
1318
1319 asSwapIndex :: GenSwapIndex sidx -> IO SwapIndex
1320 asSwapIndex = transferGenForeignPtr peekSwapIndex . peel . peel . getIndex
1321 peekSwapIndex :: Ptr CSwapIndex' -> IO SwapIndex
1322 peekSwapIndex = newCastForeignPtr >=> newGenSwapIndex
1323 withSwapIndex :: GenSwapIndex sidx -> (Ptr CSwapIndex' -> IO b) -> IO b
1324 withSwapIndex = withGenForeignPtr . peel . peel . getIndex
1325 newGenSwapIndex :: GenForeignPtr sidx CSwapIndex' -> IO (GenSwapIndex sidx)
1326 newGenSwapIndex = pure . GenIndex . newAnyOf . newAnyOf
1327
1328 peekOvernightIndexedSwapIndex :: Ptr COvernightIndexedSwapIndex' -> IO OvernightIndexedSwapIndex
1329 peekOvernightIndexedSwapIndex = newGenForeignPtr >=> newGenSwapIndex
1330 withOvernightIndexedSwapIndex :: OvernightIndexedSwapIndex -> (Ptr COvernightIndexedSwapIndex' -> IO b) -> IO b
1331 withOvernightIndexedSwapIndex = withForeignPtr .ptr . peel . peel . getIndex
1332
1333 data CEquityIndex'
1334 type CEquityIndex = ForeignPtr CEquityIndex'
1335 type EquityIndex = GenIndex CEquityIndex
1336 foreign import ccall unsafe "ql.h &qlFreeEquityIndex" qlFreeEquityIndex :: FinalizerPtr CEquityIndex'
1337 instance Finalizable CEquityIndex' where finalize = qlFreeEquityIndex
1338 foreign import ccall "ql.h qlEquityIndexAsIndex" qlEquityIndexAsIndex :: Ptr CEquityIndex' -> IO (Ptr CIndex')
1339 instance Upcastable CEquityIndex' where {type Base CEquityIndex' = CIndex'; upcast = qlEquityIndexAsIndex}
1340 peekEquityIndex :: Ptr CEquityIndex' -> IO EquityIndex
1341 peekEquityIndex = GenIndex <.> newGenForeignPtr
1342 withEquityIndex :: EquityIndex -> (Ptr CEquityIndex' -> IO b) -> IO b
1343 withEquityIndex = withForeignPtr . ptr . getIndex
1344
1345 -- | A plain 'Index' leaf, mirroring 'EquityIndex' -- no subclasses upstream.
1346 data CCommodityIndex'
1347 type CCommodityIndex = ForeignPtr CCommodityIndex'
1348 type CommodityIndex = GenIndex CCommodityIndex
1349 foreign import ccall unsafe "ql.h &qlFreeCommodityIndex" qlFreeCommodityIndex :: FinalizerPtr CCommodityIndex'
1350 instance Finalizable CCommodityIndex' where finalize = qlFreeCommodityIndex
1351 foreign import ccall "ql.h qlCommodityIndexAsIndex" qlCommodityIndexAsIndex :: Ptr CCommodityIndex' -> IO (Ptr CIndex')
1352 instance Upcastable CCommodityIndex' where {type Base CCommodityIndex' = CIndex'; upcast = qlCommodityIndexAsIndex}
1353 peekCommodityIndex :: Ptr CCommodityIndex' -> IO CommodityIndex
1354 peekCommodityIndex = GenIndex <.> newGenForeignPtr
1355 withCommodityIndex :: CommodityIndex -> (Ptr CCommodityIndex' -> IO b) -> IO b
1356 withCommodityIndex = withForeignPtr . ptr . getIndex
1357
1358 -- | > TermStructure = GenTermStructure t
1359 -- > YieldTermStructure = GenYieldTermStructure y = GenTermStructure t
1360 -- > FittedBondDiscountCurve = GenYieldTermStructure ...
1361 -- > RelinkableYieldTermStructure = GenYieldTermStructure ...
1362 -- (MultiCurve, below with the other standalone leaves, is not a YieldTermStructure member --
1363 -- it manages a cycle of them, handing out 'YieldTermStructure' handles via addBootstrappedCurve
1364 -- \/ addNonBootstrappedCurve. See its own definition's comment.)
1365 -- > VolatilityTermStructure
1366 -- > OptionletVolatilityStructure
1367 -- > RelinkableOptionletVolatilityStructure
1368 -- > BlackVolTermStructure
1369 -- > BlackVarianceCurve
1370 -- > BlackVolatilitySurfaceDelta
1371 -- > RelinkableBlackVolTermStructure
1372 -- > SwaptionVolatilityStructure
1373 -- > RelinkableSwaptionVolatilityStructure
1374 -- > SabrSwaptionVolatilityCube
1375 -- > InterpolatedSwaptionVolatilityCube
1376 -- > CapFloorTermVolatilityStructure*
1377 -- > CapFloorTermVolCurve
1378 -- > CapFloorTermVolSurface
1379 -- > BlackAtmVolCurve*
1380 -- > AbcdAtmVolCurve
1381 -- > BlackVolSurface*
1382 -- > SabrVolSurface
1383 -- > LocalVolTermStructure
1384 -- > YoYOptionletVolatilitySurface
1385 -- > CPIVolatilitySurface
1386 -- > CallableBondVolatilityStructure
1387 -- > DefaultProbabilityTermStructure
1388 -- > ZeroInflationTermStructure
1389 -- > YoYInflationTermStructure
1390 -- > YoYCapFloorTermPriceSurface
1391 -- > CPICapFloorTermPriceSurface
1392 -- > CommodityCurve
1393 type TermStructure = GenTermStructure CTermStructure
1394 data CTermStructure'
1395 data CVolatilityTermStructure'
1396 data COptionletVolatilityStructure'
1397 data CRelinkableOptionletVolatilityStructure'
1398 data CSwaptionVolatilityStructure'
1399 data CRelinkableSwaptionVolatilityStructure'
1400 data CSabrSwaptionVolatilityCube'
1401 data CInterpolatedSwaptionVolatilityCube'
1402 data CCapFloorTermVolatilityStructure'
1403 data CCapFloorTermVolCurve'
1404 data CCapFloorTermVolSurface'
1405 data CLocalVolTermStructure'
1406 data CYoYOptionletVolatilitySurface'
1407 data CCPIVolatilitySurface'
1408 data CBlackVolTermStructure'
1409 data CRelinkableBlackVolTermStructure'
1410 data CBlackVarianceCurve'
1411 data CBlackVolatilitySurfaceDelta'
1412 data CYieldTermStructure'
1413 data CFittedBondDiscountCurve'
1414 data CRelinkableYieldTermStructure'
1415 data CCallableBondVolatilityStructure'
1416 data CDefaultProbabilityTermStructure'
1417 data CZeroInflationTermStructure'
1418 data CYoYInflationTermStructure'
1419 data CCommodityCurve'
1420 newtype GenTermStructure t = GenTermStructure {getTermStructure :: GenForeignPtr t CTermStructure'}
1421 type CTermStructure = ForeignPtr CTermStructure'
1422 type GenYieldTermStructure y = GenTermStructure (AnyOf CYieldTermStructure' y)
1423 type CYieldTermStructure = ForeignPtr CYieldTermStructure'
1424 type YieldTermStructure = GenYieldTermStructure CYieldTermStructure
1425 type CFittedBondDiscountCurve = ForeignPtr CFittedBondDiscountCurve'
1426 type FittedBondDiscountCurve = GenYieldTermStructure CFittedBondDiscountCurve
1427 type CRelinkableYieldTermStructure = ForeignPtr CRelinkableYieldTermStructure'
1428 -- | A curve held behind a relinkable handle. It /is/ a 'YieldTermStructure' -- pass it
1429 -- anywhere a curve is expected and it upcasts like any other hierarchy member, sharing its
1430 -- @Link@ so that a later 'QuantLib.TermStructure.Yield.linkTo' reaches everything already
1431 -- built on it.
1432 type RelinkableYieldTermStructure = GenYieldTermStructure CRelinkableYieldTermStructure
1433 type GenVolatilityTermStructure v = GenTermStructure (AnyOf CVolatilityTermStructure' v)
1434 type CVolatilityTermStructure = ForeignPtr CVolatilityTermStructure'
1435 type VolatilityTermStructure = GenVolatilityTermStructure CVolatilityTermStructure
1436 type GenOptionletVolatilityStructure ov = GenVolatilityTermStructure (AnyOf COptionletVolatilityStructure' ov)
1437 type COptionletVolatilityStructure = ForeignPtr COptionletVolatilityStructure'
1438 type OptionletVolatilityStructure = GenOptionletVolatilityStructure COptionletVolatilityStructure
1439 type CRelinkableOptionletVolatilityStructure = ForeignPtr CRelinkableOptionletVolatilityStructure'
1440 -- | An optionlet vol surface held behind a relinkable handle. It /is/ an
1441 -- 'OptionletVolatilityStructure' -- pass it anywhere one is expected and it upcasts like any
1442 -- other hierarchy member, sharing its @Link@ so that a later
1443 -- 'QuantLib.TermStructure.Volatility.linkOptionletVolTo' reaches everything already built on
1444 -- it. Mirrors 'RelinkableSwaptionVolatilityStructure'.
1445 type RelinkableOptionletVolatilityStructure = GenOptionletVolatilityStructure CRelinkableOptionletVolatilityStructure
1446 type GenCapFloorTermVolatilityStructure c = GenVolatilityTermStructure (AnyOf CCapFloorTermVolatilityStructure' c)
1447 type CCapFloorTermVolatilityStructure = ForeignPtr CCapFloorTermVolatilityStructure'
1448 -- | The abstract root shared by 'ConstantCapFloorTermVolatility' (erased straight to this type at
1449 -- construction, having no calc\/getter of its own beyond 'capFloorVolatilityForPeriod' et al.,
1450 -- mirroring 'ConstantOptionletVolatility' \/\'OptionletVolatilityStructure'), and the two dedicated
1451 -- leaves below. Promoted out of a flat 'VolatilityTermStructure' leaf (the way
1452 -- 'YoYOptionletVolatilitySurface' still is) specifically so 'capFloorVolatilityForPeriod'\/
1453 -- 'capFloorVolatilityForDate'\/'capFloorVolatilityForTime' -- declared on
1454 -- @CapFloorTermVolatilityStructure@ upstream, not on 'VolatilityTermStructure' -- can be bound
1455 -- generically without a @dynamic_pointer_cast@ in the shim.
1456 type CapFloorTermVolatilityStructure = GenCapFloorTermVolatilityStructure CCapFloorTermVolatilityStructure
1457 type CCapFloorTermVolCurve = ForeignPtr CCapFloorTermVolCurve'
1458 -- | An ATM-only cap\/floor term vol curve (no strike dimension, unlike 'CapFloorTermVolSurface').
1459 -- Gets its own dedicated leaf (rather than erasing to 'CapFloorTermVolatilityStructure' the way
1460 -- 'ConstantCapFloorTermVolatility' does) so a future binding of @OptionletStripper2@ -- which takes
1461 -- a concrete @Handle\<CapFloorTermVolCurve\>@ upstream -- has a type to reach for without another
1462 -- breaking change here.
1463 type CapFloorTermVolCurve = GenCapFloorTermVolatilityStructure CCapFloorTermVolCurve
1464 type CCapFloorTermVolSurface = ForeignPtr CCapFloorTermVolSurface'
1465 type CapFloorTermVolSurface = GenCapFloorTermVolatilityStructure CCapFloorTermVolSurface
1466 type GenSwaptionVolatilityStructure sv = GenVolatilityTermStructure (AnyOf CSwaptionVolatilityStructure' sv)
1467 type CSwaptionVolatilityStructure = ForeignPtr CSwaptionVolatilityStructure'
1468 type SwaptionVolatilityStructure = GenSwaptionVolatilityStructure CSwaptionVolatilityStructure
1469 type CRelinkableSwaptionVolatilityStructure = ForeignPtr CRelinkableSwaptionVolatilityStructure'
1470 -- | A swaption vol surface held behind a relinkable handle. It /is/ a
1471 -- 'SwaptionVolatilityStructure' -- pass it anywhere one is expected and it upcasts like any
1472 -- other hierarchy member, sharing its @Link@ so that a later
1473 -- 'QuantLib.TermStructure.Volatility.linkSwaptionVolTo' reaches everything already built on
1474 -- it. Mirrors 'RelinkableBlackVolTermStructure'.
1475 type RelinkableSwaptionVolatilityStructure = GenSwaptionVolatilityStructure CRelinkableSwaptionVolatilityStructure
1476 type CSabrSwaptionVolatilityCube = ForeignPtr CSabrSwaptionVolatilityCube'
1477 -- | A SABR-calibrated swaption vol cube. It /is/ a 'SwaptionVolatilityStructure' -- pass it
1478 -- anywhere one is expected. Its own extra getters (sparse\/dense SABR parameters, market\/ATM-
1479 -- calibrated vol cubes, ATM strike) are bound directly against this concrete type rather than
1480 -- via a downcast: it has real calculations of its own beyond the generic interface, so per the
1481 -- API-design rule in CLAUDE.md it earns a dedicated leaf instead of being collapsed into
1482 -- 'SwaptionVolatilityStructure' the way 'swaptionVolatilityMatrix'' is.
1483 type SabrSwaptionVolatilityCube = GenSwaptionVolatilityStructure CSabrSwaptionVolatilityCube
1484 type CInterpolatedSwaptionVolatilityCube = ForeignPtr CInterpolatedSwaptionVolatilityCube'
1485 -- | The non-SABR, linear-interpolation swaption vol cube. It /is/ a
1486 -- 'SwaptionVolatilityStructure' -- pass it anywhere one is expected. Gets the same dedicated-leaf
1487 -- treatment as 'SabrSwaptionVolatilityCube' for its 'atmStrike' getter (inherited, in upstream,
1488 -- from the same abstract @SwaptionVolatilityCube@ base both concrete cubes share).
1489 type InterpolatedSwaptionVolatilityCube = GenSwaptionVolatilityStructure CInterpolatedSwaptionVolatilityCube
1490 -- | Black at-the-money (no-smile) volatility curve, abstract here (hasquant binds no
1491 -- @qlBlackAtmVolCurve@ constructor -- @BlackAtmVolCurve@ has no bindable constructor upstream
1492 -- either, only its concrete subclasses do). A sibling of 'OptionletVolatilityStructure'\/
1493 -- 'CapFloorTermVolatilityStructure'\/'SwaptionVolatilityStructure' directly off
1494 -- 'VolatilityTermStructure'. Reachable as a value via 'SabrVolSurface''s @atmCurve@ getter (any
1495 -- concrete member may be held there), and as the argument type of 'sabrVolSurface'.
1496 type GenBlackAtmVolCurve b = GenVolatilityTermStructure (AnyOf CBlackAtmVolCurve' b)
1497 data CBlackAtmVolCurve'
1498 type CBlackAtmVolCurve = ForeignPtr CBlackAtmVolCurve'
1499 type BlackAtmVolCurve = GenBlackAtmVolCurve CBlackAtmVolCurve
1500 -- | Black volatility (smile) surface: adds a strike\/smile dimension over 'BlackAtmVolCurve'.
1501 -- Abstract here (no bindable constructor of its own -- only 'SabrVolSurface' constructs one in
1502 -- this binding), but earns its own hierarchy level rather than folding into 'BlackAtmVolCurve'
1503 -- (unlike @InterestRateVolSurface@, deliberately not given its own level -- see 'SabrVolSurface')
1504 -- because its own calculation, @smileSection@, is the defining feature of the "surface" vs
1505 -- "curve" distinction, not a thin pass-through inspector.
1506 type GenBlackVolSurface b = GenBlackAtmVolCurve (AnyOf CBlackVolSurface' b)
1507 data CBlackVolSurface'
1508 type CBlackVolSurface = ForeignPtr CBlackVolSurface'
1509 type BlackVolSurface = GenBlackVolSurface CBlackVolSurface
1510 data CAbcdAtmVolCurve'
1511 type CAbcdAtmVolCurve = ForeignPtr CAbcdAtmVolCurve'
1512 -- | ABCD-parametric fit to a set of (tenor, quote) at-the-money vols. A dedicated
1513 -- 'BlackAtmVolCurve' leaf (real calc\/getters of its own -- @a@\/@b@\/@c@\/@d@\/@rmsError@\/etc --
1514 -- per the API-design rule in CLAUDE.md), one 'AnyOf' layer under 'GenBlackAtmVolCurve', same depth
1515 -- as 'CapFloorTermVolCurve' under 'GenCapFloorTermVolatilityStructure'.
1516 type AbcdAtmVolCurve = GenBlackAtmVolCurve CAbcdAtmVolCurve
1517 data CSabrVolSurface'
1518 type CSabrVolSurface = ForeignPtr CSabrVolSurface'
1519 -- | SABR-smile surface built from an interest-rate index, an ATM 'BlackAtmVolCurve', and
1520 -- per-tenor vol spreads. A dedicated 'BlackVolSurface' leaf (own getters: @atmCurve@,
1521 -- @volatilitySpreads@; plus @index@\/@optionDateFromTenor@ folded in directly from upstream's
1522 -- @InterestRateVolSurface@, which is not given its own hierarchy level here since
1523 -- 'SabrVolSurface' is its only concrete member in this binding -- per CLAUDE.md's "don't mirror
1524 -- the C++ hierarchy 1:1" rule). Two 'AnyOf' layers under 'GenBlackVolSurface' (mirrors
1525 -- 'VanillaSwap' under 'FixedVsFloatingSwap' under 'GenSwap').
1526 type SabrVolSurface = GenBlackVolSurface CSabrVolSurface
1527 type CLocalVolTermStructure = ForeignPtr CLocalVolTermStructure'
1528 type LocalVolTermStructure = GenVolatilityTermStructure CLocalVolTermStructure
1529 type CYoYOptionletVolatilitySurface = ForeignPtr CYoYOptionletVolatilitySurface'
1530 -- | A YoY-inflation optionlet vol surface, quoted via 'volatility'\/'totalVariance' at
1531 -- (maturity, strike) pairs rather than QuantLib's usual (option date, tenor, strike) grid, since
1532 -- inflation caplets observe a single index fixing rather than a forward rate. A plain
1533 -- 'VolatilityTermStructure' leaf like 'CapFloorTermVolSurface', constructed and consumed via a
1534 -- @Handle@ (mirroring 'OptionletVolatilityStructure', since it feeds
1535 -- 'QuantLib.PricingEngine.yoyInflationBlackCapFloorEngine' et al. exactly the way
1536 -- 'OptionletVolatilityStructure' feeds 'QuantLib.PricingEngine.blackCapFloorEngine'').
1537 type YoYOptionletVolatilitySurface = GenVolatilityTermStructure CYoYOptionletVolatilitySurface
1538 type CCPIVolatilitySurface = ForeignPtr CCPIVolatilitySurface'
1539 -- | A CPI (zero-inflation) volatility surface, quoted via 'volatility'\/'totalVariance' at
1540 -- (maturity, strike) pairs -- same shape as 'YoYOptionletVolatilitySurface', a plain
1541 -- 'VolatilityTermStructure' leaf constructed and consumed via a @Handle@. Unlike
1542 -- 'YoYOptionletVolatilitySurface' it feeds no pricing engine in QL 1.43: 'CPICapFloor' prices
1543 -- purely off 'QuantLib.TermStructure.InflationVolatility.CPICapFloorTermPriceSurface' via
1544 -- 'QuantLib.PricingEngine.interpolatingCPICapFloorEngine', and 'CPICouponPricer' (the type that
1545 -- would consume this) is itself explicitly unfinished upstream for vol-dependent coupons (no
1546 -- concrete descendant exists to bind, unlike 'YoYInflationCouponPricer's three) -- so this type
1547 -- stands alone as a queryable surface, not (yet) as engine\/pricer plumbing.
1548 type CPIVolatilitySurface = GenVolatilityTermStructure CCPIVolatilitySurface
1549 type GenBlackVolTermStructure bv = GenVolatilityTermStructure (AnyOf CBlackVolTermStructure' bv)
1550 type CBlackVolTermStructure = ForeignPtr CBlackVolTermStructure'
1551 type BlackVolTermStructure = GenBlackVolTermStructure CBlackVolTermStructure
1552 type CRelinkableBlackVolTermStructure = ForeignPtr CRelinkableBlackVolTermStructure'
1553 -- | A Black vol surface held behind a relinkable handle. It /is/ a 'BlackVolTermStructure' --
1554 -- pass it anywhere one is expected and it upcasts like any other hierarchy member, sharing its
1555 -- @Link@ so that a later 'QuantLib.TermStructure.Volatility.linkBlackVolTo' reaches everything
1556 -- already built on it. Mirrors 'RelinkableYieldTermStructure'.
1557 type RelinkableBlackVolTermStructure = GenBlackVolTermStructure CRelinkableBlackVolTermStructure
1558 type CBlackVarianceCurve = ForeignPtr CBlackVarianceCurve'
1559 type BlackVarianceCurve = GenBlackVolTermStructure CBlackVarianceCurve
1560 type CBlackVolatilitySurfaceDelta = ForeignPtr CBlackVolatilitySurfaceDelta'
1561 type BlackVolatilitySurfaceDelta = GenBlackVolTermStructure CBlackVolatilitySurfaceDelta
1562 type CCallableBondVolatilityStructure = ForeignPtr CCallableBondVolatilityStructure'
1563 type CallableBondVolatilityStructure = GenTermStructure CCallableBondVolatilityStructure
1564 type CDefaultProbabilityTermStructure = ForeignPtr CDefaultProbabilityTermStructure'
1565 type DefaultProbabilityTermStructure = GenTermStructure CDefaultProbabilityTermStructure
1566 type CZeroInflationTermStructure = ForeignPtr CZeroInflationTermStructure'
1567 type ZeroInflationTermStructure = GenTermStructure CZeroInflationTermStructure
1568 type CYoYInflationTermStructure = ForeignPtr CYoYInflationTermStructure'
1569 type YoYInflationTermStructure = GenTermStructure CYoYInflationTermStructure
1570 type CCommodityCurve = ForeignPtr CCommodityCurve'
1571 -- | A plain 'TermStructure' leaf (not a 'YieldTermStructure' -- it has no discount-factor
1572 -- semantics, just an interpolated price curve), constructed and consumed by @shared_ptr@ like
1573 -- 'CallableBondVolatilityStructure'\/'DefaultProbabilityTermStructure', never a @Handle@.
1574 type CommodityCurve = GenTermStructure CCommodityCurve
1575 data CYoYCapFloorTermPriceSurface'
1576 type CYoYCapFloorTermPriceSurface = ForeignPtr CYoYCapFloorTermPriceSurface'
1577 -- | Prices YoY cap\/floors by cap\/floor-surface intersection and put\/call parity, deriving an
1578 -- ATM YoY swap curve as a side effect -- the market-data input the YoY optionlet stripper
1579 -- ('QuantLib.TermStructure.InflationVolatility.kInterpolatedYoYOptionletVolatilitySurfaceBlack'
1580 -- et al.) bootstraps from. A plain 'TermStructure' leaf, constructed and consumed by
1581 -- @shared_ptr@ like 'CPICapFloorTermPriceSurface', never a @Handle@. Takes independent
1582 -- 'Interpolation2D' (cap\/floor price grid) and 'Interpolation' (per-maturity) choices --
1583 -- a different template (@InterpolatedYoYCapFloorTermPriceSurface@) from
1584 -- 'CPICapFloorTermPriceSurface's @InterpolatedCPICapFloorTermPriceSurface@, hence the separate
1585 -- 2-D\/1-D pair rather than 'CPICapFloorTermPriceSurface's single 'Interpolation2D'.
1586 type YoYCapFloorTermPriceSurface = GenTermStructure CYoYCapFloorTermPriceSurface
1587 data CCPICapFloorTermPriceSurface'
1588 type CCPICapFloorTermPriceSurface = ForeignPtr CCPICapFloorTermPriceSurface'
1589 -- | Prices CPI cap\/floors by interpolation and put\/call parity off a market strike\/maturity
1590 -- price grid, not by any vol model (see 'CPICapFloor's own comment) -- a plain 'TermStructure'
1591 -- leaf, constructed and consumed by @shared_ptr@ like 'CommodityCurve', never a @Handle@ (wrapped
1592 -- into one at the point of use, e.g. 'QuantLib.PricingEngine.interpolatingCPICapFloorEngine').
1593 -- Takes an 'Interpolation2D' choice for the cap\/floor price grid -- a different template
1594 -- (@InterpolatedCPICapFloorTermPriceSurface@) from 'YoYCapFloorTermPriceSurface's
1595 -- @InterpolatedYoYCapFloorTermPriceSurface@, hence its own single 2-D slot rather than
1596 -- 'YoYCapFloorTermPriceSurface's separate 2-D\/1-D pair.
1597 type CPICapFloorTermPriceSurface = GenTermStructure CCPICapFloorTermPriceSurface
1598 foreign import ccall unsafe "ql.h &qlFreeTermStructure" qlFreeTermStructure :: FinalizerPtr CTermStructure'
1599 foreign import ccall unsafe "ql.h &qlFreeVolatilityTermStructure" qlFreeVolatilityTermStructure :: FinalizerPtr CVolatilityTermStructure'
1600 foreign import ccall unsafe "ql.h &qlFreeOptionletVolatilityStructure" qlFreeOptionletVolatilityStructure :: FinalizerPtr COptionletVolatilityStructure'
1601 foreign import ccall unsafe "ql.h &qlFreeRelinkableOptionletVolatilityStructure" qlFreeRelinkableOptionletVolatilityStructure :: FinalizerPtr CRelinkableOptionletVolatilityStructure'
1602 foreign import ccall unsafe "ql.h &qlFreeSwaptionVolatilityStructure" qlFreeSwaptionVolatilityStructure :: FinalizerPtr CSwaptionVolatilityStructure'
1603 foreign import ccall unsafe "ql.h &qlFreeRelinkableSwaptionVolatilityStructure" qlFreeRelinkableSwaptionVolatilityStructure :: FinalizerPtr CRelinkableSwaptionVolatilityStructure'
1604 foreign import ccall unsafe "ql.h &qlFreeSabrSwaptionVolatilityCube" qlFreeSabrSwaptionVolatilityCube :: FinalizerPtr CSabrSwaptionVolatilityCube'
1605 foreign import ccall unsafe "ql.h &qlFreeInterpolatedSwaptionVolatilityCube" qlFreeInterpolatedSwaptionVolatilityCube :: FinalizerPtr CInterpolatedSwaptionVolatilityCube'
1606 foreign import ccall unsafe "ql.h &qlFreeCapFloorTermVolatilityStructure" qlFreeCapFloorTermVolatilityStructure :: FinalizerPtr CCapFloorTermVolatilityStructure'
1607 foreign import ccall unsafe "ql.h &qlFreeCapFloorTermVolCurve" qlFreeCapFloorTermVolCurve :: FinalizerPtr CCapFloorTermVolCurve'
1608 foreign import ccall unsafe "ql.h &qlFreeCapFloorTermVolSurface" qlFreeCapFloorTermVolSurface :: FinalizerPtr CCapFloorTermVolSurface'
1609 foreign import ccall unsafe "ql.h &qlFreeBlackAtmVolCurve" qlFreeBlackAtmVolCurve :: FinalizerPtr CBlackAtmVolCurve'
1610 foreign import ccall unsafe "ql.h &qlFreeBlackVolSurface" qlFreeBlackVolSurface :: FinalizerPtr CBlackVolSurface'
1611 foreign import ccall unsafe "ql.h &qlFreeAbcdAtmVolCurve" qlFreeAbcdAtmVolCurve :: FinalizerPtr CAbcdAtmVolCurve'
1612 foreign import ccall unsafe "ql.h &qlFreeSabrVolSurface" qlFreeSabrVolSurface :: FinalizerPtr CSabrVolSurface'
1613 foreign import ccall unsafe "ql.h &qlFreeLocalVolTermStructure" qlFreeLocalVolTermStructure :: FinalizerPtr CLocalVolTermStructure'
1614 foreign import ccall unsafe "ql.h &qlFreeYoYOptionletVolatilitySurface" qlFreeYoYOptionletVolatilitySurface :: FinalizerPtr CYoYOptionletVolatilitySurface'
1615 foreign import ccall unsafe "ql.h &qlFreeCPIVolatilitySurface" qlFreeCPIVolatilitySurface :: FinalizerPtr CCPIVolatilitySurface'
1616 foreign import ccall unsafe "ql.h &qlFreeBlackVolTermStructure" qlFreeBlackVolTermStructure :: FinalizerPtr CBlackVolTermStructure'
1617 foreign import ccall unsafe "ql.h &qlFreeRelinkableBlackVolTermStructure" qlFreeRelinkableBlackVolTermStructure :: FinalizerPtr CRelinkableBlackVolTermStructure'
1618 foreign import ccall unsafe "ql.h &qlFreeBlackVarianceCurve" qlFreeBlackVarianceCurve :: FinalizerPtr CBlackVarianceCurve'
1619 foreign import ccall unsafe "ql.h &qlFreeBlackVolatilitySurfaceDelta" qlFreeBlackVolatilitySurfaceDelta :: FinalizerPtr CBlackVolatilitySurfaceDelta'
1620 foreign import ccall unsafe "ql.h &qlFreeYieldTermStructure" qlFreeYieldTermStructure :: FinalizerPtr CYieldTermStructure'
1621 foreign import ccall unsafe "ql.h &qlFreeFittedBondDiscountCurve" qlFreeFittedBondDiscountCurve :: FinalizerPtr CFittedBondDiscountCurve'
1622 foreign import ccall unsafe "ql.h &qlFreeRelinkableYieldTermStructure" qlFreeRelinkableYieldTermStructure :: FinalizerPtr CRelinkableYieldTermStructure'
1623 foreign import ccall unsafe "ql.h &qlFreeCallableBondVolatilityStructure" qlFreeCallableBondVolatilityStructure :: FinalizerPtr CCallableBondVolatilityStructure'
1624 foreign import ccall unsafe "ql.h &qlFreeDefaultProbabilityTermStructure" qlFreeDefaultProbabilityTermStructure :: FinalizerPtr CDefaultProbabilityTermStructure'
1625 foreign import ccall unsafe "ql.h &qlFreeZeroInflationTermStructure" qlFreeZeroInflationTermStructure :: FinalizerPtr CZeroInflationTermStructure'
1626 foreign import ccall unsafe "ql.h &qlFreeYoYInflationTermStructure" qlFreeYoYInflationTermStructure :: FinalizerPtr CYoYInflationTermStructure'
1627 foreign import ccall unsafe "ql.h &qlFreeYoYCapFloorTermPriceSurface" qlFreeYoYCapFloorTermPriceSurface :: FinalizerPtr CYoYCapFloorTermPriceSurface'
1628 foreign import ccall unsafe "ql.h &qlFreeCPICapFloorTermPriceSurface" qlFreeCPICapFloorTermPriceSurface :: FinalizerPtr CCPICapFloorTermPriceSurface'
1629 foreign import ccall unsafe "ql.h &qlFreeCommodityCurve" qlFreeCommodityCurve :: FinalizerPtr CCommodityCurve'
1630 instance Finalizable CTermStructure' where finalize = qlFreeTermStructure
1631 instance Finalizable CVolatilityTermStructure' where finalize = qlFreeVolatilityTermStructure
1632 instance Finalizable COptionletVolatilityStructure' where finalize = qlFreeOptionletVolatilityStructure
1633 instance Finalizable CRelinkableOptionletVolatilityStructure' where finalize = qlFreeRelinkableOptionletVolatilityStructure
1634 instance Finalizable CSwaptionVolatilityStructure' where finalize = qlFreeSwaptionVolatilityStructure
1635 instance Finalizable CRelinkableSwaptionVolatilityStructure' where finalize = qlFreeRelinkableSwaptionVolatilityStructure
1636 instance Finalizable CSabrSwaptionVolatilityCube' where finalize = qlFreeSabrSwaptionVolatilityCube
1637 instance Finalizable CInterpolatedSwaptionVolatilityCube' where finalize = qlFreeInterpolatedSwaptionVolatilityCube
1638 instance Finalizable CCapFloorTermVolatilityStructure' where finalize = qlFreeCapFloorTermVolatilityStructure
1639 instance Finalizable CCapFloorTermVolCurve' where finalize = qlFreeCapFloorTermVolCurve
1640 instance Finalizable CCapFloorTermVolSurface' where finalize = qlFreeCapFloorTermVolSurface
1641 instance Finalizable CBlackAtmVolCurve' where finalize = qlFreeBlackAtmVolCurve
1642 instance Finalizable CBlackVolSurface' where finalize = qlFreeBlackVolSurface
1643 instance Finalizable CAbcdAtmVolCurve' where finalize = qlFreeAbcdAtmVolCurve
1644 instance Finalizable CSabrVolSurface' where finalize = qlFreeSabrVolSurface
1645 instance Finalizable CLocalVolTermStructure' where finalize = qlFreeLocalVolTermStructure
1646 instance Finalizable CYoYOptionletVolatilitySurface' where finalize = qlFreeYoYOptionletVolatilitySurface
1647 instance Finalizable CCPIVolatilitySurface' where finalize = qlFreeCPIVolatilitySurface
1648 instance Finalizable CBlackVolTermStructure' where finalize = qlFreeBlackVolTermStructure
1649 instance Finalizable CRelinkableBlackVolTermStructure' where finalize = qlFreeRelinkableBlackVolTermStructure
1650 instance Finalizable CBlackVarianceCurve' where finalize = qlFreeBlackVarianceCurve
1651 instance Finalizable CBlackVolatilitySurfaceDelta' where finalize = qlFreeBlackVolatilitySurfaceDelta
1652 instance Finalizable CYieldTermStructure' where finalize = qlFreeYieldTermStructure
1653 instance Finalizable CFittedBondDiscountCurve' where finalize = qlFreeFittedBondDiscountCurve
1654 instance Finalizable CRelinkableYieldTermStructure' where finalize = qlFreeRelinkableYieldTermStructure
1655 instance Finalizable CCallableBondVolatilityStructure' where finalize = qlFreeCallableBondVolatilityStructure
1656 instance Finalizable CDefaultProbabilityTermStructure' where finalize = qlFreeDefaultProbabilityTermStructure
1657 instance Finalizable CZeroInflationTermStructure' where finalize = qlFreeZeroInflationTermStructure
1658 instance Finalizable CYoYInflationTermStructure' where finalize = qlFreeYoYInflationTermStructure
1659 instance Finalizable CYoYCapFloorTermPriceSurface' where finalize = qlFreeYoYCapFloorTermPriceSurface
1660 instance Finalizable CCPICapFloorTermPriceSurface' where finalize = qlFreeCPICapFloorTermPriceSurface
1661 instance Finalizable CCommodityCurve' where finalize = qlFreeCommodityCurve
1662 foreign import ccall "ql.h qlYieldTermStructureAsTermStructure" qlYieldTermStructureAsTermStructure :: Ptr CYieldTermStructure' -> IO (Ptr CTermStructure')
1663 foreign import ccall "ql.h qlFittedBondDiscountCurveAsYieldTermStructure" qlFittedBondDiscountCurveAsYieldTermStructure :: Ptr CFittedBondDiscountCurve' -> IO (Ptr CYieldTermStructure')
1664 foreign import ccall "ql.h qlRelinkableYieldTermStructureAsYieldTermStructure" qlRelinkableYieldTermStructureAsYieldTermStructure :: Ptr CRelinkableYieldTermStructure' -> IO (Ptr CYieldTermStructure')
1665 foreign import ccall "ql.h qlVolatilityTermStructureAsTermStructure" qlVolatilityTermStructureAsTermStructure :: Ptr CVolatilityTermStructure' -> IO (Ptr CTermStructure')
1666 foreign import ccall "ql.h qlOptionletVolatilityStructureAsVolatilityTermStructure" qlOptionletVolatilityStructureAsVolatilityTermStructure :: Ptr COptionletVolatilityStructure' -> IO (Ptr CVolatilityTermStructure')
1667 foreign import ccall "ql.h qlRelinkableOptionletVolatilityStructureAsOptionletVolatilityStructure" qlRelinkableOptionletVolatilityStructureAsOptionletVolatilityStructure :: Ptr CRelinkableOptionletVolatilityStructure' -> IO (Ptr COptionletVolatilityStructure')
1668 foreign import ccall "ql.h qlBlackVolTermStructureAsVolatilityTermStructure" qlBlackVolTermStructureAsVolatilityTermStructure :: Ptr CBlackVolTermStructure' -> IO (Ptr CVolatilityTermStructure')
1669 foreign import ccall "ql.h qlRelinkableBlackVolTermStructureAsBlackVolTermStructure" qlRelinkableBlackVolTermStructureAsBlackVolTermStructure :: Ptr CRelinkableBlackVolTermStructure' -> IO (Ptr CBlackVolTermStructure')
1670 foreign import ccall "ql.h qlBlackVarianceCurveAsBlackVolTermStructure" qlBlackVarianceCurveAsBlackVolTermStructure :: Ptr CBlackVarianceCurve' -> IO (Ptr CBlackVolTermStructure')
1671 foreign import ccall "ql.h qlBlackVolatilitySurfaceDeltaAsBlackVolTermStructure" qlBlackVolatilitySurfaceDeltaAsBlackVolTermStructure :: Ptr CBlackVolatilitySurfaceDelta' -> IO (Ptr CBlackVolTermStructure')
1672 foreign import ccall "ql.h qlSwaptionVolatilityStructureAsVolatilityTermStructure" qlSwaptionVolatilityStructureAsVolatilityTermStructure :: Ptr CSwaptionVolatilityStructure' -> IO (Ptr CVolatilityTermStructure')
1673 foreign import ccall "ql.h qlRelinkableSwaptionVolatilityStructureAsSwaptionVolatilityStructure" qlRelinkableSwaptionVolatilityStructureAsSwaptionVolatilityStructure :: Ptr CRelinkableSwaptionVolatilityStructure' -> IO (Ptr CSwaptionVolatilityStructure')
1674 foreign import ccall "ql.h qlSabrSwaptionVolatilityCubeAsSwaptionVolatilityStructure" qlSabrSwaptionVolatilityCubeAsSwaptionVolatilityStructure :: Ptr CSabrSwaptionVolatilityCube' -> IO (Ptr CSwaptionVolatilityStructure')
1675 foreign import ccall "ql.h qlInterpolatedSwaptionVolatilityCubeAsSwaptionVolatilityStructure" qlInterpolatedSwaptionVolatilityCubeAsSwaptionVolatilityStructure :: Ptr CInterpolatedSwaptionVolatilityCube' -> IO (Ptr CSwaptionVolatilityStructure')
1676 foreign import ccall "ql.h qlCapFloorTermVolatilityStructureAsVolatilityTermStructure" qlCapFloorTermVolatilityStructureAsVolatilityTermStructure :: Ptr CCapFloorTermVolatilityStructure' -> IO (Ptr CVolatilityTermStructure')
1677 foreign import ccall "ql.h qlCapFloorTermVolCurveAsCapFloorTermVolatilityStructure" qlCapFloorTermVolCurveAsCapFloorTermVolatilityStructure :: Ptr CCapFloorTermVolCurve' -> IO (Ptr CCapFloorTermVolatilityStructure')
1678 foreign import ccall "ql.h qlCapFloorTermVolSurfaceAsCapFloorTermVolatilityStructure" qlCapFloorTermVolSurfaceAsCapFloorTermVolatilityStructure :: Ptr CCapFloorTermVolSurface' -> IO (Ptr CCapFloorTermVolatilityStructure')
1679 foreign import ccall "ql.h qlBlackAtmVolCurveAsVolatilityTermStructure" qlBlackAtmVolCurveAsVolatilityTermStructure :: Ptr CBlackAtmVolCurve' -> IO (Ptr CVolatilityTermStructure')
1680 foreign import ccall "ql.h qlBlackVolSurfaceAsBlackAtmVolCurve" qlBlackVolSurfaceAsBlackAtmVolCurve :: Ptr CBlackVolSurface' -> IO (Ptr CBlackAtmVolCurve')
1681 foreign import ccall "ql.h qlAbcdAtmVolCurveAsBlackAtmVolCurve" qlAbcdAtmVolCurveAsBlackAtmVolCurve :: Ptr CAbcdAtmVolCurve' -> IO (Ptr CBlackAtmVolCurve')
1682 foreign import ccall "ql.h qlSabrVolSurfaceAsBlackVolSurface" qlSabrVolSurfaceAsBlackVolSurface :: Ptr CSabrVolSurface' -> IO (Ptr CBlackVolSurface')
1683 foreign import ccall "ql.h qlLocalVolTermStructureAsVolatilityTermStructure" qlLocalVolTermStructureAsVolatilityTermStructure :: Ptr CLocalVolTermStructure' -> IO (Ptr CVolatilityTermStructure')
1684 foreign import ccall "ql.h qlYoYOptionletVolatilitySurfaceAsVolatilityTermStructure" qlYoYOptionletVolatilitySurfaceAsVolatilityTermStructure :: Ptr CYoYOptionletVolatilitySurface' -> IO (Ptr CVolatilityTermStructure')
1685 foreign import ccall "ql.h qlCPIVolatilitySurfaceAsVolatilityTermStructure" qlCPIVolatilitySurfaceAsVolatilityTermStructure :: Ptr CCPIVolatilitySurface' -> IO (Ptr CVolatilityTermStructure')
1686 foreign import ccall "ql.h qlCallableBondVolatilityStructureAsTermStructure" qlCallableBondVolatilityStructureAsTermStructure :: Ptr CCallableBondVolatilityStructure' -> IO (Ptr CTermStructure')
1687 foreign import ccall "ql.h qlDefaultProbabilityTermStructureAsTermStructure" qlDefaultProbabilityTermStructureAsTermStructure :: Ptr CDefaultProbabilityTermStructure' -> IO (Ptr CTermStructure')
1688 foreign import ccall "ql.h qlZeroInflationTermStructureAsTermStructure" qlZeroInflationTermStructureAsTermStructure :: Ptr CZeroInflationTermStructure' -> IO (Ptr CTermStructure')
1689 foreign import ccall "ql.h qlYoYInflationTermStructureAsTermStructure" qlYoYInflationTermStructureAsTermStructure :: Ptr CYoYInflationTermStructure' -> IO (Ptr CTermStructure')
1690 foreign import ccall "ql.h qlYoYCapFloorTermPriceSurfaceAsTermStructure" qlYoYCapFloorTermPriceSurfaceAsTermStructure :: Ptr CYoYCapFloorTermPriceSurface' -> IO (Ptr CTermStructure')
1691 foreign import ccall "ql.h qlCPICapFloorTermPriceSurfaceAsTermStructure" qlCPICapFloorTermPriceSurfaceAsTermStructure :: Ptr CCPICapFloorTermPriceSurface' -> IO (Ptr CTermStructure')
1692 foreign import ccall "ql.h qlCommodityCurveAsTermStructure" qlCommodityCurveAsTermStructure :: Ptr CCommodityCurve' -> IO (Ptr CTermStructure')
1693 instance Upcastable CYieldTermStructure' where {type Base CYieldTermStructure' = CTermStructure'; upcast = qlYieldTermStructureAsTermStructure}
1694 instance Upcastable CFittedBondDiscountCurve' where {type Base CFittedBondDiscountCurve' = CYieldTermStructure'; upcast = qlFittedBondDiscountCurveAsYieldTermStructure}
1695 instance Upcastable CRelinkableYieldTermStructure' where {type Base CRelinkableYieldTermStructure' = CYieldTermStructure'; upcast = qlRelinkableYieldTermStructureAsYieldTermStructure}
1696 instance Upcastable CVolatilityTermStructure' where {type Base CVolatilityTermStructure' = CTermStructure'; upcast = qlVolatilityTermStructureAsTermStructure}
1697 instance Upcastable CCallableBondVolatilityStructure' where {type Base CCallableBondVolatilityStructure' = CTermStructure'; upcast = qlCallableBondVolatilityStructureAsTermStructure}
1698 instance Upcastable CDefaultProbabilityTermStructure' where {type Base CDefaultProbabilityTermStructure' = CTermStructure'; upcast = qlDefaultProbabilityTermStructureAsTermStructure}
1699 instance Upcastable CZeroInflationTermStructure' where {type Base CZeroInflationTermStructure' = CTermStructure'; upcast = qlZeroInflationTermStructureAsTermStructure}
1700 instance Upcastable CYoYInflationTermStructure' where {type Base CYoYInflationTermStructure' = CTermStructure'; upcast = qlYoYInflationTermStructureAsTermStructure}
1701 instance Upcastable CYoYCapFloorTermPriceSurface' where {type Base CYoYCapFloorTermPriceSurface' = CTermStructure'; upcast = qlYoYCapFloorTermPriceSurfaceAsTermStructure}
1702 instance Upcastable CCPICapFloorTermPriceSurface' where {type Base CCPICapFloorTermPriceSurface' = CTermStructure'; upcast = qlCPICapFloorTermPriceSurfaceAsTermStructure}
1703 instance Upcastable CCommodityCurve' where {type Base CCommodityCurve' = CTermStructure'; upcast = qlCommodityCurveAsTermStructure}
1704 instance Upcastable CBlackVolTermStructure' where {type Base CBlackVolTermStructure' = CVolatilityTermStructure'; upcast = qlBlackVolTermStructureAsVolatilityTermStructure}
1705 instance Upcastable CRelinkableBlackVolTermStructure' where {type Base CRelinkableBlackVolTermStructure' = CBlackVolTermStructure'; upcast = qlRelinkableBlackVolTermStructureAsBlackVolTermStructure}
1706 instance Upcastable CBlackVarianceCurve' where {type Base CBlackVarianceCurve' = CBlackVolTermStructure'; upcast = qlBlackVarianceCurveAsBlackVolTermStructure}
1707 instance Upcastable CBlackVolatilitySurfaceDelta' where {type Base CBlackVolatilitySurfaceDelta' = CBlackVolTermStructure'; upcast = qlBlackVolatilitySurfaceDeltaAsBlackVolTermStructure}
1708 instance Upcastable COptionletVolatilityStructure' where {type Base COptionletVolatilityStructure' = CVolatilityTermStructure'; upcast = qlOptionletVolatilityStructureAsVolatilityTermStructure}
1709 instance Upcastable CRelinkableOptionletVolatilityStructure' where {type Base CRelinkableOptionletVolatilityStructure' = COptionletVolatilityStructure'; upcast = qlRelinkableOptionletVolatilityStructureAsOptionletVolatilityStructure}
1710 instance Upcastable CSwaptionVolatilityStructure' where {type Base CSwaptionVolatilityStructure' = CVolatilityTermStructure'; upcast = qlSwaptionVolatilityStructureAsVolatilityTermStructure}
1711 instance Upcastable CRelinkableSwaptionVolatilityStructure' where {type Base CRelinkableSwaptionVolatilityStructure' = CSwaptionVolatilityStructure'; upcast = qlRelinkableSwaptionVolatilityStructureAsSwaptionVolatilityStructure}
1712 instance Upcastable CSabrSwaptionVolatilityCube' where {type Base CSabrSwaptionVolatilityCube' = CSwaptionVolatilityStructure'; upcast = qlSabrSwaptionVolatilityCubeAsSwaptionVolatilityStructure}
1713 instance Upcastable CInterpolatedSwaptionVolatilityCube' where {type Base CInterpolatedSwaptionVolatilityCube' = CSwaptionVolatilityStructure'; upcast = qlInterpolatedSwaptionVolatilityCubeAsSwaptionVolatilityStructure}
1714 instance Upcastable CCapFloorTermVolatilityStructure' where {type Base CCapFloorTermVolatilityStructure' = CVolatilityTermStructure'; upcast = qlCapFloorTermVolatilityStructureAsVolatilityTermStructure}
1715 instance Upcastable CCapFloorTermVolCurve' where {type Base CCapFloorTermVolCurve' = CCapFloorTermVolatilityStructure'; upcast = qlCapFloorTermVolCurveAsCapFloorTermVolatilityStructure}
1716 instance Upcastable CCapFloorTermVolSurface' where {type Base CCapFloorTermVolSurface' = CCapFloorTermVolatilityStructure'; upcast = qlCapFloorTermVolSurfaceAsCapFloorTermVolatilityStructure}
1717 instance Upcastable CBlackAtmVolCurve' where {type Base CBlackAtmVolCurve' = CVolatilityTermStructure'; upcast = qlBlackAtmVolCurveAsVolatilityTermStructure}
1718 instance Upcastable CBlackVolSurface' where {type Base CBlackVolSurface' = CBlackAtmVolCurve'; upcast = qlBlackVolSurfaceAsBlackAtmVolCurve}
1719 instance Upcastable CAbcdAtmVolCurve' where {type Base CAbcdAtmVolCurve' = CBlackAtmVolCurve'; upcast = qlAbcdAtmVolCurveAsBlackAtmVolCurve}
1720 instance Upcastable CSabrVolSurface' where {type Base CSabrVolSurface' = CBlackVolSurface'; upcast = qlSabrVolSurfaceAsBlackVolSurface}
1721 instance Upcastable CLocalVolTermStructure' where {type Base CLocalVolTermStructure' = CVolatilityTermStructure'; upcast = qlLocalVolTermStructureAsVolatilityTermStructure}
1722 instance Upcastable CYoYOptionletVolatilitySurface' where {type Base CYoYOptionletVolatilitySurface' = CVolatilityTermStructure'; upcast = qlYoYOptionletVolatilitySurfaceAsVolatilityTermStructure}
1723 instance Upcastable CCPIVolatilitySurface' where {type Base CCPIVolatilitySurface' = CVolatilityTermStructure'; upcast = qlCPIVolatilitySurfaceAsVolatilityTermStructure}
1724 asTermStructure :: GenTermStructure t -> IO TermStructure
1725 asTermStructure = transferGenForeignPtr peekTermStructure . getTermStructure
1726 withTermStructure :: GenTermStructure t -> (Ptr CTermStructure' -> IO b) -> IO b
1727 withTermStructure = withGenForeignPtr . getTermStructure
1728 withGenTermStructure :: GenTermStructure (ForeignPtr t) -> (Ptr t -> IO b) -> IO b
1729 withGenTermStructure = withForeignPtr . ptr . getTermStructure
1730 peekTermStructure :: Ptr CTermStructure' -> IO TermStructure
1731 peekTermStructure = GenTermStructure <.> newCastForeignPtr
1732
1733 asVolatilityTermStructure :: GenVolatilityTermStructure v -> IO VolatilityTermStructure
1734 asVolatilityTermStructure = transferGenForeignPtr peekVolatilityTermStructure . peel . getTermStructure
1735 peekVolatilityTermStructure :: Ptr CVolatilityTermStructure' -> IO VolatilityTermStructure
1736 peekVolatilityTermStructure = newCastForeignPtr >=> newGenVolatilityTermStructure
1737 peekGenVolatilityTermStructure :: (Finalizable v, Upcastable v, Base v ~ CVolatilityTermStructure') => Ptr v -> IO (GenVolatilityTermStructure (ForeignPtr v))
1738 peekGenVolatilityTermStructure = newGenForeignPtr >=> newGenVolatilityTermStructure
1739 withVolatilityTermStructure :: GenVolatilityTermStructure v -> (Ptr CVolatilityTermStructure' -> IO b) -> IO b
1740 withVolatilityTermStructure = withGenForeignPtr . peel . getTermStructure
1741 withGenVolatilityTermStructure :: GenVolatilityTermStructure (ForeignPtr v) -> (Ptr v -> IO b) -> IO b
1742 withGenVolatilityTermStructure = withForeignPtr . ptr . peel . getTermStructure
1743 newGenVolatilityTermStructure :: GenForeignPtr v CVolatilityTermStructure' -> IO (GenVolatilityTermStructure v)
1744 newGenVolatilityTermStructure = pure . GenTermStructure . newAnyOf
1745
1746 asBlackVolTermStructure :: GenBlackVolTermStructure bv -> IO BlackVolTermStructure
1747 asBlackVolTermStructure = transferGenForeignPtr peekBlackVolTermStructure . peel . peel . getTermStructure
1748 peekBlackVolTermStructure :: Ptr CBlackVolTermStructure' -> IO BlackVolTermStructure
1749 peekBlackVolTermStructure = newCastForeignPtr >=> newGenBlackVolTermStructure
1750 withBlackVolTermStructure :: GenBlackVolTermStructure bv -> (Ptr CBlackVolTermStructure' -> IO b) -> IO b
1751 withBlackVolTermStructure = withGenForeignPtr . peel . peel . getTermStructure
1752 withMaybeBlackVolTermStructure :: Maybe (GenBlackVolTermStructure bv) -> (Ptr CBlackVolTermStructure' -> IO b) -> IO b
1753 withMaybeBlackVolTermStructure x f = maybe (f nullPtr) (`withBlackVolTermStructure` f) x
1754 newGenBlackVolTermStructure :: GenForeignPtr bv CBlackVolTermStructure' -> IO (GenBlackVolTermStructure bv)
1755 newGenBlackVolTermStructure = pure . GenTermStructure . newAnyOf . newAnyOf
1756
1757 peekBlackVarianceCurve :: Ptr CBlackVarianceCurve' -> IO BlackVarianceCurve
1758 peekBlackVarianceCurve = newGenForeignPtr >=> newGenBlackVolTermStructure
1759 peekRelinkableBlackVolTermStructure :: Ptr CRelinkableBlackVolTermStructure' -> IO RelinkableBlackVolTermStructure
1760 peekRelinkableBlackVolTermStructure = newGenForeignPtr >=> newGenBlackVolTermStructure
1761 withRelinkableBlackVolTermStructure :: RelinkableBlackVolTermStructure -> (Ptr CRelinkableBlackVolTermStructure' -> IO b) -> IO b
1762 withRelinkableBlackVolTermStructure = withForeignPtr . ptr . peel . peel . getTermStructure
1763 withBlackVarianceCurve :: BlackVarianceCurve -> (Ptr CBlackVarianceCurve' -> IO b) -> IO b
1764 withBlackVarianceCurve = withForeignPtr . ptr . peel . peel . getTermStructure
1765 peekBlackVolatilitySurfaceDelta :: Ptr CBlackVolatilitySurfaceDelta' -> IO BlackVolatilitySurfaceDelta
1766 peekBlackVolatilitySurfaceDelta = newGenForeignPtr >=> newGenBlackVolTermStructure
1767 withBlackVolatilitySurfaceDelta :: BlackVolatilitySurfaceDelta -> (Ptr CBlackVolatilitySurfaceDelta' -> IO b) -> IO b
1768 withBlackVolatilitySurfaceDelta = withForeignPtr . ptr . peel . peel . getTermStructure
1769
1770 peekOptionletVolatilityStructure :: Ptr COptionletVolatilityStructure' -> IO OptionletVolatilityStructure
1771 peekOptionletVolatilityStructure = newCastForeignPtr >=> newGenOptionletVolatilityStructure
1772 withOptionletVolatilityStructure :: GenOptionletVolatilityStructure ov -> (Ptr COptionletVolatilityStructure' -> IO b) -> IO b
1773 withOptionletVolatilityStructure = withGenForeignPtr . peel . peel . getTermStructure
1774 withMaybeOptionletVolatilityStructure :: Maybe (GenOptionletVolatilityStructure ov) -> (Ptr COptionletVolatilityStructure' -> IO b) -> IO b
1775 withMaybeOptionletVolatilityStructure x f = maybe (f nullPtr) (`withOptionletVolatilityStructure` f) x
1776 newGenOptionletVolatilityStructure :: GenForeignPtr ov COptionletVolatilityStructure' -> IO (GenOptionletVolatilityStructure ov)
1777 newGenOptionletVolatilityStructure = pure . GenTermStructure . newAnyOf . newAnyOf
1778 peekRelinkableOptionletVolatilityStructure :: Ptr CRelinkableOptionletVolatilityStructure' -> IO RelinkableOptionletVolatilityStructure
1779 peekRelinkableOptionletVolatilityStructure = newGenForeignPtr >=> newGenOptionletVolatilityStructure
1780 withRelinkableOptionletVolatilityStructure :: RelinkableOptionletVolatilityStructure -> (Ptr CRelinkableOptionletVolatilityStructure' -> IO b) -> IO b
1781 withRelinkableOptionletVolatilityStructure = withForeignPtr . ptr . peel . peel . getTermStructure
1782 peekSwaptionVolatilityStructure :: Ptr CSwaptionVolatilityStructure' -> IO SwaptionVolatilityStructure
1783 peekSwaptionVolatilityStructure = newCastForeignPtr >=> newGenSwaptionVolatilityStructure
1784 withSwaptionVolatilityStructure :: GenSwaptionVolatilityStructure sv -> (Ptr CSwaptionVolatilityStructure' -> IO b) -> IO b
1785 withSwaptionVolatilityStructure = withGenForeignPtr . peel . peel . getTermStructure
1786 withMaybeSwaptionVolatilityStructure :: Maybe (GenSwaptionVolatilityStructure sv) -> (Ptr CSwaptionVolatilityStructure' -> IO b) -> IO b
1787 withMaybeSwaptionVolatilityStructure x f = maybe (f nullPtr) (`withSwaptionVolatilityStructure` f) x
1788 newGenSwaptionVolatilityStructure :: GenForeignPtr sv CSwaptionVolatilityStructure' -> IO (GenSwaptionVolatilityStructure sv)
1789 newGenSwaptionVolatilityStructure = pure . GenTermStructure . newAnyOf . newAnyOf
1790 peekRelinkableSwaptionVolatilityStructure :: Ptr CRelinkableSwaptionVolatilityStructure' -> IO RelinkableSwaptionVolatilityStructure
1791 peekRelinkableSwaptionVolatilityStructure = newGenForeignPtr >=> newGenSwaptionVolatilityStructure
1792 withRelinkableSwaptionVolatilityStructure :: RelinkableSwaptionVolatilityStructure -> (Ptr CRelinkableSwaptionVolatilityStructure' -> IO b) -> IO b
1793 withRelinkableSwaptionVolatilityStructure = withForeignPtr . ptr . peel . peel . getTermStructure
1794 peekSabrSwaptionVolatilityCube :: Ptr CSabrSwaptionVolatilityCube' -> IO SabrSwaptionVolatilityCube
1795 peekSabrSwaptionVolatilityCube = newGenForeignPtr >=> newGenSwaptionVolatilityStructure
1796 withSabrSwaptionVolatilityCube :: SabrSwaptionVolatilityCube -> (Ptr CSabrSwaptionVolatilityCube' -> IO b) -> IO b
1797 withSabrSwaptionVolatilityCube = withForeignPtr . ptr . peel . peel . getTermStructure
1798 peekInterpolatedSwaptionVolatilityCube :: Ptr CInterpolatedSwaptionVolatilityCube' -> IO InterpolatedSwaptionVolatilityCube
1799 peekInterpolatedSwaptionVolatilityCube = newGenForeignPtr >=> newGenSwaptionVolatilityStructure
1800 withInterpolatedSwaptionVolatilityCube :: InterpolatedSwaptionVolatilityCube -> (Ptr CInterpolatedSwaptionVolatilityCube' -> IO b) -> IO b
1801 withInterpolatedSwaptionVolatilityCube = withForeignPtr . ptr . peel . peel . getTermStructure
1802 peekCapFloorTermVolatilityStructure :: Ptr CCapFloorTermVolatilityStructure' -> IO CapFloorTermVolatilityStructure
1803 peekCapFloorTermVolatilityStructure = newCastForeignPtr >=> newGenCapFloorTermVolatilityStructure
1804 withGenCapFloorTermVolatilityStructure :: GenCapFloorTermVolatilityStructure c -> (Ptr CCapFloorTermVolatilityStructure' -> IO b) -> IO b
1805 withGenCapFloorTermVolatilityStructure = withGenForeignPtr . peel . peel . getTermStructure
1806 newGenCapFloorTermVolatilityStructure :: GenForeignPtr c CCapFloorTermVolatilityStructure' -> IO (GenCapFloorTermVolatilityStructure c)
1807 newGenCapFloorTermVolatilityStructure = pure . GenTermStructure . newAnyOf . newAnyOf
1808 peekCapFloorTermVolCurve :: Ptr CCapFloorTermVolCurve' -> IO CapFloorTermVolCurve
1809 peekCapFloorTermVolCurve = newGenForeignPtr >=> newGenCapFloorTermVolatilityStructure
1810 withCapFloorTermVolCurve :: CapFloorTermVolCurve -> (Ptr CCapFloorTermVolCurve' -> IO b) -> IO b
1811 withCapFloorTermVolCurve = withForeignPtr . ptr . peel . peel . getTermStructure
1812 peekCapFloorTermVolSurface :: Ptr CCapFloorTermVolSurface' -> IO CapFloorTermVolSurface
1813 peekCapFloorTermVolSurface = newGenForeignPtr >=> newGenCapFloorTermVolatilityStructure
1814 withCapFloorTermVolSurface :: CapFloorTermVolSurface -> (Ptr CCapFloorTermVolSurface' -> IO b) -> IO b
1815 withCapFloorTermVolSurface = withForeignPtr . ptr . peel . peel . getTermStructure
1816 peekBlackAtmVolCurve :: Ptr CBlackAtmVolCurve' -> IO BlackAtmVolCurve
1817 peekBlackAtmVolCurve = newCastForeignPtr >=> newGenBlackAtmVolCurve
1818 withGenBlackAtmVolCurve :: GenBlackAtmVolCurve b -> (Ptr CBlackAtmVolCurve' -> IO r) -> IO r
1819 withGenBlackAtmVolCurve = withGenForeignPtr . peel . peel . getTermStructure
1820 newGenBlackAtmVolCurve :: GenForeignPtr b CBlackAtmVolCurve' -> IO (GenBlackAtmVolCurve b)
1821 newGenBlackAtmVolCurve = pure . GenTermStructure . newAnyOf . newAnyOf
1822 peekAbcdAtmVolCurve :: Ptr CAbcdAtmVolCurve' -> IO AbcdAtmVolCurve
1823 peekAbcdAtmVolCurve = newGenForeignPtr >=> newGenBlackAtmVolCurve
1824 withAbcdAtmVolCurve :: AbcdAtmVolCurve -> (Ptr CAbcdAtmVolCurve' -> IO b) -> IO b
1825 withAbcdAtmVolCurve = withForeignPtr . ptr . peel . peel . getTermStructure
1826 withGenBlackVolSurface :: GenBlackVolSurface b -> (Ptr CBlackVolSurface' -> IO r) -> IO r
1827 withGenBlackVolSurface = withGenForeignPtr . peel . peel . peel . getTermStructure
1828 newGenBlackVolSurface :: GenForeignPtr b CBlackVolSurface' -> IO (GenBlackVolSurface b)
1829 newGenBlackVolSurface = pure . GenTermStructure . newAnyOf . newAnyOf . newAnyOf
1830 peekSabrVolSurface :: Ptr CSabrVolSurface' -> IO SabrVolSurface
1831 peekSabrVolSurface = newGenForeignPtr >=> newGenBlackVolSurface
1832 withSabrVolSurface :: SabrVolSurface -> (Ptr CSabrVolSurface' -> IO b) -> IO b
1833 withSabrVolSurface = withForeignPtr . ptr . peel . peel . peel . getTermStructure
1834 peekLocalVolTermStructure :: Ptr CLocalVolTermStructure' -> IO LocalVolTermStructure
1835 peekLocalVolTermStructure = peekGenVolatilityTermStructure
1836 peekYoYOptionletVolatilityStructure :: Ptr CYoYOptionletVolatilitySurface' -> IO YoYOptionletVolatilitySurface
1837 peekYoYOptionletVolatilityStructure = peekGenVolatilityTermStructure
1838 peekCPIVolatilitySurface :: Ptr CCPIVolatilitySurface' -> IO CPIVolatilitySurface
1839 peekCPIVolatilitySurface = peekGenVolatilityTermStructure
1840 withLocalVolTermStructure :: LocalVolTermStructure -> (Ptr CLocalVolTermStructure' -> IO b) -> IO b
1841 withLocalVolTermStructure = withGenVolatilityTermStructure
1842 withMaybeLocalVolTermStructure :: Maybe LocalVolTermStructure -> (Ptr CLocalVolTermStructure' -> IO b) -> IO b
1843 withMaybeLocalVolTermStructure x f = maybe (f nullPtr) (`withGenVolatilityTermStructure` f) x
1844 peekCallableBondVolatilityStructure :: Ptr CCallableBondVolatilityStructure' -> IO CallableBondVolatilityStructure
1845 peekCallableBondVolatilityStructure = GenTermStructure <.> newGenForeignPtr
1846 peekDefaultProbabilityTermStructure :: Ptr CDefaultProbabilityTermStructure' -> IO DefaultProbabilityTermStructure
1847 peekDefaultProbabilityTermStructure = GenTermStructure <.> newGenForeignPtr
1848 withMaybeDefaultProbabilityTermStructure :: Maybe DefaultProbabilityTermStructure -> (Ptr CDefaultProbabilityTermStructure' -> IO b) -> IO b
1849 withMaybeDefaultProbabilityTermStructure x f = maybe (f nullPtr) (`withGenTermStructure` f) x
1850 peekZeroInflationTermStructure :: Ptr CZeroInflationTermStructure' -> IO ZeroInflationTermStructure
1851 peekZeroInflationTermStructure = GenTermStructure <.> newGenForeignPtr
1852 withMaybeZeroInflationTermStructure :: Maybe ZeroInflationTermStructure -> (Ptr CZeroInflationTermStructure' -> IO b) -> IO b
1853 withMaybeZeroInflationTermStructure x f = maybe (f nullPtr) (`withGenTermStructure` f) x
1854 peekYoYInflationTermStructure :: Ptr CYoYInflationTermStructure' -> IO YoYInflationTermStructure
1855 peekYoYInflationTermStructure = GenTermStructure <.> newGenForeignPtr
1856 withMaybeYoYInflationTermStructure :: Maybe YoYInflationTermStructure -> (Ptr CYoYInflationTermStructure' -> IO b) -> IO b
1857 withMaybeYoYInflationTermStructure x f = maybe (f nullPtr) (`withGenTermStructure` f) x
1858 peekYoYCapFloorTermPriceSurface :: Ptr CYoYCapFloorTermPriceSurface' -> IO YoYCapFloorTermPriceSurface
1859 peekYoYCapFloorTermPriceSurface = GenTermStructure <.> newGenForeignPtr
1860 peekCPICapFloorTermPriceSurface :: Ptr CCPICapFloorTermPriceSurface' -> IO CPICapFloorTermPriceSurface
1861 peekCPICapFloorTermPriceSurface = GenTermStructure <.> newGenForeignPtr
1862 peekCommodityCurve :: Ptr CCommodityCurve' -> IO CommodityCurve
1863 peekCommodityCurve = GenTermStructure <.> newGenForeignPtr
1864 withMaybeCommodityCurve :: Maybe CommodityCurve -> (Ptr CCommodityCurve' -> IO b) -> IO b
1865 withMaybeCommodityCurve x f = maybe (f nullPtr) (`withGenTermStructure` f) x
1866 -- |Peek a possibly-null @CommodityCurve*@ -- @basisOfCurve_@ is a @nullptr@ 'shared_ptr' when no
1867 -- basis curve has been set via 'QuantLib.TermStructure.Commodity.setCommodityCurveBasisOfCurve',
1868 -- not an empty-'Data'-style placeholder (unlike 'peekMaybeCommodityType' et al.).
1869 peekMaybeCommodityCurve :: Ptr CCommodityCurve' -> IO (Maybe CommodityCurve)
1870 peekMaybeCommodityCurve p
1871 | p == nullPtr = pure Nothing
1872 | otherwise = Just <$> peekCommodityCurve p
1873
1874 asYieldTermStructure :: GenYieldTermStructure y -> IO YieldTermStructure
1875 asYieldTermStructure = transferGenForeignPtr peekYieldTermStructure . peel . getTermStructure
1876 peekYieldTermStructure :: Ptr CYieldTermStructure' -> IO YieldTermStructure
1877 peekYieldTermStructure = newCastForeignPtr >=> newGenYieldTermStructure
1878 withYieldTermStructure :: GenYieldTermStructure y -> (Ptr CYieldTermStructure' -> IO b) -> IO b
1879 withYieldTermStructure = withGenForeignPtr . peel . getTermStructure
1880 withMaybeYieldTermStructure :: Maybe (GenYieldTermStructure y) -> (Ptr CYieldTermStructure' -> IO b) -> IO b
1881 withMaybeYieldTermStructure x f = maybe (f nullPtr) (`withYieldTermStructure` f) x
1882 newGenYieldTermStructure :: GenForeignPtr y CYieldTermStructure' -> IO (GenYieldTermStructure y)
1883 newGenYieldTermStructure = pure . GenTermStructure . newAnyOf
1884
1885 peekFittedBondDiscountCurve :: Ptr CFittedBondDiscountCurve' -> IO FittedBondDiscountCurve
1886 peekFittedBondDiscountCurve = newGenForeignPtr >=> newGenYieldTermStructure
1887 peekRelinkableYieldTermStructure :: Ptr CRelinkableYieldTermStructure' -> IO RelinkableYieldTermStructure
1888 peekRelinkableYieldTermStructure = newGenForeignPtr >=> newGenYieldTermStructure
1889 -- | Reach the relinkable handle itself, for the operations that only it has ('linkTo',
1890 -- 'currentLink'). Ordinary curve arguments go through 'withYieldTermStructure' instead,
1891 -- which upcasts.
1892 withRelinkableYieldTermStructure :: RelinkableYieldTermStructure -> (Ptr CRelinkableYieldTermStructure' -> IO b) -> IO b
1893 withRelinkableYieldTermStructure = withForeignPtr . ptr . peel . getTermStructure
1894 withFittedBondDiscountCurve :: FittedBondDiscountCurve -> (Ptr CFittedBondDiscountCurve' -> IO b) -> IO b
1895 withFittedBondDiscountCurve = withForeignPtr . ptr . peel . getTermStructure
1896
1897 -- | > StochasticProcess
1898 -- > ExtOUWithJumpsProcess
1899 -- > GJRGARCHProcess
1900 -- > HybridHestonHullWhiteProcess
1901 -- > KlugeExtOUProcess
1902 -- > LiborForwardModelProcess
1903 -- > StochasticProcessArray
1904 -- > G2Process
1905 -- > G2ForwardProcess
1906 -- > HestonProcess
1907 -- > BatesProcess
1908 -- > StochasticProcess1D
1909 -- > ExtendedOrnsteinUhlenbeckProcess
1910 -- > HullWhiteForwardProcess
1911 -- > HullWhiteProcess
1912 -- > Merton76Process
1913 -- > VarianceGammaProcess
1914 -- > GeneralizedBlackScholesProcess
1915 -- > BlackProcess
1916 type StochasticProcess = GenStochasticProcess CStochasticProcess
1917 data CStochasticProcess'
1918 data CExtOUWithJumpsProcess'
1919 data CGJRGARCHProcess'
1920 data CHybridHestonHullWhiteProcess'
1921 data CKlugeExtOUProcess'
1922 data CLiborForwardModelProcess'
1923 data CStochasticProcessArray'
1924 data CG2Process'
1925 data CG2ForwardProcess'
1926 data CHestonProcess'
1927 data CStochasticProcess1D'
1928 data CBatesProcess'
1929 data CExtendedOrnsteinUhlenbeckProcess'
1930 data CHullWhiteForwardProcess'
1931 data CHullWhiteProcess'
1932 data CMerton76Process'
1933 data CVarianceGammaProcess'
1934 data CGeneralizedBlackScholesProcess'
1935 data CBlackProcess'
1936 newtype GenStochasticProcess p = GenStochasticProcess {getStochasticProcess :: GenForeignPtr p CStochasticProcess'}
1937 type CStochasticProcess = ForeignPtr CStochasticProcess'
1938 type CExtOUWithJumpsProcess = ForeignPtr CExtOUWithJumpsProcess'
1939 type ExtOUWithJumpsProcess = GenStochasticProcess CExtOUWithJumpsProcess
1940 type CGJRGARCHProcess = ForeignPtr CGJRGARCHProcess'
1941 type GJRGARCHProcess = GenStochasticProcess CGJRGARCHProcess
1942 type CHybridHestonHullWhiteProcess = ForeignPtr CHybridHestonHullWhiteProcess'
1943 type HybridHestonHullWhiteProcess = GenStochasticProcess CHybridHestonHullWhiteProcess
1944 type CKlugeExtOUProcess = ForeignPtr CKlugeExtOUProcess'
1945 type KlugeExtOUProcess = GenStochasticProcess CKlugeExtOUProcess
1946 type CLiborForwardModelProcess = ForeignPtr CLiborForwardModelProcess'
1947 type LiborForwardModelProcess = GenStochasticProcess CLiborForwardModelProcess
1948 type CStochasticProcessArray = ForeignPtr CStochasticProcessArray'
1949 type StochasticProcessArray = GenStochasticProcess CStochasticProcessArray
1950 type CG2Process = ForeignPtr CG2Process'
1951 type G2Process = GenStochasticProcess CG2Process
1952 type CG2ForwardProcess = ForeignPtr CG2ForwardProcess'
1953 type G2ForwardProcess = GenStochasticProcess CG2ForwardProcess
1954 type GenHestonProcess hp = GenStochasticProcess (AnyOf CHestonProcess' hp)
1955 type CHestonProcess = ForeignPtr CHestonProcess'
1956 type HestonProcess = GenHestonProcess CHestonProcess
1957 type GenStochasticProcess1D p1d = GenStochasticProcess (AnyOf CStochasticProcess1D' p1d)
1958 type CStochasticProcess1D = ForeignPtr CStochasticProcess1D'
1959 type StochasticProcess1D = GenStochasticProcess1D CStochasticProcess1D
1960 type CMerton76Process = ForeignPtr CMerton76Process'
1961 type Merton76Process = GenStochasticProcess1D CMerton76Process
1962 type CVarianceGammaProcess = ForeignPtr CVarianceGammaProcess'
1963 type VarianceGammaProcess = GenStochasticProcess1D CVarianceGammaProcess
1964 type GenGeneralizedBlackScholesProcess gbs = GenStochasticProcess1D (AnyOf CGeneralizedBlackScholesProcess' gbs)
1965 type CGeneralizedBlackScholesProcess = ForeignPtr CGeneralizedBlackScholesProcess'
1966 type GeneralizedBlackScholesProcess = GenGeneralizedBlackScholesProcess CGeneralizedBlackScholesProcess
1967 type CBlackProcess = ForeignPtr CBlackProcess'
1968 type BlackProcess = GenGeneralizedBlackScholesProcess CBlackProcess
1969 type CBatesProcess = ForeignPtr CBatesProcess'
1970 type BatesProcess = GenHestonProcess CBatesProcess
1971 type CHullWhiteProcess = ForeignPtr CHullWhiteProcess'
1972 type HullWhiteProcess = GenStochasticProcess1D CHullWhiteProcess
1973 type CHullWhiteForwardProcess = ForeignPtr CHullWhiteForwardProcess'
1974 type HullWhiteForwardProcess = GenStochasticProcess1D CHullWhiteForwardProcess
1975 type CExtendedOrnsteinUhlenbeckProcess = ForeignPtr CExtendedOrnsteinUhlenbeckProcess'
1976 type ExtendedOrnsteinUhlenbeckProcess = GenStochasticProcess1D CExtendedOrnsteinUhlenbeckProcess
1977 foreign import ccall unsafe "ql.h &qlFreeStochasticProcess" qlFreeStochasticProcess :: FinalizerPtr CStochasticProcess'
1978 foreign import ccall unsafe "ql.h &qlFreeExtOUWithJumpsProcess" qlFreeExtOUWithJumpsProcess :: FinalizerPtr CExtOUWithJumpsProcess'
1979 foreign import ccall unsafe "ql.h &qlFreeGJRGARCHProcess" qlFreeGJRGARCHProcess :: FinalizerPtr CGJRGARCHProcess'
1980 foreign import ccall unsafe "ql.h &qlFreeHybridHestonHullWhiteProcess" qlFreeHybridHestonHullWhiteProcess :: FinalizerPtr CHybridHestonHullWhiteProcess'
1981 foreign import ccall unsafe "ql.h &qlFreeKlugeExtOUProcess" qlFreeKlugeExtOUProcess :: FinalizerPtr CKlugeExtOUProcess'
1982 foreign import ccall unsafe "ql.h &qlFreeLiborForwardModelProcess" qlFreeLiborForwardModelProcess :: FinalizerPtr CLiborForwardModelProcess'
1983 foreign import ccall unsafe "ql.h &qlFreeStochasticProcessArray" qlFreeStochasticProcessArray :: FinalizerPtr CStochasticProcessArray'
1984 foreign import ccall unsafe "ql.h &qlFreeG2Process" qlFreeG2Process :: FinalizerPtr CG2Process'
1985 foreign import ccall unsafe "ql.h &qlFreeG2ForwardProcess" qlFreeG2ForwardProcess :: FinalizerPtr CG2ForwardProcess'
1986 foreign import ccall unsafe "ql.h &qlFreeHestonProcess" qlFreeHestonProcess :: FinalizerPtr CHestonProcess'
1987 foreign import ccall unsafe "ql.h &qlFreeStochasticProcess1D" qlFreeStochasticProcess1D :: FinalizerPtr CStochasticProcess1D'
1988 foreign import ccall unsafe "ql.h &qlFreeBatesProcess" qlFreeBatesProcess :: FinalizerPtr CBatesProcess'
1989 foreign import ccall unsafe "ql.h &qlFreeExtendedOrnsteinUhlenbeckProcess" qlFreeExtendedOrnsteinUhlenbeckProcess :: FinalizerPtr CExtendedOrnsteinUhlenbeckProcess'
1990 foreign import ccall unsafe "ql.h &qlFreeHullWhiteForwardProcess" qlFreeHullWhiteForwardProcess :: FinalizerPtr CHullWhiteForwardProcess'
1991 foreign import ccall unsafe "ql.h &qlFreeHullWhiteProcess" qlFreeHullWhiteProcess :: FinalizerPtr CHullWhiteProcess'
1992 foreign import ccall unsafe "ql.h &qlFreeMerton76Process" qlFreeMerton76Process :: FinalizerPtr CMerton76Process'
1993 foreign import ccall unsafe "ql.h &qlFreeVarianceGammaProcess" qlFreeVarianceGammaProcess :: FinalizerPtr CVarianceGammaProcess'
1994 foreign import ccall unsafe "ql.h &qlFreeGeneralizedBlackScholesProcess" qlFreeGeneralizedBlackScholesProcess :: FinalizerPtr CGeneralizedBlackScholesProcess'
1995 foreign import ccall unsafe "ql.h &qlFreeBlackProcess" qlFreeBlackProcess :: FinalizerPtr CBlackProcess'
1996 instance Finalizable CStochasticProcess' where finalize = qlFreeStochasticProcess
1997 instance Finalizable CExtOUWithJumpsProcess' where finalize = qlFreeExtOUWithJumpsProcess
1998 instance Finalizable CGJRGARCHProcess' where finalize = qlFreeGJRGARCHProcess
1999 instance Finalizable CHybridHestonHullWhiteProcess' where finalize = qlFreeHybridHestonHullWhiteProcess
2000 instance Finalizable CKlugeExtOUProcess' where finalize = qlFreeKlugeExtOUProcess
2001 instance Finalizable CLiborForwardModelProcess' where finalize = qlFreeLiborForwardModelProcess
2002 instance Finalizable CStochasticProcessArray' where finalize = qlFreeStochasticProcessArray
2003 instance Finalizable CG2Process' where finalize = qlFreeG2Process
2004 instance Finalizable CG2ForwardProcess' where finalize = qlFreeG2ForwardProcess
2005 instance Finalizable CHestonProcess' where finalize = qlFreeHestonProcess
2006 instance Finalizable CStochasticProcess1D' where finalize = qlFreeStochasticProcess1D
2007 instance Finalizable CBatesProcess' where finalize = qlFreeBatesProcess
2008 instance Finalizable CExtendedOrnsteinUhlenbeckProcess' where finalize = qlFreeExtendedOrnsteinUhlenbeckProcess
2009 instance Finalizable CHullWhiteForwardProcess' where finalize = qlFreeHullWhiteForwardProcess
2010 instance Finalizable CHullWhiteProcess' where finalize = qlFreeHullWhiteProcess
2011 instance Finalizable CMerton76Process' where finalize = qlFreeMerton76Process
2012 instance Finalizable CVarianceGammaProcess' where finalize = qlFreeVarianceGammaProcess
2013 instance Finalizable CGeneralizedBlackScholesProcess' where finalize = qlFreeGeneralizedBlackScholesProcess
2014 instance Finalizable CBlackProcess' where finalize = qlFreeBlackProcess
2015 foreign import ccall "ql.h qlExtOUWithJumpsProcessAsStochasticProcess" qlExtOUWithJumpsProcessAsStochasticProcess :: Ptr CExtOUWithJumpsProcess' -> IO (Ptr CStochasticProcess')
2016 foreign import ccall "ql.h qlGJRGARCHProcessAsStochasticProcess" qlGJRGARCHProcessAsStochasticProcess :: Ptr CGJRGARCHProcess' -> IO (Ptr CStochasticProcess')
2017 foreign import ccall "ql.h qlHybridHestonHullWhiteProcessAsStochasticProcess" qlHybridHestonHullWhiteProcessAsStochasticProcess :: Ptr CHybridHestonHullWhiteProcess' -> IO (Ptr CStochasticProcess')
2018 foreign import ccall "ql.h qlKlugeExtOUProcessAsStochasticProcess" qlKlugeExtOUProcessAsStochasticProcess :: Ptr CKlugeExtOUProcess' -> IO (Ptr CStochasticProcess')
2019 foreign import ccall "ql.h qlLiborForwardModelProcessAsStochasticProcess" qlLiborForwardModelProcessAsStochasticProcess :: Ptr CLiborForwardModelProcess' -> IO (Ptr CStochasticProcess')
2020 foreign import ccall "ql.h qlStochasticProcessArrayAsStochasticProcess" qlStochasticProcessArrayAsStochasticProcess :: Ptr CStochasticProcessArray' -> IO (Ptr CStochasticProcess')
2021 foreign import ccall "ql.h qlG2ProcessAsStochasticProcess" qlG2ProcessAsStochasticProcess :: Ptr CG2Process' -> IO (Ptr CStochasticProcess')
2022 foreign import ccall "ql.h qlG2ForwardProcessAsStochasticProcess" qlG2ForwardProcessAsStochasticProcess :: Ptr CG2ForwardProcess' -> IO (Ptr CStochasticProcess')
2023 foreign import ccall "ql.h qlHestonProcessAsStochasticProcess" qlHestonProcessAsStochasticProcess :: Ptr CHestonProcess' -> IO (Ptr CStochasticProcess')
2024 foreign import ccall "ql.h qlStochasticProcess1DAsStochasticProcess" qlStochasticProcess1DAsStochasticProcess :: Ptr CStochasticProcess1D' -> IO (Ptr CStochasticProcess')
2025 foreign import ccall "ql.h qlBatesProcessAsHestonProcess" qlBatesProcessAsHestonProcess :: Ptr CBatesProcess' -> IO (Ptr CHestonProcess')
2026 foreign import ccall "ql.h qlExtendedOrnsteinUhlenbeckProcessAsStochasticProcess1D" qlExtendedOrnsteinUhlenbeckProcessAsStochasticProcess1D :: Ptr CExtendedOrnsteinUhlenbeckProcess' -> IO (Ptr CStochasticProcess1D')
2027 foreign import ccall "ql.h qlHullWhiteForwardProcessAsStochasticProcess1D" qlHullWhiteForwardProcessAsStochasticProcess1D :: Ptr CHullWhiteForwardProcess' -> IO (Ptr CStochasticProcess1D')
2028 foreign import ccall "ql.h qlHullWhiteProcessAsStochasticProcess1D" qlHullWhiteProcessAsStochasticProcess1D :: Ptr CHullWhiteProcess' -> IO (Ptr CStochasticProcess1D')
2029 foreign import ccall "ql.h qlMerton76ProcessAsStochasticProcess1D" qlMerton76ProcessAsStochasticProcess1D :: Ptr CMerton76Process' -> IO (Ptr CStochasticProcess1D')
2030 foreign import ccall "ql.h qlVarianceGammaProcessAsStochasticProcess1D" qlVarianceGammaProcessAsStochasticProcess1D :: Ptr CVarianceGammaProcess' -> IO (Ptr CStochasticProcess1D')
2031 foreign import ccall "ql.h qlGeneralizedBlackScholesProcessAsStochasticProcess1D" qlGeneralizedBlackScholesProcessAsStochasticProcess1D :: Ptr CGeneralizedBlackScholesProcess' -> IO (Ptr CStochasticProcess1D')
2032 foreign import ccall "ql.h qlBlackProcessAsGeneralizedBlackScholesProcess" qlBlackProcessAsGeneralizedBlackScholesProcess :: Ptr CBlackProcess' -> IO (Ptr CGeneralizedBlackScholesProcess')
2033 instance Upcastable CExtOUWithJumpsProcess' where {type Base CExtOUWithJumpsProcess' = CStochasticProcess'; upcast = qlExtOUWithJumpsProcessAsStochasticProcess}
2034 instance Upcastable CGJRGARCHProcess' where {type Base CGJRGARCHProcess' = CStochasticProcess'; upcast = qlGJRGARCHProcessAsStochasticProcess}
2035 instance Upcastable CHybridHestonHullWhiteProcess' where {type Base CHybridHestonHullWhiteProcess' = CStochasticProcess'; upcast = qlHybridHestonHullWhiteProcessAsStochasticProcess}
2036 instance Upcastable CKlugeExtOUProcess' where {type Base CKlugeExtOUProcess' = CStochasticProcess'; upcast = qlKlugeExtOUProcessAsStochasticProcess}
2037 instance Upcastable CLiborForwardModelProcess' where {type Base CLiborForwardModelProcess' = CStochasticProcess'; upcast = qlLiborForwardModelProcessAsStochasticProcess}
2038 instance Upcastable CStochasticProcessArray' where {type Base CStochasticProcessArray' = CStochasticProcess'; upcast = qlStochasticProcessArrayAsStochasticProcess}
2039 instance Upcastable CG2Process' where {type Base CG2Process' = CStochasticProcess'; upcast = qlG2ProcessAsStochasticProcess}
2040 instance Upcastable CG2ForwardProcess' where {type Base CG2ForwardProcess' = CStochasticProcess'; upcast = qlG2ForwardProcessAsStochasticProcess}
2041 instance Upcastable CHestonProcess' where {type Base CHestonProcess' = CStochasticProcess'; upcast = qlHestonProcessAsStochasticProcess}
2042 instance Upcastable CStochasticProcess1D' where {type Base CStochasticProcess1D' = CStochasticProcess'; upcast = qlStochasticProcess1DAsStochasticProcess}
2043 instance Upcastable CBatesProcess' where {type Base CBatesProcess' = CHestonProcess'; upcast = qlBatesProcessAsHestonProcess}
2044 instance Upcastable CExtendedOrnsteinUhlenbeckProcess' where {type Base CExtendedOrnsteinUhlenbeckProcess' = CStochasticProcess1D'; upcast = qlExtendedOrnsteinUhlenbeckProcessAsStochasticProcess1D}
2045 instance Upcastable CHullWhiteForwardProcess' where {type Base CHullWhiteForwardProcess' = CStochasticProcess1D'; upcast = qlHullWhiteForwardProcessAsStochasticProcess1D}
2046 instance Upcastable CHullWhiteProcess' where {type Base CHullWhiteProcess' = CStochasticProcess1D'; upcast = qlHullWhiteProcessAsStochasticProcess1D}
2047 instance Upcastable CMerton76Process' where {type Base CMerton76Process' = CStochasticProcess1D'; upcast = qlMerton76ProcessAsStochasticProcess1D}
2048 instance Upcastable CVarianceGammaProcess' where {type Base CVarianceGammaProcess' = CStochasticProcess1D'; upcast = qlVarianceGammaProcessAsStochasticProcess1D}
2049 instance Upcastable CGeneralizedBlackScholesProcess' where {type Base CGeneralizedBlackScholesProcess' = CStochasticProcess1D'; upcast = qlGeneralizedBlackScholesProcessAsStochasticProcess1D}
2050 instance Upcastable CBlackProcess' where {type Base CBlackProcess' = CGeneralizedBlackScholesProcess'; upcast = qlBlackProcessAsGeneralizedBlackScholesProcess}
2051 asStochasticProcess :: GenStochasticProcess p -> IO StochasticProcess
2052 asStochasticProcess = transferGenForeignPtr peekStochasticProcess . getStochasticProcess
2053 peekStochasticProcess :: Ptr CStochasticProcess' -> IO StochasticProcess
2054 peekStochasticProcess = GenStochasticProcess <.> newCastForeignPtr
2055 withStochasticProcess :: GenStochasticProcess p -> (Ptr CStochasticProcess' -> IO b) -> IO b
2056 withStochasticProcess = withGenForeignPtr . getStochasticProcess
2057 withGenStochasticProcess :: GenStochasticProcess (ForeignPtr p) -> (Ptr p -> IO b) -> IO b
2058 withGenStochasticProcess = withForeignPtr . ptr . getStochasticProcess
2059 peekExtOUWithJumpsProcess :: Ptr CExtOUWithJumpsProcess' -> IO ExtOUWithJumpsProcess
2060 peekExtOUWithJumpsProcess = GenStochasticProcess <.> newGenForeignPtr
2061 peekGJRGARCHProcess :: Ptr CGJRGARCHProcess' -> IO GJRGARCHProcess
2062 peekGJRGARCHProcess = GenStochasticProcess <.> newGenForeignPtr
2063 peekHybridHestonHullWhiteProcess :: Ptr CHybridHestonHullWhiteProcess' -> IO HybridHestonHullWhiteProcess
2064 peekHybridHestonHullWhiteProcess = GenStochasticProcess <.> newGenForeignPtr
2065 peekKlugeExtOUProcess :: Ptr CKlugeExtOUProcess' -> IO KlugeExtOUProcess
2066 peekKlugeExtOUProcess = GenStochasticProcess <.> newGenForeignPtr
2067 peekLiborForwardModelProcess :: Ptr CLiborForwardModelProcess' -> IO LiborForwardModelProcess
2068 peekLiborForwardModelProcess = GenStochasticProcess <.> newGenForeignPtr
2069 peekStochasticProcessArray :: Ptr CStochasticProcessArray' -> IO StochasticProcessArray
2070 peekStochasticProcessArray = GenStochasticProcess <.> newGenForeignPtr
2071 peekG2Process :: Ptr CG2Process' -> IO G2Process
2072 peekG2Process = GenStochasticProcess <.> newGenForeignPtr
2073 peekG2ForwardProcess :: Ptr CG2ForwardProcess' -> IO G2ForwardProcess
2074 peekG2ForwardProcess = GenStochasticProcess <.> newGenForeignPtr
2075 asHestonProcess :: GenHestonProcess hp -> IO HestonProcess
2076 asHestonProcess = transferGenForeignPtr peekHestonProcess . peel . getStochasticProcess
2077 peekHestonProcess :: Ptr CHestonProcess' -> IO HestonProcess
2078 peekHestonProcess = newCastForeignPtr >=> newGenHestonProcess
2079 withHestonProcess :: GenHestonProcess hp -> (Ptr CHestonProcess' -> IO b) -> IO b
2080 withHestonProcess = withGenForeignPtr . peel . getStochasticProcess
2081 newGenHestonProcess :: GenForeignPtr hp CHestonProcess' -> IO (GenHestonProcess hp)
2082 newGenHestonProcess = pure . GenStochasticProcess . newAnyOf
2083 peekGenHestonProcess :: (Finalizable hp, Upcastable hp, Base hp ~ CHestonProcess') => Ptr hp -> IO (GenHestonProcess (ForeignPtr hp))
2084 peekGenHestonProcess = newGenForeignPtr >=> newGenHestonProcess
2085 asStochasticProcess1D :: GenStochasticProcess1D p1d -> IO StochasticProcess1D
2086 asStochasticProcess1D = transferGenForeignPtr peekStochasticProcess1D . peel . getStochasticProcess
2087 peekStochasticProcess1D :: Ptr CStochasticProcess1D' -> IO StochasticProcess1D
2088 peekStochasticProcess1D = newCastForeignPtr >=> newGenStochasticProcess1D
2089 withStochasticProcess1D :: GenStochasticProcess1D p1d -> (Ptr CStochasticProcess1D' -> IO b) -> IO b
2090 withStochasticProcess1D = withGenForeignPtr . peel . getStochasticProcess
2091 withStochasticProcess1DArray :: [GenStochasticProcess1D p1d] -> ((CUInt, Ptr (Ptr CStochasticProcess1D')) -> IO b) -> IO b
2092 withStochasticProcess1DArray = withGenArray withStochasticProcess1D
2093 newGenStochasticProcess1D :: GenForeignPtr p1d CStochasticProcess1D' -> IO (GenStochasticProcess1D p1d)
2094 newGenStochasticProcess1D = pure . GenStochasticProcess . newAnyOf
2095 peekGenStochasticProcess1D :: (Finalizable p1d, Upcastable p1d, Base p1d ~ CStochasticProcess1D') => Ptr p1d -> IO (GenStochasticProcess1D (ForeignPtr p1d))
2096 peekGenStochasticProcess1D = newGenForeignPtr >=> newGenStochasticProcess1D
2097 withGenStochasticProcess1D :: GenStochasticProcess1D (ForeignPtr p1d) -> (Ptr p1d -> IO b) -> IO b
2098 withGenStochasticProcess1D = withForeignPtr . ptr . peel . getStochasticProcess
2099 peekBatesProcess :: Ptr CBatesProcess' -> IO BatesProcess
2100 peekBatesProcess = peekGenHestonProcess
2101 withBatesProcess :: BatesProcess -> (Ptr CBatesProcess' -> IO b) -> IO b
2102 withBatesProcess = withForeignPtr . ptr . peel . getStochasticProcess
2103 peekExtendedOrnsteinUhlenbeckProcess :: Ptr CExtendedOrnsteinUhlenbeckProcess' -> IO ExtendedOrnsteinUhlenbeckProcess
2104 peekExtendedOrnsteinUhlenbeckProcess = peekGenStochasticProcess1D
2105 peekHullWhiteForwardProcess :: Ptr CHullWhiteForwardProcess' -> IO HullWhiteForwardProcess
2106 peekHullWhiteForwardProcess = peekGenStochasticProcess1D
2107 peekHullWhiteProcess :: Ptr CHullWhiteProcess' -> IO HullWhiteProcess
2108 peekHullWhiteProcess = peekGenStochasticProcess1D
2109 peekMerton76Process :: Ptr CMerton76Process' -> IO Merton76Process
2110 peekMerton76Process = peekGenStochasticProcess1D
2111 peekVarianceGammaProcess :: Ptr CVarianceGammaProcess' -> IO VarianceGammaProcess
2112 peekVarianceGammaProcess = peekGenStochasticProcess1D
2113 asGeneralizedBlackScholesProcess :: GenGeneralizedBlackScholesProcess gbs -> IO GeneralizedBlackScholesProcess
2114 asGeneralizedBlackScholesProcess = transferGenForeignPtr peekGeneralizedBlackScholesProcess . peel . peel . getStochasticProcess
2115 peekGeneralizedBlackScholesProcess :: Ptr CGeneralizedBlackScholesProcess' -> IO GeneralizedBlackScholesProcess
2116 peekGeneralizedBlackScholesProcess = newCastForeignPtr >=> newGenGeneralizedBlackScholesProcess
2117 withGeneralizedBlackScholesProcess :: GenGeneralizedBlackScholesProcess gbs -> (Ptr CGeneralizedBlackScholesProcess' -> IO b) -> IO b
2118 withGeneralizedBlackScholesProcess = withGenForeignPtr . peel . peel . getStochasticProcess
2119 newGenGeneralizedBlackScholesProcess :: GenForeignPtr gbs CGeneralizedBlackScholesProcess' -> IO (GenGeneralizedBlackScholesProcess gbs)
2120 newGenGeneralizedBlackScholesProcess = pure . GenStochasticProcess . newAnyOf . newAnyOf
2121 peekBlackProcess :: Ptr CBlackProcess' -> IO BlackProcess
2122 peekBlackProcess = newGenForeignPtr >=> newGenGeneralizedBlackScholesProcess
2123 withBlackProcess :: BlackProcess -> (Ptr CBlackProcess' -> IO b) -> IO b
2124 withBlackProcess = withForeignPtr . ptr . peel . peel . getStochasticProcess
2125
2126 -- | > CalibratedModel
2127 -- > LiborForwardModel + AffineModel
2128 -- > GJRGARCHModel
2129 -- > PiecewiseTimeDependentHestonModel
2130 -- > HestonModel
2131 -- > BatesModel
2132 -- > BatesDetJumpModel
2133 -- > BatesDoubleExpModel
2134 -- > BatesDoubleExpDetJumpModel
2135 -- > ShortRateModel
2136 -- > G2 + AffineModel
2137 -- > OneFactorAffineModel + AffineModel
2138 -- > HullWhite + AffineModel
2139 -- > Gsr + Gaussian1dModel
2140 -- > MarkovFunctional + Gaussian1dModel
2141 type CalibratedModel = GenCalibratedModel CCalibratedModel
2142 data CCalibratedModel'
2143 data CGJRGARCHModel'
2144 data CLiborForwardModel'
2145 data CGsr'
2146 data CMarkovFunctional'
2147 data CPiecewiseTimeDependentHestonModel'
2148 data CHestonModel'
2149 data CShortRateModel'
2150 data CBatesModel'
2151 data CBatesDetJumpModel'
2152 data CBatesDoubleExpModel'
2153 data CBatesDoubleExpDetJumpModel'
2154 data COneFactorAffineModel'
2155 data CHullWhite'
2156 data CG2'
2157 data CAffineModel'
2158 data CShortRateDynamics'
2159 newtype GenCalibratedModel m = GenCalibratedModel {getCalibratedModel :: GenForeignPtr m CCalibratedModel'}
2160 type CCalibratedModel = ForeignPtr CCalibratedModel'
2161 type CLiborForwardModel = ForeignPtr CLiborForwardModel'
2162 type LiborForwardModel = GenCalibratedModel CLiborForwardModel
2163 type CGJRGARCHModel = ForeignPtr CGJRGARCHModel'
2164 type GJRGARCHModel = GenCalibratedModel CGJRGARCHModel
2165 type CGsr = ForeignPtr CGsr'
2166 type Gsr = GenCalibratedModel CGsr
2167 type CMarkovFunctional = ForeignPtr CMarkovFunctional'
2168 type MarkovFunctional = GenCalibratedModel CMarkovFunctional
2169 type CPiecewiseTimeDependentHestonModel = ForeignPtr CPiecewiseTimeDependentHestonModel'
2170 type PiecewiseTimeDependentHestonModel = GenCalibratedModel CPiecewiseTimeDependentHestonModel
2171 type GenHestonModel hm = GenCalibratedModel (AnyOf CHestonModel' hm)
2172 type CHestonModel = ForeignPtr CHestonModel'
2173 type HestonModel = GenHestonModel CHestonModel
2174 type GenShortRateModel sm = GenCalibratedModel (AnyOf CShortRateModel' sm)
2175 type CShortRateModel = ForeignPtr CShortRateModel'
2176 type ShortRateModel = GenShortRateModel CShortRateModel
2177 type GenBatesModel bm = GenHestonModel (AnyOf CBatesModel' bm)
2178 type CBatesModel = ForeignPtr CBatesModel'
2179 type BatesModel = GenBatesModel CBatesModel
2180 type CBatesDetJumpModel = ForeignPtr CBatesDetJumpModel'
2181 type BatesDetJumpModel = GenBatesModel CBatesDetJumpModel
2182 type GenBatesDoubleExpModel bdem = GenHestonModel (AnyOf CBatesDoubleExpModel' bdem)
2183 type CBatesDoubleExpModel = ForeignPtr CBatesDoubleExpModel'
2184 type BatesDoubleExpModel = GenBatesDoubleExpModel CBatesDoubleExpModel
2185 type CBatesDoubleExpDetJumpModel = ForeignPtr CBatesDoubleExpDetJumpModel'
2186 type BatesDoubleExpDetJumpModel = GenBatesDoubleExpModel CBatesDoubleExpDetJumpModel
2187 type GenOneFactorAffineModel om = GenShortRateModel (AnyOf COneFactorAffineModel' om)
2188 type COneFactorAffineModel = ForeignPtr COneFactorAffineModel'
2189 type OneFactorAffineModel = GenOneFactorAffineModel COneFactorAffineModel
2190 type CHullWhite = ForeignPtr CHullWhite'
2191 type HullWhite = GenOneFactorAffineModel CHullWhite
2192 type CG2 = ForeignPtr CG2'
2193 type G2 = GenShortRateModel CG2
2194 foreign import ccall unsafe "ql.h &qlFreeCalibratedModel" qlFreeCalibratedModel :: FinalizerPtr CCalibratedModel'
2195 foreign import ccall unsafe "ql.h &qlFreeLiborForwardModel" qlFreeLiborForwardModel :: FinalizerPtr CLiborForwardModel'
2196 foreign import ccall unsafe "ql.h &qlFreeGJRGARCHModel" qlFreeGJRGARCHModel :: FinalizerPtr CGJRGARCHModel'
2197 foreign import ccall unsafe "ql.h &qlFreeGsr" qlFreeGsr :: FinalizerPtr CGsr'
2198 foreign import ccall unsafe "ql.h &qlFreeMarkovFunctional" qlFreeMarkovFunctional :: FinalizerPtr CMarkovFunctional'
2199 foreign import ccall unsafe "ql.h &qlFreePiecewiseTimeDependentHestonModel" qlFreePiecewiseTimeDependentHestonModel :: FinalizerPtr CPiecewiseTimeDependentHestonModel'
2200 foreign import ccall unsafe "ql.h &qlFreeHestonModel" qlFreeHestonModel :: FinalizerPtr CHestonModel'
2201 foreign import ccall unsafe "ql.h &qlFreeShortRateModel" qlFreeShortRateModel :: FinalizerPtr CShortRateModel'
2202 foreign import ccall unsafe "ql.h &qlFreeBatesModel" qlFreeBatesModel :: FinalizerPtr CBatesModel'
2203 foreign import ccall unsafe "ql.h &qlFreeBatesDetJumpModel" qlFreeBatesDetJumpModel :: FinalizerPtr CBatesDetJumpModel'
2204 foreign import ccall unsafe "ql.h &qlFreeBatesDoubleExpModel" qlFreeBatesDoubleExpModel :: FinalizerPtr CBatesDoubleExpModel'
2205 foreign import ccall unsafe "ql.h &qlFreeBatesDoubleExpDetJumpModel" qlFreeBatesDoubleExpDetJumpModel :: FinalizerPtr CBatesDoubleExpDetJumpModel'
2206 foreign import ccall unsafe "ql.h &qlFreeG2" qlFreeG2 :: FinalizerPtr CG2'
2207 foreign import ccall unsafe "ql.h &qlFreeAffineModel" qlFreeAffineModel :: FinalizerPtr CAffineModel'
2208 foreign import ccall unsafe "ql.h &qlFreeShortRateDynamics" qlFreeShortRateDynamics :: FinalizerPtr CShortRateDynamics'
2209 foreign import ccall unsafe "ql.h &qlFreeOneFactorAffineModel" qlFreeOneFactorAffineModel :: FinalizerPtr COneFactorAffineModel'
2210 foreign import ccall unsafe "ql.h &qlFreeHullWhite" qlFreeHullWhite :: FinalizerPtr CHullWhite'
2211 foreign import ccall "ql.h qlPiecewiseTimeDependentHestonModelAsCalibratedModel" qlPiecewiseTimeDependentHestonModelAsCalibratedModel :: Ptr CPiecewiseTimeDependentHestonModel' -> IO (Ptr CCalibratedModel')
2212 foreign import ccall "ql.h qlLiborForwardModelAsCalibratedModel" qlLiborForwardModelAsCalibratedModel :: Ptr CLiborForwardModel' -> IO (Ptr CCalibratedModel')
2213 foreign import ccall "ql.h qlGJRGARCHModelAsCalibratedModel" qlGJRGARCHModelAsCalibratedModel :: Ptr CGJRGARCHModel' -> IO (Ptr CCalibratedModel')
2214 foreign import ccall "ql.h qlGsrAsCalibratedModel" qlGsrAsCalibratedModel :: Ptr CGsr' -> IO (Ptr CCalibratedModel')
2215 foreign import ccall "ql.h qlMarkovFunctionalAsCalibratedModel" qlMarkovFunctionalAsCalibratedModel :: Ptr CMarkovFunctional' -> IO (Ptr CCalibratedModel')
2216 foreign import ccall "ql.h qlHestonModelAsCalibratedModel" qlHestonModelAsCalibratedModel :: Ptr CHestonModel' -> IO (Ptr CCalibratedModel')
2217 foreign import ccall "ql.h qlShortRateModelAsCalibratedModel" qlShortRateModelAsCalibratedModel :: Ptr CShortRateModel' -> IO (Ptr CCalibratedModel')
2218 foreign import ccall "ql.h qlBatesModelAsHestonModel" qlBatesModelAsHestonModel :: Ptr CBatesModel' -> IO (Ptr CHestonModel')
2219 foreign import ccall "ql.h qlBatesDetJumpModelAsBatesModel" qlBatesDetJumpModelAsBatesModel :: Ptr CBatesDetJumpModel' -> IO (Ptr CBatesModel')
2220 foreign import ccall "ql.h qlBatesDoubleExpModelAsHestonModel" qlBatesDoubleExpModelAsHestonModel :: Ptr CBatesDoubleExpModel' -> IO (Ptr CHestonModel')
2221 foreign import ccall "ql.h qlBatesDoubleExpDetJumpModelAsBatesDoubleExpModel" qlBatesDoubleExpDetJumpModelAsBatesDoubleExpModel :: Ptr CBatesDoubleExpDetJumpModel' -> IO (Ptr CBatesDoubleExpModel')
2222 foreign import ccall "ql.h qlOneFactorAffineModelAsShortRateModel" qlOneFactorAffineModelAsShortRateModel :: Ptr COneFactorAffineModel' -> IO (Ptr CShortRateModel')
2223 foreign import ccall "ql.h qlHullWhiteAsOneFactorAffineModel" qlHullWhiteAsOneFactorAffineModel :: Ptr CHullWhite' -> IO (Ptr COneFactorAffineModel')
2224 foreign import ccall "ql.h qlG2AsShortRateModel" qlG2AsShortRateModel :: Ptr CG2' -> IO (Ptr CShortRateModel')
2225 instance Finalizable CCalibratedModel' where finalize = qlFreeCalibratedModel
2226 instance Finalizable CLiborForwardModel' where finalize = qlFreeLiborForwardModel
2227 instance Finalizable CGJRGARCHModel' where finalize = qlFreeGJRGARCHModel
2228 instance Finalizable CGsr' where finalize = qlFreeGsr
2229 instance Finalizable CMarkovFunctional' where finalize = qlFreeMarkovFunctional
2230 instance Finalizable CPiecewiseTimeDependentHestonModel' where finalize = qlFreePiecewiseTimeDependentHestonModel
2231 instance Finalizable CHestonModel' where finalize = qlFreeHestonModel
2232 instance Finalizable CShortRateModel' where finalize = qlFreeShortRateModel
2233 instance Finalizable CBatesModel' where finalize = qlFreeBatesModel
2234 instance Finalizable CBatesDetJumpModel' where finalize = qlFreeBatesDetJumpModel
2235 instance Finalizable CBatesDoubleExpModel' where finalize = qlFreeBatesDoubleExpModel
2236 instance Finalizable CBatesDoubleExpDetJumpModel' where finalize = qlFreeBatesDoubleExpDetJumpModel
2237 instance Finalizable COneFactorAffineModel' where finalize = qlFreeOneFactorAffineModel
2238 instance Finalizable CHullWhite' where finalize = qlFreeHullWhite
2239 instance Finalizable CG2' where finalize = qlFreeG2
2240 instance Finalizable CAffineModel' where finalize = qlFreeAffineModel
2241 instance Finalizable CShortRateDynamics' where finalize = qlFreeShortRateDynamics
2242 instance Upcastable CLiborForwardModel' where {type Base CLiborForwardModel' = CCalibratedModel'; upcast = qlLiborForwardModelAsCalibratedModel}
2243 instance Upcastable CPiecewiseTimeDependentHestonModel' where {type Base CPiecewiseTimeDependentHestonModel' = CCalibratedModel'; upcast = qlPiecewiseTimeDependentHestonModelAsCalibratedModel}
2244 instance Upcastable CGJRGARCHModel' where {type Base CGJRGARCHModel' = CCalibratedModel'; upcast = qlGJRGARCHModelAsCalibratedModel}
2245 instance Upcastable CGsr' where {type Base CGsr' = CCalibratedModel'; upcast = qlGsrAsCalibratedModel}
2246 instance Upcastable CMarkovFunctional' where {type Base CMarkovFunctional' = CCalibratedModel'; upcast = qlMarkovFunctionalAsCalibratedModel}
2247 instance Upcastable CHestonModel' where {type Base CHestonModel' = CCalibratedModel'; upcast = qlHestonModelAsCalibratedModel}
2248 instance Upcastable CShortRateModel' where {type Base CShortRateModel' = CCalibratedModel'; upcast = qlShortRateModelAsCalibratedModel}
2249 instance Upcastable CBatesModel' where {type Base CBatesModel' = CHestonModel'; upcast = qlBatesModelAsHestonModel}
2250 instance Upcastable CBatesDetJumpModel' where {type Base CBatesDetJumpModel' = CBatesModel'; upcast = qlBatesDetJumpModelAsBatesModel}
2251 instance Upcastable CBatesDoubleExpModel' where {type Base CBatesDoubleExpModel' = CHestonModel'; upcast = qlBatesDoubleExpModelAsHestonModel}
2252 instance Upcastable CBatesDoubleExpDetJumpModel' where {type Base CBatesDoubleExpDetJumpModel' = CBatesDoubleExpModel'; upcast = qlBatesDoubleExpDetJumpModelAsBatesDoubleExpModel}
2253 instance Upcastable COneFactorAffineModel' where {type Base COneFactorAffineModel' = CShortRateModel'; upcast = qlOneFactorAffineModelAsShortRateModel}
2254 instance Upcastable CHullWhite' where {type Base CHullWhite' = COneFactorAffineModel'; upcast = qlHullWhiteAsOneFactorAffineModel}
2255 instance Upcastable CG2' where {type Base CG2' = CShortRateModel'; upcast = qlG2AsShortRateModel}
2256 asCalibratedModel :: GenCalibratedModel m -> IO CalibratedModel
2257 asCalibratedModel = transferGenForeignPtr peekCalibratedModel . getCalibratedModel
2258 peekCalibratedModel :: Ptr CCalibratedModel' -> IO CalibratedModel
2259 peekCalibratedModel = GenCalibratedModel <.> newCastForeignPtr
2260 withCalibratedModel :: GenCalibratedModel m -> (Ptr CCalibratedModel' -> IO b) -> IO b
2261 withCalibratedModel = withGenForeignPtr . getCalibratedModel
2262 withGenCalibratedModel :: GenCalibratedModel (ForeignPtr m) -> (Ptr m -> IO b) -> IO b
2263 withGenCalibratedModel = withForeignPtr . ptr . getCalibratedModel
2264 peekLiborForwardModel :: Ptr CLiborForwardModel' -> IO LiborForwardModel
2265 peekLiborForwardModel = GenCalibratedModel <.> newGenForeignPtr
2266 peekGJRGARCHModel :: Ptr CGJRGARCHModel' -> IO GJRGARCHModel
2267 peekGJRGARCHModel = GenCalibratedModel <.> newGenForeignPtr
2268 peekGsr :: Ptr CGsr' -> IO Gsr
2269 peekGsr = GenCalibratedModel <.> newGenForeignPtr
2270 peekMarkovFunctional :: Ptr CMarkovFunctional' -> IO MarkovFunctional
2271 peekMarkovFunctional = GenCalibratedModel <.> newGenForeignPtr
2272 peekPiecewiseTimeDependentHestonModel :: Ptr CPiecewiseTimeDependentHestonModel' -> IO PiecewiseTimeDependentHestonModel
2273 peekPiecewiseTimeDependentHestonModel = GenCalibratedModel <.> newGenForeignPtr
2274
2275 asHestonModel :: GenHestonModel hm -> IO HestonModel
2276 asHestonModel = transferGenForeignPtr peekHestonModel . peel . getCalibratedModel
2277 peekHestonModel :: Ptr CHestonModel' -> IO HestonModel
2278 peekHestonModel = newCastForeignPtr >=> newGenHestonModel
2279 withHestonModel :: GenHestonModel hm -> (Ptr CHestonModel' -> IO b) -> IO b
2280 withHestonModel = withGenForeignPtr . peel . getCalibratedModel
2281 newGenHestonModel :: GenForeignPtr hm CHestonModel' -> IO (GenHestonModel hm)
2282 newGenHestonModel = pure . GenCalibratedModel . newAnyOf
2283
2284 asShortRateModel :: GenShortRateModel sm -> IO ShortRateModel
2285 asShortRateModel = transferGenForeignPtr peekShortRateModel . peel . getCalibratedModel
2286 peekShortRateModel :: Ptr CShortRateModel' -> IO ShortRateModel
2287 peekShortRateModel = newCastForeignPtr >=> newGenShortRateModel
2288 withShortRateModel :: GenShortRateModel sm -> (Ptr CShortRateModel' -> IO b) -> IO b
2289 withShortRateModel = withGenForeignPtr . peel . getCalibratedModel
2290 newGenShortRateModel :: GenForeignPtr sm CShortRateModel' -> IO (GenShortRateModel sm)
2291 newGenShortRateModel = pure . GenCalibratedModel . newAnyOf
2292 peekGenShortRateModel :: (Finalizable sm, Upcastable sm, Base sm ~ CShortRateModel') => Ptr sm -> IO (GenShortRateModel (ForeignPtr sm))
2293 peekGenShortRateModel = newGenForeignPtr >=> newGenShortRateModel
2294
2295 asBatesModel :: GenBatesModel bm -> IO BatesModel
2296 asBatesModel = transferGenForeignPtr peekBatesModel . peel . peel . getCalibratedModel
2297 peekBatesModel :: Ptr CBatesModel' -> IO BatesModel
2298 peekBatesModel = newCastForeignPtr >=> newGenBatesModel
2299 withBatesModel :: GenBatesModel bm -> (Ptr CBatesModel' -> IO b) -> IO b
2300 withBatesModel = withGenForeignPtr . peel . peel . getCalibratedModel
2301 newGenBatesModel :: GenForeignPtr bm CBatesModel' -> IO (GenBatesModel bm)
2302 newGenBatesModel = pure . GenCalibratedModel . newAnyOf . newAnyOf
2303 peekBatesDetJumpModel :: Ptr CBatesDetJumpModel' -> IO BatesDetJumpModel
2304 peekBatesDetJumpModel = newGenForeignPtr >=> newGenBatesModel
2305 withBatesDetJumpModel :: BatesDetJumpModel -> (Ptr CBatesDetJumpModel' -> IO b) -> IO b
2306 withBatesDetJumpModel = withForeignPtr . ptr . peel . peel . getCalibratedModel
2307
2308 asBatesDoubleExpModel :: GenBatesDoubleExpModel bdem -> IO BatesDoubleExpModel
2309 asBatesDoubleExpModel = transferGenForeignPtr peekBatesDoubleExpModel . peel . peel . getCalibratedModel
2310 peekBatesDoubleExpModel :: Ptr CBatesDoubleExpModel' -> IO BatesDoubleExpModel
2311 peekBatesDoubleExpModel = newCastForeignPtr >=> newGenBatesDoubleExpModel
2312 withBatesDoubleExpModel :: GenBatesDoubleExpModel bdem -> (Ptr CBatesDoubleExpModel' -> IO b) -> IO b
2313 withBatesDoubleExpModel = withGenForeignPtr . peel . peel . getCalibratedModel
2314 newGenBatesDoubleExpModel :: GenForeignPtr bdem CBatesDoubleExpModel' -> IO (GenBatesDoubleExpModel bdem)
2315 newGenBatesDoubleExpModel = pure . GenCalibratedModel . newAnyOf . newAnyOf
2316 peekBatesDoubleExpDetJumpModel :: Ptr CBatesDoubleExpDetJumpModel' -> IO BatesDoubleExpDetJumpModel
2317 peekBatesDoubleExpDetJumpModel = newGenForeignPtr >=> newGenBatesDoubleExpModel
2318 withBatesDoubleExpDetJumpModel :: BatesDoubleExpDetJumpModel -> (Ptr CBatesDoubleExpDetJumpModel' -> IO b) -> IO b
2319 withBatesDoubleExpDetJumpModel = withForeignPtr . ptr . peel . peel . getCalibratedModel
2320
2321 asOneFactorAffineModel :: GenOneFactorAffineModel om -> IO OneFactorAffineModel
2322 asOneFactorAffineModel = transferGenForeignPtr peekOneFactorAffineModel . peel . peel . getCalibratedModel
2323 peekOneFactorAffineModel :: Ptr COneFactorAffineModel' -> IO OneFactorAffineModel
2324 peekOneFactorAffineModel = newCastForeignPtr >=> newGenOneFactorAffineModel
2325 withOneFactorAffineModel :: GenOneFactorAffineModel om -> (Ptr COneFactorAffineModel' -> IO b) -> IO b
2326 withOneFactorAffineModel = withGenForeignPtr . peel . peel . getCalibratedModel
2327 newGenOneFactorAffineModel :: GenForeignPtr om COneFactorAffineModel' -> IO (GenOneFactorAffineModel om)
2328 newGenOneFactorAffineModel = pure . GenCalibratedModel . newAnyOf . newAnyOf
2329
2330 peekHullWhite :: Ptr CHullWhite' -> IO HullWhite
2331 peekHullWhite = newGenForeignPtr >=> newGenOneFactorAffineModel
2332 withHullWhite :: HullWhite -> (Ptr CHullWhite' -> IO b) -> IO b
2333 withHullWhite = withForeignPtr . ptr . peel . peel . getCalibratedModel
2334
2335 peekG2 :: Ptr CG2' -> IO G2
2336 peekG2 = peekGenShortRateModel
2337 withG2 :: G2 -> (Ptr CG2' -> IO b) -> IO b
2338 withG2 = withForeignPtr . ptr . peel . getCalibratedModel
2339
2340 foreign import ccall "ql.h qlOneFactorAffineModelAsAffineModel" qlOneFactorAffineModelAsAffineModel :: Ptr COneFactorAffineModel' -> IO (Ptr CAffineModel')
2341 foreign import ccall "ql.h qlLiborForwardModelAsAffineModel" qlLiborForwardModelAsAffineModel :: Ptr CLiborForwardModel' -> IO (Ptr CAffineModel')
2342 foreign import ccall "ql.h qlG2AsAffineModel" qlG2AsAffineModel :: Ptr CG2' -> IO (Ptr CAffineModel')
2343 foreign import ccall "ql.h qlHullWhiteAsAffineModel" qlHullWhiteAsAffineModel :: Ptr CHullWhite' -> IO (Ptr CAffineModel')
2344
2345 type AffineModel = Standalone CAffineModel'
2346 hullWhiteAsAffineModel :: HullWhite -> IO AffineModel
2347 hullWhiteAsAffineModel m = withHullWhite m qlHullWhiteAsAffineModel >>= peekStandalone
2348 g2AsAffineModel :: G2 -> IO AffineModel
2349 g2AsAffineModel m = withG2 m qlG2AsAffineModel >>= peekStandalone
2350 oneFactorAffineModelAsAffineModel :: OneFactorAffineModel -> IO AffineModel
2351 oneFactorAffineModelAsAffineModel m = withOneFactorAffineModel m qlOneFactorAffineModelAsAffineModel >>= peekStandalone
2352 liborForwardModelAsAffineModel :: LiborForwardModel -> IO AffineModel
2353 liborForwardModelAsAffineModel m = withGenCalibratedModel m qlLiborForwardModelAsAffineModel >>= peekStandalone
2354
2355 -- |The two-factor short-rate dynamics (state variables @x@, @y@ with @r_t = phi(t) + x_t + y_t@)
2356 -- underlying a 'G2' model, as returned by @TwoFactorModel::dynamics()@.
2357 type ShortRateDynamics = Standalone CShortRateDynamics'
2358
2359 data CGaussian1dModel'
2360 foreign import ccall unsafe "ql.h &qlFreeGaussian1dModel" qlFreeGaussian1dModel :: FinalizerPtr CGaussian1dModel'
2361 instance Finalizable CGaussian1dModel' where finalize = qlFreeGaussian1dModel
2362 foreign import ccall "ql.h qlGsrAsGaussian1dModel" qlGsrAsGaussian1dModel :: Ptr CGsr' -> IO (Ptr CGaussian1dModel')
2363 foreign import ccall "ql.h qlMarkovFunctionalAsGaussian1dModel" qlMarkovFunctionalAsGaussian1dModel :: Ptr CMarkovFunctional' -> IO (Ptr CGaussian1dModel')
2364 type Gaussian1dModel = Standalone CGaussian1dModel'
2365 gsrAsGaussian1dModel :: Gsr -> IO Gaussian1dModel
2366 gsrAsGaussian1dModel m = withGenCalibratedModel m qlGsrAsGaussian1dModel >>= peekStandalone
2367 markovFunctionalAsGaussian1dModel :: MarkovFunctional -> IO Gaussian1dModel
2368 markovFunctionalAsGaussian1dModel m = withGenCalibratedModel m qlMarkovFunctionalAsGaussian1dModel >>= peekStandalone
2369
2370 -- | > Instrument*
2371 -- > Forward*
2372 -- > BondForward
2373 -- > ForwardRateAgreement
2374 -- > FxForward
2375 -- > VarianceSwap
2376 -- > VarianceOption
2377 -- > Option*
2378 -- > CdsOption
2379 -- > MultiAssetOption
2380 -- > MargrabeOption
2381 -- > OneAssetOption
2382 -- > BarrierOption
2383 -- > DoubleBarrierOption
2384 -- > SoftBarrierOption
2385 -- > VanillaOption
2386 -- > QuantoVanillaOption
2387 -- > QuantoForwardVanillaOption
2388 -- > QuantoBarrierOption
2389 -- > QuantoDoubleBarrierOption
2390 -- > Swaption
2391 -- > NonstandardSwaption
2392 -- > FloatFloatSwaption
2393 -- > Swap*
2394 -- > FixedVsFloatingSwap*
2395 -- > VanillaSwap
2396 -- > NonstandardSwap
2397 -- > FloatFloatSwap
2398 -- > AssetSwap
2399 -- > BMASwap
2400 -- > OvernightIndexedSwap
2401 -- > ZeroCouponInflationSwap
2402 -- > YearOnYearInflationSwap
2403 -- > CPISwap
2404 -- > ZeroCouponSwap
2405 -- > EquityTotalReturnSwap
2406 -- > ConstNotionalCrossCurrencySwap
2407 -- > ConstNotionalCrossCurrencyBasisSwap
2408 -- > ConstNotionalCrossCurrencyFixedVsFloatingSwap
2409 -- > CreditDefaultSwap
2410 -- > CapFloor
2411 -- > YoYInflationCapFloor
2412 -- > CPICapFloor
2413 -- > Bond
2414 -- > ConvertibleBond
2415 -- > FixedRateBond
2416 -- > CallableBond
2417 -- > CPIBond
2418 -- > Commodity*
2419 -- > EnergyCommodity*
2420 -- > EnergyFuture
2421 -- > EnergySwap*
2422 -- > EnergyVanillaSwap
2423 -- > EnergyBasisSwap
2424 type Instrument = GenInstrument CInstrument
2425 data CInstrument'
2426 newtype GenInstrument i = GenInstrument {getInstrument :: GenForeignPtr i CInstrument'}
2427 type CInstrument = ForeignPtr CInstrument'
2428 foreign import ccall unsafe "ql.h &qlFreeInstrument" qlFreeInstrument :: FinalizerPtr CInstrument'
2429 instance Finalizable CInstrument' where finalize = qlFreeInstrument
2430 asInstrument :: GenInstrument i -> IO Instrument
2431 asInstrument = transferGenForeignPtr peekInstrument . getInstrument
2432 peekInstrument :: Ptr CInstrument' -> IO Instrument
2433 peekInstrument = GenInstrument <.> newCastForeignPtr
2434 withInstrument :: GenInstrument i -> (Ptr CInstrument' -> IO b) -> IO b
2435 withInstrument = withGenForeignPtr . getInstrument
2436 withGenInstrument :: GenInstrument (ForeignPtr i) -> (Ptr i -> IO b) -> IO b
2437 withGenInstrument = withForeignPtr . ptr . getInstrument
2438
2439 data CForwardRateAgreement'
2440 type CForwardRateAgreement = ForeignPtr CForwardRateAgreement'
2441 type ForwardRateAgreement = GenInstrument CForwardRateAgreement
2442 foreign import ccall unsafe "ql.h &qlFreeForwardRateAgreement" qlFreeForwardRateAgreement :: FinalizerPtr CForwardRateAgreement'
2443 instance Finalizable CForwardRateAgreement' where finalize = qlFreeForwardRateAgreement
2444 foreign import ccall "ql.h qlForwardRateAgreementAsInstrument" qlForwardRateAgreementAsInstrument :: Ptr CForwardRateAgreement' -> IO (Ptr CInstrument')
2445 instance Upcastable CForwardRateAgreement' where {type Base CForwardRateAgreement' = CInstrument'; upcast = qlForwardRateAgreementAsInstrument}
2446 peekForwardRateAgreement :: Ptr CForwardRateAgreement' -> IO ForwardRateAgreement
2447 peekForwardRateAgreement = GenInstrument <.> newGenForeignPtr
2448
2449 data CFxForward'
2450 type CFxForward = ForeignPtr CFxForward'
2451 type FxForward = GenInstrument CFxForward
2452 foreign import ccall unsafe "ql.h &qlFreeFxForward" qlFreeFxForward :: FinalizerPtr CFxForward'
2453 instance Finalizable CFxForward' where finalize = qlFreeFxForward
2454 foreign import ccall "ql.h qlFxForwardAsInstrument" qlFxForwardAsInstrument :: Ptr CFxForward' -> IO (Ptr CInstrument')
2455 instance Upcastable CFxForward' where {type Base CFxForward' = CInstrument'; upcast = qlFxForwardAsInstrument}
2456 peekFxForward :: Ptr CFxForward' -> IO FxForward
2457 peekFxForward = GenInstrument <.> newGenForeignPtr
2458
2459 data CCreditDefaultSwap'
2460 type CCreditDefaultSwap = ForeignPtr CCreditDefaultSwap'
2461 type CreditDefaultSwap = GenInstrument CCreditDefaultSwap
2462 foreign import ccall unsafe "ql.h &qlFreeCreditDefaultSwap" qlFreeCreditDefaultSwap :: FinalizerPtr CCreditDefaultSwap'
2463 instance Finalizable CCreditDefaultSwap' where finalize = qlFreeCreditDefaultSwap
2464 foreign import ccall "ql.h qlCreditDefaultSwapAsInstrument" qlCreditDefaultSwapAsInstrument :: Ptr CCreditDefaultSwap' -> IO (Ptr CInstrument')
2465 instance Upcastable CCreditDefaultSwap' where {type Base CCreditDefaultSwap' = CInstrument'; upcast = qlCreditDefaultSwapAsInstrument}
2466 peekCreditDefaultSwap :: Ptr CCreditDefaultSwap' -> IO CreditDefaultSwap
2467 peekCreditDefaultSwap = GenInstrument <.> newGenForeignPtr
2468
2469 data CVarianceSwap'
2470 type CVarianceSwap = ForeignPtr CVarianceSwap'
2471 type VarianceSwap = GenInstrument CVarianceSwap
2472 foreign import ccall unsafe "ql.h &qlFreeVarianceSwap" qlFreeVarianceSwap :: FinalizerPtr CVarianceSwap'
2473 instance Finalizable CVarianceSwap' where finalize = qlFreeVarianceSwap
2474 foreign import ccall "ql.h qlVarianceSwapAsInstrument" qlVarianceSwapAsInstrument :: Ptr CVarianceSwap' -> IO (Ptr CInstrument')
2475 instance Upcastable CVarianceSwap' where {type Base CVarianceSwap' = CInstrument'; upcast = qlVarianceSwapAsInstrument}
2476 peekVarianceSwap :: Ptr CVarianceSwap' -> IO VarianceSwap
2477 peekVarianceSwap = GenInstrument <.> newGenForeignPtr
2478
2479 data CVarianceOption'
2480 type CVarianceOption = ForeignPtr CVarianceOption'
2481 type VarianceOption = GenInstrument CVarianceOption
2482 foreign import ccall unsafe "ql.h &qlFreeVarianceOption" qlFreeVarianceOption :: FinalizerPtr CVarianceOption'
2483 instance Finalizable CVarianceOption' where finalize = qlFreeVarianceOption
2484 foreign import ccall "ql.h qlVarianceOptionAsInstrument" qlVarianceOptionAsInstrument :: Ptr CVarianceOption' -> IO (Ptr CInstrument')
2485 instance Upcastable CVarianceOption' where {type Base CVarianceOption' = CInstrument'; upcast = qlVarianceOptionAsInstrument}
2486 peekVarianceOption :: Ptr CVarianceOption' -> IO VarianceOption
2487 peekVarianceOption = GenInstrument <.> newGenForeignPtr
2488
2489 data CCapFloor'
2490 type CCapFloor = ForeignPtr CCapFloor'
2491 type CapFloor = GenInstrument CCapFloor
2492 foreign import ccall unsafe "ql.h &qlFreeCapFloor" qlFreeCapFloor :: FinalizerPtr CCapFloor'
2493 instance Finalizable CCapFloor' where finalize = qlFreeCapFloor
2494 foreign import ccall "ql.h qlCapFloorAsInstrument" qlCapFloorAsInstrument :: Ptr CCapFloor' -> IO (Ptr CInstrument')
2495 instance Upcastable CCapFloor' where {type Base CCapFloor' = CInstrument'; upcast = qlCapFloorAsInstrument}
2496 peekCapFloor :: Ptr CCapFloor' -> IO CapFloor
2497 peekCapFloor = GenInstrument <.> newGenForeignPtr
2498
2499 data CYoYInflationCapFloor'
2500 type CYoYInflationCapFloor = ForeignPtr CYoYInflationCapFloor'
2501 -- | A YoY-inflation cap\/floor\/collar (all three are thin ctor-only subclasses upstream with
2502 -- no logic of their own, so 'QuantLib.Instrument.InflationCapFloor.yoyInflationCap'\/
2503 -- 'yoyInflationCollar'\/'yoyInflationFloor' each construct this one flat leaf directly, mirroring
2504 -- how 'CapFloor' collapses @Cap@\/@Collar@\/@Floor@). Unlike 'CapFloor', it shares no C++ base
2505 -- below 'Instrument' with the nominal cap/floor, so it's a separate sibling leaf, not a subtype.
2506 type YoYInflationCapFloor = GenInstrument CYoYInflationCapFloor
2507 foreign import ccall unsafe "ql.h &qlFreeYoYInflationCapFloor" qlFreeYoYInflationCapFloor :: FinalizerPtr CYoYInflationCapFloor'
2508 instance Finalizable CYoYInflationCapFloor' where finalize = qlFreeYoYInflationCapFloor
2509 foreign import ccall "ql.h qlYoYInflationCapFloorAsInstrument" qlYoYInflationCapFloorAsInstrument :: Ptr CYoYInflationCapFloor' -> IO (Ptr CInstrument')
2510 instance Upcastable CYoYInflationCapFloor' where {type Base CYoYInflationCapFloor' = CInstrument'; upcast = qlYoYInflationCapFloorAsInstrument}
2511 peekYoYInflationCapFloor :: Ptr CYoYInflationCapFloor' -> IO YoYInflationCapFloor
2512 peekYoYInflationCapFloor = GenInstrument <.> newGenForeignPtr
2513
2514 data CCPICapFloor'
2515 type CCPICapFloor = ForeignPtr CCPICapFloor'
2516 -- | A CPI cap\/floor: unlike 'YoYInflationCapFloor', a single cumulative option (observes
2517 -- cumulative inflation up to maturity, like a ZCIIS option) rather than a strip of optionlets --
2518 -- flat sibling leaf under 'Instrument', sharing no C++ base with either 'CapFloor' or
2519 -- 'YoYInflationCapFloor'.
2520 type CPICapFloor = GenInstrument CCPICapFloor
2521 foreign import ccall unsafe "ql.h &qlFreeCPICapFloor" qlFreeCPICapFloor :: FinalizerPtr CCPICapFloor'
2522 instance Finalizable CCPICapFloor' where finalize = qlFreeCPICapFloor
2523 foreign import ccall "ql.h qlCPICapFloorAsInstrument" qlCPICapFloorAsInstrument :: Ptr CCPICapFloor' -> IO (Ptr CInstrument')
2524 instance Upcastable CCPICapFloor' where {type Base CCPICapFloor' = CInstrument'; upcast = qlCPICapFloorAsInstrument}
2525 peekCPICapFloor :: Ptr CCPICapFloor' -> IO CPICapFloor
2526 peekCPICapFloor = GenInstrument <.> newGenForeignPtr
2527
2528 data CForward'
2529 type GenForward f = GenInstrument (AnyOf CForward' f)
2530 type CForward = ForeignPtr CForward'
2531 type Forward = GenForward CForward
2532 foreign import ccall unsafe "ql.h &qlFreeForward" qlFreeForward :: FinalizerPtr CForward'
2533 instance Finalizable CForward' where finalize = qlFreeForward
2534 foreign import ccall "ql.h qlForwardAsInstrument" qlForwardAsInstrument :: Ptr CForward' -> IO (Ptr CInstrument')
2535 instance Upcastable CForward' where {type Base CForward' = CInstrument'; upcast = qlForwardAsInstrument}
2536 asForward :: GenForward f -> IO Forward
2537 asForward = transferGenForeignPtr peekForward . peel . getInstrument
2538 peekForward :: Ptr CForward' -> IO Forward
2539 peekForward = newCastForeignPtr >=> newGenForward
2540 withForward :: GenForward f -> (Ptr CForward' -> IO b) -> IO b
2541 withForward = withGenForeignPtr . peel . getInstrument
2542 newGenForward :: GenForeignPtr f CForward' -> IO (GenForward f)
2543 newGenForward = pure . GenInstrument . newAnyOf
2544 peekGenForward :: (Finalizable f, Upcastable f, Base f ~ CForward') => Ptr f -> IO (GenForward (ForeignPtr f))
2545 peekGenForward = newGenForeignPtr >=> newGenForward
2546 withGenForward :: GenForward (ForeignPtr f) -> (Ptr f -> IO b) -> IO b
2547 withGenForward = withForeignPtr . ptr . peel . getInstrument
2548
2549 data COption'
2550 type GenOption o = GenInstrument (AnyOf COption' o)
2551 type COption = ForeignPtr COption'
2552 type Option = GenOption COption
2553 foreign import ccall unsafe "ql.h &qlFreeOption" qlFreeOption :: FinalizerPtr COption'
2554 instance Finalizable COption' where finalize = qlFreeOption
2555 foreign import ccall "ql.h qlOptionAsInstrument" qlOptionAsInstrument :: Ptr COption' -> IO (Ptr CInstrument')
2556 instance Upcastable COption' where {type Base COption' = CInstrument'; upcast = qlOptionAsInstrument}
2557 asOption :: GenOption o -> IO Option
2558 asOption = transferGenForeignPtr peekOption . peel . getInstrument
2559 peekOption :: Ptr COption' -> IO Option
2560 peekOption = newCastForeignPtr >=> newGenOption
2561 withOption :: GenOption o -> (Ptr COption' -> IO b) -> IO b
2562 withOption = withGenForeignPtr . peel . getInstrument
2563 newGenOption :: GenForeignPtr o COption' -> IO (GenOption o)
2564 newGenOption = pure . GenInstrument . newAnyOf
2565 peekGenOption :: (Finalizable o, Upcastable o, Base o ~ COption') => Ptr o -> IO (GenOption (ForeignPtr o))
2566 peekGenOption = newGenForeignPtr >=> newGenOption
2567 withGenOption :: GenOption (ForeignPtr o) -> (Ptr o -> IO b) -> IO b
2568 withGenOption = withForeignPtr . ptr . peel . getInstrument
2569
2570 data CSwap'
2571 type GenSwap s = GenInstrument (AnyOf CSwap' s)
2572 type CSwap = ForeignPtr CSwap'
2573 type Swap = GenSwap CSwap
2574 foreign import ccall unsafe "ql.h &qlFreeSwap" qlFreeSwap :: FinalizerPtr CSwap'
2575 instance Finalizable CSwap' where finalize = qlFreeSwap
2576 foreign import ccall "ql.h qlSwapAsInstrument" qlSwapAsInstrument :: Ptr CSwap' -> IO (Ptr CInstrument')
2577 instance Upcastable CSwap' where {type Base CSwap' = CInstrument'; upcast = qlSwapAsInstrument}
2578 asSwap :: GenSwap s -> IO Swap
2579 asSwap = transferGenForeignPtr peekSwap . peel . getInstrument
2580 peekSwap :: Ptr CSwap' -> IO Swap
2581 peekSwap = newCastForeignPtr >=> newGenSwap
2582 withSwap :: GenSwap s -> (Ptr CSwap' -> IO b) -> IO b
2583 withSwap = withGenForeignPtr . peel . getInstrument
2584 newGenSwap :: GenForeignPtr s CSwap' -> IO (GenSwap s)
2585 newGenSwap = pure . GenInstrument . newAnyOf
2586 peekGenSwap :: (Finalizable s, Upcastable s, Base s ~ CSwap') => Ptr s -> IO (GenSwap (ForeignPtr s))
2587 peekGenSwap = newGenForeignPtr >=> newGenSwap
2588 withGenSwap :: GenSwap (ForeignPtr s) -> (Ptr s -> IO b) -> IO b
2589 withGenSwap = withForeignPtr . ptr . peel . getInstrument
2590
2591 data CBond'
2592 type GenBond b = GenInstrument (AnyOf CBond' b)
2593 type CBond = ForeignPtr CBond'
2594 type Bond = GenBond CBond
2595 foreign import ccall unsafe "ql.h &qlFreeBond" qlFreeBond :: FinalizerPtr CBond'
2596 instance Finalizable CBond' where finalize = qlFreeBond
2597 foreign import ccall "ql.h qlBondAsInstrument" qlBondAsInstrument :: Ptr CBond' -> IO (Ptr CInstrument')
2598 instance Upcastable CBond' where {type Base CBond' = CInstrument'; upcast = qlBondAsInstrument}
2599 asBond :: GenBond b -> IO Bond
2600 asBond = transferGenForeignPtr peekBond . peel . getInstrument
2601 peekBond :: Ptr CBond' -> IO Bond
2602 peekBond = newCastForeignPtr >=> newGenBond
2603 withBond :: GenBond b -> (Ptr CBond' -> IO r) -> IO r
2604 withBond = withGenForeignPtr . peel . getInstrument
2605 newGenBond :: GenForeignPtr b CBond' -> IO (GenBond b)
2606 newGenBond = pure . GenInstrument . newAnyOf
2607 peekGenBond :: (Finalizable b, Upcastable b, Base b ~ CBond') => Ptr b -> IO (GenBond (ForeignPtr b))
2608 peekGenBond = newGenForeignPtr >=> newGenBond
2609 withGenBond :: GenBond (ForeignPtr b) -> (Ptr b -> IO r) -> IO r
2610 withGenBond = withForeignPtr . ptr . peel . getInstrument
2611
2612 data CBondForward'
2613 type CBondForward = ForeignPtr CBondForward'
2614 type BondForward = GenForward CBondForward
2615 foreign import ccall unsafe "ql.h &qlFreeBondForward" qlFreeBondForward :: FinalizerPtr CBondForward'
2616 instance Finalizable CBondForward' where finalize = qlFreeBondForward
2617 foreign import ccall "ql.h qlBondForwardAsForward" qlBondForwardAsForward :: Ptr CBondForward' -> IO (Ptr CForward')
2618 instance Upcastable CBondForward' where {type Base CBondForward' = CForward'; upcast = qlBondForwardAsForward}
2619 peekBondForward :: Ptr CBondForward' -> IO BondForward
2620 peekBondForward = peekGenForward
2621 withBondForward :: BondForward -> (Ptr CBondForward' -> IO b) -> IO b
2622 withBondForward = withForeignPtr . ptr . peel . getInstrument
2623
2624 data CConvertibleBond'
2625 type CConvertibleBond = ForeignPtr CConvertibleBond'
2626 type ConvertibleBond = GenBond CConvertibleBond
2627 foreign import ccall unsafe "ql.h &qlFreeConvertibleBond" qlFreeConvertibleBond :: FinalizerPtr CConvertibleBond'
2628 instance Finalizable CConvertibleBond' where finalize = qlFreeConvertibleBond
2629 foreign import ccall "ql.h qlConvertibleBondAsBond" qlConvertibleBondAsBond :: Ptr CConvertibleBond' -> IO (Ptr CBond')
2630 instance Upcastable CConvertibleBond' where {type Base CConvertibleBond' = CBond'; upcast = qlConvertibleBondAsBond}
2631 peekConvertibleBond :: Ptr CConvertibleBond' -> IO ConvertibleBond
2632 peekConvertibleBond = peekGenBond
2633 withConvertibleBond :: ConvertibleBond -> (Ptr CConvertibleBond' -> IO b) -> IO b
2634 withConvertibleBond = withForeignPtr . ptr . peel . getInstrument
2635
2636 data CFixedRateBond'
2637 type CFixedRateBond = ForeignPtr CFixedRateBond'
2638 type FixedRateBond = GenBond CFixedRateBond
2639 foreign import ccall unsafe "ql.h &qlFreeFixedRateBond" qlFreeFixedRateBond :: FinalizerPtr CFixedRateBond'
2640 instance Finalizable CFixedRateBond' where finalize = qlFreeFixedRateBond
2641 foreign import ccall "ql.h qlFixedRateBondAsBond" qlFixedRateBondAsBond :: Ptr CFixedRateBond' -> IO (Ptr CBond')
2642 instance Upcastable CFixedRateBond' where {type Base CFixedRateBond' = CBond'; upcast = qlFixedRateBondAsBond}
2643 peekFixedRateBond :: Ptr CFixedRateBond' -> IO FixedRateBond
2644 peekFixedRateBond = peekGenBond
2645 withFixedRateBond :: FixedRateBond -> (Ptr CFixedRateBond' -> IO b) -> IO b
2646 withFixedRateBond = withForeignPtr . ptr . peel . getInstrument
2647
2648 data CCPIBond'
2649 type CCPIBond = ForeignPtr CCPIBond'
2650 type CPIBond = GenBond CCPIBond
2651 foreign import ccall unsafe "ql.h &qlFreeCPIBond" qlFreeCPIBond :: FinalizerPtr CCPIBond'
2652 instance Finalizable CCPIBond' where finalize = qlFreeCPIBond
2653 foreign import ccall "ql.h qlCPIBondAsBond" qlCPIBondAsBond :: Ptr CCPIBond' -> IO (Ptr CBond')
2654 instance Upcastable CCPIBond' where {type Base CCPIBond' = CBond'; upcast = qlCPIBondAsBond}
2655 peekCPIBond :: Ptr CCPIBond' -> IO CPIBond
2656 peekCPIBond = peekGenBond
2657 withCPIBond :: CPIBond -> (Ptr CCPIBond' -> IO b) -> IO b
2658 withCPIBond = withForeignPtr . ptr . peel . getInstrument
2659
2660 data CCallableBond'
2661 type CCallableBond = ForeignPtr CCallableBond'
2662 type CallableBond = GenBond CCallableBond
2663 foreign import ccall unsafe "ql.h &qlFreeCallableBond" qlFreeCallableBond :: FinalizerPtr CCallableBond'
2664 instance Finalizable CCallableBond' where finalize = qlFreeCallableBond
2665 foreign import ccall "ql.h qlCallableBondAsBond" qlCallableBondAsBond :: Ptr CCallableBond' -> IO (Ptr CBond')
2666 instance Upcastable CCallableBond' where {type Base CCallableBond' = CBond'; upcast = qlCallableBondAsBond}
2667 peekCallableBond :: Ptr CCallableBond' -> IO CallableBond
2668 peekCallableBond = peekGenBond
2669 withCallableBond :: CallableBond -> (Ptr CCallableBond' -> IO b) -> IO b
2670 withCallableBond = withForeignPtr . ptr . peel . getInstrument
2671
2672 -- FixedVsFloatingSwap sits between Swap and VanillaSwap (upstream: VanillaSwap, OvernightIndexedSwap
2673 -- and MultipleResetsSwap all derive from it, but only VanillaSwap is modelled through it here --
2674 -- the others still upcast straight to Swap, collapsing the intermediate level as usual). It earns
2675 -- its own family level (mirrors MultiAssetOption/MargrabeOption's one-more-AnyOf-layer shape)
2676 -- because SwaptionHelper::underlying() (QuantLib/Model.chs) returns exactly this type, and its own
2677 -- getters (fairRate, fairSpread, fixedLeg*, floatingLeg*) are inherited, not VanillaSwap-specific --
2678 -- binding them generically over 'GenFixedVsFloatingSwap' avoids a cast to reach them from that
2679 -- getter's result. FixedVsFloatingSwap itself is abstract upstream (pure virtual
2680 -- setupFloatingArguments), so hasquant binds no constructor for it directly.
2681 data CFixedVsFloatingSwap'
2682 type GenFixedVsFloatingSwap f = GenSwap (AnyOf CFixedVsFloatingSwap' f)
2683 type CFixedVsFloatingSwap = ForeignPtr CFixedVsFloatingSwap'
2684 type FixedVsFloatingSwap = GenFixedVsFloatingSwap CFixedVsFloatingSwap
2685 data CVanillaSwap'
2686 type CVanillaSwap = ForeignPtr CVanillaSwap'
2687 type VanillaSwap = GenFixedVsFloatingSwap CVanillaSwap
2688 foreign import ccall unsafe "ql.h &qlFreeFixedVsFloatingSwap" qlFreeFixedVsFloatingSwap :: FinalizerPtr CFixedVsFloatingSwap'
2689 foreign import ccall unsafe "ql.h &qlFreeVanillaSwap" qlFreeVanillaSwap :: FinalizerPtr CVanillaSwap'
2690 instance Finalizable CFixedVsFloatingSwap' where finalize = qlFreeFixedVsFloatingSwap
2691 instance Finalizable CVanillaSwap' where finalize = qlFreeVanillaSwap
2692 foreign import ccall "ql.h qlFixedVsFloatingSwapAsSwap" qlFixedVsFloatingSwapAsSwap :: Ptr CFixedVsFloatingSwap' -> IO (Ptr CSwap')
2693 foreign import ccall "ql.h qlVanillaSwapAsFixedVsFloatingSwap" qlVanillaSwapAsFixedVsFloatingSwap :: Ptr CVanillaSwap' -> IO (Ptr CFixedVsFloatingSwap')
2694 instance Upcastable CFixedVsFloatingSwap' where {type Base CFixedVsFloatingSwap' = CSwap'; upcast = qlFixedVsFloatingSwapAsSwap}
2695 instance Upcastable CVanillaSwap' where {type Base CVanillaSwap' = CFixedVsFloatingSwap'; upcast = qlVanillaSwapAsFixedVsFloatingSwap}
2696 asFixedVsFloatingSwap :: GenFixedVsFloatingSwap f -> IO FixedVsFloatingSwap
2697 asFixedVsFloatingSwap = transferGenForeignPtr peekFixedVsFloatingSwap . peel . peel . getInstrument
2698 peekFixedVsFloatingSwap :: Ptr CFixedVsFloatingSwap' -> IO FixedVsFloatingSwap
2699 peekFixedVsFloatingSwap = newCastForeignPtr >=> newGenFixedVsFloatingSwap
2700 withFixedVsFloatingSwap :: GenFixedVsFloatingSwap f -> (Ptr CFixedVsFloatingSwap' -> IO b) -> IO b
2701 withFixedVsFloatingSwap = withGenForeignPtr . peel . peel . getInstrument
2702 newGenFixedVsFloatingSwap :: GenForeignPtr f CFixedVsFloatingSwap' -> IO (GenFixedVsFloatingSwap f)
2703 newGenFixedVsFloatingSwap = pure . GenInstrument . newAnyOf . newAnyOf
2704 peekVanillaSwap :: Ptr CVanillaSwap' -> IO VanillaSwap
2705 peekVanillaSwap = newGenForeignPtr >=> newGenFixedVsFloatingSwap
2706 withVanillaSwap :: VanillaSwap -> (Ptr CVanillaSwap' -> IO b) -> IO b
2707 withVanillaSwap = withForeignPtr . ptr . peel . peel . getInstrument
2708
2709 -- ConstNotionalCrossCurrencySwap sits between Swap and its two owned leaves
2710 -- (ConstNotionalCrossCurrencyBasisSwap, ConstNotionalCrossCurrencyFixedVsFloatingSwap). It earns
2711 -- its own family level (mirrors FixedVsFloatingSwap/VanillaSwap just above) because its own
2712 -- getters (legCurrency, inCcyLegBPS, inCcyLegNPV, npvDateDiscounts) are inherited by both leaves
2713 -- and are bound generically over 'GenConstNotionalCrossCurrencySwap', while each leaf keeps its
2714 -- own engine-dispatched getters (fairPaySpread/fairRecSpread, fairRate/fairSpread) reachable only
2715 -- through the real leaf pointer. Unlike FixedVsFloatingSwap, the base class is concrete upstream
2716 -- and hasquant binds its own 2-leg/N-leg constructors directly at this level.
2717 data CConstNotionalCrossCurrencySwap'
2718 type GenConstNotionalCrossCurrencySwap x = GenSwap (AnyOf CConstNotionalCrossCurrencySwap' x)
2719 type CConstNotionalCrossCurrencySwap = ForeignPtr CConstNotionalCrossCurrencySwap'
2720 type ConstNotionalCrossCurrencySwap = GenConstNotionalCrossCurrencySwap CConstNotionalCrossCurrencySwap
2721 data CConstNotionalCrossCurrencyBasisSwap'
2722 type CConstNotionalCrossCurrencyBasisSwap = ForeignPtr CConstNotionalCrossCurrencyBasisSwap'
2723 type ConstNotionalCrossCurrencyBasisSwap = GenConstNotionalCrossCurrencySwap CConstNotionalCrossCurrencyBasisSwap
2724 data CConstNotionalCrossCurrencyFixedVsFloatingSwap'
2725 type CConstNotionalCrossCurrencyFixedVsFloatingSwap = ForeignPtr CConstNotionalCrossCurrencyFixedVsFloatingSwap'
2726 type ConstNotionalCrossCurrencyFixedVsFloatingSwap = GenConstNotionalCrossCurrencySwap CConstNotionalCrossCurrencyFixedVsFloatingSwap
2727 foreign import ccall unsafe "ql.h &qlFreeConstNotionalCrossCurrencySwap" qlFreeConstNotionalCrossCurrencySwap :: FinalizerPtr CConstNotionalCrossCurrencySwap'
2728 foreign import ccall unsafe "ql.h &qlFreeConstNotionalCrossCurrencyBasisSwap" qlFreeConstNotionalCrossCurrencyBasisSwap :: FinalizerPtr CConstNotionalCrossCurrencyBasisSwap'
2729 foreign import ccall unsafe "ql.h &qlFreeConstNotionalCrossCurrencyFixedVsFloatingSwap" qlFreeConstNotionalCrossCurrencyFixedVsFloatingSwap :: FinalizerPtr CConstNotionalCrossCurrencyFixedVsFloatingSwap'
2730 instance Finalizable CConstNotionalCrossCurrencySwap' where finalize = qlFreeConstNotionalCrossCurrencySwap
2731 instance Finalizable CConstNotionalCrossCurrencyBasisSwap' where finalize = qlFreeConstNotionalCrossCurrencyBasisSwap
2732 instance Finalizable CConstNotionalCrossCurrencyFixedVsFloatingSwap' where finalize = qlFreeConstNotionalCrossCurrencyFixedVsFloatingSwap
2733 foreign import ccall "ql.h qlConstNotionalCrossCurrencySwapAsSwap" qlConstNotionalCrossCurrencySwapAsSwap :: Ptr CConstNotionalCrossCurrencySwap' -> IO (Ptr CSwap')
2734 foreign import ccall "ql.h qlConstNotionalCrossCurrencyBasisSwapAsConstNotionalCrossCurrencySwap" qlConstNotionalCrossCurrencyBasisSwapAsConstNotionalCrossCurrencySwap :: Ptr CConstNotionalCrossCurrencyBasisSwap' -> IO (Ptr CConstNotionalCrossCurrencySwap')
2735 foreign import ccall "ql.h qlConstNotionalCrossCurrencyFixedVsFloatingSwapAsConstNotionalCrossCurrencySwap" qlConstNotionalCrossCurrencyFixedVsFloatingSwapAsConstNotionalCrossCurrencySwap :: Ptr CConstNotionalCrossCurrencyFixedVsFloatingSwap' -> IO (Ptr CConstNotionalCrossCurrencySwap')
2736 instance Upcastable CConstNotionalCrossCurrencySwap' where {type Base CConstNotionalCrossCurrencySwap' = CSwap'; upcast = qlConstNotionalCrossCurrencySwapAsSwap}
2737 instance Upcastable CConstNotionalCrossCurrencyBasisSwap' where {type Base CConstNotionalCrossCurrencyBasisSwap' = CConstNotionalCrossCurrencySwap'; upcast = qlConstNotionalCrossCurrencyBasisSwapAsConstNotionalCrossCurrencySwap}
2738 instance Upcastable CConstNotionalCrossCurrencyFixedVsFloatingSwap' where {type Base CConstNotionalCrossCurrencyFixedVsFloatingSwap' = CConstNotionalCrossCurrencySwap'; upcast = qlConstNotionalCrossCurrencyFixedVsFloatingSwapAsConstNotionalCrossCurrencySwap}
2739 asConstNotionalCrossCurrencySwap :: GenConstNotionalCrossCurrencySwap x -> IO ConstNotionalCrossCurrencySwap
2740 asConstNotionalCrossCurrencySwap = transferGenForeignPtr peekConstNotionalCrossCurrencySwap . peel . peel . getInstrument
2741 peekConstNotionalCrossCurrencySwap :: Ptr CConstNotionalCrossCurrencySwap' -> IO ConstNotionalCrossCurrencySwap
2742 peekConstNotionalCrossCurrencySwap = newCastForeignPtr >=> newGenConstNotionalCrossCurrencySwap
2743 withConstNotionalCrossCurrencySwap :: GenConstNotionalCrossCurrencySwap x -> (Ptr CConstNotionalCrossCurrencySwap' -> IO b) -> IO b
2744 withConstNotionalCrossCurrencySwap = withGenForeignPtr . peel . peel . getInstrument
2745 newGenConstNotionalCrossCurrencySwap :: GenForeignPtr x CConstNotionalCrossCurrencySwap' -> IO (GenConstNotionalCrossCurrencySwap x)
2746 newGenConstNotionalCrossCurrencySwap = pure . GenInstrument . newAnyOf . newAnyOf
2747 peekConstNotionalCrossCurrencyBasisSwap :: Ptr CConstNotionalCrossCurrencyBasisSwap' -> IO ConstNotionalCrossCurrencyBasisSwap
2748 peekConstNotionalCrossCurrencyBasisSwap = newGenForeignPtr >=> newGenConstNotionalCrossCurrencySwap
2749 withConstNotionalCrossCurrencyBasisSwap :: ConstNotionalCrossCurrencyBasisSwap -> (Ptr CConstNotionalCrossCurrencyBasisSwap' -> IO b) -> IO b
2750 withConstNotionalCrossCurrencyBasisSwap = withForeignPtr . ptr . peel . peel . getInstrument
2751 peekConstNotionalCrossCurrencyFixedVsFloatingSwap :: Ptr CConstNotionalCrossCurrencyFixedVsFloatingSwap' -> IO ConstNotionalCrossCurrencyFixedVsFloatingSwap
2752 peekConstNotionalCrossCurrencyFixedVsFloatingSwap = newGenForeignPtr >=> newGenConstNotionalCrossCurrencySwap
2753 withConstNotionalCrossCurrencyFixedVsFloatingSwap :: ConstNotionalCrossCurrencyFixedVsFloatingSwap -> (Ptr CConstNotionalCrossCurrencyFixedVsFloatingSwap' -> IO b) -> IO b
2754 withConstNotionalCrossCurrencyFixedVsFloatingSwap = withForeignPtr . ptr . peel . peel . getInstrument
2755
2756 data CNonstandardSwap'
2757 type CNonstandardSwap = ForeignPtr CNonstandardSwap'
2758 type NonstandardSwap = GenSwap CNonstandardSwap
2759 foreign import ccall unsafe "ql.h &qlFreeNonstandardSwap" qlFreeNonstandardSwap :: FinalizerPtr CNonstandardSwap'
2760 instance Finalizable CNonstandardSwap' where finalize = qlFreeNonstandardSwap
2761 foreign import ccall "ql.h qlNonstandardSwapAsSwap" qlNonstandardSwapAsSwap :: Ptr CNonstandardSwap' -> IO (Ptr CSwap')
2762 instance Upcastable CNonstandardSwap' where {type Base CNonstandardSwap' = CSwap'; upcast = qlNonstandardSwapAsSwap}
2763 peekNonstandardSwap :: Ptr CNonstandardSwap' -> IO NonstandardSwap
2764 peekNonstandardSwap = peekGenSwap
2765 withNonstandardSwap :: NonstandardSwap -> (Ptr CNonstandardSwap' -> IO b) -> IO b
2766 withNonstandardSwap = withForeignPtr . ptr . peel . getInstrument
2767
2768 data CFloatFloatSwap'
2769 type CFloatFloatSwap = ForeignPtr CFloatFloatSwap'
2770 type FloatFloatSwap = GenSwap CFloatFloatSwap
2771 foreign import ccall unsafe "ql.h &qlFreeFloatFloatSwap" qlFreeFloatFloatSwap :: FinalizerPtr CFloatFloatSwap'
2772 instance Finalizable CFloatFloatSwap' where finalize = qlFreeFloatFloatSwap
2773 foreign import ccall "ql.h qlFloatFloatSwapAsSwap" qlFloatFloatSwapAsSwap :: Ptr CFloatFloatSwap' -> IO (Ptr CSwap')
2774 instance Upcastable CFloatFloatSwap' where {type Base CFloatFloatSwap' = CSwap'; upcast = qlFloatFloatSwapAsSwap}
2775 peekFloatFloatSwap :: Ptr CFloatFloatSwap' -> IO FloatFloatSwap
2776 peekFloatFloatSwap = peekGenSwap
2777 withFloatFloatSwap :: FloatFloatSwap -> (Ptr CFloatFloatSwap' -> IO b) -> IO b
2778 withFloatFloatSwap = withForeignPtr . ptr . peel . getInstrument
2779
2780 data CAssetSwap'
2781 type CAssetSwap = ForeignPtr CAssetSwap'
2782 type AssetSwap = GenSwap CAssetSwap
2783 foreign import ccall unsafe "ql.h &qlFreeAssetSwap" qlFreeAssetSwap :: FinalizerPtr CAssetSwap'
2784 instance Finalizable CAssetSwap' where finalize = qlFreeAssetSwap
2785 foreign import ccall "ql.h qlAssetSwapAsSwap" qlAssetSwapAsSwap :: Ptr CAssetSwap' -> IO (Ptr CSwap')
2786 instance Upcastable CAssetSwap' where {type Base CAssetSwap' = CSwap'; upcast = qlAssetSwapAsSwap}
2787 peekAssetSwap :: Ptr CAssetSwap' -> IO AssetSwap
2788 peekAssetSwap = peekGenSwap
2789 withAssetSwap :: AssetSwap -> (Ptr CAssetSwap' -> IO b) -> IO b
2790 withAssetSwap = withForeignPtr . ptr . peel . getInstrument
2791
2792 data CBMASwap'
2793 type CBMASwap = ForeignPtr CBMASwap'
2794 type BMASwap = GenSwap CBMASwap
2795 foreign import ccall unsafe "ql.h &qlFreeBMASwap" qlFreeBMASwap :: FinalizerPtr CBMASwap'
2796 instance Finalizable CBMASwap' where finalize = qlFreeBMASwap
2797 foreign import ccall "ql.h qlBMASwapAsSwap" qlBMASwapAsSwap :: Ptr CBMASwap' -> IO (Ptr CSwap')
2798 instance Upcastable CBMASwap' where {type Base CBMASwap' = CSwap'; upcast = qlBMASwapAsSwap}
2799 peekBMASwap :: Ptr CBMASwap' -> IO BMASwap
2800 peekBMASwap = peekGenSwap
2801 withBMASwap :: BMASwap -> (Ptr CBMASwap' -> IO b) -> IO b
2802 withBMASwap = withForeignPtr . ptr . peel . getInstrument
2803
2804 data COvernightIndexedSwap'
2805 type COvernightIndexedSwap = ForeignPtr COvernightIndexedSwap'
2806 type OvernightIndexedSwap = GenSwap COvernightIndexedSwap
2807 foreign import ccall unsafe "ql.h &qlFreeOvernightIndexedSwap" qlFreeOvernightIndexedSwap :: FinalizerPtr COvernightIndexedSwap'
2808 instance Finalizable COvernightIndexedSwap' where finalize = qlFreeOvernightIndexedSwap
2809 foreign import ccall "ql.h qlOvernightIndexedSwapAsSwap" qlOvernightIndexedSwapAsSwap :: Ptr COvernightIndexedSwap' -> IO (Ptr CSwap')
2810 instance Upcastable COvernightIndexedSwap' where {type Base COvernightIndexedSwap' = CSwap'; upcast = qlOvernightIndexedSwapAsSwap}
2811 peekOvernightIndexedSwap :: Ptr COvernightIndexedSwap' -> IO OvernightIndexedSwap
2812 peekOvernightIndexedSwap = peekGenSwap
2813 withOvernightIndexedSwap :: OvernightIndexedSwap -> (Ptr COvernightIndexedSwap' -> IO b) -> IO b
2814 withOvernightIndexedSwap = withForeignPtr . ptr . peel . getInstrument
2815
2816 data CZeroCouponInflationSwap'
2817 type CZeroCouponInflationSwap = ForeignPtr CZeroCouponInflationSwap'
2818 type ZeroCouponInflationSwap = GenSwap CZeroCouponInflationSwap
2819 foreign import ccall unsafe "ql.h &qlFreeZeroCouponInflationSwap" qlFreeZeroCouponInflationSwap :: FinalizerPtr CZeroCouponInflationSwap'
2820 instance Finalizable CZeroCouponInflationSwap' where finalize = qlFreeZeroCouponInflationSwap
2821 foreign import ccall "ql.h qlZeroCouponInflationSwapAsSwap" qlZeroCouponInflationSwapAsSwap :: Ptr CZeroCouponInflationSwap' -> IO (Ptr CSwap')
2822 instance Upcastable CZeroCouponInflationSwap' where {type Base CZeroCouponInflationSwap' = CSwap'; upcast = qlZeroCouponInflationSwapAsSwap}
2823 peekZeroCouponInflationSwap :: Ptr CZeroCouponInflationSwap' -> IO ZeroCouponInflationSwap
2824 peekZeroCouponInflationSwap = peekGenSwap
2825 withZeroCouponInflationSwap :: ZeroCouponInflationSwap -> (Ptr CZeroCouponInflationSwap' -> IO b) -> IO b
2826 withZeroCouponInflationSwap = withForeignPtr . ptr . peel . getInstrument
2827
2828 data CYearOnYearInflationSwap'
2829 type CYearOnYearInflationSwap = ForeignPtr CYearOnYearInflationSwap'
2830 type YearOnYearInflationSwap = GenSwap CYearOnYearInflationSwap
2831 foreign import ccall unsafe "ql.h &qlFreeYearOnYearInflationSwap" qlFreeYearOnYearInflationSwap :: FinalizerPtr CYearOnYearInflationSwap'
2832 instance Finalizable CYearOnYearInflationSwap' where finalize = qlFreeYearOnYearInflationSwap
2833 foreign import ccall "ql.h qlYearOnYearInflationSwapAsSwap" qlYearOnYearInflationSwapAsSwap :: Ptr CYearOnYearInflationSwap' -> IO (Ptr CSwap')
2834 instance Upcastable CYearOnYearInflationSwap' where {type Base CYearOnYearInflationSwap' = CSwap'; upcast = qlYearOnYearInflationSwapAsSwap}
2835 peekYearOnYearInflationSwap :: Ptr CYearOnYearInflationSwap' -> IO YearOnYearInflationSwap
2836 peekYearOnYearInflationSwap = peekGenSwap
2837 withYearOnYearInflationSwap :: YearOnYearInflationSwap -> (Ptr CYearOnYearInflationSwap' -> IO b) -> IO b
2838 withYearOnYearInflationSwap = withForeignPtr . ptr . peel . getInstrument
2839
2840 data CCPISwap'
2841 type CCPISwap = ForeignPtr CCPISwap'
2842 type CPISwap = GenSwap CCPISwap
2843 foreign import ccall unsafe "ql.h &qlFreeCPISwap" qlFreeCPISwap :: FinalizerPtr CCPISwap'
2844 instance Finalizable CCPISwap' where finalize = qlFreeCPISwap
2845 foreign import ccall "ql.h qlCPISwapAsSwap" qlCPISwapAsSwap :: Ptr CCPISwap' -> IO (Ptr CSwap')
2846 instance Upcastable CCPISwap' where {type Base CCPISwap' = CSwap'; upcast = qlCPISwapAsSwap}
2847 peekCPISwap :: Ptr CCPISwap' -> IO CPISwap
2848 peekCPISwap = peekGenSwap
2849 withCPISwap :: CPISwap -> (Ptr CCPISwap' -> IO b) -> IO b
2850 withCPISwap = withForeignPtr . ptr . peel . getInstrument
2851
2852 data CZeroCouponSwap'
2853 type CZeroCouponSwap = ForeignPtr CZeroCouponSwap'
2854 type ZeroCouponSwap = GenSwap CZeroCouponSwap
2855 foreign import ccall unsafe "ql.h &qlFreeZeroCouponSwap" qlFreeZeroCouponSwap :: FinalizerPtr CZeroCouponSwap'
2856 instance Finalizable CZeroCouponSwap' where finalize = qlFreeZeroCouponSwap
2857 foreign import ccall "ql.h qlZeroCouponSwapAsSwap" qlZeroCouponSwapAsSwap :: Ptr CZeroCouponSwap' -> IO (Ptr CSwap')
2858 instance Upcastable CZeroCouponSwap' where {type Base CZeroCouponSwap' = CSwap'; upcast = qlZeroCouponSwapAsSwap}
2859 peekZeroCouponSwap :: Ptr CZeroCouponSwap' -> IO ZeroCouponSwap
2860 peekZeroCouponSwap = peekGenSwap
2861 withZeroCouponSwap :: ZeroCouponSwap -> (Ptr CZeroCouponSwap' -> IO b) -> IO b
2862 withZeroCouponSwap = withForeignPtr . ptr . peel . getInstrument
2863
2864 data CEquityTotalReturnSwap'
2865 type CEquityTotalReturnSwap = ForeignPtr CEquityTotalReturnSwap'
2866 type EquityTotalReturnSwap = GenSwap CEquityTotalReturnSwap
2867 foreign import ccall unsafe "ql.h &qlFreeEquityTotalReturnSwap" qlFreeEquityTotalReturnSwap :: FinalizerPtr CEquityTotalReturnSwap'
2868 instance Finalizable CEquityTotalReturnSwap' where finalize = qlFreeEquityTotalReturnSwap
2869 foreign import ccall "ql.h qlEquityTotalReturnSwapAsSwap" qlEquityTotalReturnSwapAsSwap :: Ptr CEquityTotalReturnSwap' -> IO (Ptr CSwap')
2870 instance Upcastable CEquityTotalReturnSwap' where {type Base CEquityTotalReturnSwap' = CSwap'; upcast = qlEquityTotalReturnSwapAsSwap}
2871 peekEquityTotalReturnSwap :: Ptr CEquityTotalReturnSwap' -> IO EquityTotalReturnSwap
2872 peekEquityTotalReturnSwap = peekGenSwap
2873 withEquityTotalReturnSwap :: EquityTotalReturnSwap -> (Ptr CEquityTotalReturnSwap' -> IO b) -> IO b
2874 withEquityTotalReturnSwap = withForeignPtr . ptr . peel . getInstrument
2875
2876 data CCdsOption'
2877 type CCdsOption = ForeignPtr CCdsOption'
2878 type CdsOption = GenOption CCdsOption
2879 foreign import ccall unsafe "ql.h &qlFreeCdsOption" qlFreeCdsOption :: FinalizerPtr CCdsOption'
2880 instance Finalizable CCdsOption' where finalize = qlFreeCdsOption
2881 foreign import ccall "ql.h qlCdsOptionAsOption" qlCdsOptionAsOption :: Ptr CCdsOption' -> IO (Ptr COption')
2882 instance Upcastable CCdsOption' where {type Base CCdsOption' = COption'; upcast = qlCdsOptionAsOption}
2883 peekCdsOption :: Ptr CCdsOption' -> IO CdsOption
2884 peekCdsOption = peekGenOption
2885 withCdsOption :: CdsOption -> (Ptr CCdsOption' -> IO b) -> IO b
2886 withCdsOption = withForeignPtr . ptr . peel . getInstrument
2887
2888 data CSwaption'
2889 type CSwaption = ForeignPtr CSwaption'
2890 type Swaption = GenOption CSwaption
2891 foreign import ccall unsafe "ql.h &qlFreeSwaption" qlFreeSwaption :: FinalizerPtr CSwaption'
2892 instance Finalizable CSwaption' where finalize = qlFreeSwaption
2893 foreign import ccall "ql.h qlSwaptionAsOption" qlSwaptionAsOption :: Ptr CSwaption' -> IO (Ptr COption')
2894 instance Upcastable CSwaption' where {type Base CSwaption' = COption'; upcast = qlSwaptionAsOption}
2895 peekSwaption :: Ptr CSwaption' -> IO Swaption
2896 peekSwaption = peekGenOption
2897 withSwaption :: Swaption -> (Ptr CSwaption' -> IO b) -> IO b
2898 withSwaption = withForeignPtr . ptr . peel . getInstrument
2899
2900 data CNonstandardSwaption'
2901 type CNonstandardSwaption = ForeignPtr CNonstandardSwaption'
2902 type NonstandardSwaption = GenOption CNonstandardSwaption
2903 foreign import ccall unsafe "ql.h &qlFreeNonstandardSwaption" qlFreeNonstandardSwaption :: FinalizerPtr CNonstandardSwaption'
2904 instance Finalizable CNonstandardSwaption' where finalize = qlFreeNonstandardSwaption
2905 foreign import ccall "ql.h qlNonstandardSwaptionAsOption" qlNonstandardSwaptionAsOption :: Ptr CNonstandardSwaption' -> IO (Ptr COption')
2906 instance Upcastable CNonstandardSwaption' where {type Base CNonstandardSwaption' = COption'; upcast = qlNonstandardSwaptionAsOption}
2907 peekNonstandardSwaption :: Ptr CNonstandardSwaption' -> IO NonstandardSwaption
2908 peekNonstandardSwaption = peekGenOption
2909 withNonstandardSwaption :: NonstandardSwaption -> (Ptr CNonstandardSwaption' -> IO b) -> IO b
2910 withNonstandardSwaption = withForeignPtr . ptr . peel . getInstrument
2911
2912 data CFloatFloatSwaption'
2913 type CFloatFloatSwaption = ForeignPtr CFloatFloatSwaption'
2914 type FloatFloatSwaption = GenOption CFloatFloatSwaption
2915 foreign import ccall unsafe "ql.h &qlFreeFloatFloatSwaption" qlFreeFloatFloatSwaption :: FinalizerPtr CFloatFloatSwaption'
2916 instance Finalizable CFloatFloatSwaption' where finalize = qlFreeFloatFloatSwaption
2917 foreign import ccall "ql.h qlFloatFloatSwaptionAsOption" qlFloatFloatSwaptionAsOption :: Ptr CFloatFloatSwaption' -> IO (Ptr COption')
2918 instance Upcastable CFloatFloatSwaption' where {type Base CFloatFloatSwaption' = COption'; upcast = qlFloatFloatSwaptionAsOption}
2919 peekFloatFloatSwaption :: Ptr CFloatFloatSwaption' -> IO FloatFloatSwaption
2920 peekFloatFloatSwaption = peekGenOption
2921 withFloatFloatSwaption :: FloatFloatSwaption -> (Ptr CFloatFloatSwaption' -> IO b) -> IO b
2922 withFloatFloatSwaption = withForeignPtr . ptr . peel . getInstrument
2923
2924 data CMultiAssetOption'
2925 data CMargrabeOption'
2926 type GenMultiAssetOption mo = GenOption (AnyOf CMultiAssetOption' mo)
2927 type CMultiAssetOption = ForeignPtr CMultiAssetOption'
2928 type MultiAssetOption = GenMultiAssetOption CMultiAssetOption
2929 type CMargrabeOption = ForeignPtr CMargrabeOption'
2930 type MargrabeOption = GenMultiAssetOption CMargrabeOption
2931 foreign import ccall unsafe "ql.h &qlFreeMultiAssetOption" qlFreeMultiAssetOption :: FinalizerPtr CMultiAssetOption'
2932 foreign import ccall unsafe "ql.h &qlFreeMargrabeOption" qlFreeMargrabeOption :: FinalizerPtr CMargrabeOption'
2933 instance Finalizable CMultiAssetOption' where finalize = qlFreeMultiAssetOption
2934 instance Finalizable CMargrabeOption' where finalize = qlFreeMargrabeOption
2935 foreign import ccall "ql.h qlMultiAssetOptionAsOption" qlMultiAssetOptionAsOption :: Ptr CMultiAssetOption' -> IO (Ptr COption')
2936 foreign import ccall "ql.h qlMargrabeOptionAsMultiAssetOption" qlMargrabeOptionAsMultiAssetOption :: Ptr CMargrabeOption' -> IO (Ptr CMultiAssetOption')
2937 instance Upcastable CMultiAssetOption' where {type Base CMultiAssetOption' = COption'; upcast = qlMultiAssetOptionAsOption}
2938 instance Upcastable CMargrabeOption' where {type Base CMargrabeOption' = CMultiAssetOption'; upcast = qlMargrabeOptionAsMultiAssetOption}
2939 asMultiAssetOption :: GenMultiAssetOption mo -> IO MultiAssetOption
2940 asMultiAssetOption = transferGenForeignPtr peekMultiAssetOption . peel . peel . getInstrument
2941 peekMultiAssetOption :: Ptr CMultiAssetOption' -> IO MultiAssetOption
2942 peekMultiAssetOption = newCastForeignPtr >=> newGenMultiAssetOption
2943 withMultiAssetOption :: GenMultiAssetOption mo -> (Ptr CMultiAssetOption' -> IO b) -> IO b
2944 withMultiAssetOption = withGenForeignPtr . peel . peel . getInstrument
2945 newGenMultiAssetOption :: GenForeignPtr mo CMultiAssetOption' -> IO (GenMultiAssetOption mo)
2946 newGenMultiAssetOption = pure . GenInstrument . newAnyOf . newAnyOf
2947
2948 peekMargrabeOption :: Ptr CMargrabeOption' -> IO MargrabeOption
2949 peekMargrabeOption = newGenForeignPtr >=> newGenMultiAssetOption
2950 withMargrabeOption :: MargrabeOption -> (Ptr CMargrabeOption' -> IO b) -> IO b
2951 withMargrabeOption = withForeignPtr . ptr . peel . peel . getInstrument
2952
2953 data COneAssetOption'
2954 type GenOneAssetOption oo = GenOption (AnyOf COneAssetOption' oo)
2955 type COneAssetOption = ForeignPtr COneAssetOption'
2956 type OneAssetOption = GenOneAssetOption COneAssetOption
2957 foreign import ccall unsafe "ql.h &qlFreeOneAssetOption" qlFreeOneAssetOption :: FinalizerPtr COneAssetOption'
2958 instance Finalizable COneAssetOption' where finalize = qlFreeOneAssetOption
2959 foreign import ccall "ql.h qlOneAssetOptionAsOption" qlOneAssetOptionAsOption :: Ptr COneAssetOption' -> IO (Ptr COption')
2960 instance Upcastable COneAssetOption' where {type Base COneAssetOption' = COption'; upcast = qlOneAssetOptionAsOption}
2961 asOneAssetOption :: GenOneAssetOption oo -> IO OneAssetOption
2962 asOneAssetOption = transferGenForeignPtr peekOneAssetOption . peel . peel . getInstrument
2963 peekOneAssetOption :: Ptr COneAssetOption' -> IO OneAssetOption
2964 peekOneAssetOption = newCastForeignPtr >=> newGenOneAssetOption
2965 withOneAssetOption :: GenOneAssetOption oo -> (Ptr COneAssetOption' -> IO b) -> IO b
2966 withOneAssetOption = withGenForeignPtr . peel . peel . getInstrument
2967 newGenOneAssetOption :: GenForeignPtr oo COneAssetOption' -> IO (GenOneAssetOption oo)
2968 newGenOneAssetOption = pure . GenInstrument . newAnyOf . newAnyOf
2969
2970 data CBarrierOption'
2971 type CBarrierOption = ForeignPtr CBarrierOption'
2972 type BarrierOption = GenOneAssetOption CBarrierOption
2973 foreign import ccall unsafe "ql.h &qlFreeBarrierOption" qlFreeBarrierOption :: FinalizerPtr CBarrierOption'
2974 instance Finalizable CBarrierOption' where finalize = qlFreeBarrierOption
2975 foreign import ccall "ql.h qlBarrierOptionAsOneAssetOption" qlBarrierOptionAsOneAssetOption :: Ptr CBarrierOption' -> IO (Ptr COneAssetOption')
2976 instance Upcastable CBarrierOption' where {type Base CBarrierOption' = COneAssetOption'; upcast = qlBarrierOptionAsOneAssetOption}
2977 peekBarrierOption :: Ptr CBarrierOption' -> IO BarrierOption
2978 peekBarrierOption = newGenForeignPtr >=> newGenOneAssetOption
2979 withBarrierOption :: BarrierOption -> (Ptr CBarrierOption' -> IO b) -> IO b
2980 withBarrierOption = withForeignPtr . ptr . peel . peel . getInstrument
2981
2982 data CSoftBarrierOption'
2983 type CSoftBarrierOption = ForeignPtr CSoftBarrierOption'
2984 type SoftBarrierOption = GenOneAssetOption CSoftBarrierOption
2985 foreign import ccall unsafe "ql.h &qlFreeSoftBarrierOption" qlFreeSoftBarrierOption :: FinalizerPtr CSoftBarrierOption'
2986 instance Finalizable CSoftBarrierOption' where finalize = qlFreeSoftBarrierOption
2987 foreign import ccall "ql.h qlSoftBarrierOptionAsOneAssetOption" qlSoftBarrierOptionAsOneAssetOption :: Ptr CSoftBarrierOption' -> IO (Ptr COneAssetOption')
2988 instance Upcastable CSoftBarrierOption' where {type Base CSoftBarrierOption' = COneAssetOption'; upcast = qlSoftBarrierOptionAsOneAssetOption}
2989 peekSoftBarrierOption :: Ptr CSoftBarrierOption' -> IO SoftBarrierOption
2990 peekSoftBarrierOption = newGenForeignPtr >=> newGenOneAssetOption
2991 withSoftBarrierOption :: SoftBarrierOption -> (Ptr CSoftBarrierOption' -> IO b) -> IO b
2992 withSoftBarrierOption = withForeignPtr . ptr . peel . peel . getInstrument
2993
2994 data CDoubleBarrierOption'
2995 type CDoubleBarrierOption = ForeignPtr CDoubleBarrierOption'
2996 type DoubleBarrierOption = GenOneAssetOption CDoubleBarrierOption
2997 foreign import ccall unsafe "ql.h &qlFreeDoubleBarrierOption" qlFreeDoubleBarrierOption :: FinalizerPtr CDoubleBarrierOption'
2998 instance Finalizable CDoubleBarrierOption' where finalize = qlFreeDoubleBarrierOption
2999 foreign import ccall "ql.h qlDoubleBarrierOptionAsOneAssetOption" qlDoubleBarrierOptionAsOneAssetOption :: Ptr CDoubleBarrierOption' -> IO (Ptr COneAssetOption')
3000 instance Upcastable CDoubleBarrierOption' where {type Base CDoubleBarrierOption' = COneAssetOption'; upcast = qlDoubleBarrierOptionAsOneAssetOption}
3001 peekDoubleBarrierOption :: Ptr CDoubleBarrierOption' -> IO DoubleBarrierOption
3002 peekDoubleBarrierOption = newGenForeignPtr >=> newGenOneAssetOption
3003 withDoubleBarrierOption :: DoubleBarrierOption -> (Ptr CDoubleBarrierOption' -> IO b) -> IO b
3004 withDoubleBarrierOption = withForeignPtr . ptr . peel . peel . getInstrument
3005
3006 data CQuantoForwardVanillaOption'
3007 type CQuantoForwardVanillaOption = ForeignPtr CQuantoForwardVanillaOption'
3008 type QuantoForwardVanillaOption = GenOneAssetOption CQuantoForwardVanillaOption
3009 foreign import ccall unsafe "ql.h &qlFreeQuantoForwardVanillaOption" qlFreeQuantoForwardVanillaOption :: FinalizerPtr CQuantoForwardVanillaOption'
3010 instance Finalizable CQuantoForwardVanillaOption' where finalize = qlFreeQuantoForwardVanillaOption
3011 foreign import ccall "ql.h qlQuantoForwardVanillaOptionAsOneAssetOption" qlQuantoForwardVanillaOptionAsOneAssetOption :: Ptr CQuantoForwardVanillaOption' -> IO (Ptr COneAssetOption')
3012 instance Upcastable CQuantoForwardVanillaOption' where {type Base CQuantoForwardVanillaOption' = COneAssetOption'; upcast = qlQuantoForwardVanillaOptionAsOneAssetOption}
3013 peekQuantoForwardVanillaOption :: Ptr CQuantoForwardVanillaOption' -> IO QuantoForwardVanillaOption
3014 peekQuantoForwardVanillaOption = newGenForeignPtr >=> newGenOneAssetOption
3015 withQuantoForwardVanillaOption :: QuantoForwardVanillaOption -> (Ptr CQuantoForwardVanillaOption' -> IO b) -> IO b
3016 withQuantoForwardVanillaOption = withForeignPtr . ptr . peel . peel . getInstrument
3017
3018 data CQuantoVanillaOption'
3019 type CQuantoVanillaOption = ForeignPtr CQuantoVanillaOption'
3020 type QuantoVanillaOption = GenOneAssetOption CQuantoVanillaOption
3021 foreign import ccall unsafe "ql.h &qlFreeQuantoVanillaOption" qlFreeQuantoVanillaOption :: FinalizerPtr CQuantoVanillaOption'
3022 instance Finalizable CQuantoVanillaOption' where finalize = qlFreeQuantoVanillaOption
3023 foreign import ccall "ql.h qlQuantoVanillaOptionAsOneAssetOption" qlQuantoVanillaOptionAsOneAssetOption :: Ptr CQuantoVanillaOption' -> IO (Ptr COneAssetOption')
3024 instance Upcastable CQuantoVanillaOption' where {type Base CQuantoVanillaOption' = COneAssetOption'; upcast = qlQuantoVanillaOptionAsOneAssetOption}
3025 peekQuantoVanillaOption :: Ptr CQuantoVanillaOption' -> IO QuantoVanillaOption
3026 peekQuantoVanillaOption = newGenForeignPtr >=> newGenOneAssetOption
3027 withQuantoVanillaOption :: QuantoVanillaOption -> (Ptr CQuantoVanillaOption' -> IO b) -> IO b
3028 withQuantoVanillaOption = withForeignPtr . ptr . peel . peel . getInstrument
3029
3030 data CVanillaOption'
3031 type CVanillaOption = ForeignPtr CVanillaOption'
3032 type VanillaOption = GenOneAssetOption CVanillaOption
3033 foreign import ccall unsafe "ql.h &qlFreeVanillaOption" qlFreeVanillaOption :: FinalizerPtr CVanillaOption'
3034 instance Finalizable CVanillaOption' where finalize = qlFreeVanillaOption
3035 foreign import ccall "ql.h qlVanillaOptionAsOneAssetOption" qlVanillaOptionAsOneAssetOption :: Ptr CVanillaOption' -> IO (Ptr COneAssetOption')
3036 instance Upcastable CVanillaOption' where {type Base CVanillaOption' = COneAssetOption'; upcast = qlVanillaOptionAsOneAssetOption}
3037 peekVanillaOption :: Ptr CVanillaOption' -> IO VanillaOption
3038 peekVanillaOption = newGenForeignPtr >=> newGenOneAssetOption
3039 withVanillaOption :: VanillaOption -> (Ptr CVanillaOption' -> IO b) -> IO b
3040 withVanillaOption = withForeignPtr . ptr . peel . peel . getInstrument
3041
3042 data CQuantoBarrierOption'
3043 type CQuantoBarrierOption = ForeignPtr CQuantoBarrierOption'
3044 type QuantoBarrierOption = GenOneAssetOption CQuantoBarrierOption
3045 foreign import ccall unsafe "ql.h &qlFreeQuantoBarrierOption" qlFreeQuantoBarrierOption :: FinalizerPtr CQuantoBarrierOption'
3046 instance Finalizable CQuantoBarrierOption' where finalize = qlFreeQuantoBarrierOption
3047 foreign import ccall "ql.h qlQuantoBarrierOptionAsOneAssetOption" qlQuantoBarrierOptionAsOneAssetOption :: Ptr CQuantoBarrierOption' -> IO (Ptr COneAssetOption')
3048 instance Upcastable CQuantoBarrierOption' where {type Base CQuantoBarrierOption' = COneAssetOption'; upcast = qlQuantoBarrierOptionAsOneAssetOption}
3049 peekQuantoBarrierOption :: Ptr CQuantoBarrierOption' -> IO QuantoBarrierOption
3050 peekQuantoBarrierOption = newGenForeignPtr >=> newGenOneAssetOption
3051 withQuantoBarrierOption :: QuantoBarrierOption -> (Ptr CQuantoBarrierOption' -> IO b) -> IO b
3052 withQuantoBarrierOption = withForeignPtr . ptr . peel . peel . getInstrument
3053
3054 data CQuantoDoubleBarrierOption'
3055 type CQuantoDoubleBarrierOption = ForeignPtr CQuantoDoubleBarrierOption'
3056 type QuantoDoubleBarrierOption = GenOneAssetOption CQuantoDoubleBarrierOption
3057 foreign import ccall unsafe "ql.h &qlFreeQuantoDoubleBarrierOption" qlFreeQuantoDoubleBarrierOption :: FinalizerPtr CQuantoDoubleBarrierOption'
3058 instance Finalizable CQuantoDoubleBarrierOption' where finalize = qlFreeQuantoDoubleBarrierOption
3059 foreign import ccall "ql.h qlQuantoDoubleBarrierOptionAsOneAssetOption" qlQuantoDoubleBarrierOptionAsOneAssetOption :: Ptr CQuantoDoubleBarrierOption' -> IO (Ptr COneAssetOption')
3060 instance Upcastable CQuantoDoubleBarrierOption' where {type Base CQuantoDoubleBarrierOption' = COneAssetOption'; upcast = qlQuantoDoubleBarrierOptionAsOneAssetOption}
3061 peekQuantoDoubleBarrierOption :: Ptr CQuantoDoubleBarrierOption' -> IO QuantoDoubleBarrierOption
3062 peekQuantoDoubleBarrierOption = newGenForeignPtr >=> newGenOneAssetOption
3063 withQuantoDoubleBarrierOption :: QuantoDoubleBarrierOption -> (Ptr CQuantoDoubleBarrierOption' -> IO b) -> IO b
3064 withQuantoDoubleBarrierOption = withForeignPtr . ptr . peel . peel . getInstrument
3065
3066 -- Commodity/EnergyCommodity are abstract-here: Commodity's own constructor is never called
3067 -- directly upstream (every concrete instrument goes through EnergyCommodity), and
3068 -- EnergyCommodity::quantity() is pure virtual, so neither binds a constructor here -- both are
3069 -- reachable only as upcast targets once a Stage-6 leaf (EnergyFuture, EnergyVanillaSwap,
3070 -- EnergyBasisSwap) exists. Commodity::secondaryCosts()/EnergyCommodity::commodityType() are plain,
3071 -- never-mutated echoes of each class's own constructor argument (commodity.hpp/energycommodity.hpp's
3072 -- inline getters each just `return foo_;`) -- not bound, per CLAUDE.md's trivial-getter rule.
3073 -- secondaryCostAmounts()/pricingErrors()/addPricingError are genuine (mutable, computed during
3074 -- pricing); their generalized 'withCommodity' accessor and marshalling live below, next to the
3075 -- Stage-6 leaves that finally give them a producer to verify against.
3076 data CCommodity'
3077 type GenCommodity c = GenInstrument (AnyOf CCommodity' c)
3078 type CCommodity = ForeignPtr CCommodity'
3079 type Commodity = GenCommodity CCommodity
3080 foreign import ccall unsafe "ql.h &qlFreeCommodity" qlFreeCommodity :: FinalizerPtr CCommodity'
3081 instance Finalizable CCommodity' where finalize = qlFreeCommodity
3082 foreign import ccall "ql.h qlCommodityAsInstrument" qlCommodityAsInstrument :: Ptr CCommodity' -> IO (Ptr CInstrument')
3083 instance Upcastable CCommodity' where {type Base CCommodity' = CInstrument'; upcast = qlCommodityAsInstrument}
3084
3085 data CEnergyCommodity'
3086 type GenEnergyCommodity e = GenCommodity (AnyOf CEnergyCommodity' e)
3087 type CEnergyCommodity = ForeignPtr CEnergyCommodity'
3088 type EnergyCommodity = GenEnergyCommodity CEnergyCommodity
3089 foreign import ccall unsafe "ql.h &qlFreeEnergyCommodity" qlFreeEnergyCommodity :: FinalizerPtr CEnergyCommodity'
3090 instance Finalizable CEnergyCommodity' where finalize = qlFreeEnergyCommodity
3091 foreign import ccall "ql.h qlEnergyCommodityAsCommodity" qlEnergyCommodityAsCommodity :: Ptr CEnergyCommodity' -> IO (Ptr CCommodity')
3092 instance Upcastable CEnergyCommodity' where {type Base CEnergyCommodity' = CCommodity'; upcast = qlEnergyCommodityAsCommodity}
3093
3094 -- |Generalizes 'Commodity's base-level getters (secondaryCostAmounts, pricingErrors,
3095 -- addPricingError) across every leaf in the Commodity\/EnergyCommodity\/EnergySwap subtree -- the
3096 -- same move as 'withFixedVsFloatingSwap' generalizing its own base-level getters. One peel:
3097 -- Commodity is the (only, so far) 'AnyOf' layer directly under 'GenInstrument' here.
3098 withCommodity :: GenCommodity c -> (Ptr CCommodity' -> IO b) -> IO b
3099 withCommodity = withGenForeignPtr . peel . getInstrument
3100
3101 -- |'newGenEnergyCommodity' wraps the 2 'AnyOf' layers (Commodity, EnergyCommodity) shared by every
3102 -- 'EnergyCommodity' leaf -- the same helper role 'newGenFixedVsFloatingSwap' plays for 'VanillaSwap'.
3103 newGenEnergyCommodity :: GenForeignPtr e CEnergyCommodity' -> IO (GenEnergyCommodity e)
3104 newGenEnergyCommodity = pure . GenInstrument . newAnyOf . newAnyOf
3105
3106 -- |Generalizes 'EnergyCommodity's one pure-virtual interface method, @quantity()@, across every
3107 -- leaf (EnergyFuture, EnergyVanillaSwap, EnergyBasisSwap): one shim, dispatched virtually on the
3108 -- C++ side, rather than a per-leaf binding -- EnergyFuture's own override is a plain echo of its
3109 -- constructor argument, but EnergySwap's is a real computed sum over its pricing periods
3110 -- (energyswap.cpp), so the binding as a whole is not a redundant echo even though one leaf's
3111 -- override happens to be.
3112 withEnergyCommodity :: GenEnergyCommodity e -> (Ptr CEnergyCommodity' -> IO b) -> IO b
3113 withEnergyCommodity = withGenForeignPtr . peel . peel . getInstrument
3114
3115 -- |'EnergyFuture': a leaf directly under 'EnergyCommodity' (Stage 6). 2 peels reach
3116 -- 'CEnergyFuture'' -- through the Commodity and EnergyCommodity layers -- the same depth
3117 -- 'VanillaSwap' needs under 'GenFixedVsFloatingSwap' (Swap + FixedVsFloatingSwap).
3118 data CEnergyFuture'
3119 type CEnergyFuture = ForeignPtr CEnergyFuture'
3120 type EnergyFuture = GenEnergyCommodity CEnergyFuture
3121 foreign import ccall unsafe "ql.h &qlFreeEnergyFuture" qlFreeEnergyFuture :: FinalizerPtr CEnergyFuture'
3122 instance Finalizable CEnergyFuture' where finalize = qlFreeEnergyFuture
3123 foreign import ccall "ql.h qlEnergyFutureAsEnergyCommodity" qlEnergyFutureAsEnergyCommodity :: Ptr CEnergyFuture' -> IO (Ptr CEnergyCommodity')
3124 instance Upcastable CEnergyFuture' where {type Base CEnergyFuture' = CEnergyCommodity'; upcast = qlEnergyFutureAsEnergyCommodity}
3125 peekEnergyFuture :: Ptr CEnergyFuture' -> IO EnergyFuture
3126 peekEnergyFuture = newGenForeignPtr >=> newGenEnergyCommodity
3127 withEnergyFuture :: EnergyFuture -> (Ptr CEnergyFuture' -> IO b) -> IO b
3128 withEnergyFuture = withForeignPtr . ptr . peel . peel . getInstrument
3129
3130 -- |'EnergySwap' is abstract-here: it binds a public constructor upstream, but never overrides
3131 -- 'performCalculations', so calling it directly falls through to 'Instrument's null-engine
3132 -- @QL_REQUIRE@ and throws -- reachable only as an upcast target from 'EnergyVanillaSwap'\/
3133 -- 'EnergyBasisSwap', exactly like 'FixedVsFloatingSwap'\/'VanillaSwap'. Its own accessors
3134 -- (calendar, payCurrency, receiveCurrency, pricingPeriods, dailyPositions, paymentCashFlows,
3135 -- commodityType, quantity) are bound generically over 'GenEnergySwap' in
3136 -- 'QuantLib.Instrument.Energy' so both leaves inherit them for free, mirroring
3137 -- 'GenFixedVsFloatingSwap's fairRate\/fixedLeg*\/floatingLeg* getters.
3138 data CEnergySwap'
3139 type GenEnergySwap s = GenEnergyCommodity (AnyOf CEnergySwap' s)
3140 type CEnergySwap = ForeignPtr CEnergySwap'
3141 type EnergySwap = GenEnergySwap CEnergySwap
3142 foreign import ccall unsafe "ql.h &qlFreeEnergySwap" qlFreeEnergySwap :: FinalizerPtr CEnergySwap'
3143 instance Finalizable CEnergySwap' where finalize = qlFreeEnergySwap
3144 foreign import ccall "ql.h qlEnergySwapAsEnergyCommodity" qlEnergySwapAsEnergyCommodity :: Ptr CEnergySwap' -> IO (Ptr CEnergyCommodity')
3145 instance Upcastable CEnergySwap' where {type Base CEnergySwap' = CEnergyCommodity'; upcast = qlEnergySwapAsEnergyCommodity}
3146 newGenEnergySwap :: GenForeignPtr s CEnergySwap' -> IO (GenEnergySwap s)
3147 newGenEnergySwap = pure . GenInstrument . newAnyOf . newAnyOf . newAnyOf
3148 withEnergySwap :: GenEnergySwap s -> (Ptr CEnergySwap' -> IO b) -> IO b
3149 withEnergySwap = withGenForeignPtr . peel . peel . peel . getInstrument
3150
3151 data CEnergyVanillaSwap'
3152 type CEnergyVanillaSwap = ForeignPtr CEnergyVanillaSwap'
3153 type EnergyVanillaSwap = GenEnergySwap CEnergyVanillaSwap
3154 foreign import ccall unsafe "ql.h &qlFreeEnergyVanillaSwap" qlFreeEnergyVanillaSwap :: FinalizerPtr CEnergyVanillaSwap'
3155 instance Finalizable CEnergyVanillaSwap' where finalize = qlFreeEnergyVanillaSwap
3156 foreign import ccall "ql.h qlEnergyVanillaSwapAsEnergySwap" qlEnergyVanillaSwapAsEnergySwap :: Ptr CEnergyVanillaSwap' -> IO (Ptr CEnergySwap')
3157 instance Upcastable CEnergyVanillaSwap' where {type Base CEnergyVanillaSwap' = CEnergySwap'; upcast = qlEnergyVanillaSwapAsEnergySwap}
3158 peekEnergyVanillaSwap :: Ptr CEnergyVanillaSwap' -> IO EnergyVanillaSwap
3159 peekEnergyVanillaSwap = newGenForeignPtr >=> newGenEnergySwap
3160 withEnergyVanillaSwap :: EnergyVanillaSwap -> (Ptr CEnergyVanillaSwap' -> IO b) -> IO b
3161 withEnergyVanillaSwap = withForeignPtr . ptr . peel . peel . peel . getInstrument
3162
3163 data CEnergyBasisSwap'
3164 type CEnergyBasisSwap = ForeignPtr CEnergyBasisSwap'
3165 type EnergyBasisSwap = GenEnergySwap CEnergyBasisSwap
3166 foreign import ccall unsafe "ql.h &qlFreeEnergyBasisSwap" qlFreeEnergyBasisSwap :: FinalizerPtr CEnergyBasisSwap'
3167 instance Finalizable CEnergyBasisSwap' where finalize = qlFreeEnergyBasisSwap
3168 foreign import ccall "ql.h qlEnergyBasisSwapAsEnergySwap" qlEnergyBasisSwapAsEnergySwap :: Ptr CEnergyBasisSwap' -> IO (Ptr CEnergySwap')
3169 instance Upcastable CEnergyBasisSwap' where {type Base CEnergyBasisSwap' = CEnergySwap'; upcast = qlEnergyBasisSwapAsEnergySwap}
3170 peekEnergyBasisSwap :: Ptr CEnergyBasisSwap' -> IO EnergyBasisSwap
3171 peekEnergyBasisSwap = newGenForeignPtr >=> newGenEnergySwap
3172 withEnergyBasisSwap :: EnergyBasisSwap -> (Ptr CEnergyBasisSwap' -> IO b) -> IO b
3173 withEnergyBasisSwap = withForeignPtr . ptr . peel . peel . peel . getInstrument
3174
3175 -- |'CommodityCashFlow': a standalone 'CashFlow' subclass, following the same
3176 -- ZeroInflationCashFlow\/CPICashFlow\/EquityCashFlow precedent (no polymorphic @CashFlow@ family is
3177 -- modelled here -- see those types in 'QuantLib.CashFlow' -- each concrete cash flow class is its
3178 -- own standalone foreign-pointer type instead).
3179 data CCommodityCashFlow
3180 newtype CommodityCashFlow = CommodityCashFlow {getCCommodityCashFlow :: Standalone CCommodityCashFlow}
3181 foreign import ccall unsafe "ql.h &qlFreeCommodityCashFlow" qlFreeCommodityCashFlow :: FinalizerPtr CCommodityCashFlow
3182 instance Finalizable CCommodityCashFlow where finalize = qlFreeCommodityCashFlow
3183 peekCommodityCashFlow :: Ptr CCommodityCashFlow -> IO CommodityCashFlow
3184 peekCommodityCashFlow = CommodityCashFlow <.> peekStandalone
3185 withCommodityCashFlow :: CommodityCashFlow -> (Ptr CCommodityCashFlow -> IO b) -> IO b
3186 withCommodityCashFlow = withStandalone . getCCommodityCashFlow
3187 -- |An array of freshly-constructed 'CommodityCashFlow's -- 'EnergySwap.paymentCashFlows()''s
3188 -- @map<Date, shared_ptr<CommodityCashFlow>>@, read as a plain list (each element's own
3189 -- 'QuantLib.Instrument.Energy.commodityCashFlowDate' already carries the map key, so it isn't
3190 -- duplicated as a separate tuple field).
3191 peekCommodityCashFlowArray :: Ptr CUInt -> Ptr (Ptr (Ptr CCommodityCashFlow)) -> IO [CommodityCashFlow]
3192 peekCommodityCashFlowArray = peekPtrArray peekCommodityCashFlow
3193
3194 withInstrumentArray :: [GenInstrument i] -> ((CUInt, Ptr (Ptr CInstrument')) -> IO b) -> IO b
3195 withInstrumentArray = withGenArray withInstrument
3196
3197 -- vim: set ff=unix ts=8 sts=2 sw=2 et: