xirr
Internal rate of return for nonperiodic cash flow
Description
returns the internal rate of return for a schedule of
nonperiodic cash flows.Return
= xirr(CashFlow
,CashFlowDates
)
adds optional arguments.Return
= xirr(___,Guess
,MaxIterations
,Basis
)
Examples
Find Internal Rate of Return for Nonperiodic Cash Flow
Find the internal rate of return for an investment of $10,000 that returns the following nonperiodic cash flow. The original investment is the first cash flow and is a negative number.
Cash Flow Dates
-10000 12-Jan-2007
2500 14-Feb-2008
2000 03-Mar-2008
3000 14-Jun-2008
4000 01-Dec-2008
Calculate the internal rate of return for this nonperiodic cash flow:
CashFlow = [-10000, 2500, 2000, 3000, 4000]; CashFlowDates = ['01/12/2007' '02/14/2008' '03/03/2008' '06/14/2008' '12/01/2008']; Return = xirr(CashFlow, CashFlowDates)
Return = 0.1006
Alternatively, you can use datetime input to calculate the internal rate of return for this nonperiodic cash flow:
CashFlow = [-10000, 2500, 2000, 3000, 4000]; CashFlowDates = ['01/12/2007' '02/14/2008' '03/03/2008' '06/14/2008' '12/01/2008']; CashFlowDates = datetime(CashFlowDates,'Locale','en_US')'; Return = xirr(CashFlow, CashFlowDates)
Return = 0.1006
Input Arguments
CashFlow
— Cash flow
vector | matrix
Cash flow, specified as a vector or matrix. The
first entry is the initial investment. If
CashFlow
is a matrix, each
column represents a separate stream of cash flows
whose internal rate of return is calculated. The
first cash flow of each stream is the initial
investment, usually entered as a negative
number.
Data Types: double
CashFlowDates
— Cash flow dates
datetime array | string array | date character vector
Cash flow dates, specified as a vector or matrix
using a datetime array, string array, or date character vectors. The
size of the input date numbers for CashFlowDates
must the same size as CashFlow
. Each column of
CashFlowDate
represents the dates of the
corresponding column of CashFlow
.
To support existing code, xirr
also
accepts serial date numbers as inputs, but they are not recommended.
Data Types: char
| datetime
| string
Guess
— Initial estimate of the internal rate of return
0.1
(10%) (default) | numeric
(Optional) Initial estimate of the internal rate
of return, specified as a scalar or vector. If
Guess
is a scalar, then it is
applied to all streams, and if
Guess
is a vector, then it is
the same length as the number of streams.
Data Types: double
MaxIterations
— Number of iterations used by Newton's method to solve the internal rate of return
50
(default) | positive integer
(Optional) Number of iterations used by Newton's
method to solve the internal rate of return,
specified as a scalar or vector of positive
integers. If MaxIterations
is a
scalar, then it is applied to all streams, and if
MaxIterations
is a vector, then
it is the same length as the number of
streams.
Data Types: double
Basis
— Day-count basis
0
(actual/actual) (default) | positive integers of the set [1...13]
| vector of positive integers of the set
[1...13]
(Optional) Day-count basis, specified as a
positive integer using scalar or a
N
-by-1
vector. If Basis
is a scalar,
then it is applied to all streams, and if
Basis
is a vector, then it is
the same length as the number of streams.
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
Return
— Annualized internal rate of return of each cash flow stream
numeric
Annualized internal rate of return of each cash
flow stream, returned as a vector. A
NaN
indicates that a solution
was not found.
References
[1] Brealey and Myers. Principles of Corporate Finance. McGraw-Hill Higher Education, Chapter 5, 2003.
[2] Sharpe, William F., and Gordon J. Alexander. Investments. Englewood Cliffs, NJ: Prentice-Hall. 4th ed., 1990.
Version History
Introduced before R2006aR2022b: Serial date numbers not recommended
Although xirr
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.
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)
Asia Pacific
- Australia (English)
- India (English)
- New Zealand (English)
- 中国
- 日本Japanese (日本語)
- 한국Korean (한국어)