Logo
Fully annotated reference manual - version 1.8.12
Loading...
Searching...
No Matches
cashflows.cpp
Go to the documentation of this file.
1/*
2 Copyright (C) 2020 Quaternion Risk Management Ltd
3 All rights reserved.
4
5 This file is part of ORE, a free-software/open-source library
6 for transparent pricing and risk analysis - http://opensourcerisk.org
7
8 ORE is free software: you can redistribute it and/or modify it
9 under the terms of the Modified BSD License. You should have received a
10 copy of the license along with this program.
11 The license is also available online at <http://opensourcerisk.org>
12
13 This program is distributed on the basis that it will form a useful
14 contribution to risk analytics and model standardisation, but WITHOUT
15 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
16 FITNESS FOR A PARTICULAR PURPOSE. See the license for more details.
17*/
18
20#include <iostream>
21
22using QuantLib::Date;
23using QuantLib::Rate;
24using QuantLib::Real;
25using QuantLib::Time;
26
27namespace QuantExt {
28
29Real getOisAtmLevel(const QuantLib::ext::shared_ptr<OvernightIndex>& on, const Date& fixingDate,
30 const Period& rateComputationPeriod) {
31 Date today = Settings::instance().evaluationDate();
32 Date start = on->valueDate(fixingDate);
33 Date end = on->fixingCalendar().advance(start, rateComputationPeriod);
34 Date adjStart = std::max(start, today);
35 Date adjEnd = std::max(adjStart + 1, end);
36 OvernightIndexedCoupon cpn(end, 1.0, adjStart, adjEnd, on);
37 cpn.setPricer(QuantLib::ext::make_shared<OvernightIndexedCouponPricer>());
38 return cpn.rate();
39}
40
41Real getBMAAtmLevel(const QuantLib::ext::shared_ptr<BMAIndex>& bma, const Date& fixingDate,
42 const Period& rateComputationPeriod) {
43 Date today = Settings::instance().evaluationDate();
44 Date start = bma->fixingCalendar().advance(fixingDate, 1 * Days);
45 Date end = bma->fixingCalendar().advance(start, rateComputationPeriod);
46 Date adjStart = std::max(start, today);
47 Date adjEnd = std::max(adjStart + 1, end);
48 AverageBMACoupon cpn(end, 1.0, adjStart, adjEnd, bma);
49 return cpn.rate();
50}
51
52} // namespace QuantExt
Real getOisAtmLevel(const QuantLib::ext::shared_ptr< OvernightIndex > &on, const Date &fixingDate, const Period &rateComputationPeriod)
Definition: cashflows.cpp:29
Real getBMAAtmLevel(const QuantLib::ext::shared_ptr< BMAIndex > &bma, const Date &fixingDate, const Period &rateComputationPeriod)
Definition: cashflows.cpp:41
some cashflow related utilities.