periodReturn {quantmod}R Documentation

Calculate Periodic Returns

Description

Given a set of prices, return a quantmod.return object of returns calculated during specified period.

Usage

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')

Arguments

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

Details

periodReturn is the underlying function for wrappers:

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

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.

Author(s)

Jeffrey A. Ryan

References

Bodie,Kane...

See Also

getSymbols to.period

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)

[Package quantmod version 0.3-4 Index]