Main Page | Namespace List | Class Hierarchy | Class List | File List | Class Members | File Members

yieldCurve Class Reference

#include <yieldCurve.h>

Inheritance diagram for yieldCurve:

creditCurve List of all members.

Public Member Functions

 yieldCurve (void)
 Default void constructor.

 yieldCurve (Real flatRate)
 FlatCurve.

void assignFlatRate (Real r=0.0)
 For flat rate curves, set the flat rate value.

void assignZCBrateAtIndex (Real rate, Natural i)
 sets an EXISTING rate at a certain level

yieldCurve shiftZCBRateCurve (Real shift=defaultshiftfactorForShortRate)
 for risk mngmt purposes, shifts the yc

yieldCurve rotateZCBRateCurve (Real moveInShortestRate=defaultshiftfactorForShortRate, Real maturityOfRotation=7)
 for risk mngmt purposes, rotates the yc with a ref to how you move the shortest rate, around which rate

 yieldCurve (valarray< yieldPoint > yieldPoints, char *name="unnamed")
 Constructor.

 ~yieldCurve (void)
virtual Real spotRate (Real maturity) const
 Calculates the spot ZCB rate.

virtual valarray< RealgetMaturitiesInTheMarketCurve () const
 Return the maturities present in the market curve, both from the Cash and Swap Pointsvalarray<Real>.

virtual valarray< RealgetMaturitiesInTheZCBCurve () const
 Return the maturities present in the market curve, both from the Cash and Swap Pointsvalarray<Real>.

virtual Real spotRate (Date maturityDate) const
 Calculates the spot ZCB rate.

virtual Real discountFactor (Real maturity, interestComposition composition=Continuous)
 Calculates the discountFactor.

virtual Real discountFactor (Date maturityDate, interestComposition composition=Continuous)
 Calculates the discountFactor.

virtual Real forwardDiscountFactor (Real forwardstart, Real lengthofcontractafterstart, interestComposition composition=Continuous)
 Calculates the discountFactor.

virtual Real forwardRate (Real forwardStart, Real effectiveLengthOfTheContractAfterStart, interestComposition composition=Continuous)
 Calculates the fwd rate.

virtual Real forwardRate (Date forwardStart, Date forwardEnd, interestComposition composition=Continuous)
 Calculates the fwd rate.

virtual yieldCurve forwardZCBCurve (Real forwardStart)
 Forward curve.

char * getName ()
virtual bool operator== (const yieldCurve &yours)
 compares two y curves.

virtual bool operator!= (const yieldCurve &yours)

Private Member Functions

yieldPoint getPointAtMaturity (Real maturity)
 for know maturities, we can return the market Point as it is

void sortMarketRatesByMaturity ()
 Sorting rates by maturity, just in case ...

void sortCashSwap ()
 Routine to make sure the short term rates (cash) are before the mid/long term (swap).

valarray< yieldPointgetSwapRates ()
 needed in the bootstrap method to be able to back the ZC

valarray< yieldPointgetSequentSwapRates ()
 1Y difference in swaps -> ZC's easily backed up The method assumes that rates are sorted by ascending maturity The mkt curve is 1Y by 1Y - we should fill in the gaps by linear interpolation

void computeZCBRatesBootstrap ()
 Go from the swap rates to the ZC - matrix inversion to be done Swap rates can be annual or semi annual in their most common quotes on the market.

valarray< RealSequentDiscountFactorsByInvertSwapMatrix ()
 Discount Factors corresponding to annual swaps quoted on sequent yrs : X-1 * (1...1)' where X is as follows: - diag = +1 swap (i) - inferior triang (i,j) = swap (i) - superior diag (i,j) =0.


Private Attributes

valarray< yieldPoint_marketRates
valarray< yieldPoint_zcbRates
char _name [YC_NAME_STRLEN]

Friends

ostream & operator<< (ostream &os, const yieldCurve &c)
 display maturities and spotrates in the curve.

ostream & operator<< (ostream &os, const yieldCurve *c)

Constructor & Destructor Documentation

yieldCurve::yieldCurve void   ) 
 

Default void constructor.

clean ?

Definition at line 42 of file yieldCurve.cpp.

References _name, assignFlatRate(), computeZCBRatesBootstrap(), and YC_MAX_NUMBER_POINTS.

Referenced by creditCurve::combineUnderlyingAndSpreads(), creditCurve::copyObj(), creditCurve::createSpreadCurve(), creditCurve::creditCurve(), forwardZCBCurve(), rotateZCBRateCurve(), and shiftZCBRateCurve().

