[Blotter-commits] r557 - in pkg/blotter: . R man

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Thu Feb 17 16:08:26 CET 2011


Author: braverock
Date: 2011-02-17 16:08:26 +0100 (Thu, 17 Feb 2011)
New Revision: 557

Modified:
   pkg/blotter/DESCRIPTION
   pkg/blotter/NAMESPACE
   pkg/blotter/R/chart.Posn.R
   pkg/blotter/R/chart.Reconcile.R
   pkg/blotter/R/getPos.R
   pkg/blotter/R/tradeStats.R
   pkg/blotter/man/addDiv.Rd
   pkg/blotter/man/addTxn.Rd
   pkg/blotter/man/addTxns.Rd
   pkg/blotter/man/chart.Posn.Rd
   pkg/blotter/man/chart.Reconcile.Rd
   pkg/blotter/man/extractTxns.Rd
   pkg/blotter/man/getAccount.Rd
   pkg/blotter/man/getPos.Rd
   pkg/blotter/man/getTxns.Rd
   pkg/blotter/man/initPortf.Rd
   pkg/blotter/man/pennyPerShare.Rd
   pkg/blotter/man/tradeStats.Rd
Log:
- add Dates parameter support and slippage calcs to chart.Posn and chart.Reconcile
- bump xts requirement to 0.7-6.17 for TZ fixes
- bump package version to 0.8
- update roxygen docs

Modified: pkg/blotter/DESCRIPTION
===================================================================
--- pkg/blotter/DESCRIPTION	2011-02-11 17:58:25 UTC (rev 556)
+++ pkg/blotter/DESCRIPTION	2011-02-17 15:08:26 UTC (rev 557)
@@ -1,7 +1,7 @@
 Package: blotter
 Type: Package
 Title: Tools for transaction-oriented trading systems development.
-Version: 0.7.4.2
+Version: 0.8
 Date: $Date$
 Author: Peter Carl, Brian G. Peterson
 Maintainer: Brian G. Peterson <brian at braverock.com>
@@ -9,8 +9,12 @@
     Provides portfolio support for multi-asset class and multi-currency portfolios.  Still in heavy development.
 License: GPL
 LazyLoad: yes
-Depends: R (>= 2.11.1), xts (>= 0.7-6.8), quantmod (>= 0.3-14), FinancialInstrument
+Depends: R (>= 2.11.1), xts (>= xts_0.7-6.17), quantmod (>= 0.3-14), FinancialInstrument
 Suggests: PerformanceAnalytics, Hmisc, RUnit
 Contributors: Lance Levenson, Ben McCann, Joshua Ulrich, Wolfgang Wu,
 URL: https://r-forge.r-project.org/projects/blotter/
 Copyright: (c) 2008-2011
+Collate: 'addPortfInstr.R' 'addTxn.R' 'calcPortfWgt.R' 'calcPosAvgCost.R' 'calcTxnAvgCost.R' 'calcTxnValue.R' 'chart.Posn.R'
+    'chart.Reconcile.R' 'chart.Spread.R' 'extractTests.R' 'getAccount.R' 'getByPortf.R' 'getBySymbol.R' 'getEndEq.R' 'getPortfAcct.R'
+    'getPortfolio.R' 'getPosAvgCost.R' 'getPosQty.R' 'getPos.R' 'getTxn.R' 'initAcct.R' 'initPortf.R' 'initPosPL.R' 'initSummary.R' 'initTxn.R'
+    'PortfReturns.R' 'tradeStats.R' 'updateAcct.R' 'updateEndEq.R' 'updatePortf.R' 'updatePosPL.R'

Modified: pkg/blotter/NAMESPACE
===================================================================
--- pkg/blotter/NAMESPACE	2011-02-11 17:58:25 UTC (rev 556)
+++ pkg/blotter/NAMESPACE	2011-02-17 15:08:26 UTC (rev 557)
@@ -5,7 +5,6 @@
 export(chart.Posn)
 export(chart.Reconcile)
 export(chart.Spread)
-export(dailyStats)
 export(extractTxns)
 export(getAccount)
 export(getEndEq)

