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

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Fri Dec 31 16:45:38 CET 2010


Author: braverock
Date: 2010-12-31 16:45:37 +0100 (Fri, 31 Dec 2010)
New Revision: 513

Added:
   pkg/blotter/man/calcPortfAttr.Rd
   pkg/blotter/man/dailyEqPL.Rd
   pkg/blotter/man/dailyTxnPL.Rd
   pkg/blotter/man/getByPortf.Rd
   pkg/blotter/man/getBySymbol.Rd
   pkg/blotter/man/getPortfAcct.Rd
   pkg/blotter/man/getPosAvgCost.Rd
   pkg/blotter/man/initPosPL.Rd
   pkg/blotter/man/initSummary.Rd
   pkg/blotter/man/initTxn.Rd
   pkg/blotter/man/tradeStats.Rd
   pkg/blotter/man/updatePosPL.Rd
Removed:
   pkg/blotter/man/.calcPortfAttr.Rd
   pkg/blotter/man/.getByPortf.Rd
   pkg/blotter/man/.getBySymbol.Rd
   pkg/blotter/man/.getPortfAcct.Rd
   pkg/blotter/man/.getPosAvgCost.Rd
   pkg/blotter/man/.initPosPL.Rd
   pkg/blotter/man/.initSummary.Rd
   pkg/blotter/man/.initTxn.Rd
   pkg/blotter/man/.onLoad.Rd
   pkg/blotter/man/.updatePosPL.Rd
Modified:
   pkg/blotter/DESCRIPTION
   pkg/blotter/NAMESPACE
   pkg/blotter/R/PortfReturns.R
   pkg/blotter/R/addTxn.R
   pkg/blotter/R/getTxn.R
   pkg/blotter/R/initAcct.R
   pkg/blotter/R/initPortf.R
   pkg/blotter/R/tradeStats.R
   pkg/blotter/man/PortfReturns.Rd
   pkg/blotter/man/addDiv.Rd
   pkg/blotter/man/addTxn.Rd
   pkg/blotter/man/addTxns.Rd
   pkg/blotter/man/calcPortfWgt.Rd
   pkg/blotter/man/getTxns.Rd
   pkg/blotter/man/initAcct.Rd
   pkg/blotter/man/initPortf.Rd
   pkg/blotter/man/updatePortf.Rd
Log:
- add additional daily trade stats functions
- update roxygen documentation
- remove non-ASCII/UTF-8 characters that were preventing PDF build
- bump version

Modified: pkg/blotter/DESCRIPTION
===================================================================
--- pkg/blotter/DESCRIPTION	2010-12-30 21:21:45 UTC (rev 512)
+++ pkg/blotter/DESCRIPTION	2010-12-31 15:45:37 UTC (rev 513)
@@ -1,27 +1,16 @@
 Package: blotter
 Type: Package
 Title: Tools for transaction-oriented trading systems development.
-Version: 0.7.3
+Version: 0.7.4
 Date: $Date$
 Author: Peter Carl, Brian G. Peterson, Joshua Ulrich
 Maintainer: Brian G. Peterson <brian at braverock.com>
-Description: Transaction infrastructure for defining instruments,
-    transactions, portfolios and accounts for trading systems and
-    simulation.  Provides portfolio support for multi-asset class and
-    multi-currency portfolios.  Still in heavy development.
+Description: Transaction infrastructure for defining instruments, transactions, portfolios and accounts for trading systems and simulation.
+    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 (>= 0.7-6.8), quantmod (>= 0.3-14), FinancialInstrument
 Suggests: PerformanceAnalytics, PortfolioAnalytics, Hmisc, RUnit
 Contributors: Wolfgang Wu, Ben McCann
 URL: https://r-forge.r-project.org/projects/blotter/
 Copyright: (c) 2008-2010
-Collate: 'addPortfInstr.R' 'addTxn.R' 'calcPortfAttr.R'
-    'calcPortfSummary.R' 'calcPortfWgt.R' 'calcPosAvgCost.R'
-    'calcTxnAvgCost.R' 'calcTxnValue.R' 'chart.Posn.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'
-    'updateAcct.R' 'updateEndEq.R' 'updatePortf.R' 'updatePosPL.R'

