Logo
Fully annotated reference manual - version 1.8.12
Loading...
Searching...
No Matches
Classes | List of all members
FxForward Class Reference

FX Forward More...

#include <qle/instruments/fxforward.hpp>

+ Inheritance diagram for FxForward:
+ Collaboration diagram for FxForward:

Classes

class  arguments
 
class  engine
 
class  results
 

Public Member Functions

Constructors
 FxForward (const Real &nominal1, const Currency &currency1, const Real &nominal2, const Currency &currency2, const Date &maturityDate, const bool &payCurrency1, const bool isPhysicallySettled=true, const Date &payDate=Date(), const Currency &payCcy=Currency(), const Date &fixingDate=Date(), const QuantLib::ext::shared_ptr< QuantExt::FxIndex > &fxIndex=nullptr, bool includeSettlementDateFlows=false)
 
 FxForward (const Money &nominal1, const ExchangeRate &forwardRate, const Date &forwardDate, bool sellingNominal, const bool isPhysicallySettled=true, const Date &payDate=Date(), const Currency &payCcy=Currency(), const Date &fixingDate=Date(), const QuantLib::ext::shared_ptr< QuantExt::FxIndex > &fxIndex=nullptr, bool includeSettlementDateFlows=false)
 
 FxForward (const Money &nominal1, const Handle< Quote > &fxForwardQuote, const Currency &currency2, const Date &maturityDate, bool sellingNominal, const bool isPhysicallySettled=true, const Date &payDate=Date(), const Currency &payCcy=Currency(), const Date &fixingDate=Date(), const QuantLib::ext::shared_ptr< QuantExt::FxIndex > &fxIndex=nullptr, bool includeSettlementDateFlows=false)
 
Results
const Money & npvMoney () const
 Return NPV as money (the price currency is set in the pricing engine) More...
 
const ExchangeRate & fairForwardRate () const
 Return the fair FX forward rate. More...
 
Additional interface
Real currency1Nominal () const
 
Real currency2Nominal () const
 
Currency currency1 () const
 
Currency currency2 () const
 
Date maturityDate () const
 
Date payDate () const
 
Currency payCcy () const
 
QuantLib::ext::shared_ptr< QuantExt::FxIndexfxIndex () const
 
bool payCurrency1 () const
 

Instrument interface

Real nominal1_
 
Currency currency1_
 
Real nominal2_
 
Currency currency2_
 
Date maturityDate_
 
bool payCurrency1_
 
bool isPhysicallySettled_
 
Date payDate_
 
Currency payCcy_
 
QuantLib::ext::shared_ptr< FxIndexfxIndex_
 
Date fixingDate_
 
bool includeSettlementDateFlows_
 
Money npv_
 
ExchangeRate fairForwardRate_
 
bool isExpired () const override
 
void setupArguments (PricingEngine::arguments *) const override
 
void fetchResults (const PricingEngine::results *) const override
 
void setupExpired () const override
 

Detailed Description

FX Forward

This class holds the term sheet data for an FX Forward instrument.

\ingroup instruments

Definition at line 44 of file fxforward.hpp.

Constructor & Destructor Documentation

◆ FxForward() [1/3]

FxForward ( const Real &  nominal1,
const Currency &  currency1,
const Real &  nominal2,
const Currency &  currency2,
const Date &  maturityDate,
const bool payCurrency1,
const bool  isPhysicallySettled = true,
const Date &  payDate = Date(),
const Currency &  payCcy = Currency(),
const Date &  fixingDate = Date(),
const QuantLib::ext::shared_ptr< QuantExt::FxIndex > &  fxIndex = nullptr,
bool  includeSettlementDateFlows = false 
)
Parameters
nominal1,currency1There are nominal1 units of currency1.
nominal2,currency2There are nominal2 units of currency2.
maturityDateDate on which currency amounts are exchanged.
payCurrency1Pay nominal1 if true, otherwise pay nominal2.
isPhysicallySettledif true fx forward is physically settled
payDateDate on which the cashflows are exchanged
payCcyIf cash settled, the settlement currency
fixingDateIf cash settled, the fixing date
fxIndexIf cash settled, the FX index from which to take the fixing on the fixing date
includeSettlementDateFlowsIf true, we include cash flows on valuation date into the NPV calculation

