QuantLib: a free/open-source library for quantitative finance
Fully annotated sources - version 1.32
Loading...
Searching...
No Matches
irregularswap.hpp
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, 2006, 2007 StatPro Italia srl
6 Copyright (C) 2006, 2008 Ferdinando Ametrano
7 Copyright (C) 2010 Andre Miemiec
8
9 This file is part of QuantLib, a free-software/open-source library
10 for financial quantitative analysts and developers - http://quantlib.org/
11
12 QuantLib is free software: you can redistribute it and/or modify it
13 under the terms of the QuantLib license. You should have received a
14 copy of the license along with this program; if not, please email
15 <quantlib-dev@lists.sf.net>. The license is also available online at
16 <http://quantlib.org/license.shtml>.
17
18 This program is distributed in the hope that it will be useful, but WITHOUT
19 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
20 FOR A PARTICULAR PURPOSE. See the license for more details.
21*/
22
27#ifndef quantlib_irregular_swap_hpp
28#define quantlib_irregular_swap_hpp
29
30#include <ql/cashflows/fixedratecoupon.hpp>
31#include <ql/cashflows/iborcoupon.hpp>
32#include <ql/instruments/swap.hpp>
33#include <ql/time/daycounter.hpp>
34#include <ql/time/schedule.hpp>
35
36namespace QuantLib {
37
38 class IborIndex;
39
41 class IrregularSwap : public Swap {
42 public:
43 class arguments;
44 class results;
45 class engine;
47 Type type,
48 const Leg& fixLeg,
49 const Leg& floatLeg);
51
52 Type type() const;
53
54 const Leg& fixedLeg() const;
55 const Leg& floatingLeg() const;
57
59
60 Real fixedLegBPS() const;
61 Real fixedLegNPV() const;
62 Rate fairRate() const;
63
64 Real floatingLegBPS() const;
65 Real floatingLegNPV() const;
66 Spread fairSpread() const;
68 // other
69 void setupArguments(PricingEngine::arguments* args) const override;
70 void fetchResults(const PricingEngine::results*) const override;
71
72 private:
73 void setupExpired() const override;
75
76 // results
77 mutable Rate fairRate_;
79 };
80
81
84 public:
85 arguments() = default;
87
88
89 std::vector<Date> fixedResetDates;
90 std::vector<Date> fixedPayDates;
91 std::vector<Real> fixedCoupons;
92 std::vector<Real> fixedNominals;
93
94 std::vector<Date> floatingResetDates;
95 std::vector<Date> floatingFixingDates;
96 std::vector<Date> floatingPayDates;
97 std::vector<Time> floatingAccrualTimes;
98 std::vector<Real> floatingNominals;
99 std::vector<Spread> floatingSpreads;
100 std::vector<Real> floatingCoupons;
101
102 void validate() const override;
103 };
104
107 public:
110 void reset() override;
111 };
112
113 class IrregularSwap::engine : public GenericEngine<IrregularSwap::arguments,
114 IrregularSwap::results> {};
115
116
117 // inline definitions
118
120 return type_;
121 }
122
123 inline const Leg& IrregularSwap::fixedLeg() const {
124 return legs_[0];
125 }
126
127 inline const Leg& IrregularSwap::floatingLeg() const {
128 return legs_[1];
129 }
130
131}
132
133#endif
template base class for option pricing engines
Arguments for irregular-swap calculation
std::vector< Date > floatingResetDates
std::vector< Real > floatingNominals
std::vector< Spread > floatingSpreads
std::vector< Date > floatingFixingDates
std::vector< Time > floatingAccrualTimes
std::vector< Date > floatingPayDates
Results from irregular-swap calculation
Irregular swap: fixed vs floating leg.
const Leg & floatingLeg() const
void setupArguments(PricingEngine::arguments *args) const override
const Leg & fixedLeg() const
void setupExpired() const override
void fetchResults(const PricingEngine::results *) const override
Interest rate swap.
Definition: swap.hpp:41
std::vector< Leg > legs_
Definition: swap.hpp:133
QL_REAL Real
real number
Definition: types.hpp:50
Real Spread
spreads on interest rates
Definition: types.hpp:74
Real Rate
interest rates
Definition: types.hpp:70
Definition: any.hpp:35
std::vector< ext::shared_ptr< CashFlow > > Leg
Sequence of cash-flows.
Definition: cashflow.hpp:78