tick2ret

Convert price series to return series

Description

example

[Returns,Intervals] = tick2ret(Data) computes asset returns for NUMOBS price observations of NASSETS assets.

example

[Returns,Intervals] = tick2ret(___,Name,Value) adds optional name-value pair arguments.

Examples

collapse all

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.

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

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

collapse all

Data for asset prices, specified as a NUMOBSNASSETS matrix, table, or timetable. Prices across a given row are assumed to occur at the same time for all columns, and each column is a price series of an individual asset.

Data Types: double | 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)

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 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

collapse all

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.

Interval times between successive prices, returned as a NUMOBS-1 length column vector where Intervals(t) = TickTimes(t) - TickTimes(t - 1).

Version History

Introduced before R2006a

expand all