Posted by
rob.philipp on
URL: http://quantlib.414.s1.nabble.com/way-to-shift-curve-tp1498p1499.html
Here is a code snippet to shock the entire curve. Just modify the spread
vector to shock the points you like.
std::cout << "Shocking the term structure" << std::endl;
std::vector< Date > zeroDates( 180 );
std::vector< Handle< Quote> > spreads( 180 );
for( int t = 1; t < 2; ++t )
{
Date date = depoFutSwap->referenceDate() + Period( t, Months );
zeroDates.push_back( date );
spreads.push_back( Handle< Quote >( new SimpleQuote( 0.005
) ) );
std::cout << date << std::endl;
}
std::cout << std::endl;
Handle< YieldTermStructure > depoFutSwapHandle( depoFutSwap,
false );
PiecewiseZeroSpreadedTermStructure curve( depoFutSwapHandle,
spreads, zeroDates );
std::cout << "Shocked Spot Rates and Forward Rates
(Depo-Fut-Swap)" << std::endl;
for( Time t = 0; t < 180; ++t )
{
std::cout << t << ", " << curve.zeroRate( t / 12,
Compounded ).rate()
<< ", " << curve.forwardRate( t/12, t/12, Compounded ).rate()
<< std::endl;
}
Robert Philipp
Synapse Financial Engineering
703.623.4063 (mobile)
703.261.6799 (fax)
[hidden email]
www.synapsefe.com
On 7/22/2011 11:03 PM, Shuo Wang wrote:
> Hi,
>
> I am very new to quantlib, may I know what is the easiest way to shift
> a YieldTermStructure, at a key rate, say 5 year, up by 10bps?
>
------------------------------------------------------------------------------
Storage Efficiency Calculator
This modeling tool is based on patent-pending intellectual property that
has been used successfully in hundreds of IBM storage optimization engage-
ments, worldwide. Store less, Store more with what you own, Move data to
the right place. Try It Now!
http://www.accelacomm.com/jaw/sfnl/114/51427378/_______________________________________________
QuantLib-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/quantlib-users