QuantLib: a free/open-source library for quantitative finance
fully annotated source code - version 1.38
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
56 /*! If the passed iborIndex is an overnight rate such as
57 SOFR, ESTR or SONIA, the floatSchedule argument is
58 required and will be used to build overnight-indexed
59 coupons.
60 */
62 ext::shared_ptr<Bond> bond,
63 Real bondCleanPrice,
64 const ext::shared_ptr<IborIndex>& iborIndex,
66 Schedule floatSchedule = Schedule(),
67 const DayCounter& floatingDayCount = DayCounter(),
68 bool parAssetSwap = true,
69 Real gearing = 1.0,
71 Date dealMaturity = Date());
72
73 /*! \deprecated Use the other overload.
74 Deprecated in version 1.37.
75 */
76 [[deprecated("Use the other overload")]]
77 AssetSwap(bool parAssetSwap,
78 ext::shared_ptr<Bond> bond,
79 Real bondCleanPrice,
81 Real gearing,
82 const ext::shared_ptr<IborIndex>& iborIndex,
83 Spread spread = 0.0,
84 const DayCounter& floatingDayCount = DayCounter(),
85 Date dealMaturity = Date(),
86 bool payBondCoupon = false);
87
88 // results
89 Spread fairSpread() const;
90 Real floatingLegBPS() const;
91 Real floatingLegNPV() const;
92 Real fairCleanPrice() const;
94 // inspectors
95 bool parSwap() const { return parSwap_; }
96 Spread spread() const { return spread_; }
97 Real cleanPrice() const { return bondCleanPrice_; }
99 const ext::shared_ptr<Bond>& bond() const { return bond_; }
100 bool payBondCoupon() const { return (payer_[0] == -1.0); }
101 const Leg& bondLeg() const { return legs_[0]; }
102 const Leg& floatingLeg() const { return legs_[1]; }
103 // other
104 void setupArguments(PricingEngine::arguments* args) const override;
105 void fetchResults(const PricingEngine::results*) const override;
106
107 private:
108 void setupExpired() const override;
109 ext::shared_ptr<Bond> bond_;
114 // results
117 };
118
119
120 //! %Arguments for asset swap calculation
122 public:
123 arguments() = default;
124 std::vector<Date> fixedResetDates;
125 std::vector<Date> fixedPayDates;
126 std::vector<Real> fixedCoupons;
127 std::vector<Time> floatingAccrualTimes;
128 std::vector<Date> floatingResetDates;
129 std::vector<Date> floatingFixingDates;
130 std::vector<Date> floatingPayDates;
131 std::vector<Spread> floatingSpreads;
132 void validate() const override;
133 };
134
135 //! %Results from simple swap calculation
137 public:
140 void reset() override;
141 };
142
143}
144
145#endif
concrete bond class
Arguments for asset swap calculation
Definition: assetswap.hpp:121
std::vector< Date > floatingResetDates
Definition: assetswap.hpp:128
std::vector< Spread > floatingSpreads
Definition: assetswap.hpp:131
std::vector< Date > floatingFixingDates
Definition: assetswap.hpp:129
std::vector< Date > fixedPayDates
Definition: assetswap.hpp:125
std::vector< Date > fixedResetDates
Definition: assetswap.hpp:124
void validate() const override
Definition: assetswap.cpp:334
std::vector< Time > floatingAccrualTimes
Definition: assetswap.hpp:127
std::vector< Real > fixedCoupons
Definition: assetswap.hpp:126
std::vector< Date > floatingPayDates
Definition: assetswap.hpp:130
Results from simple swap calculation
Definition: assetswap.hpp:136
Bullet bond vs Libor swap.
Definition: assetswap.hpp:51
Real cleanPrice() const
Definition: assetswap.hpp:97
const ext::shared_ptr< Bond > & bond() const
Definition: assetswap.hpp:99
Real fairCleanPrice() const
Definition: assetswap.cpp:277
bool parSwap() const
Definition: assetswap.hpp:95
const Leg & floatingLeg() const
Definition: assetswap.hpp:102
Spread fairSpread() const
Definition: assetswap.cpp:250
Real floatingLegBPS() const
Definition: assetswap.cpp:263
Real fairNonParRepayment() const
Definition: assetswap.cpp:299
Real nonParRepayment() const
Definition: assetswap.hpp:98
void setupArguments(PricingEngine::arguments *args) const override
Definition: assetswap.cpp:204
const Leg & bondLeg() const
Definition: assetswap.hpp:101
ext::shared_ptr< Bond > bond_
Definition: assetswap.hpp:109
void setupExpired() const override
Definition: assetswap.cpp:313
Real floatingLegNPV() const
Definition: assetswap.cpp:270
void fetchResults(const PricingEngine::results *) const override
Definition: assetswap.cpp:320
Spread spread() const
Definition: assetswap.hpp:96
bool payBondCoupon() const
Definition: assetswap.hpp:100
Concrete date class.
Definition: date.hpp:125
day counter class
Definition: daycounter.hpp:44
template class providing a null value for a given type.
Definition: null.hpp:59
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:37
std::vector< ext::shared_ptr< CashFlow > > Leg
Sequence of cash-flows.
Definition: cashflow.hpp:78
date schedule
Interest rate swap.