yieldCurve::yieldCurve Real  flatRate  ) 
 

FlatCurve.

Parameters:
flatRate : Real is the flat rate - by default, it will simulate a flat ZCB curve with 15 Points by default

clean ?

Definition at line 64 of file yieldCurve.cpp.

References _name, assignFlatRate(), computeZCBRatesBootstrap(), Real, and YC_MAX_NUMBER_POINTS.

yieldCurve::yieldCurve valarray< yieldPoint yieldPoints,
char *  name = "unnamed"
 

Constructor.

Parameters:
yieldPoints the array of yieldPoints
name the name we give it

clean ?

Definition at line 74 of file yieldCurve.cpp.

References _name, computeZCBRatesBootstrap(), sortCashSwap(), and sortMarketRatesByMaturity().

yieldCurve::~yieldCurve void   ) 
 

Definition at line 85 of file yieldCurve.cpp.


Member Function Documentation

void yieldCurve::assignFlatRate Real  r = 0.0  ) 
 

For flat rate curves, set the flat rate value.

Definition at line 53 of file yieldCurve.cpp.

References _marketRates, ACT_360, Cash, Natural, r, and Real.

Referenced by yieldCurve().

void yieldCurve::assignZCBrateAtIndex Real  rate,
Natural  i
 

sets an EXISTING rate at a certain level

Definition at line 377 of file yieldCurve.cpp.

References _zcbRates, Natural, and Real.

Referenced by rotateZCBRateCurve(), and shiftZCBRateCurve().

void yieldCurve::computeZCBRatesBootstrap  )  [private]
 

Go from the swap rates to the ZC - matrix inversion to be done Swap rates can be annual or semi annual in their most common quotes on the market.

Having semi annual swaps with annual maturities makes life hard as to bootstrap the ZC's as we would not be able to back out the semi annual ZC's to move to the next step without market bond prices, etc: it would really be cumbersome On the quote screen provided by Prof Laud, swaps are quoted annualy from 2 to 10 -> easy calculation [cf latex Code] as for the 15 - 20 and 30 with frequency annual, we need to find a way to find mid Points 11-14, 16-19 21-29.

Definition at line 354 of file yieldCurve.cpp.

References _marketRates, _zcbRates, Cash, Natural, Real, and SequentDiscountFactorsByInvertSwapMatrix().

Referenced by yieldCurve().

Real yieldCurve::discountFactor Date  maturityDate,
interestComposition  composition = Continuous
[virtual]
 

Calculates the discountFactor.

Parameters:
maturity : just after ZCBrates are computed, it it very easy [done at trhe constructor level]

Reimplemented in creditCurve.

Definition at line 247 of file yieldCurve.cpp.

References Day30_360, Date::dayCount(), discountFactor(), Real, and Date::setDateToToday().

Real yieldCurve::discountFactor Real  maturity,
interestComposition  composition = Continuous
[virtual]
 

Calculates the discountFactor.

Parameters:
maturity : just after ZCBrates are computed, it it very easy [done at trhe constructor level]

Reimplemented in creditCurve.

Definition at line 235 of file yieldCurve.cpp.

References Continuous, Discrete, Real, and spotRate().

Referenced by creditCurve::defaultProbability(), discountFactor(), creditCurve::discountFactor(), asset::forwardPrice(), forwardRate(), CashFlow::getFairValue(), mainmc(), bond::quotedPrice(), RainbowOption::RainbowOption(), creditCurve::riskyDiscountFactor(), and creditCurve::swapFees().

Real yieldCurve::forwardDiscountFactor Real  forwardstart,
Real  lengthofcontractafterstart,
interestComposition  composition = Continuous
[virtual]
 

Calculates the discountFactor.

Parameters:
maturity : just after ZCBrates are computed, it it very easy [done at trhe constructor level]

Definition at line 253 of file yieldCurve.cpp.

References Continuous, Discrete, forwardRate(), and Real.

Referenced by binomialTree::setClaimVariables().

Real yieldCurve::forwardRate Date  forwardStart,
Date  forwardEnd,
interestComposition  composition = Continuous
[virtual]
 

Calculates the fwd rate.

Parameters:
forwardStart start of the rate
maturityAfterForward maturity after the start

Reimplemented in creditCurve.

Definition at line 298 of file yieldCurve.cpp.

References Day30_360, Date::dayCount(), forwardRate(), Real, and Date::setDateToToday().

Real yieldCurve::forwardRate Real  forwardStart,
Real  effectiveLengthOfTheContractAfterStart,
interestComposition  composition = Continuous
[virtual]
 

Calculates the fwd rate.