Modified: pkg/blotter/NAMESPACE
===================================================================
--- pkg/blotter/NAMESPACE	2010-12-30 21:21:45 UTC (rev 512)
+++ pkg/blotter/NAMESPACE	2010-12-31 15:45:37 UTC (rev 513)
@@ -14,7 +14,9 @@
 export(initAcct)
 export(initPortf)
 export(PortfReturns)
+export(tradeStats)
+export(dailyTxnPL)
+export(dailyEqPL)
 export(updateAcct)
 export(updateEndEq)
 export(updatePortf)
-export(tradeStats)

Modified: pkg/blotter/R/PortfReturns.R
===================================================================
--- pkg/blotter/R/PortfReturns.R	2010-12-30 21:21:45 UTC (rev 512)
+++ pkg/blotter/R/PortfReturns.R	2010-12-31 15:45:37 UTC (rev 513)
@@ -5,12 +5,13 @@
 #' to return on capital of each portfolio, or of the entire account.
 #' 
 #' This function exists because of R/Finance community requests by Mark Breman and Thomas Bolton 
+#' @export
 #' @param Account string name of the account to generate returns for
 #' @param method for now, only 'contribution' is supported
 #' @param \dots any other passthru parameters (like \code{native} for \code{.getBySymbol}
 #' @param Dates xts style ISO 8601 date subset to retrieve, default NULL (all dates)
 #' @param Portfolios concatenated string vector for portfolio names to retrieve returns on, default NULL (all portfolios)
-#' @export
+#' @note
 #' TODO handle portfolio and account in different currencies (not hard, just not done)
 #' 
 #' TODO explicitly handle portfolio weights

Modified: pkg/blotter/R/addTxn.R
===================================================================
--- pkg/blotter/R/addTxn.R	2010-12-30 21:21:45 UTC (rev 512)
+++ pkg/blotter/R/addTxn.R	2010-12-31 15:45:37 UTC (rev 513)
@@ -1,8 +1,15 @@
 #' Add transactions to a portfolio.
 #' 
-#' 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 position’s 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.
+#' 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 
+#' 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.
+#' 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.
 #' 
 #' @param Portfolio  A portfolio name that points to a portfolio object structured with initPortf()
 #' @param Symbol An instrument identifier for a symbol included in the portfolio,e.g., IBM
@@ -11,9 +18,12 @@
 #' @param TxnPrice  Price at which the transaction was done
 #' @param \dots Any other passthrough parameters
 #' @param TxnFees Fees associated with the transaction, e.g. commissions., See Details
-#' @param ConMult Contract/instrument multiplier for the Symbol if it is not defined in an instrument specification
+#' @param ConMult Contract/instrument multiplier for the Symbol if it is not dened in an instrument specication
 #' @param 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 @ 77.6". Suppress using FALSE.
-#' @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.
+#' @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.
 #' @seealso \code{\link{addTxns}}, \code{\link{pennyPerShare}}, \code{\link{initPortf}}
 #' @author Peter Carl
 #' @export
@@ -96,7 +106,7 @@
 #' @param TxnData  An xts object containing all required txn fields
 #' @param \dots Any other passthrough parameters
 #' @param 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 @ 77.6". Suppress using FALSE.
-#' @param ConMult Contract or instrument multiplier for the Symbol if it is not defined in an instrument specification
+#' @param ConMult Contract or instrument multiplier for the Symbol if it is not dened in an instrument specication
 #' @seealso \code{\link{addTxn}}, \code{\link{initPortf}}
 #' TODO figure out if we can fully vectorize this function to make it faster
 addTxns<- function(Portfolio, Symbol, TxnData , verbose=TRUE, ..., ConMult=NULL)
@@ -171,8 +181,9 @@
 #' @param \dots Any other passthrough parameters.
 #' @param TxnFees Fees associated with the transaction, e.g. commissions., See Details
 #' @param 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 @ 77.6". Suppress using FALSE.
-#' @param ConMult Contract or instrument multiplier for the Symbol if it is not defined in an instrument specification.
+#' @param ConMult Contract or instrument multiplier for the Symbol if it is not dened in an instrument specication.
 #' @export
