[Blotter-commits] r1368 - in pkg: blotter/R quantstrat/inst/tests

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Thu Jan 17 14:45:20 CET 2013


Author: milktrader
Date: 2013-01-17 14:45:20 +0100 (Thu, 17 Jan 2013)
New Revision: 1368

Removed:
   pkg/quantstrat/inst/tests/blue.R
Modified:
   pkg/blotter/R/tradeStats.R
   pkg/quantstrat/inst/tests/test_yellow.R
Log:
removed tradeStat stubbed stats and testing of them

Modified: pkg/blotter/R/tradeStats.R
===================================================================
--- pkg/blotter/R/tradeStats.R	2013-01-17 01:54:22 UTC (rev 1367)
+++ pkg/blotter/R/tradeStats.R	2013-01-17 13:45:20 UTC (rev 1368)
@@ -222,12 +222,6 @@
                                  Med.WinLoss.Ratio  = MedWinLoss,
                                  Max.Equity         = MaxEquity,
                                  Min.Equity         = MinEquity,
-#                                 Buy.And.Hold       = BuyAndHold,
-#                                 Time.In.Market     = TimeInMarket
-#                                 RINA.Index         = RINAIndex
-#                                 Sharpe.Ratio       = SharpeRatio,
-#                                 Sortino.Ratio      = SortinoRatio,
-#                                 K.Ratio            = KRatio,
                                  End.Equity         = EndEquity)
             rownames(tmpret) <- symbol             
             ret              <- rbind(ret,tmpret)
@@ -420,12 +414,6 @@
                 Med.WinLoss.Ratio  = MedWinLoss,
                 Max.Equity         = MaxEquity,
                 Min.Equity         = MinEquity,
-#                Buy.And.Hold       = Buy.And.Hold,
-#                Time.In.Market     = TimeInMarket
-#                RINA.Index         = RINAIndex
-#                Sharpe.Ratio       = Sharpe.Ratio,
-#                Sortino.Ratio      = Sortino.Ratio,
-#                K.Ratio            = K.Ratio,
                 End.Equity         = EndEquity)
         return(tmpret)
     }

