/src/quantlib/ql/cashflows/cashflowvectors.cpp
Line | Count | Source |
1 | | /* -*- mode: c++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ |
2 | | |
3 | | /* |
4 | | Copyright (C) 2000, 2001, 2002, 2003 RiskMap srl |
5 | | Copyright (C) 2003, 2004, 2005 StatPro Italia srl |
6 | | Copyright (C) 2006, 2007 Cristina Duminuco |
7 | | Copyright (C) 2006, 2007 Giorgio Facchinetti |
8 | | Copyright (C) 2006 Mario Pucci |
9 | | Copyright (C) 2007 Ferdinando Ametrano |
10 | | |
11 | | This file is part of QuantLib, a free-software/open-source library |
12 | | for financial quantitative analysts and developers - http://quantlib.org/ |
13 | | |
14 | | QuantLib is free software: you can redistribute it and/or modify it |
15 | | under the terms of the QuantLib license. You should have received a |
16 | | copy of the license along with this program; if not, please email |
17 | | <quantlib-dev@lists.sf.net>. The license is also available online at |
18 | | <https://www.quantlib.org/license.shtml>. |
19 | | |
20 | | This program is distributed in the hope that it will be useful, but WITHOUT |
21 | | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS |
22 | | FOR A PARTICULAR PURPOSE. See the license for more details. |
23 | | */ |
24 | | |
25 | | #include <ql/cashflows/cashflowvectors.hpp> |
26 | | #include <ql/cashflows/fixedratecoupon.hpp> |
27 | | #include <ql/cashflows/capflooredcoupon.hpp> |
28 | | #include <ql/cashflows/rangeaccrual.hpp> |
29 | | #include <ql/indexes/iborindex.hpp> |
30 | | #include <ql/time/schedule.hpp> |
31 | | |
32 | | namespace QuantLib::detail { |
33 | | |
34 | | Rate effectiveFixedRate(const std::vector<Spread>& spreads, |
35 | | const std::vector<Rate>& caps, |
36 | | const std::vector<Rate>& floors, |
37 | 0 | Size i) { |
38 | 0 | Rate result = get(spreads, i, 0.0); |
39 | 0 | Rate floor = get(floors, i, Null<Rate>()); |
40 | 0 | if (floor!=Null<Rate>()) |
41 | 0 | result = std::max(floor, result); |
42 | 0 | Rate cap = get(caps, i, Null<Rate>()); |
43 | 0 | if (cap!=Null<Rate>()) |
44 | 0 | result = std::min(cap, result); |
45 | 0 | return result; |
46 | 0 | } |
47 | | |
48 | | bool noOption(const std::vector<Rate>& caps, |
49 | | const std::vector<Rate>& floors, |
50 | 0 | Size i) { |
51 | 0 | return (get(caps, i, Null<Rate>()) == Null<Rate>()) && |
52 | 0 | (get(floors, i, Null<Rate>()) == Null<Rate>()); |
53 | 0 | } |
54 | | |
55 | | } |