[Blotter-commits] r1594 - in pkg/quantstrat: . R demo man

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Sat Mar 29 21:39:45 CET 2014


Author: braverock
Date: 2014-03-29 21:39:45 +0100 (Sat, 29 Mar 2014)
New Revision: 1594

Modified:
   pkg/quantstrat/.project
   pkg/quantstrat/DESCRIPTION
   pkg/quantstrat/NAMESPACE
   pkg/quantstrat/R/applyStrategy.rebalancing.R
   pkg/quantstrat/R/ruleSignal.R
   pkg/quantstrat/R/rules.R
   pkg/quantstrat/R/strategy.R
   pkg/quantstrat/demo/faber.R
   pkg/quantstrat/demo/faber_rebal.R
   pkg/quantstrat/demo/macdRebalancing.R
   pkg/quantstrat/man/add.distribution.Rd
   pkg/quantstrat/man/add.distribution.constraint.Rd
   pkg/quantstrat/man/add.indicator.Rd
   pkg/quantstrat/man/add.init.Rd
   pkg/quantstrat/man/add.rule.Rd
   pkg/quantstrat/man/add.signal.Rd
   pkg/quantstrat/man/addOrder.Rd
   pkg/quantstrat/man/addPosLimit.Rd
   pkg/quantstrat/man/apply.paramset.Rd
   pkg/quantstrat/man/applyIndicators.Rd
   pkg/quantstrat/man/applyParameter.Rd
   pkg/quantstrat/man/applyRules.Rd
   pkg/quantstrat/man/applySignals.Rd
   pkg/quantstrat/man/applyStrategy.Rd
   pkg/quantstrat/man/applyStrategy.rebalancing.Rd
   pkg/quantstrat/man/chart.forward.Rd
   pkg/quantstrat/man/chart.forward.training.Rd
   pkg/quantstrat/man/delete.paramset.Rd
   pkg/quantstrat/man/enable.rule.Rd
   pkg/quantstrat/man/get.strategy.Rd
   pkg/quantstrat/man/getOrderBook.Rd
   pkg/quantstrat/man/getOrders.Rd
   pkg/quantstrat/man/getParameterTable.Rd
   pkg/quantstrat/man/getPosLimit.Rd
   pkg/quantstrat/man/initOrders.Rd
   pkg/quantstrat/man/initStrategy.Rd
   pkg/quantstrat/man/is.strategy.Rd
   pkg/quantstrat/man/load.strategy.Rd
   pkg/quantstrat/man/match.names.Rd
   pkg/quantstrat/man/osMaxPos.Rd
   pkg/quantstrat/man/osNoOp.Rd
   pkg/quantstrat/man/paramConstraint.Rd
   pkg/quantstrat/man/put.orderbook.Rd
   pkg/quantstrat/man/put.strategy.Rd
   pkg/quantstrat/man/rm.strat.Rd
   pkg/quantstrat/man/ruleOrderProc.Rd
   pkg/quantstrat/man/rulePctEquity.Rd
   pkg/quantstrat/man/ruleRevoke.Rd
   pkg/quantstrat/man/ruleSignal.Rd
   pkg/quantstrat/man/save.strategy.Rd
   pkg/quantstrat/man/setParameterConstraint.Rd
   pkg/quantstrat/man/setParameterDistribution.Rd
   pkg/quantstrat/man/sigComparison.Rd
   pkg/quantstrat/man/sigCrossover.Rd
   pkg/quantstrat/man/sigFormula.Rd
   pkg/quantstrat/man/sigPeak.Rd
   pkg/quantstrat/man/sigThreshold.Rd
   pkg/quantstrat/man/sigTimestamp.Rd
   pkg/quantstrat/man/strategy.Rd
   pkg/quantstrat/man/tradeGraphs.Rd
   pkg/quantstrat/man/tradeOrderStats.Rd
   pkg/quantstrat/man/updateOrders.Rd
   pkg/quantstrat/man/updateStrategy.Rd
   pkg/quantstrat/man/walk.forward.Rd
Log:
- fix rebalancing and rebalancing demos
- update roxygen docs
- bump version

Modified: pkg/quantstrat/.project
===================================================================
--- pkg/quantstrat/.project	2014-03-29 15:18:31 UTC (rev 1593)
+++ pkg/quantstrat/.project	2014-03-29 20:39:45 UTC (rev 1594)
@@ -14,5 +14,6 @@
 	<natures>
 		<nature>de.walware.statet.base.StatetNature</nature>
 		<nature>de.walware.statet.r.RNature</nature>
+		<nature>de.walware.statet.r.RPkgNature</nature>
 	</natures>
 </projectDescription>

Modified: pkg/quantstrat/DESCRIPTION
===================================================================
--- pkg/quantstrat/DESCRIPTION	2014-03-29 15:18:31 UTC (rev 1593)
+++ pkg/quantstrat/DESCRIPTION	2014-03-29 20:39:45 UTC (rev 1594)
@@ -1,15 +1,18 @@
 Package: quantstrat
 Type: Package
 Title: Quantitative Strategy Model Framework