Parameters:
forwardStart start of the rate
maturityAfterForward maturity after the start

Reimplemented in creditCurve.

Definition at line 264 of file yieldCurve.cpp.

References Continuous, discountFactor(), Discrete, Real, and spotRate().

Referenced by CashFlow::CashFlow(), Drift::Drift(), forwardDiscountFactor(), forwardRate(), creditCurve::forwardRate(), and forwardZCBCurve().

yieldCurve yieldCurve::forwardZCBCurve Real  forwardStart  )  [virtual]
 

Forward curve.

Definition at line 279 of file yieldCurve.cpp.

References _zcbRates, forwardRate(), Natural, Real, and yieldCurve().

Referenced by VanillaSwap::getTheta(), and Exotics::getTheta().

valarray< Real > yieldCurve::getMaturitiesInTheMarketCurve  )  const [virtual]
 

Return the maturities present in the market curve, both from the Cash and Swap Pointsvalarray<Real>.

Definition at line 333 of file yieldCurve.cpp.

References _marketRates, and Natural.

valarray< Real > yieldCurve::getMaturitiesInTheZCBCurve  )  const [virtual]
 

Return the maturities present in the market curve, both from the Cash and Swap Pointsvalarray<Real>.

Reimplemented in creditCurve.

Definition at line 343 of file yieldCurve.cpp.

References _zcbRates, and Natural.

Referenced by creditCurve::combineUnderlyingAndSpreads(), creditCurve::getMaturitiesInTheZCBCurve(), mainyieldcurve(), operator<<(), and operator==().

char* yieldCurve::getName  )  [inline]
 

Reimplemented in creditCurve.

Definition at line 192 of file yieldCurve.h.

References _name.

Referenced by creditCurve::getName().

yieldPoint yieldCurve::getPointAtMaturity Real  maturity  )  [private]
 

for know maturities, we can return the market Point as it is

Parameters:
maturity : Be careful with this method as if it does not know the maturity it will give a blank Point

Definition at line 89 of file yieldCurve.cpp.

References _marketRates, Natural, and Real.

Referenced by sortMarketRatesByMaturity().

valarray< yieldPoint > yieldCurve::getSequentSwapRates  )  [private]
 

1Y difference in swaps -> ZC's easily backed up The method assumes that rates are sorted by ascending maturity The mkt curve is 1Y by 1Y - we should fill in the gaps by linear interpolation

Swaps are quoted per year sequent then gaps : we need to fill in the gaps with a linear interpolation

we know that the first one is in 1Y swap rate (assigned at 1Y cash rate), as for the rest we ahve to Check for 1y sequent swap rates first

Definition at line 172 of file yieldCurve.cpp.

References getSwapRates(), Natural, Real, and Swap.

Referenced by SequentDiscountFactorsByInvertSwapMatrix().

valarray< yieldPoint > yieldCurve::getSwapRates  )  [private]
 

needed in the bootstrap method to be able to back the ZC

Definition at line 155 of file yieldCurve.cpp.

References _marketRates, Cash, Natural, spotRate(), Swap, and YC_MAX_NUMBER_POINTS.

Referenced by getSequentSwapRates().

bool yieldCurve::operator!= const yieldCurve yours  )  [virtual]
 

Definition at line 452 of file yieldCurve.cpp.

References operator==().

bool yieldCurve::operator== const yieldCurve yours  )  [virtual]
 

compares two y curves.

Two y curves are equal if they give identical spotrates for all ZCB maturities in each curve

Parameters:
param - the creditcurve to compare to
Returns:
true if all spotrates match, otherwise false

Definition at line 423 of file yieldCurve.cpp.

References getMaturitiesInTheZCBCurve(), m, mergeunique(), Natural, Real, and spotRate().

Referenced by operator!=().

yieldCurve yieldCurve::rotateZCBRateCurve Real  moveInShortestRate = defaultshiftfactorForShortRate,
Real  maturityOfRotation = 7
 

for risk mngmt purposes, rotates the yc with a ref to how you move the shortest rate, around which rate

Definition at line 399 of file yieldCurve.cpp.

References _zcbRates, assignZCBrateAtIndex(), Natural, Real, and yieldCurve().

Referenced by mainyieldcurve().

valarray< Real > yieldCurve::SequentDiscountFactorsByInvertSwapMatrix  )  [private]
 

Discount Factors corresponding to annual swaps quoted on sequent yrs : X-1 * (1...1)' where X is as follows: - diag = +1 swap (i) - inferior triang (i,j) = swap (i) - superior diag (i,j) =0.

