CDSSwapPortfolio





http://www.QuantTools.com
CapeTools CDS Swap Portfolio function list

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

Key TAGs | Excel Index | API Index



Creates a credit default swap portfolio object.

A 'SwapKey' string value will be returned on a successful creation of the credit default swap portfolio object.

This string 'Key' value can then be passed to further swap functions for pricing or querying.



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



Note: Within Excel, the function is named - CT.BOOK.CDSSwapPortfolio




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



Parameter Description


  1. Key parameter

    Key Handle to be used for the new Portfolio 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. ValueDate parameter

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

    Calendar Key required for holiday adjustments.
  5. GroupedCDS parameter

    Key to an already constructed Grouped CDS Curve object. This object is needed in order to extract the necessary probability curve objects needed for pricing.
  6. SwapRange parameter

    A 14 column Swap range : 'SwapName', 'Type', 'PayRec', 'StartDate', 'EndDate', 'Notional', 'Premium', 'PremiumFreq', 'payAccrued', 'DayCount', 'BDC', 'ProbCurveName', 'RecoveryRate', 'DefaultFreq'. The range must contain the titles (detailed within the previous paragraph) for each column.


Extended information

Function Syntax

VB Syntax


String CTCDSPortfolio.CDSSwapPortfolio( _
String Key, _
Long Reload, _
String ValueDate, _
String Cal, _
String GroupedCDS, _
Variant SwapRange)


Excel Spreadsheet Syntax


=CT.BOOK.CDSSwapPortfolio(
Excel String Cell Key,
Excel Numeric Cell Reload,
Excel String Cell ValueDate,
Excel String Cell Cal,
Excel String Cell GroupedCDS,
XLRange SwapRange)


C++ Syntax


static std::string CDSSwapPortfolio(
std::string Key,
long Reload,
std::string ValueDate,
std::string Cal,
std::string GroupedCDS,
CTRangeDataCPP SwapRange);


DotNET Syntax


System.String CTCDSPortfolioSA.CDSSwapPortfolio(
System.String Key,
System.Int32 Reload,
System.String ValueDate,
System.String Cal,
System.String GroupedCDS,
CTRangeData SwapRange);

Parameter data types

ArgNameArgTypeIsKey
KeyStringFALSE
ReloadLongFALSE
ValueDateStringTRUE
CalStringTRUE
GroupedCDSStringTRUE
SwapRangeRangeFALSE


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
KeyFALSEMyCDSSwapPortfolio
ReloadFALSE1
ValueDateFALSEValueDateNAME.EXTTAG.TICKER (from a function call)
CalFALSECalNAME.EXTTAG.TICKER (from a function call)
GroupedCDSFALSEGroupedCDSNAME.EXTTAG.TICKER (from a function call)
SwapRangeFALSECDSSwapPortfolio_SwapRange_Range (creates a range object)


Example range for parameter : SwapRange

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

