[Blotter-commits] r371 - pkg/quantstrat/demo
noreply at r-forge.r-project.org
noreply at r-forge.r-project.org
Thu Aug 12 22:18:09 CEST 2010
Author: braverock
Date: 2010-08-12 22:18:09 +0200 (Thu, 12 Aug 2010)
New Revision: 371
Modified:
pkg/quantstrat/demo/bbands.R
pkg/quantstrat/demo/faber.R
pkg/quantstrat/demo/maCross.R
pkg/quantstrat/demo/macd.R
pkg/quantstrat/demo/rsi.R
Log:
- update demos
Modified: pkg/quantstrat/demo/bbands.R
===================================================================
--- pkg/quantstrat/demo/bbands.R 2010-08-12 13:52:05 UTC (rev 370)
+++ pkg/quantstrat/demo/bbands.R 2010-08-12 20:18:09 UTC (rev 371)
@@ -27,22 +27,22 @@
stratBBands <- strategy("bbands")
#one indicator
-stratBBands <- add.indicator(strategy = s, name = "BBands", arguments = list(HLC = quote(HLC(mktdata)), maType='SMA'))
+stratBBands <- add.indicator(strategy = stratBBands, name = "BBands", arguments = list(HLC = quote(HLC(mktdata)), maType='SMA'))
#add signals:
-stratBBands <- add.signal(s,name="sigCrossover",arguments = list(columns=c("Close","up"),relationship="gt"),label="Cl.gt.UpperBand")
-stratBBands <- add.signal(s,name="sigCrossover",arguments = list(columns=c("Close","dn"),relationship="lt"),label="Cl.lt.LowerBand")
-stratBBands <- add.signal(s,name="sigCrossover",arguments = list(columns=c("High","Low","mavg"),relationship="op"),label="Cross.Mid")
+stratBBands <- add.signal(stratBBands,name="sigCrossover",arguments = list(columns=c("Close","up"),relationship="gt"),label="Cl.gt.UpperBand")
+stratBBands <- add.signal(stratBBands,name="sigCrossover",arguments = list(columns=c("Close","dn"),relationship="lt"),label="Cl.lt.LowerBand")
+stratBBands <- add.signal(stratBBands,name="sigCrossover",arguments = list(columns=c("High","Low","mavg"),relationship="op"),label="Cross.Mid")
# lets add some rules
-stratBBands <- add.rule(s,name='ruleSignal', arguments = list(sigcol="Cl.gt.UpperBand",sigval=TRUE, orderqty=-100, ordertype='market', orderside=NULL, threshold=NULL),type='enter')
-stratBBands <- add.rule(s,name='ruleSignal', arguments = list(sigcol="Cl.lt.LowerBand",sigval=TRUE, orderqty= 100, ordertype='market', orderside=NULL, threshold=NULL),type='enter')
-stratBBands <- add.rule(s,name='ruleSignal', arguments = list(sigcol="Cross.Mid",sigval=TRUE, orderqty= 'all', ordertype='market', orderside=NULL, threshold=NULL),type='exit')
+stratBBands <- add.rule(stratBBands,name='ruleSignal', arguments = list(sigcol="Cl.gt.UpperBand",sigval=TRUE, orderqty=-100, ordertype='market', orderside=NULL, threshold=NULL),type='enter')
+stratBBands <- add.rule(stratBBands,name='ruleSignal', arguments = list(sigcol="Cl.lt.LowerBand",sigval=TRUE, orderqty= 100, ordertype='market', orderside=NULL, threshold=NULL),type='enter')
+stratBBands <- add.rule(stratBBands,name='ruleSignal', arguments = list(sigcol="Cross.Mid",sigval=TRUE, orderqty= 'all', ordertype='market', orderside=NULL, threshold=NULL),type='exit')
#alternately, to exit at the opposite band, the rules would be...
-#stratBBands <- add.rule(s,name='ruleSignal', arguments = list(data=quote(mktdata),sigcol="Lo.gt.UpperBand",sigval=TRUE, orderqty= 'all', ordertype='market', orderside=NULL, threshold=NULL),type='exit')
-#stratBBands <- add.rule(s,name='ruleSignal', arguments = list(data=quote(mktdata),sigcol="Hi.lt.LowerBand",sigval=TRUE, orderqty= 'all', ordertype='market', orderside=NULL, threshold=NULL),type='exit')
+#stratBBands <- add.rule(stratBBands,name='ruleSignal', arguments = list(data=quote(mktdata),sigcol="Lo.gt.UpperBand",sigval=TRUE, orderqty= 'all', ordertype='market', orderside=NULL, threshold=NULL),type='exit')
+#stratBBands <- add.rule(stratBBands,name='ruleSignal', arguments = list(data=quote(mktdata),sigcol="Hi.lt.LowerBand",sigval=TRUE, orderqty= 'all', ordertype='market', orderside=NULL, threshold=NULL),type='exit')
#TODO add thresholds and stop-entry and stop-exit handling to test
Modified: pkg/quantstrat/demo/faber.R
===================================================================
--- pkg/quantstrat/demo/faber.R 2010-08-12 13:52:05 UTC (rev 370)
+++ pkg/quantstrat/demo/faber.R 2010-08-12 20:18:09 UTC (rev 371)
@@ -85,19 +85,19 @@
stratFaber <- strategy("faber")
# Add an indicator
-stratFaber <- add.indicator(strategy = s, name = "SMA", arguments = list(x = quote(Cl(mktdata)), n=10), label="SMA10")
+stratFaber <- add.indicator(strategy = stratFaber, name = "SMA", arguments = list(x = quote(Cl(mktdata)), n=10), label="SMA10")
# There are two signals:
# The first is when monthly price crosses over the 10-month SMA
-stratFaber <- add.signal(s,name="sigCrossover",arguments = list(columns=c("Close","SMA10"),relationship="gt"),label="Cl.gt.SMA")
+stratFaber <- add.signal(stratFaber,name="sigCrossover",arguments = list(columns=c("Close","SMA10"),relationship="gt"),label="Cl.gt.SMA")
# The second is when the monthly price crosses under the 10-month SMA
-stratFaber <- add.signal(s,name="sigCrossover",arguments = list(columns=c("Close","SMA10"),relationship="lt"),label="Cl.lt.SMA")
+stratFaber <- add.signal(stratFaber,name="sigCrossover",arguments = list(columns=c("Close","SMA10"),relationship="lt"),label="Cl.lt.SMA")
# There are two rules:
# The first is to buy when the price crosses above the SMA
-stratFaber <- add.rule(s, name='ruleSignal', arguments = list(sigcol="Cl.gt.SMA", sigval=TRUE, orderqty=1000, ordertype='market', orderside='long', pricemethod='market'), type='enter', path.dep=TRUE)
+stratFaber <- add.rule(stratFaber, name='ruleSignal', arguments = list(sigcol="Cl.gt.SMA", sigval=TRUE, orderqty=1000, ordertype='market', orderside='long', pricemethod='market'), type='enter', path.dep=TRUE)
# The second is to sell when the price crosses below the SMA
-stratFaber <- add.rule(s, name='ruleSignal', arguments = list(sigcol="Cl.lt.SMA", sigval=TRUE, orderqty='all', ordertype='market', orderside='long', pricemethod='market'), type='exit', path.dep=TRUE)
+stratFaber <- add.rule(stratFaber, name='ruleSignal', arguments = list(sigcol="Cl.lt.SMA", sigval=TRUE, orderqty='all', ordertype='market', orderside='long', pricemethod='market'), type='exit', path.dep=TRUE)
# Process the indicators and generate trades
start_t<-Sys.time()
Modified: pkg/quantstrat/demo/maCross.R
===================================================================
--- pkg/quantstrat/demo/maCross.R 2010-08-12 13:52:05 UTC (rev 370)
+++ pkg/quantstrat/demo/maCross.R 2010-08-12 20:18:09 UTC (rev 371)
@@ -54,6 +54,6 @@
# This library is distributed under the terms of the GNU Public License (GPL)
# for full details see the file COPYING
#
-# $Id: faber.R 369 2010-08-12 11:44:00Z braverock $
+# $Id$
#
###############################################################################
\ No newline at end of file
Property changes on: pkg/quantstrat/demo/maCross.R
___________________________________________________________________
Added: svn:keywords
+ Revision Id Date Author
Modified: pkg/quantstrat/demo/macd.R
===================================================================
--- pkg/quantstrat/demo/macd.R 2010-08-12 13:52:05 UTC (rev 370)
+++ pkg/quantstrat/demo/macd.R 2010-08-12 20:18:09 UTC (rev 371)
@@ -65,6 +65,6 @@
# This library is distributed under the terms of the GNU Public License (GPL)
# for full details see the file COPYING
#
-# $Id: faber.R 369 2010-08-12 11:44:00Z braverock $
+# $Id$
#
##############################################################################
\ No newline at end of file
Property changes on: pkg/quantstrat/demo/macd.R
___________________________________________________________________
Added: svn:keywords
+ Revision Id Date Author
Modified: pkg/quantstrat/demo/rsi.R
===================================================================
--- pkg/quantstrat/demo/rsi.R 2010-08-12 13:52:05 UTC (rev 370)
+++ pkg/quantstrat/demo/rsi.R 2010-08-12 20:18:09 UTC (rev 371)
@@ -84,6 +84,6 @@
# This library is distributed under the terms of the GNU Public License (GPL)
# for full details see the file COPYING
#
-# $Id: faber.R 369 2010-08-12 11:44:00Z braverock $
+# $Id$
#
###############################################################################
\ No newline at end of file
Property changes on: pkg/quantstrat/demo/rsi.R
___________________________________________________________________
Added: svn:keywords
+ Revision Id Date Author
More information about the Blotter-commits
mailing list