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

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Sun Sep 22 21:05:30 CEST 2013


Author: braverock
Date: 2013-09-22 21:05:29 +0200 (Sun, 22 Sep 2013)
New Revision: 1509

Added:
   pkg/quantstrat/man/get.strategy.Rd
Removed:
   pkg/quantstrat/man/getStrategy.Rd
Modified:
   pkg/quantstrat/DESCRIPTION
   pkg/quantstrat/NAMESPACE
   pkg/quantstrat/R/orders.R
   pkg/quantstrat/R/strategy.R
   pkg/quantstrat/man/getOrderBook.Rd
Log:
- create aliases for come camelCase fns to create more standardization
- clean up some formatting and doc errors


Modified: pkg/quantstrat/DESCRIPTION
===================================================================
--- pkg/quantstrat/DESCRIPTION	2013-09-19 21:22:29 UTC (rev 1508)
+++ pkg/quantstrat/DESCRIPTION	2013-09-22 19:05:29 UTC (rev 1509)
@@ -1,7 +1,7 @@
 Package: quantstrat
 Type: Package
 Title: Quantitative Strategy Model Framework
-Version: 0.7.8
+Version: 0.7.9
 Date: $Date$
 Author: Peter Carl, Brian G. Peterson, Joshua Ulrich, Jan Humme
 Depends:
@@ -15,31 +15,8 @@
 Maintainer: Brian G. Peterson <brian at braverock.com>
 Description: Specify, build, and back-test quantitative
     financial trading and portfolio strategies
-Contributors: Yu Chen, Joe Dunn, Dirk Eddelbuettel, Jeffrey A. Ryan, Garrett
-    See, Jan Humme
+Contributors: Yu Chen, Joe Dunn, Dirk Eddelbuettel, 
+    Jeffrey A. Ryan, Garrett See
 LazyLoad: yes
 License: GPL-3
 ByteCompile: TRUE
-Collate:
-    'applyStrategy.rebalancing.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'
-    'utils.R'
-    'walk.forward.R'
-    'wrapup.R'
-    'tradeOrderStats.R'
-    'chart.forward.R'

Modified: pkg/quantstrat/NAMESPACE
===================================================================
--- pkg/quantstrat/NAMESPACE	2013-09-19 21:22:29 UTC (rev 1508)
+++ pkg/quantstrat/NAMESPACE	2013-09-22 19:05:29 UTC (rev 1509)
@@ -1,5 +1,5 @@
+export(add.distribution)
 export(add.distribution.constraint)
-export(add.distribution)
 export(add.indicator)
 export(add.init)
 export(add.rule)
@@ -11,17 +11,17 @@
 export(applyParameter)
 export(applyRules)
 export(applySignals)
+export(applyStrategy)
 export(applyStrategy.rebalancing)
-export(applyStrategy)
+export(chart.forward)
 export(chart.forward.training)
-export(chart.forward)
 export(delete.paramset)
 export(enable.rule)
-export(getOrderBook)
+export(get.orderbook)
+export(get.strategy)
 export(getOrders)
 export(getParameterTable)
 export(getPosLimit)
-export(getStrategy)
 export(initOrders)
 export(initStrategy)
 export(is.strategy)

Modified: pkg/quantstrat/R/orders.R
===================================================================
--- pkg/quantstrat/R/orders.R	2013-09-19 21:22:29 UTC (rev 1508)
+++ pkg/quantstrat/R/orders.R	2013-09-22 19:05:29 UTC (rev 1509)
@@ -20,9 +20,13 @@
 #' 		\item{Order.Set}{}
 #' 		\item{Txn.Fees}{}
 #' 		\item{Rule}{}
-#' }         
+#' }   
+#' @aliases
+#' get.orderbook
+#' getOrderbook
+#' @rdname getOrderBook      
 #' @export