SwapNameTypePayRecStartDateEndDateNotionalPremiumPremiumFreqpayAccruedDayCountBDCProbCurveNameRecoveryRateDefaultFreq
CDS-123456CDSpayer21/Jul/201121/Jul/2016500000000.02QFalseACT365FModifiedfollowingDEFCURVE_10.4M
CDS : 21-Jul-2012 / 0.02%CDSpayer21/Jul/201221/Jul/2017500000000.02QFalseACT365FModifiedfollowingDEFCURVE_20.4M
CDS : 21-Jul-2013 / 0.02%CDSpayer21/Jul/201321/Jul/2018500000000.02QFalseACT365FModifiedfollowingDEFCURVE_20.4M
CDS : 21-Jul-2014 / 0.03%CDSpayer21/Jul/201421/Jul/2019500000000.03QFalseACT365FModifiedfollowingDEFCURVE_30.4M
CDS : 21-Jul-2015 / 0.03%CDSpayer21/Jul/201521/Jul/2020500000000.03QFalseACT365FModifiedfollowingDEFCURVE_30.4M
CDS : 21-Jul-2016 / 0.03%BINARYCDSreciever21/Jul/201621/Jul/2021100000000.03SFalseACT365FModifiedfollowingDEFCURVE_40.4M
CDS : 21-Jul-2017 / 0.03%BINARYCDSreciever21/Jul/201721/Jul/2022100000000.03SFalseACT365FModifiedfollowingDEFCURVE_40.4M
CDS : 21-Jul-2018 / 0.03%BINARYCDSreciever21/Jul/201821/Jul/2023100000000.03SFalseACT365FModifiedfollowingDEFCURVE_50.4M
CDS : 21-Jul-2019 / 0.03%BINARYCDSreciever21/Jul/201921/Jul/2024100000000.03SFalseACT365FModifiedfollowingDEFCURVE_50.4M
CDS : 21-Jul-2020 / 0.04%BINARYCDSreciever21/Jul/202021/Jul/2025100000000.04SFalseACT365FModifiedfollowingCOUNTERPARTY0.4M
CDS : 21-Jul-2021 / 0.04%BINARYCDSreciever21/Jul/202121/Jul/2026100000000.04SFalseACT365FModifiedfollowingCOUNTERPARTY0.4M
CDS : 21-Jul-2022 / 0.04%BINARYCDSreciever21/Jul/202221/Jul/2027100000000.04SFalseACT365FModifiedfollowingCOUNTERPARTY0.4M
CDS : 21-Jul-2023 / 0.04%BINARYCDSreciever21/Jul/202321/Jul/2028100000000.04SFalseACT365FModifiedfollowingCOUNTERPARTY0.4M
CDS : 21-Jul-2024 / 0.04%BINARYCDSreciever21/Jul/202421/Jul/2029100000000.04SFalseACT365FModifiedfollowingCOUNTERPARTY0.4M
CDS : 21-Jul-2025 / 0.04%BINARYCDSreciever21/Jul/202521/Jul/2030100000000.04SFalseACT365FModifiedfollowingCOUNTERPARTY0.4M

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



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

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

