[Xts-commits] r864 - pkg/xtsExtra/sandbox

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Fri Dec 26 18:30:36 CET 2014


Author: rossbennett34
Date: 2014-12-26 18:30:36 +0100 (Fri, 26 Dec 2014)
New Revision: 864

Modified:
   pkg/xtsExtra/sandbox/paFUN.R
   pkg/xtsExtra/sandbox/test_plot2.R
Log:
fixing test script and function examples

Modified: pkg/xtsExtra/sandbox/paFUN.R
===================================================================
--- pkg/xtsExtra/sandbox/paFUN.R	2014-12-26 17:28:15 UTC (rev 863)
+++ pkg/xtsExtra/sandbox/paFUN.R	2014-12-26 17:30:36 UTC (rev 864)
@@ -7,24 +7,24 @@
     xsubset <- x$Env$xsubset
     colorset <- x$Env$theme$colorset
     # Add x-axis grid lines
-    atbt <- axTicksByTime2(xdata[xsubset])
+    atbt <- xtsExtra:::axTicksByTime2(xdata[xsubset])
     segments(x$Env$xycoords$x[atbt],
              par("usr")[3],
              x$Env$xycoords$x[atbt],
              par("usr")[4],
              col=x$Env$theme$grid)
     drawdowns <- PerformanceAnalytics:::Drawdowns(xdata, geometric)[xsubset]
-    chart.lines(drawdowns, type="l", colorset=colorset) 
+    xtsExtra:::chart.lines(drawdowns, type="l", colorset=colorset) 
   }
   mapply(function(name,value) { assign(name,value,envir=lenv) }, 
          names(list(geometric=geometric,...)),
          list(geometric=geometric,...))
   exp <- parse(text=gsub("list","plot_drawdowns",
-                         as.expression(substitute(list(x=current.xts_chob(),
+                         as.expression(substitute(list(x=xtsExtra:::current.xts_chob(),
                                                        geometric=geometric,...)))),
                srcfile=NULL)
   
-  plot_object <- current.xts_chob()
+  plot_object <- xtsExtra:::current.xts_chob()
   ncalls <- length(plot_object$Env$call_list)
   plot_object$Env$call_list[[ncalls+1]] <- match.call()
   
@@ -85,23 +85,23 @@
     up.col <- x$Env$theme$up.col
     dn.col <- x$Env$theme$dn.col
     # Add x-axis grid lines
-    atbt <- axTicksByTime2(xdata[xsubset])
+    atbt <- xtsExtra:::axTicksByTime2(xdata[xsubset])
     segments(x$Env$xycoords$x[atbt],
              par("usr")[3],
              x$Env$xycoords$x[atbt],
              par("usr")[4],
              col=x$Env$theme$grid)
-    chart.lines(xdata[xsubset], type=type, colorset=colorset, up.col=up.col, dn.col=dn.col)
+    xtsExtra:::chart.lines(xdata[xsubset], type=type, colorset=colorset, up.col=up.col, dn.col=dn.col)
   }
   mapply(function(name,value) { assign(name,value,envir=lenv) }, 
          names(list(type=type)),
          list(type=type))
   exp <- parse(text=gsub("list","plot_returns",
-                         as.expression(substitute(list(x=current.xts_chob(), 
+                         as.expression(substitute(list(x=xtsExtra:::current.xts_chob(), 
                                                        type=type)))),
                srcfile=NULL)
   
-  plot_object <- current.xts_chob()
+  plot_object <- xtsExtra:::current.xts_chob()
   ncalls <- length(plot_object$Env$call_list)
   plot_object$Env$call_list[[ncalls+1]] <- match.call()
   
@@ -167,23 +167,23 @@
     up.col <- x$Env$theme$up.col
     dn.col <- x$Env$theme$dn.col
     # Add x-axis grid lines
-    segments(axTicksByTime2(xdata[xsubset]),
+    segments(xtsExtra:::axTicksByTime2(xdata[xsubset]),
              par("usr")[3],
-             axTicksByTime2(xdata[xsubset]),
+             xtsExtra:::axTicksByTime2(xdata[xsubset]),
              par("usr")[4],
              col=x$Env$theme$grid)
     rolling_performance <- RollingPerformance(R=xdata, width=width, FUN=FUN, fill=fill, ...=...)
-    chart.lines(rolling_performance, type="l", colorset=colorset, up.col=up.col, dn.col=dn.col) 
+    xtsExtra:::chart.lines(rolling_performance, type="l", colorset=colorset, up.col=up.col, dn.col=dn.col) 
   }
   mapply(function(name,value) { assign(name,value,envir=lenv) }, 
          names(list(width=width, FUN=FUN, fill=fill, ...)),
          list(width=width, FUN=FUN, fill=fill, ...))
   exp <- parse(text=gsub("list","plot_performance",
-                         as.expression(substitute(list(x=current.xts_chob(),
+                         as.expression(substitute(list(x=xtsExtra:::current.xts_chob(),
                                                        width=width, FUN=FUN, fill=fill, ...)))),
                srcfile=NULL)
   
-  plot_object <- current.xts_chob()
+  plot_object <- xtsExtra:::current.xts_chob()
   ncalls <- length(plot_object$Env$call_list)
   plot_object$Env$call_list[[ncalls+1]] <- match.call()
   

Modified: pkg/xtsExtra/sandbox/test_plot2.R
===================================================================
--- pkg/xtsExtra/sandbox/test_plot2.R	2014-12-26 17:28:15 UTC (rev 863)
+++ pkg/xtsExtra/sandbox/test_plot2.R	2014-12-26 17:30:36 UTC (rev 864)
@@ -1,6 +1,6 @@
 library(xtsExtra)
 library(PerformanceAnalytics)
-library(quantmod)
+# library(quantmod)
 source("sandbox/paFUN.R")
 
 data(edhec)
@@ -137,21 +137,21 @@
 addSeries(tmp3, on=1, type="p", pch=2)
 
 
-stock.str='AAPL'
-initDate="2011-01-01" 
-endDate="2012-12-31"   
-getSymbols(stock.str,from=initDate,to=endDate, src="yahoo")
-plot(Ad(AAPL))
-addSeries(Ad(AAPL)["2012-05-28/"]-10, on=1, col = "red")
-xtsExtra::addLines(c("2011-11-04", "2012-11-10", "2012-05-28"), on=1)
-xtsExtra::addLines(c("2011-03-04", "2012-01-10", "2012-07-28"), on=1)
-xtsExtra::addLines(c("2011-11-04", "2012-11-10", "2012-05-28"))
+# stock.str='AAPL'
+# initDate="2011-01-01" 
+# endDate="2012-12-31"   
+# quantmod::getSymbols(stock.str,from=initDate,to=endDate, src="yahoo")
+# plot(Ad(AAPL))
+# addSeries(Ad(AAPL)["2012-05-28/"]-10, on=1, col = "red")
+# xtsExtra::addLines(c("2011-11-04", "2012-11-10", "2012-05-28"), on=1)
+# xtsExtra::addLines(c("2011-03-04", "2012-01-10", "2012-07-28"), on=1)
+# xtsExtra::addLines(c("2011-11-04", "2012-11-10", "2012-05-28"))
+# 
+# aapl <- Ad(AAPL)
+# plot(aapl)
+# aapl["2011-07/2012-07"] <- NA
+# plot(aapl)
 
-aapl <- Ad(AAPL)
-plot(aapl)
-aapl["2011-07/2012-07"] <- NA
-plot(aapl)
-
 # png("~/Documents/foo.png")
 # plot(R, FUN="CumReturns")
 # addDrawdowns()



More information about the Xts-commits mailing list