-Version: 0.8.0
+Version: 0.8.2
 Date: $Date$
 Author: Peter Carl, Brian G. Peterson, Joshua Ulrich, Jan Humme
 Depends:
-    xts(>= 0.8-2),TTR(>= 0.2),blotter(>= 0.7.2),
+    xts(>= 0.8-2),TTR(>= 0.2),
+    blotter(>= 0.7.2),
     FinancialInstrument(>= 0.12.5),
     foreach(>= 1.4.0)
 Suggests:
-    PerformanceAnalytics,PortfolioAnalytics,rgl,
+    PerformanceAnalytics,
+    PortfolioAnalytics,
+    rgl,
     testthat,
     xtsExtra
 Maintainer: Brian G. Peterson <brian at braverock.com>
@@ -20,26 +23,3 @@
 LazyLoad: yes
 License: GPL-3
 ByteCompile: TRUE
-Collate:
-    'applyStrategy.rebalancing.R'
-    'chart.forward.R'
-    'chart.forward.training.R'
-    'indicators.R'
-    'initialize.R'
-    'match.names.R'
-    'orders.R'
-    'osFUNs.R'
-    'parameters.R'
-    'paramsets.R'
-    'rebalance.rules.R'
-    'ruleOrderProc.R'
-    'ruleRevoke.R'
-    'rules.R'
-    'ruleSignal.R'
-    'signals.R'
-    'strategy.R'
-    'tradeGraphs.R'
-    'tradeOrderStats.R'
-    'utils.R'
-    'walk.forward.R'
-    'wrapup.R'

Modified: pkg/quantstrat/NAMESPACE
===================================================================
--- pkg/quantstrat/NAMESPACE	2014-03-29 15:18:31 UTC (rev 1593)
+++ pkg/quantstrat/NAMESPACE	2014-03-29 20:39:45 UTC (rev 1594)
@@ -13,6 +13,7 @@
 export(applySignals)
 export(applyStrategy)
 export(applyStrategy.rebalancing)
+export(applyStrategy.rebalancing.training)
 export(chart.forward)
 export(chart.forward.training)
 export(delete.paramset)
@@ -46,6 +47,7 @@
 export(sigFormula)
 export(sigPeak)
 export(sigThreshold)
+export(sigTimestamp)
 export(strategy)
 export(tradeGraphs)
 export(tradeOrderStats)

Modified: pkg/quantstrat/R/applyStrategy.rebalancing.R
===================================================================
--- pkg/quantstrat/R/applyStrategy.rebalancing.R	2014-03-29 15:18:31 UTC (rev 1593)
+++ pkg/quantstrat/R/applyStrategy.rebalancing.R	2014-03-29 20:39:45 UTC (rev 1594)
@@ -15,6 +15,7 @@
 #' @seealso \code{\link{strategy}},  \code{\link{applyIndicators}}, 
 #'  \code{\link{applySignals}}, \code{\link{applyRules}},
 #'  \code{\link{initStrategy}}, \code{\link{applyStrategy}}