+#' @note
 #' # TODO add TxnTypes to $txn table
 #' 
 #' # TODO add AsOfDate 

Modified: pkg/blotter/R/getTxn.R
===================================================================
--- pkg/blotter/R/getTxn.R	2010-12-30 21:21:45 UTC (rev 512)
+++ pkg/blotter/R/getTxn.R	2010-12-31 15:45:37 UTC (rev 513)
@@ -1,6 +1,6 @@
 #' Retrieves the transactions and their attributes.
 #'
-#' Find and return the transactions and attribute values for the symbol and date in a specified portfolio.
+#' 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.
 #'

Modified: pkg/blotter/R/initAcct.R
===================================================================
--- pkg/blotter/R/initAcct.R	2010-12-30 21:21:45 UTC (rev 512)
+++ pkg/blotter/R/initAcct.R	2010-12-31 15:45:37 UTC (rev 513)
@@ -40,6 +40,7 @@
 #' @param initEq initial account equity in the currency of the portfolio, as a floating point number.
 #' @param \dots any other passthrough parameters  
 #' @export
+#' @note
 #' TODO Add calcPeriodROR function
 #' 
 #' TODO Adddd functions addCapital, drawCapital, addFees

Modified: pkg/blotter/R/initPortf.R
===================================================================
--- pkg/blotter/R/initPortf.R	2010-12-30 21:21:45 UTC (rev 512)
+++ pkg/blotter/R/initPortf.R	2010-12-31 15:45:37 UTC (rev 513)
@@ -18,7 +18,7 @@
 #' \item Avg.Txn.Cost: a calculated value for the average net price paid (received) per contract bought (received),
 #' \item Pos.Qty: the resulting position quantity of contracts, calculated as the sum of the current transaction and the prior position,
 #' \item Pos.Avg.Cost: the calculated average cost of the resulting position, and
-#' \item Realized.PL: any profit or loss realized in the transaction from closing out a prior position
+#' \item Realized.PL: any prot or loss realized in the transaction from closing out a prior position
 #' }
 #'
 #' The second, posPL, is a container used to store calculated P&L values from transactions and close prices within an instrument. The data series is, however, a regular time series. Columns of the table include:
@@ -27,23 +27,24 @@
 #' \item Pos.Value the notional value of the position,
 #' \item Txn.Value the net value of the transactions occuring,
 #' \item Txn.Fees the total fees associated with transactions,
-#' \item Realized.PL any net profit or loss realized through transactions,
-#' \item Unrealized.PL any profit or loss associated with the remaining or ’open’ position, and
-#' \item Trading.PL the sum of net realized and unrealized profit and loss.
+#' \item Realized.PL any net prot or loss realized through transactions,
+#' \item Unrealized.PL any prot or loss associated with the remaining or open position, and
+#' \item Trading.PL the sum of net realized and unrealized prot and loss.
 #' }
 #' 
 #' The third, posPL.ccy, is the same as the second but translated into the portfolio currency.
 #'
 #' For each portfolio, the summary slot contains a table that tracks calculated portfolio information through time. The table contains the following columns, held in a regular xts time series:
+#' \itemize{
 #' \item Long.Value: The sum of the notional value of all positions held long in the portfolio.
 #' \item Short.Value: The sum of the notional value of all positions held short in the portfolio.
 #' \item Net.Value: The sum of the notional long and notional short value of the portfolio.
 #' \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 profits or losses aggregated from the underlying positions in the portfolio. Gross realized profits 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 profits or losses on open positions in the portfolio at the end of the period.
-#' \item Net.Trading.PL: Net realized profit or loss plus interest income plus change in unrealized profit or loss across all positions in the portfolio.
-#' 
+#' \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 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
 #
 #' Outputs

Modified: pkg/blotter/R/tradeStats.R
===================================================================
--- pkg/blotter/R/tradeStats.R	2010-12-30 21:21:45 UTC (rev 512)
+++ pkg/blotter/R/tradeStats.R	2010-12-31 15:45:37 UTC (rev 513)
@@ -1,3 +1,4 @@
+
 #' calculate statistics on transactions and P&L for a symbol or symbols in a portfolio or portfolios
 #' 
 #' This function calculates trade-level statistics on a symbol or symbols within a portfolio or portfolios.
