[R-SIG-Finance] Return.Calculate vs ROC
Brian G. Peterson
brian at braverock.com
Sun Jun 12 22:34:03 CEST 2011
On Sun, 2011-06-12 at 23:20 +0300, Costas Vorlow wrote:
> Hi,
>
> I am having a bit of trouble with the following code:
>
> require(PerformanceAnalytics)
> require(quantmod)
>
> getSymbols("^GSPC", from="1990-01-01")
>
> retorig<-Return.calculate(Cl(GSPC),method="simple")
> retroc<-ROC(Cl(GSPC), type="discrete")
What is the ROC supposed to give you?
Return.calculate will give you simple returns on a buy and hold of GSPC.
for example, this code works fine:
require(PerformanceAnalytics)
require(quantmod)
getSymbols("^GSPC", from="1990-01-01")
retorig<-Return.calculate(Cl(GSPC),method="simple")
charts.PerformanceSummary(retorig, geometric=FALSE, wealth.index=TRUE)
> strategiestest<-merge(retorig,retroc)
> charts.PerformanceSummary(strategiestest, geometric=FALSE, wealth.index)
> shouldn't in the above example retorig=retroc?
Why would the rate of change of the returns be the same as the returns
themselves? Perhapsnderstand you, but that doesn't make any sense to
me.
> retorig appears to be 0....
>
>
> > head(strategiestest)
> GSPC.Close GSPC.Close.1
> 1990-01-02 0 0.000000000
> 1990-01-03 0 -0.002585560
> 1990-01-04 0 -0.008613000
> 1990-01-05 0 -0.009756235
> 1990-01-08 0 0.004514480
> 1990-01-09 0 -0.011786653
> >
>
>
> Many thanks in advance,
> Costas
>
--
Brian G. Peterson
http://braverock.com/brian/
Ph: 773-459-4973
IM: bgpbraverock
More information about the R-SIG-Finance
mailing list