[Blotter-commits] r1291 - in pkg/quantstrat: . inst inst/tests tests

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Thu Dec 13 14:04:23 CET 2012


Author: milktrader
Date: 2012-12-13 14:04:22 +0100 (Thu, 13 Dec 2012)
New Revision: 1291

Added:
   pkg/quantstrat/inst/tests/testthat_bbands.R
   pkg/quantstrat/tests/
   pkg/quantstrat/tests/run-all.R
Removed:
   pkg/quantstrat/inst/doc/
   pkg/quantstrat/inst/tests/svunit_bbands.r
Modified:
   pkg/quantstrat/DESCRIPTION
   pkg/quantstrat/inst/tests/bee_version_for_tests.R
Log:
more testing framework infrastructure

Modified: pkg/quantstrat/DESCRIPTION
===================================================================
--- pkg/quantstrat/DESCRIPTION	2012-12-13 02:36:56 UTC (rev 1290)
+++ pkg/quantstrat/DESCRIPTION	2012-12-13 13:04:22 UTC (rev 1291)
@@ -8,7 +8,7 @@
     xts(>= 0.8-2),TTR(>= 0.2),blotter(>= 0.7.2),
     FinancialInstrument(>= 0.12.5)
 Suggests:
-    PerformanceAnalytics,PortfolioAnalytics,rgl, testthat, svUnit
+    PerformanceAnalytics,PortfolioAnalytics,rgl, testthat
 Maintainer: Brian G. Peterson <brian at braverock.com>
 Description: Specify, build, and back-test quantitative
     financial trading and portfolio strategies

Modified: pkg/quantstrat/inst/tests/bee_version_for_tests.R
===================================================================
--- pkg/quantstrat/inst/tests/bee_version_for_tests.R	2012-12-13 02:36:56 UTC (rev 1290)
+++ pkg/quantstrat/inst/tests/bee_version_for_tests.R	2012-12-13 13:04:22 UTC (rev 1291)
@@ -127,7 +127,7 @@
 
 ############################# APPLY STRATEGY ################################
 
-applyStrategy(bee, port, prefer='Open', verbose=FALSE)
+out = applyStrategy(bee, port, prefer='Open', verbose=FALSE)
 
 ############################# UPDATE ########################################
 

Deleted: pkg/quantstrat/inst/tests/svunit_bbands.r
===================================================================
--- pkg/quantstrat/inst/tests/svunit_bbands.r	2012-12-13 02:36:56 UTC (rev 1290)
+++ pkg/quantstrat/inst/tests/svunit_bbands.r	2012-12-13 13:04:22 UTC (rev 1291)
@@ -1,24 +0,0 @@
-
-require(svUnit)
-
-source('bbands_version_for_tests.r')
-
-bbands = 'Testing consistent trade stats'
-
-test(bbands) = function() {
-
-  stats = tradeStats(portfolio.st)
-
-  checkEquals( stats$Num.Txns, 51)
-  checkEquals( stats$Num.Trades, 21)
-  checkEquals( stats$Net.Trading.PL, 46)
-  checkEquals( stats$Largest.Winner, 24)
-  checkEquals( stats$Largest.Loser, -38)
-  checkEquals( stats$Max.Drawdown, -84)
-}
-
-
-clearLog()
-runTest(bbands)
-Log()
-summary(Log())

Added: pkg/quantstrat/inst/tests/testthat_bbands.R
===================================================================
--- pkg/quantstrat/inst/tests/testthat_bbands.R	                        (rev 0)
+++ pkg/quantstrat/inst/tests/testthat_bbands.R	2012-12-13 13:04:22 UTC (rev 1291)
@@ -0,0 +1,67 @@
+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)) })
+
+

Added: pkg/quantstrat/tests/run-all.R
===================================================================
--- pkg/quantstrat/tests/run-all.R	                        (rev 0)
+++ pkg/quantstrat/tests/run-all.R	2012-12-13 13:04:22 UTC (rev 1291)
@@ -0,0 +1,4 @@
+library(testthat)
+library(quantstrat)
+
+test_package("quantstrat")



More information about the Blotter-commits mailing list