|
Dear all:
I am facing a disconcerting issue with the functions CalculateReturns() and chart.CumReturns() of the PerformanceAnalytics package.
First, when I try to use CalculateReturns() to back out the returns from the total return indices values, the resulting returns do not add up:
Indices.ts <- as.timeSeries(CalculateReturns(indices, method = "compound")) #Note that the method = “simple” option only returns zeros for me.
Running the code above on the data in the “indices” CSV file attached, I obtain suspicious returns (for instance the total return for S&P 500 is 17% while it is actually close to 40%).
Second, when I do the reverse and use chart.CumReturns() with the correct returns calculated manually in the “returns” CSV file attached, I also obtain wrong cumulative returns.
Returns.ts <- chart.CumReturns(returns[,c(1:5), drop = FALSE], main="Cumulative Returns", begin="axis", legend.loc = "topleft", geometric = TRUE, wealth.index = TRUE, colorset = rainbow6equal)
Running this code plots for instance the Barclays US Agg Corporate in my sample above the Barclays Global Agg whereas the later outperformed it.
I spent a fair amount of time trying to resolve this by myself but it appears that something is amiss.
Thanks in advance for your much appreciated help!
Julien
This e-mail and its attachments are intended only for the individual or entity to whom it is addressed and may contain information that is confidential, privileged, inside information, or subject to other restrictions on use or disclosure. If you have received this transmission in error, please notify the sender immediately by return e-mail, and permanently delete or destroy this e-mail, any attachments, and all copies. Any unauthorized use, dissemination or copying of this transmission or the information may be unlawful. This message is provided for informational purposes and should not be construed as an invitation or offer to buy or sell any securities or related financial instruments. _______________________________________________ [hidden email] 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. |
|
Bonjour Julien, Just as FYI, entering the dates in your first column as DD/MM/YYYY is not ideal - best to format them as YYYY-MM-DD as unambigous format R can understand I can have the method "compound" work as it should personally but still have the simple method giving me zeros - ??? AFTER changing the csv first column dates with format YYYY-MM-DD > dfPrices <- read.csv("Indices.csv",header=TRUE,row.names=1,as.is=TRUE) > testSimple <- CalculateReturns(dfPrices,method="simple") > write.csv(testSimple,"testSimple.csv") > testCompound <- CalculateReturns(dfPrices,method="compound") > write.csv(testCompound,"testCompound.csv") attached the csv I got from that code - weirdly I have simple returns as zeros but compound returns OK? I am suspecting the second issue might be related? thhanks to report back to the list if it is the case Rgds, Julien Just to confirm testing the below & I am getting the same... I am guessing we do not use it proprely although it should be simple - focusing ont he CalculateRetuurns() function: > dfPrices <- read.csv("Indices.csv",header=TRUE,row.names=1,as.is=TRUE) test <- CalculateReturns(dfPrices,method="compound") Warning message: In data.row.names(row.names, rowsi, i) : some row.names duplicated: 3,6,9,11,13,16,20,23,25,27,30,33,37,40,45,49,51,54,56,58,60,62,64,66,68,73,78,84,86,89,91,93,95,98,100,102,104,106,112,115,118,124,126,130,133,136,138,140,143,147,150,152,154,157,160,164,167,172,176,178,181,183,185,187,189,191,193,195,200,205,211,213,216,218,220,222,225,227,229,231,233,239,242,245,251,253,257,260,263,265,267,270,274,277,279,281,284,287,291,294,299,303,305,308,310,312,314,316,318,320,322,327,332,338,340,343,345,347,349,352,354,356,358,360,366,369,372,378,380,384,387,390,392,394,397,401,404,406,408,411,414,418,421,426,430,432,435,437,439,441,443,445,447,449,454,459,465,467,470,472,474,476,479,481,483,486,492,495,498,504,506,512,515,517,519,522,526,528,530,532,535,538,542,549,551 --> row.names NOT used Not sure what the warning is about as I do not have duplicated From: [hidden email] To: [hidden email] Date: Wed, 25 Jul 2012 03:52:09 +0000 Subject: [R-SIG-Finance] PerformanceAnalytics issue Dear all: I am facing a disconcerting issue with the functions CalculateReturns() and chart.CumReturns() of the PerformanceAnalytics package. First, when I try to use CalculateReturns() to back out the returns from the total return indices values, the resulting returns do not add up: Indices.ts <- as.timeSeries(CalculateReturns(indices, method = "compound")) #Note that the method = “simple” option only returns zeros for me. Running the code above on the data in the “indices” CSV file attached, I obtain suspicious returns (for instance the total return for S&P 500 is 17% while it is actually close to 40%). Second, when I do the reverse and use chart.CumReturns() with the correct returns calculated manually in the “returns” CSV file attached, I also obtain wrong cumulative returns. Returns.ts <- chart.CumReturns(returns[,c(1:5), drop = FALSE], main="Cumulative Returns", begin="axis", legend.loc = "topleft", geometric = TRUE, wealth.index = TRUE, colorset = rainbow6equal) Running this code plots for instance the Barclays US Agg Corporate in my sample above the Barclays Global Agg whereas the later outperformed it. I spent a fair amount of time trying to resolve this by myself but it appears that something is amiss. Thanks in advance for your much appreciated help! Julien This e-mail and its attachments are intended only for the individual or entity to whom it is addressed and may contain information that is confidential, privileged, inside information, or subject to other restrictions on use or disclosure. If you have received this transmission in error, please notify the sender immediately by return e-mail, and permanently delete or destroy this e-mail, any attachments, and all copies. Any unauthorized use, dissemination or copying of this transmission or the information may be unlawful. This message is provided for informational purposes and should not be construed as an invitation or offer to buy or sell any securities or related financial instruments. _______________________________________________ [hidden email] 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. _______________________________________________ [hidden email] 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. |
|
In reply to this post by Julien Dargent
Look at your returns.csv file - all your monthly returns are rounded to
the nearest 1%, so the graph is not going to be anywhere close to your expectations. Your issue with method = "simple" has been reported before to this list and was corrected in r-forge. Check that you are using the most up-to-date CRAN release, and if not then try updating. pcc -- Peter Carl http://www.braverock.com/peter > Dear all: > > I am facing a disconcerting issue with the functions CalculateReturns() > and chart.CumReturns() of the PerformanceAnalytics package. > > First, when I try to use CalculateReturns() to back out the returns from > the total return indices values, the resulting returns do not add up: > > Indices.ts <- as.timeSeries(CalculateReturns(indices, method = > "compound")) > #Note that the method = "simple" option only returns zeros for me. > > Running the code above on the data in the "indices" CSV file attached, I > obtain suspicious returns (for instance the total return for S&P 500 is > 17% while it is actually close to 40%). > > Second, when I do the reverse and use chart.CumReturns() with the correct > returns calculated manually in the "returns" CSV file attached, I also > obtain wrong cumulative returns. > > Returns.ts <- chart.CumReturns(returns[,c(1:5), drop = FALSE], > main="Cumulative Returns", > begin="axis", > legend.loc = "topleft", > geometric = TRUE, > wealth.index = TRUE, > colorset = rainbow6equal) > > Running this code plots for instance the Barclays US Agg Corporate in my > sample above the Barclays Global Agg whereas the later outperformed it. > > [cid:image001.png@01CD69DE.3138E1C0] > > I spent a fair amount of time trying to resolve this by myself but it > appears that something is amiss. > > Thanks in advance for your much appreciated help! > > Julien > > > > This e-mail and its attachments are intended only for the individual or > entity to whom it is addressed and may contain information that is > confidential, privileged, inside information, or subject to other > restrictions on use or disclosure. If you have received this transmission > in error, please notify the sender immediately by return e-mail, and > permanently delete or destroy this e-mail, any attachments, and all > copies. Any unauthorized use, dissemination or copying of this > transmission or the information may be unlawful. This message is provided > for informational purposes and should not be construed as an invitation or > offer to buy or sell any securities or related financial instruments. > _______________________________________________ > [hidden email] 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. _______________________________________________ [hidden email] 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. |
|
On 07/25/2012 10:45 AM, Peter Carl wrote:
> Your issue with method = "simple" has been reported before to this list > and was corrected in r-forge. Check that you are using the most > up-to-date CRAN release, and if not then try updating. THe bug was fixed on 2 Apr, 2012, in svn r1894, which is *after* the last CRAN release. You should use the R-Forge version, currently here: install.packages("PerformanceAnalytics", repos= c("http://R-Forge.R-project.org", getOption("repos"))) (assuming that the R-Forge build process hasn't failed, as it often seems to) Regards, - Brian -- Brian G. Peterson http://braverock.com/brian/ Ph: 773-459-4973 IM: bgpbraverock _______________________________________________ [hidden email] 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. |
|
> (assuming that the R-Forge build process hasn't failed, as it often seems to)
There are a couple of warnings and a error during the running of an example at the windows package. Probably that's the reason why it failed to build. Details at https://r-forge.r-project.org/R/?group_id=579&log=check_x86_64_windows&pkg=PerformanceAnalytics&flavor=patched Regards, Andreas _______________________________________________ [hidden email] 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. |
|
In reply to this post by braverock
Brian, Peter & Others,
Thank you very much for your help. The rounding was definitely part of the problem with chart.CumReturns and I had also wrongly assumed CumReturns would work with compound/log return whereas it takes in actual/simple returns. Thanks again for the great package. Julien -----Original Message----- From: [hidden email] [mailto:[hidden email]] On Behalf Of Brian G. Peterson Sent: Wednesday, July 25, 2012 8:56 AM To: [hidden email] Subject: Re: [R-SIG-Finance] PerformanceAnalytics issue On 07/25/2012 10:45 AM, Peter Carl wrote: > Your issue with method = "simple" has been reported before to this list > and was corrected in r-forge. Check that you are using the most > up-to-date CRAN release, and if not then try updating. THe bug was fixed on 2 Apr, 2012, in svn r1894, which is *after* the last CRAN release. You should use the R-Forge version, currently here: install.packages("PerformanceAnalytics", repos= c("http://R-Forge.R-project.org", getOption("repos"))) (assuming that the R-Forge build process hasn't failed, as it often seems to) Regards, - Brian -- Brian G. Peterson http://braverock.com/brian/ Ph: 773-459-4973 IM: bgpbraverock _______________________________________________ [hidden email] 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. This e-mail and its attachments are intended only for the individual or entity to whom it is addressed and may contain information that is confidential, privileged, inside information, or subject to other restrictions on use or disclosure. If you have received this transmission in error, please notify the sender immediately by return e-mail, and permanently delete or destroy this e-mail, any attachments, and all copies. Any unauthorized use, dissemination or copying of this transmission or the information may be unlawful. This message is provided for informational purposes and should not be construed as an invitation or offer to buy or sell any securities or related financial instruments. _______________________________________________ [hidden email] 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. |
| Powered by Nabble | Edit this page |
