[Blotter-commits] r291 - pkg/blotter/R

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Tue Mar 16 20:14:45 CET 2010


Author: braverock
Date: 2010-03-16 20:14:44 +0100 (Tue, 16 Mar 2010)
New Revision: 291

Modified:
   pkg/blotter/R/updatePortf.R
   pkg/blotter/R/updatePosPL.R
Log:
- allow for passing of Symbol and Prices into functions, and allow for NULL Dates in updatePortf 

Modified: pkg/blotter/R/updatePortf.R
===================================================================
--- pkg/blotter/R/updatePortf.R	2010-03-16 15:33:51 UTC (rev 290)
+++ pkg/blotter/R/updatePortf.R	2010-03-16 19:14:44 UTC (rev 291)
@@ -10,18 +10,25 @@
 #' assigns position information and PL into the environment
 #' 
 #' @param Portfolio 
+#' @param Symbols
 #' @param Dates 
+#' @param Prices
 #' @export
-updatePortf <- function(Portfolio, Dates)
+updatePortf <- function(Portfolio, Symbols=NULL, Dates=NULL, Prices=NULL)
 { #' @author Peter Carl
     pname<-Portfolio
     Portfolio<-getPortfolio(pname) # TODO add Date handling
 
     # FUNCTION
-    symbols = names(Portfolio)
-    for(symbol in symbols){
+    if(is.null(Symbols)){
+        Symbols = names(Portfolio)
+    } 
+    for(symbol in Symbols){
+        if(is.null(Prices)){
+            Prices=Cl(get(symbol))
+        } 
         tmp_instr<-try(getInstrument(symbol))
-        updatePosPL(pname, symbol, Dates, Cl(get(symbol)))            
+        updatePosPL(pname, symbol, Dates, Prices=Prices)            
     }
     return(pname) #not sure this is a good idea
 }

Modified: pkg/blotter/R/updatePosPL.R
===================================================================
--- pkg/blotter/R/updatePosPL.R	2010-03-16 15:33:51 UTC (rev 290)
+++ pkg/blotter/R/updatePosPL.R	2010-03-16 19:14:44 UTC (rev 291)
@@ -7,7 +7,7 @@
 #' @return Regular time series of position information and PL 
 #' @author Peter Carl
 #' @export
-updatePosPL <- function(Portfolio, Symbol, Dates, Prices=Cl(get(Symbol)), ConMult=NULL)
+updatePosPL <- function(Portfolio, Symbol, Dates=NULL, Prices=Cl(get(Symbol)))
 { # @author Peter Carl
 
     pname<-Portfolio



More information about the Blotter-commits mailing list