[R-SIG-Finance] Multi-currency example for blotter

Wolfgang Wu wobwu22 at yahoo.de
Fri Mar 26 14:03:19 CET 2010


Is there an example of how to use blotter for multiple currencies. Imagine a portfolio of two stocks. One is denominated in USD the other in EUR. I buy them both at time t. At time t+1 I want to evaluate the value of the portfolio in USD. 

Would I do something like this?

require(blotter)
initDate='1997-12-31'
initEq=100000

currency("USD")
currency("EUR")

stock("A",currency="USD",multiplier=1)
stock("B", currency="EUR", multiplier=1)

getSymbols('A', src='yahoo', index.class=c("POSIXt","POSIXct"),from='1998-01-01')
getSymbols('B', src='yahoo', 
index.class=c("POSIXt","POSIXct"),from='1998-01-01')

initPortf('MultCurPort',symbols=c('A','B'), initDate=initDate)
initAcct('MultCurAcc',portfolios='MultCurPort', initDate=initDate, initEq=initEq)

CurrentDate = '1997-01-30'
addTxn('MultCurPort', Symbol='A', TxnDate=CurrentDate, TxnPrice=100, TxnQty = 1, TxnFees=0)
addTxn('MultCurPort', Symbol='A', TxnDate=CurrentDate, 
TxnPrice=50, TxnQty = 1, TxnFees=0)
updatePortf('MultCurPort', Dates = CurrentDate)
updateAcct('MultCurAcc', Dates = CurrentDate)
updateEndEq('MultCurAcc', Dates = CurrentDate)

CurrentDate = '1998-01-30'
updatePortf('MultCurPort', Dates = CurrentDate)
updateAcct('MultCurAcc', Dates = CurrentDate)
updateEndEq('MultCurAcc', Dates = CurrentDate)


a) What I don't understand is how the USDEUR currency rate is used. Do I need the time series for the currency as well? Something like
getSymbols('EUR', src='yahoo', 
index.class=c("POSIXt","POSIXct"),from='1998-01-01')? 

b) How do I get the value of the portfolio? Via getEndEq(Account, Date)? In what currency will the account be evaluated? 

Thanks for the help.

Regards,

 Wolfgang Wu


_______________________________
ügt über einen herausragenden Schutz gegen Massenmails. 
http://mail.yahoo.com



More information about the R-SIG-Finance mailing list