[Blotter-commits] r642 - in pkg: blotter/R quantstrat/demo

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Sat Jun 25 22:53:58 CEST 2011


Author: gsee
Date: 2011-06-25 22:53:58 +0200 (Sat, 25 Jun 2011)
New Revision: 642

Modified:
   pkg/blotter/R/updateAcct.R
   pkg/blotter/R/updatePosPL.R
   pkg/quantstrat/demo/faberMC.R
Log:
-exchange rate patches.

Modified: pkg/blotter/R/updateAcct.R
===================================================================
--- pkg/blotter/R/updateAcct.R	2011-06-25 20:18:41 UTC (rev 641)
+++ pkg/blotter/R/updateAcct.R	2011-06-25 20:53:58 UTC (rev 642)
@@ -36,18 +36,18 @@
 		psummary = Portfolio$summary[Dates]
 		if( a.ccy.str != p.ccy.str ){
             # If not, translate the portfolio summary to the account currency
-			
+			CcyMult <- NA
 			port_currency<-try(getInstrument(p.ccy.str))
 			if(inherits(port_currency,"try-error") | !is.instrument(port_currency)){
 				warning("Currency",p.ccy.str," not found, using currency multiplier of 1")
 				CcyMult<-1
 			} else {
 				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))
+				FXrate<-try(get(FXrate.str), silent=TRUE)
 				#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(a.ccy.str,p.ccy.str,sep='')
-					FXrate<-try(get(FXrate.str))
+					FXrate<-try(get(FXrate.str), silent=TRUE)
 					if(inherits(FXrate,"try-error")){ 
 						warning("Exchange Rate",FXrate.str," not found for symbol,',Symbol,' using currency multiplier of 1")
 						CcyMult<-1

Modified: pkg/blotter/R/updatePosPL.R
===================================================================
--- pkg/blotter/R/updatePosPL.R	2011-06-25 20:18:41 UTC (rev 641)
+++ pkg/blotter/R/updatePosPL.R	2011-06-25 20:53:58 UTC (rev 642)
@@ -153,13 +153,13 @@
 			if(inherits(port_currency,"try-error") | !is.instrument(port_currency)){
 				warning("Currency",p.ccy.str," not found, using currency multiplier of 1")
 				CcyMult<-1
-			} else {
-				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))
+			} else { #convert from instr ccy to portfolio ccy
+				FXrate.str<-paste(tmp_instr$currency, p.ccy.str, sep='') # currency quote convention is EURUSD which reads as "USD per EUR"
+				FXrate<-try(get(FXrate.str), silent=TRUE)
 				#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(tmp_instr$currency,p.ccy.str,sep='')
-					FXrate<-try(get(FXrate.str))
+					FXrate.str<-paste(p.ccy.str, tmp_instr$currency, sep='')
+					FXrate<-try(get(FXrate.str), silent=TRUE)
 					if(inherits(FXrate,"try-error")){ 
 						warning("Exchange Rate",FXrate.str," not found for symbol,',Symbol,' using currency multiplier of 1")
 						CcyMult<-1

Modified: pkg/quantstrat/demo/faberMC.R
===================================================================
--- pkg/quantstrat/demo/faberMC.R	2011-06-25 20:18:41 UTC (rev 641)
+++ pkg/quantstrat/demo/faberMC.R	2011-06-25 20:53:58 UTC (rev 642)
@@ -63,9 +63,9 @@
 currency("EUR")
 
 #get the currencies
-JPYUSD<-getPrice(to.monthly(getSymbols("JPY=X",auto.assign=FALSE),indexAt='lastof',drop.time=TRUE))
+USDJPY<-getPrice(to.monthly(getSymbols("JPY=X",auto.assign=FALSE),indexAt='lastof',drop.time=TRUE))
 EURUSD<-getPrice(to.monthly(getSymbols("EURUSD=X",auto.assign=FALSE),indexAt='lastof',drop.time=TRUE))
-colnames(JPYUSD)<-"JPYUSD"
+colnames(USDJPY)<-"USDJPY"
 colnames(EURUSD)<-"EURUSD"
 
 getSymbols(symbols,from=initDate)



More information about the Blotter-commits mailing list