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.
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.
Data — Data for asset prices matrix | table | timetable
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 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.
'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 — 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.
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.