periodReturn(x,
period='monthly',
subset=NULL,
type='arithmetic',
leading=TRUE,
...)dailyReturn(x, subset=NULL, type='arithmetic',
leading=TRUE, ...)
weeklyReturn(x, subset=NULL, type='arithmetic',
leading=TRUE, ...)
monthlyReturn(x, subset=NULL, type='arithmetic',
leading=TRUE, ...)
quarterlyReturn(x, subset=NULL, type='arithmetic',
leading=TRUE, ...)
annualReturn(x, subset=NULL, type='arithmetic',
leading=TRUE, ...)
yearlyReturn(x, subset=NULL, type='arithmetic',
leading=TRUE, ...)
allReturns(x, subset=NULL, type='arithmetic',
leading=TRUE)
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.
periodReturn
is the underlying function for wrappers:
allReturns:
calculate all available return periodsdailyReturn:
calculate daily returnsweeklyReturn:
calculate weekly returnsmonthlyReturn:
calculate monthly returnsquarterlyReturn:
calculate quarterly returnsannualReturn:
calculate annual returnsgetSymbols
to.period
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)
Run the code above in your browser using DataLab