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

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Tue Feb 23 23:19:16 CET 2010


Author: braverock
Date: 2010-02-23 23:19:16 +0100 (Tue, 23 Feb 2010)
New Revision: 252

Modified:
   pkg/blotter/R/getPos.R
   pkg/blotter/R/getPosQty.R
   pkg/blotter/R/initAcct.R
Log:
- cleanup to use utility functions and set defaults

Modified: pkg/blotter/R/getPos.R
===================================================================
--- pkg/blotter/R/getPos.R	2010-02-23 20:23:09 UTC (rev 251)
+++ pkg/blotter/R/getPos.R	2010-02-23 22:19:16 UTC (rev 252)
@@ -1,10 +1,6 @@
 getPos <- function(Portfolio, Symbol, Date)
 { # @author Peter Carl
-    pname<-Portfolio
-    Portfolio<-get(paste("portfolio",pname,sep='.'),envir=.blotter)
-    if(inherits(Portfolio,"try-error"))
-        stop(paste("Portfolio",name," not found, use initPortf() to create a new account"))
-    
+    Portfolio<-getPortfolio(Portfolio)    
     # DESCRIPTION:
     # Retrieves all information about the position as of a date
 

Modified: pkg/blotter/R/getPosQty.R
===================================================================
--- pkg/blotter/R/getPosQty.R	2010-02-23 20:23:09 UTC (rev 251)
+++ pkg/blotter/R/getPosQty.R	2010-02-23 22:19:16 UTC (rev 252)
@@ -2,9 +2,10 @@
 getPosQty <- function(Portfolio, Symbol, Date)
 { # @author Peter Carl
     pname<-Portfolio
-    Portfolio<-get(paste("portfolio",pname,sep='.'),envir=.blotter)
-    if(inherits(Portfolio,"try-error"))
-        stop(paste("Portfolio",name," not found, use initPortf() to create a new account"))
+    # portfolio retrieval happens in getPos
+    #Portfolio<-get(paste("portfolio",pname,sep='.'),envir=.blotter)
+    #if(inherits(Portfolio,"try-error"))
+    #    stop(paste("Portfolio",name," not found, use initPortf() to create a new account"))
     
     # DESCRIPTION:
     # Gets the previous position 

Modified: pkg/blotter/R/initAcct.R
===================================================================
--- pkg/blotter/R/initAcct.R	2010-02-23 20:23:09 UTC (rev 251)
+++ pkg/blotter/R/initAcct.R	2010-02-23 22:19:16 UTC (rev 252)
@@ -46,7 +46,7 @@
 #' @param initDate 
 #' @param initEq 
 #' @export
-initAcct <- function(name='default', portfolios, initDate="1950-01-01", initEq=100000)
+initAcct <- function(name='default', portfolios, initDate="1950-01-01", initEq=0)
 { # @author Peter Carl
 
     if(exists(paste("account",name,sep='.'), envir=.blotter,inherits=TRUE)) 



More information about the Blotter-commits mailing list