adjustedClosingPrices
Description
adjusts raw closing prices for splits and cash dividends.TT2
= adjustedclosingprices(TT1
)
adjustedclosingprices
adjusts raw closing prices for stock
splits by dividing by the split ratio (for example, dividing by 2 for a 2:1 split or
1.5 for a 3:2 split). adjustedclosingprices
adjusts closing
prices for cash dividends by scaling them by a dividend multiplier in which it
expresses the dividend as a fraction of the last closing price preceding the
ex-dividend date. To avoid negative prices, this scaling operation adheres to the
Center for Research in Security Prices (CRSP) standard.
specifies options using one or more name-value arguments in addition to the input
arguments in the previous syntax.TT2
= adjustedclosingprices(___,Name=Value
)
Examples
Adjust Closing Stock Prices for Splits and Cash Dividends
This example shows how to adjust a time series of closing stock prices that includes a 2-for-1 split and pays a 0.17 cash dividend. First, you store the closing prices, split ratios, and cash dividends in timetable TT1
and then pass them to adjustedClosingPrices
.
Create a timetable
(TT1
) for a single stock. TT1
contains raw closing prices, split ratios, and cash dividends, but TT1
can also contain other variables such as Open, High, Low, Volume, and so on.
dates = [(datetime(2023,2,18) + caldays(0:4)') ; datetime(2023,2,[25 26]')]; close = [100 102.79 53.12 53.01 53.10 52.20 52.22]'; split = [1 1 2 1 1 1 1]'; dividend = [0 0 0 0 0 0.17 0]'; TT1 = timetable(close,split,dividend,RowTimes=dates,VariableNames=["Close" "Split" "Dividend"])
TT1=7×3 timetable
Time Close Split Dividend
___________ ______ _____ ________
18-Feb-2023 100 1 0
19-Feb-2023 102.79 1 0
20-Feb-2023 53.12 2 0
21-Feb-2023 53.01 1 0
22-Feb-2023 53.1 1 0
25-Feb-2023 52.2 1 0.17
26-Feb-2023 52.22 1 0
To adjust the closing stock prices for the splits and cash dividends in TT1
, use adjustedClosingPrices
and output the results in TT2
.
TT2 = adjustedClosingPrices(TT1)
TT2=7×1 timetable
Time Adjusted_Close
___________ ______________
18-Feb-2023 49.84
19-Feb-2023 51.23
20-Feb-2023 52.95
21-Feb-2023 52.84
22-Feb-2023 52.93
25-Feb-2023 52.2
26-Feb-2023 52.22
The output timetable TT2
has the same dates as TT1
, but TT2
contains only the adjusted closing prices. However, since TT1
and TT2
share the same dates, you can combine the data of both timetables.
[TT1 TT2]
ans=7×4 timetable
Time Close Split Dividend Adjusted_Close
___________ ______ _____ ________ ______________
18-Feb-2023 100 1 0 49.84
19-Feb-2023 102.79 1 0 51.23
20-Feb-2023 53.12 2 0 52.95
21-Feb-2023 53.01 1 0 52.84
22-Feb-2023 53.1 1 0 52.93
25-Feb-2023 52.2 1 0.17 52.2
26-Feb-2023 52.22 1 0 52.22
Input Arguments
TT1
— Timetable containing raw closing stock prices to adjust for splits and cash dividends
timetable
Timetable containing the raw closing stock prices to adjust for splits and
cash dividends, specified as a timetable
.
Note
TT1
must have datetime stamps in strictly
ascending or descending order. All observations in
TT1
are associated with whole dates that you
specify as datetime values but have no HH:MM:SS
time component.
Optionally, TT1
can also contain split ratios and cash
dividends per share.
Data Types: timetable
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.
Example: TT2 =
adjustedClosingPrices(TT1,ClosingPriceVariable="closong_price_variable")
ClosingPriceVariable
— Variable specification to select raw closing price variable from TT1
variable that contains "Close"
(case insensitive) (default) | positive scalar numeric index | scalar variable name (string or character vector) | logical vector with one true element
Variable specification to select the raw closing price variable from
TT1
, specified as a positive scalar numeric
index, a scalar variable name (string or character vector), or a logical
vector with one true element.
Note
If no variable contains "Close"
, then this
function issues an error.
Data Types: double
| char
| string
| logical
DividendVariable
— Variable specification to select cash dividend variable from TT1
variable that contains "Dividend"
(case insensitive) (default) | positive scalar numeric index | scalar variable name (string or character vector) | logical vector with one true element
Variable specification to select the cash dividend variable from
TT1
, specified as a positive scalar numeric
index, a scalar variable name (string or character vector), or a logical
vector with one true element.
Note
If no variable contains "Dividend"
, then
this function does not make a dividend adjustment.
Data Types: double
| char
| string
| logical
SplitVariable
— Variable specification to select split ratio variable from TT1
variable that contains "Split"
(case insensitive) (default) | positive scalar numeric index | scalar variable name (string or character vector) | logical vector with one true element
Variable specification to select the split ratio variable from
TT1
, specified as a positive scalar numeric
index, a scalar variable name (string or character vector), or a logical
vector with one true element.
Note
If no variable contains "Split"
, then this
function makes split adjustment.
Data Types: double
| char
| string
| logical
Output Arguments
TT2
— Adjusted closing prices associated with raw closing prices of variable ClosingPriceVariable
timetable
Timetable with the same dates as TT1
containing
adjusted closing prices associated with the raw closing prices of variable
ClosingPriceVariable
, returned as a timetable
.
If the raw closing price variable in TT1
contains
"Close"
, then the function obtains the adjusted
closing price variable by inserting "Adjusted_"
immediately before "Close"
. Otherwise, the function
obtains the adjusted closing price variable by prepending
"Adjusted_"
to the variable in
TT1
containing the raw closing prices. If the
function makes no adjustments, it copies the raw closing prices of
TT1
to the adjusted closing prices of
TT2
. If the dates of TT1
are in
ascending or descending order, then the dates of TT2
are
in ascending or descending order, respectively.
The naming convention of the adjusted closing price variable in
TT2
is:
If the closing price variable in
TT1
is"XYZ_Close"
(TT1.XYZ_Close
), then the adjusted closing price variable inTT2
is"XYZ_Adjusted_Close"
(TT2.XYZ_Adjusted_Close
).If the closing price variable in
TT1
is"XYZ"
(TT1.XYZ
), then the adjusted closing price variable inTT2
is"Adjusted_XYZ"
(TT2.Adjusted_XYZ
).
Version History
Introduced in R2024a
See Also
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 (한국어)