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

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Fri Jun 10 01:18:04 CEST 2011


Author: gsee
Date: 2011-06-10 01:18:04 +0200 (Fri, 10 Jun 2011)
New Revision: 621

Modified:
   pkg/quantstrat/demo/bbands.R
   pkg/quantstrat/demo/faber.R
   pkg/quantstrat/demo/faberMC.R
   pkg/quantstrat/demo/maCross.R
   pkg/quantstrat/demo/macd.R
   pkg/quantstrat/demo/pair_trade.R
   pkg/quantstrat/demo/rsi.R
Log:
-Replaced try rm with suppressWarnings in demo cleanup. No more warnings in demos!!! :)
-Corrected yahoo ticker for S&P 500 in faberMC


Modified: pkg/quantstrat/demo/bbands.R
===================================================================
--- pkg/quantstrat/demo/bbands.R	2011-06-09 23:15:14 UTC (rev 620)
+++ pkg/quantstrat/demo/bbands.R	2011-06-09 23:18:04 UTC (rev 621)
@@ -1,7 +1,7 @@
 require(quantstrat)
-try(rm("order_book.bbands",pos=.strategy),silent=TRUE)
-try(rm("account.bbands","portfolio.bbands",pos=.blotter),silent=TRUE)
-try(rm("account.st","portfolio.st","stock.str","stratBBands","initDate","initEq",'start_t','end_t'),silent=TRUE)
+suppressWarnings(rm("order_book.bbands",pos=.strategy))
+suppressWarnings(rm("account.bbands","portfolio.bbands",pos=.blotter))
+suppressWarnings(rm("account.st","portfolio.st","stock.str","stratBBands","initDate","initEq",'start_t','end_t'))
 
 # some things to set up here
 stock.str='IBM' # what are we trying it on

Modified: pkg/quantstrat/demo/faber.R
===================================================================
--- pkg/quantstrat/demo/faber.R	2011-06-09 23:15:14 UTC (rev 620)
+++ pkg/quantstrat/demo/faber.R	2011-06-09 23:18:04 UTC (rev 621)
@@ -46,9 +46,10 @@
 require(quantstrat)
 
 # Try to clean up in case the demo was run previously
-try(rm("account.faber","portfolio.faber",pos=.blotter),silent=TRUE)
-try(rm("ltaccount","ltportfolio","ClosePrice","CurrentDate","equity","GSPC","stratFaber","initDate","initEq","Posn","UnitSize","verbose"),silent=TRUE)
-try(rm("order_book.faber",pos=.strategy),silent=TRUE)
+suppressWarnings(rm("account.faber","portfolio.faber",pos=.blotter))
+suppressWarnings(rm("ltaccount", "ltportfolio", "ClosePrice", "CurrentDate", "equity", 
+            "GSPC", "stratFaber", "initDate", "initEq", "Posn", "UnitSize", "verbose"))
+suppressWarnings(rm("order_book.faber",pos=.strategy))
 
 # Set initial values
 initDate='1997-12-31'

Modified: pkg/quantstrat/demo/faberMC.R
===================================================================
--- pkg/quantstrat/demo/faberMC.R	2011-06-09 23:15:14 UTC (rev 620)
+++ pkg/quantstrat/demo/faberMC.R	2011-06-09 23:18:04 UTC (rev 621)
@@ -46,16 +46,17 @@
 require(quantstrat)
 
 # Try to clean up in case the demo was run previously
-try(rm("account.faber","portfolio.faber",pos=.blotter),silent=TRUE)
-try(rm("ltaccount","ltportfolio","ClosePrice","CurrentDate","equity","stratFaber","initDate","initEq","Posn","UnitSize","verbose"),silent=TRUE)
-try(rm("order_book.faber",pos=.strategy),silent=TRUE)
+suppressWarnings(rm("account.faber","account.faberMC","portfolio.faber","portfolio.combMC", 
+                        "portfolio.GDAXI", "portfolio.GSPC", "portfolio.N225",pos=.blotter))
+suppressWarnings(rm("ltaccount","ltportfolio","ClosePrice","CurrentDate","equity","stratFaber","initDate","initEq","Posn","UnitSize","verbose"))
+suppressWarnings(rm("order_book.faber","order_book.combMC", "order_book.GDAXI", "order_book.GSPC", "order_book.N225", pos=.strategy))
 
 # Set initial values
-initDate='2007-01-01'
+initDate='2000-01-01'
 initEq=100000
 
 # Set up instruments with FinancialInstruments package
-symbols = c("SPX", "^N225", "^GDAXI")
+symbols = c("^GSPC", "^N225", "^GDAXI")
 
 currency("USD")
 currency("JPY")
@@ -69,7 +70,7 @@
 
 getSymbols(symbols,from=initDate)
 #takes out the carat
-symbols = c("SPX", "N225", "GDAXI")
+symbols = c("GSPC", "N225", "GDAXI")
 
 
 stock(symbols[1], currency="USD",multiplier=1)
@@ -158,4 +159,4 @@
 #
 # $Id: faber.R 371 2010-08-12 20:18:09Z braverock $
 #
-###############################################################################
\ No newline at end of file
+###############################################################################

Modified: pkg/quantstrat/demo/maCross.R
===================================================================
--- pkg/quantstrat/demo/maCross.R	2011-06-09 23:15:14 UTC (rev 620)
+++ pkg/quantstrat/demo/maCross.R	2011-06-09 23:18:04 UTC (rev 621)
@@ -5,9 +5,9 @@
 #########################################################################################################################################################################
 
 require(quantstrat)
