[Blotter-commits] r1552 - pkg/blotter/R
noreply at r-forge.r-project.org
noreply at r-forge.r-project.org
Sun Oct 27 01:09:00 CEST 2013
Author: braverock
Date: 2013-10-27 01:09:00 +0200 (Sun, 27 Oct 2013)
New Revision: 1552
Modified:
pkg/blotter/R/tradeStats.R
Log:
- change to use getPortfolio so we don't change the environment
Modified: pkg/blotter/R/tradeStats.R
===================================================================
--- pkg/blotter/R/tradeStats.R 2013-10-26 19:30:49 UTC (rev 1551)
+++ pkg/blotter/R/tradeStats.R 2013-10-26 23:09:00 UTC (rev 1552)
@@ -243,18 +243,10 @@
{
ret <- NULL
for (Portfolio in Portfolios){
- ## Error Handling Borrowed from getPortfolio
pname <- Portfolio
- if (!grepl("portfolio\\.", pname))
- Portfolio <- try(get(paste("portfolio", pname, sep = "."), envir = .blotter), silent=TRUE)
- else Portfolio <- try(get(pname, envir = .blotter), silent=TRUE)
- if (inherits(Portfolio, "try-error"))
- stop(paste("Portfolio", pname, " not found, use initPortf() to create a new portfolio"))
- if (!inherits(Portfolio, "portfolio"))
- stop("Portfolio", pname, "passed is not the name of a portfolio object.")
+ Portfolio <- getPortfolio(pname)
-
## FIXME: need a way to define symbols for each portfolio
if(missing(Symbols)) symbols <- ls(Portfolio$symbols)
else symbols <- Symbols
@@ -286,18 +278,9 @@
{
ret <- NULL
for (Portfolio in Portfolios){
- ## Error Handling Borrowed from getPortfolio
pname <- Portfolio
- if (!grepl("portfolio\\.", pname))
- Portfolio <- try(get(paste("portfolio", pname, sep = "."), envir = .blotter), silent=TRUE)
- else Portfolio <- try(get(pname, envir = .blotter), silent=TRUE)
- if (inherits(Portfolio, "try-error"))
- stop(paste("Portfolio", pname, " not found, use initPortf() to create a new portfolio"))
- if (!inherits(Portfolio, "portfolio"))
- stop("Portfolio", pname, "passed is not the name of a portfolio object.")
+ Portfolio <- getPortfolio(pname)
-
-
## FIXME: need a way to define symbols for each portfolio
if(missing(Symbols)) symbols <- ls(Portfolio$symbols)
else symbols <- Symbols
More information about the Blotter-commits
mailing list