Posted by
tallent_e on
Jan 09, 2013; 10:00am
URL: http://quantlib.414.s1.nabble.com/Re-Building-Yield-Curve-of-Zero-Rates-Theo-tp13887.html
Hi Theo.
Notice that the result you get is close to your benchmark.
First, check you use the right curve library: http://quantlib.org/reference/class_quant_lib_1_1_yield_term_structure.html as suggested by another person.
Then, watch your evaluation date. You don't show your complete snippet but this might be tricky (and firm-specific):
// http://quantcorner.wordpress.com/2011/01/31/us-treasury-notes-and-quantlib/
// Evaluation date
Integer fixingDays = 1;
Natural settlementDays = 1;
Date todaysDate = calendar.advance(settlementDate, -fixingDays, Days);
Settings::instance().evaluationDate() = todaysDate;
Last but not least, pay attention to the business day convention: adjusted/unajusted, modified, modified-following ?
I hope this helps a bit,
Best,
Édouard
--
http://quantcorner.wordpress.com
twitter: @tallent_e
linkedin: fr.linkedin.com/pub/édouard-tallent/8/145/7a/
4. ??: FW: Building Yield Curve of Zero Rates (Cheng Li)
Hi All,I have Sample of USD Zero Yield Curve Data as follows: Observation Date03/08/2012Maturity Days0,3,4,11,35,67,96,137,227,320,411,501,591,734,1099,1466,1830,2195,2560,2926,3293,3657,4387,5484,7311,9135,10961,Yield0,1.57151762841849E-03,1.5841928756397E-03,1.80193133074194E-03,2.37422375119134E-03,3.30406684491067E-03,4.35679286119092E-03,3.56334288917869E-03,3.69745160830227E-03,3.77125648757358E-03,3.84515157443031E-03,3.92832387415253E-03,4.03993077763243E-03,4.35625780531457E-03,5.08068564885412E-03,6.4706614338575E-03,8.38591062422842E-03,0.010332793648027,1.21710204339663E-02,1.38041853050158E-02,1.52910208160213E-02,1.67279197064853E-02,1.89718781527944E-02,2.12626395949329E-02,2.31753447176866E-02,2.41372894297357E-02,2.47383920090547E-02InterpolationTypeLinearExtrapolation TypenearDayCount ConventionACT365FIXEDCompunding FrequencyCONTINUOUS,So I build a vector<QuantLib::Date> yieldMaturities, vector<Rate> yieldsfrom the information above.In the case of vector<QuantLib::Date> yieldMaturities, I just add theMaturity Days to observation date.I now build the yieldCurve asHandle<YieldTermStructure> yieldCurve(boost::shared_ptr<YieldTermStructure>(new ForwardCurve(yieldMaturities,yields, dayCountConv)));Then pass to boost::shared_ptr<BlackProcess> blackProcess(new BlackProcess(underlyingH, yieldCurve,flatVolTS));as I am cant determine what the zero rate will be for the exercise dateof the option.Now given this option is on a commodity forward, I want to discount frompayment date.Hence have DiscountFactor expiryDiscount =blackProcess->riskFreeRate()->discount(europeanExercise->lastDate());DiscountFactor paymentDiscount =blackProcess->riskFreeRate()->discount(paymentDate);Real forwardValue = europeanOption.NPV()/expiryDiscount;Real presentValue = forwardValue * paymentDiscount;My PV is slightly off the PV from another system.The market data is the same in both systems, except for the differencein discount factors.The paymentDiscount factor in Quantlib is 0.9990450902703203, whilstthat from the other system is 0.9987391782033116, hence diff in PV.I am wondering whether my yieldCurve of Zeros has been constructedproperly. Also its seems YieldTermStructure takes in market quotes and boostrapszero rates from it. So Given I already have Zero rates, have Icontstructed the Zero Yield Curve propely? Looks like I have not donesomething right.RegardsTheoRegardsTheo
------------------------------------------------------------------------------
Master Java SE, Java EE, Eclipse, Spring, Hibernate, JavaScript, jQuery
and much more. Keep your Java skills current with LearnJavaNow -
200+ hours of step-by-step video tutorials by Java experts.
SALE $49.99 this month only -- learn more at:
http://p.sf.net/sfu/learnmore_122612 _______________________________________________
QuantLib-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/quantlib-users