CreateSwapIndex





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

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

Key TAGs | Excel Index | API Index



Creates a new Index based on SWAP details.

Used when pricing CMS swaps or creating SWAP deals quickly with minimal arguments.

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.

There are nine algorithms that you can specify for the computation of the CMS adjustments.

Hull (which is described in 'Options, Futures, and derivatives' 5th Edition, pp600) and the other eight algorithms are based on Hagan ('Convexity Conundrums: Pricing CMS Swaps, Caps, and Floors', wilmott magazine) . HaganFullStd (integration via swaptions using Bond maths) is based on - equations 2.19a and A.3. HaganFullExact (integration via swaptions using exact yields) is based on - equations 2.19a and A.8. HaganFullPShift (integration via swaptions using Parallel shifts) is based on - equations 2.19a and A.12a. HaganFullNonPShift (integration via swaptions using Non-Parallel shifts) is based on - equations 2.19a and A.15a. HaganBlackStd (Analytical version of Hagan's formula using the Black model coupled with Bond maths) is based on - equations 3.5a and A.3. HaganBlackExact (Analytical version of Hagan's formula using the Black model coupled with exact yield calculations) is based on - equations 3.5a and A.8. HaganBlackPShift (Analytical version of Hagan's formula using the Black model coupled with Parallel shifts) is based on - equations 3.5a and A.12a. HaganBlackNonPShift (Analytical version of Hagan's formula using the Black model coupled with Non-Parallel shifts) is based on - equations 3.5a and A.15a. In terms of rate convexity adjustment, 'Hull' is the fastest but the least accurate.

Next we have 'HaganBlackStd', 'HaganBlackPShift', 'HaganBlackNonPShift' and 'HaganBlackExact'. These are quite fast also however they suffer from the fact that they do not take advantage of the volatility smile.

They use the ATM volatility only within their convexity formula.

'Hull' also uses ATM volatilities but uses a different method to handle CMS payment date adjustments.

The most accurate, but the slowest are the 'HaganFullStd', 'HaganFullPShift', 'HaganFullNonPShift' and 'HaganFullExact' algorithms.

They try to capture the volatility smile via the integration of swaptions.

We have made some optimizations to the volatility curves to detect when the 'HaganFullStd' and 'HaganFullExact' are being conducted and thus optimise volatility retrival.

Finally the value within the 'CMSAlgo' parameter determines the algorithm used for the computation of CMS caplets and floorlets.

'HaganBlackStd' will be used if 'Hull' is specified.

CMS Caplets and Floorlets are computed via CALL-PUT Parity.



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 : "SWIDX"



Note: Within Excel, the function is named - CT.IDX.CreateSwapIndex




High level graphic of CreateSwapIndex() 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. SwapIndName parameter

    A Tag name you would like the new Swap Index code to display when querying.
  4. SwapTenor parameter

    The tenor of the swap index.
  5. SettlDays parameter

    The number of days till settlement.
  6. SwapFreq parameter

    Frequency of the FIX side of the swap.
  7. SwapDayCount parameter

    DayCount code to use for the FIX side of the swap.
  8. SwapBusDayConv parameter

    Business day convention code to use for the FIX side of the swap.
  9. FixLegCal parameter

    Calendar Key required for adjusting the end dates of each cash flow on the FIX leg of the swap.
  10. IndexKey parameter

    Key to an already constructed Libor Index key. This Index contains all the information for the Float side of the swap.
  11. CMSAlgo parameter

    The CMS algorithm to apply. Possible values are 'Hull', 'HaganFullStd' (integration via swaptions using Bond maths), 'HaganFullExact' (integration via swaptions using exact yields), 'HaganFullPShift' (integration via swaptions using Parallel shifts), 'HaganFullNonPShift' (integration via swaptions using Non-Parallel shifts), 'HaganBlackStd' (Analytical version of Hagan's formula using the Black model coupled with Bond maths), 'HaganBlackExact' (Analytical version of Hagan's formula using the Black model coupled with exact yield calculations), , 'HaganBlackPShift' (Analytical version of Hagan's formula using the Black model coupled with Parallel shifts) or 'HaganBlackNonPShift' (Analytical version of Hagan's formula using the Black model coupled with Non-Parallel shifts).
  12. CMSMeanRev parameter

    If the 'CMSAlgo' parameter is set to 'HaganBlackNonPShift' or 'HaganFullNonPShift' then a positive mean reversion parameter is required.
  13. PastFixings parameter

    Optional Swap past fixings range.


