Get startedGet started for free

Exploring risk-factor data: exchange rates

For a portfolio with risk exposure in different countries, it is necessary to consider the risk coming from foreign exchange (FX) rates. The qrmdata package includes FX rate data for many currencies, ranging from Swiss Francs to Japanese Yen, with respect to the USD (United States dollar) and GBP (Great Britain pound).

In this exercise, you will look at the datasets "EUR_USD" and "GBP_USD", which contain the Euro and British pound exchange rates against the US dollar. Then, you will merge these time series and plot them together for the period 2010-2015.

This exercise is part of the course

Quantitative Risk Management in R

View Course

Exercise instructions

  • Load the foreign exchange data "GBP_USD" and "EUR_USD" from qrmdata.
  • Use plot() to plot each exchange rate separately.
  • Use plot() and the inverse of GBP_USD to plot a US dollar to British pound exchange rate.
  • Use merge() to merge the GBP_USD and EUR_USD data, in that order, as object fx.
  • Extract the exchange rates for 2010-15 from fx and assign to fx0015.
  • Plot fx0015 using plot.zoo().

Hands-on interactive exercise

Have a go at this exercise by completing this sample code.

# Load exchange rate data
___(___)
___(___)

# Plot the two exchange rates
___(___)
___(___)

# Plot a USD_GBP exchange rate
___(___)

# Merge the two exchange rates GBP_USD and EUR_USD
fx <- merge(___, ___, all = TRUE)

# Extract 2010-15 data from fx and assign to fx0015
fx0015 <- ___

# Plot the exchange rates in fx0015
___(___)
Edit and Run Code