Definition at line 305 of file yieldCurve.cpp.

References getSequentSwapRates(), M, and Natural.

Referenced by computeZCBRatesBootstrap().

yieldCurve yieldCurve::shiftZCBRateCurve Real  shift = defaultshiftfactorForShortRate  ) 
 

for risk mngmt purposes, shifts the yc

Definition at line 382 of file yieldCurve.cpp.

References _zcbRates, assignZCBrateAtIndex(), Natural, Real, and yieldCurve().

Referenced by VanillaSwap::getRho(), RainbowOption::getRho(), Exotics::getRho(), asset::getRho(), mainyieldcurve(), riskybond::shiftedbond(), treasurybond::shiftedbond(), and volsurface::shiftedYCvolsurface().

void yieldCurve::sortCashSwap  )  [private]
 

Routine to make sure the short term rates (cash) are before the mid/long term (swap).

Definition at line 134 of file yieldCurve.cpp.

References _marketRates, Cash, Natural, and Swap.

Referenced by yieldCurve().

void yieldCurve::sortMarketRatesByMaturity  )  [private]
 

Sorting rates by maturity, just in case ...

Definition at line 112 of file yieldCurve.cpp.

References _marketRates, getPointAtMaturity(), Natural, Real, and YC_MAX_NUMBER_POINTS.

Referenced by yieldCurve().

Real yieldCurve::spotRate Date  maturityDate  )  const [virtual]
 

Calculates the spot ZCB rate.

Parameters:
maturityDate : maturityDate of the ZCB

Reimplemented in creditCurve.

Definition at line 229 of file yieldCurve.cpp.

References Day30_360, Date::dayCount(), Real, Date::setDateToToday(), and spotRate().

Real yieldCurve::spotRate Real  maturity  )  const [virtual]
 

Calculates the spot ZCB rate.

Parameters:
maturity : if it is exact it just gives the result from a Point, else an interpolated one based on interpolator

Reimplemented in creditCurve.

Definition at line 207 of file yieldCurve.cpp.

References _zcbRates, Natural, and Real.

Referenced by creditCurve::combineUnderlyingAndSpreads(), RainbowOption::compute_C(), RainbowOption::compute_d1(), RainbowOption::compute_d2(), creditCurve::createSpreadCurve(), creditCurve::creditSpread(), discountFactor(), forwardRate(), getSwapRates(), inputBSOption(), inputButterflySpread(), inputCallSpread(), inputPutSpread(), inputRatioCallSpread(), inputStraddle(), inputStrangle(), RainbowOption::instanciateMCVariables(), mainyieldcurve(), operator<<(), operator==(), RainbowOption::PriceByClosedForm_MaxOf2_call(), RainbowOption::PriceByClosedForm_MaxOf2_put(), RainbowOption::PriceByClosedForm_MinOf2_call(), RainbowOption::PriceByClosedForm_MinOf2_put(), RainbowOption::PriceByClosedForm_WorseOf2(), creditCurve::resampleSpread(), volsurface::setvolsurface(), spotRate(), and creditCurve::spotRate().


Friends And Related Function Documentation

ostream& operator<< ostream &  os,
const yieldCurve c
[friend]
 

Definition at line 100 of file yieldCurve.h.

ostream& operator<< ostream &  os,
const yieldCurve c
[friend]
 

display maturities and spotrates in the curve.

Parameters:
os - the output stream to direct output to
c - the curve to display
Returns:
output stream as is standard for operator<<

Definition at line 457 of file yieldCurve.cpp.


Member Data Documentation

valarray<yieldPoint> yieldCurve::_marketRates [private]
 

Definition at line 199 of file yieldCurve.h.

Referenced by assignFlatRate(), computeZCBRatesBootstrap(), getMaturitiesInTheMarketCurve(), getPointAtMaturity(), getSwapRates(), sortCashSwap(), and sortMarketRatesByMaturity().

char yieldCurve::_name[YC_NAME_STRLEN] [private]
 

Definition at line 201 of file yieldCurve.h.

Referenced by getName(), and yieldCurve().

valarray<yieldPoint> yieldCurve::_zcbRates [private]
 

Definition at line 200 of file yieldCurve.h.

Referenced by assignZCBrateAtIndex(), computeZCBRatesBootstrap(), forwardZCBCurve(), getMaturitiesInTheZCBCurve(), rotateZCBRateCurve(), shiftZCBRateCurve(), and spotRate().


The documentation for this class was generated from the following files:
Note: Generated nightly - reload for latest version
Generated on Thu Dec 22 23:12:40 2005 for terreneuve by doxygen 1.3.6