Extended information

Function Syntax

VB Syntax


String CTIndexes.CreateSwapIndex( _
String Key, _
Long Reload, _
String SwapIndName, _
String SwapTenor, _
Long SettlDays, _
FreqEnum SwapFreq, _
DayCountEnum SwapDayCount, _
BDCEnum SwapBusDayConv, _
String FixLegCal, _
String IndexKey, _
String CMSAlgo, _
Double CMSMeanRev, _
Variant PastFixings)


Excel Spreadsheet Syntax


=CT.IDX.CreateSwapIndex(
Excel String Cell Key,
Excel Numeric Cell Reload,
Excel String Cell SwapIndName,
Excel String Cell SwapTenor,
Excel Numeric Cell SettlDays,
Excel String Cell SwapFreq,
Excel String Cell SwapDayCount,
Excel String Cell SwapBusDayConv,
Excel String Cell FixLegCal,
Excel String Cell IndexKey,
Excel String Cell CMSAlgo,
Excel Numeric Cell CMSMeanRev,
XLRange PastFixings)


C++ Syntax


static std::string CreateSwapIndex(
std::string Key,
long Reload,
std::string SwapIndName,
std::string SwapTenor,
long SettlDays,
FreqEnum SwapFreq,
DayCountEnum SwapDayCount,
BDCEnum SwapBusDayConv,
std::string FixLegCal,
std::string IndexKey,
std::string CMSAlgo,
double CMSMeanRev,
CTRangeDataCPP PastFixings);


DotNET Syntax


System.String CTIndexesSA.CreateSwapIndex(
System.String Key,
System.Int32 Reload,
System.String SwapIndName,
System.String SwapTenor,
System.Int32 SettlDays,
CTIEnums.FreqEnum SwapFreq,
CTIEnums.DayCountEnum SwapDayCount,
CTIEnums.BDCEnum SwapBusDayConv,
System.String FixLegCal,
System.String IndexKey,
System.String CMSAlgo,
System.Double CMSMeanRev,
CTRangeData PastFixings);

Parameter data types

ArgNameArgTypeIsKey
KeyStringFALSE
ReloadLongFALSE
SwapIndNameStringFALSE
SwapTenorStringFALSE
SettlDaysLongFALSE
SwapFreqFreqEnumFALSE
SwapDayCountDayCountEnumFALSE
SwapBusDayConvBDCEnumFALSE
FixLegCalStringTRUE
IndexKeyStringTRUE
CMSAlgoStringFALSE
CMSMeanRevDoubleFALSE
PastFixingsRangeFALSE


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
KeyFALSEMySwapIndex
ReloadFALSE1
SwapIndNameFALSE5YSwap_A
SwapTenorFALSE5Y
SettlDaysFALSE2
SwapFreqFALSEA
SwapDayCountFALSE30360
SwapBusDayConvFALSEMonthEndReference
FixLegCalFALSEFixLegCalNAME.EXTTAG.TICKER (from a function call)
IndexKeyFALSEIndexKeyNAME.EXTTAG.TICKER (from a function call)
CMSAlgoFALSEHaganBlackStd
CMSMeanRevTRUE0.01
PastFixingsTRUECreateSwapIndex_PastFixings_Range (creates a range object)


Example range for parameter : PastFixings

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

