DiscountCurve2





http://www.QuantTools.com
CapeTools Curves function list

Welcome | Documentation format | QuantTools Groups | QuantTools Categories | Licence

Key TAGs | Excel Index | API Index



Creates a discount curve from Tenors (or Dates) and discount factor inputs.

Whether using Tenors or Dates, the first point must be a date value equal to the ValueDate value (passed into the 'ValueDate' parameter of this function) and must have a discount value of 1. Further points most have discount value inputs of decreasing value but values greater than 0. This curve can be used for retrieving forward rates, discount factors and zero rates.

Can also be used to price market instruments, deposits, futures, FRAs, CMS and Swap rates.

This function requires the input of a IndexKey template object key, which must have been produced via a call to CreateDepoTemplate(). This function would have returned a string 'KEY' which is to be passed to the 'DepoIndex' parameter of this function.

This function requires the input of a SWAP IndexKey template object key, which must have been produced via a call to CreateSwapTemplate(). This function would have returned a string 'KEY' which is to be passed to the 'Swap Index' parameter of this function.

This function requires the input of a Calendar object key, which must have been produced via a call to one of the Calendar creation functions present within the CapeTools Calendars category of functions.

These functions would have returned a string 'KEY' which is to be passed to the 'Cal' parameter of this function.

For the 'DayCount' and 'BusDayConv' parameters, please refer to the large number of enumeration functions present within the CapeTools Enums category of functions.

The CapeTools Enums category of functions return correct string codes that can be passed to parameters taking fixed string values defined by the library (ie - DayCount codes, frequency codes, currency codes, compounding codes, business day convention codes etc...).

You can thus execute these enumeration functions which return the proper code, instead of trying to remember the string code needed or making spelling mistakes which can be difficult to debug.



This function creates an object and returns a string-key value to represent this created object.
The TAG value of the string-key returned (second part of the key) is : "DYC2"



Note: Within Excel, the function is named - CT.CRV.DiscountCurve2




High level graphic of DiscountCurve2() function with parameters. Blue square node is the actual function with the parameters ordered.



Parameter Description


  1. Key parameter

    Key value to use as a handle for the created object
  2. Reload parameter

    When creating this object for the first time, set this parameter to a positive value. Within Excel, when re-computing a worksheet where you do not wish to recreate the object, set this parameter to zero (0).
  3. CurveName parameter

    A tag used to identify this curve (case insensitive) if placed within a Yieldcurve collection ( via the GroupedCurves() function ). If you pass in an empty string, it will default to the name of the 'Key' parameter.
  4. ValueDate parameter

    Key to an already created Valuation Date Object. (Via the ValueDateObj() function).
  5. oTenorsVals parameter

    A 2 column range of Tenors (or Dates) and discount factors.
  6. DayCount parameter

    DayCounter for converting dates into year fractions.
  7. DepoIndex parameter

    Deposit (Libor) Index Template Key. (Created via the CreateDepoTemplate() function). This is the minimum definition of an interest rate index ( ie - LIBOR ) and is the one used by the curve. If this curve allows Deposit or FRA instrument as inputs, then the definition of those instruments are specified via this template (minus the 'Tenor' information). In addition, if this curve is passed to an Index creation function ( functions within the 'CapeTools Indexes' category of functions) then this index will serve as the definition of one side of an interest rate BasisSwap transaction. Basically, provides the definition of a BasisSwap between this index template and the index defined by the index-creation function.
  8. SwapIndex parameter

    Swap Index Template Key. (Created via the CreateSwapTemplate() function). This object provides the minimum definition of an interest rate Swap and is the one used by the curve. If this curve allows for Swap instrument as inputs, then the definition of those instruments are specified via this template. This object is also used by other functions when requesting a Swap rate without the underlying swap rate definition.
  9. Extrapolate parameter

    Whether the yieldCurve data should be extrapolated if a calculation request that uses a date that is beyond the end date of the yieldCurve (ie - a request for a 40 year discount factor, but the curve is only built up to 30 years.) If false an error will be returned. This setting is set globally for the whole curve. We strongly advise you to populate the curve up to the point you are pricing to.


Extended information

Function Syntax

VB Syntax


String CTCurves.DiscountCurve2( _
String Key, _
Long Reload, _
String CurveName, _
String ValueDate, _
Variant oTenorsVals, _
DayCountEnum DayCount, _
String DepoIndex, _
String SwapIndex, _
Boolean Extrapolate)


