tick2ret
Convert price series to return series
Description
Examples
Convert Price Series to Return Series
Load the file SimulatedStock.mat
, which provides a timetable (TMW
) for financial data for TMW stock. Then convert a price series to a return series, given the first 10 periodic returns of TMW
.
load SimulatedStock.mat TMW_Close = TMW(1:10,'Close'); [Returns,Intervals] = tick2ret(TMW_Close)
Returns=9×1 timetable
Time Close
___________ ___________
05-Sep-2012 0.0017955
06-Sep-2012 0.013741
07-Sep-2012 -0.022591
10-Sep-2012 -0.011557
11-Sep-2012 -0.014843
12-Sep-2012 -0.0012384
13-Sep-2012 0.0081628
14-Sep-2012 -0.00051245
17-Sep-2012 -0.02902
Intervals = 9x1 duration
24:00:00
24:00:00
24:00:00
72:00:00
24:00:00
24:00:00
24:00:00
24:00:00
72:00:00
Convert Price Series to Return Series Using datetime
Input
Use datetime
input to convert a price series to a return series, given periodic returns of two stocks observed in the first, second, third, and fourth quarters.
TickSeries = [100 80 110 90 115 88 110 91]; TickTimes = datetime({'1/1/2015','1/7/2015','1/16/2015','1/28/2015'},'InputFormat','MM/dd/uuuu'); [Returns,Intervals] = tick2ret(TickSeries,'TickTimes',TickTimes)
Returns = 3×2
0.1000 0.1250
0.0455 -0.0222
-0.0435 0.0341
Intervals = 3x1 duration
144:00:00
216:00:00
288:00:00
Input Arguments
Data
— Data for asset prices
matrix | table | 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.
Before R2021a, use commas to separate each name and value, and enclose
Name
in quotes.
Example: [Returns,Intervals] =
tick2ret(TickSeries,'TickTimes',TickTimes)
TickTimes
— Observation times associated with prices
sequential observation times from 1
,2
,...NUMOBS
assumed for all assets (default) | vector
Observation times associated with prices, specified as the
comma-separated pair consisting of 'TickTimes'
and a
NUMOBS
element column vector of monotonically
increasing observation times associated with the prices in
Data
. Times are taken either as serial date
numbers (day units), date strings, datetime arrays, or as decimal
numbers in arbitrary units (for example, yearly).
Note
If the input Data
type is a timetable, the
row times information in the timetable overwrites the
TickTimes
input.
Data Types: double
| datetime
| string
Method
— Method to convert asset prices to returns
'Simple'
(default) | character vector with value of 'Simple'
or 'Continuous'
| string with value of "Simple"
or "Continuous"
Method to convert asset prices to returns, specified as the
comma-separated pair consisting of 'Method'
and a
string or character vector indicating the method to convert asset prices
to returns.
If the method is 'Simple'
, then simple periodic
returns at time t are computed
as:
Returns(t) = Data(t)/Data(t-1) - 1.
If the method is 'Continuous'
, the continuous
returns are computed
as:
Returns(t) = log(Data(t)/Data(t-1)).
Data Types: char
| string
Output Arguments
Returns
— Time series array of asset returns
matrix | table | timetable
Time series array of asset returns, returned as a
NUMOBS-1
-by-NASSETS
array of asset
returns with the same type (matrix, table, or timetable) as the input
Data
. The first row contains the oldest returns and
the last row contains the most recent. Returns across a given row are
assumed to occur at the same time for all columns, and each column is a
return series of an individual asset.
Intervals
— Interval times between successive prices
vector
Interval times between successive prices, returned as a
NUMOBS-1
length column vector where
Intervals
(t) =
TickTimes
(t) -
TickTimes
(t - 1).
Extended Capabilities
Tall Arrays
Calculate with arrays that have more rows than fit in memory.
This function supports input Data
that is specified as a tall
column vector, a tall table, or a tall timetable. For more information, see tall
and Tall Arrays.
Version History
Introduced before R2006aR2022b: Support for negative price data
The Data
input accepts negative prices.
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 (한국어)