cfyield
Compute yield to maturity for cash flow given price
Description
computes yield to maturity for a cash flow given price.Yield
= cfyield(CFlowAmounts
,CFlowDates
,Price
,Settle
)
specifies options using one or more name-value pair arguments in addition to the
input arguments in the previous syntax. Yield
= cfyield(___,Name,Value
)
Examples
Compute the Yield to Maturity for a Cash Flow When Given a Price
Use cfyield
to compute yield to maturity for a cash flow when given a price.
Define data for the yield curve and price.
Settle = datenum('01-Jul-2003'); Price = 98; CFlowAmounts = [30 40 30]; CFlowDates = datenum({'15-Jul-2004', '15-Jul-2005', '15-Jul-2006'})';
Compute the Yield
.
Yield = cfyield(CFlowAmounts, CFlowDates, Price, Settle)
Yield = 0.0099
Compute the Yield to Maturity for a Cash Flow When Given a Price Using datetime Inputs
Use cfyield
to compute yield to maturity for a cash flow, when given a price using datetime
inputs.
Settle = datenum('01-Jul-2003'); Price = 98; CFlowAmounts = [30 40 30]; CFlowDates = datenum({'15-Jul-2004', '15-Jul-2005', '15-Jul-2006'})'; CFlowDates = datetime(CFlowDates,'ConvertFrom','datenum','Locale','en_US'); Settle = datetime(Settle,'ConvertFrom','datenum','Locale','en_US'); Yield = cfyield(CFlowAmounts, CFlowDates, Price, Settle)
Yield = 0.0099
Input Arguments
CFlowAmounts
— Cash flow amounts
vector
Cash flow amounts, specified as an
NINST
-by-MOSTCFS
matrix. Each row
is a list of cash flow values for one instrument. If an instrument has fewer
than MOSTCFS
cash flows, the end of the row is padded
with NaN
s.
Data Types: double
CFlowDates
— Cash flow dates
serial date number | date character vector | datetime array
Cash flow dates, specified as an
NINST
-by-MOSTCFS
matrix. Each
entry contains the date of the corresponding cash flow in
CFlowAmounts
.
Data Types: double
| char
| datetime
Price
— Prices
vector
Prices specified as an NINST
-by-1
vector.
Data Types: double
Settle
— Settlement date
cell array of date character vectors | vector of serial date numbers
Settlement date, specified as an
NMBS
-by-1
vector using serial date
numbers or a cell array of date character vectors. The
Settle
date is the date on which the cash flows are
priced.
Data Types: double
| char
| cell
Name-Value Arguments
Specify optional pairs of arguments as
Name1=Value1,...,NameN=ValueN
, where Name
is
the argument name and Value
is the corresponding value.
Name-value arguments must appear after other arguments, but the order of the
pairs does not matter.
Before R2021a, use commas to separate each name and value, and enclose
Name
in quotes.
Example: Yield =
cfyield(CFAmounts,CFDates,Yield,Settle,'Basis',4,'CompoundingFrequency',4)
Note
An optional input of size NINST
-by-1
is
also acceptable as a single value applicable to all contracts. Single values are
internally expanded to an array of size
NINST
-by-1
.
Basis
— Day-count basis
0
(actual/actual) (default) | positive integers of the set [1...13]
| vector of positive integers of the set
[1...13]
Day-count basis, specified as the comma-separated pair consisting of
'Basis'
and a positive integer using a
N
-by-1
vector.
0 = actual/actual
1 = 30/360 (SIA)
2 = actual/360
3 = actual/365
4 = 30/360 (PSA)
5 = 30/360 (ISDA)
6 = 30/360 (European)
7 = actual/365 (Japanese)
8 = actual/actual (ICMA)
9 = actual/360 (ICMA)
10 = actual/365 (ICMA)
11 = 30/360E (ICMA)
12 = actual/365 (ISDA)
13 = BUS/252
For more information, see Basis.
Data Types: double
CompoundingFrequency
— Compounding frequency
2
(actual/actual) (default) | positive integers of the set [1...13]
| vector of positive integers of the set
[1...13]
Compounding frequency, specified as the comma-separated pair
consisting of 'CompoundingFrequency'
and a positive
integer using a N
-by-1
vector.
0 = actual/actual
1 = 30/360 (SIA)
2 = actual/360
3 = actual/365
4 = 30/360 (PSA)
5 = 30/360 (ISDA)
6 = 30/360 (European)
7 = actual/365 (Japanese)
8 = actual/actual (ICMA)
9 = actual/360 (ICMA)
10 = actual/365 (ICMA)
11 = 30/360E (ICMA)
12 = actual/365 (ISDA)
13 = BUS/252
For more information, see Basis.
Data Types: double
CompoundingFrequency
— Compounding frequency
SIA bases uses2
, ICMA bases uses
1
(default) | integer with value of 1
, 2
,
3
, 4
, 6
, or
12
Compounding frequency for yield calculation, specified as the
comma-separated pair consisting of
'CompundingFrequency'
and a scalar or a
NUMBONDS
-by-1
or
1
-by-NUMBONDS
vector.
1
— Annual compounding2
— Semiannual compounding3
— Compounding three times per year4
— Quarterly compounding6
— Bimonthly compounding12
— Monthly compounding
Note
By default, SIA bases
(0
-7
) and
BUS/252
use a semiannual compounding
convention and ICMA bases
(8
-12
) use an annual
compounding convention.
Data Types: double
Output Arguments
Yield
— Yield for cash flows
vector
Yield for cash flows, returned as an
NINST
-by-1
vector.
Version History
Open Example
You have a modified version of this example. Do you want to open this example with your edits?
MATLAB Command
You clicked a link that corresponds to this MATLAB command:
Run the command by entering it in the MATLAB Command Window. Web browsers do not support MATLAB commands.
Select a Web Site
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .
You can also select a web site from the following list:
How to Get Best Site Performance
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
Americas
- América Latina (Español)
- Canada (English)
- United States (English)
Europe
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)