QuantLib: a free/open-source library for quantitative finance
fully annotated source code - version 1.34
|
Forward contract on a bond More...
#include <bondforward.hpp>
Public Member Functions | |
Constructors | |
BondForward (const Date &valueDate, const Date &maturityDate, Position::Type type, Real strike, Natural settlementDays, const DayCounter &dayCounter, const Calendar &calendar, BusinessDayConvention businessDayConvention, const ext::shared_ptr< Bond > &bond, const Handle< YieldTermStructure > &discountCurve=Handle< YieldTermStructure >(), const Handle< YieldTermStructure > &incomeDiscountCurve=Handle< YieldTermStructure >()) | |
![]() | |
virtual Date | settlementDate () const |
const Calendar & | calendar () const |
BusinessDayConvention | businessDayConvention () const |
const DayCounter & | dayCounter () const |
Handle< YieldTermStructure > | discountCurve () const |
term structure relevant to the contract (e.g. repo curve) More... | |
Handle< YieldTermStructure > | incomeDiscountCurve () 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 | forwardValue () const |
forward value/price of underlying, discounting income/dividends More... | |
InterestRate | impliedYield (Real underlyingSpotValue, Real forwardValue, Date settlementDate, Compounding compoundingConvention, const DayCounter &dayCounter) |
![]() | |
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 Date & | valuationDate () const |
returns the date the net present value refers to. More... | |
template<typename T > | |
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 |
![]() | |
LazyObject () | |
~LazyObject () override=default | |
void | update () override |
bool | isCalculated () const |
void | forwardFirstNotificationOnly () |
void | alwaysForwardNotifications () |
void | recalculate () |
void | freeze () |
void | unfreeze () |
![]() | |
Observable () | |
Observable (const Observable &) | |
Observable & | operator= (const Observable &) |
Observable (Observable &&)=delete | |
Observable & | operator= (Observable &&)=delete |
virtual | ~Observable ()=default |
void | notifyObservers () |
![]() | |
Observer ()=default | |
Observer (const Observer &) | |
Observer & | operator= (const Observer &) |
virtual | ~Observer () |
std::pair< iterator, bool > | registerWith (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 | |
ext::shared_ptr< Bond > | bond_ |
Real | forwardPrice () const |
(dirty) forward bond price More... | |
Real | cleanForwardPrice () const |
(dirty) forward bond price minus accrued on bond at delivery More... | |
Real | spotIncome (const Handle< YieldTermStructure > &incomeDiscountCurve) const override |
NPV of bond coupons discounted using incomeDiscountCurve. More... | |
Real | spotValue () const override |
NPV of underlying bond. More... | |
void | performCalculations () const override |
Additional Inherited Members | |
![]() | |
typedef set_type::iterator | iterator |
![]() | |
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 |
![]() | |
void | calculate () const override |
virtual void | setupExpired () const |
![]() | |
![]() | |
Real | underlyingIncome_ |
Real | underlyingSpotValue_ |
DayCounter | dayCounter_ |
Calendar | calendar_ |
BusinessDayConvention | businessDayConvention_ |
Natural | settlementDays_ |
ext::shared_ptr< Payoff > | payoff_ |
Date | valueDate_ |
Date | maturityDate_ |
maturityDate of the forward contract or delivery date of underlying More... | |
Handle< YieldTermStructure > | discountCurve_ |
Handle< YieldTermStructure > | incomeDiscountCurve_ |
![]() | |
Real | NPV_ |
Real | errorEstimate_ |
Date | valuationDate_ |
std::map< std::string, ext::any > | additionalResults_ |
ext::shared_ptr< PricingEngine > | engine_ |
![]() | |
bool | calculated_ = false |
bool | frozen_ = false |
bool | alwaysForward_ |
Forward contract on a bond
Relevant formulas used in the calculations ( P refers to a price):
a. P_{CleanFwd}(t) = P_{DirtyFwd}(t) - AI(t=deliveryDate) where AI refers to the accrued interest on the underlying bond.
b. P_{DirtyFwd}(t) = \frac{P_{DirtySpot}(t) - SpotIncome(t)} {discountCurve->discount(t=deliveryDate)}
c. SpotIncome(t) = \sum_i \left( CF_i \times incomeDiscountCurve->discount(t_i) \right) where CF_i represents the ith bond cash flow (coupon payment) associated with the underlying bond falling between the settlementDate and the deliveryDate. (Note the two different discount curves used in b. and c.)
Definition at line 69 of file bondforward.hpp.
BondForward | ( | const Date & | valueDate, |
const Date & | maturityDate, | ||
Position::Type | type, | ||
Real | strike, | ||
Natural | settlementDays, | ||
const DayCounter & | dayCounter, | ||
const Calendar & | calendar, | ||
BusinessDayConvention | businessDayConvention, | ||
const ext::shared_ptr< Bond > & | bond, | ||
const Handle< YieldTermStructure > & | discountCurve = Handle<YieldTermStructure>() , |
||
const Handle< YieldTermStructure > & | incomeDiscountCurve = Handle<YieldTermStructure>() |
||
) |
If strike is given in the constructor, can calculate the NPV of the contract via NPV().
If strike/forward price is desired, it can be obtained via forwardPrice(). In this case, the strike variable in the constructor is irrelevant and will be ignored.
Definition at line 27 of file bondforward.cpp.
Real forwardPrice | ( | ) | const |
(dirty) forward bond price
Definition at line 54 of file bondforward.cpp.
Real cleanForwardPrice | ( | ) | const |
(dirty) forward bond price minus accrued on bond at delivery
Definition at line 49 of file bondforward.cpp.
|
overridevirtual |
NPV of bond coupons discounted using incomeDiscountCurve.
Here only coupons between max(evaluation date,settlement date) and maturity date of bond forward contract are considered income.
Implements Forward.
Definition at line 59 of file bondforward.cpp.
|
overridevirtual |
NPV of underlying bond.
Implements Forward.
Definition at line 86 of file bondforward.cpp.
|
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 91 of file bondforward.cpp.
|
protected |
Definition at line 116 of file bondforward.hpp.