#!/usr/bin/env python # coding: utf-8 # # **The Euro on Forex** # ## **Exploring Twenty Years of Volatility** # ### Very Brief History # The currency exchange market has been around since coins were first used. At the end of the 1800s the development of the gold standard fixed currency values to a certain amount of gold, allowing for an internationally stable monetary system (1). Eventually the amount of gold was not enough to keep up with the demand for currency. After World War II the Bretton Woods Accord set the US Dollar as the global fixed currency. This created an adjustable rate exchange, but it was still determined by central banks and state actors (2). The US dollar was pegged to gold at the time, and during the 1970s the same liquidity problem (i.e. amount of gold vs currency in circulation) occurred. In August of 1971 President Richard Nixon unilaterally canceled direct international convertibility of the US dollar to gold, inadvertently beginning a regime of free-floating currencies (3). # # ### Today # The modern foreign exchange market (Forex, FX, or currency market) is a direct broker to dealer global marketplace that determines the market value and exchange rate of currencies all over the world. It is open 24 hours a day, 5 days a week. Currencies are always traded in pairs, and the value expressed is of one currency relative to another. For example, at the end of the day on 11/19/21 the Euro to US dollar rate was 1.13, or $1.13 equals €1. All of the twenty most traded currencies are free-floating, their value is determined by political conditions, economic factors and market psychology. # # Forex is by far the largest financial market in the world, in 2019 having a daily volume of over $6.6 trillion (4). The Euro to US dollar (EURUSD) is the most traded currency pair, taking about 30% of the multi-billion dollar Forex turnover (5). # # ### Methodology # This study examines the more than two decades of exchange rates for the Euro. It uses the 2019 Triennial Central Bank Survey by the Bank for International Settlements to determine four currencies that represent large portions of the market and four currencies that represent small portions of the market. The highly traded currencies are the US dollar, Japanese yen, UK pound, and Australian dollar. The Israeli shekel, Phillipine peso, Malaysian ringgit, and Romanian leu comprise the group of least traded currencies. # # The data set used is based on daily closing values provided by the European Central Bank and compiled by Daria Chemkaeva. It is updated weekly, the version used for this study was downloaded from Kaggle in November 2021. # # ### Summary # This study demonstrates that geopolitics has broad influence on the foreign exchange market. This is shown through the correlation between historical events and changes in FOREX. This study also reveals global and regional synchronicity in exchange rate volatility. # ## **Euro & Traded Pairs** # ### Euro to Highly Traded Currencies # The first set of line graphs represent the exchange rates for the Euro to the US dollar, Japanese yen, UK pound, and Australian dollar. These four currencies, in addition to the Euro, are the top five currencies in the Forex market. All five together comprise over 75% of daily trades (4). # ### Euro to Least Traded Currencies # The second set of graphs represent the exchange rates for the Euro to the Israeli shekel, Philippine peso, Malaysian ringgit, and Romanian leu. These four currencies have low trade volumes, they comprise less than 0.4% of daily trades (4). # In[1]: # import libraries and set display options import pandas as pd import pprint # set frame width and center output from IPython.core.display import display, HTML display(HTML(""" """)) # pretty print options pd.options.display.float_format = '{:20,.4f}'.format pd.set_option('display.max_rows', None) pd.set_option('display.max_columns', None) pd.set_option('display.width', 3000) pd.set_option('display.colheader_justify', 'center') pd.set_option('display.precision', 3) # open file x_rates = pd.read_csv("euro-daily-hist_1999_2020.csv") # remove brackets and trailing space # replace remaining space with underscore x_rates.columns = x_rates.columns.str.lower() x_rates.columns = x_rates.columns.str.replace("[", "", regex=False).str.replace("]", "", regex=False).str.rstrip() x_rates.columns = x_rates.columns.str.replace(" ","_", regex=False) # rename columns x_rates.rename(columns={"period\\unit:":"date", "chinese_yuan_renminbi":"chinese_yuan", "uk_pound_sterling":"uk_pound"}, inplace=True) # convert datetime x_rates["date"] = pd.to_datetime(x_rates["date"]) # resort and reindex x_rates.sort_values("date", inplace=True) x_rates.reset_index(drop=True, inplace=True) # convert hyphens in currency columns to NaN import numpy as np x_rates = x_rates.replace("-", np.nan) # convert exchange rate values to float x_rates.iloc[:,1:] = x_rates.iloc[:,1:].astype(float) # display(x_rates.head()) # In[2]: # import matplot import matplotlib.pyplot as plt plt.rcParams.update({'figure.max_open_warning': 0}) import matplotlib.dates as mdates plt.style.use('ggplot') # set style for graphs # import colormap and set up color iteration from matplotlib.pyplot import cm colors = iter([plt.cm.tab10(i) for i in range(8)]) # create a list of data frames for each currency with log rate of the exchange rate, 30 day rolling mean, and year df_dict = {} for currency in x_rates.columns[1:]: df_name = currency df = x_rates[["date", currency]].copy() df = df[df[currency].notna()] df["log_rate"] = np.log(df.iloc[:,1]/df.iloc[:,1].shift()) # getting the log of the exchange rate # double check this is the correct way to get log df["rolling_mean_30"] = df[currency].rolling(30).mean() df["year"] = df["date"].dt.year df_dict[currency] = df # currencies for comparison high_freq = [df_dict["us_dollar"], df_dict["japanese_yen"], df_dict["uk_pound"], df_dict["australian_dollar"]] low_freq = [df_dict["israeli_shekel"], df_dict["philippine_peso"], df_dict["malaysian_ringgit"], df_dict["romanian_leu"]] # line graph showing Euro to each high frequency trading pairs fig, ((ax1, ax2), (ax3, ax4)) = plt.subplots(nrows=2, ncols=2, figsize=(18,10)) for ax, currency in zip((ax1, ax2, ax3, ax4), high_freq): ax.plot(currency["date"], currency["rolling_mean_30"], linewidth=3, c=next(colors)) for ax in ax1, ax2, ax3, ax4: ax.set_xticks(["2000-01-04 00:00:00", "2005-01-04 00:00:00", "2010-01-04 00:00:00", "2015-01-04 00:00:00", "2020-01-04 00:00:00"]) ax.set_xticklabels([2000,2005,2010,2015,2020], fontsize=18) ax.set(yticks=[]) # ax.set_ylabel(str(currency)) # why not, i can get it to change to a string "currency", but not a variable ax1.set_ylabel("US dollar", fontsize=18, weight="bold", color="tab:blue") ax2.set_ylabel("Japanese yen", fontsize=18, weight="bold", color="tab:orange") ax2.yaxis.set_label_position("right") ax3.set_ylabel("UK pound", fontsize=18, weight="bold", color="tab:green") ax4.set_ylabel("Australian dollar", fontsize=18, weight="bold", color="tab:red") ax4.yaxis.set_label_position("right") plt.subplots_adjust(wspace=0.01,hspace=0.01) ax.text(0.08, 0.0, "© B McMinn" + " "*174 + "Source: European Central Bank", color = "#f0f0f0", backgroundcolor = "#4d4d4d", fontsize=14, transform=fig.transFigure) fig.suptitle(" "*21 + "Euro to High Frequency Pairs" + " "*21, color = "#f0f0f0", backgroundcolor = "#4d4d4d", fontsize=35, weight="bold") plt.show() # line graph showing Euro to each low frequency trading pairs fig, ((ax1, ax2), (ax3, ax4)) = plt.subplots(nrows=2, ncols=2, figsize=(18,10), sharex=True) for ax, currency in zip((ax1, ax2, ax3, ax4), low_freq): ax.plot(currency["date"], currency["rolling_mean_30"], linewidth=3, c=next(colors)) for ax in ax1, ax2, ax3, ax4: ax.set_xticks(["2000-01-04 00:00:00", "2005-01-04 00:00:00", "2010-01-04 00:00:00", "2015-01-04 00:00:00", "2020-01-04 00:00:00"]) ax.set_xticklabels([2000,2005,2010,2015,2020], fontsize=18) ax.set(yticks=[]) # ax.set_ylabel(str(currency)) # why not, i can get it to change to a string "currency", but not a variable ax1.set_ylabel("Israeli shekel", fontsize=18, weight="bold", color="tab:purple") ax2.set_ylabel("Philippine peso", fontsize=18, weight="bold", color="tab:brown") ax2.yaxis.set_label_position("right") ax3.set_ylabel("Malaysian ringgit", fontsize=18, weight="bold", color="tab:pink") ax4.set_ylabel("Romanian leu", fontsize=18, weight="bold", color="tab:grey") ax4.yaxis.set_label_position("right") plt.subplots_adjust(wspace=0.01,hspace=0.01) ax.text(0.08, 0.0, "© B McMinn" + " "*174 + "Source: European Central Bank", color = "#f0f0f0", backgroundcolor = "#4d4d4d", fontsize=14, transform=fig.transFigure) fig.suptitle(" "*22 + "Euro to Low Frequency Pairs" + " "*22, color = "#f0f0f0", backgroundcolor = "#4d4d4d", fontsize=35, weight="bold") plt.show() # ## **Euro & Traded Pairs Conclusion** # # ### High Frequency Pairs # * The US dollar, Japanese yen, and UK pound all show a tight ratio (1:1) with the Euro in the early 2000s. # * Both the Japanese yen and Australian dollar have a period in 2011 or 2012 where the exchange ratio gets tight and then rebounds. Is it really at the same time? Are there any other countries with the same pattern and what could the cause have been? # ### Low Frequency Pairs # * The Israeli shekel appears to have steadily closed it's ratio to the Euro over the last two decades, while the Romanian leu is definitely loosing value. # * The shekel and leu appear to be fairly stable, or have low volatility. # * The Israeli shekel, Malaysian ringgit, and Phillipine peso also show the tight ratio of the early 2000s. # # ## **Alignments** # We can answer some questions and come up with some new ones by overlapping graphs of the exchange rates. Closer looks will often reveal how currencies respond to similar events. The graph below examines the rate for the Euro to the four major currencies simultaneously. # In[3]: # line graph showing Euro to four high frequency trading pairs overlapped chart_date_high = (df_dict["us_dollar"]["date"]) colors = iter([plt.cm.tab10(i) for i in range(0,4)]) fig, ax = plt.subplots(figsize=(18,10)) ax1 = ax.twinx() ax2 = ax.twinx() ax3 = ax.twinx() for ax, currency in zip ((ax, ax1,ax2,ax3), high_freq): ax.plot(chart_date_high, currency["rolling_mean_30"], linewidth=3, c=next(colors)) ax.set_xticks(["2000-01-04 00:00:00", "2005-01-04 00:00:00", "2010-01-04 00:00:00", "2015-01-04 00:00:00", "2020-01-04 00:00:00"]) ax.set_xticklabels([2000,2005,2010,2015,2020], fontsize=18) ax.set(yticks=[]) # Sept 11, 2001 sept11 = df_dict["us_dollar"]["date"] == "2001-09-11" sept11 = df_dict["us_dollar"][sept11] sept11 = sept11["date"] ax.axvline(x=sept11, alpha=0.8, color="gold", linewidth=2) ax.axvspan(xmin=chart_date_high.iloc[11], xmax=chart_date_high.iloc[701], ymax=0.97, ymin=0.86, alpha=0.4, color='gold') ax.text(0.165, 0.82, "9/11 attacks", color="black", fontsize=16, transform=fig.transFigure) ax.text(0.165, 0.8, "in US", color="black", fontsize=16, transform=fig.transFigure) # EESA eesa = df_dict["us_dollar"]["date"] == "2008-10-03" eesa = df_dict["us_dollar"][eesa] eesa = eesa["date"] ax.axvline(x=eesa, color="gold", linewidth=2) ax.axvspan(xmin=chart_date_high.iloc[1604], xmax=chart_date_high.iloc[2504], ymax=0.19, ymin=0.10, alpha=0.4, color='gold') ax.text(0.365, 0.23, "E.E.S.A. enacted", color="black", fontsize=16, transform=fig.transFigure) ax.text(0.365, 0.21, "in US", color="black", fontsize=16, transform=fig.transFigure) # European Debt Crisis # https://www.businessinsider.com/s?q=euro+forex+2012 # https://www.ecb.europa.eu/pub/pdf/scpwps/ecbwp1532.pdf edc = df_dict["us_dollar"]["date"] == "2012-09-06" edc = df_dict["us_dollar"][edc] edc = edc["date"] ax.axvline(x=edc, color="gold", linewidth=2) ax.axvspan(xmin=chart_date_high.iloc[3508], xmax=chart_date_high.iloc[4488], ymax=0.97, ymin=0.86, alpha=0.4, color='gold') ax.text(0.60, 0.82, "ECB announces", color="black", fontsize=16, transform=fig.transFigure) ax.text(0.60, 0.8, "unlimited support", color="black", fontsize=16, transform=fig.transFigure) # other text fig.suptitle(" "*12 + "Alignment of Euro/High Frequency Pairs" + " "*12, color = "#f0f0f0", backgroundcolor = "#4d4d4d", fontsize=35, weight="bold") ax.text(0.75, 0.24, "US dollar", color="tab:blue", fontsize=18, weight="bold", transform=fig.transFigure) ax.text(0.75, 0.21, "Japanese yen", color="tab:orange", fontsize=18, weight="bold", transform=fig.transFigure) ax.text(0.75, 0.17, "UK pound", color="tab:green", fontsize=18, weight="bold", transform=fig.transFigure) ax.text(0.75, 0.14, "Australian dollar", color="tab:red", fontsize=18, weight="bold", transform=fig.transFigure) ax.text(0.08, 0.0, "© B McMinn" + " "*174 + "Source: European Central Bank", color = "#f0f0f0", backgroundcolor = "#4d4d4d", fontsize=14, transform=fig.transFigure) plt.show() # ## **Alignments Conclusion** # The overlay of the four major currencies shows some very interesting patterns. Broadly speaking, there are periods of strong alignment, divergent alignment, and times with minimal correlation. # * The Japanese yen, UK pound, and US dollar all track closely from the start of data collection through the early years following the September 11 attacks in the US. # * The September 11 attacks also mark a long period where those three currencies have a looser trade ratio with the Euro. It is not evident if this is due to a strong Euro or if the other currencies are trading lower in conjunction. # * In October of 2008 the US President, Treasury Secretary, and Congress enacted the Emergency Economic Stabilization Act, the main pillar of which was the $700 billion Troubled Asset Relief Program (7). This was in response to the 2007-2008 Financial Crises and led to an "unprecedented federal intervention to rescue banks and restore confidence to the finance sector" (8). It marks an interesting point in the Alignment of Euro/High Frequency Pairs graph, and can be seen more closely in the zoomed image below. #