Logo
Fully annotated reference manual - version 1.8.12
Loading...
Searching...
No Matches
floatingratefxlinkednotionalcoupon.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 floatingratefxlinkednotionalcoupon.hpp
20 \brief Coupon paying a Libor-type index but with an FX linked notional
21
22 \ingroup cashflows
23*/
24
25#ifndef quantext_floating_rate_fx_linked_notional_coupon_hpp
26#define quantext_floating_rate_fx_linked_notional_coupon_hpp
27
28#include <ql/cashflows/floatingratecoupon.hpp>
30
31namespace QuantExt {
32using namespace QuantLib;
33
34//! %Coupon paying a Libor-type index on an fx-linked nominal
35//! \ingroup cashflows
37public:
38 //! FloatingRateFXLinkedNotionalCoupon
39 FloatingRateFXLinkedNotionalCoupon(const Date& fxFixingDate, Real foreignAmount, QuantLib::ext::shared_ptr<FxIndex> fxIndex,
40 const QuantLib::ext::shared_ptr<FloatingRateCoupon>& underlying)
41 : FloatingRateCoupon(underlying->date(), Null<Real>(), underlying->accrualStartDate(),
42 underlying->accrualEndDate(), underlying->fixingDate(), underlying->index(),
43 underlying->gearing(), underlying->spread(), underlying->referencePeriodStart(),
44 underlying->referencePeriodEnd(), underlying->dayCounter(), underlying->isInArrears()),
46 fixingDays_ = underlying->fixingDays() == Null<Natural>()
47 ? (underlying->index() ? underlying->index()->fixingDays() : 0)
48 : underlying->fixingDays();
49 registerWith(FXLinked::fxIndex());
50 registerWith(underlying_);
51 }
52
53 //! \name FXLinked interface
54 //@{
55 QuantLib::ext::shared_ptr<FXLinked> clone(QuantLib::ext::shared_ptr<FxIndex> fxIndex) override;
56 //@}
57
58 //! \name Obverver interface
59 //@{
60 void deepUpdate() override {
61 update();
62 underlying_->deepUpdate();
63 }
64 //@}
65
66 //! \name LazyObject interface
67 //@{
68 void performCalculations() const override { rate_ = underlying_->rate(); }
70 LazyObject::alwaysForwardNotifications();
71 underlying_->alwaysForwardNotifications();
72 }
73 //@}
74 //! \name Coupon interface
75 //@{
76 Rate nominal() const override { return foreignAmount() * fxRate(); }
77 //@}
78
79 //! \name FloatingRateCoupon interface
80 //@{
81 Rate indexFixing() const override { return underlying_->indexFixing(); } // might be overwritten in underlying
82 void setPricer(const ext::shared_ptr<FloatingRateCouponPricer>& p) override { underlying_->setPricer(p); }
83 //@}
84
85 //! \name Visitability
86 //@{
87 void accept(AcyclicVisitor&) override;
88 //@}
89
90 //! more inspectors
91 QuantLib::ext::shared_ptr<FloatingRateCoupon> underlying() const { return underlying_; }
92
93private:
94 const QuantLib::ext::shared_ptr<FloatingRateCoupon> underlying_;
95};
96
97// inline definitions
98inline void FloatingRateFXLinkedNotionalCoupon::accept(AcyclicVisitor& v) {
99 Visitor<FloatingRateFXLinkedNotionalCoupon>* v1 = dynamic_cast<Visitor<FloatingRateFXLinkedNotionalCoupon>*>(&v);
100 if (v1 != 0)
101 v1->visit(*this);
102 else
103 FloatingRateCoupon::accept(v);
104}
105
106inline QuantLib::ext::shared_ptr<FXLinked> FloatingRateFXLinkedNotionalCoupon::clone(QuantLib::ext::shared_ptr<FxIndex> fxIndex) {
107 return QuantLib::ext::make_shared<FloatingRateFXLinkedNotionalCoupon>(fxFixingDate(), foreignAmount(), fxIndex,
108 underlying());
109}
110
111} // namespace QuantExt
112
113#endif
Base class for FX Linked cashflows.
const QuantLib::ext::shared_ptr< FxIndex > & fxIndex() const
Real foreignAmount() const
Date fxFixingDate() const
QuantLib::ext::shared_ptr< FXLinked > clone(QuantLib::ext::shared_ptr< FxIndex > fxIndex) override
QuantLib::ext::shared_ptr< FloatingRateCoupon > underlying() const
more inspectors
FloatingRateFXLinkedNotionalCoupon(const Date &fxFixingDate, Real foreignAmount, QuantLib::ext::shared_ptr< FxIndex > fxIndex, const QuantLib::ext::shared_ptr< FloatingRateCoupon > &underlying)
FloatingRateFXLinkedNotionalCoupon.
void setPricer(const ext::shared_ptr< FloatingRateCouponPricer > &p) override
const QuantLib::ext::shared_ptr< FloatingRateCoupon > underlying_
An FX linked cashflow.