CDSSwapPortfolio_SwapRange_builder.Append("{");
CDSSwapPortfolio_SwapRange_builder.Append("SwapName	 | Type	 | PayRec	 | StartDate	 | EndDate	 | Notional	 | Premium	 | PremiumFreq	 | payAccrued	 | DayCount	 | BDC	 | ProbCurveName	 | RecoveryRate	 | DefaultFreq ;");
CDSSwapPortfolio_SwapRange_builder.Append("CDS-123456	 | CDS	 | payer	 | #21/Jul/2011#	 | #21/Jul/2016#	 | 50000000	 | 0.02	 | Q	 | False	 | ACT365F	 | Modifiedfollowing	 | DEFCURVE_1	 | 0.4	 | M ;");
CDSSwapPortfolio_SwapRange_builder.Append("CDS : 21-Jul-2012 / 0.02%	 | CDS	 | payer	 | #21/Jul/2012#	 | #21/Jul/2017#	 | 50000000	 | 0.02	 | Q	 | False	 | ACT365F	 | Modifiedfollowing	 | DEFCURVE_2	 | 0.4	 | M ;");
CDSSwapPortfolio_SwapRange_builder.Append("CDS : 21-Jul-2013 / 0.02%	 | CDS	 | payer	 | #21/Jul/2013#	 | #21/Jul/2018#	 | 50000000	 | 0.02	 | Q	 | False	 | ACT365F	 | Modifiedfollowing	 | DEFCURVE_2	 | 0.4	 | M ;");
CDSSwapPortfolio_SwapRange_builder.Append("CDS : 21-Jul-2014 / 0.03%	 | CDS	 | payer	 | #21/Jul/2014#	 | #21/Jul/2019#	 | 50000000	 | 0.03	 | Q	 | False	 | ACT365F	 | Modifiedfollowing	 | DEFCURVE_3	 | 0.4	 | M ;");
CDSSwapPortfolio_SwapRange_builder.Append("CDS : 21-Jul-2015 / 0.03%	 | CDS	 | payer	 | #21/Jul/2015#	 | #21/Jul/2020#	 | 50000000	 | 0.03	 | Q	 | False	 | ACT365F	 | Modifiedfollowing	 | DEFCURVE_3	 | 0.4	 | M ;");
CDSSwapPortfolio_SwapRange_builder.Append("CDS : 21-Jul-2016 / 0.03%	 | BINARYCDS	 | reciever	 | #21/Jul/2016#	 | #21/Jul/2021#	 | 10000000	 | 0.03	 | S	 | False	 | ACT365F	 | Modifiedfollowing	 | DEFCURVE_4	 | 0.4	 | M ;");
CDSSwapPortfolio_SwapRange_builder.Append("CDS : 21-Jul-2017 / 0.03%	 | BINARYCDS	 | reciever	 | #21/Jul/2017#	 | #21/Jul/2022#	 | 10000000	 | 0.03	 | S	 | False	 | ACT365F	 | Modifiedfollowing	 | DEFCURVE_4	 | 0.4	 | M ;");
CDSSwapPortfolio_SwapRange_builder.Append("CDS : 21-Jul-2018 / 0.03%	 | BINARYCDS	 | reciever	 | #21/Jul/2018#	 | #21/Jul/2023#	 | 10000000	 | 0.03	 | S	 | False	 | ACT365F	 | Modifiedfollowing	 | DEFCURVE_5	 | 0.4	 | M ;");
CDSSwapPortfolio_SwapRange_builder.Append("CDS : 21-Jul-2019 / 0.03%	 | BINARYCDS	 | reciever	 | #21/Jul/2019#	 | #21/Jul/2024#	 | 10000000	 | 0.03	 | S	 | False	 | ACT365F	 | Modifiedfollowing	 | DEFCURVE_5	 | 0.4	 | M ;");
CDSSwapPortfolio_SwapRange_builder.Append("CDS : 21-Jul-2020 / 0.04%	 | BINARYCDS	 | reciever	 | #21/Jul/2020#	 | #21/Jul/2025#	 | 10000000	 | 0.04	 | S	 | False	 | ACT365F	 | Modifiedfollowing	 | COUNTERPARTY	 | 0.4	 | M ;");
CDSSwapPortfolio_SwapRange_builder.Append("CDS : 21-Jul-2021 / 0.04%	 | BINARYCDS	 | reciever	 | #21/Jul/2021#	 | #21/Jul/2026#	 | 10000000	 | 0.04	 | S	 | False	 | ACT365F	 | Modifiedfollowing	 | COUNTERPARTY	 | 0.4	 | M ;");
CDSSwapPortfolio_SwapRange_builder.Append("CDS : 21-Jul-2022 / 0.04%	 | BINARYCDS	 | reciever	 | #21/Jul/2022#	 | #21/Jul/2027#	 | 10000000	 | 0.04	 | S	 | False	 | ACT365F	 | Modifiedfollowing	 | COUNTERPARTY	 | 0.4	 | M ;");
CDSSwapPortfolio_SwapRange_builder.Append("CDS : 21-Jul-2023 / 0.04%	 | BINARYCDS	 | reciever	 | #21/Jul/2023#	 | #21/Jul/2028#	 | 10000000	 | 0.04	 | S	 | False	 | ACT365F	 | Modifiedfollowing	 | COUNTERPARTY	 | 0.4	 | M ;");
CDSSwapPortfolio_SwapRange_builder.Append("CDS : 21-Jul-2024 / 0.04%	 | BINARYCDS	 | reciever	 | #21/Jul/2024#	 | #21/Jul/2029#	 | 10000000	 | 0.04	 | S	 | False	 | ACT365F	 | Modifiedfollowing	 | COUNTERPARTY	 | 0.4	 | M ;");
CDSSwapPortfolio_SwapRange_builder.Append("CDS : 21-Jul-2025 / 0.04%	 | BINARYCDS	 | reciever	 | #21/Jul/2025#	 | #21/Jul/2030#	 | 10000000	 | 0.04	 | S	 | False	 | ACT365F	 | Modifiedfollowing	 | COUNTERPARTY	 | 0.4	 | M");
CDSSwapPortfolio_SwapRange_builder.Append("}");

// Parse the string into the Range object.
CDSSwapPortfolio_SwapRange.RangeFromStr( CDSSwapPortfolio_SwapRange_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.IRPortfolio20 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 CDSSwapPortfolio() 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 CDSSwapPortfolio() function call


MyCDSSwapPortfolio_1.BOOKCDSWP.0

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