[Blotter-commits] r1292 - pkg/quantstrat/inst/tests

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Thu Dec 13 14:31:21 CET 2012


Author: milktrader
Date: 2012-12-13 14:31:21 +0100 (Thu, 13 Dec 2012)
New Revision: 1292

Removed:
   pkg/quantstrat/inst/tests/bbands_version_for_tests.R
   pkg/quantstrat/inst/tests/bbands_version_for_tests.r
   pkg/quantstrat/inst/tests/testthat_bbands.R
   pkg/quantstrat/inst/tests/testthat_bbands.r
   pkg/quantstrat/inst/tests/testthat_bee.R
Log:
cleanup .r and .R mess

Deleted: pkg/quantstrat/inst/tests/bbands_version_for_tests.R
===================================================================
--- pkg/quantstrat/inst/tests/bbands_version_for_tests.R	2012-12-13 13:04:22 UTC (rev 1291)
+++ pkg/quantstrat/inst/tests/bbands_version_for_tests.R	2012-12-13 13:31:21 UTC (rev 1292)
@@ -1,104 +0,0 @@
-#################### CLEANUP PREVIOUS TEST ######################
-
-# suppressWarnings(rm(list=ls(.strategy), pos=.strategy))
-# suppressWarnings(rm(list=ls(.blotter), pos=.blotter))
-# suppressWarnings(rm(list=ls()))
-
-################### LOAD QUANTSTRAT #################
-
-suppressMessages(require(quantstrat))
-
-###################### LOAD TTRC ######################
-
-data('ttrc')
-TTRC = xts(ttrc[,-1],ttrc[,1])
-TTRC = head(TTRC, n=500)
-
-###################### DEFINE VARIABLES #################
-
-SD = 2 
-N = 20
-currency('USD')
-stock('TTRC', currency='USD', multiplier=1)
-initDate='1984-12-31'
-initEq=1000000
-portfolio.st='bbands'
-account.st='bbands'
-
-############################ INITIALIZE AND POSITION LOGIC ################
-
-initPortf(portfolio.st,symbols='TTRC', initDate=initDate)
-initAcct(account.st,portfolios='bbands', initDate=initDate)
-initOrders(portfolio=portfolio.st,initDate=initDate)
-addPosLimit(portfolio.st, 'TTRC', initDate, 200, 2 ) #set max pos
-stratBBands <- strategy("bbands")
-
-############################ INDICATOR ############################
-
-stratBBands <- add.indicator(strategy = stratBBands,
-                             name = "BBands", 
-                             arguments = list(HLC = quote(HLC(mktdata)), 
-                                              maType='SMA'))
-
-
-############################ SIGNALS ##############################
-
-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")
-
-############################# RULES ###############################
-
-
-stratBBands <- add.rule(stratBBands,
-                        name='ruleSignal', 
-                        arguments = list(sigcol="Cl.gt.UpperBand",
-                                         sigval=TRUE, 
-                                         orderqty=-100, 
-                                         ordertype='market', 
-                                         orderside=NULL, 
-                                         threshold=NULL,
-                                         osFUN=osMaxPos),
-                        type='enter')
-
-stratBBands <- add.rule(stratBBands,
-                        name='ruleSignal', 
-                        arguments = list(sigcol="Cl.lt.LowerBand",
-                                         sigval=TRUE, 
-                                         orderqty= 100, 
-                                         ordertype='market', 
-                                         orderside=NULL, 
-                                         threshold=NULL,
-                                         osFUN=osMaxPos),
-                        type='enter')
-
-stratBBands <- add.rule(stratBBands,
-                        name='ruleSignal', 
-                        arguments = list(sigcol="Cross.Mid",
-                                         sigval=TRUE, 
-                                         orderqty= 'all', 
-                                         ordertype='market', 
-                                         orderside=NULL, 
-                                         threshold=NULL,
-                                         osFUN=osMaxPos),
-                        type='exit')
-
-######################## APPLY STRAT  ###################################################
-
-out<-try(applyStrategy(strategy=stratBBands , portfolios='bbands',parameters=list(sd=SD,n=N)) )
-
-updatePortf(Portfolio='bbands',Dates=paste('::',as.Date(Sys.time()),sep=''))

