CommencerCommencer gratuitement

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.

Cet exercice fait partie du cours

Quantitative Risk Management in R

Afficher le cours

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().

Exercice interactif pratique

Essayez cet exercice en complétant cet exemple de 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
___(___)
Modifier et exécuter le code