QuantLib: a free/open-source library for quantitative finance
fully annotated source code - version 1.34
Loading...
Searching...
No Matches
irregularswap.hpp
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, 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
23/*! \file irregularswap.hpp
24 \brief Irregular fixed-rate vs Libor swap
25*/
26
27#ifndef quantlib_irregular_swap_hpp
28#define quantlib_irregular_swap_hpp
29
34#include <ql/time/schedule.hpp>
35
36namespace QuantLib {
37
38 class IborIndex;
39
40 //! Irregular swap: fixed vs floating leg
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);
50 //! \name Inspectors
51 //@{
52 Type type() const;
53
54 const Leg& fixedLeg() const;
55 const Leg& floatingLeg() const;
56 //@}
57
58 //! \name Results
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;
67 //@}
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
82 //! %Arguments for irregular-swap calculation
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
105 //! %Results from irregular-swap calculation
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
day counter class
Coupon paying a fixed annual rate.
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
Coupon paying a Libor-type index.
Definition: any.hpp:35
std::vector< ext::shared_ptr< CashFlow > > Leg
Sequence of cash-flows.
Definition: cashflow.hpp:78
date schedule
Interest rate swap.