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

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Thu Dec 13 16:36:59 CET 2012


Author: milktrader
Date: 2012-12-13 16:36:59 +0100 (Thu, 13 Dec 2012)
New Revision: 1295

Modified:
   pkg/quantstrat/inst/tests/bbands_version_for_tests.R
   pkg/quantstrat/inst/tests/bee_version_for_tests.R
   pkg/quantstrat/inst/tests/testthat_bbands.R
   pkg/quantstrat/inst/tests/testthat_bee.R
Log:
using spx.rda and commented out 8 tests

Modified: pkg/quantstrat/inst/tests/bbands_version_for_tests.R
===================================================================
--- pkg/quantstrat/inst/tests/bbands_version_for_tests.R	2012-12-13 15:10:59 UTC (rev 1294)
+++ pkg/quantstrat/inst/tests/bbands_version_for_tests.R	2012-12-13 15:36:59 UTC (rev 1295)
@@ -1,36 +1,34 @@
 #################### CLEANUP PREVIOUS TEST ######################
 
-# suppressWarnings(rm(list=ls(.strategy), pos=.strategy))
-# suppressWarnings(rm(list=ls(.blotter), pos=.blotter))
-# suppressWarnings(rm(list=ls()))
+ 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 ######################
+###################### LOAD DATA ######################
 
-data('ttrc')
-TTRC = xts(ttrc[,-1],ttrc[,1])
-TTRC = head(TTRC, n=500)
+data('spx')
 
 ###################### DEFINE VARIABLES #################
 
 SD = 2 
 N = 20
 currency('USD')
-stock('TTRC', currency='USD', multiplier=1)
-initDate='1984-12-31'
+stock('spx', currency='USD', multiplier=1)
+initDate='1969-12-31'
 initEq=1000000
 portfolio.st='bbands'
 account.st='bbands'
 
 ############################ INITIALIZE AND POSITION LOGIC ################
 
-initPortf(portfolio.st,symbols='TTRC', initDate=initDate)
+initPortf(portfolio.st,symbols='spx', 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
+addPosLimit(portfolio.st, 'spx', initDate, 200, 2 ) #set max pos
 stratBBands <- strategy("bbands")
 
 ############################ INDICATOR ############################

Modified: pkg/quantstrat/inst/tests/bee_version_for_tests.R
===================================================================
--- pkg/quantstrat/inst/tests/bee_version_for_tests.R	2012-12-13 15:10:59 UTC (rev 1294)
+++ pkg/quantstrat/inst/tests/bee_version_for_tests.R	2012-12-13 15:36:59 UTC (rev 1295)
@@ -1,26 +1,25 @@
 
 #################### CLEANUP PREVIOUS TEST ######################
 # 
-# suppressWarnings(rm(list=ls(.strategy), pos=.strategy))
-# suppressWarnings(rm(list=ls(.blotter), pos=.blotter))
-# suppressWarnings(rm(list=ls()))
+ 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 ######################
+###################### LOAD DATA ######################
 
-data('ttrc')
-TTRC = xts(ttrc[,-1],ttrc[,1])
+data('spx')
 
 ############################# DEFINE VARIABLES ##############################
 
-sym           = head(TTRC, n=500)
+sym           = spx
 port          = 'bug'
 acct          = 'colony'
 initEq        = 100000
-initDate      = '1984-12-31'
+initDate      = '1969-12-31'
 fast          = 10
 slow          = 30
 sd            = 0.5

Modified: pkg/quantstrat/inst/tests/testthat_bbands.R
===================================================================
--- pkg/quantstrat/inst/tests/testthat_bbands.R	2012-12-13 15:10:59 UTC (rev 1294)
+++ pkg/quantstrat/inst/tests/testthat_bbands.R	2012-12-13 15:36:59 UTC (rev 1295)
@@ -12,22 +12,17 @@
 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
+# 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(list=ls()))
+# suppressWarnings(rm(list=ls(), pos=.strategy))
+# suppressWarnings(rm(list=ls(), 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 #######################
@@ -35,33 +30,33 @@
 context('Consistent trade statistics for bbands.R')
 
 test_that("Number of transactions is consistent", 
-          { expect_that(Txns, equals(51)) })
+          { expect_that(Txns, equals(40)) })
 
 test_that("Number of the number of trades is consistent", 
-          { expect_that(Trades, equals(21)) })
+          { expect_that(Trades, equals(16)) })
 
 test_that("Net Trading PL is consistent", 
-          { expect_that(NetPL, equals(46)) })
+          { expect_that(NetPL, equals(-1637)) })
 
 test_that("Largest Winner is consistent", 
-          { expect_that(LWinner, equals(24)) })
+          { expect_that(LWinner, equals(656)) })
 
 test_that("Largest Loser is consistent", 
-          { expect_that(LLoser, equals(-38)) })
+          { expect_that(LLoser, equals(-1303)) })
 
 test_that("Max Drawdown is consistent", 
-          { expect_that(MaxDD, equals(-84)) })
+          { expect_that(MaxDD, equals(-3037)) })
 
-test_that("K Factor is consistent", 
-          { expect_that(KFactor, equals(0)) })
+# 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)) })
 
-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)) })
-
-

Modified: pkg/quantstrat/inst/tests/testthat_bee.R
===================================================================
--- pkg/quantstrat/inst/tests/testthat_bee.R	2012-12-13 15:10:59 UTC (rev 1294)
+++ pkg/quantstrat/inst/tests/testthat_bee.R	2012-12-13 15:36:59 UTC (rev 1295)
@@ -4,10 +4,6 @@
 
 source("bee_version_for_tests.R")
 
-#  bing = ls()
-#  bang = ls(.strategy)
-#  boom = ls(.blotter)
-
 stratstat   = tradeStats(port)
 
 Txns      = stratstat$Num.Txns
@@ -16,10 +12,10 @@
 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
+# KFactor   = stratstat$K.Factor
+# RINAindex = stratstat$RINA.Index
+# InMarket  = stratstat$In.Market
+# BuyHold   = stratstat$Buy.Hold
 
 
 # suppressWarnings(rm(list=ls()))
@@ -31,33 +27,33 @@
 context("Consistent trade statistics for bee.R")
 
 test_that("Number of transactions is consistent", 
-          { expect_that(Txns, equals(24)) })
+          { expect_that(Txns, equals(18)) })
 
 test_that("Number of the number of trades is consistent", 
-          { expect_that(Trades, equals(16)) })
+          { expect_that(Trades, equals(12)) })
 
 test_that("Net Trading PL is consistent", 
-          { expect_that(NetPL, equals(63)) })
+          { expect_that(NetPL, equals(199)) })
 
 test_that("Largest Winner is consistent", 
-          { expect_that(LWinner, equals(12)) })
+          { expect_that(LWinner, equals(1336)) })
 
 test_that("Largest Loser is consistent", 
-          { expect_that(LLoser, equals(-32)) })
+          { expect_that(LLoser, equals(-525)) })
 
 test_that("Max Drawdown is consistent", 
-          { expect_that(MaxDD, equals(-867)) })
+          { expect_that(MaxDD, equals(-20359)) })
 
-test_that("K Factor is consistent", 
-          { expect_that(KFactor, equals(0)) })
+# 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)) })
 
-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