Definition at line 27 of file fxforward.cpp.

35 includeSettlementDateFlows_(includeSettlementDateFlows) {
36
37 if (payDate_ == Date())
39
40 if (fixingDate_ == Date())
42
43 if (!isPhysicallySettled && payDate_ > fixingDate_) {
44 QL_REQUIRE(fxIndex_, "FxForward: no FX index given for non-deliverable forward.");
45 QL_REQUIRE(fixingDate_ != Date(), "FxForward: no FX fixing date given for non-deliverable forward.");
46 registerWith(fxIndex_);
47 }
48}
Currency currency2() const
Definition: fxforward.hpp:162
QuantLib::ext::shared_ptr< FxIndex > fxIndex_
Definition: fxforward.hpp:185
QuantLib::ext::shared_ptr< QuantExt::FxIndex > fxIndex() const
Definition: fxforward.hpp:166
Date maturityDate() const
Definition: fxforward.hpp:163
Date payDate() const
Definition: fxforward.hpp:164
bool payCurrency1() const
Definition: fxforward.hpp:167
bool includeSettlementDateFlows_
Definition: fxforward.hpp:187
Currency currency1() const
Definition: fxforward.hpp:161
Currency payCcy() const
Definition: fxforward.hpp:165

◆ FxForward() [2/3]

FxForward ( const Money &  nominal1,
const ExchangeRate &  forwardRate,
const Date &  forwardDate,
bool  sellingNominal,
const bool  isPhysicallySettled = true,
const Date &  payDate = Date(),
const Currency &  payCcy = Currency(),
const Date &  fixingDate = Date(),
const QuantLib::ext::shared_ptr< QuantExt::FxIndex > &  fxIndex = nullptr,
bool  includeSettlementDateFlows = false 
)
Parameters
nominal1FX forward nominal amount (domestic currency)
forwardRateFX rate of the exchange
forwardDateDate of the exchange.
sellingNominalSell (pay) nominal1 if true, otherwise buy (receive) nominal.
isPhysicallySettledif true fx forward is physically settled
payDateDate on which the cashflows are exchanged
payCcyIf cash settled, the settlement currency
fixingDateIf cash settled, the fixing date
fxIndexIf cash settled, the FX index from which to take the fixing on the fixing date
includeSettlementDateFlowsIf true, we include cash flows on valuation date into the NPV calculation

Definition at line 50 of file fxforward.cpp.

54 : nominal1_(nominal1.value()), currency1_(nominal1.currency()), maturityDate_(maturityDate),
55 payCurrency1_(sellingNominal), isPhysicallySettled_(isPhysicallySettled), payDate_(payDate), payCcy_(payCcy),
56 fxIndex_(fxIndex), fixingDate_(fixingDate), includeSettlementDateFlows_(includeSettlementDateFlows) {
57
58 QL_REQUIRE(currency1_ == forwardRate.target(), "Currency of nominal1 does not match target (domestic) "
59 "currency in the exchange rate.");
60
61 Money otherNominal = forwardRate.exchange(nominal1);
62 nominal2_ = otherNominal.value();
63 currency2_ = otherNominal.currency();
64
65 if (payDate_ == Date())
67
68 if (fixingDate_ == Date())
70
71 if (!isPhysicallySettled && payDate_ > fixingDate_) {
72 QL_REQUIRE(fxIndex_, "FxForward: no FX index given for non-deliverable forward.");
73 QL_REQUIRE(fixingDate_ != Date(), "FxForward: no FX fixing date given for non-deliverable forward.");
74 registerWith(fxIndex_);
75 }
76}

