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
Use cfyield to compute yield to maturity for a cash flow when given a price.
Define data for the yield curve and price.
Settle = datetime(2003,7,1); Price = 98; CFlowAmounts = [30 40 30]; CFlowDates = [datetime(2004,7,15) ; datetime(2005,7,15) ; datetime(2006,7,15)]';
Compute the Yield.
Yield = cfyield(CFlowAmounts, CFlowDates, Price, Settle)
Yield = 0.0099
Input Arguments
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 NaNs.
Data Types: double
Cash flow dates, specified as an
NINST-by-MOSTCFS matrix using a
datetime array, string array, or date character vectors. Each entry contains
the date of the corresponding cash flow in
CFlowAmounts.
To support existing code, cfyield also
accepts serial date numbers as inputs, but they are not recommended.
Data Types: char | string | datetime
Prices specified as an NINST-by-1
vector.
Data Types: double
Settlement date, specified as an
NINST-by-1 vector using a datetime
array, string array, or date character vectors. The
Settle date is the date on which the cash flows are
priced.
To support existing code, cfyield also
accepts serial date numbers as inputs, but they are not recommended.
Data Types: char | string | datetime
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.
Day-count basis, specified as the comma-separated pair consisting of
'Basis' and a positive integer using a
NINST-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
Compounding frequency for yield calculation, specified as the
comma-separated pair consisting of
'CompundingFrequency' and a scalar or a
NINST-by-1 or
1-by-NINST 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 for cash flows, returned as an
NINST-by-1 vector.
Version History
Introduced in R2012aAlthough cfyield supports serial date numbers,
datetime values are recommended instead. The
datetime data type provides flexible date and time
formats, storage out to nanosecond precision, and properties to account for time
zones and daylight saving time.
To convert serial date numbers or text to datetime values, use the datetime function. For example:
t = datetime(738427.656845093,"ConvertFrom","datenum"); y = year(t)
y =
2021
There are no plans to remove support for serial date number inputs.
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.
Web サイトの選択
Web サイトを選択すると、翻訳されたコンテンツにアクセスし、地域のイベントやサービスを確認できます。現在の位置情報に基づき、次のサイトの選択を推奨します:
また、以下のリストから Web サイトを選択することもできます。
最適なサイトパフォーマンスの取得方法
中国のサイト (中国語または英語) を選択することで、最適なサイトパフォーマンスが得られます。その他の国の MathWorks のサイトは、お客様の地域からのアクセスが最適化されていません。
南北アメリカ
- América Latina (Español)
- Canada (English)
- United States (English)
ヨーロッパ
- 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)