Learn R Programming

FinancialInstrument (version 1.3.1)

redenominate: Redenominate (change the base of) an instrument

Description

Redenominate (change the base of) an instrument

Usage

redenominate(x, new_base = "USD", old_base = NULL, EOD_time = "15:00:00",
  env = .GlobalEnv, silent = FALSE)

Arguments

x

can be either an xts object or the name of an instrument.

new_base

change the denomination to this; usually a currency.

old_base

what is the current denomination?

EOD_time

If data need to be converted to daily, this is the time of day to take the observation.

env

environment that holds the data

silent

silence warnings?

Value

xts object, with as many columns as practicable, that represents the value of an instrument in a different currency (base).

Details

If old_base is not provided, x must be the name of an instrument (or an object with the name of a defined instrument) so that the currency attribute of the instrument can be used. Otherwise, old_base must be provided.

If you want to convert to JPY something that is denominated in EUR, you must have data for the EURJPY (or JPYEUR) exchange rate. If you don't have data for EURJPY, but you do have data for EURUSD and USDJPY, you could redenominate to USD, then redenominate to EUR, but this function is not yet smart enough to do that for you.

See the help for buildRatio also.

See Also

buildRatio

Examples

Run this code
# NOT RUN {
# }
# NOT RUN {
require(quantmod)
EURUSD <- getSymbols("EURUSD=x",src='yahoo',auto.assign=FALSE)
GLD <- getSymbols("GLD", src='yahoo', auto.assign=FALSE)
GLD.EUR <- redenominate(GLD,"EUR","USD") #can call with xts object

currency("USD")
stock("GLD","USD")
GLD.EUR <- redenominate('GLD','EUR') #can also call with instrument name
# }

Run the code above in your browser using DataLab