cfspread
Compute spread over yield curve for cash flow
Syntax
Description
computes spread over a yield curve for a cash flow.Spread
= cfspread(RateSpec
,Price
,CFlowAmounts
,CFlowDates
,Settle
)
specifies options using one or more name-value pair arguments in addition to the
input arguments in the previous syntax. Spread
= cfspread(___,Name,Value
)
Examples
Use cfspread
to compute the spread over a yield curve for a cash flow.
Define data for the yield curve.
Settle = datetime(2003,7,1) %datenum('01-Jul-2003');
Settle = datetime
01-Jul-2003
CurveDates = daysadd(Settle,360*[.25 .5 1 2 3 5 7 10 20],1); ZeroRates = [.0089 .0096 .0107 .0130 .0166 .0248 .0306 .0356 .0454]';
Compute the RateSpec
.
RateSpec = intenvset('StartDates', Settle, 'EndDates', CurveDates,... 'Rates', ZeroRates)
RateSpec = struct with fields:
FinObj: 'RateSpec'
Compounding: 2
Disc: [9×1 double]
Rates: [9×1 double]
EndTimes: [9×1 double]
StartTimes: [9×1 double]
EndDates: [9×1 double]
StartDates: 731763
ValuationDate: 731763
Basis: 0
EndMonthRule: 1
Compute the spread.
Price = 98; CFAmounts = [30;40;30]; CFDates = [datetime(2004,7,15); datetime(2005,7,15) ; datetime(2006,7,15)]; Spread = cfspread(RateSpec, Price, CFAmounts, CFDates, Settle)
Spread = 3×1
103 ×
-8.7956
-4.0774
-3.7073
Input Arguments
Price of cash flows, specified as an
NINST
-by-1
vector.
Data Types: double
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
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, cfspread
also
accepts serial date numbers as inputs, but they are not recommended.
Data Types: char
| string
| datetime
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, cfspread
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: Spread =
cfspread(RateSpec,Price,CFlowAmounts,CFlowDates,Settle,'Basis',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
Output Arguments
Spread of cash flows over a zero curve, returned as an
NINST
-by-1
vector. The
Spread
is expressed in basis points.
Version History
Introduced in R2012aAlthough cfspread
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.
웹사이트 선택
번역된 콘텐츠를 보고 지역별 이벤트와 혜택을 살펴보려면 웹사이트를 선택하십시오. 현재 계신 지역에 따라 다음 웹사이트를 권장합니다:
또한 다음 목록에서 웹사이트를 선택하실 수도 있습니다.
사이트 성능 최적화 방법
최고의 사이트 성능을 위해 중국 사이트(중국어 또는 영어)를 선택하십시오. 현재 계신 지역에서는 다른 국가의 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)