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

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Fri Jun 24 16:02:06 CEST 2011


Author: braverock
Date: 2011-06-24 16:02:05 +0200 (Fri, 24 Jun 2011)
New Revision: 637

Modified:
   pkg/blotter/R/updateAcct.R
   pkg/blotter/R/updatePosPL.R
Log:
- reverse order of currency conversion to match FX convention, thanks to Garrett See for spotting inconsitencies
- NOTE: we should actually check the $currency slot and $counter_currency slot instead, but this is an improvement


Modified: pkg/blotter/R/updateAcct.R
===================================================================
--- pkg/blotter/R/updateAcct.R	2011-06-24 04:14:35 UTC (rev 636)
+++ pkg/blotter/R/updateAcct.R	2011-06-24 14:02:05 UTC (rev 637)
@@ -42,10 +42,11 @@
 				warning("Currency",p.ccy.str," not found, using currency multiplier of 1")
 				CcyMult<-1
 			} else {
-				FXrate.str<-paste(a.ccy.str,p.ccy.str,sep='')
+				FXrate.str<-paste(p.ccy.str,a.ccy.str,sep='') # currency quote convention is EURUSD which reads as "USD per EUR"
 				FXrate<-try(get(FXrate.str))
+				#TODO FIXME: this uses convention to sort out the rate, we should check $currency and $counter_currency and make sure directionality is correct 
 				if(inherits(FXrate,"try-error")){
-					FXrate.str<-paste(p.ccy.str,a.ccy.str,sep='')
+					FXrate.str<-paste(a.ccy.str,p.ccy.str,sep='')
 					FXrate<-try(get(FXrate.str))
 					if(inherits(FXrate,"try-error")){ 
 						warning("Exchange Rate",FXrate.str," not found for symbol,',Symbol,' using currency multiplier of 1")

Modified: pkg/blotter/R/updatePosPL.R
===================================================================
--- pkg/blotter/R/updatePosPL.R	2011-06-24 04:14:35 UTC (rev 636)
+++ pkg/blotter/R/updatePosPL.R	2011-06-24 14:02:05 UTC (rev 637)
@@ -154,10 +154,11 @@
 				warning("Currency",p.ccy.str," not found, using currency multiplier of 1")
 				CcyMult<-1
 			} else {
-				FXrate.str<-paste(tmp_instr$currency,p.ccy.str,sep='')
+				FXrate.str<-paste(p.ccy.str,tmp_instr$currency,sep='') # currency quote convention is EURUSD which reads as "USD per EUR"
 				FXrate<-try(get(FXrate.str))
+				#TODO FIXME: this uses convention to sort out the rate, we should check $currency and $counter_currency and make sure directionality is correct 
 				if(inherits(FXrate,"try-error")){
-					FXrate.str<-paste(p.ccy.str,tmp_instr$currency,sep='')
+					FXrate.str<-paste(tmp_instr$currency,p.ccy.str,sep='')
 					FXrate<-try(get(FXrate.str))
 					if(inherits(FXrate,"try-error")){ 
 						warning("Exchange Rate",FXrate.str," not found for symbol,',Symbol,' using currency multiplier of 1")



More information about the Blotter-commits mailing list