Forecasting USD-MNT Exchange Rate — Part 2: Machine Learning
By: Robert Ritz
Tags: Machine Learning, Data Science, Currency, Exchange Rate, Mongolia

Forecasting USD-MNT Exchange Rate — Part 2: Machine Learning

When a good model doesn’t work

The past few weeks have seen an amazing depreciation of the Tugrik. As Mongolia relies so heavily on imported products, this weighs heavily on everything from prices of potato chips to fuel to vehicle imports. Also, the International Monetary Fund released a report earlier this month reviewing the Mongolian macroeconomic situation. I’ll leave the macroeconomic commentary to others, but I hope this shows the importance and scope of this problem.

In part 1 of this series I showed one tool for forecasting time series data, Facebook’s Prophet tool, and applied it to the USD-MNT exchange rate and meat prices. The result was a model that didn’t give high confidence for forecasting exchange rates, but a seemingly well fit model for meat prices (which are highly seasonal).

In this article, I’ll show how to apply machine learning algorithms to forecast exchange rates 3, 6, and 12 months in the future. This article will be more technical than most, so feel free to skip to the bottom with the results if data munging and code isn’t for you. All of the code and data for this project are on Github here.

The Problem

Let’s start with a statement of the problem. It is always a good idea to start with a well-defined problem to work from. If you have all of the data and skill you could want, but not a defined problem, you won’t have a good result.

The Problem: Given available macroeconomic data, can we accurately forecast USD-MNT exchange rates 3, 6, and/or 12 months in the future?

The Data

Approaching this problem, this was my least certain piece. I’m no expert in macroeconomics, so I had to do some research (and ask Kevin, our economics instructor at LETU Mongolia, for some advice). From my research and discussion, I found that money supply and balance of payments were the places to start. I dug around 1212.mn to find that data and more and came up with the following data features.

USD — USD-MNT exchange rate

CPI — consumer price index. This is the change in CPI from the previous month in percent.

m2 money supply

m1 money supply

current: the current account from the balance of payments

capital: the capital account from the balance of payments

financial: the financial account from the balance of payments

errors: errors and omissions from the balance of payments

balance: the balance of exports and imports in Mongolia

Other features, such as interest rates, quasi-money, and government account balance were excluded as they hurt the accuracy of the model.

Setting It Up

I collected all of the data above and combined them into one dataframe. The code and details are located here. One challenge was the periodicity of the various features. Our exchange data is daily, some data is monthly, and others quarterly. For our daily exchange rates, I took the last value of each month. For the quarterly data, I copied the quarterly value to each month in that quarter. This gives us a dataframe of monthly data that is easier to work with.

First, we will import the libraries we will be using and also load our data into a Pandas dataframe.