| periodReturn {quantmod} | R Documentation |
Given a set of prices, return a quantmod.return object
of returns calculated during specified period.
periodReturn(x, period='monthly', subset=NULL, type='arithmetic',
...)
dailyReturn(x, subset=NULL, type='arithmetic', ...)
weeklyReturn(x, subset=NULL, type='arithmetic', ...)
monthlyReturn(x, subset=NULL, type='arithmetic', ...)
quarterlyReturn(x, subset=NULL, type='arithmetic', ...)
annualReturn(x, subset=NULL, type='arithmetic', ...)
yearlyReturn(x, subset=NULL, type='arithmetic', ...)
allReturns(x, subset=NULL, type='arithmetic')
x |
zoo object of state prices |
period |
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 style subset string |
type |
type of returns: arithmetic (discrete) or log (continuous) |
... |
passed along to to.period |
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
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.
The final row of returned object will have the current period return to last date, i.e. this week/month/quarter/year return to date.
Jeffrey A. Ryan
Bodie,Kane...
## 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)