In [4]:
library(zoo)
library(xts)
library(Quandl)
In [2]:
# Get data from Quandl
spx = Quandl("YAHOO/INDEX_GSPC", start_date="2014-01-01")
dax = Quandl("YAHOO/INDEX_GDAXI", start_date="2014-01-01")
exc = Quandl("ECB/EURUSD", start_date="2014-01-01") #exchange rate eurusd
# Observe the data
print("SPX Index")
head(spx)
print("DAX Index")
head(dax)
print("EUR/USD")
head(exc)
In [17]:
zspx = zoo(spx$Close, order.by=spx$Date)
zdax = zoo(dax$Close, order.by=dax$Date)
#zexc = zoo(exc$Value, order.by=exc$Date)
#zspx.rets = log(lag(zspx)) - log(zspx)
#zdax.rets = log(lag(zdax)) - log(zdax)
#zexc.rets = log(lag(zexc)) - log(zexc)
eurusd = zoo(exc$Value, order.by=exc$Date)
daxspx = zdax/zspx
spxdax = zspx/zdax
In [27]:
m_eurusd_spxdax = merge(eurusd,spxdax)
m_eurusd_daxspx = merge(eurusd,daxspx)
plot(m_eurusd_spxdax)
plot(m_eurusd_daxspx)
In [29]:
print(cor(na.locf(m_eurusd_spxdax$eurusd),na.locf(m_eurusd_spxdax$spxdax)))
print(cor(na.locf(m_eurusd_daxspx$eurusd),na.locf(m_eurusd_daxspx$daxspx)))
It can be seen that there is no significant correlation between spx/dax and eur/usd The fundamental foundation of the strategy is not promising.