[Blotter-commits] r690 - pkg/FinancialInstrument/R
noreply at r-forge.r-project.org
noreply at r-forge.r-project.org
Wed Jul 20 23:39:54 CEST 2011
Author: gsee
Date: 2011-07-20 23:39:54 +0200 (Wed, 20 Jul 2011)
New Revision: 690
Modified:
pkg/FinancialInstrument/R/redenominate.R
Log:
minor error handling improvement. Tell user why there was an error if it cannot find rate.
Modified: pkg/FinancialInstrument/R/redenominate.R
===================================================================
--- pkg/FinancialInstrument/R/redenominate.R 2011-07-20 21:29:34 UTC (rev 689)
+++ pkg/FinancialInstrument/R/redenominate.R 2011-07-20 21:39:54 UTC (rev 690)
@@ -38,7 +38,10 @@
rsym <- paste(ccy2, ccy1, sep="/")
invert = TRUE
}
- rate <- get(rsym,pos=env)
+ rate <- try(get(rsym,pos=env),silent=TRUE)
+ if (inherits(rate,'try-error'))
+ stop(paste('Could not find exchange rate for ', ccy1,
+ ' and ', ccy2, ' in ', deparse(substitute(env)), sep=''))
rsym <- paste(substr(rsym,1,3), substr(rsym,nchar(rsym)-2,nchar(rsym)),sep="")
if (invert) {
rate <- 1/rate #inverting will reverse High/Low and Bid/Ask
@@ -129,7 +132,7 @@
x2 <- try(get(x[2],pos=env),silent=TRUE)
if (inherits(x1,'try-error') || inherits(x2,'try-error')) {
#maybe we can get the ratio directly
- if (!silent) warning(paste('Nothing to build. Returning data found in', deparse(substitute(env))))
+ if (!silent) warning(paste('Nothing to build. Returning data found in', deparse(substitute(env)),'if any.'))
return(.get_rate(x[1],x[2],env))
}
#!#---#!#
More information about the Blotter-commits
mailing list