forked from lballabio/QuantLib-SWIG
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcashflows.i
1270 lines (1163 loc) · 48.2 KB
/
cashflows.i
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) 2000, 2001, 2002, 2003 RiskMap srl
Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2009 StatPro Italia srl
Copyright (C) 2005 Dominic Thuillier
Copyright (C) 2010, 2011 Lluis Pujol Bajador
Copyright (C) 2017, 2018, 2019, 2020 Matthias Lungwitz
Copyright (C) 2021 Marcin Rybacki
This file is part of QuantLib, a free-software/open-source library
for financial quantitative analysts and developers - http://quantlib.org/
QuantLib is free software: you can redistribute it and/or modify it
under the terms of the QuantLib license. You should have received a
copy of the license along with this program; if not, please email
<[email protected]>. The license is also available online at
<http://quantlib.org/license.shtml>.
This program is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
FOR A PARTICULAR PURPOSE. See the license for more details.
*/
#ifndef quantlib_cash_flows_i
#define quantlib_cash_flows_i
%include date.i
%include types.i
%include calendars.i
%include daycounters.i
%include indexes.i
%include termstructures.i
%include scheduler.i
%include vectors.i
%include volatilities.i
%{
using QuantLib::CashFlow;
using QuantLib::Leg;
%}
%shared_ptr(CashFlow)
class CashFlow : public Observable {
private:
CashFlow();
public:
Real amount() const;
Date date() const;
bool hasOccurred(const Date& refDate = Date()) const;
};
#if defined(SWIGCSHARP)
SWIG_STD_VECTOR_ENHANCED( ext::shared_ptr<CashFlow> )
#endif
%template(Leg) std::vector<ext::shared_ptr<CashFlow> >;
typedef std::vector<ext::shared_ptr<CashFlow> > Leg;
#if defined(SWIGCSHARP)
SWIG_STD_VECTOR_ENHANCED( Leg )
#endif
%template(LegVector) std::vector<Leg>;
// implementations
%{
using QuantLib::SimpleCashFlow;
using QuantLib::IndexedCashFlow;
using QuantLib::Redemption;
using QuantLib::AmortizingPayment;
using QuantLib::Coupon;
using QuantLib::FixedRateCoupon;
using QuantLib::FloatingRateCoupon;
using QuantLib::RateAveraging;
using QuantLib::OvernightIndexedCoupon;
%}
%shared_ptr(SimpleCashFlow)
class SimpleCashFlow : public CashFlow {
public:
SimpleCashFlow(Real amount, const Date& date);
};
%shared_ptr(Redemption)
class Redemption : public CashFlow {
public:
Redemption(Real amount, const Date& date);
};
%shared_ptr(AmortizingPayment)
class AmortizingPayment : public CashFlow {
public:
AmortizingPayment(Real amount, const Date& date);
};
%shared_ptr(IndexedCashFlow)
class IndexedCashFlow : public CashFlow {
public:
IndexedCashFlow(Real notional,
const ext::shared_ptr<Index>& index,
const Date& baseDate,
const Date& fixingDate,
const Date& paymentDate,
bool growthOnly = false);
Real notional() const;
Date baseDate() const;
Date fixingDate() const;
Real baseFixing() const;
Real indexFixing() const;
ext::shared_ptr<Index> index() const;
bool growthOnly() const;
};
%inline %{
ext::shared_ptr<IndexedCashFlow> as_indexed_cashflow(const ext::shared_ptr<CashFlow>& cf) {
return ext::dynamic_pointer_cast<IndexedCashFlow>(cf);
}
%}
%shared_ptr(Coupon)
class Coupon : public CashFlow {
private:
Coupon();
public:
Real nominal() const;
Date accrualStartDate() const;
Date accrualEndDate() const;
Date referencePeriodStart() const;
Date referencePeriodEnd() const;
Date exCouponDate() const;
Real rate() const;
Time accrualPeriod() const;
BigInteger accrualDays() const;
DayCounter dayCounter() const;
Real accruedAmount(const Date& date) const;
};
%inline %{
ext::shared_ptr<Coupon> as_coupon(const ext::shared_ptr<CashFlow>& cf) {
return ext::dynamic_pointer_cast<Coupon>(cf);
}
%}
%shared_ptr(FixedRateCoupon)
class FixedRateCoupon : public Coupon {
#if !defined(SWIGJAVA) && !defined(SWIGCSHARP)
%feature("kwargs") FixedRateCoupon;
#endif
public:
FixedRateCoupon(const Date& paymentDate, Real nominal,
Rate rate, const DayCounter& dayCounter,
const Date& startDate, const Date& endDate,
const Date& refPeriodStart = Date(),
const Date& refPeriodEnd = Date(),
const Date& exCouponDate = Date());
InterestRate interestRate() const;
};
%inline %{
ext::shared_ptr<FixedRateCoupon> as_fixed_rate_coupon(
const ext::shared_ptr<CashFlow>& cf) {
return ext::dynamic_pointer_cast<FixedRateCoupon>(cf);
}
%}
%{
using QuantLib::FloatingRateCouponPricer;
%}
%shared_ptr(FloatingRateCouponPricer)
class FloatingRateCouponPricer {
private:
FloatingRateCouponPricer();
public:
virtual Real swapletPrice() const;
virtual Rate swapletRate() const;
virtual Real capletPrice(Rate effectiveCap) const;
virtual Rate capletRate(Rate effectiveCap) const;
virtual Real floorletPrice(Rate effectiveFloor) const;
virtual Rate floorletRate(Rate effectiveFloor) const;
};
void setCouponPricer(const Leg&,
const ext::shared_ptr<FloatingRateCouponPricer>&);
%shared_ptr(FloatingRateCoupon)
class FloatingRateCoupon : public Coupon {
private:
FloatingRateCoupon();
public:
Date fixingDate() const;
Integer fixingDays() const;
bool isInArrears() const;
Real gearing() const;
Rate spread() const;
Rate indexFixing() const;
Rate adjustedFixing() const;
Rate convexityAdjustment() const;
Real price(const Handle<YieldTermStructure>& discountCurve) const;
ext::shared_ptr<InterestRateIndex> index() const;
void setPricer(const ext::shared_ptr<FloatingRateCouponPricer>& p);
};
%inline %{
ext::shared_ptr<FloatingRateCoupon> as_floating_rate_coupon(
const ext::shared_ptr<CashFlow>& cf) {
return ext::dynamic_pointer_cast<FloatingRateCoupon>(cf);
}
%}
struct RateAveraging {
enum Type {
Simple,
Compound
};
};
%shared_ptr(OvernightIndexedCoupon)
class OvernightIndexedCoupon : public FloatingRateCoupon {
public:
OvernightIndexedCoupon(
const Date& paymentDate,
Real nominal,
const Date& startDate,
const Date& endDate,
const ext::shared_ptr<OvernightIndex>& overnightIndex,
Real gearing = 1.0,
Spread spread = 0.0,
const Date& refPeriodStart = Date(),
const Date& refPeriodEnd = Date(),
const DayCounter& dayCounter = DayCounter(),
bool telescopicValueDates = false,
RateAveraging::Type averagingMethod = RateAveraging::Compound);
const std::vector<Date>& fixingDates() const;
const std::vector<Time>& dt() const;
const std::vector<Rate>& indexFixings() const;
const std::vector<Date>& valueDates() const;
};
%inline %{
ext::shared_ptr<OvernightIndexedCoupon> as_overnight_indexed_coupon(
const ext::shared_ptr<CashFlow>& cf) {
return ext::dynamic_pointer_cast<OvernightIndexedCoupon>(cf);
}
%}
%{
using QuantLib::CappedFlooredCoupon;
%}
%shared_ptr(CappedFlooredCoupon)
class CappedFlooredCoupon : public FloatingRateCoupon {
#if !defined(SWIGJAVA) && !defined(SWIGCSHARP)
%feature("kwargs") CappedFlooredCoupon;
#endif
public:
CappedFlooredCoupon(const ext::shared_ptr<FloatingRateCoupon>& underlying,
Rate cap = Null<Rate>(),
Rate floor = Null<Rate>());
Rate cap() const;
Rate floor() const;
Rate effectiveCap() const;
Rate effectiveFloor() const;
bool isCapped() const;
bool isFloored() const;
void setPricer(const ext::shared_ptr<FloatingRateCouponPricer>& p);
};
// specialized floating-rate coupons
%{
using QuantLib::IborCoupon;
using QuantLib::CappedFlooredIborCoupon;
using QuantLib::SubPeriodsCoupon;
%}
%shared_ptr(IborCoupon)
class IborCoupon : public FloatingRateCoupon {
#if !defined(SWIGJAVA) && !defined(SWIGCSHARP)
%feature("kwargs") IborCoupon;
#endif
public:
IborCoupon(const Date& paymentDate, Real nominal,
const Date& startDate, const Date& endDate,
Integer fixingDays,
ext::shared_ptr<IborIndex>& index,
Real gearing = 1.0, Spread spread = 0.0,
const Date& refPeriodStart = Date(),
const Date& refPeriodEnd = Date(),
const DayCounter& dayCounter = DayCounter(),
bool isInArrears = false,
const Date& exCouponDate = Date());
%extend {
static void createAtParCoupons() {
IborCoupon::Settings::instance().createAtParCoupons();
}
static void createIndexedCoupons() {
IborCoupon::Settings::instance().createIndexedCoupons();
}
static bool usingAtParCoupons() {
return IborCoupon::Settings::instance().usingAtParCoupons();
}
}
};
%shared_ptr(CappedFlooredIborCoupon)
class CappedFlooredIborCoupon : public CappedFlooredCoupon {
#if !defined(SWIGJAVA) && !defined(SWIGCSHARP)
%feature("kwargs") CappedFlooredIborCoupon;
#endif
public:
CappedFlooredIborCoupon(const Date& paymentDate, Real nominal,
const Date& startDate, const Date& endDate,
Integer fixingDays,
ext::shared_ptr<IborIndex>& index,
Real gearing = 1.0, Spread spread = 0.0,
const Rate cap = Null<Rate>(),
const Rate floor = Null<Rate>(),
const Date& refPeriodStart = Date(),
const Date& refPeriodEnd = Date(),
const DayCounter& dayCounter = DayCounter(),
bool isInArrears = false,
const Date& exCouponDate = Date());
};
%shared_ptr(SubPeriodsCoupon)
class SubPeriodsCoupon: public FloatingRateCoupon {
#if !defined(SWIGJAVA) && !defined(SWIGCSHARP)
%feature("kwargs") SubPeriodsCoupon;
#endif
public:
SubPeriodsCoupon(const Date& paymentDate,
Real nominal,
const Date& startDate,
const Date& endDate,
Natural fixingDays,
const ext::shared_ptr<IborIndex>& index,
Real gearing = 1.0,
Rate couponSpread = 0.0,
Rate rateSpread = 0.0,
const Date& refPeriodStart = Date(),
const Date& refPeriodEnd = Date(),
const DayCounter& dayCounter = DayCounter(),
const Date& exCouponDate = Date());
const std::vector<Date>& fixingDates() const;
const std::vector<Time>& dt() const;
const std::vector<Date>& valueDates() const;
Spread rateSpread() const;
};
%inline %{
ext::shared_ptr<SubPeriodsCoupon> as_sub_periods_coupon(
const ext::shared_ptr<CashFlow>& cf) {
return ext::dynamic_pointer_cast<SubPeriodsCoupon>(cf);
}
%}
%{
using QuantLib::IborCouponPricer;
using QuantLib::BlackIborCouponPricer;
using QuantLib::SubPeriodsPricer;
using QuantLib::CompoundingRatePricer;
using QuantLib::AveragingRatePricer;
%}
%shared_ptr(IborCouponPricer)
class IborCouponPricer : public FloatingRateCouponPricer {
private:
IborCouponPricer();
public:
Handle<OptionletVolatilityStructure> capletVolatility() const;
void setCapletVolatility(const Handle<OptionletVolatilityStructure>& v =
Handle<OptionletVolatilityStructure>());
};
%shared_ptr(BlackIborCouponPricer)
class BlackIborCouponPricer : public IborCouponPricer {
#if !defined(SWIGJAVA) && !defined(SWIGCSHARP)
%feature("kwargs") BlackIborCouponPricer;
#endif
public:
enum TimingAdjustment { Black76, BivariateLognormal };
BlackIborCouponPricer(const Handle<OptionletVolatilityStructure>& v =
Handle<OptionletVolatilityStructure>(),
const TimingAdjustment timingAdjustment = Black76,
const Handle<Quote> correlation =
Handle<Quote>(ext::shared_ptr<Quote>(new SimpleQuote(1.0))),
ext::optional<bool> useIndexedCoupon = ext::nullopt);
};
%shared_ptr(SubPeriodsPricer)
class SubPeriodsPricer: public FloatingRateCouponPricer {
private:
SubPeriodsPricer();
};
%shared_ptr(CompoundingRatePricer)
class CompoundingRatePricer: public SubPeriodsPricer {
public:
CompoundingRatePricer();
};
%shared_ptr(AveragingRatePricer)
class AveragingRatePricer: public SubPeriodsPricer {
public:
AveragingRatePricer();
};
%{
using QuantLib::CmsCoupon;
using QuantLib::CappedFlooredCmsCoupon;
using QuantLib::CmsSpreadCoupon;
using QuantLib::CappedFlooredCmsSpreadCoupon;
%}
%shared_ptr(CmsCoupon)
class CmsCoupon : public FloatingRateCoupon {
#if !defined(SWIGJAVA) && !defined(SWIGCSHARP)
%feature("kwargs") CmsCoupon;
#endif
public:
CmsCoupon(const Date& paymentDate, Real nominal,
const Date& startDate, const Date& endDate,
Integer fixingDays, const ext::shared_ptr<SwapIndex>& index,
Real gearing = 1.0, Spread spread = 0.0,
const Date& refPeriodStart = Date(),
const Date& refPeriodEnd = Date(),
const DayCounter& dayCounter = DayCounter(),
bool isInArrears = false,
const Date& exCouponDate = Date());
};
%shared_ptr(CmsSpreadCoupon)
class CmsSpreadCoupon : public FloatingRateCoupon {
#if !defined(SWIGJAVA) && !defined(SWIGCSHARP)
%feature("kwargs") CmsSpreadCoupon;
#endif
public:
CmsSpreadCoupon(const Date& paymentDate,
Real nominal,
const Date& startDate,
const Date& endDate,
Natural fixingDays,
const ext::shared_ptr<SwapSpreadIndex>& index,
Real gearing = 1.0,
Spread spread = 0.0,
const Date& refPeriodStart = Date(),
const Date& refPeriodEnd = Date(),
const DayCounter& dayCounter = DayCounter(),
bool isInArrears = false,
const Date& exCouponDate = Date());
};
%{
using QuantLib::CmsCouponPricer;
using QuantLib::AnalyticHaganPricer;
using QuantLib::NumericHaganPricer;
using QuantLib::GFunctionFactory;
using QuantLib::LinearTsrPricer;
using QuantLib::CmsSpreadCouponPricer;
using QuantLib::LognormalCmsSpreadPricer;
%}
%shared_ptr(CmsCouponPricer)
class CmsCouponPricer : public FloatingRateCouponPricer {
private:
CmsCouponPricer();
public:
Handle<SwaptionVolatilityStructure> swaptionVolatility() const;
void setSwaptionVolatility(const Handle<SwaptionVolatilityStructure>& v =
Handle<SwaptionVolatilityStructure>());
};
#if defined(SWIGCSHARP)
SWIG_STD_VECTOR_ENHANCED( ext::shared_ptr<CmsCouponPricer> )
#endif
namespace std {
%template(CmsCouponPricerVector)
vector<ext::shared_ptr<CmsCouponPricer> >;
}
class GFunctionFactory {
private:
GFunctionFactory();
public:
enum YieldCurveModel { Standard,
ExactYield,
ParallelShifts,
NonParallelShifts };
};
%shared_ptr(AnalyticHaganPricer)
class AnalyticHaganPricer : public CmsCouponPricer {
public:
AnalyticHaganPricer(const Handle<SwaptionVolatilityStructure>& v,
GFunctionFactory::YieldCurveModel model,
const Handle<Quote>& meanReversion);
};
%shared_ptr(NumericHaganPricer)
class NumericHaganPricer : public CmsCouponPricer {
public:
NumericHaganPricer(const Handle<SwaptionVolatilityStructure>& v,
GFunctionFactory::YieldCurveModel model,
const Handle<Quote>& meanReversion,
Rate lowerLimit = 0.0,
Rate upperLimit = 1.0,
Real precision = 1.0e-6);
};
%shared_ptr(CappedFlooredCmsCoupon)
class CappedFlooredCmsCoupon: public CappedFlooredCoupon {
#if !defined(SWIGJAVA) && !defined(SWIGCSHARP)
%feature("kwargs") CappedFlooredCoupon;
#endif
public:
CappedFlooredCmsCoupon(
const Date& paymentDate, Real nominal,
const Date& startDate, const Date& endDate,
Natural fixingDays, const ext::shared_ptr<SwapIndex>& index,
Real gearing = 1.0, Spread spread = 0.0,
const Rate cap = Null<Rate>(),
const Rate floor = Null<Rate>(),
const Date& refPeriodStart = Date(),
const Date& refPeriodEnd = Date(),
const DayCounter& dayCounter = DayCounter(),
bool isInArrears = false,
const Date& exCouponDate = Date());
};
%shared_ptr(CappedFlooredCmsSpreadCoupon)
class CappedFlooredCmsSpreadCoupon: public CappedFlooredCoupon {
#if !defined(SWIGJAVA) && !defined(SWIGCSHARP)
%feature("kwargs") CappedFlooredCoupon;
#endif
public:
CappedFlooredCmsSpreadCoupon(
const Date& paymentDate, Real nominal,
const Date& startDate, const Date& endDate,
Natural fixingDays,
const ext::shared_ptr<SwapSpreadIndex>& index,
Real gearing = 1.0, Spread spread = 0.0,
const Rate cap = Null<Rate>(),
const Rate floor = Null<Rate>(),
const Date& refPeriodStart = Date(),
const Date& refPeriodEnd = Date(),
const DayCounter& dayCounter = DayCounter(),
bool isInArrears = false,
const Date& exCouponDate = Date());
};
%rename (LinearTsrPricerSettings) LinearTsrPricer::Settings;
%feature ("flatnested") Settings;
%shared_ptr(LinearTsrPricer)
class LinearTsrPricer : public CmsCouponPricer {
public:
struct Settings {
Settings();
Settings &withRateBound(const Real lowerRateBound = 0.0001,
const Real upperRateBound = 2.0000);
Settings &withVegaRatio(const Real vegaRatio = 0.01);
Settings &withVegaRatio(const Real vegaRatio,
const Real lowerRateBound,
const Real upperRateBound);
Settings &withPriceThreshold(const Real priceThreshold = 1.0E-8);
Settings &withPriceThreshold(const Real priceThreshold,
const Real lowerRateBound,
const Real upperRateBound);
Settings &withBSStdDevs(const Real stdDevs = 3.0);
Settings &withBSStdDevs(const Real stdDevs,
const Real lowerRateBound,
const Real upperRateBound);
enum Strategy {
RateBound,
VegaRatio,
PriceThreshold,
BSStdDevs
};
};
LinearTsrPricer(
const Handle<SwaptionVolatilityStructure> &swaptionVol,
const Handle<Quote> &meanReversion,
const Handle<YieldTermStructure> &couponDiscountCurve =
Handle<YieldTermStructure>(),
const LinearTsrPricer::Settings &settings =
LinearTsrPricer::Settings());
};
%shared_ptr(CmsSpreadCouponPricer)
class CmsSpreadCouponPricer : public FloatingRateCouponPricer {
private:
CmsSpreadCouponPricer();
public:
Handle<Quote> correlation() const;
void setCorrelation(const Handle<Quote> &correlation = Handle<Quote>());
};
%shared_ptr(LognormalCmsSpreadPricer)
class LognormalCmsSpreadPricer : public CmsSpreadCouponPricer {
public:
LognormalCmsSpreadPricer(
const ext::shared_ptr<CmsCouponPricer>& cmsPricer,
const Handle<Quote> &correlation,
const Handle<YieldTermStructure> &couponDiscountCurve =
Handle<YieldTermStructure>(),
const Size IntegrationPoints = 16,
const ext::optional<VolatilityType> volatilityType = ext::nullopt,
const Real shift1 = Null<Real>(), const Real shift2 = Null<Real>());
Real swapletPrice() const;
Rate swapletRate() const;
Real capletPrice(Rate effectiveCap) const;
Rate capletRate(Rate effectiveCap) const;
Real floorletPrice(Rate effectiveFloor) const;
Rate floorletRate(Rate effectiveFloor) const;
};
%{
using QuantLib::EquityCashFlow;
using QuantLib::EquityCashFlowPricer;
using QuantLib::EquityQuantoCashFlowPricer;
%}
%shared_ptr(EquityCashFlowPricer)
class EquityCashFlowPricer {
private:
EquityCashFlowPricer();
};
void setCouponPricer(const Leg&,
const ext::shared_ptr<EquityCashFlowPricer>&);
%shared_ptr(EquityCashFlow)
class EquityCashFlow : public IndexedCashFlow {
public:
EquityCashFlow(Real notional,
ext::shared_ptr<EquityIndex> index,
const Date& baseDate,
const Date& fixingDate,
const Date& paymentDate,
bool growthOnly = true);
void setPricer(const ext::shared_ptr<EquityCashFlowPricer>&);
};
%shared_ptr(EquityQuantoCashFlowPricer)
class EquityQuantoCashFlowPricer : public EquityCashFlowPricer {
public:
EquityQuantoCashFlowPricer(Handle<YieldTermStructure> quantoCurrencyTermStructure,
Handle<BlackVolTermStructure> equityVolatility,
Handle<BlackVolTermStructure> fxVolatility,
Handle<Quote> correlation);
};
// cash flow vector builders
%{
Leg _FixedRateLeg(const Schedule& schedule,
const DayCounter& dayCount,
const std::vector<Real>& nominals,
const std::vector<Rate>& couponRates,
BusinessDayConvention paymentAdjustment = Following,
const DayCounter& firstPeriodDayCount = DayCounter(),
const Period& exCouponPeriod = Period(),
const Calendar& exCouponCalendar = Calendar(),
BusinessDayConvention exCouponConvention = Unadjusted,
bool exCouponEndOfMonth = false,
const Calendar& paymentCalendar = Calendar(),
const Integer paymentLag = 0,
Compounding comp = Simple,
Frequency freq = Annual) {
return QuantLib::FixedRateLeg(schedule)
.withNotionals(nominals)
.withCouponRates(couponRates, dayCount, comp, freq)
.withPaymentAdjustment(paymentAdjustment)
.withPaymentCalendar(paymentCalendar.empty() ? schedule.calendar() : paymentCalendar)
.withPaymentLag(paymentLag)
.withFirstPeriodDayCounter(firstPeriodDayCount)
.withExCouponPeriod(exCouponPeriod,
exCouponCalendar,
exCouponConvention,
exCouponEndOfMonth);
}
%}
#if !defined(SWIGJAVA) && !defined(SWIGCSHARP)
%feature("kwargs") _FixedRateLeg;
#endif
%rename(FixedRateLeg) _FixedRateLeg;
Leg _FixedRateLeg(const Schedule& schedule,
const DayCounter& dayCount,
const std::vector<Real>& nominals,
const std::vector<Rate>& couponRates,
BusinessDayConvention paymentAdjustment = Following,
const DayCounter& firstPeriodDayCount = DayCounter(),
const Period& exCouponPeriod = Period(),
const Calendar& exCouponCalendar = Calendar(),
BusinessDayConvention exCouponConvention = Unadjusted,
bool exCouponEndOfMonth = false,
const Calendar& paymentCalendar = Calendar(),
Integer paymentLag = 0,
Compounding compounding = Simple,
Frequency compoundingFrequency = Annual);
%{
Leg _IborLeg(const std::vector<Real>& nominals,
const Schedule& schedule,
const ext::shared_ptr<IborIndex>& index,
const DayCounter& paymentDayCounter = DayCounter(),
const BusinessDayConvention paymentConvention = Following,
const std::vector<Natural>& fixingDays = std::vector<Natural>(),
const std::vector<Real>& gearings = std::vector<Real>(),
const std::vector<Spread>& spreads = std::vector<Spread>(),
const std::vector<Rate>& caps = std::vector<Rate>(),
const std::vector<Rate>& floors = std::vector<Rate>(),
bool isInArrears = false,
const Period& exCouponPeriod = Period(),
const Calendar& exCouponCalendar = Calendar(),
BusinessDayConvention exCouponConvention = Unadjusted,
bool exCouponEndOfMonth = false,
const Calendar& paymentCalendar = Calendar(),
const Integer paymentLag = 0,
ext::optional<bool> withIndexedCoupons = ext::nullopt) {
return QuantLib::IborLeg(schedule, index)
.withNotionals(nominals)
.withPaymentDayCounter(paymentDayCounter)
.withPaymentAdjustment(paymentConvention)
.withPaymentCalendar(paymentCalendar.empty() ? schedule.calendar() : paymentCalendar)
.withPaymentLag(paymentLag)
.withFixingDays(fixingDays)
.withGearings(gearings)
.withSpreads(spreads)
.withCaps(caps)
.withFloors(floors)
.inArrears(isInArrears)
.withExCouponPeriod(exCouponPeriod,
exCouponCalendar,
exCouponConvention,
exCouponEndOfMonth)
.withIndexedCoupons(withIndexedCoupons);
}
%}
#if !defined(SWIGJAVA) && !defined(SWIGCSHARP)
%feature("kwargs") _IborLeg;
#endif
%rename(IborLeg) _IborLeg;
Leg _IborLeg(const std::vector<Real>& nominals,
const Schedule& schedule,
const ext::shared_ptr<IborIndex>& index,
const DayCounter& paymentDayCounter = DayCounter(),
const BusinessDayConvention paymentConvention = Following,
const std::vector<Natural>& fixingDays = std::vector<Natural>(),
const std::vector<Real>& gearings = std::vector<Real>(),
const std::vector<Spread>& spreads = std::vector<Spread>(),
const std::vector<Rate>& caps = std::vector<Rate>(),
const std::vector<Rate>& floors = std::vector<Rate>(),
bool isInArrears = false,
const Period& exCouponPeriod = Period(),
const Calendar& exCouponCalendar = Calendar(),
BusinessDayConvention exCouponConvention = Unadjusted,
bool exCouponEndOfMonth = false,
const Calendar& paymentCalendar = Calendar(),
Integer paymentLag = 0,
ext::optional<bool> withIndexedCoupons = ext::nullopt);
%{
Leg _OvernightLeg(const std::vector<Real>& nominals,
const Schedule& schedule,
const ext::shared_ptr<OvernightIndex>& index,
const DayCounter& paymentDayCounter = DayCounter(),
const BusinessDayConvention paymentConvention = Following,
const std::vector<Real>& gearings = std::vector<Real>(),
const std::vector<Spread>& spreads = std::vector<Spread>(),
bool telescopicValueDates = false,
RateAveraging::Type averagingMethod = RateAveraging::Compound,
const Calendar& paymentCalendar = Calendar(),
const Integer paymentLag = 0) {
return QuantLib::OvernightLeg(schedule, index)
.withNotionals(nominals)
.withPaymentDayCounter(paymentDayCounter)
.withPaymentAdjustment(paymentConvention)
.withPaymentCalendar(paymentCalendar.empty() ? schedule.calendar() : paymentCalendar)
.withPaymentLag(paymentLag)
.withGearings(gearings)
.withSpreads(spreads)
.withTelescopicValueDates(telescopicValueDates)
.withAveragingMethod(averagingMethod);
}
%}
#if !defined(SWIGJAVA) && !defined(SWIGCSHARP)
%feature("kwargs") _OvernightLeg;
#endif
%rename(OvernightLeg) _OvernightLeg;
Leg _OvernightLeg(const std::vector<Real>& nominals,
const Schedule& schedule,
const ext::shared_ptr<OvernightIndex>& index,
const DayCounter& paymentDayCounter = DayCounter(),
const BusinessDayConvention paymentConvention = Following,
const std::vector<Real>& gearings = std::vector<Real>(),
const std::vector<Spread>& spreads = std::vector<Spread>(),
bool telescopicValueDates = false,
RateAveraging::Type averagingMethod = RateAveraging::Compound,
const Calendar& paymentCalendar = Calendar(),
Integer paymentLag = 0);
%{
Leg _CmsLeg(const std::vector<Real>& nominals,
const Schedule& schedule,
const ext::shared_ptr<SwapIndex>& index,
const DayCounter& paymentDayCounter = DayCounter(),
const BusinessDayConvention paymentConvention = Following,
const std::vector<Natural>& fixingDays = std::vector<Natural>(),
const std::vector<Real>& gearings = std::vector<Real>(),
const std::vector<Spread>& spreads = std::vector<Spread>(),
const std::vector<Rate>& caps = std::vector<Rate>(),
const std::vector<Rate>& floors = std::vector<Rate>(),
bool isInArrears = false,
const Period& exCouponPeriod = Period(),
const Calendar& exCouponCalendar = Calendar(),
const BusinessDayConvention exCouponConvention = Unadjusted,
bool exCouponEndOfMonth = false) {
return QuantLib::CmsLeg(schedule, index)
.withNotionals(nominals)
.withPaymentDayCounter(paymentDayCounter)
.withPaymentAdjustment(paymentConvention)
.withFixingDays(fixingDays)
.withGearings(gearings)
.withSpreads(spreads)
.withCaps(caps)
.withFloors(floors)
.withExCouponPeriod(exCouponPeriod, exCouponCalendar,
exCouponConvention, exCouponEndOfMonth)
.inArrears(isInArrears);
}
%}
#if !defined(SWIGJAVA) && !defined(SWIGCSHARP)
%feature("kwargs") _CmsLeg;
#endif
%rename(CmsLeg) _CmsLeg;
Leg _CmsLeg(const std::vector<Real>& nominals,
const Schedule& schedule,
const ext::shared_ptr<SwapIndex>& index,
const DayCounter& paymentDayCounter = DayCounter(),
const BusinessDayConvention paymentConvention = Following,
const std::vector<Natural>& fixingDays = std::vector<Natural>(),
const std::vector<Real>& gearings = std::vector<Real>(),
const std::vector<Spread>& spreads = std::vector<Spread>(),
const std::vector<Rate>& caps = std::vector<Rate>(),
const std::vector<Rate>& floors = std::vector<Rate>(),
bool isInArrears = false,
const Period& exCouponPeriod = Period(),
const Calendar& exCouponCalendar = Calendar(),
const BusinessDayConvention exCouponConvention = Unadjusted,
bool exCouponEndOfMonth = false);
%{
Leg _CmsZeroLeg(const std::vector<Real>& nominals,
const Schedule& schedule,
const ext::shared_ptr<SwapIndex>& index,
const DayCounter& paymentDayCounter = DayCounter(),
const BusinessDayConvention paymentConvention = Following,
const std::vector<Natural>& fixingDays = std::vector<Natural>(),
const std::vector<Real>& gearings = std::vector<Real>(),
const std::vector<Spread>& spreads = std::vector<Spread>(),
const std::vector<Rate>& caps = std::vector<Rate>(),
const std::vector<Rate>& floors = std::vector<Rate>(),
const Period& exCouponPeriod = Period(),
const Calendar& exCouponCalendar = Calendar(),
const BusinessDayConvention exCouponConvention = Unadjusted,
bool exCouponEndOfMonth = false) {
return QuantLib::CmsLeg(schedule, index)
.withNotionals(nominals)
.withPaymentDayCounter(paymentDayCounter)
.withPaymentAdjustment(paymentConvention)
.withFixingDays(fixingDays)
.withGearings(gearings)
.withSpreads(spreads)
.withCaps(caps)
.withFloors(floors)
.withExCouponPeriod(exCouponPeriod, exCouponCalendar,
exCouponConvention, exCouponEndOfMonth)
.withZeroPayments();
}
%}
#if !defined(SWIGJAVA) && !defined(SWIGCSHARP)
%feature("kwargs") _CmsZeroLeg;
#endif
%rename(CmsZeroLeg) _CmsZeroLeg;
Leg _CmsZeroLeg(const std::vector<Real>& nominals,
const Schedule& schedule,
const ext::shared_ptr<SwapIndex>& index,
const DayCounter& paymentDayCounter = DayCounter(),
const BusinessDayConvention paymentConvention = Following,
const std::vector<Natural>& fixingDays = std::vector<Natural>(),
const std::vector<Real>& gearings = std::vector<Real>(),
const std::vector<Spread>& spreads = std::vector<Spread>(),
const std::vector<Rate>& caps = std::vector<Rate>(),
const std::vector<Rate>& floors = std::vector<Rate>(),
const Period& exCouponPeriod = Period(),
const Calendar& exCouponCalendar = Calendar(),
const BusinessDayConvention exCouponConvention = Unadjusted,
bool exCouponEndOfMonth = false);
%{
Leg _CmsSpreadLeg(const std::vector<Real>& nominals,
const Schedule& schedule,
const ext::shared_ptr<SwapSpreadIndex>& index,
const DayCounter& paymentDayCounter = DayCounter(),
const BusinessDayConvention paymentConvention = Following,
const std::vector<Natural>& fixingDays = std::vector<Natural>(),
const std::vector<Real>& gearings = std::vector<Real>(),
const std::vector<Spread>& spreads = std::vector<Spread>(),
const std::vector<Rate>& caps = std::vector<Rate>(),
const std::vector<Rate>& floors = std::vector<Rate>(),
bool isInArrears = false) {
return QuantLib::CmsSpreadLeg(schedule, index)
.withNotionals(nominals)
.withPaymentDayCounter(paymentDayCounter)
.withPaymentAdjustment(paymentConvention)
.withFixingDays(fixingDays)
.withGearings(gearings)
.withSpreads(spreads)
.withCaps(caps)
.withFloors(floors)
.inArrears(isInArrears);
}
%}
#if !defined(SWIGJAVA) && !defined(SWIGCSHARP)
%feature("kwargs") _CmsSpreadLeg;
#endif
%rename(CmsSpreadLeg) _CmsSpreadLeg;
Leg _CmsSpreadLeg(const std::vector<Real>& nominals,
const Schedule& schedule,
const ext::shared_ptr<SwapSpreadIndex>& index,
const DayCounter& paymentDayCounter = DayCounter(),
const BusinessDayConvention paymentConvention = Following,
const std::vector<Natural>& fixingDays = std::vector<Natural>(),
const std::vector<Real>& gearings = std::vector<Real>(),
const std::vector<Spread>& spreads = std::vector<Spread>(),
const std::vector<Rate>& caps = std::vector<Rate>(),
const std::vector<Rate>& floors = std::vector<Rate>(),
bool isInArrears = false);
%{
Leg _SubPeriodsLeg(const std::vector<Real>& nominals,
const Schedule& schedule,
const ext::shared_ptr<IborIndex>& index,
const DayCounter& paymentDayCounter = DayCounter(),
const BusinessDayConvention paymentConvention = Following,
const Calendar& paymentCalendar = Calendar(),
Integer paymentLag = 0,
const std::vector<Natural>& fixingDays = std::vector<Natural>(),
const std::vector<Real>& gearings = std::vector<Real>(),
const std::vector<Spread>& couponSpreads = std::vector<Spread>(),
const std::vector<Spread>& rateSpreads = std::vector<Spread>(),
const Period& exCouponPeriod = Period(),
const Calendar& exCouponCalendar = Calendar(),
BusinessDayConvention exCouponConvention = Unadjusted,
bool exCouponEndOfMonth = false,
RateAveraging::Type averagingMethod = RateAveraging::Compound) {
return QuantLib::SubPeriodsLeg(schedule, index)
.withNotionals(nominals)
.withPaymentDayCounter(paymentDayCounter)
.withPaymentAdjustment(paymentConvention)
.withPaymentCalendar(paymentCalendar.empty() ? schedule.calendar() : paymentCalendar)
.withPaymentLag(paymentLag)
.withFixingDays(fixingDays)
.withGearings(gearings)
.withCouponSpreads(couponSpreads)
.withRateSpreads(rateSpreads)
.withExCouponPeriod(exCouponPeriod,
exCouponCalendar,
exCouponConvention,
exCouponEndOfMonth)
.withAveragingMethod(averagingMethod);
}
%}
#if !defined(SWIGJAVA) && !defined(SWIGCSHARP)
%feature("kwargs") _SubPeriodsLeg;
#endif
%rename(SubPeriodsLeg) _SubPeriodsLeg;
Leg _SubPeriodsLeg(const std::vector<Real>& nominals,
const Schedule& schedule,
const ext::shared_ptr<IborIndex>& index,
const DayCounter& paymentDayCounter = DayCounter(),
const BusinessDayConvention paymentConvention = Following,
const Calendar& paymentCalendar = Calendar(),
Integer paymentLag = 0,
const std::vector<Natural>& fixingDays = std::vector<Natural>(),
const std::vector<Real>& gearings = std::vector<Real>(),