[Blotter-commits] r729 - pkg/quantstrat/demo

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Fri Aug 12 22:22:58 CEST 2011


Author: cyrforge
Date: 2011-08-12 22:22:58 +0200 (Fri, 12 Aug 2011)
New Revision: 729

Modified:
   pkg/quantstrat/demo/parameterTestMACD.R
Log:
Some miner changes on demo.

Modified: pkg/quantstrat/demo/parameterTestMACD.R
===================================================================
--- pkg/quantstrat/demo/parameterTestMACD.R	2011-08-12 01:46:57 UTC (rev 728)
+++ pkg/quantstrat/demo/parameterTestMACD.R	2011-08-12 20:22:58 UTC (rev 729)
@@ -8,21 +8,26 @@
 workers <- startWorkers(2)
 registerDoSMP(workers)
 
-
-source("D:\\Documents\\GoogleCode\\Workspace\\quantstrat\\R\\parameters.R")
-
 #please run macd demo before all these...
 paramStructure<-getParameterTable(stratMACD)
 
-tPD2<-setParameterDistribution() 
-tPD2
+rm(tPD2)
 
+
 # Just provide leagal values and use random sampling.
-tPD2<-setParameterDistribution(tPD2,'indicator',indexnum=1,distribution=list(nFast=(10:30)),label='nFast')
-#make them over lap from 20 to 30 to test.
-tPD2<-setParameterDistribution(tPD2,'indicator',indexnum=1,distribution=list(nSlow=(20:40)),label='nSlow')
-tPD2<-setParameterDistribution(tPD2,'signal',indexnum=1,distribution=list(relationship=c('gt','gte')),label='sig1.gtgte')
+# Make nFast and nSlow over lap from 20 to 30 to test the constrains later.
+# First call don't need to input tPD2, the funciton will initial one and return it.
 
+tPD2<-setParameterDistribution(type='indicator',indexnum=1,distribution=list(nFast=(10:30)),label='nFast')
+
+# Initial one tPD2 and pass it also works as following two lines:
+## tPD2<-setParameterDistribution() 
+## tPD2<-setParameterDistribution(type='indicator',indexnum=1,distribution=list(nFast=(10:30)),label='nFast')
+
+tPD2<-setParameterDistribution(tPD2,type='indicator',indexnum=1,distribution=list(nSlow=(20:40)),label='nSlow')
+tPD2<-setParameterDistribution(tPD2,type='signal',indexnum=1,distribution=list(relationship=c('gt','gte')),label='sig1.gtgte')
+
+# Put constrains to the nFast and nSlow parameters.
 pConstraint2<-setParameterConstraint(constraintLabel='macdPC',paramList=c('nFast','nSlow'),relationship='lt')
 
 
@@ -31,10 +36,17 @@
 #system.time(testPackList2<-applyParameter(strategy=stratMACD,portfolios=portfolio.st,parameterPool=tPD2,method='random',sampleSize=3,parameterConstrains=pConstraint2))
 
 
-laststpar<-system.time(
-		testPackListPL<-applyParameter(strategy=stratMACD,portfolios=portfolio.st,parameterPool=tPD2,method='random',sampleSize=10,parameterConstrains=pConstraint2)
+laststpar.rnd<-system.time(
+		testPackListPL<-applyParameter(strategy=stratMACD,portfolios=portfolio.st,parameterPool=tPD2,method='random',sampleSize=20,parameterConstrains=pConstraint2)
 )
-laststpar
+laststpar.rnd
+
+# Please run either random mode or expand mode, since the latter run will overwrite the objects in .blotter.
+#laststpar.exp<-system.time(
+#		testPackListPL<-applyParameter(strategy=stratMACD,portfolios=portfolio.st,parameterPool=tPD2,method='random',sampleSize=20,parameterConstrains=pConstraint2)
+#)
+#laststpar.exp
+
 #
 #stopWorkers(workers)
 #rmSessions(all=TRUE)



More information about the Blotter-commits mailing list