@@ -21,18 +22,19 @@
 #' calculated independently of strategy rules could be considered proprietary.
 #' 
 #' Special Thanks for contributions to this function from:
-#' \itemize{
+#' \describe{
 #'   \item{Josh Ulrich}{ for adding multiple-portfolio support, fixing bugs, and improving readability of the code }
 #'   \item{Klemen Koselj}{ for median stats, num trades, and win/loss ratios }
-#'   \item{Mark Knect}{ for suggesting Profit Factor and largest winner/largest loser }
+#'   \item{Mark Knecht}{ for suggesting Profit Factor and largest winner/largest loser }
 #' }  
 #' 
 #' WARNING: we're not sure this function is stable/complete yet.  If you're using it, please give us feedback!
 #' 
-#' @param Portfolio portfolio string 
+#' @param Portfolios portfolio string 
 #' @param Symbols character vector of symbol strings, default NULL
 #' @author Lance Levenson
 #' @export
+#' @note
 #' TODO document each statistic included in this function, with equations 
 tradeStats <- function(Portfolios, Symbols)
 {
@@ -47,7 +49,9 @@
     		stop(paste("Portfolio", pname, " not found, use initPortf() to create a new portfolio"))
         if (!inherits(Portfolio, "portfolio")) 
                 stop("Portfolio", pname, "passed is not the name of a portfolio object.")
-            
+        
+        
+        
         ## FIXME: need a way to define symbols for each portfolio    
         if(missing(Symbols)) symbols <- names(Portfolio$symbols)
         else symbols <- Symbols
@@ -88,9 +92,10 @@
             AvgWinLoss <- AvgWinTrade/-AvgLossTrade
             MedWinLoss <- MedWinTrade/-MedLossTrade
             
-            AvgDailyPL <- mean(apply.daily(PL.ne0,sum))
-            MedDailyPL <- median(apply.daily(PL.ne0,sum))
-            StdDailyPL <- as.numeric(sd(apply.daily(PL.ne0,sum)))
+            DailyPL <- apply.daily(PL.ne0,sum)
+            AvgDailyPL <- mean(DailyPL)
+            MedDailyPL <- median(DailyPL)
+            StdDailyPL <- as.numeric(sd(DailyPL))
             
             Equity <- cumsum(posPL$Net.Trading.PL)
 	        Equity.max <- cummax(Equity)
@@ -141,10 +146,103 @@
             ret <- rbind(ret,tmpret)
         } # end symbol loop
     } # end portfolio loop
+    return(ret)
+}
+
+#' generate daily Transaction Realized or Equity Curve P&L by instrument
+#' 
+#' designed to collate information for high frequency portfolios
+#' 
+#' @aliases dailyEqPL
+#' @param Portfolios portfolio string 
+#' @param Symbols character vector of symbol strings
+#' @param drop.time remove time component of POSIX datestamp (if any), default TRUE 
+#' @author Brian G. Peterson
+#' @export
+dailyTxnPL <- function(Portfolios, Symbols, drop.time=TRUE)
+{
+    ret<-NULL
+    for (Portfolio in Portfolios){
+        ## Error Handling Borrowed from getPortfolio
+        pname <- Portfolio
+        if (!grepl("portfolio\\.", pname)) 
+            Portfolio <- try(get(paste("portfolio", pname, sep = "."),  envir = .blotter))
+        else Portfolio <- try(get(pname, envir = .blotter))
+        if (inherits(Portfolio, "try-error")) 
+            stop(paste("Portfolio", pname, " not found, use initPortf() to create a new portfolio"))
+        if (!inherits(Portfolio, "portfolio")) 
+            stop("Portfolio", pname, "passed is not the name of a portfolio object.")
         
+        
+        
+        ## FIXME: need a way to define symbols for each portfolio    
+        if(missing(Symbols)) symbols <- names(Portfolio$symbols)
+        else symbols <- Symbols
+        
+        ## Trade Statistics
+        for (symbol in symbols){
+            txn <- Portfolio$symbols[[symbol]]$txn
+            posPL <- Portfolio$symbols[[symbol]]$posPL
+            posPL <- posPL[-1,]
+            
+            #PL.gt0 <- txn$Net.Txn.Realized.PL[txn$Net.Txn.Realized.PL  > 0]
+            #PL.lt0 <- txn$Net.Txn.Realized.PL[txn$Net.Txn.Realized.PL  < 0]
+            PL.ne0 <- txn$Net.Txn.Realized.PL[txn$Net.Txn.Realized.PL != 0]
+            
+            DailyPL <- apply.daily(PL.ne0,sum)
+            colnames(DailyPL)<-paste(symbol,'DailyTxnPL',sep='.')
+            if(is.null(ret)) ret=DailyPL else ret<-cbind(ret,DailyPL)
+            
+        } # end symbol loop
+    } # end portfolio loop
+    ret<-apply.daily(ret,colSums,na.rm=TRUE)  
+    if(drop.time) index(ret)<-as.Date(index(ret))
     return(ret)
 }
 
