BondPortfolio_p





http://www.QuantTools.com
CapeTools Bond Portfolio function list

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

Key TAGs | Excel Index | API Index



Creates a fixed portfolio bond object.

A portfolio bond object is made up of many serial bonds with different maturity dates.

The bond takes as input the Bond's clean price.

From this price, the Bond Yield will be computed and it is this yield that will be used to discount the Bond flows.

A 'BondKey' string value will be returned on a successful creation of the bond object.

This string 'Key' value can then be passed to further bond 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 : "FBOOKBND_P"



Note: Within Excel, the function is named - CT.BONDBOOK.Portfolio_p




High level graphic of BondPortfolio_p() 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 Bond 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. Ccy parameter

    The currency code that you want to associate with the Bond.
  4. SettleDate parameter

    Settlement date of the Bonds.
  5. calKey parameter

    Key to an already constructed Calendar object. Used to adjust dates for holidays.
  6. BondRange parameter

    A 18 column Bond range : 'BondName', 'Position', 'DatedDate', 'FirstCouponDate', 'PenultCouponDate', 'MatDate', 'exDivTenor', 'Coupon', 'Notional', 'Redemption', 'Freq', 'exactCoupon', 'BDC', 'cpnDayCount', 'accDayCount', 'CleanPrice', 'YieldMethod' and 'FCYieldMethod'. The columns 'DatedDate', 'FirstCouponDate' and 'PenultCouponDate' are optional (only required to define odd first or last coupon periods) so you can fill these with zeros. The 'cpnDayCount' column corresponds to the accrual method for calculating the coupon amount when the 'exactCoupon' column is set to false. The 'accDayCount' column corresponds to the accrual method in either an odd-first and/or an odd-last coupon period. Setting the 'exactCoupon' column to true imply that the bond generates level coupon payments.


Extended information

Function Syntax

VB Syntax


String CTBondPortfolio.BondPortfolio_p( _
String Key, _
Long Reload, _
CCYEnum Ccy, _
Long SettleDate, _
String calKey, _
Variant BondRange)


Excel Spreadsheet Syntax


=CT.BONDBOOK.Portfolio_p(
Excel String Cell Key,
Excel Numeric Cell Reload,
Excel String Cell Ccy,
Excel Numeric Cell SettleDate,
Excel String Cell calKey,
XLRange BondRange)


C++ Syntax


static std::string BondPortfolio_p(
std::string Key,
long Reload,
CCYEnum Ccy,
long SettleDate,
std::string calKey,
CTRangeDataCPP BondRange);


DotNET Syntax


System.String CTBondPortfolioSA.BondPortfolio_p(
System.String Key,
System.Int32 Reload,
CTIEnums.CCYEnum Ccy,
System.Int32 SettleDate,
System.String calKey,
CTRangeData BondRange);

Parameter data types

ArgNameArgTypeIsKey
KeyStringFALSE
ReloadLongFALSE
CcyCCYEnumFALSE
SettleDateLongFALSE
calKeyStringTRUE
BondRangeRangeFALSE


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
KeyFALSEMyBondPortfolio_p
ReloadFALSE1
CcyFALSEEUR
SettleDateFALSE19/Jul/2005 (serial date type)
calKeyFALSEcalKeyNAME.EXTTAG.TICKER (from a function call)
BondRangeFALSEBondPortfolio_p_BondRange_Range (creates a range object)


Example range for parameter : BondRange

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

MicrosoftSHORT21/Apr/20050021/Oct/20073BD5.14500000120STrueUnAdjusted3036030360100.06ISMA:30360Simple:Actual360
Bond : 21-Oct-2009 / 5.28%SHORT21/Apr/20050021/Oct/20093BD5.28500000120STrueUnAdjusted3036030360101.19ISMA:30360Simple:Actual360
Bond : 21-Oct-2011 / 5.47%SHORT21/Apr/20050021/Oct/20113BD5.47500000120STrueUnAdjusted3036030360102.27ISMA:30360Simple:Actual360
Bond : 21-Oct-2013 / 5.63%SHORT21/Apr/20050021/Oct/20133BD5.63500000120STrueUnAdjusted3036030360100.88ISMA:30360Simple:Actual360
Bond : 21-Oct-2015 / 5.81%SHORT21/Apr/20050021/Oct/20153BD5.81500000120STrueUnAdjusted3036030360102.14ISMA:30360Simple:Actual360
Bond : 21-Oct-2017 / 6%SHORT21/Apr/20050021/Oct/20173BD61000000100ATrueUnAdjustedACTACTACT36597.76ISMA:30360Simple:Actual360
Bond : 21-Oct-2019 / 6.12%LONG21/Apr/20050021/Oct/20193BD6.121000000100ATrueUnAdjustedACTACTACT36599.17ISMA:30360Simple:Actual360
Bond : 21-Oct-2021 / 6.29%LONG21/Apr/20050021/Oct/20213BD6.291000000100ATrueUnAdjustedACTACTACT365102.21ISMA:30360Simple:Actual360
Bond : 21-Oct-2023 / 6.43%LONG21/Apr/20050021/Oct/20233BD6.431000000100ATrueUnAdjustedACTACTACT36597.6ISMA:30360Simple:Actual360
Bond : 21-Oct-2025 / 6.57%LONG21/Apr/20050021/Oct/20253BD6.571000000100ATrueUnAdjustedACTACTACT365101.52ISMA:30360Simple:Actual360

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



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

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

