QuantLib: a free/open-source library for quantitative finance
Fully annotated sources - version 1.32
Loading...
Searching...
No Matches
List of all members
Forward Class Referenceabstract

Abstract base forward class. More...

#include <ql/instruments/forward.hpp>

+ Inheritance diagram for Forward:
+ Collaboration diagram for Forward:

Public Member Functions

Inspectors
virtual Date settlementDate () const
 
const Calendarcalendar () const
 
BusinessDayConvention businessDayConvention () const
 
const DayCounterdayCounter () const
 
Handle< YieldTermStructurediscountCurve () const
 term structure relevant to the contract (e.g. repo curve) More...
 
Handle< YieldTermStructureincomeDiscountCurve () const
 term structure that discounts the underlying's income cash flows More...
 
bool isExpired () const override
 returns whether the instrument is still tradable. More...
 
virtual Real spotValue () const =0
 returns spot value/price of an underlying financial instrument More...
 
virtual Real spotIncome (const Handle< YieldTermStructure > &incomeDiscountCurve) const =0
 NPV of income/dividends/storage-costs etc. of underlying instrument. More...
 
- Public Member Functions inherited from Instrument
 Instrument ()
 
Real NPV () const
 returns the net present value of the instrument. More...
 
Real errorEstimate () const
 returns the error estimate on the NPV when available. More...
 
const DatevaluationDate () const
 returns the date the net present value refers to. More...
 
template<typename T >
result (const std::string &tag) const
 returns any additional result returned by the pricing engine. More...
 
const std::map< std::string, ext::any > & additionalResults () const
 returns all additional result returned by the pricing engine. More...
 
void setPricingEngine (const ext::shared_ptr< PricingEngine > &)
 set the pricing engine to be used. More...
 
virtual void setupArguments (PricingEngine::arguments *) const
 
virtual void fetchResults (const PricingEngine::results *) const
 
- Public Member Functions inherited from LazyObject
 LazyObject ()
 
 ~LazyObject () override=default
 
void update () override
 
bool isCalculated () const
 
void forwardFirstNotificationOnly ()
 
void alwaysForwardNotifications ()
 
void recalculate ()
 
void freeze ()
 
void unfreeze ()
 
- Public Member Functions inherited from Observable
 Observable ()
 
 Observable (const Observable &)
 
Observableoperator= (const Observable &)
 
 Observable (Observable &&)=delete
 
Observableoperator= (Observable &&)=delete
 
virtual ~Observable ()=default
 
void notifyObservers ()
 
- Public Member Functions inherited from Observer
 Observer ()=default
 
 Observer (const Observer &)
 
Observeroperator= (const Observer &)
 
virtual ~Observer ()
 
std::pair< iterator, boolregisterWith (const ext::shared_ptr< Observable > &)
 
void registerWithObservables (const ext::shared_ptr< Observer > &)
 
Size unregisterWith (const ext::shared_ptr< Observable > &)
 
void unregisterWithAll ()
 
virtual void update ()=0
 
virtual void deepUpdate ()
 

Calculations

Real underlyingIncome_
 
Real underlyingSpotValue_
 
DayCounter dayCounter_
 
Calendar calendar_
 
BusinessDayConvention businessDayConvention_
 
Natural settlementDays_
 
ext::shared_ptr< Payoffpayoff_
 
Date valueDate_
 
Date maturityDate_
 maturityDate of the forward contract or delivery date of underlying More...
 
Handle< YieldTermStructurediscountCurve_
 
Handle< YieldTermStructureincomeDiscountCurve_
 
virtual Real forwardValue () const
 forward value/price of underlying, discounting income/dividends More...
 
InterestRate impliedYield (Real underlyingSpotValue, Real forwardValue, Date settlementDate, Compounding compoundingConvention, const DayCounter &dayCounter)
 
 Forward (DayCounter dayCounter, Calendar calendar, BusinessDayConvention businessDayConvention, Natural settlementDays, ext::shared_ptr< Payoff > payoff, const Date &valueDate, const Date &maturityDate, Handle< YieldTermStructure > discountCurve=Handle< YieldTermStructure >())
 
void performCalculations () const override
 

Additional Inherited Members

- Public Types inherited from Observer
typedef set_type::iterator iterator
 
- Protected Member Functions inherited from Instrument
void calculate () const override
 
virtual void setupExpired () const
 
- Protected Member Functions inherited from LazyObject
- Protected Attributes inherited from Instrument
Real NPV_
 
Real errorEstimate_
 
Date valuationDate_
 
std::map< std::string, ext::any > additionalResults_
 
ext::shared_ptr< PricingEngineengine_
 
- Protected Attributes inherited from LazyObject
bool calculated_ = false
 
bool frozen_ = false
 
bool alwaysForward_
 

Detailed Description

Abstract base forward class.

Derived classes must implement the virtual functions spotValue() (NPV or spot price) and spotIncome() associated with the specific relevant underlying (e.g. bond, stock, commodity, loan/deposit). These functions must be used to set the protected member variables underlyingSpotValue_ and underlyingIncome_ within performCalculations() in the derived class before the base-class implementation is called.

spotIncome() refers generically to the present value of coupons, dividends or storage costs.

