-
Notifications
You must be signed in to change notification settings - Fork 284
Expand file tree
/
Copy pathconventions.hpp
More file actions
1974 lines (1767 loc) · 75.7 KB
/
conventions.hpp
File metadata and controls
1974 lines (1767 loc) · 75.7 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
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
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/*
Copyright (C) 2016 Quaternion Risk Management Ltd
Copyright (C) 2024 Oleg Kulkov
All rights reserved.
This file is part of ORE, a free-software/open-source library
for transparent pricing and risk analysis - http://opensourcerisk.org
ORE is free software: you can redistribute it and/or modify it
under the terms of the Modified BSD License. You should have received a
copy of the license along with this program.
The license is also available online at <http://opensourcerisk.org>
This program is distributed on the basis that it will form a useful
contribution to risk analytics and model standardisation, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the license for more details.
*/
/*! \file ored/configuration/conventions.hpp
\brief Currency and instrument specific conventions/defaults
\ingroup configuration
*/
#pragma once
#include <ored/utilities/xmlutils.hpp>
#include <ored/portfolio/schedule.hpp>
#include <ql/quotes/deltavolquote.hpp>
#include <ql/indexes/iborindex.hpp>
#include <ql/indexes/inflationindex.hpp>
#include <ql/indexes/swapindex.hpp>
#include <ql/instruments/overnightindexfuture.hpp>
#include <ql/instruments/bond.hpp>
#include <ql/option.hpp>
#include <qle/cashflows/subperiodscoupon.hpp> // SubPeriodsCouponType
#include <qle/indexes/bmaindexwrapper.hpp>
#include <qle/indexes/commodityindex.hpp>
#include <boost/thread/shared_mutex.hpp>
#include <boost/thread/lock_types.hpp>
namespace ore {
namespace data {
using ore::data::XMLNode;
using ore::data::XMLSerializable;
using std::map;
using std::string;
using QuantExt::SubPeriodsCoupon1;
using namespace QuantLib;
//! Abstract base class for convention objects
/*!
\ingroup configuration
*/
class Convention : public XMLSerializable {
public:
//! Supported convention types
enum class Type {
Zero,
Deposit,
Future,
FRA,
OIS,
Swap,
AverageOIS,
TenorBasisSwap,
TenorBasisTwoSwap,
BMABasisSwap,
FX,
CrossCcyBasis,
CrossCcyFixFloat,
CDS,
IborIndex,
OvernightIndex,
SwapIndex,
ZeroInflationIndex,
InflationSwap,
SecuritySpread,
CMSSpreadOption,
CommodityForward,
CommodityFuture,
FxOption,
FxOptionTimeWeighting,
BondYield
};
//! Default destructor
virtual ~Convention() {}
//! \name Inspectors
//@{
const string& id() const { return id_; }
Type type() const { return type_; }
//@}
//! \name convention interface definition
//@{
virtual void build() = 0;
//@}
protected:
Convention() {}
Convention(const string& id, Type type);
Type type_;
string id_;
};
std::ostream& operator<<(std::ostream& out, Convention::Type type);
//! Repository for currency dependent market conventions
/*!
\ingroup market
*/
class Conventions : public XMLSerializable {
public:
//! Default constructor
Conventions() {}
/*! Returns the convention if found and throws if not */
QuantLib::ext::shared_ptr<Convention> get(const string& id) const;
/*! Get a convention with the given \p id and \p type. If no convention of the given \p type with the given \p id
is found, the first element of the returned pair is \c false and the second element is a \c nullptr. If a
convention is found, the first element of the returned pair is \c true and the second element holds the
convention.
*/
std::pair<bool, QuantLib::ext::shared_ptr<Convention>> get(const std::string& id, const Convention::Type& type) const;
/*! Get all conventions of a given type */
std::set<QuantLib::ext::shared_ptr<Convention>> get(const Convention::Type& type) const;
/*! Find a convention for an FX pair */
QuantLib::ext::shared_ptr<Convention> getFxConvention(const string& ccy1, const string& ccy2) const;
//! Checks if we have a convention with the given \p id
bool has(const std::string& id) const;
//! Checks if we have a convention with the given \p id and \p type
bool has(const std::string& id, const Convention::Type& type) const;
/*! Clear all conventions */
void clear() const;
/*! Add a convention. This will overwrite an existing convention
with the same id */
void add(const QuantLib::ext::shared_ptr<Convention>& convention) const;
//! \name Serialisation
//@{0
virtual void fromXML(XMLNode* node) override;
virtual XMLNode* toXML(XMLDocument& doc) const override;
//@}
private:
mutable map<string, QuantLib::ext::shared_ptr<Convention>> data_;
mutable map<string, std::pair<string, string>> unparsed_;
mutable std::set<string> used_;
mutable boost::shared_mutex mutex_;
};
//! Singleton to hold conventions
//
class InstrumentConventions : public QuantLib::Singleton<InstrumentConventions, std::integral_constant<bool, true>> {
friend class QuantLib::Singleton<InstrumentConventions, std::integral_constant<bool, true>>;
private:
InstrumentConventions() { clear(); }
mutable std::map<QuantLib::Date, QuantLib::ext::shared_ptr<ore::data::Conventions>> conventions_;
mutable boost::shared_mutex mutex_;
mutable std::size_t numberOfEmittedWarnings_ = 0;
public:
const QuantLib::ext::shared_ptr<ore::data::Conventions>& conventions(QuantLib::Date d = QuantLib::Date()) const;
void setConventions(const QuantLib::ext::shared_ptr<ore::data::Conventions>& conventions,
QuantLib::Date d = QuantLib::Date());
void clear() { conventions_[Date()] = QuantLib::ext::make_shared<ore::data::Conventions>(); }
};
//! Container for storing Zero Rate conventions
/*!
\ingroup marketdata
*/
class ZeroRateConvention : public Convention {
public:
//! \name Constructors
//@{
//! Default constructor
ZeroRateConvention() {}
ZeroRateConvention(const string& id, const string& dayCounter, const string& compounding,
const string& compoundingFrequency);
ZeroRateConvention(const string& id, const string& dayCounter, const string& tenorCalendar,
const string& compounding = "Continuous", const string& compoundingFrequency = "Annual",
const string& spotLag = "", const string& spotCalendar = "", const string& rollConvention = "",
const string& eom = "");
//@}
//! \name Inspectors
//@{
//! Zero rate day counter
const DayCounter& dayCounter() const { return dayCounter_; }
//! Return the calendar used for converting tenor points into dates
const Calendar& tenorCalendar() const { return tenorCalendar_; }
//! Zero rate compounding
Compounding compounding() const { return compounding_; }
//! Zero rate compounding frequency
Frequency compoundingFrequency() const { return compoundingFrequency_; }
//! Zero rate spot lag
Natural spotLag() const { return spotLag_; }
//! Calendar used for spot date adjustment
const Calendar& spotCalendar() const { return spotCalendar_; }
//! Business day convention used in converting tenor points into dates
BusinessDayConvention rollConvention() const { return rollConvention_; }
//! End of month adjustment
bool eom() { return eom_; }
//! Flag to indicate whether the Zero Rate convention is based on a tenor input
bool tenorBased() { return tenorBased_; }
//@}
//! \name Serialisation
//@{
virtual void fromXML(XMLNode* node) override;
virtual XMLNode* toXML(XMLDocument& doc) const override;
virtual void build() override;
//@}
private:
DayCounter dayCounter_;
Calendar tenorCalendar_;
Compounding compounding_;
Frequency compoundingFrequency_;
Natural spotLag_;
Calendar spotCalendar_;
BusinessDayConvention rollConvention_;
bool eom_;
bool tenorBased_;
// Strings to store the inputs
string strDayCounter_;
string strTenorCalendar_;
string strCompounding_;
string strCompoundingFrequency_;
string strSpotLag_;
string strSpotCalendar_;
string strRollConvention_;
string strEom_;
};
//! Container for storing Deposit conventions
/*!
\ingroup marketdata
*/
class DepositConvention : public Convention {
public:
//! \name Constructors
//@{
//! Default constructor
DepositConvention() {}
//! Index based constructor
DepositConvention(const string& id, const string& index);
//! Detailed constructor
DepositConvention(const string& id, const string& calendar, const string& convention, const string& eom,
const string& dayCounter, const string& settlementDays);
//@}
//! \name Inspectors
//@{
const string& index() const { return index_; }
const Calendar& calendar() const { return calendar_; }
BusinessDayConvention convention() const { return convention_; }
bool eom() { return eom_; }
const DayCounter& dayCounter() const { return dayCounter_; }
const Size settlementDays() const { return settlementDays_; }
bool indexBased() { return indexBased_; }
// @}
//! \name Serialisation
//@{
virtual void fromXML(XMLNode* node) override;
virtual XMLNode* toXML(XMLDocument& doc) const override;
virtual void build() override;
//@}
private:
string index_;
Calendar calendar_;
BusinessDayConvention convention_;
bool eom_;
DayCounter dayCounter_;
Size settlementDays_;
bool indexBased_;
// Strings to store the inputs
string strCalendar_;
string strConvention_;
string strEom_;
string strDayCounter_;
string strSettlementDays_;
};
//! Container for storing Money Market Futures conventions
/*!
\ingroup marketdata
*/
class FutureConvention : public Convention {
public:
enum class DateGenerationRule { IMM, FirstDayOfMonth };
//! \name Constructors
//@{
//! Default constructor
FutureConvention() {}
//! Index based constructor
FutureConvention(const string& id, const string& index);
//! Index based constructor taking in addition a netting type for ON indices and a date generation rule
FutureConvention(const string& id, const string& index,
const QuantLib::RateAveraging::Type overnightIndexFutureNettingType,
const DateGenerationRule dateGeneration, const string& calendar);
//@}
//! \name Inspectors
//@{
QuantLib::ext::shared_ptr<IborIndex> index() const;
QuantLib::RateAveraging::Type overnightIndexFutureNettingType() const { return overnightIndexFutureNettingType_; }
DateGenerationRule dateGenerationRule() const { return dateGenerationRule_; }
QuantLib::Calendar calendar() const { return calendar_; }
//@}
//! Serialisation
//@{
virtual void fromXML(XMLNode* node) override;
virtual XMLNode* toXML(XMLDocument& doc) const override;
virtual void build() override {}
//@}
private:
string strIndex_;
string strCalendar_;
QuantLib::RateAveraging::Type overnightIndexFutureNettingType_;
DateGenerationRule dateGenerationRule_;
QuantLib::Calendar calendar_;
};
//! Container for storing Forward rate Agreement conventions
/*!
\ingroup marketdata
*/
class FraConvention : public Convention {
public:
//! \name Constructors
//@{
//! Default constructor
FraConvention() {}
//! Index based constructor
FraConvention(const string& id, const string& index);
//@}
//! \name Inspectors
//@{
QuantLib::ext::shared_ptr<IborIndex> index() const;
const string& indexName() const { return strIndex_; }
//@}
//! \name Serialisation
//@{
virtual void fromXML(XMLNode* node) override;
virtual XMLNode* toXML(XMLDocument& doc) const override;
virtual void build() override {}
//@}
private:
string strIndex_;
};
//! Container for storing Overnight Index Swap conventions
/*!
\ingroup marketdata
*/
class OisConvention : public Convention {
public:
//! \name Constructors
//@{
//! Default constructor
OisConvention() {}
//! Detailed constructor
OisConvention(const string& id, const string& spotLag, const string& index, const string& fixedDayCounter,
const string& fixedCalendar, const string& paymentLag = "", const string& eom = "",
const string& fixedFrequency = "", const string& fixedConvention = "",
const string& fixedPaymentConvention = "", const string& rule = "",
const std::string& paymentCalendar = "",
const std::string& rateCutoff = "");
//@}
//! \name Inspectors
//@{
Natural spotLag() const { return spotLag_; }
const string& indexName() const { return strIndex_; }
QuantLib::ext::shared_ptr<OvernightIndex> index() const;
const DayCounter& fixedDayCounter() const { return fixedDayCounter_; }
// might be empty to retain bwd compatibility
const Calendar& fixedCalendar() const { return fixedCalendar_; }
Natural paymentLag() const { return paymentLag_; }
bool eom() { return eom_; }
Frequency fixedFrequency() const { return fixedFrequency_; }
BusinessDayConvention fixedConvention() const { return fixedConvention_; }
BusinessDayConvention fixedPaymentConvention() const { return fixedPaymentConvention_; }
DateGeneration::Rule rule() const { return rule_; }
QuantLib::Calendar paymentCalendar() const { return paymentCal_; }
Natural rateCutoff() const { return rateCutoff_; }
//@}
//! \name Serialisation
//@{
virtual void fromXML(XMLNode* node) override;
virtual XMLNode* toXML(XMLDocument& doc) const override;
virtual void build() override;
//@}
private:
Natural spotLag_;
DayCounter fixedDayCounter_;
Calendar fixedCalendar_;
Natural paymentLag_;
bool eom_;
Frequency fixedFrequency_;
BusinessDayConvention fixedConvention_;
BusinessDayConvention fixedPaymentConvention_;
DateGeneration::Rule rule_;
QuantLib::Calendar paymentCal_;
Natural rateCutoff_;
// Strings to store the inputs
string strSpotLag_;
string strIndex_;
string strFixedDayCounter_;
string strFixedCalendar_;
string strPaymentLag_;
string strEom_;
string strFixedFrequency_;
string strFixedConvention_;
string strFixedPaymentConvention_;
string strRule_;
std::string strPaymentCal_;
string strRateCutoff_;
};
//! Container for storing Ibor Index conventions
/*!
\ingroup marketdata
*/
class IborIndexConvention : public Convention {
public:
IborIndexConvention() {}
IborIndexConvention(const string& id, const string& fixingCalendar, const string& dayCounter,
const Size settlementDays, const string& businessDayConvention, const bool endOfMonth);
const string& fixingCalendar() const { return strFixingCalendar_; }
const string& dayCounter() const { return strDayCounter_; }
const Size settlementDays() const { return settlementDays_; }
const string& businessDayConvention() const { return strBusinessDayConvention_; }
const bool endOfMonth() const { return endOfMonth_; }
virtual void fromXML(XMLNode* node) override;
virtual XMLNode* toXML(XMLDocument& doc) const override;
virtual void build() override;
private:
string localId_;
string strFixingCalendar_;
string strDayCounter_;
Size settlementDays_;
string strBusinessDayConvention_;
bool endOfMonth_;
};
//! Container for storing Overnight Index conventions
/*!
\ingroup marketdata
*/
class OvernightIndexConvention : public Convention {
public:
OvernightIndexConvention() {}
OvernightIndexConvention(const string& id, const string& fixingCalendar, const string& dayCounter,
const Size settlementDays);
const string& fixingCalendar() const { return strFixingCalendar_; }
const string& dayCounter() const { return strDayCounter_; }
const Size settlementDays() const { return settlementDays_; }
virtual void fromXML(XMLNode* node) override;
virtual XMLNode* toXML(XMLDocument& doc) const override;
virtual void build() override;
private:
string strFixingCalendar_;
string strDayCounter_;
Size settlementDays_;
};
//! Container for storing Swap Index conventions
/*!
\ingroup marketdata
*/
class SwapIndexConvention : public Convention {
public:
SwapIndexConvention() {}
SwapIndexConvention(const string& id, const string& conventions, const string& fixingCalendar = "");
const string& conventions() const { return strConventions_; }
const string& fixingCalendar() const { return fixingCalendar_; }
virtual void fromXML(XMLNode* node) override;
virtual XMLNode* toXML(XMLDocument& doc) const override;
virtual void build() override {};
private:
string strConventions_;
string fixingCalendar_;
};
//! Container for storing Interest Rate Swap conventions
/*!
\ingroup marketdata
*/
class IRSwapConvention : public Convention {
public:
//! \name Constructors
//@{
//! Default constructor
IRSwapConvention() {}
//! Detailed constructor
IRSwapConvention(const string& id, const string& fixedCalendar, const string& fixedFrequency,
const string& fixedConvention, const string& fixedDayCounter, const string& index,
bool hasSubPeriod = false, const string& floatFrequency = "",
const string& subPeriodsCouponType = "");
//@}
//! \name Inspectors
//@{
const Calendar& fixedCalendar() const { return fixedCalendar_; }
Frequency fixedFrequency() const { return fixedFrequency_; }
BusinessDayConvention fixedConvention() const { return fixedConvention_; }
const DayCounter& fixedDayCounter() const { return fixedDayCounter_; }
const string& indexName() const { return strIndex_; }
QuantLib::ext::shared_ptr<IborIndex> index() const;
// For sub period
bool hasSubPeriod() const { return hasSubPeriod_; }
Frequency floatFrequency() const { return floatFrequency_; } // returns NoFrequency for normal swaps
SubPeriodsCoupon1::Type subPeriodsCouponType() const { return subPeriodsCouponType_; }
//@}
//! \name Serialisation
//@{
virtual void fromXML(XMLNode* node) override;
virtual XMLNode* toXML(XMLDocument& doc) const override;
virtual void build() override;
//@}
private:
Calendar fixedCalendar_;
Frequency fixedFrequency_;
BusinessDayConvention fixedConvention_;
DayCounter fixedDayCounter_;
bool hasSubPeriod_;
Frequency floatFrequency_;
SubPeriodsCoupon1::Type subPeriodsCouponType_;
// Strings to store the inputs
string strFixedCalendar_;
string strFixedFrequency_;
string strFixedConvention_;
string strFixedDayCounter_;
string strIndex_;
string strFloatFrequency_;
string strSubPeriodsCouponType_;
};
//! Container for storing Average OIS conventions
/*!
\ingroup marketdata
*/
class AverageOisConvention : public Convention {
public:
//! \name Constructors
//@{
//! Default constructor
AverageOisConvention() {}
//! Detailed constructor
AverageOisConvention(const string& id, const string& spotLag, const string& fixedTenor,
const string& fixedDayCounter, const string& fixedCalendar, const string& fixedConvention,
const string& fixedPaymentConvention, const string& fixedFrequency, const string& index,
const string& onTenor, const string& rateCutoff);
//@}
//! \name Inspectors
//@{
Natural spotLag() const { return spotLag_; }
const Period& fixedTenor() const { return fixedTenor_; }
const DayCounter& fixedDayCounter() const { return fixedDayCounter_; }
const Calendar& fixedCalendar() const { return fixedCalendar_; }
BusinessDayConvention fixedConvention() const { return fixedConvention_; }
BusinessDayConvention fixedPaymentConvention() const { return fixedPaymentConvention_; }
Frequency fixedFrequency() const { return fixedFrequency_; }
const string& indexName() const { return strIndex_; }
QuantLib::ext::shared_ptr<OvernightIndex> index() const;
const Period& onTenor() const { return onTenor_; }
Natural rateCutoff() const { return rateCutoff_; }
//@}
//! \name Serialisation
//@{
virtual void fromXML(XMLNode* node) override;
virtual XMLNode* toXML(XMLDocument& doc) const override;
virtual void build() override;
//@}
private:
Natural spotLag_;
Period fixedTenor_;
DayCounter fixedDayCounter_;
Calendar fixedCalendar_;
BusinessDayConvention fixedConvention_;
BusinessDayConvention fixedPaymentConvention_;
Frequency fixedFrequency_;
Period onTenor_;
Natural rateCutoff_;
// Strings to store the inputs
string strSpotLag_;
string strFixedTenor_;
string strFixedDayCounter_;
string strFixedCalendar_;
string strFixedConvention_;
string strFixedPaymentConvention_;
string strFixedFrequency_;
string strIndex_;
string strOnTenor_;
string strRateCutoff_;
};
//! Container for storing Tenor Basis Swap conventions
/*!
\ingroup marketdata
*/
class TenorBasisSwapConvention : public Convention {
public:
//! \name Constructors
//@{
//! Default constructor
TenorBasisSwapConvention() {}
//! Detailed constructor
TenorBasisSwapConvention(const string& id, const string& payIndex, const string& receiveIndex,
const string& receiveFrequency = "", const string& payFrequency = "",
const string& spreadOnRec = "", const string& includeSpread = "",
const string& subPeriodsCouponType = "");
//@}
//! \name Inspectors
//@{
QuantLib::ext::shared_ptr<IborIndex> payIndex() const;
QuantLib::ext::shared_ptr<IborIndex> receiveIndex() const;
const string& payIndexName() const { return strPayIndex_; }
const string& receiveIndexName() const { return strReceiveIndex_; }
const Period& receiveFrequency() const { return receiveFrequency_; }
const Period& payFrequency() const { return payFrequency_; }
bool spreadOnRec() const { return spreadOnRec_; }
bool includeSpread() const { return includeSpread_; }
SubPeriodsCoupon1::Type subPeriodsCouponType() const { return subPeriodsCouponType_; }
//@}
//! \name Serialisation
//@{
virtual void fromXML(XMLNode* node) override;
virtual XMLNode* toXML(XMLDocument& doc) const override;
virtual void build() override;
//@}
private:
Period receiveFrequency_;
Period payFrequency_;
bool spreadOnRec_;
bool includeSpread_;
SubPeriodsCoupon1::Type subPeriodsCouponType_;
// Strings to store the inputs
string strPayIndex_;
string strReceiveIndex_;
string strReceiveFrequency_;
string strPayFrequency_;
string strSpreadOnRec_;
string strIncludeSpread_;
string strSubPeriodsCouponType_;
};
//! Container for storing conventions for Tenor Basis Swaps quoted as a spread of two interest rate swaps
/*!
\ingroup marketdata
*/
class TenorBasisTwoSwapConvention : public Convention {
public:
//! \name Constructors
//@{
//! Default constructor
TenorBasisTwoSwapConvention() {}
//! Detailed constructor
TenorBasisTwoSwapConvention(const string& id, const string& calendar, const string& longFixedFrequency,
const string& longFixedConvention, const string& longFixedDayCounter,
const string& longIndex, const string& shortFixedFrequency,
const string& shortFixedConvention, const string& shortFixedDayCounter,
const string& shortIndex, const string& longMinusShort = "");
//@}
//! \name Inspectors
//@{
const Calendar& calendar() const { return calendar_; }
Frequency longFixedFrequency() const { return longFixedFrequency_; }
BusinessDayConvention longFixedConvention() const { return longFixedConvention_; }
const DayCounter& longFixedDayCounter() const { return longFixedDayCounter_; }
QuantLib::ext::shared_ptr<IborIndex> longIndex() const;
Frequency shortFixedFrequency() const { return shortFixedFrequency_; }
BusinessDayConvention shortFixedConvention() const { return shortFixedConvention_; }
const DayCounter& shortFixedDayCounter() const { return shortFixedDayCounter_; }
QuantLib::ext::shared_ptr<IborIndex> shortIndex() const;
bool longMinusShort() const { return longMinusShort_; }
//@}
//! \name Serialisation
//@{
virtual void fromXML(XMLNode* node) override;
virtual XMLNode* toXML(XMLDocument& doc) const override;
virtual void build() override;
//@}
private:
Calendar calendar_;
Frequency longFixedFrequency_;
BusinessDayConvention longFixedConvention_;
DayCounter longFixedDayCounter_;
Frequency shortFixedFrequency_;
BusinessDayConvention shortFixedConvention_;
DayCounter shortFixedDayCounter_;
bool longMinusShort_;
// Strings to store the inputs
string strCalendar_;
string strLongFixedFrequency_;
string strLongFixedConvention_;
string strLongFixedDayCounter_;
string strLongIndex_;
string strShortFixedFrequency_;
string strShortFixedConvention_;
string strShortFixedDayCounter_;
string strShortIndex_;
string strLongMinusShort_;
};
//! Container for storing Libor-BMA Basis Swap conventions
/*!
\ingroup marketdata
*/
class BMABasisSwapConvention : public Convention {
public:
//! \name Constructors
//@{
//! Default constructor
BMABasisSwapConvention() {}
//! Detailed constructor
BMABasisSwapConvention(const string& id, const string& index, const string& bmaIndex);
//@}
//! \name Inspectors
//@{
QuantLib::ext::shared_ptr<IborIndex> index() const;
QuantLib::ext::shared_ptr<QuantExt::BMAIndexWrapper> bmaIndex() const;
const string& indexName() const { return strIndex_; }
const string& bmaIndexName() const { return strBmaIndex_; }
const Calendar& bmaPaymentCalendar() const { return bmaPaymentCalendar_; }
BusinessDayConvention bmaPaymentConvention() const { return bmaPaymentConvention_; }
Natural bmaPaymentLag() const { return bmaPaymentLag_; }
const Calendar& indexPaymentCalendar() const { return indexPaymentCalendar_; }
BusinessDayConvention indexPaymentConvention() const { return indexPaymentConvention_; }
Natural indexPaymentLag() const { return indexPaymentLag_; }
Natural indexSettlementDays() const { return indexSettlementDays_; }
const Period& indexPaymentPeriod() const { return indexPaymentPeriod_; }
BusinessDayConvention indexConvention() const { return indexConvention_; }
Natural overnightLockoutDays() const { return overnightLockoutDays_; }
//@}
//! \name Serialisation
//@{
virtual void fromXML(XMLNode* node) override;
virtual XMLNode* toXML(XMLDocument& doc) const override;
virtual void build() override;
//@}
private:
Calendar bmaPaymentCalendar_;
BusinessDayConvention bmaPaymentConvention_;
Natural bmaPaymentLag_;
Calendar indexPaymentCalendar_;
BusinessDayConvention indexPaymentConvention_;
Natural indexPaymentLag_;
Natural indexSettlementDays_;
Period indexPaymentPeriod_;
BusinessDayConvention indexConvention_;
Natural overnightLockoutDays_;
// Strings to store the inputs
string strIndex_;
string strBmaIndex_;
string strBmaPaymentCalendar_;
string strBmaPaymentConvention_;
string strBmaPaymentLag_;
string strIndexPaymentCalendar_;
string strIndexPaymentConvention_;
string strIndexPaymentLag_;
string strIndexSettlementDays_;
string strIndexPaymentPeriod_;
string strIndexConvention_;
string strOvernightLockoutDays_;
};
//! Container for storing FX Spot quote conventions
/*!
\ingroup marketdata
*/
class FXConvention : public Convention {
public:
//! \name Constructors
//@{
//! Default constructor
FXConvention() {}
//! Detailed constructor
FXConvention(const string& id, const string& spotDays, const string& sourceCurrency, const string& targetCurrency,
const string& pointsFactor, const string& advanceCalendar = "", const string& spotRelative = "",
const string& endOfMonth = "", const string& convention = "");
//@}
//! \name Inspectors
//@{
Natural spotDays() const { return spotDays_; }
const Currency& sourceCurrency() const { return sourceCurrency_; }
const Currency& targetCurrency() const { return targetCurrency_; }
Real pointsFactor() const { return pointsFactor_; }
const Calendar& advanceCalendar() const { return advanceCalendar_; }
bool spotRelative() const { return spotRelative_; }
bool endOfMonth() const { return endOfMonth_; }
BusinessDayConvention convention() const { return convention_; }
//@}
//! \name Serialisation
//
virtual void fromXML(XMLNode* node) override;
virtual XMLNode* toXML(XMLDocument& doc) const override;
virtual void build() override;
//@}
private:
Natural spotDays_;
Currency sourceCurrency_;
Currency targetCurrency_;
Real pointsFactor_;
Calendar advanceCalendar_;
bool spotRelative_;
bool endOfMonth_;
BusinessDayConvention convention_;
// Strings to store the inputs
string strSpotDays_;
string strSourceCurrency_;
string strTargetCurrency_;
string strPointsFactor_;
string strAdvanceCalendar_;
string strSpotRelative_;
string strEndOfMonth_;
string strConvention_;
};
//! Container for storing Cross Currency Basis Swap quote conventions
/*!
\ingroup marketdata
*/
class CrossCcyBasisSwapConvention : public Convention {
public:
//! \name Constructors
//@{
//! Default constructor
CrossCcyBasisSwapConvention() {}
//! Detailed constructor
CrossCcyBasisSwapConvention(const string& id, const string& strSettlementDays, const string& strSettlementCalendar,
const string& strRollConvention, const string& flatIndex, const string& spreadIndex,
const string& strEom = "", const string& strIsResettable = "",
const string& strFlatIndexIsResettable = "", const std::string& strFlatTenor = "",
const std::string& strSpreadTenor = "", const string& strPaymentLag = "",
const string& strFlatPaymentLag = "", const string& strIncludeSpread = "",
const string& strLookback = "", const string& strFixingDays = "",
const string& strRateCutoff = "", const string& strIsAveraged = "",
const string& strFlatIncludeSpread = "", const string& strFlatLookback = "",
const string& strFlatFixingDays = "", const string& strFlatRateCutoff = "",
const string& strFlatIsAveraged = "", const Conventions* conventions = nullptr);
//@}
//! \name Inspectors
//@{
Natural settlementDays() const { return settlementDays_; }
const Calendar& settlementCalendar() const { return settlementCalendar_; }
BusinessDayConvention rollConvention() const { return rollConvention_; }
QuantLib::ext::shared_ptr<IborIndex> flatIndex() const;
QuantLib::ext::shared_ptr<IborIndex> spreadIndex() const;
const string& flatIndexName() const { return strFlatIndex_; }
const string& spreadIndexName() const { return strSpreadIndex_; }
bool eom() const { return eom_; }
bool isResettable() const { return isResettable_; }
bool flatIndexIsResettable() const { return flatIndexIsResettable_; }
const QuantLib::Period& flatTenor() const { return flatTenor_; }
const QuantLib::Period& spreadTenor() const { return spreadTenor_; }
Size paymentLag() const { return paymentLag_; }
Size flatPaymentLag() const { return flatPaymentLag_; }
// only OIS
QuantLib::ext::optional<bool> includeSpread() const { return includeSpread_; }
QuantLib::ext::optional<QuantLib::Period> lookback() const { return lookback_; }
QuantLib::ext::optional<QuantLib::Size> fixingDays() const { return fixingDays_; }
QuantLib::ext::optional<Size> rateCutoff() const { return rateCutoff_; }
QuantLib::ext::optional<bool> isAveraged() const { return isAveraged_; }
QuantLib::ext::optional<bool> flatIncludeSpread() const { return flatIncludeSpread_; }
QuantLib::ext::optional<QuantLib::Period> flatLookback() const { return flatLookback_; }
QuantLib::ext::optional<QuantLib::Size> flatFixingDays() const { return flatFixingDays_; }
QuantLib::ext::optional<Size> flatRateCutoff() const { return flatRateCutoff_; }
QuantLib::ext::optional<bool> flatIsAveraged() const { return flatIsAveraged_; }
//@}
//! \name Serialisation
//@{
virtual void fromXML(XMLNode* node) override;
virtual XMLNode* toXML(XMLDocument& doc) const override;
virtual void build() override;
//@}
private:
Natural settlementDays_;
Calendar settlementCalendar_;
BusinessDayConvention rollConvention_;
bool eom_;
bool isResettable_;
bool flatIndexIsResettable_;
QuantLib::Period flatTenor_;
QuantLib::Period spreadTenor_;
QuantLib::Size paymentLag_;
QuantLib::Size flatPaymentLag_;
// OIS only
QuantLib::ext::optional<bool> includeSpread_;
QuantLib::ext::optional<QuantLib::Period> lookback_;
QuantLib::ext::optional<QuantLib::Size> fixingDays_;
QuantLib::ext::optional<Size> rateCutoff_;
QuantLib::ext::optional<bool> isAveraged_;
QuantLib::ext::optional<bool> flatIncludeSpread_;
QuantLib::ext::optional<QuantLib::Period> flatLookback_;
QuantLib::ext::optional<QuantLib::Size> flatFixingDays_;
QuantLib::ext::optional<Size> flatRateCutoff_;
QuantLib::ext::optional<bool> flatIsAveraged_;
// Strings to store the inputs
string strSettlementDays_;
string strSettlementCalendar_;
string strRollConvention_;
string strFlatIndex_;
string strSpreadIndex_;
string strEom_;
string strIsResettable_;
string strFlatIndexIsResettable_;
string strFlatTenor_;
string strSpreadTenor_;
string strPaymentLag_;
string strFlatPaymentLag_;
// OIS only
string strIncludeSpread_;
string strLookback_;
string strFixingDays_;
string strRateCutoff_;
string strIsAveraged_;
string strFlatIncludeSpread_;
string strFlatLookback_;
string strFlatFixingDays_;
string strFlatRateCutoff_;
string strFlatIsAveraged_;
};
/*! Container for storing Cross Currency Fix vs Float Swap quote conventions
\ingroup marketdata
*/
class CrossCcyFixFloatSwapConvention : public Convention {
public:
//! \name Constructors
//@{
//! Default constructor
CrossCcyFixFloatSwapConvention() {}
//! Detailed constructor
CrossCcyFixFloatSwapConvention(const std::string& id, const std::string& settlementDays,
const std::string& settlementCalendar, const std::string& settlementConvention,
const std::string& fixedCurrency, const std::string& fixedFrequency,