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

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Wed Jun 29 22:23:11 CEST 2011


Author: cyrforge
Date: 2011-06-29 22:23:11 +0200 (Wed, 29 Jun 2011)
New Revision: 653

Added:
   pkg/quantstrat/demo/parameterTest.R
Log:
Demo for parameter generating and testing, run after bbands demo

Added: pkg/quantstrat/demo/parameterTest.R
===================================================================
--- pkg/quantstrat/demo/parameterTest.R	                        (rev 0)
+++ pkg/quantstrat/demo/parameterTest.R	2011-06-29 20:23:11 UTC (rev 653)
@@ -0,0 +1,36 @@
+# TODO: Add comment
+# 
+# Author: Yu Chen
+###############################################################################
+
+
+
+#please run bbands demo before all these...
+
+tPD<-setParameterDistribution() 
+
+#Do expand test
+#tPD<-setParameterDistribution(tPD,'indicator',indexnum=1,distribution=list(sd=(1:3)))
+#tPD<-setParameterDistribution(tPD,'signal',indexnum=2,distribution=list(sd=sample(1:10, size=1, replace=FALSE)))
+#tPD<-setParameterDistribution(tPD,'signal',indexnum=3,distribution=list(n=sample(1:10, size=1, replace=FALSE)))
+#
+##update the 3rd slot by using psindex
+#tPD<-setParameterDistribution(tPD,'signal',indexnum=2,distribution=list(n=c(20,30)),psindex=3)
+#testPackList<-applyParameter(strategy=stratBBands,portfolios='bbands',parameterPool=tPD,method='expand')
+
+
+
+
+tPD
+#debug(applyParameter)
+#undebug(applyParameter)
+
+
+# Just provide leagal values and use random sampling.
+tPD<-setParameterDistribution(tPD,'indicator',indexnum=1,distribution=list(sd=(1:3)),weight=c(.25,.25,.5))
+tPD<-setParameterDistribution(tPD,'signal',indexnum=2,distribution=list(sd=1:10),weight=1:10)
+tPD<-setParameterDistribution(tPD,'signal',indexnum=3,distribution=list(n=20:30))
+
+testPackList<-applyParameter(strategy=stratBBands,portfolios='bbands',parameterPool=tPD,method='random',sampleSize=5)
+
+



More information about the Blotter-commits mailing list