Deleted: pkg/quantstrat/inst/tests/bbands_version_for_tests.r
===================================================================
--- pkg/quantstrat/inst/tests/bbands_version_for_tests.r	2012-12-13 13:04:22 UTC (rev 1291)
+++ pkg/quantstrat/inst/tests/bbands_version_for_tests.r	2012-12-13 13:31:21 UTC (rev 1292)
@@ -1,104 +0,0 @@
-#################### CLEANUP PREVIOUS TEST ######################
-
-# suppressWarnings(rm(list=ls(.strategy), pos=.strategy))
-# suppressWarnings(rm(list=ls(.blotter), pos=.blotter))
-# suppressWarnings(rm(list=ls()))
-
-################### LOAD QUANTSTRAT #################
-
-suppressMessages(require(quantstrat))
-
-###################### LOAD TTRC ######################
-
-data('ttrc')
-TTRC = xts(ttrc[,-1],ttrc[,1])
-TTRC = head(TTRC, n=500)
-
-###################### DEFINE VARIABLES #################
-
-SD = 2 
-N = 20
-currency('USD')
-stock('TTRC', currency='USD', multiplier=1)
-initDate='1984-12-31'
-initEq=1000000
-portfolio.st='bbands'
-account.st='bbands'
-
-############################ INITIALIZE AND POSITION LOGIC ################
-
-initPortf(portfolio.st,symbols='TTRC', initDate=initDate)
-initAcct(account.st,portfolios='bbands', initDate=initDate)
-initOrders(portfolio=portfolio.st,initDate=initDate)
-addPosLimit(portfolio.st, 'TTRC', initDate, 200, 2 ) #set max pos
-stratBBands <- strategy("bbands")
-
-############################ INDICATOR ############################
-
-stratBBands <- add.indicator(strategy = stratBBands,
-                             name = "BBands", 
-                             arguments = list(HLC = quote(HLC(mktdata)), 
-                                              maType='SMA'))
-
-
-############################ SIGNALS ##############################
-
-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")
-
-############################# RULES ###############################
-
-
-stratBBands <- add.rule(stratBBands,
-                        name='ruleSignal', 
-                        arguments = list(sigcol="Cl.gt.UpperBand",
-                                         sigval=TRUE, 
-                                         orderqty=-100, 
-                                         ordertype='market', 
-                                         orderside=NULL, 
-                                         threshold=NULL,
-                                         osFUN=osMaxPos),
-                        type='enter')
-
-stratBBands <- add.rule(stratBBands,
-                        name='ruleSignal', 
-                        arguments = list(sigcol="Cl.lt.LowerBand",
-                                         sigval=TRUE, 
-                                         orderqty= 100, 
-                                         ordertype='market', 
-                                         orderside=NULL, 
-                                         threshold=NULL,
-                                         osFUN=osMaxPos),
-                        type='enter')
-
-stratBBands <- add.rule(stratBBands,
-                        name='ruleSignal', 
-                        arguments = list(sigcol="Cross.Mid",
-                                         sigval=TRUE, 
-                                         orderqty= 'all', 
-                                         ordertype='market', 
-                                         orderside=NULL, 
-                                         threshold=NULL,
-                                         osFUN=osMaxPos),
-                        type='exit')
-
-######################## APPLY STRAT  ###################################################
-
-out<-try(applyStrategy(strategy=stratBBands , portfolios='bbands',parameters=list(sd=SD,n=N)) )
-
-updatePortf(Portfolio='bbands',Dates=paste('::',as.Date(Sys.time()),sep=''))

Deleted: pkg/quantstrat/inst/tests/testthat_bbands.R
===================================================================
--- pkg/quantstrat/inst/tests/testthat_bbands.R	2012-12-13 13:04:22 UTC (rev 1291)
+++ pkg/quantstrat/inst/tests/testthat_bbands.R	2012-12-13 13:31:21 UTC (rev 1292)
@@ -1,67 +0,0 @@
-require(testthat)
-
-################## bee.r  #########################
-
-source('bbands_version_for_tests.r')
-
-stratstat   = tradeStats(portfolio.st)
-
-Txns      = stratstat$Num.Txns
-Trades    = stratstat$Num.Trades
-NetPL     = stratstat$Net.Trading.PL
-LWinner   = stratstat$Largest.Winner
-LLoser    = stratstat$Largest.Loser
-MaxDD     = stratstat$Max.Drawdown
-KFactor   = stratstat$K.Factor
-RINAindex = stratstat$RINA.Index
-InMarket  = stratstat$In.Market
-BuyHold   = stratstat$Buy.Hold
-
-# suppressWarnings(rm("order_book.bbands",pos=.strategy))
-# suppressWarnings(rm("account.bbands","portfolio.bbands",pos=.blotter))
-
-# suppressWarnings(rm("order_book.bbands",pos=.strategy))
-# suppressWarnings(rm("account.bbands","portfolio.bbands",pos=.blotter))
-
-# suppressWarnings(rm("order_book.bbands",pos=.strategy))
-# suppressWarnings(rm("account.bbands","portfolio.bbands",pos=.blotter))
-
-# 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'))
-# 
-######################## RUN TEST SUITE #######################
-
-context('Consistent trade statistics for bbands.R')
-
-test_that("Number of transactions is consistent", 
-          { expect_that(Txns, equals(51)) })
-
-test_that("Number of the number of trades is consistent", 
-          { expect_that(Trades, equals(21)) })
-
-test_that("Net Trading PL is consistent", 
-          { expect_that(NetPL, equals(46)) })
-
-test_that("Largest Winner is consistent", 
-          { expect_that(LWinner, equals(24)) })
-
-test_that("Largest Loser is consistent", 
-          { expect_that(LLoser, equals(-38)) })
-
-test_that("Max Drawdown is consistent", 
-          { expect_that(MaxDD, equals(-84)) })
-
-test_that("K Factor is consistent", 
-          { expect_that(KFactor, equals(0)) })
-
-test_that("RINA Index is consistent", 
-          { expect_that(RINAindex, equals(0)) })
-
-test_that("Time in Market is consistent", 
-          { expect_that(InMarket, equals(0)) })
-
-test_that("Buy and Hold is consistent", 
-          { expect_that(BuyHold, equals(0)) })
-
-

