SCM

SCM Repository

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

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

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

pkg/quantstrat/demo/parameterTestMACD.R revision 729, Fri Aug 12 20:22:58 2011 UTC pkg/quantstrat/demo/macdParameters.R revision 1370, Thu Jan 17 20:58:10 2013 UTC
# Line 1  Line 1 
1  # TODO: Add comment  # Parameter demo for MACD demo
2  #  #
3  # Author: CCD  # Author: Yu Chen
4  ###############################################################################  ###############################################################################
5    
6  require(foreach)  require(foreach,quietly=TRUE)
7  require(doSMP)  require(quantstrat)
8  workers <- startWorkers(2)  
9  registerDoSMP(workers)  demo('macd',ask=FALSE)
10    
11    # example parallel initialization for doParallel. this or doMC, or doRedis are
12    # most probably preferable to doSMP
13    #require(doParallel)
14    #registerDoParallel() # by default number of physical cores -1
15    
16    
17  #please run macd demo before all these...  #please run macd demo before all these...
18    
19    #retrieve the strategy from the environment, since the 'macd' strategy uses store=TRUE
20    stratMACD<-getStrategy('macd')
21    
22  paramStructure<-getParameterTable(stratMACD)  paramStructure<-getParameterTable(stratMACD)
23    
24  rm(tPD2)  rm(tPD2)
# Line 37  Line 47 
47    
48    
49  laststpar.rnd<-system.time(  laststpar.rnd<-system.time(
50                  testPackListPL<-applyParameter(strategy=stratMACD,portfolios=portfolio.st,parameterPool=tPD2,method='random',sampleSize=20,parameterConstrains=pConstraint2)                  testPackListPL<-applyParameter(strategy=stratMACD,portfolios=portfolio.st,parameterPool=tPD2,method='random',sampleSize=20,parameterConstraints=pConstraint2)
51  )  )
52  laststpar.rnd  #laststpar.rnd
53    
54  # Please run either random mode or expand mode, since the latter run will overwrite the objects in .blotter.  # Please run either random mode or expand mode, since the latter run will overwrite the objects in .blotter.
55  #laststpar.exp<-system.time(  #laststpar.exp<-system.time(
56  #               testPackListPL<-applyParameter(strategy=stratMACD,portfolios=portfolio.st,parameterPool=tPD2,method='random',sampleSize=20,parameterConstrains=pConstraint2)  #               testPackListPL<-applyParameter(strategy=stratMACD,portfolios=portfolio.st,parameterPool=tPD2,method='random',sampleSize=20,parameterConstrains=pConstraint2)
57  #)  #)
58  #laststpar.exp  if(verbose >=1) print(laststpar.exp)
   
 #  
 #stopWorkers(workers)  
 #rmSessions(all=TRUE)  
   
   
   
59    
60    #examine the stats from this parameter run:
61    if(verbose >=1) print(testPackListPL$statsTable)
62    
63    ##### PLACE THIS BLOCK AHEAD OF DATE INITS IN DEMO SCRIPT ######
64    # if(!exists('in_test') || !isTRUE(in_test)){
65    #     initDate='2005-12-31' # ensure this is demo default
66    #     endDate=Sys.Date()    # ensure this is demo default
67    # }
68    ################################################################
69    
70    ##### PLACE THIS BLOCK AT END OF DEMO SCRIPT ###################
71    # book  = getOrderBook(port)
72    # stats = tradeStats(port)
73    # rets  = PortfReturns(acct)
74    ################################################################

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

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