Documentation

ret2price

Convert returns to prices

Syntax

[TickSeries,TickTimes] = ...
ret2price(RetSeries,StartPrice,RetIntervals,StartTime,Method)

Description

[TickSeries,TickTimes] = ...
ret2price(RetSeries,StartPrice,RetIntervals,StartTime,Method)
generates price series for the specified assets, given the asset starting prices and the return observations for each asset.

Input Arguments

RetSeries

Time series array of returns.RetSeries可以是列向量或矩阵:

  • 作为一个向量,RetSeriesrepresents a univariate series of returns of a single asset. The length of the vector is the number of observations (NUMOBS)。第一个元素包含最古老的观察结果,而最后一个元素是最新的。

  • As a matrix,RetSeriesrepresents aNUMOBS-by-number of assets (努力) matrix of asset returns. Rows correspond to time indices. The first row contains the oldest observations and the last row the most recent.ret2priceassumes that the observations across a given row occur at the same time for all columns, and each column is a return series of an individual asset.

StartPrice

A努力element vector of initial prices for each asset, or a single scalar initial price applied to all assets. IfStartPrice = []or is unspecified, all asset prices start at1.

RetIntervals

ANUMOBSelement vector of time intervals between return observations, or a single scalar interval applied to all observations. IfRetIntervalsis[]or is unspecified,ret2priceassumes that all intervals have length1.

StartTime

(optional) Scalar starting time for the first observation, applied to the price series of all assets. The default is0.

Method

Character vector indicating the compounding method used to compute asset returns. IfMethodis'连续的',[], or unspecified, thenret2price计算连续复合的回报。如果Methodis'Periodic'thenret2pricecomputes simple periodic returns.Methodis case insensitive.

Output Arguments

TickSeries

资产价格阵列:

  • WhenRetSeriesis aNUMOBS元素列向量,TickSeriesis aNUMOBS+1column vector. The first element contains the starting price of the asset, and the last element the most recent price.

  • WhenRetSeriesis aNUMOBS-by-努力然后RetSeries是(NUMOBS+1)-by-努力矩阵。第一行包含资产的起价,最后一行包含最新价格。

tick时间

ANUMOBS+1 element vector of price observation times. The initial time is zero unless specified inStartTime.

Examples

collapse all

创建一个股票价格过程不断复杂10%

S = 100*exp(0.10*[0:19]');% Create the stock price series

Compute 10 percent returns for reference

r = Price2Ret(S);% Convert the price series to a% 10 percent return series

Convert the resulting return series to the original price series, and compare results:

p = ret2price(R,100);%转换为原始价格% series[S P]% Compare the original and
ans =100.0000 100.0000 110.5171 110.5171 122.1403 122.1403 134.9859 134.9859 149.1825 149.1825 164.8721 164.8721 182.2119 182.2119 201.3753 201.3753 222.5541 222.5541 245.9603 245.9603
% computed price series

This example compares the relative price performance of the NASDAQ and the NYSE indexes.

加载权益索引数据。

loaddata_equitydx

Convert the returns back to prices, specifying the same starting price,100, for each series, and plot the results.

数字;绘图(ret2price(Price2Ret([[DATATABLE.NASDAQ DATATABLE.NYSE)]),100))ylabel('Prices') legend('Nasdaq','NYSE','地点','Best') axistight

蓝色(上)图显示了NASDAQprice series. The green (lower) plot shows theNYSEprice series.

See Also

|

在R2006a之前引入

这个话题有帮助吗?