The normal way of constructing an interest rate curve is from a set of prices of traded instruments. The short end of the curve is typically specified by the money market rates while the longer end is specified by the interest rate swap rates.
The full list of information that is required to build a curve in this way is specified by the BNCDS::IRCurveBase class. This is a pure virtual class because it only defines the required information. Actual creation of a curve from this information is handled by the BNCDS::jw::Curve class as described below.
The BNCDS::IRCurvePub is the straightforward implementation of the BNCDS::IRCurveBase class in which each piece of information required for building the rate curve is exposed as a public member of the class. It therefore provides a fully open and public implementation of the BNCDS::IRCurvePub, but at a cost that internal consistency of the data can not be automatically maintained.
Since the members are publicly available they can be simply assigned to:
#include <boost/assign/list_of.hpp>
#include "bncds/jw/stringcnv.hpp"
#include "bncds/ircurve_pub.hpp"
/// A simple example of filling the BNCDS::IRCurvePub curve with all
/// the required information to create a rate curve
void example_ircurvepub_usage(BNCDS::IRCurvePub &irc)
{
// The types of each of the instruments
irc.m_types=boost::assign::list_of
('M')('M')('M')('M')('M')
('M')('S')('S')('S')('S')('S')('S')('S')('S');
// The expiry dates of each of the instruments
irc.m_terms=boost::assign::list_of
("1M")("2M")("3M")("6M")("9M")
("1Y")("2Y")("3Y")("4Y")("5Y")("6Y")("7Y")("8Y")("9Y");
// The quoted rates for each of the instruments
irc.m_rates=boost::assign::list_of
(0.003088)(0.004163)(0.005969)(0.011175)(0.013638)
(0.015975)(0.014770)(0.020908)(0.025598)(0.029021)(0.031631)(0.033551)(0.034907)(0.034907);
// The day count conveion of the money-market instruments
irc.m_mmDCC=BNCDS::dayCC("Act/360");
// The frequency of payments for the fixed leg of rate swaps
irc.m_fixedSwapFreq=BNCDS::dayIntrvlToFreq("6M");
// The frequency of payments for the floating leg of rate swaps
irc.m_floatSwapFreq=BNCDS::dayIntrvlToFreq("3M");
// The day count convention of the fixed leg of the rate swaps
irc.m_fixedSwapDCC=BNCDS::dayCC("30/360");
// The day count convention of the floating leg of the rate swaps
irc.m_floatSwapDCC=BNCDS::dayCC("ACT/360");
// The convention for dealing with non-business days.
irc.m_badDayConv='M';
}
The BNCDS::IRCurveBase class provides a straightforward for modifying the curve, as is for example usually done when computing sensitivities and durations. You can access the rate associated with each tenor by simply using the operator [] function and passing the tenor designation.
An example of modifying the curve is given below:
#include "bncds/ircurve_pub.hpp"
void example_modify_ircurvepub(const BNCDS::IRCurvePub &irc)
{
// Create a copy of the input curve
BNCDS::IRCurvePub irc_m(irc);
// Bump the 6-month tennor by 1 basis point
irc_m["6M"] += 1e-4;
}
Classes BNCDS::IRCurveBase and BNCDS::IRCurvePub contain the market information that define an interest rate curve. An actual curve, with a definitive base date at which it starts, and which defines discount factors for all dates after the base date is represented by objects of type BNCDS::jw::Curve. As the name suggests this is a class at a lower level of the interface which wraps the TCurve structure from the JPMCDS model.
The class BNCDS::jw::Curve constructs simply from a reference to a BNCDS::IRCurveBase and a base date:
#include <iostream>
#include "bncds/ircurve_pub.hpp"
#include "bncds/jw/date.hpp"
#include "bncds/jw/curve.hpp"
#include "bncds/jw/curve_io.hpp"
/// This illustrates how to construct an actual curve from the market
/// information contained in the BNCDS::IRCurvePub class. The curve in
/// this case is then only printed to the standard output
void example_construct_jwcurve(BNCDS::IRCurvePub &irc)
{
// This is the base date for the curve
const BNCDS::jw::Date base(2009, 7, 21);
// Construct the curve from market information
BNCDS::jw::Curve ircurve(base,
irc);
std::cout<<"The instantiated curve"
<<ircurve
<<std::endl;
}
This construction of the jw::Curve object is the equivalent to a call to JpmcdsBuildIRZeroCurve within the C-interface of the model.
The convention for EUR Swap instruments is that the payment frequency of the fixed leg of the swap is annual and the frequency of the floating leg is semi-annual:
#include "bncds/ircurve_pub.hpp"
#include "bncds/jw/stringcnv.hpp"
/// Approriate payment frequencies for typically quoted instruments
/// defining the EUR rate curve
void euro_curve_frequencies(BNCDS::IRCurvePub &irc)
{
/// Fixed leg has annual payment interval
irc.m_fixedSwapFreq=BNCDS::dayIntrvlToFreq("1Y");
/// Floating let has six-monthly payment interval
irc.m_floatSwapFreq=BNCDS::dayIntrvlToFreq("6M");
}
References: