tick2ret

Convert price series to return series

tick2ret accepts Data as a matrix, timetable, or table.

Syntax

[Returns,Intervals] = tick2ret(Data)
[Returns,Intervals] = tick2ret(___,Name,Value)

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.

load SimulatedStock.mat

TMW_Close = TMW(1:10,'Close');
[Returns,Intervals] = tick2ret(TMW_Close)
Returns=9×2 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 array
   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 array
   144:00:00
   216:00:00
   288:00:00

Input Arguments

collapse all

Data for asset prices, specified as a matrix, table, or timetable, specified as NUMOBS-by-NASSETS. 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 Pair Arguments

Specify optional comma-separated pairs of Name,Value arguments. Name is the argument name and Value is the corresponding value. Name must appear inside quotes. You can specify several name and value pair arguments in any order as Name1,Value1,...,NameN,ValueN.

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

Extended Capabilities

Introduced before R2006a