[R-SIG-Finance] Return.Calculate vs ROC

Costas Vorlow costas.vorlow at gmail.com
Mon Jun 13 14:50:24 CEST 2011


Thanks for all the replies.

There was something wrong with my installations of the relevant
packages. When I reinstalled, the problem seized...

Maybe some code overwritten or mixed up with some of my routines.

Thanks again for your time and replies,
Costas

On 12 June 2011 23:43, G See <gsee000 at gmail.com> wrote:
> Is it possible that you overwrote the function Return.calculate?  Or, that
> you overwrote retorig before you merged?  What is the output if you enter
> Return.calculate?  i.e. what source code do you have for that function?
> I can't replicate your problem:
>> getSymbols("^GSPC", from="1990-01-01")
> [1] "GSPC"
>> retorig<-Return.calculate(Cl(GSPC),method="simple")
>> retroc<-ROC(Cl(GSPC), type="discrete")
>>
>> identical(retorig,retroc)
> [1] TRUE
>> strategiestest<-merge(retorig,retroc)
>> head(strategiestest)
>              GSPC.Close GSPC.Close.1
> 1990-01-02           NA           NA
> 1990-01-03 -0.002585560 -0.002585560
> 1990-01-04 -0.008613000 -0.008613000
> 1990-01-05 -0.009756235 -0.009756235
> 1990-01-08  0.004514480  0.004514480
> 1990-01-09 -0.011786653 -0.011786653
>> which(strategiestest[,1]!=strategiestest[,2])
> integer(0)
>
>
>
> On Sun, Jun 12, 2011 at 3:20 PM, Costas Vorlow <costas.vorlow at gmail.com>
> 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")
>>
>> strategiestest<-merge(retorig,retroc)
>> charts.PerformanceSummary(strategiestest, geometric=FALSE, wealth.index)
>>
>>
>> shouldn't in the above example retorig=retroc?
>>
>> 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
>>
>> --
>>
>> +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
>> |c|o|s|t|a|s|@|v|o|r|l|o|w|.|o|r|g|
>> +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
>>
>> _______________________________________________
>> R-SIG-Finance at r-project.org mailing list
>> https://stat.ethz.ch/mailman/listinfo/r-sig-finance
>> -- Subscriber-posting only. If you want to post, subscribe first.
>> -- Also note that this is not the r-help list where general R questions
>> should go.
>
>



-- 

+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|c|o|s|t|a|s|@|v|o|r|l|o|w|.|o|r|g|
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+



More information about the R-SIG-Finance mailing list