[go: up one dir, main page]

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 <http://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
32namespace QuantLib {
33
34 namespace detail {
35
36 Rate effectiveFixedRate(const std::vector<Spread>& spreads,
37 const std::vector<Rate>& caps,
38 const std::vector<Rate>& floors,
39 Size i) {
40 Rate result = get(v: spreads, i, defaultValue: 0.0);
41 Rate floor = get(v: floors, i, defaultValue: Null<Rate>());
42 if (floor!=Null<Rate>())
43 result = std::max(a: floor, b: result);
44 Rate cap = get(v: caps, i, defaultValue: Null<Rate>());
45 if (cap!=Null<Rate>())
46 result = std::min(a: cap, b: result);
47 return result;
48 }
49
50 bool noOption(const std::vector<Rate>& caps,
51 const std::vector<Rate>& floors,
52 Size i) {
53 return (get(v: caps, i, defaultValue: Null<Rate>()) == Null<Rate>()) &&
54 (get(v: floors, i, defaultValue: Null<Rate>()) == Null<Rate>());
55 }
56
57 }
58
59}
60

source code of quantlib/ql/cashflows/cashflowvectors.cpp