+#' @export
+dailyEqPL <- function(Portfolios, Symbols, drop.time=TRUE)
+{
+    ret<-NULL
+    for (Portfolio in Portfolios){
+        ## Error Handling Borrowed from getPortfolio
+        pname <- Portfolio
+        if (!grepl("portfolio\\.", pname)) 
+            Portfolio <- try(get(paste("portfolio", pname, sep = "."),  envir = .blotter))
+        else Portfolio <- try(get(pname, envir = .blotter))
+        if (inherits(Portfolio, "try-error")) 
+            stop(paste("Portfolio", pname, " not found, use initPortf() to create a new portfolio"))
+        if (!inherits(Portfolio, "portfolio")) 
+            stop("Portfolio", pname, "passed is not the name of a portfolio object.")
+        
+        
+        
+        ## FIXME: need a way to define symbols for each portfolio    
+        if(missing(Symbols)) symbols <- names(Portfolio$symbols)
+        else symbols <- Symbols
+        
+        ## Trade Statistics
+        for (symbol in symbols){
+            txn <- Portfolio$symbols[[symbol]]$txn
+            posPL <- Portfolio$symbols[[symbol]]$posPL
+            posPL <- posPL[-1,]
+            
+            #PL.gt0 <- txn$Net.Txn.Realized.PL[txn$Net.Txn.Realized.PL  > 0]
+            #PL.lt0 <- txn$Net.Txn.Realized.PL[txn$Net.Txn.Realized.PL  < 0]
+            PL.ne0 <- txn$Net.Txn.Realized.PL[txn$Net.Txn.Realized.PL != 0]
+            Equity <- cumsum(posPL$Net.Trading.PL)
+            
+            #DailyPL <- apply.daily(Equity,last)
+            DailyPL <- apply.daily(posPL$Net.Trading.PL,colSums)
+            colnames(DailyPL)<-paste(symbol,'DailyEndEq',sep='.')
+            if(is.null(ret)) ret=DailyPL else ret<-cbind(ret,DailyPL)
+            
+        } # end symbol loop
+    } # end portfolio loop
+    ret<-apply.daily(ret,colSums,na.rm=TRUE)  
+    if(drop.time) index(ret)<-as.Date(index(ret))
+    return(ret)
+}
 
 ###############################################################################
 # Blotter: Tools for transaction-oriented trading systems development

Deleted: pkg/blotter/man/.calcPortfAttr.Rd
===================================================================
--- pkg/blotter/man/.calcPortfAttr.Rd	2010-12-30 21:21:45 UTC (rev 512)
+++ pkg/blotter/man/.calcPortfAttr.Rd	2010-12-31 15:45:37 UTC (rev 513)
@@ -1,11 +0,0 @@
-\name{.calcPortfAttr}
-\alias{.calcPortfAttr}
-\title{calculate summary attributes for a portfolio...}
-\usage{.calcPortfAttr(Portfolio, Attribute, Dates, Symbols)}
-\description{calculate summary attributes for a portfolio}
-\details{supported values are:
-Gross.Trading.PL, Txn.Fee, Net.Trading.PL, Realized.PL, Unrealized.PL, Gross.Value, Long.Value, Short.Value}
-\arguments{\item{Portfolio}{portfolio object}
-\item{Attribute}{attribute to calculate}
-\item{Dates}{date subset}
-\item{Symbols}{symbols to calculate for}}