Deleted: pkg/quantstrat/inst/tests/testthat_bbands.r
===================================================================
--- pkg/quantstrat/inst/tests/testthat_bbands.r	2012-12-13 13:04:22 UTC (rev 1291)
+++ pkg/quantstrat/inst/tests/testthat_bbands.r	2012-12-13 13:31:21 UTC (rev 1292)
@@ -1,67 +0,0 @@
-require(testthat)
-
-################## bee.r  #########################
-
-source('bbands_version_for_tests.r')
-
-stratstat   = tradeStats(portfolio.st)
-
-Txns      = stratstat$Num.Txns
-Trades    = stratstat$Num.Trades
-NetPL     = stratstat$Net.Trading.PL
-LWinner   = stratstat$Largest.Winner
-LLoser    = stratstat$Largest.Loser
-MaxDD     = stratstat$Max.Drawdown
-KFactor   = stratstat$K.Factor
-RINAindex = stratstat$RINA.Index
-InMarket  = stratstat$In.Market
-BuyHold   = stratstat$Buy.Hold
-
-# suppressWarnings(rm("order_book.bbands",pos=.strategy))
-# suppressWarnings(rm("account.bbands","portfolio.bbands",pos=.blotter))
-
-# suppressWarnings(rm("order_book.bbands",pos=.strategy))
-# suppressWarnings(rm("account.bbands","portfolio.bbands",pos=.blotter))
-
-# suppressWarnings(rm("order_book.bbands",pos=.strategy))
-# suppressWarnings(rm("account.bbands","portfolio.bbands",pos=.blotter))
-
-# 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'))
-# 
-######################## RUN TEST SUITE #######################
-
-context('Consistent trade statistics for bbands.R')
-
-test_that("Number of transactions is consistent", 
-          { expect_that(Txns, equals(51)) })
-
-test_that("Number of the number of trades is consistent", 
-          { expect_that(Trades, equals(21)) })
-
-test_that("Net Trading PL is consistent", 
-          { expect_that(NetPL, equals(46)) })
-
-test_that("Largest Winner is consistent", 
-          { expect_that(LWinner, equals(24)) })
-
-test_that("Largest Loser is consistent", 
-          { expect_that(LLoser, equals(-38)) })
-
-test_that("Max Drawdown is consistent", 
-          { expect_that(MaxDD, equals(-84)) })
-
-test_that("K Factor is consistent", 
-          { expect_that(KFactor, equals(0)) })
-
-test_that("RINA Index is consistent", 
-          { expect_that(RINAindex, equals(0)) })
-
-test_that("Time in Market is consistent", 
-          { expect_that(InMarket, equals(0)) })
-
-test_that("Buy and Hold is consistent", 
-          { expect_that(BuyHold, equals(0)) })
-
-

Deleted: pkg/quantstrat/inst/tests/testthat_bee.R
===================================================================
--- pkg/quantstrat/inst/tests/testthat_bee.R	2012-12-13 13:04:22 UTC (rev 1291)
+++ pkg/quantstrat/inst/tests/testthat_bee.R	2012-12-13 13:31:21 UTC (rev 1292)
@@ -1,63 +0,0 @@
-require(testthat)
-
-################## bee.r  #########################
-
-source("bee_version_for_tests.R")
-
-#  bing = ls()
-#  bang = ls(.strategy)
-#  boom = ls(.blotter)
-
-stratstat   = tradeStats(port)
-
-Txns      = stratstat$Num.Txns
-Trades    = stratstat$Num.Trades
-NetPL     = stratstat$Net.Trading.PL
-LWinner   = stratstat$Largest.Winner
-LLoser    = stratstat$Largest.Loser
-MaxDD     = stratstat$Max.Drawdown
-KFactor   = stratstat$K.Factor
-RINAindex = stratstat$RINA.Index
-InMarket  = stratstat$In.Market
-BuyHold   = stratstat$Buy.Hold
-
-
-# suppressWarnings(rm(list=ls()))
-# suppressWarnings(rm(list=ls(), pos=.strategy))
-# suppressWarnings(rm(list=ls(), pos=.blotter))
-
-######################## RUN TEST SUITE #######################
-
-context("Consistent trade statistics for bee.R")
-
-test_that("Number of transactions is consistent", 
-          { expect_that(Txns, equals(24)) })
-
-test_that("Number of the number of trades is consistent", 
-          { expect_that(Trades, equals(16)) })
-
-test_that("Net Trading PL is consistent", 
-          { expect_that(NetPL, equals(63)) })
-
-test_that("Largest Winner is consistent", 
-          { expect_that(LWinner, equals(12)) })
-
-test_that("Largest Loser is consistent", 
-          { expect_that(LLoser, equals(-32)) })
-
-test_that("Max Drawdown is consistent", 
-          { expect_that(MaxDD, equals(-867)) })
-
-test_that("K Factor is consistent", 
-          { expect_that(KFactor, equals(0)) })
-
-test_that("RINA Index is consistent", 
-          { expect_that(RINAindex, equals(0)) })
-
-test_that("Time in Market is consistent", 
-          { expect_that(InMarket, equals(0)) })
-
-test_that("Buy and Hold is consistent", 
-          { expect_that(BuyHold, equals(0)) })
-
-



More information about the Blotter-commits mailing list