character string indicating time period. Valid entries are
‘daily’, ‘weekly’,
‘monthly’, ‘quarterly’, ‘yearly’. All
are accessible from wrapper functions described below.
Defaults to monthly returns (same as monthlyReturn)
subset
an xts/ISO8601 style subset string
type
type of returns: arithmetic (discrete) or log (continuous)
leading
should incomplete leading period returns be returned
...
passed along to to.period
Details
periodReturn is the underlying function for wrappers:
allReturns: calculate all available return periods
dailyReturn: calculate daily returns
weeklyReturn: calculate weekly returns
monthlyReturn: calculate monthly returns
quarterlyReturn: calculate quarterly returns
annualReturn: calculate annual returns
Value
Returns object of the class that was originally passed in,
with the possible exception of monthly and quarterly return
indicies being changed to class yearmon and yearqtr
where available. This can be overridden with the indexAt
argument passed in the ... to the to.period function.
By default, if subset is NULL, the full dataset will
be used.
Note
Attempts are made to re-convert the resultant series to its original
class, if supported by the xts package. At present, objects inheriting
from the ‘ts’ class are returned as xts objects. This
is to make the results more visually appealling and informative. All
xts objects can be converted to class ts with
as.ts if that is desirable.
The first and final row of returned object will have the period return to last date,
i.e. this week/month/quarter/year return to date even if the start/end is not the start/end
of the period. Leading period calculations can be suppressed by setting leading=FALSE.
Author(s)
Jeffrey A. Ryan
See Also
getSymbols
Examples
## Not run:
getSymbols('QQQQ',src='yahoo')
allReturns(QQQQ) # returns all periods
periodReturn(QQQQ,period='yearly',subset='2003::') # returns years 2003 to present
periodReturn(QQQQ,period='yearly',subset='2003') # returns year 2003
rm(QQQQ)
## End(Not run)