Deleted: pkg/blotter/man/.getByPortf.Rd
===================================================================
--- pkg/blotter/man/.getByPortf.Rd	2010-12-30 21:21:45 UTC (rev 512)
+++ pkg/blotter/man/.getByPortf.Rd	2010-12-31 15:45:37 UTC (rev 513)
@@ -1,17 +0,0 @@
-\name{.getByPortf}
-\alias{.getByPortf}
-\title{get attributes from each portfolio in an account...}
-\usage{.getByPortf(Account, Attribute, Dates)}
-\description{get attributes from each portfolio in an account}
-\details{Retrieves calculated attributes for each portfolio in the account
-from the portfolio summary table.  Assembles into a portfolio-by-time table,
-normalized to the Account currency 
-
-
-Attribute: typically any of:
-'Long.Value', 'Short.Value', 'Net.Value', 'Gross.Value', 'Txn.Fees',
-'Realized.PL', 'Unrealized.PL', or 'Trading.PL'}
-\value{regular xts object of values by portfolio}
-\arguments{\item{Account}{an Account object containing Portfolio summaries}
-\item{Attribute}{column name to be assembled for each symbol}
-\item{Dates}{}}

Deleted: pkg/blotter/man/.getBySymbol.Rd
===================================================================
--- pkg/blotter/man/.getBySymbol.Rd	2010-12-30 21:21:45 UTC (rev 512)
+++ pkg/blotter/man/.getBySymbol.Rd	2010-12-31 15:45:37 UTC (rev 513)
@@ -1,17 +0,0 @@
-\name{.getBySymbol}
-\alias{.getBySymbol}
-\title{Retrieves calculated attributes for each position in the portfolio...}
-\usage{.getBySymbol(Portfolio, Attribute, Dates, Symbols, native=FALSE)}
-\description{Retrieves calculated attributes for each position in the portfolio}
-\details{Retrieves calculated attributes for each position in the portfolio
-from the posPL table.  Assembles into a symbol-by-time table useful
-for graphing or calculations
-
-items typically include things like
-'Pos.Qty', 'Pos.Value', 'Txn.Value', 'Realized.PL', 'Unrealized.PL',or 'Trading.PL'}
-\value{regular xts object of values by symbol}
-\arguments{\item{Portfolio}{a portfolio object containing transactions}
-\item{Attribute}{column name to be assembled for each symbol}
-\item{Dates}{}
-\item{Symbols}{}
-\item{native}{}}

Deleted: pkg/blotter/man/.getPortfAcct.Rd
===================================================================
--- pkg/blotter/man/.getPortfAcct.Rd	2010-12-30 21:21:45 UTC (rev 512)
+++ pkg/blotter/man/.getPortfAcct.Rd	2010-12-31 15:45:37 UTC (rev 513)
@@ -1,8 +0,0 @@
-\name{.getPortfAcct}
-\alias{.getPortfAcct}
-\title{get a protfolio in an account...}
-\usage{.getPortfAcct(Account, Portfolio, Dates)}
-\description{get a protfolio in an account}
-\arguments{\item{Account}{account string}
-\item{Portfolio}{portfolio string}
-\item{Dates}{date subset as an xts style ISO 8601 string}}

Deleted: pkg/blotter/man/.getPosAvgCost.Rd
===================================================================
--- pkg/blotter/man/.getPosAvgCost.Rd	2010-12-30 21:21:45 UTC (rev 512)
+++ pkg/blotter/man/.getPosAvgCost.Rd	2010-12-31 15:45:37 UTC (rev 513)
@@ -1,9 +0,0 @@
-\name{.getPosAvgCost}
-\alias{.getPosAvgCost}
-\title{Retrieves the most recent average cost of the position...}
-\usage{.getPosAvgCost(Portfolio, Symbol, Date)}
-\description{Retrieves the most recent average cost of the position}
-\value{Numeric value of the average cost of the current position}
-\arguments{\item{Portfolio}{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}}

