Logo
Fully annotated reference manual - version 1.8.12
Loading...
Searching...
No Matches
fxforward.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 qle/instruments/fxforward.hpp
20 \brief defaultable fxforward instrument
21
22 \ingroup instruments
23*/
24
25#ifndef quantext_fxforward_hpp
26#define quantext_fxforward_hpp
27
28#include <ql/currency.hpp>
29#include <ql/exchangerate.hpp>
30#include <ql/instrument.hpp>
31#include <ql/money.hpp>
32#include <ql/quote.hpp>
34
35namespace QuantExt {
36using namespace QuantLib;
37
38//! <strong> FX Forward </strong>
39
40/*! This class holds the term sheet data for an FX Forward instrument.
41
42 \ingroup instruments
43*/
44class FxForward : public Instrument {
45public:
46 class arguments;
47 class results;
48 class engine;
49 //! \name Constructors
50 //@{
51 /*! \param nominal1, currency1
52 There are nominal1 units of currency1.
53 \param nominal2, currency2
54 There are nominal2 units of currency2.
55 \param maturityDate
56 Date on which currency amounts are exchanged.
57 \param payCurrency1
58 Pay nominal1 if true, otherwise pay nominal2.
59 \param isPhysicallySettled
60 if true fx forward is physically settled
61 \param payDate
62 Date on which the cashflows are exchanged
63 \param payCcy
64 If cash settled, the settlement currency
65 \param fixingDate
66 If cash settled, the fixing date
67 \param fxIndex
68 If cash settled, the FX index from which to take the fixing on the fixing date
69 \param includeSettlementDateFlows
70 If true, we include cash flows on valuation date into the NPV calculation
71 */
72 FxForward(const Real& nominal1, const Currency& currency1, const Real& nominal2, const Currency& currency2,
73 const Date& maturityDate, const bool& payCurrency1, const bool isPhysicallySettled = true,
74 const Date& payDate = Date(), const Currency& payCcy = Currency(), const Date& fixingDate = Date(),
75 const QuantLib::ext::shared_ptr<QuantExt::FxIndex>& fxIndex = nullptr,
76 bool includeSettlementDateFlows = false);
77
78 /*! \param nominal1
79 FX forward nominal amount (domestic currency)
80 \param forwardRate
81 FX rate of the exchange
82 \param forwardDate
83 Date of the exchange.
84 \param sellingNominal
85 Sell (pay) nominal1 if true, otherwise buy (receive) nominal.
86 \param isPhysicallySettled
87 if true fx forward is physically settled
88 \param payDate
89 Date on which the cashflows are exchanged
90 \param payCcy
91 If cash settled, the settlement currency
92 \param fixingDate
93 If cash settled, the fixing date
94 \param fxIndex
95 If cash settled, the FX index from which to take the fixing on the fixing date
96 \param includeSettlementDateFlows
97 If true, we include cash flows on valuation date into the NPV calculation
98 */
99 FxForward(const Money& nominal1, const ExchangeRate& forwardRate, const Date& forwardDate, bool sellingNominal,
100 const bool isPhysicallySettled = true, const Date& payDate = Date(), const Currency& payCcy = Currency(),
101 const Date& fixingDate = Date(), const QuantLib::ext::shared_ptr<QuantExt::FxIndex>& fxIndex = nullptr,
102 bool includeSettlementDateFlows = false);
103
104 /*! \param nominal1
105 FX forward nominal amount 1 (domestic currency)
106 \param fxForwardQuote
107 FX forward quote giving the rate in domestic units
108 per one foreign unit
109 \param currency2
110 currency for nominal2 (foreign currency)
111 \param maturityDate
112 FX Forward maturity date
113 \param sellingNominal
114 Sell (pay) nominal1 if true, otherwise buy (receive) nominal1.
115 \param isPhysicallySettled
116 if true fx forward is physically settled
117 \param payDate
118 Date on which the cashflows are exchanged
119 \param payCcy
120 If cash settled, the settlement currency
121 \param fixingDate
122 If cash settled, the fixing date
123 \param fxIndex
124 If cash settled, the FX index from which to take the fixing on the fixing date
125 \param includeSettlementDateFlows
126 If true, we include cash flows on valuation date into the NPV calculation
127 */
128 FxForward(const Money& nominal1, const Handle<Quote>& fxForwardQuote, const Currency& currency2,
129 const Date& maturityDate, bool sellingNominal, const bool isPhysicallySettled = true,
130 const Date& payDate = Date(), const Currency& payCcy = Currency(), const Date& fixingDate = Date(),
131 const QuantLib::ext::shared_ptr<QuantExt::FxIndex>& fxIndex = nullptr,
132 bool includeSettlementDateFlows = false);
133
134 //@}
135
136 //! \name Results
137 //@{
138 //! Return NPV as money (the price currency is set in the pricing engine)
139 const Money& npvMoney() const {
140 calculate();
141 return npv_;
142 }
143 //! Return the fair FX forward rate.
144 const ExchangeRate& fairForwardRate() const {
145 calculate();
146 return fairForwardRate_;
147 }
148 //@}
149
150 //! \name Instrument interface
151 //@{
152 bool isExpired() const override;
153 void setupArguments(PricingEngine::arguments*) const override;
154 void fetchResults(const PricingEngine::results*) const override;
155 //@}
156
157 //! \name Additional interface
158 //@{
159 Real currency1Nominal() const { return nominal1_; }
160 Real currency2Nominal() const { return nominal2_; }
161 Currency currency1() const { return currency1_; }
162 Currency currency2() const { return currency2_; }
163 Date maturityDate() const { return maturityDate_; }
164 Date payDate() const { return payDate_; }
165 Currency payCcy() const { return payCcy_; }
166 QuantLib::ext::shared_ptr<QuantExt::FxIndex> fxIndex() const { return fxIndex_; }
167 bool payCurrency1() const { return payCurrency1_; }
168 //@}
169
170private:
171 //! \name Instrument interface
172 //@{
173 void setupExpired() const override;
174 //@}
175
177 Currency currency1_;
179 Currency currency2_;
184 Currency payCcy_;
185 QuantLib::ext::shared_ptr<FxIndex> fxIndex_;
188
189 // results
190 mutable Money npv_;
191 mutable ExchangeRate fairForwardRate_;
192};
193
194//! \ingroup instruments
196public:
198 Currency currency1;
200 Currency currency2;
205 Currency payCcy;
206 QuantLib::ext::shared_ptr<FxIndex> fxIndex;
209 void validate() const override;
210};
211
212//! \ingroup instruments
214public:
215 Money npv;
216 ExchangeRate fairForwardRate;
217 void reset() override;
218};
219
220//! \ingroup instruments
221class FxForward::engine : public GenericEngine<FxForward::arguments, FxForward::results> {};
222} // namespace QuantExt
223
224#endif
QuantLib::ext::shared_ptr< FxIndex > fxIndex
Definition: fxforward.hpp:206
void validate() const override
Definition: fxforward.cpp:147
Currency currency2() const
Definition: fxforward.hpp:162
ExchangeRate fairForwardRate_
Definition: fxforward.hpp:191
QuantLib::ext::shared_ptr< FxIndex > fxIndex_
Definition: fxforward.hpp:185
void setupArguments(PricingEngine::arguments *) const override
Definition: fxforward.cpp:115
bool isExpired() const override
Definition: fxforward.cpp:104
QuantLib::ext::shared_ptr< QuantExt::FxIndex > fxIndex() const
Definition: fxforward.hpp:166
Real currency2Nominal() const
Definition: fxforward.hpp:160
const ExchangeRate & fairForwardRate() const
Return the fair FX forward rate.
Definition: fxforward.hpp:144
Real currency1Nominal() const
Definition: fxforward.hpp:159
Date maturityDate() const
Definition: fxforward.hpp:163
Date payDate() const
Definition: fxforward.hpp:164
bool payCurrency1() const
Definition: fxforward.hpp:167
const Money & npvMoney() const
Return NPV as money (the price currency is set in the pricing engine)
Definition: fxforward.hpp:139
void setupExpired() const override
Definition: fxforward.cpp:109
void fetchResults(const PricingEngine::results *) const override
Definition: fxforward.cpp:135
bool includeSettlementDateFlows_
Definition: fxforward.hpp:187
Currency currency1() const
Definition: fxforward.hpp:161
Currency payCcy() const
Definition: fxforward.hpp:165
FX index class.