-getOrderBook <- function(portfolio, envir=.strategy) #should symbol subsets be supported too?  probably not.
+get.orderbook <- getOrderBook <- function(portfolio, envir=.strategy) #should symbol subsets be supported too?  probably not.
 { 
     if(!grepl("order_book",portfolio)) orders<-try(get(paste("order_book",portfolio,sep='.'),envir=envir),silent=TRUE)
     else orders<-try(get(portfolio,envir=envir),silent=TRUE)
@@ -39,7 +43,6 @@
 #' @seealso getOrderBook
 #' @concept order book
 #' @export
-
 put.orderbook <- function(portfolio.st, orderbook, envir=.strategy)
 {
     strategy.orderbook.st <- paste('order_book', portfolio.st, sep='.')
@@ -47,18 +50,6 @@
     assign(strategy.orderbook.st, orderbook, envir=envir)
 }
 
-###############################################################################
-# Blotter: Tools for transaction-oriented trading systems development
-# for R (see http://r-project.org/) 
-# Copyright (c) 2008-2011 Peter Carl and Brian G. Peterson
-#
-# This library is distributed under the terms of the GNU Public License (GPL)
-# for full details see the file COPYING
-#
-# $Id$
-#
-###############################################################################
-
 #' initialize order container
 #' 
 #' This function sets up the order container by portfolio.

Modified: pkg/quantstrat/R/strategy.R
===================================================================
--- pkg/quantstrat/R/strategy.R	2013-09-19 21:22:29 UTC (rev 1508)
+++ pkg/quantstrat/R/strategy.R	2013-09-22 19:05:29 UTC (rev 1509)
@@ -116,51 +116,53 @@
 	
     for (portfolio in portfolios) {
         
-		# TODO call to initStrategy will go here!
-        if(isTRUE(initStrat)) initStrategy(strategy=strategy, portfolio, symbols, ...=...)
+		  # call initStrategy
+      if(isTRUE(initStrat)) initStrategy(strategy=strategy, portfolio, symbols, ...=...)
         
    		ret[[portfolio]]<-list() # this is slot [[i]] which we will use later
-        pobj<-getPortfolio(portfolio)
-        symbols<- ls(pobj$symbols)
-        sret<-list()
-        for (symbol in symbols){
-            if(isTRUE(load.mktdata)) mktdata <- get(symbol)
+      pobj<-getPortfolio(portfolio)
+      symbols<- ls(pobj$symbols)
+      sret<-list()
+      for (symbol in symbols){
+        if(isTRUE(load.mktdata)) mktdata <- get(symbol)
+        
+        # loop over indicators
+        sret$indicators <- applyIndicators(strategy=strategy , mktdata=mktdata , parameters=parameters, ... )
+        
+        if(inherits(sret$indicators,"xts") & nrow(mktdata)==nrow(sret$indicators)){
+          mktdata<-sret$indicators
+        }
+        
+        # loop over signal generators
+        sret$signals <- applySignals(strategy=strategy, mktdata=mktdata, sret$indicators, parameters=parameters, ... )
 
-            #loop over indicators
-            sret$indicators <- applyIndicators(strategy=strategy , mktdata=mktdata , parameters=parameters, ... )
-            #this should be taken care of by the mktdata<<-mktdata line in the apply* fn
-            if(inherits(sret$indicators,"xts") & nrow(mktdata)==nrow(sret$indicators)){
-                mktdata<-sret$indicators
-            }
-            
-            #loop over signal generators
-            sret$signals <- applySignals(strategy=strategy, mktdata=mktdata, sret$indicators, parameters=parameters, ... )
-            #this should be taken care of by the mktdata<<-mktdata line in the apply* fn
-            if(inherits(sret$signals,"xts") & nrow(mktdata)==nrow(sret$signals)){
-                mktdata<-sret$signals    
-            }
-            
-            #loop over rules  
-            sret$rules<-list()
-			
-			## only fire nonpath/pathdep when true 
-			## TODO make this more elegant
-			pd <- FALSE
-			for(i in 1:length(strategy$rules)){	if(length(strategy$rules[[i]])!=0){z <- strategy$rules[[i]]; if(z[[1]]$path.dep==TRUE){pd <- TRUE}}}
-				
-            sret$rules$nonpath<-applyRules(portfolio=portfolio, symbol=symbol, strategy=strategy, mktdata=mktdata, Dates=NULL, indicators=sret$indicators, signals=sret$signals, parameters=parameters,  ..., path.dep=FALSE)
-			
-			## Check for open orders
-			rem.orders <- suppressWarnings(getOrders(portfolio=portfolio, symbol=symbol, status="open")) #, timespan=timespan, ordertype=ordertype,which.i=TRUE)
-			if(NROW(rem.orders)>0){pd <- TRUE}
-            if(pd==TRUE){sret$rules$pathdep<-applyRules(portfolio=portfolio, symbol=symbol, strategy=strategy, mktdata=mktdata, Dates=NULL, indicators=sret$indicators, signals=sret$signals, parameters=parameters,  ..., path.dep=TRUE)}
-
-			ret[[portfolio]][[symbol]]<-sret
-		}
+        if(inherits(sret$signals,"xts") & nrow(mktdata)==nrow(sret$signals)){
+          mktdata<-sret$signals    
+        }
         
-        # TODO call to updateStrategy will go here!
-        if(isTRUE(updateStrat)) updateStrategy(strategy, portfolio, Symbols=symbols, ...=...)
+        #loop over rules  
+        sret$rules<-list()
         
+        # only fire nonpath/pathdep when true 
+        # TODO make this more elegant
+        pd <- FALSE
+        for(i in 1:length(strategy$rules)){  
+          if(length(strategy$rules[[i]])!=0){z <- strategy$rules[[i]]; if(z[[1]]$path.dep==TRUE){pd <- TRUE}}
+        }
+        
+        sret$rules$nonpath<-applyRules(portfolio=portfolio, symbol=symbol, strategy=strategy, mktdata=mktdata, Dates=NULL, indicators=sret$indicators, signals=sret$signals, parameters=parameters,  ..., path.dep=FALSE)
+        
+        # Check for open orders
+        rem.orders <- suppressWarnings(getOrders(portfolio=portfolio, symbol=symbol, status="open")) #, timespan=timespan, ordertype=ordertype,which.i=TRUE)
+        if(NROW(rem.orders)>0){pd <- TRUE}
+        if(pd==TRUE){sret$rules$pathdep<-applyRules(portfolio=portfolio, symbol=symbol, strategy=strategy, mktdata=mktdata, Dates=NULL, indicators=sret$indicators, signals=sret$signals, parameters=parameters,  ..., path.dep=TRUE)}
+        
+        ret[[portfolio]][[symbol]]<-sret
+      }
+      
+      # call updateStrategy
+      if(isTRUE(updateStrat)) updateStrategy(strategy, portfolio, Symbols=symbols, ...=...)
+      
     }
     
     if(verbose) return(ret)
@@ -176,8 +178,12 @@
 #' retrieve strategy from the container environment
 #' @param x string name of object to be retrieved
 #' @param envir the environment to retrieve the strategy object from, defaults to .strategy
+#' @rdname get.strategy
+#' @aliases
+#' get.strategy
+#' getStrategy
 #' @export
-getStrategy <- function(x, envir=.strategy){
+get.strategy <- getStrategy <- function(x, envir=.strategy){
     tmp_strat<-get(as.character(x),pos=envir, inherits=TRUE)
     if( inherits(tmp_strat,"try-error") | !is.strategy(tmp_strat) ) {
         warning(paste("Strategy",x," not found, please create it first."))

Copied: pkg/quantstrat/man/get.strategy.Rd (from rev 1499, pkg/quantstrat/man/getStrategy.Rd)
===================================================================
--- pkg/quantstrat/man/get.strategy.Rd	                        (rev 0)
+++ pkg/quantstrat/man/get.strategy.Rd	2013-09-22 19:05:29 UTC (rev 1509)
@@ -0,0 +1,17 @@
+\name{get.strategy}
+\alias{get.strategy}
+\alias{getStrategy}
+\title{retrieve strategy from the container environment}
+\usage{
+  get.strategy(x, envir = .strategy)
+}
+\arguments{
+  \item{x}{string name of object to be retrieved}
+
+  \item{envir}{the environment to retrieve the strategy
+  object from, defaults to .strategy}
+}
+\description{
+  retrieve strategy from the container environment
+}
+

Modified: pkg/quantstrat/man/getOrderBook.Rd
===================================================================
--- pkg/quantstrat/man/getOrderBook.Rd	2013-09-19 21:22:29 UTC (rev 1508)
+++ pkg/quantstrat/man/getOrderBook.Rd	2013-09-22 19:05:29 UTC (rev 1509)
@@ -1,8 +1,9 @@
-\name{getOrderBook}
-\alias{getOrderBook}
+\name{get.orderbook}
+\alias{get.orderbook}
+\alias{getOrderbook}
 \title{get the order book object}
 \usage{
-  getOrderBook(portfolio, envir = .strategy)
+  get.orderbook(portfolio, envir = .strategy)
 }
 \arguments{
   \item{portfolio}{text name of the portfolio the order

Deleted: pkg/quantstrat/man/getStrategy.Rd
===================================================================
--- pkg/quantstrat/man/getStrategy.Rd	2013-09-19 21:22:29 UTC (rev 1508)
+++ pkg/quantstrat/man/getStrategy.Rd	2013-09-22 19:05:29 UTC (rev 1509)
@@ -1,16 +0,0 @@
-\name{getStrategy}
-\alias{getStrategy}
-\title{retrieve strategy from the container environment}
-\usage{
-  getStrategy(x, envir = .strategy)
-}
-\arguments{
-  \item{x}{string name of object to be retrieved}
-
-  \item{envir}{the environment to retrieve the strategy
-  object from, defaults to .strategy}
-}
-\description{
-  retrieve strategy from the container environment
-}
-



More information about the Blotter-commits mailing list