Modified: pkg/blotter/R/chart.Posn.R
===================================================================
--- pkg/blotter/R/chart.Posn.R	2011-02-11 17:58:25 UTC (rev 556)
+++ pkg/blotter/R/chart.Posn.R	2011-02-17 15:08:26 UTC (rev 557)
@@ -5,7 +5,7 @@
 #'
 #' @param Portfolio string identifying the portfolio to chart
 #' @param Symbol string identifying the symbol to chart
-#' @param Dates currently not used
+#' @param Dates xts ISO 8601 style subsetting
 #' @param \dots any other passthru parameters to \code{\link[quantmod]{chart_Series}}
 #' @export
 chart.Posn <- function(Portfolio, Symbol, Dates = NULL, ...)

Modified: pkg/blotter/R/chart.Reconcile.R
===================================================================
--- pkg/blotter/R/chart.Reconcile.R	2011-02-11 17:58:25 UTC (rev 556)
+++ pkg/blotter/R/chart.Reconcile.R	2011-02-17 15:08:26 UTC (rev 557)
@@ -3,25 +3,34 @@
 #' Produces a four-panel chart of time series charts that contains prices and transactions in the top panel, the resulting position in the second, a cumulative profit-loss line chart in the third.  
 #' The theoretical trades, positions, and P&L are plotted first, in the 'light' versions of the colors, and then the actual values are overplotted in the main color.  
 #' If they agree completely, the theoretical values will not be visible.  Differences will make themselves visible by misalignment of the symbols or lines. 
+#' 
 #' The fourth panel is the difference in P&L between the theoretical and actual values, and could be considered 'slippage', which could be positive or negative.  
-#' It is calculated by subtracting the theoretical P&L from the actual P&L.   
+#' It is calculated by subtracting the theoretical P&L from the actual P&L.  
+#' If parameter \code{PLdiff} is 'cumulative', then this panel will display the cumsum of difference between the theoretical and actual portfolios.
+#' If parameter \code{PLdiff} is 'episodic' it will display the differences in P&L    
 #'
+#' The \code{data} parameter allows the user to either \code{\link{View}} or \code{\link{return}} the data calculated inside the chart.  Default FALSE (only chart)
 #' 
 #' @param theoPort string identifying the theoretical portfolio to chart
 #' @param actualPort string identifying the actual portfolio to chart
 #' @param Symbol string identifying the symbol to chart
-#' @param Dates currently not used
+#' @param Dates xts ISO 8601 style subsetting 
 #' @param \dots any other passthru parameters to \code{\link[quantmod]{chart_Series}}
+#' @param PLdiff one of 'cumulative' or 'episodic', see Details.
+#' @param data what to do with the calculated data, see Details
 #' @seealso \code{\link{chart.Posn}}
 #' @export
 #' @note Expect changes to this function, since the underlying charts are experimental functions in quantmod.
-chart.Reconcile <- function(theoPort, actualPort, Symbol, Dates = NULL, ...)
+chart.Reconcile <- function(theoPort, actualPort, Symbol, Dates = NULL, ..., PLdiff=c('cumulative', 'episodic'),data=c(FALSE,'View','return'))
 { # @author Peter Carl, Brian G. Peterson
-    pname<-theoPort
-    aname<-actualPort
-    Portfolio<-getPortfolio(pname)
-    Actual<-getPortfolio(aname)
+    pname     <- theoPort
+    aname     <- actualPort
+    Portfolio <- getPortfolio(pname)
+    Actual    <- getPortfolio(aname)
     
+    PLdiff <- PLdiff[1]
+    data   <- data[1]
+
     # FUNCTION
 
     require(quantmod)
@@ -40,7 +49,8 @@
         n=round((freq$frequency/mult),0)*mult
     } else { n=mult }
     
-    tzero = xts(0,order.by=index(Prices[1,]))
+    tzero = xts(0,order.by=index(Prices[1,])) 
+    #uses the first column of Prices, hopefully unecessary, as getPrice should only have one col
 
     Trades = Portfolio$symbols[[Symbol]]$txn$Txn.Value
 	ATrades = Actual$symbols[[Symbol]]$txn$Txn.Value
