[Blotter-commits] r1351 - in pkg: blotter blotter/R blotter/man quantstrat/R
noreply at r-forge.r-project.org
noreply at r-forge.r-project.org
Sat Jan 12 23:35:57 CET 2013
Author: opentrades
Date: 2013-01-12 23:35:57 +0100 (Sat, 12 Jan 2013)
New Revision: 1351
Added:
pkg/blotter/R/put.portfolio.R
Modified:
pkg/blotter/DESCRIPTION
pkg/blotter/NAMESPACE
pkg/blotter/man/addTxn.Rd
pkg/blotter/man/tradeStats.Rd
pkg/quantstrat/R/paramsets.R
Log:
- introduced put.portfolio() for better data abstraction
Modified: pkg/blotter/DESCRIPTION
===================================================================
--- pkg/blotter/DESCRIPTION 2013-01-12 22:13:31 UTC (rev 1350)
+++ pkg/blotter/DESCRIPTION 2013-01-12 22:35:57 UTC (rev 1351)
@@ -28,3 +28,38 @@
URL: https://r-forge.r-project.org/projects/blotter/
Copyright: (c) 2008-2012
ByteCompile: TRUE
+Collate:
+ 'PortfReturns.R'
+ 'addPortfInstr.R'
+ 'addTxn.R'
+ 'calcPortfWgt.R'
+ 'calcPosAvgCost.R'
+ 'calcTxnAvgCost.R'
+ 'calcTxnValue.R'
+ 'chart.ME.R'
+ 'chart.Posn.R'
+ 'chart.Reconcile.R'
+ 'chart.Spread.R'
+ 'extractTests.R'
+ 'getAccount.R'
+ 'getByPortf.R'
+ 'getBySymbol.R'
+ 'getEndEq.R'
+ 'getPortfAcct.R'
+ 'getPortfolio.R'
+ 'getPos.R'
+ 'getPosAvgCost.R'
+ 'getPosQty.R'
+ 'getTxn.R'
+ 'initAcct.R'
+ 'initPortf.R'
+ 'initPosPL.R'
+ 'initSummary.R'
+ 'initTxn.R'
+ 'perTradeStats.R'
+ 'put.portfolio.R'
+ 'tradeStats.R'
+ 'updateAcct.R'
+ 'updateEndEq.R'
+ 'updatePortf.R'
+ 'updatePosPL.R'
Modified: pkg/blotter/NAMESPACE
===================================================================
--- pkg/blotter/NAMESPACE 2013-01-12 22:13:31 UTC (rev 1350)
+++ pkg/blotter/NAMESPACE 2013-01-12 22:35:57 UTC (rev 1351)
@@ -1,3 +1,4 @@
+export(PortfReturns)
export(addDiv)
export(addPortfInstr)
export(addTxn)
@@ -22,7 +23,7 @@
export(is.portfolio)
export(pennyPerShare)
export(perTradeStats)
-export(PortfReturns)
+export(put.portfolio)
export(tradeQuantiles)
export(tradeStats)
export(updateAcct)
Added: pkg/blotter/R/put.portfolio.R
===================================================================
--- pkg/blotter/R/put.portfolio.R (rev 0)
+++ pkg/blotter/R/put.portfolio.R 2013-01-12 22:35:57 UTC (rev 1351)
@@ -0,0 +1,22 @@
+#' put a portfolio object in .blotter env
+#' @param portfolio.st string identifying portfolio
+#' @param portfolio portfolio object
+#' @export
+
+put.portfolio <- function(portfolio.st, portfolio)
+{
+ blotter.portfolio.st <- paste('portfolio', portfolio.st, sep='.')
+ assign(blotter.portfolio.st, portfolio, envir=.blotter)
+}
+
+###############################################################################
+# 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: getPortfolio.R 742 2011-08-25 21:12:43Z braverock $
+#
+###############################################################################
Modified: pkg/blotter/man/addTxn.Rd
===================================================================
--- pkg/blotter/man/addTxn.Rd 2013-01-12 22:13:31 UTC (rev 1350)
+++ pkg/blotter/man/addTxn.Rd 2013-01-12 22:35:57 UTC (rev 1351)
@@ -4,7 +4,7 @@
\usage{
addTxn(Portfolio, Symbol, TxnDate, TxnQty, TxnPrice, ...,
TxnFees = 0, ConMult = NULL, verbose = TRUE,
- eps = 1e-06)
+ eps = 0.000001)
}
\arguments{
\item{Portfolio}{A portfolio name that points to a
Modified: pkg/blotter/man/tradeStats.Rd
===================================================================
--- pkg/blotter/man/tradeStats.Rd 2013-01-12 22:13:31 UTC (rev 1350)
+++ pkg/blotter/man/tradeStats.Rd 2013-01-12 22:35:57 UTC (rev 1351)
@@ -3,9 +3,10 @@
\alias{tradeStats}
\title{calculate statistics on transactions and P&L for a symbol or symbols in a portfolio or portfolios}
\usage{
- tradeStats(Portfolios, Symbols)
+ tradeStats(Portfolios, Symbols,
+ use = c("txns", "trades"))
- dailyStats(Portfolios, use = c("Equity", "Txns"))
+ dailyStats(Portfolios, use = c("equity", "txns"))
}
\arguments{
\item{Portfolios}{portfolio string}
@@ -13,8 +14,9 @@
\item{Symbols}{character vector of symbol strings,
default NULL}
- \item{use}{for dailyStats, determines whether numbers are
- calculated from trades or equity curve}
+ \item{use}{for determines whether numbers are calculated
+ from transactions or round-trip trades (for tradeStats)
+ or equity curve (for dailyStats)}
}
\value{
a \code{data.frame} containing:
@@ -38,15 +40,16 @@
\item{Med.Win.Trade}{ median P&L of profitable trades }
\item{Avg.Losing.Trade}{ mean P&L of losing trades }
\item{Med.Losing.Trade}{ median P&L of losing trades }
- \item{Avg.Daily.PL}{mean daily P&L } \item{Med.Daily.PL}{
- median daily P&L } \item{Std.Dev.Daily.PL}{ standard
- deviation of daliy P&L } \item{Max.Drawdown}{ max
- drawdown } \item{Avg.WinLoss.Ratio}{ ratio of mean
- winning over mean losing trade }
- \item{Med.WinLoss.Ratio}{ ratio of median winning trade
- over mean losing trade } \item{Max.Equity}{ maximum
- account equity } \item{Min.Equity}{ minimum account
- equity } }
+ \item{Avg.Daily.PL}{mean daily realized P&L on days there
+ were transactions, see \code{\link{dailyStats}} for all
+ days } \item{Med.Daily.PL}{ median daily P&L }
+ \item{Std.Dev.Daily.PL}{ standard deviation of daily P&L
+ } \item{Max.Drawdown}{ max drawdown }
+ \item{Avg.WinLoss.Ratio}{ ratio of mean winning over mean
+ losing trade } \item{Med.WinLoss.Ratio}{ ratio of median
+ winning trade over mean losing trade } \item{Max.Equity}{
+ maximum account equity } \item{Min.Equity}{ minimum
+ account equity } }
}
\description{
This function calculates trade-level statistics on a
@@ -104,7 +107,7 @@
Josh has suggested adding \%-return based stats too
}
\author{
- Lance Levenson
+ Lance Levenson, Brian Peterson
}
\seealso{
\code{\link{chart.ME}} for a chart of MAE and MFE derived
Modified: pkg/quantstrat/R/paramsets.R
===================================================================
--- pkg/quantstrat/R/paramsets.R 2013-01-12 22:13:31 UTC (rev 1350)
+++ pkg/quantstrat/R/paramsets.R 2013-01-12 22:35:57 UTC (rev 1351)
@@ -56,7 +56,7 @@
}
portfolio$summary <- portfolio$summary[1,]
}
- assign(paste("portfolio", as.character(cloned.portfolio.st), sep='.'), portfolio, envir=.blotter)
+ put.portfolio(as.character(cloned.portfolio.st), portfolio)
return(cloned.portfolio.st)
}
@@ -382,8 +382,7 @@
r <- args[[i]]
# move portfolio from slave returned list into .blotter environment
- full.portfolio.st <- paste('portfolio', r$portfolio.st, sep='.')
- assign(full.portfolio.st, r$portfolio, envir=.blotter)
+ put.portfolio(r$portfolio.st, r$portfolio)
r$portfolio <- NULL
# move order_book from slave returned list into .strategy environment
@@ -436,8 +435,7 @@
list2env(env.instrument, envir=FinancialInstrument:::.instrument)
- blotter.portfolio.st <- paste('portfolio', portfolio.st, sep='.')
- assign(blotter.portfolio.st, portfolio, envir=.blotter)
+ put.portfolio(portfolio.st, portfolio)
blotter.account.st <- paste('account', account.st, sep='.')
assign(blotter.account.st, account, envir=.blotter)
More information about the Blotter-commits
mailing list