19#include <ql/event.hpp>
27FxForward::FxForward(
const Real& nominal1,
const Currency& currency1,
const Real& nominal2,
const Currency& currency2,
28 const Date& maturityDate,
const bool& payCurrency1,
const bool isPhysicallySettled,
29 const Date& payDate,
const Currency& payCcy,
const Date& fixingDate,
30 const QuantLib::ext::shared_ptr<QuantExt::FxIndex>& fxIndex,
31 bool includeSettlementDateFlows)
32 : nominal1_(nominal1), currency1_(currency1), nominal2_(nominal2), currency2_(currency2),
33 maturityDate_(maturityDate), payCurrency1_(payCurrency1), isPhysicallySettled_(isPhysicallySettled),
34 payDate_(payDate), payCcy_(payCcy), fxIndex_(fxIndex), fixingDate_(fixingDate),
35 includeSettlementDateFlows_(includeSettlementDateFlows) {
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.");
51 bool sellingNominal,
const bool isPhysicallySettled,
const Date& payDate,
const Currency& payCcy,
52 const Date& fixingDate,
const QuantLib::ext::shared_ptr<QuantExt::FxIndex>& fxIndex,
53 bool includeSettlementDateFlows)
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) {
58 QL_REQUIRE(
currency1_ == forwardRate.target(),
"Currency of nominal1 does not match target (domestic) "
59 "currency in the exchange rate.");
61 Money otherNominal = forwardRate.exchange(nominal1);
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.");
79 const Date& maturityDate,
bool sellingNominal,
const bool isPhysicallySettled,
const Date& payDate,
80 const Currency& payCcy,
const Date& fixingDate,
81 const QuantLib::ext::shared_ptr<QuantExt::FxIndex>& fxIndex,
82 bool includeSettlementDateFlows)
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) {
87 QL_REQUIRE(fxForwardQuote->isValid(),
"The FX Forward quote is not valid.");
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.");
106 return detail::simple_event(p).hasOccurred();
110 Instrument::setupExpired();
111 npv_ = Money(0.0, Currency());
119 QL_REQUIRE(
arguments,
"wrong argument type in fxforward");
137 Instrument::fetchResults(r);
141 QL_REQUIRE(
results,
"wrong result type");
148 QL_REQUIRE(
nominal1 >= 0.0,
"nominal1 should be non-negative: " <<
nominal1);
149 QL_REQUIRE(
nominal2 >= 0.0,
"nominal2 should be non-negative: " <<
nominal2);
154 Instrument::results::reset();
156 npv = Money(0.0, Currency());
QuantLib::ext::shared_ptr< FxIndex > fxIndex
void validate() const override
bool includeSettlementDateFlows
ExchangeRate fairForwardRate
ExchangeRate fairForwardRate_
QuantLib::ext::shared_ptr< FxIndex > fxIndex_
void setupArguments(PricingEngine::arguments *) const override
bool isExpired() const override
const ExchangeRate & fairForwardRate() const
Return the fair FX forward rate.
bool isPhysicallySettled_
void setupExpired() const override
FxForward(const Real &nominal1, const Currency ¤cy1, const Real &nominal2, const Currency ¤cy2, 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)
void fetchResults(const PricingEngine::results *) const override
bool includeSettlementDateFlows_
defaultable fxforward instrument