Logo
Fully annotated reference manual - version 1.8.12
Loading...
Searching...
No Matches
fixedbmaswap.hpp
Go to the documentation of this file.
1/*
2 Copyright (C) 2018 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 fixedbmaswap.hpp
20 \brief fixed vs averaged bma swap
21
22 \ingroup instruments
23*/
24
25#ifndef quantlib_makefixedbmaswap_hpp
26#define quantlib_makefixedbmaswap_hpp
27
28#include <ql/cashflows/averagebmacoupon.hpp>
29#include <ql/instruments/swap.hpp>
30
31namespace QuantExt {
32using namespace QuantLib;
33
34//! swap paying a fixed rate against BMA coupons
35class FixedBMASwap : public Swap {
36public:
37 class results;
38 class engine;
39 enum Type { Receiver = -1, Payer = 1 };
41 // Fixed leg
42 const Schedule& fixedSchedule, Rate fixedRate, const DayCounter& fixedDayCount,
43 // BMA leg
44 const Schedule& bmaSchedule, const QuantLib::ext::shared_ptr<BMAIndex>& bmaIndex,
45 const DayCounter& bmaDayCount);
46
47 //! \name Inspectors
48 //@{
49 Real fixedRate() const;
50 Real nominal() const;
51 //! "payer" or "receiver" refer to the BMA leg
52 Type type() const;
53 const Leg& bmaLeg() const;
54 const Leg& fixedLeg() const;
55 //@}
56
57 //! \name Results
58 //@{
59 Real fixedLegBPS() const;
60 Real fixedLegNPV() const;
61 Rate fairRate() const;
62
63 Real bmaLegBPS() const;
64 Real bmaLegNPV() const;
65 //@}
66 // results
67 void fetchResults(const PricingEngine::results*) const override;
68
69private:
73 // results
74 mutable Rate fairRate_;
75};
76
78public:
80 void reset() override;
81};
82
83class FixedBMASwap::engine : GenericEngine<FixedBMASwap::arguments, FixedBMASwap::results> {};
84// factory class for making fixed vs bma swaps
85
87public:
88 MakeFixedBMASwap(const Period& swapTenor, const QuantLib::ext::shared_ptr<BMAIndex>& bmaIndex,
89 Rate fixedRate = Null<Rate>(), const Period& forwardStart = 0 * Days);
90
91 operator FixedBMASwap() const;
92 operator QuantLib::ext::shared_ptr<FixedBMASwap>() const;
93
94 // We regard the BMA leg parameters as fixed by convention apart from tenor
95 // and provide a factory for the fixed leg per MakeVanillaSwap
96
97 MakeFixedBMASwap& receiveFixed(bool flag = true);
100 MakeFixedBMASwap& withBMALegTenor(const Period& tenor);
101
102 MakeFixedBMASwap& withSettlementDays(Natural settlementDays);
105
106 MakeFixedBMASwap& withFixedLegTenor(const Period& t);
107 MakeFixedBMASwap& withFixedLegCalendar(const Calendar& cal);
108 MakeFixedBMASwap& withFixedLegConvention(BusinessDayConvention bdc);
110 MakeFixedBMASwap& withFixedLegRule(DateGeneration::Rule r);
111 MakeFixedBMASwap& withFixedLegEndOfMonth(bool flag = true);
114 MakeFixedBMASwap& withFixedLegDayCount(const DayCounter& dc);
115
116 MakeFixedBMASwap& withDiscountingTermStructure(const Handle<YieldTermStructure>& discountCurve);
117 MakeFixedBMASwap& withPricingEngine(const QuantLib::ext::shared_ptr<PricingEngine>& engine);
118
119private:
121 QuantLib::ext::shared_ptr<BMAIndex> bmaIndex_;
125
129
135 DateGeneration::Rule fixedRule_, bmaRule_;
140
141 QuantLib::ext::shared_ptr<PricingEngine> engine_;
142};
143} // namespace QuantExt
144
145#endif
swap paying a fixed rate against BMA coupons
Type type() const
"payer" or "receiver" refer to the BMA leg
const Leg & bmaLeg() const
Real fixedLegBPS() const
const Leg & fixedLeg() const
void fetchResults(const PricingEngine::results *) const override
Real fixedLegNPV() const
FixedBMASwap::Type type_
MakeFixedBMASwap & withFixedLegNextToLastDate(const Date &d)
BusinessDayConvention fixedConvention_
MakeFixedBMASwap & withFixedLegTenor(const Period &t)
MakeFixedBMASwap & withPricingEngine(const QuantLib::ext::shared_ptr< PricingEngine > &engine)
MakeFixedBMASwap & withFixedLegRule(DateGeneration::Rule r)
MakeFixedBMASwap & withTerminationDate(const Date &)
MakeFixedBMASwap & withType(FixedBMASwap::Type type)
MakeFixedBMASwap & withFixedLegFirstDate(const Date &d)
MakeFixedBMASwap & withFixedLegDayCount(const DayCounter &dc)
MakeFixedBMASwap & withDiscountingTermStructure(const Handle< YieldTermStructure > &discountCurve)
DateGeneration::Rule bmaRule_
MakeFixedBMASwap & withFixedLegTerminationDateConvention(BusinessDayConvention bdc)
QuantLib::ext::shared_ptr< PricingEngine > engine_
BusinessDayConvention bmaTerminationDateConvention_
MakeFixedBMASwap & withSettlementDays(Natural settlementDays)
DateGeneration::Rule fixedRule_
MakeFixedBMASwap & withFixedLegConvention(BusinessDayConvention bdc)
MakeFixedBMASwap & withEffectiveDate(const Date &)
MakeFixedBMASwap & withNominal(Real n)
MakeFixedBMASwap & withFixedLegEndOfMonth(bool flag=true)
MakeFixedBMASwap & withBMALegTenor(const Period &tenor)
BusinessDayConvention fixedTerminationDateConvention_
QuantLib::ext::shared_ptr< BMAIndex > bmaIndex_
BusinessDayConvention bmaConvention_
MakeFixedBMASwap & receiveFixed(bool flag=true)
MakeFixedBMASwap & withFixedLegCalendar(const Calendar &cal)