Deleted: pkg/blotter/man/.initPosPL.Rd
===================================================================
--- pkg/blotter/man/.initPosPL.Rd	2010-12-30 21:21:45 UTC (rev 512)
+++ pkg/blotter/man/.initPosPL.Rd	2010-12-31 15:45:37 UTC (rev 513)
@@ -1,15 +0,0 @@
-\name{.initPosPL}
-\alias{.initPosPL}
-\title{initializes position P&L for a portfolio instrument...}
-\usage{.initPosPL(initDate="1950-01-01", ..., initPosQty=0, initConMult=1,
-    initCcyMult=1)}
-\description{initializes position P&L for a portfolio instrument}
-\details{Constructs the data container used to store calculated P&L values from
-transactions and close prices.
-
-Constructs multi-column xts object used to store derived position information}
-\arguments{\item{initDate}{date prior to the first close price given, used to contain initial account equity and initial position}
-\item{\dots}{any other passthrough parameters}
-\item{initPosQty}{initial position, default is zero}
-\item{initConMult}{initial contract multiplier, default is one(1)}
-\item{initCcyMult}{initial currency multiplier, default is one(1)}}

Deleted: pkg/blotter/man/.initSummary.Rd
===================================================================
--- pkg/blotter/man/.initSummary.Rd	2010-12-30 21:21:45 UTC (rev 512)
+++ pkg/blotter/man/.initSummary.Rd	2010-12-31 15:45:37 UTC (rev 513)
@@ -1,6 +0,0 @@
-\name{.initSummary}
-\alias{.initSummary}
-\title{initialize the summary table used in portfolio and account lists...}
-\usage{.initSummary(initDate="1950-01-01")}
-\description{initialize the summary table used in portfolio and account lists}
-\arguments{\item{initDate}{date prior to the first close price given, used to contain initial account equity and initial position}}

Deleted: pkg/blotter/man/.initTxn.Rd
===================================================================
--- pkg/blotter/man/.initTxn.Rd	2010-12-30 21:21:45 UTC (rev 512)
+++ pkg/blotter/man/.initTxn.Rd	2010-12-31 15:45:37 UTC (rev 513)
@@ -1,9 +0,0 @@
-\name{.initTxn}
-\alias{.initTxn}
-\title{Constructs the data container used to store transactions and resulting positions.}
-\usage{.initTxn(initDate="1950-01-01", initPosQty=0)}
-\description{Constructs the data container used to store transactions and resulting positions.}
-\details{The data series stored here will be an irregular time series.}
-\value{Constructs multi-column xts object used to store transactions}
-\arguments{\item{initDate}{date prior to the first close price given, used to contain initial account equity and initial position}
-\item{initPosQty}{initial position, default is zero}}

Deleted: pkg/blotter/man/.onLoad.Rd
===================================================================
--- pkg/blotter/man/.onLoad.Rd	2010-12-30 21:21:45 UTC (rev 512)
+++ pkg/blotter/man/.onLoad.Rd	2010-12-31 15:45:37 UTC (rev 513)
@@ -1,4 +0,0 @@
-\name{.onLoad}
-\alias{.onLoad}
-\title{.onLoad}
-\usage{.onLoad(lib, pkg)}

Deleted: pkg/blotter/man/.updatePosPL.Rd
===================================================================
--- pkg/blotter/man/.updatePosPL.Rd	2010-12-30 21:21:45 UTC (rev 512)
+++ pkg/blotter/man/.updatePosPL.Rd	2010-12-31 15:45:37 UTC (rev 513)
@@ -1,12 +0,0 @@
-\name{.updatePosPL}
-\alias{.updatePosPL}
-\title{Calculates position PL from the position data and corresponding close price data.}
-\usage{.updatePosPL(Portfolio, Symbol, Dates, Prices, ConMult, ...)}
-\description{Calculates position PL from the position data and corresponding close price data.}
-\value{Regular time series of position information and PL}
-\author{Peter Carl, Brian Peterson}
-\arguments{\item{Portfolio}{a portfolio name to a portfolio structured with initPortf()}
-\item{Symbol}{an instrument identifier for a symbol included in the portfolio}
-\item{Dates}{xts subset of dates, e.g., "2007-01::2008-04-15". These dates must appear in the price stream}
-\item{Prices}{periodic prices in an xts object with a columnname compatible with \code{getPrice}}
-\item{ConMult}{if necessary, numeric contract multiplier, not needed if instrument is defined.}}