-try(rm("order_book.macross",pos=.strategy),silent=TRUE)
-try(rm("account.macross","portfolio.macross",pos=.blotter),silent=TRUE)
-try(rm("account.st","portfolio.st","stock.str","stratMACROSS","initDate","initEq",'start_t','end_t'),silent=TRUE)
+suppressWarnings(rm("order_book.macross",pos=.strategy))
+suppressWarnings(rm("account.macross","portfolio.macross",pos=.blotter))
+suppressWarnings(rm("account.st","portfolio.st","stock.str","stratMACROSS","initDate","initEq",'start_t','end_t'))
 stock.str='AAPL' # what are we trying it on
 currency('USD')
 stock(stock.str,currency='USD',multiplier=1)
@@ -24,7 +24,7 @@
 stratMACROSS <- add.indicator(strategy = stratMACROSS, name = "SMA", arguments = list(x=quote(Cl(mktdata)), n=50),label= "ma50" )
 stratMACROSS <- add.indicator(strategy = stratMACROSS, name = "SMA", arguments = list(x=quote(Cl(mktdata)), n=200),label= "ma200")
 
-stratMACROSS <- add.signal(strategy = stratMACROSS,name="sigCrossover",arguments = list(columns=c("ma50","ma200"),relationship="gt"),label="ma50.gt.ma200")
+stratMACROSS <- add.signal(strategy = stratMACROSS,name="sigCrossover",arguments = list(columns=c("ma50","ma200"), relationship="gt"),label="ma50.gt.ma200")
 stratMACROSS <- add.signal(strategy = stratMACROSS,name="sigCrossover",arguments = list(column=c("ma50","ma200"),relationship="lt"),label="ma50.lt.ma200")
 
 stratMACROSS <- add.rule(strategy = stratMACROSS,name='ruleSignal', arguments = list(sigcol="ma50.gt.ma200",sigval=TRUE, orderqty=100, ordertype='market', orderside='long'),type='enter')

Modified: pkg/quantstrat/demo/macd.R
===================================================================
--- pkg/quantstrat/demo/macd.R	2011-06-09 23:15:14 UTC (rev 620)
+++ pkg/quantstrat/demo/macd.R	2011-06-09 23:18:04 UTC (rev 621)
@@ -11,9 +11,9 @@
 
 
 require(quantstrat)
-try(rm("order_book.macd",pos=.strategy),silent=TRUE)
-try(rm("account.macd","portfolio.macd",pos=.blotter),silent=TRUE)
-try(rm("account.st","portfolio.st","stock.str","stratMACD","initDate","initEq",'start_t','end_t'),silent=TRUE)
+suppressWarnings(rm("order_book.macd",pos=.strategy))
+suppressWarnings(rm("account.macd","portfolio.macd",pos=.blotter))
+suppressWarnings(rm("account.st","portfolio.st","stock.str","stratMACD","initDate","initEq",'start_t','end_t'))
 
 stock.str='AAPL' # what are we trying it on
 
@@ -84,4 +84,4 @@
 #
 # $Id$
 #
-##############################################################################
\ No newline at end of file
+##############################################################################

Modified: pkg/quantstrat/demo/pair_trade.R
===================================================================
--- pkg/quantstrat/demo/pair_trade.R	2011-06-09 23:15:14 UTC (rev 620)
+++ pkg/quantstrat/demo/pair_trade.R	2011-06-09 23:18:04 UTC (rev 621)
@@ -17,10 +17,10 @@
 # The Qty of Stock A that it buys (sells) = MaxPos / lvls
 # The Qty of Stock B that is sells (buys) = MaxPos * Ratio / lvls  
 
-try(rm("order_book.pair1",pos=.strategy),silent=TRUE)
-try(rm("account.pairs", "portfolio.pair1", pos=.blotter), silent=TRUE)
-try(rm("initDate", "endDate", "startDate", "initEq", "SD", "N", "symb1", "symb2", 
-	"portfolio1.st", "account.st", "pairStrat", "out1"), silent=TRUE)
+suppressWarnings(rm("order_book.pair1",pos=.strategy))
+suppressWarnings(rm("account.pairs", "portfolio.pair1", pos=.blotter))
+suppressWarnings(rm("initDate", "endDate", "startDate", "initEq", "SD", "N", "symb1", "symb2", 
+	"portfolio1.st", "account.st", "pairStrat", "out1"))
 
 require(quantstrat)
 initDate = '2009-01-01'		

Modified: pkg/quantstrat/demo/rsi.R
===================================================================
--- pkg/quantstrat/demo/rsi.R	2011-06-09 23:15:14 UTC (rev 620)
+++ pkg/quantstrat/demo/rsi.R	2011-06-09 23:18:04 UTC (rev 621)
@@ -1,6 +1,6 @@
-try(rm("order_book.RSI",pos=.strategy),silent=TRUE)
-try(rm("account.RSI","portfolio.RSI",pos=.blotter),silent=TRUE)
-try(rm("account.st","portfolio.st","stock.str","stratRSI","initDate","initEq",'start_t','end_t'),silent=TRUE)
+suppressWarnings(rm("order_book.RSI",pos=.strategy))
+suppressWarnings(rm("account.RSI","portfolio.RSI",pos=.blotter))
+suppressWarnings(rm("account.st","portfolio.st","stock.str","stratRSI","initDate","initEq",'start_t','end_t'))
 
 # Initialize a strategy object
 stratRSI <- strategy("RSI")
@@ -90,4 +90,4 @@
 #
 # $Id$
 #
-###############################################################################
\ No newline at end of file
+###############################################################################



More information about the Blotter-commits mailing list