◆ FxForward() [3/3]

FxForward ( const Money &  nominal1,
const Handle< Quote > &  fxForwardQuote,
const Currency &  currency2,
const Date &  maturityDate,
bool  sellingNominal,
const bool  isPhysicallySettled = true,
const Date &  payDate = Date(),
const Currency &  payCcy = Currency(),
const Date &  fixingDate = Date(),
const QuantLib::ext::shared_ptr< QuantExt::FxIndex > &  fxIndex = nullptr,
bool  includeSettlementDateFlows = false 
)
Parameters
nominal1FX forward nominal amount 1 (domestic currency)
fxForwardQuoteFX forward quote giving the rate in domestic units per one foreign unit
currency2currency for nominal2 (foreign currency)
maturityDateFX Forward maturity date
sellingNominalSell (pay) nominal1 if true, otherwise buy (receive) nominal1.
isPhysicallySettledif true fx forward is physically settled
payDateDate on which the cashflows are exchanged
payCcyIf cash settled, the settlement currency
fixingDateIf cash settled, the fixing date
fxIndexIf cash settled, the FX index from which to take the fixing on the fixing date
includeSettlementDateFlowsIf true, we include cash flows on valuation date into the NPV calculation

Definition at line 78 of file fxforward.cpp.

83 : nominal1_(nominal1.value()), currency1_(nominal1.currency()), currency2_(currency2), maturityDate_(maturityDate),
84 payCurrency1_(sellingNominal), isPhysicallySettled_(isPhysicallySettled), payDate_(payDate), payCcy_(payCcy),
85 fxIndex_(fxIndex), fixingDate_(fixingDate), includeSettlementDateFlows_(includeSettlementDateFlows) {
86
87 QL_REQUIRE(fxForwardQuote->isValid(), "The FX Forward quote is not valid.");
88
89 nominal2_ = nominal1_ / fxForwardQuote->value();
90
91 if (payDate_ == Date())
93
94 if (fixingDate_ == Date())
96
97 if (!isPhysicallySettled && payDate_ > fixingDate_) {
98 QL_REQUIRE(fxIndex_, "FxForward: no FX index given for non-deliverable forward.");
99 QL_REQUIRE(fixingDate_ != Date(), "FxForward: no FX fixing date given for non-deliverable forward.");
100 registerWith(fxIndex_);
101 }
102}

Member Function Documentation

◆ npvMoney()

const Money & npvMoney ( ) const

Return NPV as money (the price currency is set in the pricing engine)

Definition at line 139 of file fxforward.hpp.

139 {
140 calculate();
141 return npv_;
142 }

◆ fairForwardRate()

const ExchangeRate & fairForwardRate ( ) const

Return the fair FX forward rate.

Definition at line 144 of file fxforward.hpp.

144 {
145 calculate();
146 return fairForwardRate_;
147 }
ExchangeRate fairForwardRate_
Definition: fxforward.hpp:191
+ Here is the caller graph for this function:

◆ isExpired()

bool isExpired ( ) const
override

Definition at line 104 of file fxforward.cpp.

104 {
105 Date p = includeSettlementDateFlows_ ? payDate_ + 1*Days : payDate_;
106 return detail::simple_event(p).hasOccurred();
107}

◆ setupArguments()

void setupArguments ( PricingEngine::arguments *  args) const
override

Definition at line 115 of file fxforward.cpp.

115 {
116
117 FxForward::arguments* arguments = dynamic_cast<FxForward::arguments*>(args);
118
119 QL_REQUIRE(arguments, "wrong argument type in fxforward");
120
121 arguments->nominal1 = nominal1_;
122 arguments->currency1 = currency1_;
123 arguments->nominal2 = nominal2_;
124 arguments->currency2 = currency2_;
125 arguments->maturityDate = maturityDate_;
126 arguments->payCurrency1 = payCurrency1_;
127 arguments->isPhysicallySettled = isPhysicallySettled_;
128 arguments->payDate = payDate_;
129 arguments->payCcy = payCcy_;
130 arguments->fxIndex = fxIndex_;
131 arguments->fixingDate = fixingDate_;
132 arguments->includeSettlementDateFlows = includeSettlementDateFlows_;
133}

