SCM

SCM Repository

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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 776 - (view) (download)
Original Path: pkg/quantstrat/demo/parameterTestMACD.R

1 : cyrforge 663 # TODO: Add comment
2 :     #
3 :     # Author: CCD
4 :     ###############################################################################
5 :    
6 : cyrforge 692 require(foreach)
7 :     require(doSMP)
8 :     workers <- startWorkers(2)
9 :     registerDoSMP(workers)
10 :    
11 : cyrforge 663 #please run macd demo before all these...
12 :     paramStructure<-getParameterTable(stratMACD)
13 :    
14 : cyrforge 729 rm(tPD2)
15 : cyrforge 663
16 : cyrforge 729
17 : cyrforge 663 # Just provide leagal values and use random sampling.
18 : cyrforge 729 # Make nFast and nSlow over lap from 20 to 30 to test the constrains later.
19 :     # First call don't need to input tPD2, the funciton will initial one and return it.
20 : cyrforge 663
21 : cyrforge 729 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 : cyrforge 663 pConstraint2<-setParameterConstraint(constraintLabel='macdPC',paramList=c('nFast','nSlow'),relationship='lt')
32 :    
33 :    
34 :    
35 : cyrforge 687 #testPackList2<-applyParameter(strategy=stratMACD,portfolios=portfolio.st,parameterPool=tPD2,method='random',sampleSize=3,parameterConstrains=pConstraint2)
36 :     #system.time(testPackList2<-applyParameter(strategy=stratMACD,portfolios=portfolio.st,parameterPool=tPD2,method='random',sampleSize=3,parameterConstrains=pConstraint2))
37 :    
38 :    
39 : cyrforge 729 laststpar.rnd<-system.time(
40 : gsee 776 testPackListPL<-applyParameter(strategy=stratMACD,portfolios=portfolio.st,parameterPool=tPD2,method='random',sampleSize=20,parameterConstraints=pConstraint2)
41 : cyrforge 692 )
42 : cyrforge 729 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 : cyrforge 687 #
51 :     #stopWorkers(workers)
52 :     #rmSessions(all=TRUE)
53 :    
54 :    
55 :    
56 :    
57 :    

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