# Commands that generated the results of Section 2.5 of # "The Portfolio Probe User's Manual" # # These commands demonstrate testing a trading strategy # using random portfolios # # This depends on functions listed in 'pprobe_functions01.R' # The data are created in 'pprobe_R_data01.txt' # # The functions that create the graphs are in 'pprobe_graphFun01.R' # If you want hardcopies of the graphs, then you need to start a # graphics device (like 'pdf') and do 'dev.off()' after the graphs # are created. # things to CHANGE, possibly PP_LOC <- ".." # initial setup if(!exists("us.pricemat")) attach(paste(PP_LOC, "us.pricemat.rda", sep="/")) if(!exists("us.macdmat")) attach(paste(PP_LOC, "us.macdmat.rda", sep="/")) # These optimizations do not involve a variance (for simplicity) # Real optimizations almost certainly will, see the file # 'pprobe_R_varCache.txt' for a method of dealing with # large variance matrices # generate set of starting portfolios rp.20.w10.2008 <- random.portfolio(20, us.pricemat[502,], gross.value=1e7, long.only=TRUE, max.weight=.1, port.size=20) # do evaluation of the strategy evalst.20.w10.t200.2008 <- pp.evalstrat(100, rp.20.w10.2008, us.pricemat[-1:-502,], us.macdmat, frac.turnover=2/252, max.weight=.1, port.size=20, verbose=2, do.warn=c(utility.switch=FALSE, novariance=FALSE)) # do plots P.evst1Q(NULL) P.evst2Q(NULL) P.evst4Q(NULL)