◆ fetchResults()

void fetchResults ( const PricingEngine::results *  r) const
override

Definition at line 135 of file fxforward.cpp.

135 {
136
137 Instrument::fetchResults(r);
138
139 const FxForward::results* results = dynamic_cast<const FxForward::results*>(r);
140
141 QL_REQUIRE(results, "wrong result type");
142
143 npv_ = results->npv;
144 fairForwardRate_ = results->fairForwardRate;
145}

◆ currency1Nominal()

Real currency1Nominal ( ) const

Definition at line 159 of file fxforward.hpp.

159{ return nominal1_; }

◆ currency2Nominal()

Real currency2Nominal ( ) const

Definition at line 160 of file fxforward.hpp.

160{ return nominal2_; }

◆ currency1()

Currency currency1 ( ) const

Definition at line 161 of file fxforward.hpp.

161{ return currency1_; }

◆ currency2()

Currency currency2 ( ) const

Definition at line 162 of file fxforward.hpp.

162{ return currency2_; }

◆ maturityDate()

Date maturityDate ( ) const

Definition at line 163 of file fxforward.hpp.

163{ return maturityDate_; }

◆ payDate()

Date payDate ( ) const

Definition at line 164 of file fxforward.hpp.

164{ return payDate_; }

◆ payCcy()

Currency payCcy ( ) const

Definition at line 165 of file fxforward.hpp.

165{ return payCcy_; }

◆ fxIndex()

QuantLib::ext::shared_ptr< QuantExt::FxIndex > fxIndex ( ) const

Definition at line 166 of file fxforward.hpp.

166{ return fxIndex_; }

◆ payCurrency1()

bool payCurrency1 ( ) const

Definition at line 167 of file fxforward.hpp.

167{ return payCurrency1_; }

◆ setupExpired()

void setupExpired ( ) const
overrideprivate

Definition at line 109 of file fxforward.cpp.

109 {
110 Instrument::setupExpired();
111 npv_ = Money(0.0, Currency());
112 fairForwardRate_ = ExchangeRate();
113}

Member Data Documentation

◆ nominal1_

Real nominal1_
private

Definition at line 176 of file fxforward.hpp.

◆ currency1_

Currency currency1_
private

Definition at line 177 of file fxforward.hpp.

◆ nominal2_

Real nominal2_
private

Definition at line 178 of file fxforward.hpp.

◆ currency2_

Currency currency2_
private

Definition at line 179 of file fxforward.hpp.

◆ maturityDate_

Date maturityDate_
private

Definition at line 180 of file fxforward.hpp.

◆ payCurrency1_

bool payCurrency1_
private

Definition at line 181 of file fxforward.hpp.

◆ isPhysicallySettled_

bool isPhysicallySettled_
private

Definition at line 182 of file fxforward.hpp.

◆ payDate_

Date payDate_
private

Definition at line 183 of file fxforward.hpp.

◆ payCcy_

Currency payCcy_
private

Definition at line 184 of file fxforward.hpp.

◆ fxIndex_

QuantLib::ext::shared_ptr<FxIndex> fxIndex_
private

Definition at line 185 of file fxforward.hpp.

◆ fixingDate_

Date fixingDate_
private

Definition at line 186 of file fxforward.hpp.

◆ includeSettlementDateFlows_

bool includeSettlementDateFlows_
private

Definition at line 187 of file fxforward.hpp.

◆ npv_

Money npv_
mutableprivate

Definition at line 190 of file fxforward.hpp.

◆ fairForwardRate_

ExchangeRate fairForwardRate_
mutableprivate

Definition at line 191 of file fxforward.hpp.