Hello, Do any of you know whether there exists a function that I can use to produce a cumulative return time series of an xts object (stock price). I have created my own code to do this but I was wondering if there already exists a function that does what I want as I would like the resulting object to remain as a XTS object so I can plot various studies on the same chart. I have attached an image of a chart that shows the cumulative return time series of an ETF and its components. http://r.789695.n4.nabble.com/file/n3520559/Screen_shot_2011-05-13_at_11.31.53_AM.png Screen_shot_2011-05-13_at_11.31.53_AM.png I looked through the 'TTR' package and found very useful functions that compute running/window SDs, Means, Cov etc... but was wondering if there is something similar for cumulative returns. -- View this message in context: http://r.789695.n4.nabble.com/is-there-a-function-that-will-compute-a-cumulative-return-times-series-tp3520559p3520559.html Sent from the Rmetrics mailing list archive at Nabble.com.
is there a function that will compute a cumulative return times series
6 messages · G See, Brian G. Peterson, S
An embedded and charset-unspecified text was scrubbed... Name: not available URL: <https://stat.ethz.ch/pipermail/r-sig-finance/attachments/20110513/1230e10b/attachment.pl>
Thanks you. I will give that a try. Another gentleman also informed me that I could use cumsum() of returns. Thank you all.
On 5/13/11 12:18 PM, G See wrote:
Maybe you want to see the PerfomanceAnalytics package?
Or, maybe you're just looking for cumprod?
library(quantmod)
getSymbols('SPY')
ret <- dailyReturn(SPY)
cumret <- cumprod(1+ret)
str(cumret)
On Fri, May 13, 2011 at 10:54 AM, algotr8der <algotr8der at gmail.com> wrote:
Hello, Do any of you know whether there exists a function that I can use to produce a cumulative return time series of an xts object (stock price). I have created my own code to do this but I was wondering if there already exists a function that does what I want as I would like the resulting object to remain as a XTS object so I can plot various studies on the same chart. I have attached an image of a chart that shows the cumulative return time series of an ETF and its components. http://r.789695.n4.nabble.com/file/n3520559/Screen_shot_2011-05-13_at_11.31.53_AM.png Screen_shot_2011-05-13_at_11.31.53_AM.png I looked through the 'TTR' package and found very useful functions that compute running/window SDs, Means, Cov etc... but was wondering if there is something similar for cumulative returns. -- View this message in context: http://r.789695.n4.nabble.com/is-there-a-function-that-will-compute-a-cumulative-return-times-series-tp3520559p3520559.html Sent from the Rmetrics mailing list archive at Nabble.com.
_______________________________________________ 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.
Package PerformanceAnalytics will do this for you. ?Return.calculate ?charts.PerformanceSummary ?chart.CumReturns for starters. Regards, - Brian
On Fri, 2011-05-13 at 08:54 -0700, algotr8der wrote:
Hello, Do any of you know whether there exists a function that I can use to produce a cumulative return time series of an xts object (stock price). I have created my own code to do this but I was wondering if there already exists a function that does what I want as I would like the resulting object to remain as a XTS object so I can plot various studies on the same chart. I have attached an image of a chart that shows the cumulative return time series of an ETF and its components. http://r.789695.n4.nabble.com/file/n3520559/Screen_shot_2011-05-13_at_11.31.53_AM.png Screen_shot_2011-05-13_at_11.31.53_AM.png I looked through the 'TTR' package and found very useful functions that compute running/window SDs, Means, Cov etc... but was wondering if there is something similar for cumulative returns. -- View this message in context: http://r.789695.n4.nabble.com/is-there-a-function-that-will-compute-a-cumulative-return-times-series-tp3520559p3520559.html Sent from the Rmetrics mailing list archive at Nabble.com.
_______________________________________________ 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.
Brian G. Peterson http://braverock.com/brian/ Ph: 773-459-4973 IM: bgpbraverock
On 5/13/11 12:23 PM, Brian G. Peterson wrote:
Package PerformanceAnalytics will do this for you. ?Return.calculate ?charts.PerformanceSummary ?chart.CumReturns
This is great. Thank you Brian. I tried a suggestion from another gentlemen who indicated I could use the cumsum() function. I will try out the functions in PerformanceAnalytics now.
for starters. Regards, - Brian On Fri, 2011-05-13 at 08:54 -0700, algotr8der wrote:
Hello, Do any of you know whether there exists a function that I can use to produce a cumulative return time series of an xts object (stock price). I have created my own code to do this but I was wondering if there already exists a function that does what I want as I would like the resulting object to remain as a XTS object so I can plot various studies on the same chart. I have attached an image of a chart that shows the cumulative return time series of an ETF and its components. http://r.789695.n4.nabble.com/file/n3520559/Screen_shot_2011-05-13_at_11.31.53_AM.png Screen_shot_2011-05-13_at_11.31.53_AM.png I looked through the 'TTR' package and found very useful functions that compute running/window SDs, Means, Cov etc... but was wondering if there is something similar for cumulative returns. -- View this message in context: http://r.789695.n4.nabble.com/is-there-a-function-that-will-compute-a-cumulative-return-times-series-tp3520559p3520559.html Sent from the Rmetrics mailing list archive at Nabble.com.
_______________________________________________ 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.
An embedded and charset-unspecified text was scrubbed... Name: not available URL: <https://stat.ethz.ch/pipermail/r-sig-finance/attachments/20110513/cbe187b8/attachment.pl>