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

revision 692, Thu Jul 21 23:00:07 2011 UTC revision 729, Fri Aug 12 20:22:58 2011 UTC
# Line 8  Line 8 
8  workers <- startWorkers(2)  workers <- startWorkers(2)
9  registerDoSMP(workers)  registerDoSMP(workers)
10    
   
 source("D:\\Documents\\GoogleCode\\Workspace\\quantstrat\\R\\parameters.R")  
   
11  #please run macd demo before all these...  #please run macd demo before all these...
12  paramStructure<-getParameterTable(stratMACD)  paramStructure<-getParameterTable(stratMACD)
13    
14  tPD2<-setParameterDistribution()  rm(tPD2)
15  tPD2  
16    
17  # Just provide leagal values and use random sampling.  # Just provide leagal values and use random sampling.
18  tPD2<-setParameterDistribution(tPD2,'indicator',indexnum=1,distribution=list(nFast=(10:30)),label='nFast')  # Make nFast and nSlow over lap from 20 to 30 to test the constrains later.
19  #make them over lap from 20 to 30 to test.  # First call don't need to input tPD2, the funciton will initial one and return it.
20  tPD2<-setParameterDistribution(tPD2,'indicator',indexnum=1,distribution=list(nSlow=(20:40)),label='nSlow')  
21  tPD2<-setParameterDistribution(tPD2,'signal',indexnum=1,distribution=list(relationship=c('gt','gte')),label='sig1.gtgte')  tPD2<-setParameterDistribution(type='indicator',indexnum=1,distribution=list(nFast=(10:30)),label='nFast')
22    
23    # Initial one tPD2 and pass it also works as following two lines:
24    ## tPD2<-setParameterDistribution()
25    ## tPD2<-setParameterDistribution(type='indicator',indexnum=1,distribution=list(nFast=(10:30)),label='nFast')
26    
27    tPD2<-setParameterDistribution(tPD2,type='indicator',indexnum=1,distribution=list(nSlow=(20:40)),label='nSlow')
28    tPD2<-setParameterDistribution(tPD2,type='signal',indexnum=1,distribution=list(relationship=c('gt','gte')),label='sig1.gtgte')
29    
30    # Put constrains to the nFast and nSlow parameters.
31  pConstraint2<-setParameterConstraint(constraintLabel='macdPC',paramList=c('nFast','nSlow'),relationship='lt')  pConstraint2<-setParameterConstraint(constraintLabel='macdPC',paramList=c('nFast','nSlow'),relationship='lt')
32    
33    
# Line 31  Line 36 
36  #system.time(testPackList2<-applyParameter(strategy=stratMACD,portfolios=portfolio.st,parameterPool=tPD2,method='random',sampleSize=3,parameterConstrains=pConstraint2))  #system.time(testPackList2<-applyParameter(strategy=stratMACD,portfolios=portfolio.st,parameterPool=tPD2,method='random',sampleSize=3,parameterConstrains=pConstraint2))
37    
38    
39  laststpar<-system.time(  laststpar.rnd<-system.time(
40                  testPackListPL<-applyParameter(strategy=stratMACD,portfolios=portfolio.st,parameterPool=tPD2,method='random',sampleSize=10,parameterConstrains=pConstraint2)                  testPackListPL<-applyParameter(strategy=stratMACD,portfolios=portfolio.st,parameterPool=tPD2,method='random',sampleSize=20,parameterConstrains=pConstraint2)
41  )  )
42  laststpar  laststpar.rnd
43    
44    # Please run either random mode or expand mode, since the latter run will overwrite the objects in .blotter.
45    #laststpar.exp<-system.time(
46    #               testPackListPL<-applyParameter(strategy=stratMACD,portfolios=portfolio.st,parameterPool=tPD2,method='random',sampleSize=20,parameterConstrains=pConstraint2)
47    #)
48    #laststpar.exp
49    
50  #  #
51  #stopWorkers(workers)  #stopWorkers(workers)
52  #rmSessions(all=TRUE)  #rmSessions(all=TRUE)

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

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