21/Mar/20050.0551
22/Mar/20050.0552
23/Mar/20050.0552
24/Mar/20050.0548
25/Mar/20050.0549
28/Mar/20050.0551
29/Mar/20050.0552
30/Mar/20050.0552
31/Mar/20050.0549
1/Apr/20050.0551
4/Apr/20050.0551
5/Apr/20050.055
6/Apr/20050.0552
7/Apr/20050.0551
8/Apr/20050.0548
11/Apr/20050.0549
12/Apr/20050.055
13/Apr/20050.0549
14/Apr/20050.0549
15/Apr/20050.0548
18/Apr/20050.0551
19/Apr/20050.055
20/Apr/20050.0549
21/Apr/20050.0552
22/Apr/20050.0551
25/Apr/20050.0552
26/Apr/20050.0549
27/Apr/20050.0548
28/Apr/20050.0551
29/Apr/20050.0549
2/May/20050.0549
3/May/20050.0551
4/May/20050.055
5/May/20050.0551
6/May/20050.0549
9/May/20050.0549
10/May/20050.0549
11/May/20050.0551
12/May/20050.055
13/May/20050.0548
16/May/20050.0552
17/May/20050.0549
18/May/20050.0548
19/May/20050.0548
20/May/20050.0548
23/May/20050.0551
24/May/20050.0548
25/May/20050.055
26/May/20050.0548
27/May/20050.0551
30/May/20050.0549
31/May/20050.0548
1/Jun/20050.0551
2/Jun/20050.0548
3/Jun/20050.0549
6/Jun/20050.0548
7/Jun/20050.0548
8/Jun/20050.0549
9/Jun/20050.0551
10/Jun/20050.055
13/Jun/20050.0551
14/Jun/20050.055
15/Jun/20050.055
16/Jun/20050.0549
17/Jun/20050.0552
20/Jun/20050.0548
21/Jun/20050.0551
22/Jun/20050.0551
23/Jun/20050.0549
24/Jun/20050.0549
27/Jun/20050.0551
28/Jun/20050.055
29/Jun/20050.0549
30/Jun/20050.0551
1/Jul/20050.0551
4/Jul/20050.0549
5/Jul/20050.0549
6/Jul/20050.0549
7/Jul/20050.0552
8/Jul/20050.0552
11/Jul/20050.0551
12/Jul/20050.0549
13/Jul/20050.055
14/Jul/20050.0549
15/Jul/20050.0549

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



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

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

