Detailed instructions for use are in the User's Guide.
[. . . ] Financial Derivatives Toolbox
For Use with MATLAB
®
Computation Visualization Programming
User's Guide
Version 2
How to Contact The MathWorks:
www. mathworks. com comp. soft-sys. matlab support@mathworks. com suggest@mathworks. com bugs@mathworks. com doc@mathworks. com service@mathworks. com info@mathworks. com
Web Newsgroup Technical support Product enhancement suggestions Bug reports Documentation error reports Order status, license renewals, passcodes Sales, pricing, and general information Phone Fax Mail
508-647-7000 508-647-7001 The MathWorks, Inc. 3 Apple Hill Drive Natick, MA 01760-2098
For contact information about worldwide offices, see the MathWorks Web site. Financial Derivatives Toolbox User's Guide COPYRIGHT 2000 - 2001 by The MathWorks, Inc.
The software described in this document is furnished under a license agreement. The software may be used or copied only under the terms of the license agreement. [. . . ] PriceTree is a tree structure with a vector of instrument prices at each node.
Examples
Price a portfolio containing two cash flow instruments paying interest annually over the four year period from January 1, 2000 to January 1, 2004. HJMTree contains the time and forward rate information needed to price the instruments.
4-41
cfbyhjm
load deriv CFlowAmounts =[5 NaN 5. 5 105;5 0 6 105]; CFlowDates = [730852, NaN, 731582, 731947; 730852, 731217, 731582, 731947]; [Price, PriceTree] = cfbyhjm(HJMTree, CFlowAmounts, . . . CFlowDates, HJMTree. RateSpec. ValuationDate) Price = 96. 7805 97. 2188 PriceTree = FinObj: 'HJMPriceTree' tObs: [0 1. 00 2. 00 3. 00 4. 00] PBush: {1x5 cell}
You can visualize the prices of the two cash flow instruments with the treeviewer function.
treeviewer(PriceTree)
See Also
cfamounts, hjmprice, hjmtree, instcf
4-42
cfbyzero
Purpose Syntax Arguments
4cfbyzero
Price cash flows by a set of zero curves
Price = cfbyzero(RateSpec, CFlowAmounts, CFlowDates, Settle, Basis) RateSpec
A structure encapsulating the properties of an interest rate structure. Number of instruments (NINST) by maximum number of cash flows (MOSTCFS) matrix with entries listing cash flow amounts corresponding to each date in CFlowDates. If an instrument has fewer than MOSTCFS cash flows, the end of the row is padded with NaNs.
NINST-by-MOSTCFS matrix of cash flow dates. Each entry
CFlowAmounts
CFlowDates
contains the serial date of the corresponding cash flow in CFlowAmounts.
Settle Basis
Settlement date on which the cash flows are priced. 0 = actual/actual (default), 1 = 30/360, 2 = actual/360, 3 = actual/365.
Description
Price = cfbyzero(RateSpec, CFlowAmounts, CFlowDates, Settle, Basis) computes Price, an NINST-by-NUMCURVES matrix of cash flows prices. Each
column arises from one of the zero curves.
Examples
Price a portfolio containing two cash flow instruments paying interest annually over the four year period from January 1, 2000 to January 1, 2004. ZeroRateSpec contains the interest rate information needed to price the instruments.
load deriv CFlowAmounts =[5 NaN 5. 5 105;5 0 6 105]; CFlowDates = [730852, NaN, 731582, 731947; 730852, 731217, 731582, 731947]; Settle = 730486;
4-43
cfbyzero
Price = cfbyzero(ZeroRateSpec, CFlowAmounts, CFlowDates, Settle) Price = 96. 7804 97. 2187
See Also
bondbyzero, fixedbyzero, floatbyzero, swapbyzero
4-44
classfin
Purpose Syntax
4classfin
Create financial structure or return financial structure class name
Obj = classfin(ClassName) Obj = classfin(Struct, ClassName) ClassName = classfin(Obj) ClassName Struct Obj
Arguments
String containing name of financial structure class. Name of a financial structure.
Description
Obj = classfin(ClassName) and Obj = classfin(Struct, ClassName) create a financial structure of class ClassName. ClassName = classfin(Obj) returns a string containing a financial
structure's class name.
Examples
Example 1. (Typically, the function hjmtimespec is used to create HJMTimeSpec structures).
TimeSpec = classfin('HJMTimeSpec'); TimeSpec. ValuationDate = datenum('Dec-10-1999'); TimeSpec. Maturity = datenum('Dec-10-2002'); TimeSpec. Compounding = 2; TimeSpec. Basis = 0; TimeSpec. EndMonthRule = 1; TimeSpec = FinObj: ValuationDate: Maturity: Compounding: Basis: EndMonthRule: 'HJMTimeSpec' 730464 731560 2 0 1
4-45
classfin
Example 2. Convert an existing MATLAB structure into a financial structure.
TSpec. ValuationDate = datenum('Dec-10-1999'); TSpec. Maturity = datenum('Dec-10-2002'); TSpec. Compounding = 2; TSpec. Basis = 0; TSpec. EndMonthRule = 0; TimeSpec = classfin(TSpec, 'HJMTimeSpec') TimeSpec = ValuationDate: Maturity: Compounding: Basis: EndMonthRule: FinObj: 730464 731560 2 0 0 'HJMTimeSpec'
Example 3. Obtain a financial structure's class name.
load deriv. mat ClassName = classfin(HJMTree) ClassName = HJMFwdTree
See Also
isafin
4-46
date2time
Purpose Syntax Arguments
4date2time
Fixed income time and frequency from dates
[Times, F] = date2time(Settle, Maturity, Compounding, Basis, EndMonthRule) Settle
Settlement date. Settle must be earlier than or equal to
Maturity.
Maturity Compounding
Maturity date. Scalar value representing the rate at which the input zero rates were compounded when annualized. This argument determines the formula for the discount factors: Compounding = 1, 2, 3, 4, 6, 12 Disc = (1 + Z/F)^(-T), where F is the compounding frequency, Z is the zero rate, and T is the time in periodic units, e. g. Compounding = 365 Disc = (1 + Z/F)^(-T), where F is the number of days in the basis year and T is a number of days elapsed computed by basis. 0 = actual/actual (default), 1 = 30/360, 2 = actual/360, 3 = actual/365. This rule applies only when Maturity is an end-of-month date for a month having 30 or fewer days. 0 = ignore rule, meaning that a bond's coupon payment date is always the same numerical day of the month. 1 = set rule on (default), meaning that a bond's coupon payment date is always the last actual day of the month.
Basis
EndMonthRule
4-47
date2time
Description
[Times, F] = date2time(Settle, Dates, Compounding, Basis, EndMonthRule) computes time factors appropriate to compounded rate quotes between Settle and Maturity dates. [. . . ] A portfolio.
A-3
A
Glossary
inverse discount - A factor by which the present value of an asset is multiplied
to find its future value. The reciprocal of the discount factor.
least squares method - A mathematical method of determining the best fit of a curve to a series of observations by choosing the curve that minimizes the sum of the squares of all deviations from the curve. option - A right to buy or sell specific securities or commodities at a stated price (exercise or strike price) within a specified time. per-dollar sensitivity - The dollar sensitivity divided by the corresponding instrument price. [. . . ]