QuantLib: a free/open-source library for quantitative finance
fully annotated source code - version 1.34
Loading...
Searching...
No Matches
cashflowvectors.cpp
Go to the documentation of this file.
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
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(spreads, i, 0.0);
41 Rate floor = get(floors, i, Null<Rate>());
42 if (floor!=Null<Rate>())
43 result = std::max(floor, result);
44 Rate cap = get(caps, i, Null<Rate>());
45 if (cap!=Null<Rate>())
46 result = std::min(cap, 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(caps, i, Null<Rate>()) == Null<Rate>()) &&
54 (get(floors, i, Null<Rate>()) == Null<Rate>());
55 }
56
57 }
58
59}
Floating rate coupon with additional cap/floor.
Cash flow vector builders.
template class providing a null value for a given type.
Definition: null.hpp:76
Coupon paying a fixed annual rate.
Real Rate
interest rates
Definition: types.hpp:70
std::size_t Size
size of a container
Definition: types.hpp:58
base class for Inter-Bank-Offered-Rate indexes
T get(const std::vector< T > &v, Size i, U defaultValue)
Definition: vectors.hpp:35
Rate effectiveFixedRate(const std::vector< Spread > &spreads, const std::vector< Rate > &caps, const std::vector< Rate > &floors, Size i)
bool noOption(const std::vector< Rate > &caps, const std::vector< Rate > &floors, Size i)
Definition: any.hpp:35
range-accrual coupon
date schedule