16/04/2020

Introduction

  • We plot the daily closing prices of the following major European stock indices from 1991-1998:
  1. Germany DAX (Ibis)
  2. Switzerland SMI
  3. France CAC
  4. UK FTSE
  • The data has been obtained from the EuStockMarkets dataset available on R, courtesy of Erste Bank AG, Vienna, Austria.

Data Processing

The following code loads the data and performs pre-processing.

suppressPackageStartupMessages(library(plotly))
suppressPackageStartupMessages(library(tidyr))
suppressPackageStartupMessages(library(dplyr))
data("EuStockMarkets")
stocks <- as.data.frame(EuStockMarkets) %>%
  gather(index, price) %>%
  mutate(time = rep(time(EuStockMarkets), 4))

Code for Plotly

Here is the code for the interactive plot.

plot <- plot_ly(stocks, x = ~time, y = ~price, 
        color = ~index, mode = "lines") 
        %>% layout(title = "Trends in European 
        Stock Indices (1991-1998)")
plot

Plot

The End