QuantLib: a free/open-source library for quantitative finance
fully annotated source code - version 1.34
Loading...
Searching...
No Matches
assetswap.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) 2006, 2007 Chiara Fornarola
5 Copyright (C) 2007, 2009, 2011 Ferdinando Ametrano
6 Copyright (C) 2007, 2009 StatPro Italia srl
7
8 This file is part of QuantLib, a free-software/open-source library
9 for financial quantitative analysts and developers - http://quantlib.org/
10
11 QuantLib is free software: you can redistribute it and/or modify it
12 under the terms of the QuantLib license. You should have received a
13 copy of the license along with this program; if not, please email
14 <quantlib-dev@lists.sf.net>. The license is also available online at
15 <http://quantlib.org/license.shtml>.
16
17 This program is distributed in the hope that it will be useful, but WITHOUT
18 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
19 FOR A PARTICULAR PURPOSE. See the license for more details.
20*/
21
22/*! \file assetswap.hpp
23 \brief Bullet bond vs Libor swap
24*/
25
26#ifndef quantlib_asset_swap_hpp
27#define quantlib_asset_swap_hpp
28
31#include <ql/time/schedule.hpp>
33
34namespace QuantLib {
35
36 class IborIndex;
37
38 //! Bullet bond vs %Libor swap
39 /*! for mechanics of par asset swap and market asset swap, refer to
40 "Introduction to Asset Swap", Lehman Brothers European Fixed
41 Income Research - January 2000, D. O'Kane
42
43 \ingroup instruments
44
45 \warning bondCleanPrice must be the (forward) price at the
46 floatSchedule start date
47
48 \bug fair prices are not calculated correctly when using
49 indexed coupons.
50 */
51 class AssetSwap : public Swap {
52 public:
53 class arguments;
54 class results;
55
57 ext::shared_ptr<Bond> bond,
58 Real bondCleanPrice,
59 const ext::shared_ptr<IborIndex>& iborIndex,
61 Schedule floatSchedule = Schedule(),
62 const DayCounter& floatingDayCount = DayCounter(),
63 bool parAssetSwap = true);
64
65 AssetSwap(bool parAssetSwap,
66 ext::shared_ptr<Bond> bond,
67 Real bondCleanPrice,
69 Real gearing,
70 const ext::shared_ptr<IborIndex>& iborIndex,
71 Spread spread = 0.0,
72 const DayCounter& floatingDayCount = DayCounter(),
73 Date dealMaturity = Date(),
74 bool payBondCoupon = false);
75 // results
76 Spread fairSpread() const;
77 Real floatingLegBPS() const;
78 Real floatingLegNPV() const;
79 Real fairCleanPrice() const;
81 // inspectors
82 bool parSwap() const { return parSwap_; }
83 Spread spread() const { return spread_; }
84 Real cleanPrice() const { return bondCleanPrice_; }
86 const ext::shared_ptr<Bond>& bond() const { return bond_; }
87 bool payBondCoupon() const { return (payer_[0] == -1.0); }
88 const Leg& bondLeg() const { return legs_[0]; }
89 const Leg& floatingLeg() const { return legs_[1]; }
90 // other
91 void setupArguments(PricingEngine::arguments* args) const override;
92 void fetchResults(const PricingEngine::results*) const override;
93
94 private:
95 void setupExpired() const override;
96 ext::shared_ptr<Bond> bond_;
101 // results
104 };
105
106
107 //! %Arguments for asset swap calculation
109 public:
110 arguments() = default;
111 std::vector<Date> fixedResetDates;
112 std::vector<Date> fixedPayDates;
113 std::vector<Real> fixedCoupons;
114 std::vector<Time> floatingAccrualTimes;
115 std::vector<Date> floatingResetDates;
116 std::vector<Date> floatingFixingDates;
117 std::vector<Date> floatingPayDates;
118 std::vector<Spread> floatingSpreads;
119 void validate() const override;
120 };
121
122 //! %Results from simple swap calculation
124 public:
127 void reset() override;
128 };
129
130}
131
132#endif
concrete bond class
Arguments for asset swap calculation
Definition: assetswap.hpp:108
std::vector< Date > floatingResetDates
Definition: assetswap.hpp:115
std::vector< Spread > floatingSpreads
Definition: assetswap.hpp:118
std::vector< Date > floatingFixingDates
Definition: assetswap.hpp:116
std::vector< Date > fixedPayDates
Definition: assetswap.hpp:112
std::vector< Date > fixedResetDates
Definition: assetswap.hpp:111
void validate() const override
Definition: assetswap.cpp:402
std::vector< Time > floatingAccrualTimes
Definition: assetswap.hpp:114
std::vector< Real > fixedCoupons
Definition: assetswap.hpp:113
std::vector< Date > floatingPayDates
Definition: assetswap.hpp:117
Results from simple swap calculation
Definition: assetswap.hpp:123
Bullet bond vs Libor swap.
Definition: assetswap.hpp:51
Real cleanPrice() const
Definition: assetswap.hpp:84
const ext::shared_ptr< Bond > & bond() const
Definition: assetswap.hpp:86
Real fairCleanPrice() const
Definition: assetswap.cpp:345
bool parSwap() const
Definition: assetswap.hpp:82
const Leg & floatingLeg() const
Definition: assetswap.hpp:89
Spread fairSpread() const
Definition: assetswap.cpp:318
Real floatingLegBPS() const
Definition: assetswap.cpp:331
Real fairNonParRepayment() const
Definition: assetswap.cpp:367
Real nonParRepayment() const
Definition: assetswap.hpp:85
void setupArguments(PricingEngine::arguments *args) const override
Definition: assetswap.cpp:272
const Leg & bondLeg() const
Definition: assetswap.hpp:88
ext::shared_ptr< Bond > bond_
Definition: assetswap.hpp:96
void setupExpired() const override
Definition: assetswap.cpp:381
Real floatingLegNPV() const
Definition: assetswap.cpp:338
void fetchResults(const PricingEngine::results *) const override
Definition: assetswap.cpp:388
Spread spread() const
Definition: assetswap.hpp:83
bool payBondCoupon() const
Definition: assetswap.hpp:87
Concrete date class.
Definition: date.hpp:125
day counter class
Definition: daycounter.hpp:44
Payment schedule.
Definition: schedule.hpp:40
Interest rate swap.
Definition: swap.hpp:41
std::vector< Leg > legs_
Definition: swap.hpp:133
std::vector< Real > payer_
Definition: swap.hpp:134
day counter class
QL_REAL Real
real number
Definition: types.hpp:50
Real Spread
spreads on interest rates
Definition: types.hpp:74
Definition: any.hpp:35
std::vector< ext::shared_ptr< CashFlow > > Leg
Sequence of cash-flows.
Definition: cashflow.hpp:78
date schedule
Interest rate swap.