By Edina Berlinger, Ferenc Illés, Milán Badics, Ádám Banai, Gergely Daróczi, Barbara Dömötör, Gergely Gabler, Dániel Havran, Péter Juhász, István Margitai, Balázs Márkus, Péter Medvegyev, Julia Molnár, Balázs Árpád Szűcs, Ágnes Tuza, Tamás Vadász, Kata Váradi, Ágnes Vidovics-Dancs
#With this command you install the package:
#install.packages("Quandl")
#install.packages("quantmod")
library("Quandl")
## Loading required package: xts
## Loading required package: zoo
##
## Attaching package: 'zoo'
## The following objects are masked from 'package:base':
##
## as.Date, as.Date.numeric
library("quantmod")
## Loading required package: TTR
## Version 0.4-0 included new data defaults. See ?getSymbols.
Quandl.api_key('vXoUyjsb171PsE3FKy7W')
currencies <- c( "USD", "CHF", "GBP", "JPY", "RUB", "CAD", "AUD")
currencies <- paste("CURRFX/EUR", currencies, sep = "")
currency_ts <- lapply(as.list(currencies), Quandl, start_date="2005-01-01",end_date="2013-06-07", type="xts")
Q <- cbind(currency_ts[[1]]$Rate,currency_ts[[3]]$Rate,currency_ts[[6]]$Rate,currency_ts[[7]]$Rate)
matplot(Q, type = "l", xlab = "Jan 03 2005 Jan 01 2007 Jan 01 2009 Jan 03 2011 Jan 01 2013", ylab = "Exhange rate from 0.7 to 2.1", main = "USD, GBP, CAD, AUD", xaxt = 'n', yaxt = 'n')
library(quantmod)
bmw_stock<- new.env()
getSymbols("BMW.DE", env = bmw_stock, src = "yahoo", from = as.Date("2010-01-01"), to=as.Date("2013-12-31"))
## 'getSymbols' currently uses auto.assign=TRUE by default, but will
## use auto.assign=FALSE in 0.5-0. You will still be able to use
## 'loadSymbols' to automatically load data. getOption("getSymbols.env")
## and getOption("getSymbols.auto.assign") will still be checked for
## alternate defaults.
##
## This message is shown once per session and may be disabled by setting
## options("getSymbols.warning4.0"=FALSE). See ?getSymbols for details.
##
## WARNING: There have been significant changes to Yahoo Finance data.
## Please see the Warning section of '?getSymbols.yahoo' for details.
##
## This message is shown once per session and may be disabled by setting
## options("getSymbols.yahoo.warning"=FALSE).
## [1] "BMW.DE"
BMW<-bmw_stock$BMW.DE
head(BMW)
## BMW.DE.Open BMW.DE.High BMW.DE.Low BMW.DE.Close BMW.DE.Volume
## 2010-01-04 31.820 32.455 31.820 32.050 1808170
## 2010-01-05 31.960 32.410 31.785 32.310 1564182
## 2010-01-06 32.450 33.040 32.360 32.810 2218604
## 2010-01-07 32.650 33.200 32.380 33.100 2026145
## 2010-01-08 33.335 33.430 32.515 32.655 1925894
## 2010-01-11 32.995 33.050 32.110 32.170 2157825
## BMW.DE.Adjusted
## 2010-01-04 32.050
## 2010-01-05 32.310
## 2010-01-06 32.810
## 2010-01-07 33.100
## 2010-01-08 32.655
## 2010-01-11 32.170
chartSeries(BMW,multi.col=TRUE,theme="white")
BMW_return <- log(BMW$BMW.DE.Close/BMW$BMW.DE.Open)
qqnorm(BMW_return, main = "Normal Q-Q Plot of BMW daily log return", xlab = "Theoretical Quantiles", ylab = "Sample Quantiles", plot.it = TRUE, datax = FALSE)
qqline(BMW_return, col="red")