returns  R Documentation 
Compute financial returns from prices or indexes.
returns(x, ...)
returns0(x, ...)
## S4 method for signature 'ANY'
returns(x, method = c("continuous", "discrete",
"compound", "simple"), percentage = FALSE, ...)
## S4 method for signature 'timeSeries'
returns(x, method = c("continuous", "discrete",
"compound", "simple"), percentage = FALSE, na.rm = TRUE,
trim = TRUE, ...)
x 
an object of class 
method 
a character string. Which method should be used to compute the returns, one of "continuous", "discrete", or "compound", "simple". The second pair of methods is a synonym for the first two methods. 
percentage 
a logical value. By default 
na.rm 
a logical value. Should NAs be removed? By default 
trim 
a logical value. Should the time series be trimmed? By Default

... 
arguments to be passed. 
an object of class timeSeries
.
returns0
returns an untrimmed series with the first
row of returns set to zero(s).
The functions returnSeries
and getReturns
will be
removed in the near future. They are synonyms for the function
returns
and their use was discouraged for many years. Just use
returns
.
The function returnSeries
is no longer
exported. getReturns
is exported only because we are waiting
for a package on CRAN to be updated.
cumulated
,
drawdowns
,
splits
,
spreads
,
midquotes
,
index2wealth
## Load Microsoft Data 
setRmetricsOptions(myFinCenter = "GMT")
data(MSFT)
X = MSFT[1:10, 1:4]
X
## Continuous Returns 
returns(X)
returns0(X)
## Discrete Returns:
returns(X, method = "discrete")
## Don't trim:
returns(X, trim = FALSE)
## Use Percentage Values:
returns(X, percentage = TRUE, trim = FALSE)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.