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

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Tue Mar 16 21:10:12 CET 2010


Author: braverock
Date: 2010-03-16 21:10:12 +0100 (Tue, 16 Mar 2010)
New Revision: 292

Modified:
   pkg/blotter/R/updatePortf.R
   pkg/blotter/R/updatePosPL.R
Log:
- move Price lookup into updatePosPL if not passed

Modified: pkg/blotter/R/updatePortf.R
===================================================================
--- pkg/blotter/R/updatePortf.R	2010-03-16 19:14:44 UTC (rev 291)
+++ pkg/blotter/R/updatePortf.R	2010-03-16 20:10:12 UTC (rev 292)
@@ -24,9 +24,6 @@
         Symbols = names(Portfolio)
     } 
     for(symbol in Symbols){
-        if(is.null(Prices)){
-            Prices=Cl(get(symbol))
-        } 
         tmp_instr<-try(getInstrument(symbol))
         updatePosPL(pname, symbol, Dates, Prices=Prices)            
     }

Modified: pkg/blotter/R/updatePosPL.R
===================================================================
--- pkg/blotter/R/updatePosPL.R	2010-03-16 19:14:44 UTC (rev 291)
+++ pkg/blotter/R/updatePosPL.R	2010-03-16 20:10:12 UTC (rev 292)
@@ -7,7 +7,7 @@
 #' @return Regular time series of position information and PL 
 #' @author Peter Carl
 #' @export
-updatePosPL <- function(Portfolio, Symbol, Dates=NULL, Prices=Cl(get(Symbol)))
+updatePosPL <- function(Portfolio, Symbol, Dates=NULL, Prices=NULL)
 { # @author Peter Carl
 
     pname<-Portfolio
@@ -16,6 +16,11 @@
     # FUNCTION
     PosAvgCost = 0
     PosQty = 0
+    
+    if(is.null(Prices)){
+        Prices=Cl(get(symbol))
+    } 
+    
 
 #     freq = periodicity(Prices)
 #     switch(freq$scale,



More information about the Blotter-commits mailing list