+#'  
 applyStrategy.rebalancing <- function(strategy , 
                                       portfolios, 
                                       mktdata=NULL , 
@@ -130,6 +131,7 @@
         
         #now we need to do the endpoints loop. 
         for(i in 2:length(pindex)){
+            
             #the proper endpoints for each symbol will vary, so we need to get
             #them separately, and subset each one
             for (symbol in symbols){
@@ -162,9 +164,14 @@
                 # specifically, we need to check if *this* index is in st$plist$period
                 for(period in names(st$plist)){
                     if(pindex[i] %in% st$plist[[period]]){
+                        
+                        #print(pindex[i])
+                        curIndex <- pindex[i] #make sure pindex is available as curIndex 
+                      
                         #this index is a rebalancing index for period
                         #call the rebalance rules for this period
                         #still need to separate the rules by rebalancing period, this will call them all
+
                         ruleProc(s$rules$rebalance,
                                 timestamp=pindex[i], 
                                 path.dep=TRUE, 

Modified: pkg/quantstrat/R/ruleSignal.R
===================================================================
--- pkg/quantstrat/R/ruleSignal.R	2014-03-29 15:18:31 UTC (rev 1593)
+++ pkg/quantstrat/R/ruleSignal.R	2014-03-29 20:39:45 UTC (rev 1594)
@@ -204,13 +204,23 @@
         #TODO add fancy formals matching for osFUN
         if(orderqty!='all')
         {
-            orderqty <- osFUN(strategy=strategy, data=mktdata, timestamp=timestamp, orderqty=orderqty, ordertype=ordertype, orderside=orderside, portfolio=portfolio, symbol=symbol,...=...,ruletype=ruletype, orderprice=as.numeric(orderprice))
+            orderqty <- osFUN(strategy=strategy, 
+                              data=mktdata, 
+                              timestamp=timestamp, 
+                              orderqty=orderqty, 
+                              ordertype=ordertype, 
+                              orderside=orderside, 
+                              portfolio=portfolio, 
+                              symbol=symbol,
+                              ...=...,
+                              ruletype=ruletype, 
+                              orderprice=as.numeric(orderprice))
         }
 
-        if(!is.null(orderqty) && orderqty!=0 && !is.null(orderprice)) #orderprice could have length > 1
+        if(!is.null(orderqty) && orderqty!=0 && length(orderprice) && is.numeric(orderprice[1])) #orderprice could have length > 1
         {
-#            if(orderqty != 'all' || getPosQty(portfolio, symbol, timestamp) != 0)
-#            {
+          if(orderqty != 'all' || getPosQty(portfolio, symbol, timestamp) != 0)
+             {
                 addOrder(portfolio=portfolio, 
                          symbol=symbol, 
                          timestamp=timestamp, 
@@ -228,8 +238,8 @@
                          prefer=prefer, 
                          TxnFees=TxnFees,
                          label=label,
-			 time.in.force=time.in.force)
-#            }
+			                   time.in.force=time.in.force)
+            }
         }
     }
     if(sethold) hold <<- TRUE

Modified: pkg/quantstrat/R/rules.R
===================================================================
--- pkg/quantstrat/R/rules.R	2014-03-29 15:18:31 UTC (rev 1593)
+++ pkg/quantstrat/R/rules.R	2014-03-29 20:39:45 UTC (rev 1594)
@@ -241,6 +241,7 @@
 #' @param ... any other passthru parameters
 #' @param path.dep TRUE/FALSE whether rule is path dependent, default TRUE, see Details 
 #' @param rule.order default NULL, use at your own risk to adjust order of rule evaluation
+#' @param debug if TRUE, return output list
 #' @seealso \code{\link{add.rule}} \code{\link{applyStrategy}} 
 #' @export
 applyRules <- function(portfolio, 
@@ -253,7 +254,8 @@
                         parameters=NULL,   
                         ..., 
                         path.dep=TRUE,
-                        rule.order=NULL) {
+                        rule.order=NULL,
+                        debug=FALSE) {
     # TODO check for symbol name in mktdata using Josh's code:
     # symbol <- strsplit(colnames(mktdata)[1],"\\.")[[1]][1]
     
@@ -486,7 +488,8 @@
     holdtill=first(time(Dates))-1 # TODO FIXME make holdtill default more robust?
     mktinstr<-getInstrument(symbol)
     curIndex<-1
-    freq <- periodicity(mktdata)  # run once and pass to ruleOrderProc
+    if(nrow(mktdata)>1) freq <- periodicity(mktdata)  # run once and pass to ruleOrderProc
+    else if (indexClass(mktdata) == 'Date') freq='daily'
     
     # do order price subsetting outside of nextIndex and curIndex loop
     # this avoids repeated [.xts calls; and mktPrices is never altered, so copies aren't made
@@ -526,7 +529,7 @@
 
     while(curIndex){
         timestamp=Dates[curIndex]    
-
+        
         #print(paste('timestamp',timestamp,'first',first(index(mktdata)),'last',last(index(mktdata))))
         
         # check to see if we need to release a hold
@@ -614,12 +617,17 @@
         else curIndex=FALSE
     } # end index while loop
 
-    mktdata<<-mktdata
-    if(is.null(ret)) {
+    if(isTRUE(debug)){
+      mktdata<<-mktdata
+      
+      if(is.null(ret)) {
         return(mktdata)
-    }
-    else return(ret)
-}
+      }
+      else return(ret)      
+    } else {
+      return(NULL)
+    }   
+} #end applyRules
 
 # private function ruleProc, used by applyRules and applyStrategy.rebalancing
 ruleProc <- function (ruletypelist,timestamp=NULL, path.dep, ruletype, ..., parameters=NULL){

Modified: pkg/quantstrat/R/strategy.R
===================================================================
--- pkg/quantstrat/R/strategy.R	2014-03-29 15:18:31 UTC (rev 1593)
+++ pkg/quantstrat/R/strategy.R	2014-03-29 20:39:45 UTC (rev 1594)
@@ -96,6 +96,8 @@
 #' @param symbols character vector identifying symbols to initialize a portfolio for, default NULL
 #' @param initStrat whether to use (experimental) initialization code, default FALSE
 #' @param updateStrat whether to use (experimental) wrapup code, default FALSE
+#' @param gc if TRUE, call \code{\link{gc}} after each symbol run, default FALSE (experimental)
+#' @param delorders if TRUE, delete the order book for a symbol at the end of the symbols loop, will cause issues with rebalancing, default FALSE (experimental)
 #' @export
 #' @seealso \code{\link{strategy}},  \code{\link{applyIndicators}}, 
 #'  \code{\link{applySignals}}, \code{\link{applyRules}},
@@ -108,7 +110,9 @@
                           debug=FALSE, 
                           symbols=NULL, 
                           initStrat=FALSE, 
-                          updateStrat=FALSE ) {
+                          updateStrat=FALSE,
+                          gc=FALSE,
+                          delorders=FALSE) {
 
   #TODO add saving of modified market data
   
@@ -170,7 +174,8 @@
                                         signals=sret$signals, 
                                         parameters=parameters,  
                                         ..., 
-                                        path.dep=FALSE)
+                                        path.dep=FALSE,
+                                        debug=debug)
          
          # Check for open orders
          rem.orders <- suppressWarnings(getOrders(portfolio=portfolio, symbol=symbol, status="open")) #, timespan=timespan, ordertype=ordertype,which.i=TRUE)
@@ -184,9 +189,14 @@
                                                      signals=sret$signals, 
                                                      parameters=parameters,  
                                                      ..., 
-                                                     path.dep=TRUE)}
+                                                     path.dep=TRUE,
+                                                     debug=debug)}
          
          if(isTRUE(debug)) ret[[portfolio]][[symbol]]<-sret