Modified: pkg/blotter/man/PortfReturns.Rd
===================================================================
--- pkg/blotter/man/PortfReturns.Rd	2010-12-30 21:21:45 UTC (rev 512)
+++ pkg/blotter/man/PortfReturns.Rd	2010-12-31 15:45:37 UTC (rev 513)
@@ -7,15 +7,14 @@
 in the portfolio or portfolios that make up an account.  These columns will be additive
 to return on capital of each portfolio, or of the entire account.
 
-TODO handle portfolio and account in different currencies (not hard, just not done)
+This function exists because of R/Finance community requests by Mark Breman and Thomas Bolton}
+\note{TODO handle portfolio and account in different currencies (not hard, just not done)
 
 TODO explicitly handle portfolio weights
 
 TODO provide additional  methods of calculating returns
 
-TODO support additions and withdrawals to available capital 
-
-This function exists because of R/Finance community requests by Mark Breman and Thomas Bolton}
+TODO support additions and withdrawals to available capital}
 \arguments{\item{Account}{string name of the account to generate returns for}
 \item{method}{for now, only 'contribution' is supported}
 \item{\dots}{any other passthru parameters (like \code{native} for \code{.getBySymbol}}

Modified: pkg/blotter/man/addDiv.Rd
===================================================================
--- pkg/blotter/man/addDiv.Rd	2010-12-30 21:21:45 UTC (rev 512)
+++ pkg/blotter/man/addDiv.Rd	2010-12-31 15:45:37 UTC (rev 513)
@@ -1,19 +1,17 @@
 \name{addDiv}
 \alias{addDiv}
-\title{add cash dividend transactions to a portfolio...}
-\usage{addDiv(Portfolio, Symbol, TxnDate, DivPerShare, ..., TxnFees=0,
-    ConMult, verbose=TRUE)}
-\description{add cash dividend transactions to a portfolio}
-\details{Adding a cash Dividend does not affect position
+\title{Add cash dividend transactions to a portfolio.}
+\usage{addDiv(Portfolio, Symbol, TxnDate, DivPerShare, ..., TxnFees=0, ConMult, verbose=TRUE)}
+\description{Add cash dividend transactions to a portfolio.}
+\details{Adding a cash dividend does not affect position quantity, like a split would.}
+\note{# TODO add TxnTypes to $txn table
 
-# 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}
-\item{TxnDate}{transaction date as ISO 8601, e.g., '2008-09-01' or '2010-01-05 09:54:23.12345'}
-\item{DivPerShare}{}
-\item{\dots}{any other passthrough parameters}
-\item{TxnFees}{fees associated with the transaction, e.g. commissions., See Details}
-\item{ConMult}{}
-\item{verbose}{}}
+\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.}
+\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{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	2010-12-30 21:21:45 UTC (rev 512)
+++ pkg/blotter/man/addTxn.Rd	2010-12-31 15:45:37 UTC (rev 513)
@@ -1,17 +1,29 @@
 \name{addTxn}
 \alias{addTxn}
-\title{Adds transactions to a portfolio.}
-\usage{addTxn(Portfolio, Symbol, TxnDate, TxnQty, TxnPrice, ..., TxnFees=0,
-    ConMult, verbose=TRUE)}
-\description{Adds transactions to a portfolio.}
-\details{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.}
+\title{Add transactions to a portfolio.}
+\usage{addTxn(Portfolio, Symbol, TxnDate, TxnQty, TxnPrice, ..., TxnFees=0, ConMult, verbose=TRUE)}
+\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 
+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.}
+\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.}
+\seealso{\code{\link{addTxns}}, \code{\link{pennyPerShare}}, \code{\link{initPortf}}}
 \author{Peter Carl}
[TRUNCATED]

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


More information about the Blotter-commits mailing list