never executed always true always false
1 -- GENERATED by C->Haskell Compiler, version 0.28.8 Switcheroo, 25 November 2017 (Haskell)
2 -- Edit the ORIGNAL .chs file instead!
3
4
5 {-# LANGUAGE TemplateHaskell, StandaloneDeriving, PatternSynonyms #-}
6 -- suppress warnings about unused Extra_ constructors
7 {-# OPTIONS_GHC -Wno-unused-top-binds #-}
8 module QuantLib.Index.InterestRate
9 (
10 InterestRateIndex
11 , BMAIndex
12 , OvernightIborIndex
13 , IborIndex
14 , SwapIndex
15 , OvernightIndexedSwapIndex
16 , GenInterestRateIndex
17 , GenIborIndex
18 , GenSwapIndex
19
20 , bmaIndex
21
22 , fixingSchedule
23 , forecastFixing
24 , currency
25 , dayCounter
26 , fixingDays
27 , tenor
28
29 , asInterestRateIndex
30 , asIborIndex
31 , asSwapIndex
32
33 , OvernightIborIndexType(..)
34 , overnightIborIndex
35
36 , LiborSwapIndexType(..)
37 , liborSwapIndex
38
39 , overnightIndexedSwapIndex
40 , swapIndex
41 , swapIndex'
42
43 -- The bundled names are the fixed-tenor shortcut pattern synonyms defined below;
44 -- @Euribor3M@ and @Euribor (3, Months)@ are the same value, usable interchangeably
45 -- in expressions and in patterns.
46 , IborConstructor(.., Bbsw1M, Bbsw2M, Bbsw3M, Bbsw4M, Bbsw5M, Bbsw6M
47 , BiborSW, Bibor1M, Bibor2M, Bibor3M, Bibor6M, Bibor9M, Bibor1Y
48 , Bkbm1M, Bkbm2M, Bkbm3M, Bkbm4M, Bkbm5M, Bkbm6M
49 , EuriborSW, Euribor2W, Euribor3W
50 , Euribor1M, Euribor2M, Euribor3M, Euribor4M, Euribor5M, Euribor6M
51 , Euribor7M, Euribor8M, Euribor9M, Euribor10M, Euribor11M, Euribor1Y
52 , Euribor365_SW, Euribor365_2W, Euribor365_3W
53 , Euribor365_1M, Euribor365_2M, Euribor365_3M, Euribor365_4M
54 , Euribor365_5M, Euribor365_6M, Euribor365_7M, Euribor365_8M
55 , Euribor365_9M, Euribor365_10M, Euribor365_11M, Euribor365_1Y
56 , EurLiborSW, EurLibor2W
57 , EurLibor1M, EurLibor2M, EurLibor3M, EurLibor4M, EurLibor5M, EurLibor6M
58 , EurLibor7M, EurLibor8M, EurLibor9M, EurLibor10M, EurLibor11M, EurLibor1Y)
59 , iborIndex
60 , overnightIndex
61 , businessDayConvention
62 , endOfMonth
63
64 , underlyingSwap
65 , underlyingOIS
66
67 , historicalRatesAnalysis
68 ) where
69 import qualified Foreign.C.String as C2HSImp
70 import qualified Foreign.C.Types as C2HSImp
71 import qualified Foreign.ForeignPtr as C2HSImp
72 import qualified Foreign.Marshal.Utils as C2HSImp
73 import qualified Foreign.Ptr as C2HSImp
74 import qualified System.IO.Unsafe as C2HSImp
75
76
77 import QuantLib.Internal
78 import QuantLib.Internal.Syntax
79 import QuantLib.Internal.Common
80 import QuantLib.Internal.Type
81 import QuantLib.Index (historicalIndexAnalysis)
82 -- Plain (non-c2hs) import: QuantLib.CashFlow is later in exposed-modules than
83 -- this file, so a {#import#} here would need its .chi before it exists.
84 -- overnightIndexedSwapIndex below marshals RateAveragingType as a plain Int
85 -- via fromEnum instead, per CLAUDE.md's cross-module enum-import workaround.
86 import QuantLib.CashFlow (RateAveragingType)
87 -- Only for IborConstructor's Read instance below (deriveReadInstance's materializer
88 -- table): this module already defines its own `currency`/`dayCounter` (an
89 -- InterestRateIndex's currency/day counter, unrelated), so these come in qualified to
90 -- avoid clashing with them.
91 import QuantLib.Time.Calendar (calendar)
92 import qualified QuantLib.Currency as Ccy (currency)
93 import qualified QuantLib.Time.Schedule as Sched (dayCounter)
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135 data OvernightIborIndexType = Aonia
136 | Eonia
137 | Estr
138 | FedFunds
139 | Nzocr
140 | Sofr
141 | Sonia
142 | Cdi
143 | Corra
144 | Kofr
145 | Destr
146 | Swestr
147 | Shir
148 | Tonar
149 | Saron
150 | Zaronia
151 deriving (Show,Eq,Read)
152 instance Enum OvernightIborIndexType where
153 succ Aonia = Eonia
154 succ Eonia = Estr
155 succ Estr = FedFunds
156 succ FedFunds = Nzocr
157 succ Nzocr = Sofr
158 succ Sofr = Sonia
159 succ Sonia = Cdi
160 succ Cdi = Corra
161 succ Corra = Kofr
162 succ Kofr = Destr
163 succ Destr = Swestr
164 succ Swestr = Shir
165 succ Shir = Tonar
166 succ Tonar = Saron
167 succ Saron = Zaronia
168 succ Zaronia = error "OvernightIborIndexType.succ: Zaronia has no successor"
169
170 pred Eonia = Aonia
171 pred Estr = Eonia
172 pred FedFunds = Estr
173 pred Nzocr = FedFunds
174 pred Sofr = Nzocr
175 pred Sonia = Sofr
176 pred Cdi = Sonia
177 pred Corra = Cdi
178 pred Kofr = Corra
179 pred Destr = Kofr
180 pred Swestr = Destr
181 pred Shir = Swestr
182 pred Tonar = Shir
183 pred Saron = Tonar
184 pred Zaronia = Saron
185 pred Aonia = error "OvernightIborIndexType.pred: Aonia has no predecessor"
186
187 enumFromTo from to = go from
188 where
189 end = fromEnum to
190 go v = case compare (fromEnum v) end of
191 LT -> v : go (succ v)
192 EQ -> [v]
193 GT -> []
194
195 enumFrom from = enumFromTo from Zaronia
196
197 fromEnum Aonia = 0
198 fromEnum Eonia = 1
199 fromEnum Estr = 2
200 fromEnum FedFunds = 3
201 fromEnum Nzocr = 4
202 fromEnum Sofr = 5
203 fromEnum Sonia = 6
204 fromEnum Cdi = 7
205 fromEnum Corra = 8
206 fromEnum Kofr = 9
207 fromEnum Destr = 10
208 fromEnum Swestr = 11
209 fromEnum Shir = 12
210 fromEnum Tonar = 13
211 fromEnum Saron = 14
212 fromEnum Zaronia = 15
213
214 toEnum 0 = Aonia
215 toEnum 1 = Eonia
216 toEnum 2 = Estr
217 toEnum 3 = FedFunds
218 toEnum 4 = Nzocr
219 toEnum 5 = Sofr
220 toEnum 6 = Sonia
221 toEnum 7 = Cdi
222 toEnum 8 = Corra
223 toEnum 9 = Kofr
224 toEnum 10 = Destr
225 toEnum 11 = Swestr
226 toEnum 12 = Shir
227 toEnum 13 = Tonar
228 toEnum 14 = Saron
229 toEnum 15 = Zaronia
230 toEnum unmatched = error ("OvernightIborIndexType.toEnum: Cannot match " ++ show unmatched)
231
232
233 data LiborSwapIndexType = ChfLiborSwapIsdaFix
234 | EurLiborSwapIfrFix
235 | EurLiborSwapIsdaFixA
236 | EurLiborSwapIsdaFixB
237 | EuriborSwapIfrFix
238 | EuriborSwapIsdaFixA
239 | EuriborSwapIsdaFixB
240 | GbpLiborSwapIsdaFix
241 | JpyLiborSwapIsdaFixAm
242 | JpyLiborSwapIsdaFixPm
243 | UsdLiborSwapIsdaFixAm
244 | UsdLiborSwapIsdaFixPm
245 deriving (Show,Eq,Read)
246 instance Enum LiborSwapIndexType where
247 succ ChfLiborSwapIsdaFix = EurLiborSwapIfrFix
248 succ EurLiborSwapIfrFix = EurLiborSwapIsdaFixA
249 succ EurLiborSwapIsdaFixA = EurLiborSwapIsdaFixB
250 succ EurLiborSwapIsdaFixB = EuriborSwapIfrFix
251 succ EuriborSwapIfrFix = EuriborSwapIsdaFixA
252 succ EuriborSwapIsdaFixA = EuriborSwapIsdaFixB
253 succ EuriborSwapIsdaFixB = GbpLiborSwapIsdaFix
254 succ GbpLiborSwapIsdaFix = JpyLiborSwapIsdaFixAm
255 succ JpyLiborSwapIsdaFixAm = JpyLiborSwapIsdaFixPm
256 succ JpyLiborSwapIsdaFixPm = UsdLiborSwapIsdaFixAm
257 succ UsdLiborSwapIsdaFixAm = UsdLiborSwapIsdaFixPm
258 succ UsdLiborSwapIsdaFixPm = error "LiborSwapIndexType.succ: UsdLiborSwapIsdaFixPm has no successor"
259
260 pred EurLiborSwapIfrFix = ChfLiborSwapIsdaFix
261 pred EurLiborSwapIsdaFixA = EurLiborSwapIfrFix
262 pred EurLiborSwapIsdaFixB = EurLiborSwapIsdaFixA
263 pred EuriborSwapIfrFix = EurLiborSwapIsdaFixB
264 pred EuriborSwapIsdaFixA = EuriborSwapIfrFix
265 pred EuriborSwapIsdaFixB = EuriborSwapIsdaFixA
266 pred GbpLiborSwapIsdaFix = EuriborSwapIsdaFixB
267 pred JpyLiborSwapIsdaFixAm = GbpLiborSwapIsdaFix
268 pred JpyLiborSwapIsdaFixPm = JpyLiborSwapIsdaFixAm
269 pred UsdLiborSwapIsdaFixAm = JpyLiborSwapIsdaFixPm
270 pred UsdLiborSwapIsdaFixPm = UsdLiborSwapIsdaFixAm
271 pred ChfLiborSwapIsdaFix = error "LiborSwapIndexType.pred: ChfLiborSwapIsdaFix has no predecessor"
272
273 enumFromTo from to = go from
274 where
275 end = fromEnum to
276 go v = case compare (fromEnum v) end of
277 LT -> v : go (succ v)
278 EQ -> [v]
279 GT -> []
280
281 enumFrom from = enumFromTo from UsdLiborSwapIsdaFixPm
282
283 fromEnum ChfLiborSwapIsdaFix = 0
284 fromEnum EurLiborSwapIfrFix = 1
285 fromEnum EurLiborSwapIsdaFixA = 2
286 fromEnum EurLiborSwapIsdaFixB = 3
287 fromEnum EuriborSwapIfrFix = 4
288 fromEnum EuriborSwapIsdaFixA = 5
289 fromEnum EuriborSwapIsdaFixB = 6
290 fromEnum GbpLiborSwapIsdaFix = 7
291 fromEnum JpyLiborSwapIsdaFixAm = 8
292 fromEnum JpyLiborSwapIsdaFixPm = 9
293 fromEnum UsdLiborSwapIsdaFixAm = 10
294 fromEnum UsdLiborSwapIsdaFixPm = 11
295
296 toEnum 0 = ChfLiborSwapIsdaFix
297 toEnum 1 = EurLiborSwapIfrFix
298 toEnum 2 = EurLiborSwapIsdaFixA
299 toEnum 3 = EurLiborSwapIsdaFixB
300 toEnum 4 = EuriborSwapIfrFix
301 toEnum 5 = EuriborSwapIsdaFixA
302 toEnum 6 = EuriborSwapIsdaFixB
303 toEnum 7 = GbpLiborSwapIsdaFix
304 toEnum 8 = JpyLiborSwapIsdaFixAm
305 toEnum 9 = JpyLiborSwapIsdaFixPm
306 toEnum 10 = UsdLiborSwapIsdaFixAm
307 toEnum 11 = UsdLiborSwapIsdaFixPm
308 toEnum unmatched = error ("LiborSwapIndexType.toEnum: Cannot match " ++ show unmatched)
309
310
311 data IborIndexType = Ibor__Bbsw
312 | Ibor__Bibor
313 | Ibor__Bkbm
314 | Ibor__Cdor
315 | Ibor__EurLibor
316 | Ibor__AudLibor
317 | Ibor__CadLibor
318 | Ibor__ChfLibor
319 | Ibor__DkkLibor
320 | Ibor__GbpLibor
321 | Ibor__JpyLibor
322 | Ibor__NzdLibor
323 | Ibor__SekLibor
324 | Ibor__UsdLibor
325 | Ibor__Euribor
326 | Ibor__Euribor365
327 | Ibor__Jibar
328 | Ibor__Mosprime
329 | Ibor__Pribor
330 | Ibor__Robor
331 | Ibor__Shibor
332 | Ibor__THBFIX
333 | Ibor__TRLibor
334 | Ibor__Tibor
335 | Ibor__Wibor
336 | Ibor__Zibor
337 | Ibor__Nibor
338 | Ibor__IborIndexTypeLast
339 deriving (Show,Eq,Read)
340 instance Enum IborIndexType where
341 succ Ibor__Bbsw = Ibor__Bibor
342 succ Ibor__Bibor = Ibor__Bkbm
343 succ Ibor__Bkbm = Ibor__Cdor
344 succ Ibor__Cdor = Ibor__EurLibor
345 succ Ibor__EurLibor = Ibor__AudLibor
346 succ Ibor__AudLibor = Ibor__CadLibor
347 succ Ibor__CadLibor = Ibor__ChfLibor
348 succ Ibor__ChfLibor = Ibor__DkkLibor
349 succ Ibor__DkkLibor = Ibor__GbpLibor
350 succ Ibor__GbpLibor = Ibor__JpyLibor
351 succ Ibor__JpyLibor = Ibor__NzdLibor
352 succ Ibor__NzdLibor = Ibor__SekLibor
353 succ Ibor__SekLibor = Ibor__UsdLibor
354 succ Ibor__UsdLibor = Ibor__Euribor
355 succ Ibor__Euribor = Ibor__Euribor365
356 succ Ibor__Euribor365 = Ibor__Jibar
357 succ Ibor__Jibar = Ibor__Mosprime
358 succ Ibor__Mosprime = Ibor__Pribor
359 succ Ibor__Pribor = Ibor__Robor
360 succ Ibor__Robor = Ibor__Shibor
361 succ Ibor__Shibor = Ibor__THBFIX
362 succ Ibor__THBFIX = Ibor__TRLibor
363 succ Ibor__TRLibor = Ibor__Tibor
364 succ Ibor__Tibor = Ibor__Wibor
365 succ Ibor__Wibor = Ibor__Zibor
366 succ Ibor__Zibor = Ibor__Nibor
367 succ Ibor__Nibor = Ibor__IborIndexTypeLast
368 succ Ibor__IborIndexTypeLast = error "IborIndexType.succ: Ibor__IborIndexTypeLast has no successor"
369
370 pred Ibor__Bibor = Ibor__Bbsw
371 pred Ibor__Bkbm = Ibor__Bibor
372 pred Ibor__Cdor = Ibor__Bkbm
373 pred Ibor__EurLibor = Ibor__Cdor
374 pred Ibor__AudLibor = Ibor__EurLibor
375 pred Ibor__CadLibor = Ibor__AudLibor
376 pred Ibor__ChfLibor = Ibor__CadLibor
377 pred Ibor__DkkLibor = Ibor__ChfLibor
378 pred Ibor__GbpLibor = Ibor__DkkLibor
379 pred Ibor__JpyLibor = Ibor__GbpLibor
380 pred Ibor__NzdLibor = Ibor__JpyLibor
381 pred Ibor__SekLibor = Ibor__NzdLibor
382 pred Ibor__UsdLibor = Ibor__SekLibor
383 pred Ibor__Euribor = Ibor__UsdLibor
384 pred Ibor__Euribor365 = Ibor__Euribor
385 pred Ibor__Jibar = Ibor__Euribor365
386 pred Ibor__Mosprime = Ibor__Jibar
387 pred Ibor__Pribor = Ibor__Mosprime
388 pred Ibor__Robor = Ibor__Pribor
389 pred Ibor__Shibor = Ibor__Robor
390 pred Ibor__THBFIX = Ibor__Shibor
391 pred Ibor__TRLibor = Ibor__THBFIX
392 pred Ibor__Tibor = Ibor__TRLibor
393 pred Ibor__Wibor = Ibor__Tibor
394 pred Ibor__Zibor = Ibor__Wibor
395 pred Ibor__Nibor = Ibor__Zibor
396 pred Ibor__IborIndexTypeLast = Ibor__Nibor
397 pred Ibor__Bbsw = error "IborIndexType.pred: Ibor__Bbsw has no predecessor"
398
399 enumFromTo from to = go from
400 where
401 end = fromEnum to
402 go v = case compare (fromEnum v) end of
403 LT -> v : go (succ v)
404 EQ -> [v]
405 GT -> []
406
407 enumFrom from = enumFromTo from Ibor__IborIndexTypeLast
408
409 fromEnum Ibor__Bbsw = 0
410 fromEnum Ibor__Bibor = 1
411 fromEnum Ibor__Bkbm = 2
412 fromEnum Ibor__Cdor = 3
413 fromEnum Ibor__EurLibor = 4
414 fromEnum Ibor__AudLibor = 5
415 fromEnum Ibor__CadLibor = 6
416 fromEnum Ibor__ChfLibor = 7
417 fromEnum Ibor__DkkLibor = 8
418 fromEnum Ibor__GbpLibor = 9
419 fromEnum Ibor__JpyLibor = 10
420 fromEnum Ibor__NzdLibor = 11
421 fromEnum Ibor__SekLibor = 12
422 fromEnum Ibor__UsdLibor = 13
423 fromEnum Ibor__Euribor = 14
424 fromEnum Ibor__Euribor365 = 15
425 fromEnum Ibor__Jibar = 16
426 fromEnum Ibor__Mosprime = 17
427 fromEnum Ibor__Pribor = 18
428 fromEnum Ibor__Robor = 19
429 fromEnum Ibor__Shibor = 20
430 fromEnum Ibor__THBFIX = 21
431 fromEnum Ibor__TRLibor = 22
432 fromEnum Ibor__Tibor = 23
433 fromEnum Ibor__Wibor = 24
434 fromEnum Ibor__Zibor = 25
435 fromEnum Ibor__Nibor = 26
436 fromEnum Ibor__IborIndexTypeLast = 27
437
438 toEnum 0 = Ibor__Bbsw
439 toEnum 1 = Ibor__Bibor
440 toEnum 2 = Ibor__Bkbm
441 toEnum 3 = Ibor__Cdor
442 toEnum 4 = Ibor__EurLibor
443 toEnum 5 = Ibor__AudLibor
444 toEnum 6 = Ibor__CadLibor
445 toEnum 7 = Ibor__ChfLibor
446 toEnum 8 = Ibor__DkkLibor
447 toEnum 9 = Ibor__GbpLibor
448 toEnum 10 = Ibor__JpyLibor
449 toEnum 11 = Ibor__NzdLibor
450 toEnum 12 = Ibor__SekLibor
451 toEnum 13 = Ibor__UsdLibor
452 toEnum 14 = Ibor__Euribor
453 toEnum 15 = Ibor__Euribor365
454 toEnum 16 = Ibor__Jibar
455 toEnum 17 = Ibor__Mosprime
456 toEnum 18 = Ibor__Pribor
457 toEnum 19 = Ibor__Robor
458 toEnum 20 = Ibor__Shibor
459 toEnum 21 = Ibor__THBFIX
460 toEnum 22 = Ibor__TRLibor
461 toEnum 23 = Ibor__Tibor
462 toEnum 24 = Ibor__Wibor
463 toEnum 25 = Ibor__Zibor
464 toEnum 26 = Ibor__Nibor
465 toEnum 27 = Ibor__IborIndexTypeLast
466 toEnum unmatched = error ("IborIndexType.toEnum: Cannot match " ++ show unmatched)
467
468
469 data IborDailyTenorIndexType = Ibor__EurDailyTenorLibor
470 | Ibor__ChfDailyTenorLibor
471 | Ibor__GbpDailyTenorLibor
472 | Ibor__JpyDailyTenorLibor
473 | Ibor__UsdDailyTenorLibor
474 | Ibor__IborDailyTenorIndexTypeLast
475 deriving (Show,Eq,Read)
476 instance Enum IborDailyTenorIndexType where
477 succ Ibor__EurDailyTenorLibor = Ibor__ChfDailyTenorLibor
478 succ Ibor__ChfDailyTenorLibor = Ibor__GbpDailyTenorLibor
479 succ Ibor__GbpDailyTenorLibor = Ibor__JpyDailyTenorLibor
480 succ Ibor__JpyDailyTenorLibor = Ibor__UsdDailyTenorLibor
481 succ Ibor__UsdDailyTenorLibor = Ibor__IborDailyTenorIndexTypeLast
482 succ Ibor__IborDailyTenorIndexTypeLast = error "IborDailyTenorIndexType.succ: Ibor__IborDailyTenorIndexTypeLast has no successor"
483
484 pred Ibor__ChfDailyTenorLibor = Ibor__EurDailyTenorLibor
485 pred Ibor__GbpDailyTenorLibor = Ibor__ChfDailyTenorLibor
486 pred Ibor__JpyDailyTenorLibor = Ibor__GbpDailyTenorLibor
487 pred Ibor__UsdDailyTenorLibor = Ibor__JpyDailyTenorLibor
488 pred Ibor__IborDailyTenorIndexTypeLast = Ibor__UsdDailyTenorLibor
489 pred Ibor__EurDailyTenorLibor = error "IborDailyTenorIndexType.pred: Ibor__EurDailyTenorLibor has no predecessor"
490
491 enumFromTo from to = go from
492 where
493 end = fromEnum to
494 go v = case compare (fromEnum v) end of
495 LT -> v : go (succ v)
496 EQ -> [v]
497 GT -> []
498
499 enumFrom from = enumFromTo from Ibor__IborDailyTenorIndexTypeLast
500
501 fromEnum Ibor__EurDailyTenorLibor = 0
502 fromEnum Ibor__ChfDailyTenorLibor = 1
503 fromEnum Ibor__GbpDailyTenorLibor = 2
504 fromEnum Ibor__JpyDailyTenorLibor = 3
505 fromEnum Ibor__UsdDailyTenorLibor = 4
506 fromEnum Ibor__IborDailyTenorIndexTypeLast = 5
507
508 toEnum 0 = Ibor__EurDailyTenorLibor
509 toEnum 1 = Ibor__ChfDailyTenorLibor
510 toEnum 2 = Ibor__GbpDailyTenorLibor
511 toEnum 3 = Ibor__JpyDailyTenorLibor
512 toEnum 4 = Ibor__UsdDailyTenorLibor
513 toEnum 5 = Ibor__IborDailyTenorIndexTypeLast
514 toEnum unmatched = error ("IborDailyTenorIndexType.toEnum: Cannot match " ++ show unmatched)
515
516
517 data IborONIndexType = Ibor__CadLiborON
518 | Ibor__EurLiborON
519 | Ibor__GbpLiborON
520 | Ibor__UsdLiborON
521 deriving (Show,Eq,Read)
522 instance Enum IborONIndexType where
523 succ Ibor__CadLiborON = Ibor__EurLiborON
524 succ Ibor__EurLiborON = Ibor__GbpLiborON
525 succ Ibor__GbpLiborON = Ibor__UsdLiborON
526 succ Ibor__UsdLiborON = error "IborONIndexType.succ: Ibor__UsdLiborON has no successor"
527
528 pred Ibor__EurLiborON = Ibor__CadLiborON
529 pred Ibor__GbpLiborON = Ibor__EurLiborON
530 pred Ibor__UsdLiborON = Ibor__GbpLiborON
531 pred Ibor__CadLiborON = error "IborONIndexType.pred: Ibor__CadLiborON has no predecessor"
532
533 enumFromTo from to = go from
534 where
535 end = fromEnum to
536 go v = case compare (fromEnum v) end of
537 LT -> v : go (succ v)
538 EQ -> [v]
539 GT -> []
540
541 enumFrom from = enumFromTo from Ibor__UsdLiborON
542
543 fromEnum Ibor__CadLiborON = 0
544 fromEnum Ibor__EurLiborON = 1
545 fromEnum Ibor__GbpLiborON = 2
546 fromEnum Ibor__UsdLiborON = 3
547
548 toEnum 0 = Ibor__CadLiborON
549 toEnum 1 = Ibor__EurLiborON
550 toEnum 2 = Ibor__GbpLiborON
551 toEnum 3 = Ibor__UsdLiborON
552 toEnum unmatched = error ("IborONIndexType.toEnum: Cannot match " ++ show unmatched)
553
554
555
556 -- the fully generic, non-enum-ordinal IborConstructor cases, merged into IborConstructor by
557 -- deriveIborConstructor below alongside the plain-tenor/daily-tenor/overnight cases generated
558 -- straight from IborIndexType/IborDailyTenorIndexType/IborONIndexType
559 data IborExtra =
560 Extra__Ibor String -- ^familyName
561 (Word, TimeUnit) -- ^tenor
562 Word -- ^settlementDays
563 Currency
564 Calendar -- ^fixingCalendar
565 BusinessDayConvention
566 Bool -- ^endOfMonth
567 DayCounter
568 | Extra__Libor String (Word, TimeUnit) Word -- ^settlementDays
569 Currency Calendar DayCounter
570 | Extra__DailyTenorLibor String Word -- ^settlementDays
571 Currency Calendar DayCounter
572 | Extra__CustomIbor String -- ^familyName
573 (Word, TimeUnit) -- ^tenor
574 Word -- ^settlementDays
575 Currency
576 Calendar -- ^fixingCalendar
577 Calendar -- ^valueCalendar
578 Calendar -- ^maturityCalendar
579 BusinessDayConvention
580 Bool -- ^endOfMonth
581 DayCounter
582
583 $(deriveIborConstructor IborConstructorSpec
584 { iborTypeName = "IborConstructor"
585 , iborOrdinalFn = "iborIndexOrdinal"
586 , iborTenorFn = "iborIndexTenor"
587 , iborTenorEnum = ''IborIndexType
588 , iborDailyTenorEnum = ''IborDailyTenorIndexType
589 , iborOvernightEnum = ''IborONIndexType
590 , iborExtraType = ''IborExtra
591 })
592
593 deriving instance Show IborConstructor
594 deriving instance Eq IborConstructor
595
596 -- Spliced here rather than alongside IborConstructor's declaration just above: this needs
597 -- `calendar`/`Ccy.currency`/`Sched.dayCounter`, none of which InterestRate.chs's own
598 -- declaration site could import without a cycle back through this module. See
599 -- deriveReadInstance's comment in Internal/Syntax.hs for the general shape; Schedule.chs and
600 -- Calendar.chs use the identical pattern for DayCounterConstructor/CalendarConstructor.
601 $(deriveReadInstance ''IborConstructor
602 [ ("Calendar", 'calendar)
603 , ("Currency", 'Ccy.currency)
604 , ("DayCounter", 'Sched.dayCounter)
605 ])
606
607 -- Fixed-tenor shortcuts, mirroring upstream's thin @Euribor3M@-style subclasses (whose
608 -- constructors only delegate to the parameterized one). They are bidirectional pattern
609 -- synonyms, not constructors: each is *defined* as the parameterized case it stands for,
610 -- so there is a single list to keep right and no separate dispatch clause that can drift
611 -- out of step with it -- @Euribor365_SW@ used to expand, via such a clause, to
612 -- @Euribor (365, Weeks)@: wrong family and wrong tenor both.
613 pattern Bbsw1M, Bbsw2M, Bbsw3M, Bbsw4M, Bbsw5M, Bbsw6M :: IborConstructor
614 pattern Bbsw1M = Bbsw (1, Months)
615 pattern Bbsw2M = Bbsw (2, Months)
616 pattern Bbsw3M = Bbsw (3, Months)
617 pattern Bbsw4M = Bbsw (4, Months)
618 pattern Bbsw5M = Bbsw (5, Months)
619 pattern Bbsw6M = Bbsw (6, Months)
620
621 pattern BiborSW, Bibor1M, Bibor2M, Bibor3M, Bibor6M, Bibor9M, Bibor1Y :: IborConstructor
622 pattern BiborSW = Bibor (1, Weeks)
623 pattern Bibor1M = Bibor (1, Months)
624 pattern Bibor2M = Bibor (2, Months)
625 pattern Bibor3M = Bibor (3, Months)
626 pattern Bibor6M = Bibor (6, Months)
627 pattern Bibor9M = Bibor (9, Months)
628 pattern Bibor1Y = Bibor (1, Years)
629
630 pattern Bkbm1M, Bkbm2M, Bkbm3M, Bkbm4M, Bkbm5M, Bkbm6M :: IborConstructor
631 pattern Bkbm1M = Bkbm (1, Months)
632 pattern Bkbm2M = Bkbm (2, Months)
633 pattern Bkbm3M = Bkbm (3, Months)
634 pattern Bkbm4M = Bkbm (4, Months)
635 pattern Bkbm5M = Bkbm (5, Months)
636 pattern Bkbm6M = Bkbm (6, Months)
637
638 pattern EuriborSW, Euribor2W, Euribor3W, Euribor1M, Euribor2M, Euribor3M, Euribor4M
639 , Euribor5M, Euribor6M, Euribor7M, Euribor8M, Euribor9M, Euribor10M, Euribor11M
640 , Euribor1Y :: IborConstructor
641 pattern EuriborSW = Euribor (1, Weeks)
642 pattern Euribor2W = Euribor (2, Weeks)
643 pattern Euribor3W = Euribor (3, Weeks)
644 pattern Euribor1M = Euribor (1, Months)
645 pattern Euribor2M = Euribor (2, Months)
646 pattern Euribor3M = Euribor (3, Months)
647 pattern Euribor4M = Euribor (4, Months)
648 pattern Euribor5M = Euribor (5, Months)
649 pattern Euribor6M = Euribor (6, Months)
650 pattern Euribor7M = Euribor (7, Months)
651 pattern Euribor8M = Euribor (8, Months)
652 pattern Euribor9M = Euribor (9, Months)
653 pattern Euribor10M = Euribor (10, Months)
654 pattern Euribor11M = Euribor (11, Months)
655 pattern Euribor1Y = Euribor (1, Years)
656
657 pattern Euribor365_SW, Euribor365_2W, Euribor365_3W, Euribor365_1M, Euribor365_2M
658 , Euribor365_3M, Euribor365_4M, Euribor365_5M, Euribor365_6M, Euribor365_7M
659 , Euribor365_8M, Euribor365_9M, Euribor365_10M, Euribor365_11M
660 , Euribor365_1Y :: IborConstructor
661 pattern Euribor365_SW = Euribor365 (1, Weeks)
662 pattern Euribor365_2W = Euribor365 (2, Weeks)
663 pattern Euribor365_3W = Euribor365 (3, Weeks)
664 pattern Euribor365_1M = Euribor365 (1, Months)
665 pattern Euribor365_2M = Euribor365 (2, Months)
666 pattern Euribor365_3M = Euribor365 (3, Months)
667 pattern Euribor365_4M = Euribor365 (4, Months)
668 pattern Euribor365_5M = Euribor365 (5, Months)
669 pattern Euribor365_6M = Euribor365 (6, Months)
670 pattern Euribor365_7M = Euribor365 (7, Months)
671 pattern Euribor365_8M = Euribor365 (8, Months)
672 pattern Euribor365_9M = Euribor365 (9, Months)
673 pattern Euribor365_10M = Euribor365 (10, Months)
674 pattern Euribor365_11M = Euribor365 (11, Months)
675 pattern Euribor365_1Y = Euribor365 (1, Years)
676
677 pattern EurLiborSW, EurLibor2W, EurLibor1M, EurLibor2M, EurLibor3M, EurLibor4M
678 , EurLibor5M, EurLibor6M, EurLibor7M, EurLibor8M, EurLibor9M, EurLibor10M
679 , EurLibor11M, EurLibor1Y :: IborConstructor
680 pattern EurLiborSW = EurLibor (1, Weeks)
681 pattern EurLibor2W = EurLibor (2, Weeks)
682 pattern EurLibor1M = EurLibor (1, Months)
683 pattern EurLibor2M = EurLibor (2, Months)
684 pattern EurLibor3M = EurLibor (3, Months)
685 pattern EurLibor4M = EurLibor (4, Months)
686 pattern EurLibor5M = EurLibor (5, Months)
687 pattern EurLibor6M = EurLibor (6, Months)
688 pattern EurLibor7M = EurLibor (7, Months)
689 pattern EurLibor8M = EurLibor (8, Months)
690 pattern EurLibor9M = EurLibor (9, Months)
691 pattern EurLibor10M = EurLibor (10, Months)
692 pattern EurLibor11M = EurLibor (11, Months)
693 pattern EurLibor1Y = EurLibor (1, Years)
694
695 iborIndex :: IborConstructor -> Maybe (GenYieldTermStructure y) -> IO IborIndex
696 iborIndex (Ibor n p s cr ca bd b dc) ts = qlIborIndex n p s cr ca bd b dc ts
697 iborIndex (Libor n p s cr ca dc) ts = qlLibor n p s cr ca dc ts
698 iborIndex (DailyTenorLibor n c cr ca dc) ts = qlDailyTenorLibor n c cr ca dc ts
699 iborIndex (CustomIbor n p s cr fc vc mc bd b dc) ts = qlCustomIborIndex n p s cr fc vc mc bd b dc ts
700 iborIndex c ts = qlCreateIbor (iborIndexOrdinal c) (iborIndexTenor c) ts
701
702 -- |Creates the BMA (Bond Market Association) short-term tax-exempt index, optionally linked to a forwarding curve.
703 bmaIndex :: (Maybe (GenYieldTermStructure y)) -> IO ((BMAIndex))
704 bmaIndex a1 =
705 withMaybeYieldTermStructure a1 $ \a1' ->
706 preErrorCheck $ \a2' ->
707 bmaIndex'_ a1' a2' >>= \res ->
708 peekBMAIndex res >>= \res' ->
709 errorCheck a2'>>
710 return (res')
711
712
713
714 -- |This method returns a schedule of fixing dates between start and end.
715 fixingSchedule :: (BMAIndex) -> (Day) -> (Day) -> IO ((Schedule))
716 fixingSchedule a1 a2 a3 =
717 withBMAIndex a1 $ \a1' ->
718 withDay a2 $ \a2' ->
719 withDay a3 $ \a3' ->
720 preErrorCheck $ \a4' ->
721 fixingSchedule'_ a1' a2' a3' a4' >>= \res ->
722 peekSchedule res >>= \res' ->
723 errorCheck a4'>>
724 return (res')
725
726
727
728 -- |It can be overridden to implement particular conventions.
729 forecastFixing :: (GenInterestRateIndex ridx) -> (Day) -> IO ((Double))
730 forecastFixing a1 a2 =
731 withInterestRateIndex a1 $ \a1' ->
732 withDay a2 $ \a2' ->
733 preErrorCheck $ \a3' ->
734 forecastFixing'_ a1' a2' a3' >>= \res ->
735 let {res' = realToFrac res} in
736 errorCheck a3'>>
737 return (res')
738
739
740
741 -- |Returns the index's underlying currency.
742 currency :: (GenInterestRateIndex ridx) -> IO ((Currency))
743 currency a1 =
744 withInterestRateIndex a1 $ \a1' ->
745 preErrorCheck $ \a2' ->
746 currency'_ a1' a2' >>= \res ->
747 peekCurrency res >>= \res' ->
748 errorCheck a2'>>
749 return (res')
750
751
752
753 -- |Returns the day counter used by the index.
754 dayCounter :: (GenInterestRateIndex ridx) -> IO ((DayCounter))
755 dayCounter a1 =
756 withInterestRateIndex a1 $ \a1' ->
757 preErrorCheck $ \a2' ->
758 dayCounter'_ a1' a2' >>= \res ->
759 peekDayCounter res >>= \res' ->
760 errorCheck a2'>>
761 return (res')
762
763
764
765 -- |Returns the number of business days between a fixing date and the corresponding value date.
766 fixingDays :: (GenInterestRateIndex ridx) -> (Word)
767 fixingDays a1 =
768 C2HSImp.unsafePerformIO $
769 withInterestRateIndex a1 $ \a1' ->
770 fixingDays'_ a1' >>= \res ->
771 let {res' = fromIntegral res} in
772 return (res')
773
774
775
776 -- |Returns the index's tenor.
777 tenor :: (GenInterestRateIndex ridx) -> IO ((Word), (TimeUnit))
778 tenor a1 =
779 withInterestRateIndex a1 $ \a1' ->
780 preEnum $ \a2' ->
781 preErrorCheck $ \a3' ->
782 tenor'_ a1' a2' a3' >>= \res ->
783 let {res' = fromIntegral res} in
784 peekEnum a2'>>= \a2'' ->
785 errorCheck a3'>>
786 return (res', a2'')
787
788
789
790 -- |Creates one of the built-in overnight indexes (e.g. Sofr, Estr, Sonia), optionally linked to a forwarding curve.
791 overnightIborIndex :: (OvernightIborIndexType) -> (Maybe (GenYieldTermStructure y)) -> IO ((OvernightIborIndex))
792 overnightIborIndex a1 a2 =
793 let {a1' = (fromIntegral . fromEnum) a1} in
794 withMaybeYieldTermStructure a2 $ \a2' ->
795 preErrorCheck $ \a3' ->
796 overnightIborIndex'_ a1' a2' a3' >>= \res ->
797 peekOvernightIborIndex res >>= \res' ->
798 errorCheck a3'>>
799 return (res')
800
801
802
803 -- |Creates one of the built-in ISDA-fix swap-rate indexes for a given tenor, with separate forwarding and discounting curves.
804 liborSwapIndex :: (LiborSwapIndexType) -> ((Int,TimeUnit)) -> (Maybe (GenYieldTermStructure y1)) -- ^forwarding
805 -> (Maybe (GenYieldTermStructure y2)) -- ^discounting
806 -> IO ((SwapIndex))
807 liborSwapIndex a1 a2 a3 a4 =
808 let {a1' = (fromIntegral . fromEnum) a1} in
809 let {(a2'1, a2'2) = fromEnumQuantity a2} in
810 withMaybeYieldTermStructure a3 $ \a3' ->
811 withMaybeYieldTermStructure a4 $ \a4' ->
812 preErrorCheck $ \a5' ->
813 liborSwapIndex'_ a1' a2'1 a2'2 a3' a4' a5' >>= \res ->
814 peekSwapIndex res >>= \res' ->
815 errorCheck a5'>>
816 return (res')
817
818
819
820 -- | Construct an overnight-indexed swap index.
821 -- RateAveragingType (QuantLib.CashFlow) is later in exposed-modules than this file,
822 -- so averagingMethod is marshalled as a plain Int via fromEnum in the unexported
823 -- glue binding below instead of a {#import#}'d enum type, per CLAUDE.md's
824 -- cross-module workaround. The public signature stays fully typed.
825 overnightIndexedSwapIndex :: String -> (Int, TimeUnit) -> Word -> Currency
826 -> OvernightIborIndex -> Bool -> RateAveragingType -> IO OvernightIndexedSwapIndex
827 overnightIndexedSwapIndex familyName tenr settlementDays ccy idx telescopicValueDates averagingMethod =
828 overnightIndexedSwapIndex_ familyName tenr settlementDays ccy idx telescopicValueDates (fromEnum averagingMethod)
829
830 -- |Low-level glue for 'overnightIndexedSwapIndex': constructs the swap-rate index tracking an overnight-indexed swap, taking the rate-averaging method as a plain Int.
831 overnightIndexedSwapIndex_ :: (String) -> ((Int,TimeUnit)) -> (Word) -- ^settlementDays
832 -> (Currency) -> (OvernightIborIndex) -> (Bool) -- ^telescopicValueDates
833 -> (Int) -- ^averagingMethod
834 -> IO ((OvernightIndexedSwapIndex))
835 overnightIndexedSwapIndex_ a1 a2 a3 a4 a5 a6 a7 =
836 C2HSImp.withCString a1 $ \a1' ->
837 let {(a2'1, a2'2) = fromEnumQuantity a2} in
838 let {a3' = fromIntegral a3} in
839 withCurrency a4 $ \a4' ->
840 withOvernightIborIndex a5 $ \a5' ->
841 let {a6' = C2HSImp.fromBool a6} in
842 let {a7' = fromIntegral a7} in
843 preErrorCheck $ \a8' ->
844 overnightIndexedSwapIndex_'_ a1' a2'1 a2'2 a3' a4' a5' a6' a7' a8' >>= \res ->
845 peekOvernightIndexedSwapIndex res >>= \res' ->
846 errorCheck a8'>>
847 return (res')
848
849
850
851 -- |Creates a swap-rate index whose forwarding and discounting both come from the underlying ibor index's curve.
852 swapIndex :: (String) -> ((Int,TimeUnit)) -> (Word) -- ^settlementDays
853 -> (Currency) -> (Calendar) -> ((Int,TimeUnit)) -- ^fixedLegTenor
854 -> (BusinessDayConvention) -> (DayCounter) -> (GenIborIndex ibor) -> IO ((SwapIndex))
855 swapIndex a1 a2 a3 a4 a5 a6 a7 a8 a9 =
856 C2HSImp.withCString a1 $ \a1' ->
857 let {(a2'1, a2'2) = fromEnumQuantity a2} in
858 let {a3' = fromIntegral a3} in
859 withCurrency a4 $ \a4' ->
860 withCalendar a5 $ \a5' ->
861 let {(a6'1, a6'2) = fromEnumQuantity a6} in
862 let {a7' = fromEnumC a7} in
863 withDayCounter a8 $ \a8' ->
864 withIborIndex a9 $ \a9' ->
865 preErrorCheck $ \a10' ->
866 swapIndex'_ a1' a2'1 a2'2 a3' a4' a5' a6'1 a6'2 a7' a8' a9' a10' >>= \res ->
867 peekSwapIndex res >>= \res' ->
868 errorCheck a10'>>
869 return (res')
870
871
872
873 -- |Creates a swap-rate index with a discounting curve distinct from the forwarding curve of the underlying ibor index.
874 swapIndex' :: (String) -- ^familyName
875 -> ((Int,TimeUnit)) -- ^tenor
876 -> (Word) -- ^settlementDays
877 -> (Currency) -> (Calendar) -> ((Int,TimeUnit)) -- ^fixedLegTenor
878 -> (BusinessDayConvention) -- ^fixedLegConvention
879 -> (DayCounter) -- ^fixedLegDayCounter
880 -> (GenIborIndex ibor) -> (GenYieldTermStructure y) -> IO ((SwapIndex))
881 swapIndex' a1 a2 a3 a4 a5 a6 a7 a8 a9 a10 =
882 C2HSImp.withCString a1 $ \a1' ->
883 let {(a2'1, a2'2) = fromEnumQuantity a2} in
884 let {a3' = fromIntegral a3} in
885 withCurrency a4 $ \a4' ->
886 withCalendar a5 $ \a5' ->
887 let {(a6'1, a6'2) = fromEnumQuantity a6} in
888 let {a7' = fromEnumC a7} in
889 withDayCounter a8 $ \a8' ->
890 withIborIndex a9 $ \a9' ->
891 withYieldTermStructure a10 $ \a10' ->
892 preErrorCheck $ \a11' ->
893 swapIndex''_ a1' a2'1 a2'2 a3' a4' a5' a6'1 a6'2 a7' a8' a9' a10' a11' >>= \res ->
894 peekSwapIndex res >>= \res' ->
895 errorCheck a11'>>
896 return (res')
897
898
899
900 -- |Low-level glue for 'iborIndex': constructs a generic Inter-Bank-Offered-Rate index, optionally linked to a forwarding curve.
901 qlIborIndex :: (String) -- ^familyName
902 -> ((Word,TimeUnit)) -- ^tenor
903 -> (Word) -- ^settlementDays
904 -> (Currency) -> (Calendar) -> (BusinessDayConvention) -> (Bool) -- ^endOfMonth
905 -> (DayCounter) -> (Maybe (GenYieldTermStructure y)) -> IO ((IborIndex))
906 qlIborIndex a1 a2 a3 a4 a5 a6 a7 a8 a9 =
907 C2HSImp.withCString a1 $ \a1' ->
908 let {(a2'1, a2'2) = fromEnumQuantity a2} in
909 let {a3' = fromIntegral a3} in
910 withCurrency a4 $ \a4' ->
911 withCalendar a5 $ \a5' ->
912 let {a6' = fromEnumC a6} in
913 let {a7' = C2HSImp.fromBool a7} in
914 withDayCounter a8 $ \a8' ->
915 withMaybeYieldTermStructure a9 $ \a9' ->
916 preErrorCheck $ \a10' ->
917 qlIborIndex'_ a1' a2'1 a2'2 a3' a4' a5' a6' a7' a8' a9' a10' >>= \res ->
918 peekIborIndex res >>= \res' ->
919 errorCheck a10'>>
920 return (res')
921
922
923
924 -- |Low-level glue for 'iborIndex': constructs an ICE LIBOR index (all currencies but EUR/O/N/S/N), optionally linked to a forwarding curve.
925 qlLibor :: (String) -- ^familyName
926 -> ((Word,TimeUnit)) -> (Word) -- settlementDays
927 -> (Currency) -> (Calendar) -> (DayCounter) -> (Maybe (GenYieldTermStructure y)) -> IO ((IborIndex))
928 qlLibor a1 a2 a3 a4 a5 a6 a7 =
929 C2HSImp.withCString a1 $ \a1' ->
930 let {(a2'1, a2'2) = fromEnumQuantity a2} in
931 let {a3' = fromIntegral a3} in
932 withCurrency a4 $ \a4' ->
933 withCalendar a5 $ \a5' ->
934 withDayCounter a6 $ \a6' ->
935 withMaybeYieldTermStructure a7 $ \a7' ->
936 preErrorCheck $ \a8' ->
937 qlLibor'_ a1' a2'1 a2'2 a3' a4' a5' a6' a7' a8' >>= \res ->
938 peekIborIndex res >>= \res' ->
939 errorCheck a8'>>
940 return (res')
941
942
943
944 -- |Low-level glue for 'iborIndex': constructs a one-day (O/N-S/N) ICE LIBOR index, optionally linked to a forwarding curve.
945 qlDailyTenorLibor :: (String) -- ^familyName
946 -> (Word) -- ^settlementDays
947 -> (Currency) -> (Calendar) -> (DayCounter) -> (Maybe (GenYieldTermStructure y)) -> IO ((IborIndex))
948 qlDailyTenorLibor a1 a2 a3 a4 a5 a6 =
949 C2HSImp.withCString a1 $ \a1' ->
950 let {a2' = fromIntegral a2} in
951 withCurrency a3 $ \a3' ->
952 withCalendar a4 $ \a4' ->
953 withDayCounter a5 $ \a5' ->
954 withMaybeYieldTermStructure a6 $ \a6' ->
955 preErrorCheck $ \a7' ->
956 qlDailyTenorLibor'_ a1' a2' a3' a4' a5' a6' a7' >>= \res ->
957 peekIborIndex res >>= \res' ->
958 errorCheck a7'>>
959 return (res')
960
961
962
963 -- |Low-level glue for 'iborIndex': constructs a LIBOR-like index with independently specified fixing/value/maturity calendars.
964 qlCustomIborIndex :: (String) -- ^familyName
965 -> ((Word,TimeUnit)) -- ^tenor
966 -> (Word) -- ^settlementDays
967 -> (Currency) -> (Calendar) -- ^fixingCalendar
968 -> (Calendar) -- ^valueCalendar
969 -> (Calendar) -- ^maturityCalendar
970 -> (BusinessDayConvention) -> (Bool) -- ^endOfMonth
971 -> (DayCounter) -> (Maybe (GenYieldTermStructure y)) -> IO ((IborIndex))
972 qlCustomIborIndex a1 a2 a3 a4 a5 a6 a7 a8 a9 a10 a11 =
973 C2HSImp.withCString a1 $ \a1' ->
974 let {(a2'1, a2'2) = fromEnumQuantity a2} in
975 let {a3' = fromIntegral a3} in
976 withCurrency a4 $ \a4' ->
977 withCalendar a5 $ \a5' ->
978 withCalendar a6 $ \a6' ->
979 withCalendar a7 $ \a7' ->
980 let {a8' = fromEnumC a8} in
981 let {a9' = C2HSImp.fromBool a9} in
982 withDayCounter a10 $ \a10' ->
983 withMaybeYieldTermStructure a11 $ \a11' ->
984 preErrorCheck $ \a12' ->
985 qlCustomIborIndex'_ a1' a2'1 a2'2 a3' a4' a5' a6' a7' a8' a9' a10' a11' a12' >>= \res ->
986 peekIborIndex res >>= \res' ->
987 errorCheck a12'>>
988 return (res')
989
990
991
992 -- |Low-level glue for 'iborIndex': constructs one of the built-in fixed-tenor/daily-tenor/overnight ibor indexes by ordinal, optionally linked to a forwarding curve.
993 qlCreateIbor :: (Int) -> ((Word,TimeUnit)) -> (Maybe (GenYieldTermStructure y)) -> IO ((IborIndex))
994 qlCreateIbor a1 a2 a3 =
995 let {a1' = fromIntegral a1} in
996 let {(a2'1, a2'2) = fromEnumQuantity a2} in
997 withMaybeYieldTermStructure a3 $ \a3' ->
998 preErrorCheck $ \a4' ->
999 qlCreateIbor'_ a1' a2'1 a2'2 a3' a4' >>= \res ->
1000 peekIborIndex res >>= \res' ->
1001 errorCheck a4'>>
1002 return (res')
1003
1004
1005
1006 -- |Creates a generic overnight index, optionally linked to a forwarding curve.
1007 overnightIndex :: (String) -> (Word) -- ^settlementDays
1008 -> (Currency) -> (Calendar) -> (DayCounter) -> (Maybe (GenYieldTermStructure y)) -> IO ((OvernightIborIndex))
1009 overnightIndex a1 a2 a3 a4 a5 a6 =
1010 C2HSImp.withCString a1 $ \a1' ->
1011 let {a2' = fromIntegral a2} in
1012 withCurrency a3 $ \a3' ->
1013 withCalendar a4 $ \a4' ->
1014 withDayCounter a5 $ \a5' ->
1015 withMaybeYieldTermStructure a6 $ \a6' ->
1016 preErrorCheck $ \a7' ->
1017 overnightIndex'_ a1' a2' a3' a4' a5' a6' a7' >>= \res ->
1018 peekOvernightIborIndex res >>= \res' ->
1019 errorCheck a7'>>
1020 return (res')
1021
1022
1023
1024 -- |Returns the business day convention used to adjust the index's value/maturity dates.
1025 businessDayConvention :: (GenIborIndex ibor) -> (BusinessDayConvention)
1026 businessDayConvention a1 =
1027 C2HSImp.unsafePerformIO $
1028 withIborIndex a1 $ \a1' ->
1029 businessDayConvention'_ a1' >>= \res ->
1030 let {res' = toEnumC res} in
1031 return (res')
1032
1033
1034
1035 -- |Returns whether the index's date calculations roll to the end of the month.
1036 endOfMonth :: (GenIborIndex ibor) -> (Bool)
1037 endOfMonth a1 =
1038 C2HSImp.unsafePerformIO $
1039 withIborIndex a1 $ \a1' ->
1040 endOfMonth'_ a1' >>= \res ->
1041 let {res' = C2HSImp.toBool res} in
1042 return (res')
1043
1044
1045
1046 -- |Returns the overnight-indexed swap underlying the index for a given fixing date. Relinking the index's term structure afterwards has no effect on the returned swap.
1047 underlyingOIS :: (OvernightIndexedSwapIndex) -> (Day) -> IO ((OvernightIndexedSwap))
1048 underlyingOIS a1 a2 =
1049 withOvernightIndexedSwapIndex a1 $ \a1' ->
1050 withDay a2 $ \a2' ->
1051 preErrorCheck $ \a3' ->
1052 underlyingOIS'_ a1' a2' a3' >>= \res ->
1053 peekOvernightIndexedSwap res >>= \res' ->
1054 errorCheck a3'>>
1055 return (res')
1056
1057
1058
1059 -- |Returns the vanilla swap underlying the index for a given fixing date. Relinking the index's term structure afterwards has no effect on the returned swap.
1060 underlyingSwap :: (GenSwapIndex sidx) -> (Day) -> IO ((VanillaSwap))
1061 underlyingSwap a1 a2 =
1062 withSwapIndex a1 $ \a1' ->
1063 withDay a2 $ \a2' ->
1064 preErrorCheck $ \a3' ->
1065 underlyingSwap'_ a1' a2' a3' >>= \res ->
1066 peekVanillaSwap res >>= \res' ->
1067 errorCheck a3'>>
1068 return (res')
1069
1070
1071
1072 -- |Convenience wrapper: 'historicalIndexAnalysis' specialised to interest-rate indexes.
1073 historicalRatesAnalysis :: Day -> Day -> (Int, TimeUnit) -> [GenInterestRateIndex ridx] -> IO HistoricalIndexAnalysis
1074 historicalRatesAnalysis startDate endDate step ridxs =
1075 mapM asIndex ridxs >>= historicalIndexAnalysis startDate endDate step
1076
1077 -- vim: set ff=unix ts=8 sts=2 sw=2 et:
1078
1079 foreign import ccall safe "QuantLib/Index/InterestRate.chs.h qlBMAIndex"
1080 bmaIndex'_ :: ((C2HSImp.Ptr (CYieldTermStructure')) -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO (C2HSImp.Ptr (CBMAIndex')))))
1081
1082 foreign import ccall safe "QuantLib/Index/InterestRate.chs.h qlBMAIndexFixingSchedule"
1083 fixingSchedule'_ :: ((C2HSImp.Ptr (CBMAIndex')) -> (C2HSImp.CInt -> (C2HSImp.CInt -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO (C2HSImp.Ptr (CSchedule)))))))
1084
1085 foreign import ccall safe "QuantLib/Index/InterestRate.chs.h qlInterestRateIndexForecastFixing"
1086 forecastFixing'_ :: ((C2HSImp.Ptr (CInterestRateIndex')) -> (C2HSImp.CInt -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO C2HSImp.CDouble))))
1087
1088 foreign import ccall safe "QuantLib/Index/InterestRate.chs.h qlInterestRateIndexCurrency"
1089 currency'_ :: ((C2HSImp.Ptr (CInterestRateIndex')) -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO (C2HSImp.Ptr (CCurrency)))))
1090
1091 foreign import ccall safe "QuantLib/Index/InterestRate.chs.h qlInterestRateIndexDayCounter"
1092 dayCounter'_ :: ((C2HSImp.Ptr (CInterestRateIndex')) -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO (C2HSImp.Ptr (CDayCounter)))))
1093
1094 foreign import ccall safe "QuantLib/Index/InterestRate.chs.h qlInterestRateIndexFixingDays"
1095 fixingDays'_ :: ((C2HSImp.Ptr (CInterestRateIndex')) -> (IO C2HSImp.CUInt))
1096
1097 foreign import ccall safe "QuantLib/Index/InterestRate.chs.h qlInterestRateIndexTenor"
1098 tenor'_ :: ((C2HSImp.Ptr (CInterestRateIndex')) -> ((C2HSImp.Ptr C2HSImp.CInt) -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO C2HSImp.CInt))))
1099
1100 foreign import ccall safe "QuantLib/Index/InterestRate.chs.h qlCreateONIndex"
1101 overnightIborIndex'_ :: (C2HSImp.CInt -> ((C2HSImp.Ptr (CYieldTermStructure')) -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO (C2HSImp.Ptr (COvernightIndex'))))))
1102
1103 foreign import ccall safe "QuantLib/Index/InterestRate.chs.h qlCreateLiborSwapIndex"
1104 liborSwapIndex'_ :: (C2HSImp.CInt -> (C2HSImp.CInt -> (C2HSImp.CInt -> ((C2HSImp.Ptr (CYieldTermStructure')) -> ((C2HSImp.Ptr (CYieldTermStructure')) -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO (C2HSImp.Ptr (CSwapIndex')))))))))
1105
1106 foreign import ccall safe "QuantLib/Index/InterestRate.chs.h qlOvernightIndexedSwapIndex"
1107 overnightIndexedSwapIndex_'_ :: ((C2HSImp.Ptr C2HSImp.CChar) -> (C2HSImp.CInt -> (C2HSImp.CInt -> (C2HSImp.CUInt -> ((C2HSImp.Ptr (CCurrency)) -> ((C2HSImp.Ptr (COvernightIndex')) -> (C2HSImp.CInt -> (C2HSImp.CInt -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO (C2HSImp.Ptr (COvernightIndexedSwapIndex'))))))))))))
1108
1109 foreign import ccall safe "QuantLib/Index/InterestRate.chs.h qlSwapIndex"
1110 swapIndex'_ :: ((C2HSImp.Ptr C2HSImp.CChar) -> (C2HSImp.CInt -> (C2HSImp.CInt -> (C2HSImp.CUInt -> ((C2HSImp.Ptr (CCurrency)) -> ((C2HSImp.Ptr (CCalendar)) -> (C2HSImp.CInt -> (C2HSImp.CInt -> (C2HSImp.CInt -> ((C2HSImp.Ptr (CDayCounter)) -> ((C2HSImp.Ptr (CIborIndex')) -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO (C2HSImp.Ptr (CSwapIndex')))))))))))))))
1111
1112 foreign import ccall safe "QuantLib/Index/InterestRate.chs.h qlSwapIndex1"
1113 swapIndex''_ :: ((C2HSImp.Ptr C2HSImp.CChar) -> (C2HSImp.CInt -> (C2HSImp.CInt -> (C2HSImp.CUInt -> ((C2HSImp.Ptr (CCurrency)) -> ((C2HSImp.Ptr (CCalendar)) -> (C2HSImp.CInt -> (C2HSImp.CInt -> (C2HSImp.CInt -> ((C2HSImp.Ptr (CDayCounter)) -> ((C2HSImp.Ptr (CIborIndex')) -> ((C2HSImp.Ptr (CYieldTermStructure')) -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO (C2HSImp.Ptr (CSwapIndex'))))))))))))))))
1114
1115 foreign import ccall safe "QuantLib/Index/InterestRate.chs.h qlIborIndex"
1116 qlIborIndex'_ :: ((C2HSImp.Ptr C2HSImp.CChar) -> (C2HSImp.CInt -> (C2HSImp.CInt -> (C2HSImp.CUInt -> ((C2HSImp.Ptr (CCurrency)) -> ((C2HSImp.Ptr (CCalendar)) -> (C2HSImp.CInt -> (C2HSImp.CInt -> ((C2HSImp.Ptr (CDayCounter)) -> ((C2HSImp.Ptr (CYieldTermStructure')) -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO (C2HSImp.Ptr (CIborIndex'))))))))))))))
1117
1118 foreign import ccall safe "QuantLib/Index/InterestRate.chs.h qlLibor"
1119 qlLibor'_ :: ((C2HSImp.Ptr C2HSImp.CChar) -> (C2HSImp.CInt -> (C2HSImp.CInt -> (C2HSImp.CUInt -> ((C2HSImp.Ptr (CCurrency)) -> ((C2HSImp.Ptr (CCalendar)) -> ((C2HSImp.Ptr (CDayCounter)) -> ((C2HSImp.Ptr (CYieldTermStructure')) -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO (C2HSImp.Ptr (CIborIndex'))))))))))))
1120
1121 foreign import ccall safe "QuantLib/Index/InterestRate.chs.h qlDailyTenorLibor"
1122 qlDailyTenorLibor'_ :: ((C2HSImp.Ptr C2HSImp.CChar) -> (C2HSImp.CUInt -> ((C2HSImp.Ptr (CCurrency)) -> ((C2HSImp.Ptr (CCalendar)) -> ((C2HSImp.Ptr (CDayCounter)) -> ((C2HSImp.Ptr (CYieldTermStructure')) -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO (C2HSImp.Ptr (CIborIndex'))))))))))
1123
1124 foreign import ccall safe "QuantLib/Index/InterestRate.chs.h qlCustomIborIndex"
1125 qlCustomIborIndex'_ :: ((C2HSImp.Ptr C2HSImp.CChar) -> (C2HSImp.CInt -> (C2HSImp.CInt -> (C2HSImp.CUInt -> ((C2HSImp.Ptr (CCurrency)) -> ((C2HSImp.Ptr (CCalendar)) -> ((C2HSImp.Ptr (CCalendar)) -> ((C2HSImp.Ptr (CCalendar)) -> (C2HSImp.CInt -> (C2HSImp.CInt -> ((C2HSImp.Ptr (CDayCounter)) -> ((C2HSImp.Ptr (CYieldTermStructure')) -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO (C2HSImp.Ptr (CIborIndex'))))))))))))))))
1126
1127 foreign import ccall safe "QuantLib/Index/InterestRate.chs.h qlCreateIbor"
1128 qlCreateIbor'_ :: (C2HSImp.CInt -> (C2HSImp.CInt -> (C2HSImp.CInt -> ((C2HSImp.Ptr (CYieldTermStructure')) -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO (C2HSImp.Ptr (CIborIndex'))))))))
1129
1130 foreign import ccall safe "QuantLib/Index/InterestRate.chs.h qlOvernightIndex"
1131 overnightIndex'_ :: ((C2HSImp.Ptr C2HSImp.CChar) -> (C2HSImp.CUInt -> ((C2HSImp.Ptr (CCurrency)) -> ((C2HSImp.Ptr (CCalendar)) -> ((C2HSImp.Ptr (CDayCounter)) -> ((C2HSImp.Ptr (CYieldTermStructure')) -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO (C2HSImp.Ptr (COvernightIndex'))))))))))
1132
1133 foreign import ccall safe "QuantLib/Index/InterestRate.chs.h qlIborIndexBusinessDayConvention"
1134 businessDayConvention'_ :: ((C2HSImp.Ptr (CIborIndex')) -> (IO C2HSImp.CInt))
1135
1136 foreign import ccall safe "QuantLib/Index/InterestRate.chs.h qlIborIndexEndOfMonth"
1137 endOfMonth'_ :: ((C2HSImp.Ptr (CIborIndex')) -> (IO C2HSImp.CInt))
1138
1139 foreign import ccall safe "QuantLib/Index/InterestRate.chs.h qlOvernightIndexedSwapIndexUnderlyingSwap"
1140 underlyingOIS'_ :: ((C2HSImp.Ptr (COvernightIndexedSwapIndex')) -> (C2HSImp.CInt -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO (C2HSImp.Ptr (COvernightIndexedSwap'))))))
1141
1142 foreign import ccall safe "QuantLib/Index/InterestRate.chs.h qlSwapIndexUnderlyingSwap"
1143 underlyingSwap'_ :: ((C2HSImp.Ptr (CSwapIndex')) -> (C2HSImp.CInt -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO (C2HSImp.Ptr (CVanillaSwap'))))))