CreateCashFlowLeg





http://www.QuantTools.com
CapeTools FIXED Legs function list

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

Key TAGs | Excel Index | API Index



Creates a CashFlow leg which pays a predetermined amount at each date.

This leg object can either be priced directly via the PrcLegObject() function or you can use this leg within the SwapFIXFIX3() and Swap2() function in order to construct the details of one side of a swap structure.

Finally there are numerous querying functions that can be applied to this leg (within the CapeTools Query Legs category of functions).

This function requires the input of a Schedule object key, which must have been produced via a call to one of the following functions : MakeSchedule() or MakeSchedule2(). These functions would have returned a string 'KEY' which is to be passed to the 'ScheduleKey' parameter of this function.

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



Note: Within Excel, the function is named - CT.LEG.CreateCashFlowLeg




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

    Whether you would like to PAY or REC this leg.
  4. Gearing parameter

    A positive factor value you wish to multiply the Floating-Reset Rate/Fixed-Coupon Rate by (Usually 1). If you want to simply double the value of the leg, modify the Notional value. For floating legs, if we denote 'M' as a margin/spread, 'G' as the gearing and 'L' as the fixing rate, the gearing will be applied as following : 'G*L+M'. For fixed rate legs, if we denote 'C' as the coupon rate and 'G' as the gearing, then the gearing value will be applied as 'G*C' which is, in effect, the same as doubling the value of the leg.
  5. Notional parameter

    A positive valued Notional amount of the deal. Can pass an array of notional amounts for each period
  6. Ccy parameter

    Currency of the Notional amount.
  7. ScheduleKey parameter

    Schedule Key to an already generated schedule object.
  8. BusDayConv parameter

    Payment Business Day Convention. Treatment of date calculations for (discounting).
  9. ExchangePrincipal parameter

    Whether you wish to exchange the principal amount(s) at the start and termination of the leg contract.
  10. MKTKey parameter

    Key to an already constructed MKT object that contains at least a discounting curve. The VolCurve should be present if pricing CMS or In-Arrear legs, deals. The curves contained within this object should all be of the same Currency of which must equal the value of the 'Ccy' parameter of this function.


Extended information

Function Syntax

VB Syntax


String CTFIXLegs.CreateCashFlowLeg( _
String Key, _
Long Reload, _
PAYRECEnum PayRec, _
Long Gearing, _
Variant Notional, _
CCYEnum Ccy, _
String ScheduleKey, _
BDCEnum BusDayConv, _
Boolean ExchangePrincipal, _
String MKTKey)


Excel Spreadsheet Syntax


=CT.LEG.CreateCashFlowLeg(
Excel String Cell Key,
Excel Numeric Cell Reload,
Excel String Cell PayRec,
Excel Numeric Cell Gearing,
XLRange Notional,
Excel String Cell Ccy,
Excel String Cell ScheduleKey,
Excel String Cell BusDayConv,
Excel Boolean Value Cell ExchangePrincipal,
Excel String Cell MKTKey)


C++ Syntax


static std::string CreateCashFlowLeg(
std::string Key,
long Reload,
PAYRECEnum PayRec,
long Gearing,
CTRangeDataCPP Notional,
CCYEnum Ccy,
std::string ScheduleKey,
BDCEnum BusDayConv,
bool ExchangePrincipal,
std::string MKTKey);


DotNET Syntax


System.String CTFIXLegsSA.CreateCashFlowLeg(
System.String Key,
System.Int32 Reload,
CTIEnums.PAYRECEnum PayRec,
System.Int32 Gearing,
CTRangeData Notional,
CTIEnums.CCYEnum Ccy,
System.String ScheduleKey,
CTIEnums.BDCEnum BusDayConv,
System.Boolean ExchangePrincipal,
System.String MKTKey);

Parameter data types

ArgNameArgTypeIsKey
KeyStringFALSE
ReloadLongFALSE
PayRecPAYRECEnumFALSE
GearingLongFALSE
NotionalRangeFALSE
CcyCCYEnumFALSE
ScheduleKeyStringTRUE
BusDayConvBDCEnumFALSE
ExchangePrincipalBooleanFALSE
MKTKeyStringTRUE


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
KeyFALSEMyCreateCashFlowLeg
ReloadFALSE1
PayRecFALSEPAY
GearingFALSE1
NotionalFALSECreateCashFlowLeg_Notional_Range (creates a range object)
CcyFALSEEUR
ScheduleKeyFALSEScheduleKeyNAME.EXTTAG.TICKER (from a function call)
BusDayConvFALSEModifiedFollowing
ExchangePrincipalFALSEfalse
MKTKeyFALSEMKTKeyNAME.EXTTAG.TICKER (from a function call)


Example range for parameter : Notional

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


Data is stored within the second column (Vector of data)..

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



CTQL.CTRangeData CreateCashFlowLeg_Notional;


int[] arrBCreateCashFlowLeg_Notional = {
125000,
125000,
125000,
125000,
125000,
125000,
125000,
125000,
125000,
125000,
125000,
125000,
125000,
125000,
125000,
125000,
125000,
125000,
125000,
125000  //  Array Data

};

CTQL.IntVector arrCreateCashFlowLeg_Notional =
new  CTQL.IntVector(arrBCreateCashFlowLeg_Notional);

// Second parameter determines whether the array is a column array (false) or a row array (true)
CreateCashFlowLeg_Notional = new  CTQL.CTRangeData(arrCreateCashFlowLeg_Notional, false);



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.IRLegs20 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 CreateCashFlowLeg() 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 CreateCashFlowLeg() function call


MyCreateCashFlowLeg_5.CSHLEG.0

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