ret2tick
Convert return series to price series
Description
[
computes prices from the start prices of TickSeries
,TickTimes
] = ret2tick(Data
)NASSET
assets and
NUMOBS
return observations.
[
adds optional name-value pair arguments. TickSeries
,TickTimes
] = ret2tick(___,Name,Value
)
Examples
Convert a Return Series to a Price Series
Compute the price increase of two stocks over a year's time based on three incremental return observations.
RetSeries = [0.10 0.12 0.05 0.04 -0.05 0.05]; RetIntervals = [182 91 92]; StartTime = datetime('18-Dec-2000','Locale','en_US'); [TickSeries,TickTimes] = ret2tick(RetSeries,'ReturnIntervals',RetIntervals,... 'StartTime',StartTime)
TickSeries = 4×2
1.0000 1.0000
1.1000 1.1200
1.1550 1.1648
1.0973 1.2230
TickTimes = 4x1 datetime
18-Dec-2000
18-Jun-2001
17-Sep-2001
18-Dec-2001
Convert a Price Series to a Return Series Using timetable
Input
Use timetable
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.
RetSeries = [0.10 0.12 0.05 0.04 -0.05 0.05]; RetTimes = datetime({'6/18/2001','9/17/2001','12/18/2001'},'InputFormat','MM/dd/uuuu','Locale','en_US'); RetSeries = array2timetable(RetSeries,'RowTimes',RetTimes); StartTime = datetime('12/18/2000','InputFormat','MM/dd/uuuu','Locale','en_US'); [TickSeries,TickTimes] = ret2tick(RetSeries,'StartTime',StartTime)
TickSeries=4×2 timetable
Time RetSeries1 RetSeries2
___________ __________ __________
18-Dec-2000 1 1
18-Jun-2001 1.1 1.12
17-Sep-2001 1.155 1.1648
18-Dec-2001 1.0973 1.223
TickTimes = 4x1 datetime
18-Dec-2000
18-Jun-2001
17-Sep-2001
18-Dec-2001
Input Arguments
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: [TickSeries,TickTimes] =
ret2tick(RetSeries,'StartTime',StartTime)
StartPrice
— Initial prices for each asset
1
for all assets (default) | numeric
Initial prices for each asset, specified as the comma-separated pair
consisting of 'StartPrice'
and a
NASSETS
-by-1
vector indicating
initial prices for each asset, or a single scalar initial price applied
to all assets.
Data Types: double
ReturnIntervals
— Return interval between prices
1
for all assets (default) | numeric | duration | calendar duration
Return interval between prices, specified as the comma-separated pair
consisting of 'ReturnIntervals'
and a scalar return
interval applied to all returns, or a vector of length
NUMOBS
return intervals between successive
returns. ReturnIntervals
is defined as:
ReturnIntervals(t) = TickTimes(t) - TickTimes(t-1).
Note
If the type of Data
is a timetable,
ReturnIntervals
is ignored.
Data Types: double
StartTime
— Starting time for first observation applied to the prices of all assets
0
if ReturnIntervals
is numeric (default) | numeric | duration | calendar duration
Starting time for first observation applied to the price series of all
assets, specified as the comma-separated pair consisting of
'StartTime'
and a scalar string, character
vector, double, or datetime.
Note
If ReturnIntervals
is a duration or
calendar duration value, the default for
StartTime
is
datetime('today')
.
If Data
is a timetable and
StartTime
is not specified, the resulting
asset prices in the first period are not reported.
Data Types: double
| string
| char
| datetime
Method
— Method to convert asset returns to prices
'Simple'
(default) | character vector with value of 'Simple'
or 'Continuous'
| string with value of "Simple"
or "Continuous"
Method to convert asset returns to prices, 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 are
used:
TTickSeries(t) = TickSeries(t-1)*(1 + ReturnSeries(t)).
If the method is 'Continuous'
, then continuous
returns are
used:
TickSeries(t) = TickSeries(t-1)*exp(ReturnSeries(t)).
Data Types: char
| string
Output Arguments
TickSeries
— Time series array of asset prices
matrix | table | timetable
Time series array of asset prices, returned as
NUMBOBS+1
-by-NASSETS
time series
of asset prices of the same type (matrix, table, or timetable) as the input
Data
. The first row contains the oldest prices and
the last row contains the most recent. 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.
TickTimes
— Observation times associated with prices in TickSeries
vector
Observation times associated with the prices in
TickSeries
, returned as a
NUMBOBS+1
length column vector of monotonically
increasing observation times associated with the prices in
TickSeries
. The initial time is
StartTime
. For matrix and table
Data
, sequential observations occur at increments
specified in ReturnIntervals
and for
Data
timetables, sequential observations are
derived from times and dates in Data
.
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 (한국어)