Excel Spreadsheet Syntax


=CT.CRV.DiscountCurve2(
Excel String Cell Key,
Excel Numeric Cell Reload,
Excel String Cell CurveName,
Excel String Cell ValueDate,
XLRange oTenorsVals,
Excel String Cell DayCount,
Excel String Cell DepoIndex,
Excel String Cell SwapIndex,
Excel Boolean Value Cell Extrapolate)


C++ Syntax


static std::string DiscountCurve2(
std::string Key,
long Reload,
std::string CurveName,
std::string ValueDate,
CTRangeDataCPP oTenorsVals,
DayCountEnum DayCount,
std::string DepoIndex,
std::string SwapIndex,
bool Extrapolate);


DotNET Syntax


System.String CTCurvesSA.DiscountCurve2(
System.String Key,
System.Int32 Reload,
System.String CurveName,
System.String ValueDate,
CTRangeData oTenorsVals,
CTIEnums.DayCountEnum DayCount,
System.String DepoIndex,
System.String SwapIndex,
System.Boolean Extrapolate);

Parameter data types

ArgNameArgTypeIsKey
KeyStringFALSE
ReloadLongFALSE
CurveNameStringFALSE
ValueDateStringTRUE
oTenorsValsRangeFALSE
DayCountDayCountEnumFALSE
DepoIndexStringTRUE
SwapIndexStringTRUE
ExtrapolateBooleanFALSE


Example Inputs

The first column represents the name of the parameters. The second column specifies whether the parameters are optional or not. Finally the last column provides some sample input data.
Function call input string-keys are always in the format : "NAME.EXTTAG.TICKER" The "EXTTAG.TICKER" part is determined from the output of other, capetools, object creation functions.


ArgNameIsOptional (Excel only)Example
KeyFALSEMyDiscountCurve2
ReloadFALSE1
CurveNameTRUEMyDiscountCurve
ValueDateFALSEValueDateNAME.EXTTAG.TICKER (from a function call)
oTenorsValsFALSEDiscountCurve2_oTenorsVals_Range (creates a range object)
DayCountFALSEACT365F
DepoIndexFALSEDepoIndexNAME.EXTTAG.TICKER (from a function call)
SwapIndexFALSESwapIndexNAME.EXTTAG.TICKER (from a function call)
ExtrapolateFALSEtrue


Example range for parameter : oTenorsVals

Within Excel, a range such as this can be passed directly into the oTenorsVals parameter.

19/Jul/20051True
1M0.99449True
2M0.98532True
3M0.97837True
4M0.97256True
5M0.96531True
6M0.95551True
7M0.94676True
8M0.94119True
9M0.93245True
10M0.92318True
2Y0.90358True
3Y0.89645True
4Y0.88086True
5Y0.86642True
6Y0.85052True
7Y0.83706True
8Y0.82289True
9Y0.81462True
10Y0.79767True
11Y0.78375True
12Y0.76553True
13Y0.75642True
14Y0.73867True
15Y0.72086True
16Y0.70395True
17Y0.6927True
18Y0.67272True
19Y0.65829True
20Y0.65091True
21Y0.63988True

Example C# API usage for setting the range data for parameter : oTenorsVals



CTQL.CTRangeData DiscountCurve2_oTenorsVals = new CTQL.CTRangeData();

System.Text.StringBuilder DiscountCurve2_oTenorsVals_builder =
new System.Text.StringBuilder(100);

