[Blotter-commits] r994 - in pkg/FinancialInstrument: . R

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Mon Apr 2 01:58:26 CEST 2012


Author: gsee
Date: 2012-04-02 01:58:26 +0200 (Mon, 02 Apr 2012)
New Revision: 994

Modified:
   pkg/FinancialInstrument/DESCRIPTION
   pkg/FinancialInstrument/R/redenominate.R
Log:
 in redenominate, if both currencies are the same, use 1 as the exchange rate 
 instead of failing

Modified: pkg/FinancialInstrument/DESCRIPTION
===================================================================
--- pkg/FinancialInstrument/DESCRIPTION	2012-03-31 17:29:03 UTC (rev 993)
+++ pkg/FinancialInstrument/DESCRIPTION	2012-04-01 23:58:26 UTC (rev 994)
@@ -11,7 +11,7 @@
     meta-data and relationships. Provides support for
     multi-asset class and multi-currency portfolios. Still
     in heavy development.
-Version: 0.13.5
+Version: 0.13.6
 URL: https://r-forge.r-project.org/projects/blotter/
 Date: $Date$
 Depends:

Modified: pkg/FinancialInstrument/R/redenominate.R
===================================================================
--- pkg/FinancialInstrument/R/redenominate.R	2012-03-31 17:29:03 UTC (rev 993)
+++ pkg/FinancialInstrument/R/redenominate.R	2012-04-01 23:58:26 UTC (rev 994)
@@ -335,11 +335,13 @@
     idxx <- index(x)
     #Now figure out the exchange rate
     #First assume that both bases are currencies, and look for an exchange rate
-    rate <- try(.get_rate(new_base,old_base,env),silent=TRUE) #try with formats like EURUSD, EUR.USD, EUR/USD, and their inverses
-    if (inherits(rate,'try-error')) {
-        rate <- buildRatio(c(old_base, new_base), env=env) #maybe it's not FX
-    }
-
+    if (!identical(new_base, old_base)) {
+        rate <- try(.get_rate(new_base,old_base,env),silent=TRUE) #try with formats like EURUSD, EUR.USD, EUR/USD, and their inverses
+        if (inherits(rate,'try-error')) {
+            rate <- buildRatio(c(old_base, new_base), env=env) #maybe it's not FX
+        }
+    } else rate <- xts(rep(1L, nrow(x)), index(x))
+    
     #!#---#!# Define function we'll need
     has.Mid <- quantmod:::has.Mid
     Mid <- #This should be exported from quantmod



More information about the Blotter-commits mailing list