CreateSwapIndex_PastFixings_builder.Append("{");
CreateSwapIndex_PastFixings_builder.Append("#21/Mar/2005#	 | 0.0551 ;");
CreateSwapIndex_PastFixings_builder.Append("#22/Mar/2005#	 | 0.0552 ;");
CreateSwapIndex_PastFixings_builder.Append("#23/Mar/2005#	 | 0.0552 ;");
CreateSwapIndex_PastFixings_builder.Append("#24/Mar/2005#	 | 0.0548 ;");
CreateSwapIndex_PastFixings_builder.Append("#25/Mar/2005#	 | 0.0549 ;");
CreateSwapIndex_PastFixings_builder.Append("#28/Mar/2005#	 | 0.0551 ;");
CreateSwapIndex_PastFixings_builder.Append("#29/Mar/2005#	 | 0.0552 ;");
CreateSwapIndex_PastFixings_builder.Append("#30/Mar/2005#	 | 0.0552 ;");
CreateSwapIndex_PastFixings_builder.Append("#31/Mar/2005#	 | 0.0549 ;");
CreateSwapIndex_PastFixings_builder.Append("#1/Apr/2005#	 | 0.0551 ;");
CreateSwapIndex_PastFixings_builder.Append("#4/Apr/2005#	 | 0.0551 ;");
CreateSwapIndex_PastFixings_builder.Append("#5/Apr/2005#	 | 0.055 ;");
CreateSwapIndex_PastFixings_builder.Append("#6/Apr/2005#	 | 0.0552 ;");
CreateSwapIndex_PastFixings_builder.Append("#7/Apr/2005#	 | 0.0551 ;");
CreateSwapIndex_PastFixings_builder.Append("#8/Apr/2005#	 | 0.0548 ;");
CreateSwapIndex_PastFixings_builder.Append("#11/Apr/2005#	 | 0.0549 ;");
CreateSwapIndex_PastFixings_builder.Append("#12/Apr/2005#	 | 0.055 ;");
CreateSwapIndex_PastFixings_builder.Append("#13/Apr/2005#	 | 0.0549 ;");
CreateSwapIndex_PastFixings_builder.Append("#14/Apr/2005#	 | 0.0549 ;");
CreateSwapIndex_PastFixings_builder.Append("#15/Apr/2005#	 | 0.0548 ;");
CreateSwapIndex_PastFixings_builder.Append("#18/Apr/2005#	 | 0.0551 ;");
CreateSwapIndex_PastFixings_builder.Append("#19/Apr/2005#	 | 0.055 ;");
CreateSwapIndex_PastFixings_builder.Append("#20/Apr/2005#	 | 0.0549 ;");
CreateSwapIndex_PastFixings_builder.Append("#21/Apr/2005#	 | 0.0552 ;");
CreateSwapIndex_PastFixings_builder.Append("#22/Apr/2005#	 | 0.0551 ;");
CreateSwapIndex_PastFixings_builder.Append("#25/Apr/2005#	 | 0.0552 ;");
CreateSwapIndex_PastFixings_builder.Append("#26/Apr/2005#	 | 0.0549 ;");
CreateSwapIndex_PastFixings_builder.Append("#27/Apr/2005#	 | 0.0548 ;");
CreateSwapIndex_PastFixings_builder.Append("#28/Apr/2005#	 | 0.0551 ;");
CreateSwapIndex_PastFixings_builder.Append("#29/Apr/2005#	 | 0.0549 ;");
CreateSwapIndex_PastFixings_builder.Append("#2/May/2005#	 | 0.0549 ;");
CreateSwapIndex_PastFixings_builder.Append("#3/May/2005#	 | 0.0551 ;");
CreateSwapIndex_PastFixings_builder.Append("#4/May/2005#	 | 0.055 ;");
CreateSwapIndex_PastFixings_builder.Append("#5/May/2005#	 | 0.0551 ;");
CreateSwapIndex_PastFixings_builder.Append("#6/May/2005#	 | 0.0549 ;");
CreateSwapIndex_PastFixings_builder.Append("#9/May/2005#	 | 0.0549 ;");
CreateSwapIndex_PastFixings_builder.Append("#10/May/2005#	 | 0.0549 ;");
CreateSwapIndex_PastFixings_builder.Append("#11/May/2005#	 | 0.0551 ;");
CreateSwapIndex_PastFixings_builder.Append("#12/May/2005#	 | 0.055 ;");
CreateSwapIndex_PastFixings_builder.Append("#13/May/2005#	 | 0.0548 ;");
CreateSwapIndex_PastFixings_builder.Append("#16/May/2005#	 | 0.0552 ;");
CreateSwapIndex_PastFixings_builder.Append("#17/May/2005#	 | 0.0549 ;");
CreateSwapIndex_PastFixings_builder.Append("#18/May/2005#	 | 0.0548 ;");
CreateSwapIndex_PastFixings_builder.Append("#19/May/2005#	 | 0.0548 ;");
CreateSwapIndex_PastFixings_builder.Append("#20/May/2005#	 | 0.0548 ;");
CreateSwapIndex_PastFixings_builder.Append("#23/May/2005#	 | 0.0551 ;");
CreateSwapIndex_PastFixings_builder.Append("#24/May/2005#	 | 0.0548 ;");
CreateSwapIndex_PastFixings_builder.Append("#25/May/2005#	 | 0.055 ;");
CreateSwapIndex_PastFixings_builder.Append("#26/May/2005#	 | 0.0548 ;");
CreateSwapIndex_PastFixings_builder.Append("#27/May/2005#	 | 0.0551 ;");
CreateSwapIndex_PastFixings_builder.Append("#30/May/2005#	 | 0.0549 ;");
CreateSwapIndex_PastFixings_builder.Append("#31/May/2005#	 | 0.0548 ;");
CreateSwapIndex_PastFixings_builder.Append("#1/Jun/2005#	 | 0.0551 ;");
CreateSwapIndex_PastFixings_builder.Append("#2/Jun/2005#	 | 0.0548 ;");
CreateSwapIndex_PastFixings_builder.Append("#3/Jun/2005#	 | 0.0549 ;");
CreateSwapIndex_PastFixings_builder.Append("#6/Jun/2005#	 | 0.0548 ;");
CreateSwapIndex_PastFixings_builder.Append("#7/Jun/2005#	 | 0.0548 ;");
CreateSwapIndex_PastFixings_builder.Append("#8/Jun/2005#	 | 0.0549 ;");
CreateSwapIndex_PastFixings_builder.Append("#9/Jun/2005#	 | 0.0551 ;");
CreateSwapIndex_PastFixings_builder.Append("#10/Jun/2005#	 | 0.055 ;");
CreateSwapIndex_PastFixings_builder.Append("#13/Jun/2005#	 | 0.0551 ;");
CreateSwapIndex_PastFixings_builder.Append("#14/Jun/2005#	 | 0.055 ;");
CreateSwapIndex_PastFixings_builder.Append("#15/Jun/2005#	 | 0.055 ;");
CreateSwapIndex_PastFixings_builder.Append("#16/Jun/2005#	 | 0.0549 ;");
CreateSwapIndex_PastFixings_builder.Append("#17/Jun/2005#	 | 0.0552 ;");
CreateSwapIndex_PastFixings_builder.Append("#20/Jun/2005#	 | 0.0548 ;");
CreateSwapIndex_PastFixings_builder.Append("#21/Jun/2005#	 | 0.0551 ;");
CreateSwapIndex_PastFixings_builder.Append("#22/Jun/2005#	 | 0.0551 ;");
CreateSwapIndex_PastFixings_builder.Append("#23/Jun/2005#	 | 0.0549 ;");
CreateSwapIndex_PastFixings_builder.Append("#24/Jun/2005#	 | 0.0549 ;");
CreateSwapIndex_PastFixings_builder.Append("#27/Jun/2005#	 | 0.0551 ;");
CreateSwapIndex_PastFixings_builder.Append("#28/Jun/2005#	 | 0.055 ;");
CreateSwapIndex_PastFixings_builder.Append("#29/Jun/2005#	 | 0.0549 ;");
CreateSwapIndex_PastFixings_builder.Append("#30/Jun/2005#	 | 0.0551 ;");
CreateSwapIndex_PastFixings_builder.Append("#1/Jul/2005#	 | 0.0551 ;");
CreateSwapIndex_PastFixings_builder.Append("#4/Jul/2005#	 | 0.0549 ;");
CreateSwapIndex_PastFixings_builder.Append("#5/Jul/2005#	 | 0.0549 ;");
CreateSwapIndex_PastFixings_builder.Append("#6/Jul/2005#	 | 0.0549 ;");
CreateSwapIndex_PastFixings_builder.Append("#7/Jul/2005#	 | 0.0552 ;");
CreateSwapIndex_PastFixings_builder.Append("#8/Jul/2005#	 | 0.0552 ;");
CreateSwapIndex_PastFixings_builder.Append("#11/Jul/2005#	 | 0.0551 ;");
CreateSwapIndex_PastFixings_builder.Append("#12/Jul/2005#	 | 0.0549 ;");
CreateSwapIndex_PastFixings_builder.Append("#13/Jul/2005#	 | 0.055 ;");
CreateSwapIndex_PastFixings_builder.Append("#14/Jul/2005#	 | 0.0549 ;");
CreateSwapIndex_PastFixings_builder.Append("#15/Jul/2005#	 | 0.0549");
CreateSwapIndex_PastFixings_builder.Append("}");

// Parse the string into the Range object.
CreateSwapIndex_PastFixings.RangeFromStr( CreateSwapIndex_PastFixings_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 CreateSwapIndex() 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 CreateSwapIndex() function call


MySwapIndex_25.SWIDX.0

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