[Blotter-commits] r204 - in pkg/blotter: . R

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Tue Jan 26 22:04:02 CET 2010


Author: braverock
Date: 2010-01-26 22:04:02 +0100 (Tue, 26 Jan 2010)
New Revision: 204

Added:
   pkg/blotter/R/getPortfAcct.R
   pkg/blotter/R/getPortfolio.R
Modified:
   pkg/blotter/NAMESPACE
   pkg/blotter/R/getBySymbol.R
Log:
- add functions getPortfolio and getPortfAcct

Modified: pkg/blotter/NAMESPACE
===================================================================
--- pkg/blotter/NAMESPACE	2010-01-26 17:30:20 UTC (rev 203)
+++ pkg/blotter/NAMESPACE	2010-01-26 21:04:02 UTC (rev 204)
@@ -3,6 +3,9 @@
 export(chart.Posn)
 export(getEndEq)
 export(getPosQty)
+export(getPortAcct)
+export(getPortfolio)
+export(getTxns)
 export(initAcct)
 export(initPortf)
 export(updateAcct)

Modified: pkg/blotter/R/getBySymbol.R
===================================================================
--- pkg/blotter/R/getBySymbol.R	2010-01-26 17:30:20 UTC (rev 203)
+++ pkg/blotter/R/getBySymbol.R	2010-01-26 21:04:02 UTC (rev 204)
@@ -4,7 +4,7 @@
     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"))
+        stop(paste("Portfolio",pname," not found, use initPortf() to create a new portfolio"))
     
     # DESCRIPTION:
     # Retrieves calculated attributes for each position in the portfolio

Added: pkg/blotter/R/getPortfAcct.R
===================================================================
--- pkg/blotter/R/getPortfAcct.R	                        (rev 0)
+++ pkg/blotter/R/getPortfAcct.R	2010-01-26 21:04:02 UTC (rev 204)
@@ -0,0 +1,28 @@
+getPortfAcct <- function(Account,Portfolio, Dates=NULL) #should symbol subsets be supported too?  probably not.
+{ # @author Brian Peterson
+    acct<-try(get(paste("account",Account,sep='.'),envir=.blotter),silent=TRUE)
+    if(inherits(acct,"try-error"))
+        stop(paste("Account",Account,"not found, use initAcct() to create a new account."))
+    pname=Portfolio
+    Portfolio<-try(acct[[paste("portfolio",pname,sep='.')]],silent=TRUE)
+    if(inherits(Portfolio,"try-error"))
+        stop(paste("Portfolio",pname,"not found, use initPortf() to create a new portfolio or initAcct() to place it in",Account))
+    
+    if(!is.null(Dates)){
+        Portfolio<-Portfolio[Dates]
+    }
+    
+    return(Portfolio)
+}
+
+###############################################################################
+# Blotter: Tools for transaction-oriented trading systems development
+# for R (see http://r-project.org/) 
+# Copyright (c) 2008-2010 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$
+#
+###############################################################################


Property changes on: pkg/blotter/R/getPortfAcct.R
___________________________________________________________________
Name: svn:keywords
   + Revision Id Date Author

Added: pkg/blotter/R/getPortfolio.R
===================================================================
--- pkg/blotter/R/getPortfolio.R	                        (rev 0)
+++ pkg/blotter/R/getPortfolio.R	2010-01-26 21:04:02 UTC (rev 204)
@@ -0,0 +1,26 @@
+getPortfolio <- function(Portfolio, Dates=NULL) #should symbol subsets be supported too?  probably not.
+{ # @author Brian Peterson
+    pname<-Portfolio
+    Portfolio<-get(paste("portfolio",pname,sep='.'),envir=.blotter)
+    if(inherits(Portfolio,"try-error"))
+        stop(paste("Portfolio",pname," not found, use initPortf() to create a new portfolio"))
+    
+    if(!is.null(Dates)){
+        message("date subsettingnot yet supported")
+        #TODO add date subsetting in getPortfolio
+    }
+    
+    return(Portfolio)
+}
+
+###############################################################################
+# Blotter: Tools for transaction-oriented trading systems development
+# for R (see http://r-project.org/) 
+# Copyright (c) 2008-2010 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$
+#
+###############################################################################


Property changes on: pkg/blotter/R/getPortfolio.R
___________________________________________________________________
Name: svn:keywords
   + Revision Id Date Author



More information about the Blotter-commits mailing list