[Blotter-commits] r1419 - pkg/quantstrat/demo

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Mon Apr 1 17:51:06 CEST 2013


Author: braverock
Date: 2013-04-01 17:51:06 +0200 (Mon, 01 Apr 2013)
New Revision: 1419

Modified:
   pkg/quantstrat/demo/maCross.R
Log:
- fix second SMA to use onlye the first Cl() column

Modified: pkg/quantstrat/demo/maCross.R
===================================================================
--- pkg/quantstrat/demo/maCross.R	2013-03-29 15:58:58 UTC (rev 1418)
+++ pkg/quantstrat/demo/maCross.R	2013-04-01 15:51:06 UTC (rev 1419)
@@ -22,14 +22,15 @@
 
 ##### PLACE DEMO AND TEST DATES HERE #################
 #
-#if(isTRUE(options('in_test')$in_test))
-#  # use test dates
-#  {initDate="2011-01-01" 
-#  endDate="2012-12-31"   
-#  } else
-#  # use demo defaults
-#  {initDate="1999-12-31"
-#  endDate=Sys.Date()}
+if(isTRUE(options('in_test')$in_test))
+  # use test dates
+  {initDate="2011-01-01" 
+  endDate="2012-12-31"   
+  } else {
+  # use demo defaults
+  initDate="1999-12-31"
+  endDate=Sys.Date()
+}
 
 initEq=1000000
 portfolio.st='macross'
@@ -41,7 +42,7 @@
 stratMACROSS<- strategy(portfolio.st)
 
 stratMACROSS <- add.indicator(strategy = stratMACROSS, name = "SMA", arguments = list(x=quote(Cl(mktdata)), n=50),label= "ma50" )
-stratMACROSS <- add.indicator(strategy = stratMACROSS, name = "SMA", arguments = list(x=quote(Cl(mktdata)), n=200),label= "ma200")
+stratMACROSS <- add.indicator(strategy = stratMACROSS, name = "SMA", arguments = list(x=quote(Cl(mktdata)[,1]), n=200),label= "ma200")
 
 stratMACROSS <- add.signal(strategy = stratMACROSS,name="sigCrossover",arguments = list(columns=c("ma50","ma200"), relationship="gte"),label="ma50.gt.ma200")
 stratMACROSS <- add.signal(strategy = stratMACROSS,name="sigCrossover",arguments = list(column=c("ma50","ma200"),relationship="lt"),label="ma50.lt.ma200")
@@ -59,7 +60,7 @@
   assign(i, adjustOHLC(get(i),use.Adjusted=TRUE))
 
 start_t<-Sys.time()
-out<-try(applyStrategy(strategy=stratMACROSS , portfolios=portfolio.st))
+out<-applyStrategy(strategy=stratMACROSS , portfolios=portfolio.st)
 end_t<-Sys.time()
 print(end_t-start_t)
 



More information about the Blotter-commits mailing list