Logo
Fully annotated reference manual - version 1.8.12
Loading...
Searching...
No Matches
averageois.hpp
Go to the documentation of this file.
1/*
2 Copyright (C) 2016 Quaternion Risk Management Ltd
3 All rights reserved.
4
5 This file is part of ORE, a free-software/open-source library
6 for transparent pricing and risk analysis - http://opensourcerisk.org
7
8 ORE is free software: you can redistribute it and/or modify it
9 under the terms of the Modified BSD License. You should have received a
10 copy of the license along with this program.
11 The license is also available online at <http://opensourcerisk.org>
12
13 This program is distributed on the basis that it will form a useful
14 contribution to risk analytics and model standardisation, but WITHOUT
15 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
16 FITNESS FOR A PARTICULAR PURPOSE. See the license for more details.
17*/
18
19/*! \file averageois.hpp
20 \brief Swap of arithmetic average overnight index against fixed
21
22 \ingroup instruments
23*/
24
25#ifndef quantext_average_ois_hpp
26#define quantext_average_ois_hpp
27
28#include <boost/make_shared.hpp>
29
30#include <ql/indexes/iborindex.hpp>
31#include <ql/instruments/swap.hpp>
32#include <ql/time/daycounter.hpp>
33#include <ql/time/schedule.hpp>
34
36
37namespace QuantExt {
38using namespace QuantLib;
39
40//! Average overnight index swap
41/*! Swap with first leg fixed and the second
42 leg being an arithmetic average overnight index.
43
44 \ingroup instruments
45*/
46class AverageOIS : public Swap {
47public:
48 //! Receiver (Payer) means receive (pay) fixed.
49 enum Type { Receiver = -1, Payer = 1 };
50
51 //! Arithmetic average ON leg vs. fixed leg constructor.
52 AverageOIS(Type type, Real nominal, const Schedule& fixedSchedule, Rate fixedRate,
53 const DayCounter& fixedDayCounter, BusinessDayConvention fixedPaymentAdjustment,
54 const Calendar& fixedPaymentCalendar, const Schedule& onSchedule,
55 const QuantLib::ext::shared_ptr<OvernightIndex>& overnightIndex, BusinessDayConvention onPaymentAdjustment,
56 const Calendar& onPaymentCalendar, Natural rateCutoff = 0, Spread onSpread = 0.0, Real onGearing = 1.0,
57 const DayCounter& onDayCounter = DayCounter(),
58 const QuantLib::ext::shared_ptr<AverageONIndexedCouponPricer>& onCouponPricer =
59 QuantLib::ext::shared_ptr<AverageONIndexedCouponPricer>(),
60 const bool telescopicValueDates = false);
61
62 /*! Arithmetic average ON leg vs. fixed leg constructor, allowing for
63 varying nominals, fixed rates, ON leg spreads and ON leg gearings.
64 */
65 AverageOIS(Type type, std::vector<Real> nominals, const Schedule& fixedSchedule, std::vector<Rate> fixedRates,
66 const DayCounter& fixedDayCounter, BusinessDayConvention fixedPaymentAdjustment,
67 const Calendar& fixedPaymentCalendar, const Schedule& onSchedule,
68 const QuantLib::ext::shared_ptr<OvernightIndex>& overnightIndex, BusinessDayConvention onPaymentAdjustment,
69 const Calendar& onPaymentCalendar, Natural rateCutoff = 0,
70 std::vector<Spread> onSpreads = std::vector<Spread>(1, 0.0),
71 std::vector<Real> onGearings = std::vector<Real>(1, 1.0), const DayCounter& onDayCounter = DayCounter(),
72 const QuantLib::ext::shared_ptr<AverageONIndexedCouponPricer>& onCouponPricer =
73 QuantLib::ext::shared_ptr<AverageONIndexedCouponPricer>(),
74 const bool telescopicValueDates = false);
75
76 //! \name Inspectors
77 //@{
78 Type type() const { return type_; }
79
80 Real nominal() const;
81 const std::vector<Real>& nominals() const { return nominals_; }
82
83 Rate fixedRate() const;
84 const std::vector<Rate>& fixedRates() const { return fixedRates_; }
85 const DayCounter& fixedDayCounter() { return fixedDayCounter_; }
86
87 const QuantLib::ext::shared_ptr<OvernightIndex>& overnightIndex() { return overnightIndex_; }
88 Natural rateCutoff() { return rateCutoff_; }
89 Spread onSpread() const;
90 const std::vector<Spread>& onSpreads() const { return onSpreads_; }
91 Real onGearing() const;
92 const std::vector<Real>& onGearings() const { return onGearings_; }
93 const DayCounter& onDayCounter() { return onDayCounter_; }
94
95 const Leg& fixedLeg() const { return legs_[0]; }
96 const Leg& overnightLeg() const { return legs_[1]; }
97 //@}
98
99 //! \name Results
100 //@{
101 Real fixedLegBPS() const;
102 Real fixedLegNPV() const;
103 Real fairRate() const;
104
105 Real overnightLegBPS() const;
106 Real overnightLegNPV() const;
107 Spread fairSpread() const;
108 //@}
109
110 void setONIndexedCouponPricer(const QuantLib::ext::shared_ptr<AverageONIndexedCouponPricer>& onCouponPricer);
111
112private:
113 void initialize(const Schedule& fixedLegSchedule, const Schedule& onLegSchedule);
114
116 std::vector<Real> nominals_;
117
118 std::vector<Rate> fixedRates_;
120 BusinessDayConvention fixedPaymentAdjustment_;
122
123 QuantLib::ext::shared_ptr<OvernightIndex> overnightIndex_;
124 BusinessDayConvention onPaymentAdjustment_;
126 Natural rateCutoff_;
127 std::vector<Spread> onSpreads_;
128 std::vector<Real> onGearings_;
129 DayCounter onDayCounter_;
130 QuantLib::ext::shared_ptr<AverageONIndexedCouponPricer> onCouponPricer_;
132};
133} // namespace QuantExt
134
135#endif
Pricer for average overnight indexed coupons.
Average overnight index swap.
Definition: averageois.hpp:46
Spread onSpread() const
Definition: averageois.cpp:111
Rate fixedRate() const
Definition: averageois.cpp:106
Real fairRate() const
Definition: averageois.cpp:133
QuantLib::ext::shared_ptr< OvernightIndex > overnightIndex_
Definition: averageois.hpp:123
Type
Receiver (Payer) means receive (pay) fixed.
Definition: averageois.hpp:49
DayCounter fixedDayCounter_
Definition: averageois.hpp:119
BusinessDayConvention fixedPaymentAdjustment_
Definition: averageois.hpp:120
const QuantLib::ext::shared_ptr< OvernightIndex > & overnightIndex()
Definition: averageois.hpp:87
const DayCounter & onDayCounter()
Definition: averageois.hpp:93
Spread fairSpread() const
Definition: averageois.cpp:151
BusinessDayConvention onPaymentAdjustment_
Definition: averageois.hpp:124
void initialize(const Schedule &fixedLegSchedule, const Schedule &onLegSchedule)
Definition: averageois.cpp:61
std::vector< Rate > fixedRates_
Definition: averageois.hpp:118
const Leg & overnightLeg() const
Definition: averageois.hpp:96
QuantLib::ext::shared_ptr< AverageONIndexedCouponPricer > onCouponPricer_
Definition: averageois.hpp:130
std::vector< Spread > onSpreads_
Definition: averageois.hpp:127
const std::vector< Real > & nominals() const
Definition: averageois.hpp:81
Calendar onPaymentCalendar_
Definition: averageois.hpp:125
const std::vector< Real > & onGearings() const
Definition: averageois.hpp:92
Real nominal() const
Definition: averageois.cpp:101
Real fixedLegBPS() const
Definition: averageois.cpp:121
Calendar fixedPaymentCalendar_
Definition: averageois.hpp:121
const std::vector< Rate > & fixedRates() const
Definition: averageois.hpp:84
Real onGearing() const
Definition: averageois.cpp:116
const Leg & fixedLeg() const
Definition: averageois.hpp:95
void setONIndexedCouponPricer(const QuantLib::ext::shared_ptr< AverageONIndexedCouponPricer > &onCouponPricer)
Definition: averageois.cpp:158
const DayCounter & fixedDayCounter()
Definition: averageois.hpp:85
Type type() const
Definition: averageois.hpp:78
Real overnightLegBPS() const
Definition: averageois.cpp:139
Real fixedLegNPV() const
Definition: averageois.cpp:127
const std::vector< Spread > & onSpreads() const
Definition: averageois.hpp:90
DayCounter onDayCounter_
Definition: averageois.hpp:129
Real overnightLegNPV() const
Definition: averageois.cpp:145
std::vector< Real > onGearings_
Definition: averageois.hpp:128
std::vector< Real > nominals_
Definition: averageois.hpp:116