[Blotter-commits] r492 - pkg/blotter/R
noreply at r-forge.r-project.org
noreply at r-forge.r-project.org
Sun Dec 12 03:19:20 CET 2010
Author: braverock
Date: 2010-12-12 03:19:19 +0100 (Sun, 12 Dec 2010)
New Revision: 492
Modified:
pkg/blotter/R/updatePortf.R
pkg/blotter/R/updatePosPL.R
Log:
- pass dots through updatePortf and .updatePosPl to make sure they are available for getPrice
- existence of potential issue reported by Lei Jin < leijin56 <at> gmail <dot> com > on R-SIG-Finance
Modified: pkg/blotter/R/updatePortf.R
===================================================================
--- pkg/blotter/R/updatePortf.R 2010-12-10 22:57:53 UTC (rev 491)
+++ pkg/blotter/R/updatePortf.R 2010-12-12 02:19:19 UTC (rev 492)
@@ -13,9 +13,10 @@
#' @param Symbols
#' @param Dates
#' @param Prices
+#' @param dots any other passthrough parameters
#' @export
#' @callGraph
-updatePortf <- function(Portfolio, Symbols=NULL, Dates=NULL, Prices=NULL)
+updatePortf <- function(Portfolio, Symbols=NULL, Dates=NULL, Prices=NULL, ...)
{ #' @author Peter Carl, Brian Peterson
pname<-Portfolio
Portfolio<-getPortfolio(pname) # TODO add Date handling
@@ -26,7 +27,7 @@
}
for(symbol in Symbols){
tmp_instr<-try(getInstrument(symbol))
- .updatePosPL(Portfolio=pname, Symbol=as.character(symbol), Dates=Dates, Prices=Prices)
+ .updatePosPL(Portfolio=pname, Symbol=as.character(symbol), Dates=Dates, Prices=Prices, ...=...)
}
# Calculate and store portfolio summary table
Modified: pkg/blotter/R/updatePosPL.R
===================================================================
--- pkg/blotter/R/updatePosPL.R 2010-12-10 22:57:53 UTC (rev 491)
+++ pkg/blotter/R/updatePosPL.R 2010-12-12 02:19:19 UTC (rev 492)
@@ -5,6 +5,7 @@
#' @param Dates xts subset of dates, e.g., "2007-01::2008-04-15". These dates must appear in the price stream
#' @param Prices periodic prices in an xts object with a columnname compatible with \code{getPrice}
#' @param ConMult if necessary, numeric contract multiplier, not needed if instrument is defined.
+#' @param \dots any other passthru parameters
#' @return Regular time series of position information and PL
#' @author Peter Carl, Brian Peterson
.updatePosPL <- function(Portfolio, Symbol, Dates=NULL, Prices=NULL, ConMult=NULL, ...)
@@ -22,7 +23,7 @@
}
if(is.null(Prices)){
- prices=getPrice(get(Symbol, envir=as.environment(.GlobalEnv)))
+ prices=getPrice(get(Symbol, envir=as.environment(.GlobalEnv)),...=...)
} else {
prices=Prices
}
@@ -31,6 +32,8 @@
Dates = time(prices)
} else if(!is.timeBased(Dates)) Dates = time(prices[Dates])
+ if(ncol(Prices)>1) Prices=getPrice(Prices,Symbol)
+
# line up Prices dates with Dates set/index/span passed in.
startDate = first(xts:::.parseISO8601(Dates))$first.time-1 #does this need to be a smaller/larger delta for millisecond data?
More information about the Blotter-commits
mailing list