DiscountCurve2_oTenorsVals_builder.Append("{");
DiscountCurve2_oTenorsVals_builder.Append("#19/Jul/2005#	 | 1	 | True ;");
DiscountCurve2_oTenorsVals_builder.Append("'1M'	 | 0.99449	 | True ;");
DiscountCurve2_oTenorsVals_builder.Append("'2M'	 | 0.98532	 | True ;");
DiscountCurve2_oTenorsVals_builder.Append("'3M'	 | 0.97837	 | True ;");
DiscountCurve2_oTenorsVals_builder.Append("'4M'	 | 0.97256	 | True ;");
DiscountCurve2_oTenorsVals_builder.Append("'5M'	 | 0.96531	 | True ;");
DiscountCurve2_oTenorsVals_builder.Append("'6M'	 | 0.95551	 | True ;");
DiscountCurve2_oTenorsVals_builder.Append("'7M'	 | 0.94676	 | True ;");
DiscountCurve2_oTenorsVals_builder.Append("'8M'	 | 0.94119	 | True ;");
DiscountCurve2_oTenorsVals_builder.Append("'9M'	 | 0.93245	 | True ;");
DiscountCurve2_oTenorsVals_builder.Append("'10M'	 | 0.92318	 | True ;");
DiscountCurve2_oTenorsVals_builder.Append("'2Y'	 | 0.90358	 | True ;");
DiscountCurve2_oTenorsVals_builder.Append("'3Y'	 | 0.89645	 | True ;");
DiscountCurve2_oTenorsVals_builder.Append("'4Y'	 | 0.88086	 | True ;");
DiscountCurve2_oTenorsVals_builder.Append("'5Y'	 | 0.86642	 | True ;");
DiscountCurve2_oTenorsVals_builder.Append("'6Y'	 | 0.85052	 | True ;");
DiscountCurve2_oTenorsVals_builder.Append("'7Y'	 | 0.83706	 | True ;");
DiscountCurve2_oTenorsVals_builder.Append("'8Y'	 | 0.82289	 | True ;");
DiscountCurve2_oTenorsVals_builder.Append("'9Y'	 | 0.81462	 | True ;");
DiscountCurve2_oTenorsVals_builder.Append("'10Y'	 | 0.79767	 | True ;");
DiscountCurve2_oTenorsVals_builder.Append("'11Y'	 | 0.78375	 | True ;");
DiscountCurve2_oTenorsVals_builder.Append("'12Y'	 | 0.76553	 | True ;");
DiscountCurve2_oTenorsVals_builder.Append("'13Y'	 | 0.75642	 | True ;");
DiscountCurve2_oTenorsVals_builder.Append("'14Y'	 | 0.73867	 | True ;");
DiscountCurve2_oTenorsVals_builder.Append("'15Y'	 | 0.72086	 | True ;");
DiscountCurve2_oTenorsVals_builder.Append("'16Y'	 | 0.70395	 | True ;");
DiscountCurve2_oTenorsVals_builder.Append("'17Y'	 | 0.6927	 | True ;");
DiscountCurve2_oTenorsVals_builder.Append("'18Y'	 | 0.67272	 | True ;");
DiscountCurve2_oTenorsVals_builder.Append("'19Y'	 | 0.65829	 | True ;");
DiscountCurve2_oTenorsVals_builder.Append("'20Y'	 | 0.65091	 | True ;");
DiscountCurve2_oTenorsVals_builder.Append("'21Y'	 | 0.63988	 | True");
DiscountCurve2_oTenorsVals_builder.Append("}");

// Parse the string into the Range object.
DiscountCurve2_oTenorsVals.RangeFromStr( DiscountCurve2_oTenorsVals_builder.ToString() );



Example function usage


The C# example below contains all the sub-function calls leading up to this function call. As a result, the example can contain a lot of code.

The VB.NET, J#, C++.NET, Java, Excel VBA, Visual Basic 6 (via COM) and C++ examples below contain function code stubs for the calls leading up to this function call. However, the function call for this function is displayed.
You can easily reproduce the stub functions code from the C# example.


If you are accessing this functrion via the MiniXL libraries, this function is present within the CT.QL.Curves20 MiniXL Excel Addin.

Within our Excel Example Addin Generator, we have used the following QuantTools sub-functions in order to prepare the arguments needed to call the DiscountCurve2() function. If you are executing this function via the MiniXL libraries, the module addin name, (in brackets, to the right of the sub-functions listed below), indicates the MiniXL library in which the sub-function is held. You will need to load this library into your Excel session (along with any other libraries that the sub-function call within the addin requires (ie - CT.QT.Utils20 addin in almost all cases) in order for the example to compute successfully.

These are the financial QuantTools sub-function calls that are used within the examples :





The objects generated by these sub-functions are inter-connected in the following way :




The following four examples demostrate calling this function within a Microsoft .NET environment

The following four examples demostrate calling this function within a non .NET environment

The following is a sample output from executing the DiscountCurve2() function call


MyDiscountCurve2_6.DYC2.0

Copyright (c) 2003-2007 CapeTools - All Rights Reserved.