discountCurve_ is the curve used to discount forward contract cash flows back to the evaluation day, as well as to obtain forward values for spot values/prices.

incomeDiscountCurve_, which for generality is not automatically set to the discountCurve_, is the curve used to discount future income/dividends/storage-costs etc back to the evaluation date.

Warning:
This class still needs to be rigorously tested

Definition at line 66 of file forward.hpp.

Constructor & Destructor Documentation

◆ Forward()

Forward ( DayCounter  dayCounter,
Calendar  calendar,
BusinessDayConvention  businessDayConvention,
Natural  settlementDays,
ext::shared_ptr< Payoff payoff,
const Date valueDate,
const Date maturityDate,
Handle< YieldTermStructure discountCurve = Handle<YieldTermStructure>() 
)
protected

Definition at line 27 of file forward.cpp.

+ Here is the call graph for this function:

Member Function Documentation

◆ settlementDate()

Date settlementDate ( ) const
virtual

Definition at line 48 of file forward.cpp.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ calendar()

const Calendar & calendar ( ) const

Definition at line 168 of file forward.hpp.

◆ businessDayConvention()

BusinessDayConvention businessDayConvention ( ) const

Definition at line 172 of file forward.hpp.

◆ dayCounter()

const DayCounter & dayCounter ( ) const

Definition at line 176 of file forward.hpp.

+ Here is the caller graph for this function:

◆ discountCurve()

Handle< YieldTermStructure > discountCurve ( ) const

term structure relevant to the contract (e.g. repo curve)

Definition at line 180 of file forward.hpp.

◆ incomeDiscountCurve()

Handle< YieldTermStructure > incomeDiscountCurve ( ) const

term structure that discounts the underlying's income cash flows

Definition at line 184 of file forward.hpp.

+ Here is the caller graph for this function:

◆ isExpired()

bool isExpired ( ) const
overridevirtual

returns whether the instrument is still tradable.

Implements Instrument.

Definition at line 55 of file forward.cpp.

+ Here is the call graph for this function:

◆ spotValue()

virtual Real spotValue ( ) const
pure virtual

returns spot value/price of an underlying financial instrument

Implemented in BondForward.

◆ spotIncome()

virtual Real spotIncome ( const Handle< YieldTermStructure > &  incomeDiscountCurve) const
pure virtual

NPV of income/dividends/storage-costs etc. of underlying instrument.

Implemented in BondForward.

+ Here is the caller graph for this function:

◆ forwardValue()

Real forwardValue ( ) const
virtual

forward value/price of underlying, discounting income/dividends

Note
if this is a bond forward price, is must be a dirty forward price.

Definition at line 61 of file forward.cpp.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ impliedYield()

InterestRate impliedYield ( Real  underlyingSpotValue,
Real  forwardValue,
Date  settlementDate,
Compounding  compoundingConvention,
const DayCounter dayCounter 
)

Simple yield calculation based on underlying spot and forward values, taking into account underlying income. When \( t>0 \), call with: underlyingSpotValue=spotValue(t), forwardValue=strikePrice, to get current yield. For a repo, if \( t=0 \), impliedYield should reproduce the spot repo rate. For FRA's, this should reproduce the relevant zero rate at the FRA's maturityDate_;

Examples
Repo.cpp.

Definition at line 68 of file forward.cpp.

+ Here is the call graph for this function:

◆ performCalculations()

void performCalculations ( ) const
overrideprotectedvirtual

In case a pricing engine is not used, this method must be overridden to perform the actual calculations and set any needed results. In case a pricing engine is used, the default implementation can be used.

Reimplemented from Instrument.

Definition at line 83 of file forward.cpp.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Member Data Documentation

◆ underlyingIncome_

Real underlyingIncome_
mutableprotected

derived classes must set this, typically via spotIncome()

Definition at line 123 of file forward.hpp.

◆ underlyingSpotValue_

Real underlyingSpotValue_
mutableprotected

derived classes must set this, typically via spotValue()

Definition at line 125 of file forward.hpp.

◆ dayCounter_

DayCounter dayCounter_
protected

Definition at line 127 of file forward.hpp.

◆ calendar_

Calendar calendar_
protected

Definition at line 128 of file forward.hpp.

◆ businessDayConvention_

BusinessDayConvention businessDayConvention_
protected

Definition at line 129 of file forward.hpp.

◆ settlementDays_

Natural settlementDays_
protected

Definition at line 130 of file forward.hpp.

◆ payoff_

ext::shared_ptr<Payoff> payoff_
protected

Definition at line 131 of file forward.hpp.

◆ valueDate_

Date valueDate_
protected

valueDate = settlement date (date the fwd contract starts accruing)

Definition at line 135 of file forward.hpp.

◆ maturityDate_

Date maturityDate_
protected

maturityDate of the forward contract or delivery date of underlying

Definition at line 137 of file forward.hpp.

◆ discountCurve_

Handle<YieldTermStructure> discountCurve_
protected

Definition at line 138 of file forward.hpp.

◆ incomeDiscountCurve_

Handle<YieldTermStructure> incomeDiscountCurve_
protected

must set this in derived classes, based on particular underlying

Definition at line 140 of file forward.hpp.