@@ -59,12 +69,22 @@
     ActPosfill = na.locf(merge(ActPos,index(Prices)))
     ActCumPL = cumsum(Actual$symbols[[Symbol]]$posPL$Net.Trading.PL)
     
+    PLdifference<-NULL
+    PLslippage<-NULL
+    
     if(length(CumPL)>1){
         CumPL = na.locf(merge(CumPL,index(Prices)))
         ActCumPL = na.locf(merge(ActCumPL,index(Prices)))
         PLdifference=ActCumPL-CumPL
-    } else CumPL = NULL
-    
+        if(PLdiff=='episodic' | PLdiff == 'both'){
+            poschange<- ActPosfill-Positionfill
+            tmpidx<-index(poschange[!poschange==0])
+            PLslippage <- PLdifference[index(poschange[poschange!=0])]
+            #like drawdowns here? cumpl - cummax?  detect starting PL?
+        }
+    } else {
+        CumPL = NULL
+    }
     #     # These aren't quite right, as abs(Pos.Qty) should be less than prior abs(Pos.Qty)
     # SellCover = Portfolio$symbols[[Symbol]]$txn$Txn.Price * (Portfolio$symbols[[Symbol]]$txn$Txn.Qty<0) * (Portfolio$symbols[[Symbol]]$txn$Pos.Qty==0)
     # BuyCover = Portfolio$symbols[[Symbol]]$txn$Txn.Price * (Portfolio$symbols[[Symbol]]$txn$Txn.Qty>0) * (Portfolio$symbols[[Symbol]]$txn$Pos.Qty==0)
@@ -99,9 +119,22 @@
 		(add_TA(ActCumPL, col='darkgreen', lwd=2, on=3))
         if(!is.null(PLdifference)){
             (add_TA(PLdifference, col='lightsalmon', lwd=2))
-        }    
+        }  
+        if(!is.null(PLslippage)){
+            #TODO separate these into positive and negative slippage, and have green/red colors for them
+            (add_TA(PLslippage, col='lightsalmon', lwd=2))
+        }
     } 
     plot(current.chob())
+    
+    if(data!=FALSE){
+        output<-cbind(ActCumPL,CumPL,PLdifference,PLslippage,ActPosfill,Positionfill)
+        colnames(output) <- c('cumPL','theoCumPL','PLdiff','PLslippage','position','theo_position')
+        switch(data,
+               View = View(output),
+               return = return(output)
+       )
+    }
 }
 
 ###############################################################################

Modified: pkg/blotter/R/getPos.R
===================================================================
--- pkg/blotter/R/getPos.R	2011-02-11 17:58:25 UTC (rev 556)
+++ pkg/blotter/R/getPos.R	2011-02-17 15:08:26 UTC (rev 557)
@@ -13,11 +13,18 @@
     Portfolio<-getPortfolio(Portfolio)    
     # FUNCTION
     PosData = Portfolio$symbols[[Symbol]]$txn
-    toDate = paste('::', Date, sep="")
+    #toDate = paste('::', Date, sep="")
     # It may not make sense to return realized P&L with the position information, so only position and 
     # position average cost are returned.
-    if(nrow(PosData)>1) Pos = last(PosData[toDate][,Columns],n=n)
-    else Pos <- PosData[,Columns]
+    #if(nrow(PosData)>1) Pos = last(PosData[toDate][,Columns],n=n)
+    if(nrow(PosData)>1) {
+        if(is.timeBased(Date)){
+            Pos = last(PosData[index(PosData)<Date][,Columns],n=n)
+        } else {
+            toDate = paste('::', Date, sep="")
+            Pos = last(PosData[toDate][,Columns],n=n)
+        }
+    } else Pos <- PosData[,Columns]
     return(Pos)
 }
 

Modified: pkg/blotter/R/tradeStats.R
===================================================================
--- pkg/blotter/R/tradeStats.R	2011-02-11 17:58:25 UTC (rev 556)
+++ pkg/blotter/R/tradeStats.R	2011-02-17 15:08:26 UTC (rev 557)
@@ -30,8 +30,10 @@
 #' 
 #' WARNING: we're not sure this function is stable/complete yet.  If you're using it, please give us feedback!
 #' 