Deleted: pkg/quantstrat/inst/tests/blue.R
===================================================================
--- pkg/quantstrat/inst/tests/blue.R	2013-01-17 01:54:22 UTC (rev 1367)
+++ pkg/quantstrat/inst/tests/blue.R	2013-01-17 13:45:20 UTC (rev 1368)
@@ -1,128 +0,0 @@
-#!/usr/bin/Rscript --vanilla
-#
-# blue.R
-#
-# this produces trade statistics that can be compared 
-# with results from other frameworks
-#
-# the data is SPX daily data from 1/1/1970 to 12/31/1972
-#
-# copyright (c) 2009-2012, Algorithm Alpha, LLC
-# Licensed GPL-2
-#
-################### LOAD QUANTSTRAT #################
-
-require(quantstrat)
-
-###################### LOAD DATA ######################
-
-data(spx)
-
-############################# DEFINE VARIABLES ##############################
-
-port          = 'bluePort'
-acct          = 'blueAcct'
-initEq        = 1e6
-initDate      = '1969-12-31'
-fast          = 10 
-slow          = 30
-
-############################# INITIALIZE ####################################
-
-currency('USD')
-stock('spx' ,currency='USD', multiplier=1)
-initPortf(port, 'spx', initDate=initDate)
-initAcct(acct, port, initEq=initEq, initDate=initDate)
-initOrders(port, initDate=initDate )
-blue = strategy(port)
-
-############################# INDICATORS ####################################
-
-blue <- add.indicator(
-                     strategy  = blue, 
-                     name      = 'SMA', 
-                     arguments = list(x=quote(Cl(mktdata)), 
-                                      n=fast),
-                     label     = 'fast' )
-
-blue <- add.indicator(
-                     strategy  = blue, 
-                     name      = 'SMA', 
-                     arguments = list(x=quote(Cl(mktdata)), 
-                                      n=slow),
-                     label     = 'slow' )
-
-############################# SIGNALS #######################################
-
-blue <- add.signal(
-                  strategy  = blue,
-                  name      = 'sigCrossover',
-                  arguments = list(columns=c('fast','slow'), 
-                                   relationship='lt'),
-                  label     = 'fast.lt.slow')
-
-blue <- add.signal(
-                  strategy  = blue,
-                  name      = 'sigCrossover',
-                  arguments = list(columns=c('fast','slow'),
-                                   relationship='gt'),
-                  label     = 'fast.gt.slow')
-
-############################# RULES #########################################
-
-blue <- add.rule(
-                strategy  = blue,
-                name      = 'ruleSignal',
-                arguments = list(sigcol    = 'fast.gt.slow',
-                                 sigval    = TRUE,
-                                 orderqty  = 100,
-                                 ordertype = 'market',
-                                 orderside = 'long'),
-
-                type      = 'enter',
-                label     = 'EnterLONG')
-blue <- add.rule(
-                strategy  = blue,
-                name      = 'ruleSignal',
-                arguments = list(sigcol    = 'fast.lt.slow',
-                                 sigval    = TRUE,
-                                 orderqty  = 'all',
-                                 ordertype = 'market',
-                                 orderside = 'long'),
-                type      = 'exit',
-                label     = 'ExitLONG')
-
-blue <- add.rule(
-                strategy  = blue,
-                name      = 'ruleSignal',
-                arguments = list(sigcol     = 'fast.lt.slow',
-                                  sigval    = TRUE,
-                                  orderqty  =  -100,
-                                  ordertype = 'market',
-                                  orderside = 'short'),
-                type      = 'enter',
-                label     = 'EnterSHORT')
-
-blue <- add.rule(
-                strategy  = blue,
-                name      = 'ruleSignal',
-                arguments = list(sigcol     = 'fast.gt.slow',
-                                 sigval     = TRUE,
-                                 orderqty   = 'all',
-                                 ordertype  = 'market',
-                                 orderside  = 'short'),
-                type      = 'exit',
-                label     = 'ExitSHORT')
-
-############################# APPLY STRATEGY ################################
-
-applyStrategy(blue, port, prefer='Open', verbose=FALSE)
-
-############################# UPDATE ########################################
-
-updatePortf(port, 'spx', Date=paste('::',as.Date(Sys.time()),sep=''))
-
-########################### CONTAINERS CALLED IN TESTING #####################
-
-book = getOrderBook(port)
-

Modified: pkg/quantstrat/inst/tests/test_yellow.R
===================================================================
--- pkg/quantstrat/inst/tests/test_yellow.R	2013-01-17 01:54:22 UTC (rev 1367)
+++ pkg/quantstrat/inst/tests/test_yellow.R	2013-01-17 13:45:20 UTC (rev 1368)
@@ -1,6 +1,14 @@
 require(testthat)
 #source('nuke_environments.R')
 
+################## SOURCE EXISTING DEMO ###############
+
+##### in_test   <-TRUE
+##### initDate <- '1998-01-01'
+##### endDate  <- '2012-12-31'
+##### 
+##### demo('macross', ask=FALSE, echo=FALSE)
+##### 
 ######################## DEFINE VARIABLES TO BE TESTED #######
 
 source('yellow.R')
@@ -13,8 +21,6 @@
 fees   = book$yellowPort$spx[,'Txn.Fees']
 rule   = book$yellowPort$spx[,'Rule']
 
-
-
 ######################## ORDER BOOK ######################
 
 context("Yellow order Book is consistent ")
@@ -109,15 +115,3 @@
 test_that("End.Equity is -36", 
           { expect_equal(stats$End.Equity , -36, .0001) })
 
-test_that("Buy.And.Hold is implemented", 
-          { expect_that(stats$Buy.And.Hold , equals(1)) })
-test_that("Time.In.Market is implemented", 
-          { expect_that(stats$Time.In.Market , equals(1)) })
-test_that("RINA.Index is implemented", 
-          { expect_that(stats$RINA.Index , equals(1)) })
-test_that("Sharpe.Ratio is implemented", 
-          { expect_that(stats$Sharpe.Ratio , equals(1)) })
-test_that("Sortino.Ratio is implemented", 
-          { expect_that(stats$Sortino.Ratio , equals(1)) })
-test_that("K.Ratio is implemented", 
-          { expect_that(stats$K.Ratio , equals(1)) })



More information about the Blotter-commits mailing list