BondPortfolio_p_BondRange_builder.Append("{");
BondPortfolio_p_BondRange_builder.Append("Microsoft	 | SHORT	 | #21/Apr/2005#	 | 0	 | 0	 | #21/Oct/2007#	 | 3BD	 | 5.14	 | 500000	 | 120	 | S	 | True	 | UnAdjusted	 | 30360	 | 30360	 | 100.06	 | ISMA:30360	 | Simple:Actual360 ;");
BondPortfolio_p_BondRange_builder.Append("Bond : 21-Oct-2009 / 5.28%	 | SHORT	 | #21/Apr/2005#	 | 0	 | 0	 | #21/Oct/2009#	 | 3BD	 | 5.28	 | 500000	 | 120	 | S	 | True	 | UnAdjusted	 | 30360	 | 30360	 | 101.19	 | ISMA:30360	 | Simple:Actual360 ;");
BondPortfolio_p_BondRange_builder.Append("Bond : 21-Oct-2011 / 5.47%	 | SHORT	 | #21/Apr/2005#	 | 0	 | 0	 | #21/Oct/2011#	 | 3BD	 | 5.47	 | 500000	 | 120	 | S	 | True	 | UnAdjusted	 | 30360	 | 30360	 | 102.27	 | ISMA:30360	 | Simple:Actual360 ;");
BondPortfolio_p_BondRange_builder.Append("Bond : 21-Oct-2013 / 5.63%	 | SHORT	 | #21/Apr/2005#	 | 0	 | 0	 | #21/Oct/2013#	 | 3BD	 | 5.63	 | 500000	 | 120	 | S	 | True	 | UnAdjusted	 | 30360	 | 30360	 | 100.88	 | ISMA:30360	 | Simple:Actual360 ;");
BondPortfolio_p_BondRange_builder.Append("Bond : 21-Oct-2015 / 5.81%	 | SHORT	 | #21/Apr/2005#	 | 0	 | 0	 | #21/Oct/2015#	 | 3BD	 | 5.81	 | 500000	 | 120	 | S	 | True	 | UnAdjusted	 | 30360	 | 30360	 | 102.14	 | ISMA:30360	 | Simple:Actual360 ;");
BondPortfolio_p_BondRange_builder.Append("Bond : 21-Oct-2017 / 6%	 | SHORT	 | #21/Apr/2005#	 | 0	 | 0	 | #21/Oct/2017#	 | 3BD	 | 6	 | 1000000	 | 100	 | A	 | True	 | UnAdjusted	 | ACTACT	 | ACT365	 | 97.76	 | ISMA:30360	 | Simple:Actual360 ;");
BondPortfolio_p_BondRange_builder.Append("Bond : 21-Oct-2019 / 6.12%	 | LONG	 | #21/Apr/2005#	 | 0	 | 0	 | #21/Oct/2019#	 | 3BD	 | 6.12	 | 1000000	 | 100	 | A	 | True	 | UnAdjusted	 | ACTACT	 | ACT365	 | 99.17	 | ISMA:30360	 | Simple:Actual360 ;");
BondPortfolio_p_BondRange_builder.Append("Bond : 21-Oct-2021 / 6.29%	 | LONG	 | #21/Apr/2005#	 | 0	 | 0	 | #21/Oct/2021#	 | 3BD	 | 6.29	 | 1000000	 | 100	 | A	 | True	 | UnAdjusted	 | ACTACT	 | ACT365	 | 102.21	 | ISMA:30360	 | Simple:Actual360 ;");
BondPortfolio_p_BondRange_builder.Append("Bond : 21-Oct-2023 / 6.43%	 | LONG	 | #21/Apr/2005#	 | 0	 | 0	 | #21/Oct/2023#	 | 3BD	 | 6.43	 | 1000000	 | 100	 | A	 | True	 | UnAdjusted	 | ACTACT	 | ACT365	 | 97.6	 | ISMA:30360	 | Simple:Actual360 ;");
BondPortfolio_p_BondRange_builder.Append("Bond : 21-Oct-2025 / 6.57%	 | LONG	 | #21/Apr/2005#	 | 0	 | 0	 | #21/Oct/2025#	 | 3BD	 | 6.57	 | 1000000	 | 100	 | A	 | True	 | UnAdjusted	 | ACTACT	 | ACT365	 | 101.52	 | ISMA:30360	 | Simple:Actual360");
BondPortfolio_p_BondRange_builder.Append("}");

// Parse the string into the Range object.
BondPortfolio_p_BondRange.RangeFromStr( BondPortfolio_p_BondRange_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.Bonds20 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 BondPortfolio_p() 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 BondPortfolio_p() function call


MyBondPortfolio_p_3.FBOOKBND_P.0

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