+         
+         if(isTRUE(delorders)) .strategy[[paste("order_book",portfolio,sep='.')]][[symbol]]<-NULL #WARNING: This is VERY DESTRUCTIVE  
+
+         if(isTRUE(gc)) gc()
        }
        
        # call updateStrategy

Modified: pkg/quantstrat/demo/faber.R
===================================================================
--- pkg/quantstrat/demo/faber.R	2014-03-29 15:18:31 UTC (rev 1593)
+++ pkg/quantstrat/demo/faber.R	2014-03-29 20:39:45 UTC (rev 1594)
@@ -146,14 +146,15 @@
 }
 
 ret1 <- PortfReturns('faber')
-ret1$total<-rowSums(ret1)
+ret1 <- to.monthly(ret1)
+ret1$total <- rowSums(ret1)
+
 View(ret1)
 
 if("package:PerformanceAnalytics" %in% search() || require("PerformanceAnalytics",quietly=TRUE)){
 	getSymbols("SPY", src='yahoo', index.class=c("POSIXt","POSIXct"), from='1999-01-01')
 	SPY<-to.monthly(SPY)
 	SPY.ret<-Return.calculate(SPY$SPY.Close)
-	index(SPY.ret)<-index(ret1)
 	dev.new()
 	charts.PerformanceSummary(cbind(ret1$total,SPY.ret), geometric=FALSE, wealth.index=TRUE)
 }

Modified: pkg/quantstrat/demo/faber_rebal.R
===================================================================
--- pkg/quantstrat/demo/faber_rebal.R	2014-03-29 15:18:31 UTC (rev 1593)
+++ pkg/quantstrat/demo/faber_rebal.R	2014-03-29 20:39:45 UTC (rev 1594)
@@ -45,6 +45,12 @@
 # Load required libraries
 require(quantstrat)
 
