ECO412 Project - Forecasting Exchange Rates Through Machine Learning and Econometric Models
ECO412 Project - Forecasting Exchange Rates Through Machine Learning and Econometric Models
ECO412 Project - Forecasting Exchange Rates Through Machine Learning and Econometric Models
An important milestone in the history of exchange rates is the Bretton Woods
Conference, which led to the establishment of the IMF (International Monetary
Fund), to monitor exchange rates and to lend reserve currencies to nations,
and the IBRD (now the World Bank), to provide financial assistance for countries
during reconstruction after the World War 1 phase. The conference was held in
1944 and was attended by 44 allied nations. Under this agreement, to
exchange currencies the countries settled their international balance in dollars,
while US dollars were fully convertible to gold. This agreement dissolved
between 1968-1973 due to the over-valuation of the dollar which led to
concerns over exchange rates and their tie to the price of gold. After the
dissolution of this system, most of the countries started using the floating
exchange rate system.
In today’s global economy, precision in predicting the exchange rates or at
least forecasting the trend correctly is of high significance for any investment.
Using an exchange rate estimate can help brokers and businesses make
informed judgments to help minimise risks and maximize gains. Though
numerous research papers have been published in this area since decades,
forecasting exchange rates with extraordinary accuracy is still a challenge. The
rates are inherently noisy, non-stationary and deterministically chaotic. In this
project, I will explore the two prominent ways of exchange rate predictions - via
Machine Learning and through Econometric models.
Literature Review
The difficulty in forecasting the exchange rates is partly reflected in the
existence of multiple theoretical models of exchange rate prediction and
several modelling approaches. Before the breakdown of Bretton Woods, most
of the exchange rate models were based on the fixed price assumptions. Now,
machine learning and econometric models have made them obsolete. Still,
there are two fundamental models that are also worth mentioning - exchange
rate prediction through PPP forecasting and the relative economic strength
model.
The PPP forecasting approach is based on the theoretical law of one price,
which states that identical goods and services in different nations should have
identical prices. For example, this law states that a pencil in India should be the
same price as a pencil in the United States after taking into account the
exchange rate and excluding shipping and transaction costs. In other words,
there should not arise an arbitrage opportunity for someone to buy inexpensive
pencils in one country and sell them in another for a profit. The PPP approach
forecasts that the exchange rate will change to offset price changes due to
inflation based on this underlying principle.
The relative economic strength model predicts the direction of exchange rates
by taking into consideration the strength of economic growth in different
countries. The idea behind this approach is that strong economic growth will
attract higher investments from foreign investors. To pay for these investments
in a particular country, the investor will buy the country’s currency, thereby
increasing the demand and price of the currency of that particular country.
The econometric models have received a lot of attention. Obstfeld and Rogoff
(1994) developed an analytically tractable two-country model that marries a full
account of dynamics to a supply framework based on monopolistic competition
and sticky prices. It offers simple and intuitive predictions about exchange rates
and current accounts. Dua and Ranjan (2011) analyzed several univariate
exchange rate models and various extensions thereof in the vector
autoregressive (VAR) and Bayesian VAR framework. The results showed that
both VAR and BVAR generally outperform the random walk based on forecasts
in a projection of one year and less than one year. Ghalayini (2014) estimated
several univariate ARIMA models using lagged values as explanatory variables
and extensions with two fundamental explanatory variables, which showed that
the PPP theory explains the main part of the euro/dollar exchange rate, and in
this case the interest differential of the fundamental variable explains only a
small proportion of subsequent changes in exchange rates. Balter, Dumitrescu
and Hansen (2015) used a realized GARCH model and showed that it
outperforms the traditional CCC, cDCC and diagonal BEKK models up to 10
period-ahead. Bayas (2018) predicted the monthly EUR/USD exchange rate
using linear regression with PPP index, Basis SWAP Libor, and historical
volatility as the features or inputs. They obtained the percentage errors below
2.9% in their initial models and as low as 0.09% in their improved model.
Methodology
Data Extraction
The currencies selected for this project are the U.S Dollar and the Indian
Rupee, more specifically, the USD/INR exchange rate. This pair was chosen as
the Indian Rupee is the most relevant currency for more than a billion Indians
and not much research work is focused on it. Moreover, the US Dollar and the
Indian Rupee are both mainly affected by macroeconomic agents, and not
much affected by news or political issues, which are not incorporated into this
project.
The weekly USD/INR exchange rate historical data was obtained from the
World Bank website. The dataset contains the following fields: Date, Opening
Price, Closing Price, Highest Price, Lowest Price and the Change Percentage.
Data from October 2005 to November 2019 was used. The data was sorted
and checked for any missing or illegal values. It was then divided into training
and test data, with the first 80% values comprising the training dataset and the
last 20% comprising the test dataset.
Data Visualisation
The data was visualised using matplotlib’s pyplot to envision the trends in the
data and to appreciate the significant variations. The exchange rate was around
Rs. 45 in 2005 and has risen to around Rs. 70 in 2019, with achieving a low of
Rs. 40 during the Great Recession of 2008 and almost touching Rs. 75 a few
months back.
Moving Average
Moving Average (MA) is a widely used metric in time series analysis that
smooths out price variations by filtering out the noise from random short-term
price fluctuations.
The two most frequently used moving averages are the Simple Moving
Average (SMA) and the Exponential Moving Average (EMA). SMA is simply the
average of a series over a fixed number of time periods, and the EMA gives
higher weight to more recent values. The most popular applications of moving
averages are to identify the trend and its direction and to ascertain support and
resistance levels. Moving averages also form the precursor for other technical
metrics such as the Moving Average Convergence Divergence (MACD).
Seasonal ARIMA
An ARIMA model, sometimes called Box-Jenkins after the original authors, is a
statistical analysis model that uses time-series data to better understand the
data set or to predict the future points in the series. ARIMA models are applied
in cases when the data is non-stationary, and an initial differencing step can be
used one or more than one times to eliminate the non-stationarity. It is a
method of regression analysis that measures the strength of one dependent
variable relative to the other variables. The model's goal is to predict future
trends in the series by examining the differences between values in the series
instead of the actual values.
In the ARIMA(p,d,q) model, the three parameters p, d and q account for the
seasonality, trend, and noise in the data respectively.
● p: The number of time lags of the autoregressive model, also called the
lag order.
● d: The degree of differencing or the number of times that the raw
observations are differenced.
● q: The lag of the error component, also called the order of moving
average. The error component is a part of the time series not explained
by trend or seasonality.
The main application of the ARIMA model is in the area of short term
forecasting. It requires at least forty historical data points. It works best when
the data displays a steady or consistent pattern over time with little or no
outliers. ARIMA is usually superior to exponential smoothing techniques when
the data is reasonably long, and the correlation between the past observations
is stable. If the data is short or highly volatile, then some smoothing method
may perform better.
ARIMA models, however, cannot capture the seasonal nature of the data, called
seasonality. Here comes the seasonal ARIMA model that also takes into
account the seasonality of the data. Seasonal ARIMA models are usually
denoted as ARIMA(p, d, q)*(P, D, Q, S), where S refers to the number of periods
until the pattern repeats. The lowercase p, d and q refer to the non-seasonal
part and is the same as described for the ARIMA model. The capital P, D, Q
refer to the autoregressive, differencing, and moving average terms for the
seasonal part of the ARIMA model. In a seasonal ARIMA model, the seasonal
AR and MA terms predict the variable using actual values and errors at times
with lags which are multiples of S, the span of the seasonality. A seasonal
ARIMA model combines both the non-seasonal and the seasonal factors in a
model.
Artificial Neural networks (ANNs) are a type of nonlinear models that can
approximate any nonlinear function to an arbitrary degree of accuracy.
Recurrent Neural Networks (RNN) are a variety of Neural Networks where the
output from the previous stage is again fed as input to the current stage, unlike
the vanilla ANNs. In conventional neural networks, all the inputs and outputs
are independent of each other. But many a time, it is required to take into
consideration the past outputs to predict future values. For example, in
predictive keyboards which predict the next word of a sentence, the previous
words of the sentence are required so that the context is known, and hence, it
is necessary to remember the preceding words. RNNs remember the previous
calculations and use them to make better predictions.
In a vanilla neural network (basic feedforward ANN), an input vector of a given
size is transformed into an output vector. In order to convert this network into a
“recurrent” neural network, the transformations are repeatedly applied to a
series of given input producing a series of output vectors. In addition to
producing the output, which is a function of the input and the hidden state, the
hidden sate itself is updated based upon the input, and then used in
processing the next input.
As you are reading this line, you don’t start thinking about each and every word
from scratch but rather understand it on the basis of your understanding of the
previous words in the sentence. The past words persist in your memory and
they influence your understanding of the upcoming words. RNNs work pretty
much in a similar fashion.
Long Short-Term Memory (LSTM) networks are a special kind of RNNs, which
have undergone quite a few refinements over the years resulting in their
widespread use and improved accuracy, especially in time-series modelling,
outperforming the competitors like Econometric models by huge margins.
RNNs perform remarkably well in predicting words in a sentence like “The
colour of the sky is ____” and may predict “blue” with high accuracy. But in
sentences such as “I live in Spain… I am fluent in ____” RNNs may struggle to
predict “Spanish” correctly. The reason being that RNNs, at least in practice,
seem to better connect with recent information than past encounters. LSTMs
overcome this shortcoming and are proficient in learning long-term
dependencies.
A popular version of the LSTM network can be represented by the following
equations:
Results
The following results were obtained by the various methods:
Moving Average
RMSE: 14.7009
Seasonal ARIMA
RMSE: 7.1669
prophet by Facebook
RMSE: 3.0000
RMSE: 0.7873
It can be deduced from the above results that LSTM networks put all the other
models to shame as it predicts the future weekly USD/INR exchange rates with
high accuracy.
Conclusions
The seemingly difficult job of forecasting exchange rates has been achieved to
a remarkable threshold with LSTMs. Though, this does not imply that the model
can be now directly used by traders and speculators to predict the future
prices. Weekly exchange rates are affected by a variety of other factors such as
the recent political and economic news and their past values only reveal a
small part of the story.
Hence, the model can be improved by incorporating information gained
through news analysis that affects the currency pair exchange rates. This
approach has not been dealt with frequently as news is difficult to extract,
process and model. Moreover, a longer time frame would perhaps provide
more accurate predictions.
All models here focus only on the USD/INR exchange rate pair. It is not yet
known how this model performs on other currency pairs, especially those that
are highly volatile. Hence, it is recommended to test this model for other
currency pairs for further studies.
References
1. Obstfeld, M., Rogoff, K. (1994) Exchange Rate Dynamics Redux. Published:
Journal of Political Economy 102 (June 1995), pp 624-660.
2. Dua, P., Ranjan, R. (2011) Modelling and forecasting the Indian RE/US dollar
exchange rate. http://econpapers.repec.org/paper/cdecdewps/197.htm
3. Ghalayini, L. (2014) Modeling and forecasting the US dollar/euro exchange
rate. International Journal of Economics and Finance, 6(1):194-207.
4. Balter, A., Dumitrescu, E.I., Hensen, P.R. (2015) Exchange rate volatility
forecasting: a multivariate Realized-GARCH approach. https://
forecasters.org/wp-content/uploads/E.Dumitrescu_SAS-grant-report.pdf
5. Bayas, A. C. (2018). Currency Risk Management: Predicting the EUR/USD
Exchange Rate. Retrieved from
https://digitalcommons.wpi.edu/mqp-all/3661
6. Kamruzzaman, J., Sarker, R.A. (2004) Forecasting of currency exchange
rates using ANN: A case study. DOI: 10.1109/ICNNSP.2003.1279395
Source: IEEE Xplore
7. Rojas, C.G., Herman, M., (2018) Foreign Exchange Forecasting via Machine
Learning http://cs229.stanford.edu/proj2018/report/76.pdf
8. Nagpure, A.R. (2019) Prediction of Multi-Currency Exchange Rates Using
Deep Learning. International Journal of Innovative Technology and
Exploring Engineering (IJITEE) ISSN: 2278-3075, Volume-8 Issue-6, April
2019