diff --git a/QuantLib.vcxproj b/QuantLib.vcxproj index a0bbb274750..c9e69684b9d 100644 --- a/QuantLib.vcxproj +++ b/QuantLib.vcxproj @@ -534,6 +534,7 @@ + @@ -1933,6 +1934,7 @@ + @@ -1951,7 +1953,6 @@ - diff --git a/QuantLib.vcxproj.filters b/QuantLib.vcxproj.filters index 8b09bc52e18..001b00b67ee 100644 --- a/QuantLib.vcxproj.filters +++ b/QuantLib.vcxproj.filters @@ -561,6 +561,9 @@ cashflows + + cashflows + cashflows @@ -4544,6 +4547,9 @@ cashflows + + cashflows + cashflows @@ -6590,9 +6596,6 @@ experimental\averageois - - experimental\averageois - experimental\averageois diff --git a/ql/CMakeLists.txt b/ql/CMakeLists.txt index e000e1c276c..ca7950156d0 100644 --- a/ql/CMakeLists.txt +++ b/ql/CMakeLists.txt @@ -25,6 +25,7 @@ set(QL_SOURCES cashflows/inflationcouponpricer.cpp cashflows/lineartsrpricer.cpp cashflows/overnightindexedcoupon.cpp + cashflows/overnightindexedcouponpricer.cpp cashflows/rangeaccrual.cpp cashflows/replication.cpp cashflows/simplecashflow.cpp @@ -49,7 +50,6 @@ set(QL_SOURCES experimental/asian/analytic_discr_geom_av_price_heston.cpp experimental/averageois/arithmeticaverageois.cpp experimental/averageois/arithmeticoisratehelper.cpp - experimental/averageois/averageoiscouponpricer.cpp experimental/averageois/makearithmeticaverageois.cpp experimental/barrieroption/mcdoublebarrierengine.cpp experimental/barrieroption/discretizeddoublebarrieroption.cpp @@ -961,6 +961,7 @@ set(QL_HEADERS cashflows/inflationcouponpricer.hpp cashflows/lineartsrpricer.hpp cashflows/overnightindexedcoupon.hpp + cashflows/overnightindexedcouponpricer.hpp cashflows/rangeaccrual.hpp cashflows/rateaveraging.hpp cashflows/replication.hpp diff --git a/ql/cashflows/Makefile.am b/ql/cashflows/Makefile.am index 5320f812c93..f45d7c0274b 100644 --- a/ql/cashflows/Makefile.am +++ b/ql/cashflows/Makefile.am @@ -29,6 +29,7 @@ this_include_HEADERS = \ inflationcouponpricer.hpp \ lineartsrpricer.hpp \ overnightindexedcoupon.hpp \ + overnightindexedcouponpricer.hpp \ rangeaccrual.hpp \ rateaveraging.hpp \ replication.hpp \ @@ -64,6 +65,7 @@ cpp_files = \ inflationcouponpricer.cpp \ lineartsrpricer.cpp \ overnightindexedcoupon.cpp \ + overnightindexedcouponpricer.cpp \ rangeaccrual.cpp \ replication.cpp \ simplecashflow.cpp \ diff --git a/ql/cashflows/all.hpp b/ql/cashflows/all.hpp index 59ee0ab2e11..ef579427e71 100644 --- a/ql/cashflows/all.hpp +++ b/ql/cashflows/all.hpp @@ -26,6 +26,7 @@ #include #include #include +#include #include #include #include diff --git a/ql/cashflows/overnightindexedcoupon.cpp b/ql/cashflows/overnightindexedcoupon.cpp index db1e8019d4c..0382671ad1d 100644 --- a/ql/cashflows/overnightindexedcoupon.cpp +++ b/ql/cashflows/overnightindexedcoupon.cpp @@ -22,7 +22,7 @@ */ #include -#include +#include #include #include #include @@ -34,169 +34,6 @@ using std::vector; namespace QuantLib { namespace { - - Size determineNumberOfFixings(const vector& interestDates, - const Date& date, - bool applyObservationShift) { - Size n = - std::lower_bound(interestDates.begin(), interestDates.end(), date) - interestDates.begin(); - // When using the observation shift, it may happen that - // that the end of accrual period will fall later than the last - // interest date. In which case, n will be equal to the number of - // interest dates, while we know that the number of fixing dates is - // always one less than the number of interest dates. - return n == interestDates.size() && applyObservationShift ? n - 1 : n; - } - - class OvernightIndexedCouponPricer : public FloatingRateCouponPricer { - public: - void initialize(const FloatingRateCoupon& coupon) override { - coupon_ = dynamic_cast(&coupon); - QL_ENSURE(coupon_, "wrong coupon type"); - } - - Rate averageRate(const Date& date) const { - - const Date today = Settings::instance().evaluationDate(); - - const ext::shared_ptr index = - ext::dynamic_pointer_cast(coupon_->index()); - const auto& pastFixings = IndexManager::instance().getHistory(index->name()); - - const vector& fixingDates = coupon_->fixingDates(); - const vector& valueDates = coupon_->valueDates(); - const vector& interestDates = coupon_->interestDates(); - const vector