+#correct for TZ issues if they crop up
+oldtz <- Sys.getenv('TZ')
+if(oldtz=='') {
+  Sys.setenv(TZ="UTC")
+}
+
 # Try to clean up in case the demo was run previously
 suppressWarnings(rm("account.faber","portfolio.faber",pos=.blotter))
 suppressWarnings(rm("ltaccount", "ltportfolio", "ClosePrice", "CurrentDate", "equity", 
@@ -121,7 +127,7 @@
 add.rule('faber', 'rulePctEquity',
         arguments=list(rebalance_on='quarters',
                 trade.percent=1/length(symbols),
-                refprice=quote(last(getPrice(mktdata)[paste('::',timestamp,sep='')][,1])),
+                refprice=quote(last(getPrice(mktdata)[paste('::',as.character(curIndex),sep='')][,1])),
                 digits=0
         ),
         type='rebalance',
@@ -135,6 +141,8 @@
 print("Strategy Loop:")
 print(end_t-start_t)
 
+Sys.setenv(TZ=oldtz)
+
 # look at the order book
 #print(getOrderBook('faber'))
 
@@ -157,16 +165,17 @@
 }
 
 ret1 <- PortfReturns('faber')
-ret1$total<-rowSums(ret1)
-ret1
+ret1 <- to.monthly(ret1)
+ret1$total <- rowSums(ret1)
 
+View(ret1)
+
 if("package:PerformanceAnalytics" %in% search() || require("PerformanceAnalytics",quietly=TRUE)){
-	getSymbols("SPY", src='yahoo', index.class=c("POSIXt","POSIXct"), from='1999-01-01')
-	SPY<-to.monthly(SPY)
-	SPY.ret<-Return.calculate(SPY$SPY.Close)
-	index(SPY.ret)<-index(ret1)
-	dev.new()
-	charts.PerformanceSummary(cbind(ret1$total,SPY.ret), geometric=FALSE, wealth.index=TRUE)
+  getSymbols("SPY", src='yahoo', index.class=c("POSIXt","POSIXct"), from='1999-01-01')
+  SPY <- to.monthly(SPY)
+  SPY.ret <- Return.calculate(SPY$SPY.Close)
+  dev.new()
+  charts.PerformanceSummary(cbind(ret1$total,SPY.ret), geometric=FALSE, wealth.index=TRUE)
 }
 
 faber.stats<-tradeStats('faber')[,c('Net.Trading.PL','Max.Drawdown','Num.Trades','Profit.Factor','Std.Dev.Trade.PL','Largest.Winner','Largest.Loser','Max.Equity','Min.Equity')]

Modified: pkg/quantstrat/demo/macdRebalancing.R
===================================================================
--- pkg/quantstrat/demo/macdRebalancing.R	2014-03-29 15:18:31 UTC (rev 1593)
+++ pkg/quantstrat/demo/macdRebalancing.R	2014-03-29 20:39:45 UTC (rev 1594)
@@ -109,7 +109,7 @@
 add.rule(strat.st, 'rulePctEquity',
         arguments=list(rebalance_on='months',
                        trade.percent=.02,
-                       refprice=quote(last(getPrice(mktdata)[paste('::',timestamp,sep='')])),
+                       refprice=quote(last(getPrice(mktdata)[paste('::',curIndex,sep='')])),
                        digits=0
         ),
         type='rebalance',
@@ -119,7 +119,7 @@
 #end rules
 ####
 
-getSymbols(stock.str,from=initDate)
+getSymbols(stock.str,from=initDate,src='yahoo')
 start_t<-Sys.time()
 out<-applyStrategy.rebalancing(strat.st , portfolios=portfolio.st,parameters=list(nFast=fastMA, nSlow=slowMA, nSig=signalMA,maType=maType),verbose=TRUE)
 end_t<-Sys.time()

Modified: pkg/quantstrat/man/add.distribution.Rd
===================================================================
--- pkg/quantstrat/man/add.distribution.Rd	2014-03-29 15:18:31 UTC (rev 1593)
+++ pkg/quantstrat/man/add.distribution.Rd	2014-03-29 20:39:45 UTC (rev 1594)
@@ -2,9 +2,8 @@
 \alias{add.distribution}
 \title{Adds a distribution to a paramset in a strategy}
 \usage{
-  add.distribution(strategy, paramset.label,
-    component.type, component.label, variable,
-    weight = NULL, label, store = TRUE)
+add.distribution(strategy, paramset.label, component.type, component.label,
+  variable, weight = NULL, label, store = TRUE)
 }
 \arguments{
   \item{strategy}{the name of the strategy object to add
@@ -31,16 +30,15 @@
   the .strategy environment}
 }
 \description{
-  Creates a distribution in paramset, where a distribution
-  consists of the name of a variable in a strategy
-  component plus a range of values for this variable.
+Creates a distribution in paramset, where a distribution
+consists of the name of a variable in a strategy component
+plus a range of values for this variable.
 }
 \author{
-  Jan Humme
+Jan Humme
 }
 \seealso{
-  \code{\link{add.distribution.constraint}},
-  \code{\link{delete.paramset}},
-  \code{\link{apply.paramset}}
+\code{\link{add.distribution.constraint}},
+\code{\link{delete.paramset}}, \code{\link{apply.paramset}}
 }
 

Modified: pkg/quantstrat/man/add.distribution.constraint.Rd
===================================================================
--- pkg/quantstrat/man/add.distribution.constraint.Rd	2014-03-29 15:18:31 UTC (rev 1593)
+++ pkg/quantstrat/man/add.distribution.constraint.Rd	2014-03-29 20:39:45 UTC (rev 1594)
@@ -2,9 +2,8 @@
 \alias{add.distribution.constraint}
 \title{Adds a constraint on 2 distributions within a paramset}
 \usage{
-  add.distribution.constraint(strategy, paramset.label,
-    distribution.label.1, distribution.label.2, operator,
-    label, store = TRUE)
+add.distribution.constraint(strategy, paramset.label, distribution.label.1,
+  distribution.label.2, operator, label, store = TRUE)
 }
 \arguments{
   \item{strategy}{the name of the strategy object to add
@@ -29,16 +28,15 @@
   the .strategy environment}
 }
 \description{
-  Creates a constraint on 2 distributions in a paramset,
-  i.e. a restriction limiting the allowed combinations from
-  the ranges for distribution 1 and distribution 2.
+Creates a constraint on 2 distributions in a paramset, i.e.
+a restriction limiting the allowed combinations from the
+ranges for distribution 1 and distribution 2.
 }
 \author{
-  Jan Humme
+Jan Humme
 }
 \seealso{
-  \code{\link{add.distribution}},
-  \code{\link{delete.paramset}},
-  \code{\link{apply.paramset}}
+\code{\link{add.distribution}},
+\code{\link{delete.paramset}}, \code{\link{apply.paramset}}
 }
 

Modified: pkg/quantstrat/man/add.indicator.Rd
===================================================================
--- pkg/quantstrat/man/add.indicator.Rd	2014-03-29 15:18:31 UTC (rev 1593)
+++ pkg/quantstrat/man/add.indicator.Rd	2014-03-29 20:39:45 UTC (rev 1594)
@@ -2,9 +2,8 @@
 \alias{add.indicator}
 \title{add an indicator to a strategy}
 \usage{
-  add.indicator(strategy, name, arguments,
-    parameters = NULL, label = NULL, ..., enabled = TRUE,
-    indexnum = NULL, store = FALSE)
+add.indicator(strategy, name, arguments, parameters = NULL, label = NULL,
+  ..., enabled = TRUE, indexnum = NULL, store = FALSE)
 }
 \arguments{
   \item{strategy}{an object (or the name of an object) type
@@ -39,71 +38,69 @@
   the .strategy environment, or return it.  default FALSE}
 }
 \value{
-  if \code{strategy} was the name of a strategy, the name.
-  It it was a strategy, the updated strategy.
+if \code{strategy} was the name of a strategy, the name. It
+it was a strategy, the updated strategy.
 }
 \description{
-  Indicators are typically standard technical or
-  statistical analysis outputs, such as moving averages,
-  bands, or pricing models.
+Indicators are typically standard technical or statistical
+analysis outputs, such as moving averages, bands, or
+pricing models.
 }
 \details{
-  Indicators are always path-independent, and should be
-  constructed from vectorized functions where possible.
+Indicators are always path-independent, and should be
+constructed from vectorized functions where possible.
 
-  Indicators are applied before signals and rules, and the
-  output of indicators may be used as inputs to construct
-  signals or fire rules.
+Indicators are applied before signals and rules, and the
+output of indicators may be used as inputs to construct
+signals or fire rules.
 
-  \code{arguments} and \code{parameters} are named lists
-  that describe the arguments to be passed to the indicator
-  function. \code{arguments} is for defining any
-  non-default arguments to be passed to the function named
-  in the \code{name} of the indicator. For example, the
-  \code{x} argument to a moving average function may be
-  defined as \code{x=quote(Cl(mktdata))}
+\code{arguments} and \code{parameters} are named lists that
+describe the arguments to be passed to the indicator
+function. \code{arguments} is for defining any non-default
+arguments to be passed to the function named in the
+\code{name} of the indicator. For example, the \code{x}
+argument to a moving average function may be defined as
+\code{x=quote(Cl(mktdata))}
 
-  If you look at the demo scripts, you'll notice that we
-  often use \code{quote(mktdata)} in setting up indicators,
-  signals, or rules. This tells \R to delay evaluation via
-  \code{quote()}, and to use the special variable
-  \code{mktdata}.
+If you look at the demo scripts, you'll notice that we
+often use \code{quote(mktdata)} in setting up indicators,
+signals, or rules. This tells \R to delay evaluation via
+\code{quote()}, and to use the special variable
+\code{mktdata}.
 
-  \code{mktdata} is typically created internally to
-  \code{quantstrat} by looking in the global environment
-  for a time series of prices or returns. mktdata may also
-  contain other data you've manipulated outside quantstrat,
-  though where possible you should use quantstrat to
-  contain all the logic for the strategy, to aid in
-  maintenance and modifications.
+\code{mktdata} is typically created internally to
+\code{quantstrat} by looking in the global environment for
+a time series of prices or returns. mktdata may also
+contain other data you've manipulated outside quantstrat,
+though where possible you should use quantstrat to contain
+all the logic for the strategy, to aid in maintenance and
+modifications.
 
-  The use of \code{quote()} tells R to not evaluate what's
-  inside the quote until the function is evaluated later.
-  By the time that code is evaluated, \code{mktdata} will
-  be populated with the correct price information based on
-  the contents of whatever portfolio you are evaluating the
-  strategy on.
+The use of \code{quote()} tells R to not evaluate what's
+inside the quote until the function is evaluated later. By
+the time that code is evaluated, \code{mktdata} will be
+populated with the correct price information based on the
+contents of whatever portfolio you are evaluating the
+strategy on.
 
-  \code{parameters} is another named list, and normally
-  will not be needed. If you have multiple indicator,
-  signal, or rule functions share the that \emph{both}
-  share the same argument names \emph{and} will need to
-  have different values passed to those arguments as
-  defined parameters at apply-time, then you may need to
-  give them unique names so that delayed evaluation can
-  sort it all out for you at apply-time. We will endeavor
-  to get an example of named parameters into the demo
-  scripts.
+\code{parameters} is another named list, and normally will
+not be needed. If you have multiple indicator, signal, or
+rule functions share the that \emph{both} share the same
+argument names \emph{and} will need to have different
+values passed to those arguments as defined parameters at
+apply-time, then you may need to give them unique names so
+that delayed evaluation can sort it all out for you at
+apply-time. We will endeavor to get an example of named
+parameters into the demo scripts.
 
-  if \code{label} is not supplied, NULL default will be
-  converted to '<name>.ind' unless there already exists an
-  indicator with that label in which case it will be
-  appended with a number (i.e. '<name>.ind.2',
-  '<name>.ind.3', etc.). If the indicator function returns
-  multiple columns, the label will be \code{\link{paste}}'d
-  to the end of either the returned column names or the
-  respective column number when applying it to
-  \code{mktdata}.
+if \code{label} is not supplied, NULL default will be
+converted to '<name>.ind' unless there already exists an
+indicator with that label in which case it will be appended
+with a number (i.e. '<name>.ind.2', '<name>.ind.3', etc.).
+If the indicator function returns multiple columns, the
+label will be \code{\link{paste}}'d to the end of either
+the returned column names or the respective column number
+when applying it to \code{mktdata}.
 }
 \examples{
 \dontrun{
@@ -116,7 +113,7 @@
 }
 }
 \seealso{
-  \code{\link{quote}} \code{\link{applyIndicators}}
-  \code{\link{add.signal}} \code{link{add.rule}}
+\code{\link{quote}} \code{\link{applyIndicators}}
+\code{\link{add.signal}} \code{link{add.rule}}
 }
 

Modified: pkg/quantstrat/man/add.init.Rd
===================================================================
--- pkg/quantstrat/man/add.init.Rd	2014-03-29 15:18:31 UTC (rev 1593)
+++ pkg/quantstrat/man/add.init.Rd	2014-03-29 20:39:45 UTC (rev 1594)
@@ -2,9 +2,8 @@
 \alias{add.init}
 \title{add arbitrary initialization functions to a strategy}
 \usage{
-  add.init(strategy, name, arguments, parameters = NULL,
-    label = NULL, ..., enabled = TRUE, indexnum = NULL,
-    store = FALSE)
+add.init(strategy, name, arguments, parameters = NULL, label = NULL, ...,
+  enabled = TRUE, indexnum = NULL, store = FALSE)
 }
 \arguments{
   \item{strategy}{an object (or the name of an object) of
@@ -36,27 +35,26 @@
   the .strategy environment, or return it.  default FALSE}
 }
 \value{
-  if \code{strategy} was the name of a strategy, the name.
-  It it was a strategy, the updated strategy.
+if \code{strategy} was the name of a strategy, the name. It
+it was a strategy, the updated strategy.
 }
 \description{
-  \code{\link{initStrategy}} will run a series of common
-  initialization functions at the beginning of an
-  \code{\link{applyStrategy}} call.  This function allows
-  the user to add arbitrary initialization functions to the
-  sequence.
+\code{\link{initStrategy}} will run a series of common
+initialization functions at the beginning of an
+\code{\link{applyStrategy}} call.  This function allows the
+user to add arbitrary initialization functions to the
+sequence.
 }
 \details{
-  These arbitrary functions will be added to the
-  \code{init} slot of the strategy object and when
-  \code{applyStrategy} is evaluated, the arbitrary
-  initialization functions will be evaluated after the
-  standardized functions.
+These arbitrary functions will be added to the \code{init}
+slot of the strategy object and when \code{applyStrategy}
+is evaluated, the arbitrary initialization functions will
+be evaluated after the standardized functions.
 
-  For example, if your strategy uses a synthetic basket
-  instrument, you could use this initialization slot to add
-  a custom constructor to build the basket instrument time
-  series and modify the symbols slot(s) of the strategy and
-  portfolio.
+For example, if your strategy uses a synthetic basket
+instrument, you could use this initialization slot to add a
+custom constructor to build the basket instrument time
+series and modify the symbols slot(s) of the strategy and
+portfolio.
 }
 

Modified: pkg/quantstrat/man/add.rule.Rd
===================================================================
--- pkg/quantstrat/man/add.rule.Rd	2014-03-29 15:18:31 UTC (rev 1593)
+++ pkg/quantstrat/man/add.rule.Rd	2014-03-29 20:39:45 UTC (rev 1594)
@@ -2,12 +2,10 @@
 \alias{add.rule}
 \title{add a rule to a strategy}
 \usage{
-  add.rule(strategy, name, arguments, parameters = NULL,
-    label = NULL,
-    type = c(NULL, "risk", "order", "rebalance", "exit", "enter", "chain"),
-    parent = NULL, ..., enabled = TRUE, indexnum = NULL,
-    path.dep = TRUE, timespan = NULL, store = FALSE,
-    storefun = TRUE)
+add.rule(strategy, name, arguments, parameters = NULL, label = NULL,
+  type = c(NULL, "risk", "order", "rebalance", "exit", "enter", "chain"),
+  parent = NULL, ..., enabled = TRUE, indexnum = NULL, path.dep = TRUE,
+  timespan = NULL, store = FALSE, storefun = TRUE)
 }
 \arguments{
   \item{strategy}{an object of type 'strategy' to add the
@@ -55,88 +53,86 @@
   usable}
 }
 \value{
-  if \code{strategy} was the name of a strategy, the name.
-  It it was a strategy, the updated strategy.
+if \code{strategy} was the name of a strategy, the name. It
+it was a strategy, the updated strategy.
 }
 \description{
-  Rules will be processed in a very particular manner, so
-  it bears going over.
+Rules will be processed in a very particular manner, so it
+bears going over.
 }
 \details{
-  First, rules are either path dependent or
-  non-path-dependent.  Path dependent rules will be
-  processed in every time increment for the \code{mktdata}
-  passed into \code{\link{applyStrategy}}.  Non path
-  dependent rules will likely be quite rare in real life,
-  and will be applied after indicators and signals, and
-  before path-dependent rules are processed.
+First, rules are either path dependent or
+non-path-dependent.  Path dependent rules will be processed
+in every time increment for the \code{mktdata} passed into
+\code{\link{applyStrategy}}.  Non path dependent rules will
+likely be quite rare in real life, and will be applied
+after indicators and signals, and before path-dependent
+rules are processed.
 
-  All rules have a \code{type}.  These may be any of:
-  \describe{ \item{risk}{ rules that check and react to
-  risk of positions, may stop all other rule execution
-  temporarily or permanently} \item{order}{ rules for order
-  processing of any open orders at time t, always
-  path-dependent} \item{rebalance}{ rules executed
-  specifically in a portfolio context, unnecessary in
-  univariate strategies} \item{exit}{ rules to determine
-  whether to exit a position} \item{enter}{ rules to
-  determine whether to enter or increase a position}
-  \item{chain}{ rules executed upon fill of an order
-  corresponding to the label of the parent rule identified
-  by the \code{parent} arg. } }
+All rules have a \code{type}.  These may be any of:
+\describe{ \item{risk}{ rules that check and react to risk
+of positions, may stop all other rule execution temporarily
+or permanently} \item{order}{ rules for order processing of
+any open orders at time t, always path-dependent}
+\item{rebalance}{ rules executed specifically in a
+portfolio context, unnecessary in univariate strategies}
+\item{exit}{ rules to determine whether to exit a position}
+\item{enter}{ rules to determine whether to enter or
+increase a position} \item{chain}{ rules executed upon fill
+of an order corresponding to the label of the parent rule
+identified by the \code{parent} arg. } }
 
-  The rules will be executed by type, in the order listed
-  above. Multiple rules of each type may be defined, as
-  with signals and indicators, they will be executed in
-  order by index number with any other rules sharing the
-  same type.
+The rules will be executed by type, in the order listed
+above. Multiple rules of each type may be defined, as with
+signals and indicators, they will be executed in order by
+index number with any other rules sharing the same type.
 
-  The rule execution order was constructed because
-  path-dependent rules may modify the ability of rules that
-  have not fired yet to be evaluated.  For example, a risk
-  rule may flatten (close out) an entire position and put
-  new orders on hold, effectively stopping all further
-  execution of the strategy. Another example would be a
-  rebalancing rule function that would enter orders to
-  rebalance the portfolio, and would hold other strategy
-  processing until the rebalancing period was over.
+The rule execution order was constructed because
+path-dependent rules may modify the ability of rules that
+have not fired yet to be evaluated.  For example, a risk
+rule may flatten (close out) an entire position and put new
+orders on hold, effectively stopping all further execution
+of the strategy. Another example would be a rebalancing
+rule function that would enter orders to rebalance the
+portfolio, and would hold other strategy processing until
+the rebalancing period was over.
 
-  The \code{timespan} parameter will limit rule execution
-  by time of day using time based subsetting.  See ISO-8601
-  specification and xts documentation for more details.
-  Note that these are only applicable to intra-day
-  execution, and will remain that way barring patches
-  (tests and documentation) from interested parties.  The
-  subsetting may (will likely) work with normal ISO/xts
-  subset ranges, but consider it unsupported.
+The \code{timespan} parameter will limit rule execution by
+time of day using time based subsetting.  See ISO-8601
+specification and xts documentation for more details.  Note
+that these are only applicable to intra-day execution, and
+will remain that way barring patches (tests and
+documentation) from interested parties.  The subsetting may
+(will likely) work with normal ISO/xts subset ranges, but
+consider it unsupported.
 
-  The \code{name} parameter should be a character string
-  naming the function to be called in the
-  \code{\link{applyRules}} loop. The \code{add.rule}
-  function will then call \code{\link{match.fun}}, ands
-  store the actual function in your strategy object. This
-  will avoid lookups via \code{\link{match.fun}} at
-  \code{\link{applyRules}} time, and may provide a
-  significant speed increase on higher frequency data (20\%
-  or more).
[TRUNCATED]

To get the complete diff run:
    svnlook diff /svnroot/blotter -r 1594


More information about the Blotter-commits mailing list