Hi
I was hoping someone could help me or direct me to a thread that has the answer to my question. I am relatively new to quant lib and to quant finance but I am trying to use the CashFlows::bps to calculate the PV01 value of the 30yr US Gov treasury bond benchmark and I am having difficulty matching the result with the Bloomberg figure. Firstly, am I right in thinking that the bps is equivalent to the PV01? I have noted in version 0.9.7 that there is a BasisPointValue (BPV) function but this does not seem to give me the value I need either. I am able to obtain the Bloomberg figure in excel using the following formula : PV01 = mod duration * dirty price /100 I am using the last traded yield as the spot rate in the mod duration and the last traded price + AI for the dirty price. For instance, Bloomberg gave the 5yr note (3.5, 02/15/2039) on the 04/06/2009, while trading at 95.25 a PV01 of 0.17389. With QuantLib I get bps = 0.179575 and a BPV =-0.171849. I have printed some snippet of the code I am using below with the data I am adding into the parameters. Does this data look right or am I modelling it wrong somehow? I am able to get accurate yield figures using the bond object so I am fairly confident the bond object is okay. I am using the compounded option so i am assuming this is okay for PV01/BPS too. I am using the abbreviated bps function and so I am not defining my own YieldTermStructure. I was wondering if I need to create a more specific structure rather than relying on the default FlatForward structure that is created within the bps function? I thought about using quantlib to obtain the modified duration to use in the equation above but again I cannot seem to get the numbers to match with my test data. Finally, I also noticed that the BasisPointValue value does not change as the settlement date changes, is that correct? Any help would be great. Thanks Michael double CBondYieldCalculator::CalculatePV01() { bool bIsEOM = false; if(QuantLib::Date::isEndOfMonth(m_pBondDetails->m_MaturityDate)) //m_pBondDetails created and populated somewhere else { bIsEOM = true; } QuantLib::Schedule sch( m_pBondDetails->m_DatedDate, //03/31/2009 m_pBondDetails->m_MaturityDate, //03/31/2014 QuantLib::Period(m_pBondDetails->m_CouponFrequency), //freq = semi-annual m_pBondDetails->m_Calendar, //US m_pBondDetails->m_accrual, //unadjusted m_pBondDetails->m_payment, //unadjusted QuantLib::DateGeneration::Backward, bIsEOM); //boolean must be set depending on whether it is an end of month (EOM) bond m_pbond = new QuantLib::FixedRateBond(m_pBondDetails->m_Settlement, //1 m_pBondDetails->m_faceAmount, //100 sch, std::vector<QuantLib::Rate>(1,m_pBondDetails->m_CouponAmount), //0.0175 m_pBondDetails->m_DayCount, //actual/actual m_pBondDetails->m_payment, //unadjusted m_pBondDetails->m_Redemption, //100 m_pBondDetails->m_IssueDate); //03/31/09 QuantLib::Real accuracy = 1.0e-15; QuantLib::Real Price = m_md.LastPrice //N.B. m_md = a stored market data object QuantLib::Real lastyield = m_pbond->yield(Price, m_pBondDetails->m_DayCount, QuantLib::Compounded, m_pBondDetails->m_CouponFrequency, m_pBondDetails->m_SettlementDate, // T+1 so 04/07/2009 accuracy, 200); QuantLib::InterestRate IR(lastyield, m_pBondDetails->m_DayCount, QuantLib::Compounded, m_pBondDetails->m_CouponFrequency); QuantLib::Real bps = QuantLib::CashFlows::bps(m_pbond->cashflows(), IR, m_pBondDetails->m_SettlementDate); QuantLib::Real BasisPointvalue = QuantLib::CashFlows::basisPointValue( m_pbond->cashflows(), IR, m_pBondDetails->m_SettlementDate); QuantLib::Real ModDuration = QuantLib::CashFlows::duration( m_pbond->cashflows(), IR, QuantLib::Duration::Modified, m_pBondDetails->m_SettlementDate); TRACE1("bps : %f\n", bps); TRACE1("Mod duration : %f\n", ModDuration ); TRACE1("BasisPointvalue : %f\n", BasisPointvalue); return bps; } ------------------------------------------------------------------------------ This SF.net email is sponsored by: High Quality Requirements in a Collaborative Environment. Download a free trial of Rational Requirements Composer Now! http://p.sf.net/sfu/www-ibm-com _______________________________________________ QuantLib-users mailing list [hidden email] https://lists.sourceforge.net/lists/listinfo/quantlib-users |
On Mon, 2009-04-06 at 09:11 -0700, [hidden email] wrote:
> Firstly, am I right in thinking that the bps is equivalent to the > PV01? Not exactly. The PV01 is the change in the bond price if you modify its yield by 1 basis point. The BPS is the change in the bond price if you modify its coupon rate by 1 basis point. I don't think that we have a ready-made function to calculate PV01 at this time, but you can get it numerically by adding the basis point manually and recalculating the bond price. Luigi -- Better to remain silent and be thought a fool than to speak out and remove all doubt. -- Abraham Lincoln ------------------------------------------------------------------------------ This SF.net email is sponsored by: High Quality Requirements in a Collaborative Environment. Download a free trial of Rational Requirements Composer Now! http://p.sf.net/sfu/www-ibm-com _______________________________________________ QuantLib-users mailing list [hidden email] https://lists.sourceforge.net/lists/listinfo/quantlib-users |
Free forum by Nabble | Edit this page |