Logo
Fully annotated reference manual - version 1.8.12
Loading...
Searching...
No Matches
Public Member Functions | List of all members
FxRateQuote Class Reference

#include <qle/indexes/fxindex.hpp>

+ Inheritance diagram for FxRateQuote:
+ Collaboration diagram for FxRateQuote:

Public Member Functions

 FxRateQuote (Handle< Quote > spotQuote, const Handle< YieldTermStructure > &sourceYts, const Handle< YieldTermStructure > &targetYts, Natural fixingDays, const Calendar &fixingCalendar)
 if sourceYts, targetYts are not given, the non-discounted spot quote will be returned as a fallback More...
 
Quote interface
Real value () const override
 
bool isValid () const override
 

Observer interface

const Handle< Quote > spotQuote_
 
const Handle< YieldTermStructure > sourceYts_
 
const Handle< YieldTermStructure > targetYts_
 
Natural fixingDays_
 
Calendar fixingCalendar_
 
void update () override
 

Detailed Description

Definition at line 51 of file fxindex.hpp.

Constructor & Destructor Documentation

◆ FxRateQuote()

FxRateQuote ( Handle< Quote >  spotQuote,
const Handle< YieldTermStructure > &  sourceYts,
const Handle< YieldTermStructure > &  targetYts,
Natural  fixingDays,
const Calendar &  fixingCalendar 
)

if sourceYts, targetYts are not given, the non-discounted spot quote will be returned as a fallback

Definition at line 45 of file fxindex.cpp.

48 : spotQuote_(spotQuote), sourceYts_(sourceYts), targetYts_(targetYts), fixingDays_(fixingDays),
49 fixingCalendar_(fixingCalendar) {
50 registerWith(spotQuote_);
51 registerWith(sourceYts_);
52 registerWith(targetYts_);
53}
const Handle< Quote > spotQuote_
Definition: fxindex.hpp:66
const Handle< YieldTermStructure > targetYts_
Definition: fxindex.hpp:67
const Handle< YieldTermStructure > sourceYts_
Definition: fxindex.hpp:67
Calendar fixingCalendar_
Definition: fxindex.hpp:69

Member Function Documentation

◆ value()

Real value ( ) const
override

Definition at line 55 of file fxindex.cpp.

55 {
56 QL_ENSURE(isValid(), "invalid FxRateQuote");
57 if (fixingDays_ == 0)
58 return spotQuote_->value();
59 else {
60 if (sourceYts_.empty() || targetYts_.empty())
61 return spotQuote_->value();
62 Date today = sourceYts_->referenceDate();
63 Date refValueDate = fixingCalendar_.advance(today, fixingDays_, Days);
64 return spotQuote_->value() * targetYts_->discount(refValueDate) / sourceYts_->discount(refValueDate);
65 }
66}
bool isValid() const override
Definition: fxindex.cpp:68
+ Here is the call graph for this function:

◆ isValid()

bool isValid ( ) const
override

Definition at line 68 of file fxindex.cpp.

68{ return !spotQuote_.empty() && spotQuote_->isValid(); }
+ Here is the caller graph for this function:

◆ update()

void update ( )
override

Definition at line 70 of file fxindex.cpp.

70{ notifyObservers(); }

Member Data Documentation

◆ spotQuote_

const Handle<Quote> spotQuote_
private

Definition at line 66 of file fxindex.hpp.

◆ sourceYts_

const Handle<YieldTermStructure> sourceYts_
private

Definition at line 67 of file fxindex.hpp.

◆ targetYts_

const Handle<YieldTermStructure> targetYts_
private

Definition at line 67 of file fxindex.hpp.

◆ fixingDays_

Natural fixingDays_
private

Definition at line 68 of file fxindex.hpp.

◆ fixingCalendar_

Calendar fixingCalendar_
private

Definition at line 69 of file fxindex.hpp.