SCM

SCM Repository

[blotter] Diff of /pkg/quantstrat/demo/faber.R
ViewVC logotype

Diff of /pkg/quantstrat/demo/faber.R

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1370, Thu Jan 17 20:58:10 2013 UTC revision 1416, Fri Mar 29 15:40:50 2013 UTC
# Line 51  Line 51 
51              "GSPC", "stratFaber", "initDate", "initEq", "Posn", "UnitSize", "verbose"))              "GSPC", "stratFaber", "initDate", "initEq", "Posn", "UnitSize", "verbose"))
52  suppressWarnings(rm("order_book.faber",pos=.strategy))  suppressWarnings(rm("order_book.faber",pos=.strategy))
53    
54  ##### PLACE THIS BLOCK AHEAD OF DATE INITS IN DEMO SCRIPT ######  ##### PLACE DEMO AND TEST DATES HERE #################
55  # if(!exists('in_test') || !isTRUE(in_test)){  #
56  #     initDate='2005-12-31' # ensure this is demo default  #if(isTRUE(options('in_test')$in_test))
57  #     endDate=Sys.Date()    # ensure this is demo default  #  # use test dates
58  # }  #  {initDate="2011-01-01"
59  ################################################################  #  endDate="2012-12-31"
60    #  } else
61    #  # use demo defaults
62    #  {initDate="1999-12-31"
63    #  endDate=Sys.Date()}
64    
65  # Set initial values  # Set initial values
66  initDate='1997-12-31'  initDate='1997-12-31'
# Line 136  Line 140 
140  }  }
141    
142  ret1 <- PortfReturns('faber')  ret1 <- PortfReturns('faber')
143  ret1$total<-rowSums(ret1)  View(ret1)
 ret1  
144    
145  if("package:PerformanceAnalytics" %in% search() || require("PerformanceAnalytics",quietly=TRUE)){  if("package:PerformanceAnalytics" %in% search() || require("PerformanceAnalytics",quietly=TRUE)){
146          getSymbols("SPY", src='yahoo', index.class=c("POSIXt","POSIXct"), from='1999-01-01')          getSymbols("SPY", src='yahoo', index.class=c("POSIXt","POSIXct"), from='1999-01-01')
147          SPY<-to.monthly(SPY)          SPY<-to.monthly(SPY)
148          SPY.ret<-Return.calculate(SPY$SPY.Close)          SPY.ret<-Return.calculate(SPY$SPY.Close)
149          index(SPY.ret)<-index(ret1)          index(SPY.ret)<-c(as.Date('1999-01-01'),index(ret1))
150          dev.new()          dev.new()
151          charts.PerformanceSummary(cbind(ret1$total,SPY.ret), geometric=FALSE, wealth.index=TRUE)          charts.PerformanceSummary(cbind(ret1$total,SPY.ret), geometric=FALSE, wealth.index=TRUE)
152  }  }

Legend:
Removed from v.1370  
changed lines
  Added in v.1416

root@r-forge.r-project.org
ViewVC Help
Powered by ViewVC 1.0.0  
Thanks to:
Vienna University of Economics and Business Powered By FusionForge