+#' @aliases dailyStats
 #' @param Portfolios portfolio string 
 #' @param Symbols character vector of symbol strings, default NULL
+#' @param uses for dailyStats, determines whether numbers are calculated from trades or equity curve
 #' @author Lance Levenson
 #' @export
 #' @note
@@ -250,6 +252,7 @@
     return(ret)
 }
 
+#' @export
 dailyStats <- function(Portfolios,use=c('Equity','Txns'))
 {
     use=use[1] #take the first value if the user didn't specify

Modified: pkg/blotter/man/addDiv.Rd
===================================================================
--- pkg/blotter/man/addDiv.Rd	2011-02-11 17:58:25 UTC (rev 556)
+++ pkg/blotter/man/addDiv.Rd	2011-02-17 15:08:26 UTC (rev 557)
@@ -7,11 +7,11 @@
 \note{# TODO add TxnTypes to $txn table
 
 # TODO add AsOfDate}
-\arguments{\item{Portfolio}{A portfolio name that points to a portfolio object structured with initPortf().}
-\item{Symbol}{An instrument identifier for a symbol included in the portfolio,e.g., IBM.}
+\arguments{\item{Portfolio}{A portfolio name that points to a portfolio object structured with \code{\link{initPortf}}.}
+\item{Symbol}{An instrument identifier for a symbol included in the portfolio, e.g., IBM.}
 \item{TxnDate}{Transaction date as ISO 8601, e.g., '2008-09-01' or '2010-01-05 09:54:23.12345'.}
 \item{DivPerShare}{The amount of the cash dividend paid per share or per unit quantity.}
 \item{\dots}{Any other passthrough parameters.}
-\item{TxnFees}{Fees associated with the transaction, e.g. commissions., See Details}
-\item{verbose}{If TRUE (default) the function prints the elements of the transaction in a line to the screen, e.g., "2007-01-08 IBM 50}
+\item{TxnFees}{Fees associated with the transaction, e.g. commissions. See Details.}
+\item{verbose}{If TRUE (default) the function prints the elements of the transaction in a line to the screen, e.g., "2007-01-08 IBM 50 \}
 \item{ConMult}{Contract or instrument multiplier for the Symbol if it is not dened in an instrument specication.}}

Modified: pkg/blotter/man/addTxn.Rd
===================================================================
--- pkg/blotter/man/addTxn.Rd	2011-02-11 17:58:25 UTC (rev 556)
+++ pkg/blotter/man/addTxn.Rd	2011-02-17 15:08:26 UTC (rev 557)
@@ -5,25 +5,26 @@
 \description{Add transactions to a portfolio.}
 \details{When a trade or adjustment is made to the Portfolio, the addTxn function 
 calculates the value and average cost of the transaction,  the change in 
-position, the resulting positions average cost, and any realized prot 
+position, the resulting positions average cost, and any realized profit 
 or loss (net of fees) from the transaction. Then it stores the transaction 
 and calculations in the Portfolio object.
 
 Fees are indicated as negative values and will be subtracted from the 
 transaction value. TxnFees can either be a fixed amount, or a function 
-of two arguments Qty and Price in which case the function is evaluated to 
-determine the fee amount.}
+in which case the function is evaluated to 
+determine the fee amount.
+The \code{pennyPerShare} function provides a simple example of a transaction cost
+function.}
 \note{The addTxn function will eventually also handle other transaction types, 
-such as adjustments for corporate actions or expire/assign for options. 
-The pennyPerShare function provides a simple example of a transaction cost function the user could supply.}
+such as adjustments for corporate actions or expire/assign for options.}
 \seealso{\code{\link{addTxns}}, \code{\link{pennyPerShare}}, \code{\link{initPortf}}}
 \author{Peter Carl}
-\arguments{\item{Portfolio}{A portfolio name that points to a portfolio object structured with initPortf()}
-\item{Symbol}{An instrument identifier for a symbol included in the portfolio,e.g., IBM}
+\arguments{\item{Portfolio}{A portfolio name that points to a portfolio object structured with \code{initPortf()}}
+\item{Symbol}{An instrument identifier for a symbol included in the portfolio, e.g., "IBM"}
 \item{TxnDate}{Transaction date as ISO 8601, e.g., '2008-09-01' or '2010-01-05 09:54:23.12345'}
 \item{TxnQty}{Total units (such as shares or contracts) transacted.  Positive values indicate a 'buy'; negative values indicate a 'sell'}
 \item{TxnPrice}{Price at which the transaction was done}
 \item{\dots}{Any other passthrough parameters}
 \item{TxnFees}{Fees associated with the transaction, e.g. commissions., See Details}
 \item{ConMult}{Contract/instrument multiplier for the Symbol if it is not dened in an instrument specication}
-\item{verbose}{If TRUE (default) the function prints the elements of the transaction in a line to the screen, e.g., "2007-01-08 IBM 50}}
+\item{verbose}{If TRUE (default) the function prints the elements of the transaction in a line to the screen, e.g., "2007-01-08 IBM 50 \}}

Modified: pkg/blotter/man/addTxns.Rd
===================================================================
--- pkg/blotter/man/addTxns.Rd	2011-02-11 17:58:25 UTC (rev 556)
+++ pkg/blotter/man/addTxns.Rd	2011-02-17 15:08:26 UTC (rev 557)
@@ -3,11 +3,11 @@
 \title{Add multiple transactions to a portfolio...}
 \usage{addTxns(Portfolio, Symbol, TxnData, verbose=TRUE, ..., ConMult)}
 \description{Add multiple transactions to a portfolio}
-\seealso{\code{\link{addTxn}}, \code{\link{initPortf}}
-TODO figure out if we can fully vectorize this function to make it faster}
-\arguments{\item{Portfolio}{A portfolio name that points to a portfolio object structured with initPortf()}
-\item{Symbol}{An instrument identifier for a symbol included in the portfolio,e.g., IBM}
+\seealso{\code{\link{addTxn}}, \code{\link{initPortf}}}
+\note{TODO figure out if we can fully vectorize this function to make it faster}
+\arguments{\item{Portfolio}{A portfolio name that points to a portfolio object structured with \code{\link{initPortf}}}
+\item{Symbol}{An instrument identifier for a symbol included in the portfolio, e.g., "IBM"}
 \item{TxnData}{An xts object containing all required txn fields}
 \item{\dots}{Any other passthrough parameters}
-\item{verbose}{If TRUE (default) the function prints the elements of the transaction in a line to the screen, e.g., "2007-01-08 IBM 50}
+\item{verbose}{If TRUE (default) the function prints the elements of the transaction in a line to the screen, e.g., "2007-01-08 IBM 50 \}
 \item{ConMult}{Contract or instrument multiplier for the Symbol if it is not dened in an instrument specication}}

Modified: pkg/blotter/man/chart.Posn.Rd
===================================================================
--- pkg/blotter/man/chart.Posn.Rd	2011-02-11 17:58:25 UTC (rev 556)
+++ pkg/blotter/man/chart.Posn.Rd	2011-02-17 15:08:26 UTC (rev 557)
@@ -1,9 +1,11 @@
 \name{chart.Posn}
 \alias{chart.Posn}
-\title{chart trades against market data, position through time, and equity curve...}
+\title{Chart trades against market data, position through time, and cumulative P\&L...}
 \usage{chart.Posn(Portfolio, Symbol, Dates, ...)}
-\description{chart trades against market data, position through time, and equity curve}
+\description{Chart trades against market data, position through time, and cumulative P\&L}
+\details{Produces a three-panel chart of time series charts that contains prices and transactions in the top panel, the resulting position in the second, and a cumulative profit-loss line chart in the third.}
+\note{Expect changes to this function, since the underlying charts are experimental functions in quantmod.}
 \arguments{\item{Portfolio}{string identifying the portfolio to chart}
 \item{Symbol}{string identifying the symbol to chart}
-\item{Dates}{date range, currently not used}
-\item{...}{any other passthru parameters (typically parameters to \code{chart_Series})}}
+\item{Dates}{xts ISO 8601 style subsetting}
+\item{\dots}{any other passthru parameters to \code{\link[quantmod]{chart_Series}}}}

Modified: pkg/blotter/man/chart.Reconcile.Rd
===================================================================
--- pkg/blotter/man/chart.Reconcile.Rd	2011-02-11 17:58:25 UTC (rev 556)
+++ pkg/blotter/man/chart.Reconcile.Rd	2011-02-17 15:08:26 UTC (rev 557)
@@ -1,17 +1,24 @@
 \name{chart.Reconcile}
 \alias{chart.Reconcile}
-\title{Chart trades against market data, position through time, and cumulative P\&L...}
-\usage{chart.Reconcile(theoPort, actualPort, Symbol, Dates, ...)}
+\title{Chart trades against market data, position through time, and cumulative PPLdiff is 'cumulative', then this panel will display the cumsum of difference between the theoretical and actual portfolios.}
+\usage{chart.Reconcile(theoPort, actualPort, Symbol, Dates, ..., PLdiff=c("cumulative", "episodic"), data=c(FALSE, "View", "return"))}
 \description{Chart trades against market data, position through time, and cumulative P\&L}
 \details{Produces a four-panel chart of time series charts that contains prices and transactions in the top panel, the resulting position in the second, a cumulative profit-loss line chart in the third.  
 The theoretical trades, positions, and P&L are plotted first, in the 'light' versions of the colors, and then the actual values are overplotted in the main color.  
 If they agree completely, the theoretical values will not be visible.  Differences will make themselves visible by misalignment of the symbols or lines. 
+
 The fourth panel is the difference in P&L between the theoretical and actual values, and could be considered 'slippage', which could be positive or negative.  
-It is calculated by subtracting the theoretical P&L from the actual P&L.}
+It is calculated by subtracting the theoretical P&L from the actual P&L.  
+If parameter \code{PLdiff} is 'cumulative', then this panel will display the cumsum of difference between the theoretical and actual portfolios.
+If parameter \code{PLdiff} is 'episodic' it will display the differences in P&L    
+
+The \code{data} parameter allows the user to either \code{\link{View}} or \code{\link{return}} the data calculated inside the chart.  Default FALSE (only chart)}
 \seealso{\code{\link{chart.Posn}}}
 \note{Expect changes to this function, since the underlying charts are experimental functions in quantmod.}
 \arguments{\item{theoPort}{string identifying the theoretical portfolio to chart}
 \item{actualPort}{string identifying the actual portfolio to chart}
 \item{Symbol}{string identifying the symbol to chart}
-\item{Dates}{currently not used}
-\item{\dots}{any other passthru parameters to \code{\link[quantmod]{chart_Series}}}}
+\item{Dates}{xts ISO 8601 style subsetting}
+\item{\dots}{any other passthru parameters to \code{\link[quantmod]{chart_Series}}}
+\item{PLdiff}{one of 'cumulative' or 'episodic', see Details.}
+\item{data}{what to do with the calculated data, see Details}}

Modified: pkg/blotter/man/extractTxns.Rd
===================================================================
--- pkg/blotter/man/extractTxns.Rd	2011-02-11 17:58:25 UTC (rev 556)
+++ pkg/blotter/man/extractTxns.Rd	2011-02-17 15:08:26 UTC (rev 557)
@@ -1,14 +1,15 @@
 \name{extractTxns}
 \alias{extractTxns}
-\title{extract transactions from a portfolio in a manner suitable for creating tests...}
+\title{Extract transactions from a portfolio...}
 \usage{extractTxns(Portfolio)}
-\description{extract transactions from a portfolio in a manner suitable for creating tests}
+\description{Extract transactions from a portfolio}
 \details{This function reverse-engineers \code{\link{addTxn}} calls for all the transactions in \code{Portfolio}.
 This is the fundamental task required to create a reproducible example, as it would replicate the 
-state of the $txn slot in the portfolio after each addTxn call.  
+state of the $txn slot in the portfolio after each \code{addTxn} call.  
 While market data, expected results, portfolio and account setup, etc, are also required, 
 these can usually be deduced or equivalent formulations can be found.  
 
-For transactions, only the exact addTxn parameters will recreate the $txn slot.  This function creates that reproducibility.}
-\value{string vector of \code{\link{addTxn}} calls that would replicate the given portfolio}
+For transactions, only the exact \code{addTxn} parameters will recreate the $txn slot.  This function creates that reproducibility, since the result (stored in 'x') can be used to regenerate transactions with \code{eval(parse(text=x))}.}
+\value{String vector of \code{\link{addTxn}} calls that would replicate the given portfolio.}
+\author{Brian G. Peterson, Josh Ulrich}
 \arguments{\item{Portfolio}{string identifying the portfolio to extract from}}

Modified: pkg/blotter/man/getAccount.Rd
===================================================================
--- pkg/blotter/man/getAccount.Rd	2011-02-11 17:58:25 UTC (rev 556)
+++ pkg/blotter/man/getAccount.Rd	2011-02-17 15:08:26 UTC (rev 557)
@@ -1,8 +1,8 @@
 \name{getAccount}
 \alias{getAccount}
-\title{get an account object from the environment for examination or manipulation...}
-\usage{getAccount(Account, Dates)}
-\description{get an account object from the environment for examination or manipulation}
+\title{Get an account object from the...}
+\usage{getAccount(Account)}
+\description{Get an account object from the .blotter environment}
+\details{Retrieves an account object from the \code{.blotter} environment.  Useful for local examination or charting, or storing interim results for later reference.}
 \value{Account object}
-\arguments{\item{Account}{string identifier for the account}
-\item{Dates}{}}
+\arguments{\item{Account}{string identifier for the account}}

Modified: pkg/blotter/man/getPos.Rd
===================================================================
--- pkg/blotter/man/getPos.Rd	2011-02-11 17:58:25 UTC (rev 556)
+++ pkg/blotter/man/getPos.Rd	2011-02-17 15:08:26 UTC (rev 557)
@@ -1,10 +1,12 @@
 \name{getPos}
 \alias{getPos}
 \title{Retrieves all information about the position as of a date...}
-\usage{getPos(Portfolio, Symbol, Date)}
+\usage{getPos(Portfolio, Symbol, Date, Columns=c("Pos.Qty", "Pos.Avg.Cost"), n=1)}
 \description{Retrieves all information about the position as of a date}
 \details{NOTE This could get much more complicated from here, particularly when it's conditional on symbol, etc.}
 \value{All data elements related to position in a row of an xts object}
 \arguments{\item{Portfolio}{string identifying a portfolio object containing transactions}
 \item{Symbol}{an instrument identifier for a symbol included in the portfolio}
-\item{Date}{timestamp as of which to have the most recent position}}
+\item{Date}{timestamp as of which to have the most recent position}
+\item{Columns}{which columns to return from the \code{txn} slot in the portfolio}
+\item{n}{number of periods to return, default 1}}

Modified: pkg/blotter/man/getTxns.Rd
===================================================================
--- pkg/blotter/man/getTxns.Rd	2011-02-11 17:58:25 UTC (rev 556)
+++ pkg/blotter/man/getTxns.Rd	2011-02-17 15:08:26 UTC (rev 557)
@@ -1,12 +1,13 @@
 \name{getTxns}
 \alias{getTxns}
-\title{Retrieves the transactions and their attributes.}
-\usage{getTxns(Portfolio, Symbol, Date)}
-\description{Retrieves the transactions and their attributes.}
+\title{Retrieve transactions and their attributes.}
+\usage{getTxns(Portfolio, Symbol, Dates)}
+\description{Retrieve transactions and their attributes.}
 \details{Find and return the transactions and attribute values for the symbol and date in a specied portfolio.
 
-This function provides easy access to the values of transactions contained in a Portfolio object. See initPortf for a detailed description of the structure of a Portfolio object.}
-\value{xts of transactions made in the Symbol during the time period given}
+This function provides easy access to the values of transactions contained in a Portfolio object. See \code{\link{initPortf}} for a detailed description of the structure of a Portfolio object.}
+\value{xts time series of transactions made in the Symbol during the time period given}
+\seealso{\code{\link{initPortf}}}
 \arguments{\item{Portfolio}{a string identifying a portfolio object containing transactions}
 \item{Symbol}{an instrument identifier for a symbol included in the portfolio}
-\item{Date}{timestamp as of which to get transactions}}
+\item{Dates}{specified as an ISO 8601 date or an xts date range, such as "2007-01::2008-04-15"}}

Modified: pkg/blotter/man/initPortf.Rd
===================================================================
--- pkg/blotter/man/initPortf.Rd	2011-02-11 17:58:25 UTC (rev 556)
+++ pkg/blotter/man/initPortf.Rd	2011-02-17 15:08:26 UTC (rev 557)
@@ -45,7 +45,7 @@
 \item Gross.Value: The sum of the notional long and absolute value of the notional short value of the portfolio.
 \item Txn.Fees: The sum of brokerage commissions, exchange and other brokerage fees paid by the portfolio during the period.
 \item Realized.PL: The sum of net realized prots or losses aggregated from the underlying positions in the portfolio. Gross realized prots can be calculated by adding Txn.Fees, the brokerage commission expenses for the period.
-\item Unrealized.PL: The sum total increase or decrease in unrealized prots or losses on open positions in the portfolio at the end of the period.
+\item Unrealized.PL: The sum total increase or decrease in unrealized profits or losses on open positions in the portfolio at the end of the period.
 \item Net.Trading.PL: Net realized prot or loss plus interest income plus change in unrealized prot or loss across all positions in the portfolio.
 }
 TODO: add $account: name of the (one) affiliated account

Modified: pkg/blotter/man/pennyPerShare.Rd
===================================================================
--- pkg/blotter/man/pennyPerShare.Rd	2011-02-11 17:58:25 UTC (rev 556)
+++ pkg/blotter/man/pennyPerShare.Rd	2011-02-17 15:08:26 UTC (rev 557)
@@ -1,7 +1,7 @@
 \name{pennyPerShare}
 \alias{pennyPerShare}
-\title{example TxnFee cost function...}
+\title{Example TxnFee cost function...}
 \usage{pennyPerShare(TxnQty)}
-\description{example TxnFee cost function}
+\description{Example TxnFee cost function}
 \arguments{\item{TxnQty}{total units (such as shares or contracts) transacted.  Positive values indicate a 'buy'; negative values indicate a 'sell'
 This is an example intended to demonstrate how a cost function could be used in place of a flat numeric fee.}}

Modified: pkg/blotter/man/tradeStats.Rd
===================================================================
--- pkg/blotter/man/tradeStats.Rd	2011-02-11 17:58:25 UTC (rev 556)
+++ pkg/blotter/man/tradeStats.Rd	2011-02-17 15:08:26 UTC (rev 557)
@@ -1,5 +1,4 @@
 \name{tradeStats}
-\alias{tradeStats}
 \title{calculate statistics on transactions and P&L for a symbol or symbols in a portfolio or portfolios...}
 \usage{tradeStats(Portfolios, Symbols)}
 \description{calculate statistics on transactions and P&L for a symbol or symbols in a portfolio or portfolios}
@@ -31,7 +30,22 @@
 }  
 
 WARNING: we're not sure this function is stable/complete yet.  If you're using it, please give us feedback!}
+\alias{dailyStats}
 \author{Lance Levenson}
-\note{TODO document each statistic included in this function, with equations}
+\note{TODO document each statistic included in this function, with equations 
+
+TODO add more stats, potentially
+PerformanceAnalytics: skewness, kurtosis, upside/downside semidieviation, Sharpe/Sortino
+
+mean absolute deviation stats
+
+more Tharpe/Kestner/Tradestation stats, e.g.
+K-factor
+RINA Index
+Percent time in the market
+Buy and hold return
+
+Josh has suggested adding %-return based stats too}
 \arguments{\item{Portfolios}{portfolio string}
-\item{Symbols}{character vector of symbol strings, default NULL}}
+\item{Symbols}{character vector of symbol strings, default NULL}
+\item{uses}{for dailyStats, determines whether numbers are calculated from trades or equity curve}}



More information about the Blotter-commits mailing list