Forecasting Foreign Currency Exchange Rate using Convolutional Neural Network

Foreign exchange rate forecasting has always been in demand because it is critical for foreign traders to know how their money will perform against other currencies. Traders and investors are always looking for fresh ways to outperform the market and make more money. As a result, economists, researchers and investors have done a number of studies in order to forecast trends and facts that influence the rise or fall of the exchange rate (ER). In this paper, a new Convolutional Neural Network (CNN) model with a random forest regression layer is used for future closing price prediction. The intended model has been tested using three major currency pairs: Australian Dollar against the Japanese Yen (AUD/JPY), the New Zealand Dollar against the US Dollar (NZD/USD) and the British Pound Sterling against the Japanese Yen (GBP/JPY). As a proof-of-concept, the forecast is made for 1 month, 2 months, 3 months, 4 months, 5 months, 6 months and 7 months utilizing data from January 2, 2001 to May 31, 2020 for AUD/JPY and GBP/JPY and data from January 1, 2003 to May 31, 2020 for NZD/USD. Furthermore, when compared the performance of the suggested model with the Autoregressive Integrated Moving Average (ARIMA), MultiLayer Perceptron (MLP) and Linear Regression (LR) models and found that the proposed CNN with Random Forest model surpasses all models. The suggested model's prediction performance is assessed using R, MAE, RMSE performance measures. The proposed model's average R values for three currency pairs from one to seven months are 0.9616, 0.9640 and 0.9620, demonstrating that it is the best model among them. The study's findings have ramifications for both policymakers and investors in the foreign exchange market. Keywords—Convolutional neural network; exchange rate; R square; random forest regression method


I. INTRODUCTION
In our lives, money is quite important. Currency markets have evolved into an important part of our lives in the growth of the financial system. The exchange rate (ER) and foreign exchange rate (Forex) are two well-known terminologies in the money market. ER is the worth of a country's currency that may be exchanged for another country's currency [1]. Forex is a global market where national currencies are exchanged for one another. Forex is the world's largest daily market for swapping one currency for another [2]. The ER is influenced by a variety of factors, including individual traders' and investors' economic, political and psychological circumstances [3,4]. The stunning presentation of the CNN on the detailed earth has gotten a lot of attention. Visual Speech recognition [5], Hand Gesture recognition [6], COVID-19 Detection [7], and time series data prediction [8] are all domains where CNN technology is used. CNN was once utilized to forecast stock market activity for the next day [9].
The primary goal of this study is to verify the computationally efficient Convolutional Neural Network model for forecasting foreign currency exchange rates. The suggested model (CNN-RF) was used to forecast the closing price of three key foreign currency pairs: the AUD/JPY, NZD/USD and GBP/JPY. The proposed model is used to forecast currency prices up to seven months ahead of time. The experimental findings are analyzed using three commonly used performance metrics: Root Mean Square Error (RMSE), Mean Absolute Percentage Error (MAE) and the coefficient of determination (R 2 ). The suggested model is compared to ARIMA, MLP and LR approaches based on performance metrics. Although many researchers have been anticipating foreign exchange currency in the past, but currently researchers are striving to come up with new models to predict the character of this market. While there are numerous machine learning and deep learning approaches utilized in finance, traders are always looking for new ways to outperform the market. This model will assist traders in achieving their goals in a systematic manner.
The following are the study's primary research contributions: (1) To capture exchange rate uncertainty, a reliable, efficient and accurate forecasting model employing CNN with Random Forest regression layer is proposed and implemented. Every 1 minute opening price, closing price, high value, low value and volume of exchange rates are all taken into account. (2) Accuracy measuring methods such as MAE, RMSE, and R 2 are used to compare the results. The R 2 value is used to measure the system's performance. The proposed forecasting model is, to our knowledge, the first of its sort in the literature.
The organization of the paper is given as: The associated work for currency ER prediction is explained in Section II. We present the data used for doing the experiment & some preferred models including our suggested model used for prediction of ER in Section III. Performance evaluation criteria described in Section IV. Experimental outcomes discussed in Section V followed by conclusions in the next section. www.ijacsa.thesai.org

II. LITERATURE SURVEY
Countless studies have proposed and developed numerous ways to examine and predict ER activity in the last few years. The following is a concise discussion of the important investigations.
For time series forecasting a broad range of prediction methods have been measured. The ARIMA model was known as the Box-Jenkins model and affirmed that it is the most popular scheme used for time series forecasting [10]. The ARIMA-GARCH model is used to forecast Ghana's GDP. It demonstrates that the ARIMA-GARCH model may reduce error variance and improve forecasts [11]. In real-world monetary time series, the performance of the linear models is below expectation due to boundaries in linear models. Thus, in this document, we talk about various non-linear models like artificial neural networks. For non-linear prediction the nonlinear model artificial neural network (ANN) is used [12].
Many academics have tried using the Long Short-Term Memory (LSTM) technique to anticipate currency exchange rates in recent years. LSTM networks operate well with time series data for classification, analysis and prediction. For shortterm prediction, Elman type approaches such as ARIMA, LSTM and Recurrent Neural Network (RNN) are used. 5 days, 11 days, 22 days, 35 days, 44 days and 55 days windows were forecasted using the three approaches above. The 22-day window has an average accuracy of 71.76 percent. In the short term, the validation dataset was best approximated using the 22-day predicting window [13]. As forex market is very volatile & complex. Thus, all the investors find new methods with more accuracy. The suggested model mentioned in this paper gives 93% average accuracy for 1 month ahead prediction which is also considered as a short-term prediction. For projecting the price 10 and 30 minutes in advance, the Gated Recurrent Unit (GRU)-LSTM approach is used. The key currency pairs EUR/USD, GBP/USD, USD/CAD and USD/CHF were evaluated for this experiment. The performance of the GRU-LSTM model is compared to that of the GRU, LSTM and statistical models based on simple moving average (SMA). Based on MAE, MSE, and RMSE results the suggested model provides better results of GBP/USD and USD/CAD currency pair. The GRU-LSTM model outperforms other models in terms of R 2 [14]. Based on the evaluation criteria our proposed model CNN with Random Forest (CNN-RF) provides better results in all datasets. Three alternative models such as support vector regression, back propagation neural network and long short-term memory, were used using Google trends and macroeconomic data to predict the value of Ghanaian Cedis in USD, British Pounds and Euros for the next 30 days. The results reveal that, unlike the other two models, the LSTM can easily manage exchange rate data variance [15]. However, in any circumstance, it's possible that Google Trends won't be able to predict changes in the Ghanaian cedi's exchange rate versus all other currencies.
Another hybrid model, ANN-GJR (Glosten, Jagannathan and Runkle) was employed to forecast currency exchange rates using five currency pairs. When compared to the benchmark model, the ANN hybrid model performs better. 14 days, 21 days and 28 days are the predicting horizons. The hybrid model's forecasting precision is over 90% for a 21-day horizon. The hybrid model's prediction accuracy improves as the prediction horizon lengthens and the benchmark model performs better for shorter horizons [16]. Therefore, this model only applied for long term forecasting. The average accuracy of the proposed model (CNN-RF) is 93% for one month prediction and 95% accuracy for seven months ahead prediction. Thus, the proposed model performance is better in both a short and long time period. Alternative hybrid model ANN-GA (genetic algorithm) used for INR (Indian Rupees) Vs USD currency exchange rate prediction. But ANN has some limitations: requires a large diversity of training for operation and also have overfitting problem [17]. Support vector regression (SVR) method is used for forecasting short-term financial time series. The forecasts were produced one to four days in advance, with a focus on the short term. The proposed PCA-ICA-SVR model facilitates to forecast stock values with small amount error [18]. This method was also used by other researchers for currency exchange rate prediction [19]. SVR, NN, LSTM known as Support vector regression, neural network, long short-term memory with hidden layers used in deep learning models for multi-currency ER prediction. They forecast the ER between the top currencies of the world. The average precision of the forecasting model exceeds 99% [20]. Based on the outcome of the forecasting model the average accuracy is very good but it will predict data by day. There is no provision for long-term prediction. A new method deep belief network (DBN) used for forecasting the currency exchange rate data. For doing the experiment INR/USD and CNY/USD currency pair used. On the overall prediction performance, with the increase of the forecast period, the prediction accuracy declines. Thus, this model is not suitable for long term prediction [21].

III. DATA AND MODELS APPLY FOR FORECASTING FOREIGN CURRENCY EXCHANGE RATES
The data collection sources are mentioned in this section. Different algorithms for Forex are discussed in this section.

A. Data
The experiment was conducted using three major currency pairs: AUD/JPY, NZD/USD and GBP/JPY. January 2, 2001 to May 31, 2020 for AUD/JPY and GBP/JPY and data from January 1, 2003 to May 31, 2020 for NZD/USD data was collected for doing experiments. Everyday opening price, closing price, low price, high price and volume data were gathered. (http://www.forextester.com/data/datasources) site used for collecting past 1-minute trade rates information. To abolish unnecessary information, 1-minute data was resampled to 1hour, 1day data.

B. Auto Regressive Integrated Moving Average (ARIMA)
It is the most popular approach used for forecasting. The future value of a variable is a linear combination of past error and past value. ... Where t x represents actual value, t  represent random error at t time, i  and j  represents the coefficients, u and v integers frequently referred to as autoregressive and moving average polynomials [22]. ARIMA model consists of three phases: identification of model, estimation of parameters & diagnostic checking.

C. Multilayer Perceptron (MLP)
MLP is also used for ER prediction [23]. An MLP network has three types of layers: a hidden layer exists within the input and output layer. The hidden layer neuron adds the received input signal after multiplying all input signals to their associated weight values. Based on the received output of the neuron is estimated.

D. Random Forest (RF)
Random forest ensemble learning procedure applied for regression and classification problems. For foreign currency ERs prediction, we use the random forest method. It simply works on tabular data. The missing value will not be measured while we prepare the data in python and sklearn packages. The dataset, depth of tree and no of the tree are the inputs of the random forest (RF) method [24].

E. Linear Regression (LR)
Here for forecasting foreign currency ER we use the LR on technique. It is of two type's linear regression and multiple regression. The mathematical formula of linear regression is w by c  (2) W stands for dependent variable, y stands for the independent variable, b known as slope, c considers as interceptor.
w stands for the dependent variable. The independent variables are represented as y1, y2 and y3.b is the slope, c known as the interceptor [25].

F. CNN
In CNN several hidden layers exist within input and output layer. The hidden part of CNN is the combination of a convolution layer (CL), pooling layer and a fully connected (FC) classifier. The features are obtained from the previous layer processed by the fully connected classifier [26]. For extracting local features from input a set of filters present in the CL. A very small part of the input is called the receptive field which represents feature map. The neuron present in the CL is very much associated with the tiny piece of the preceding layer. These neurons prepare the feature map and the similar weight pooled to every feature map. The pooling layer applied to shrink the extent of each feature map. Two types of pooling are used mean-pooling and max-pooling. Max-pooling is used for selecting the highest value and meanpooling use for selecting the least amount of feature map.
The proposed model's architecture is depicted in Fig. 2. Our model has four Convolutional layers, three pooling layers and one fully connected layer & a readout layer. First, the inputs are pre-processed to a standard normalization (0,1). Then the feature and labels are selected. After that represent the feature matrix with label. PCA algorithm is used for data transformation or dimension reduction. Every minute of 24 hours data is taken as input. The max pooling layer is followed by the convolution layer. Finally, as a readout layer, a random forest regression layer is employed. To reduce the RMSE loss, we used Adam optimization to train the network. A batch size of 256 was chosen. The probability of dropping out rate is 20%. We trained for 10 epochs with a learning rate of 0.003 at first. We divide the complete data into two parts: 80 percent for training and 20 percent for testing.

IV. PERFORMANCE EVALUATION CRITERIA
The model performance is measured by four indices R 2 , RMSE, MAE. The MAE is computed as Where u i is the real value of the i th sample, v i represents the expected value of i th sample and n represents total number of samples. MAE calculates the distinction between real value and predicted value by average the absolute difference over the test sample The intended model has been doing the experiment using three major currency pairs AUD/JPY, NZD/USD, GBP/JPY. Moreover, ARIMA, MLP, LR algorithms are considered for comparison with our proposed (CNN-RF) scheme. From the entire data, 80% and 20% of data is used for training and testing the suggested model. The proposed model is used to forecast up to 7 months in advance. The model's performance is calculated through R 2 , MAE, and RMSE. The model has been designed & tested using PYTHON3.7 software.

A. AUD/JPY
From Table I, it can be observed that our suggested model is superior to other models. It is indicated in Table I The R 2 result of the AUD/JPY from 1 to 7 months forecast in advance is presented in Fig. 3 using several methodologies such as CNN-RF, ARIMA, MLP, and LR.   Using multiple techniques such as CNN-RF, ARIMA, MLP, and LR, the MAE result of the AUD/JPY from 1 to 7 months forecast in advance is provided in Fig. 4.  Using multiple techniques such as CNN-RF, ARIMA, MLP, and LR, the RMSE result of the AUD/JPY from one to seven months ahead forecast is shown in Fig. 5.

B. NZD / USD
In Table IV, the performance of the suggested model is evaluated. For the first month, the R 2 performance in NZD/USD ER, our proposed model result is 44.01% bigger than ARIMA, 50.40%bigger than MLP,24.36%bigger than LR. For the second month, the result of R 2 of the suggested model is 44.97% bigger than ARIMA,51.41% bigger than MLP,25.45% bigger than LR. For the third month, the result of R 2 of the suggested model is 46.13% bigger than ARIMA, 58.84% bigger than MLP, 26.89% bigger than LR. For the fourth month, the result of R 2 of the suggested model is 48.35% bigger than ARIMA, 67.56% bigger than MLP, 27.81% bigger than LR. For the fifth month, the result of R 2 of the suggested model is 48.43% bigger than ARIMA,77.31% bigger than MLP,29.33% bigger than LR. For the sixth month, the result of R 2 of the suggested model is 50.19% bigger than ARIMA, 80.25% bigger than MLP, 30.76% bigger than LR. For the seventh month, the result of R 2 of the suggested model is 48.85% bigger than ARIMA, 84.20% bigger than MLP, 32.66% bigger than LR.
The R 2 result of the NZD/USD from 1 to 7 months forecast in advance is shown in Fig. 6 using several methodologies such as CNN-RF, ARIMA, MLP, and LR.   Table V show that our suggested model works better than MLP, ARIMA and LR models. For MAE, the proposed technique shows remarkable performance than other existing methods. When MAE performance measured in NZD/USD ER forecasting for the first month, our proposed model result is 39.13% smaller than ARIMA, 56.38% smaller than MLP, 41.46% smaller than LR. For the second month, the result of MAE of the suggested model is 33.64% smaller than ARIMA, 48.82% smaller than MLP, 32.98% smaller than LR. For the third month, the result of MAE of the proposed model is 27.55% smaller than ARIMA, 39.55% smaller than MLP, 22.80% smaller than LR. For the fourth month, the result of MAE of the suggested model is 26.91% smaller than ARIMA, 41.40% smaller than MLP, 22.80% smaller than LR. For the fifth month, the result of MAE of the proposed model is 42.32% smaller than ARIMA, 59.25% smaller than MLP, 41.41% smaller than LR. For the sixth month, the result of MAE of the suggested model is 58.07% smaller than ARIMA, 71.91% smaller than MLP, 58.98% smaller than LR. For seven months, the result of MAE of the proposed model is 65.20% smaller than ARIMA, 76.83% smaller than MLP, 66.30% smaller than LR.
Using multiple techniques such as CNN-RF, ARIMA, MLP, and LR, the MAE result of the NZD/USD from 1 to 7 months ahead is displayed in Fig. 7. www.ijacsa.thesai.org  In Table VI, it is observed that the suggested model shows better than LR, ARIMA and MLP models. For the RMSE parameter (the least value is the better), the performance of the suggested scheme is better than other models . In first month, the RMSE parameters in NZD/USD ER by our proposed model result is 29.82% smaller than ARIMA,44.17% smaller than MLP,27.55% smaller than LR. For the second month the result of RMSE of the suggested model is 31.33% smaller than ARIMA, 46.07% smaller than MLP, 28.82% smaller than LR. For the third month the result of RMSE of the proposed model is 38.13% smaller than ARIMA, 53.65% smaller than MLP, 36.80% smaller than LR. For the fourth month the result of RMSE of the suggested model is 47.85% smaller than ARIMA, 63.00% smaller than MLP, 48.06% smaller than LR. For the fifth month the result of RMSE of the proposed model is 55.91% smaller than ARIMA, 69.67% smaller than MLP, 56.85% smaller than LR. For the sixth month the result of RMSE of the suggested model is 58.69% smaller than ARIMA, 71.76% smaller than MLP, 59.80% smaller than LR. For seven month the result of RMSE of the proposed model is 60.35% smaller than ARIMA, 72.93% smaller than MLP, 61.51% smaller than LR.
The RMSE outcome of the NZD/USD from 1 to 7 months ahead is provided in Fig. 8 using several methodologies such as CNN-RF, ARIMA, MLP, and LR.

C. GBP / JPY
Table VII represents, the R 2 performance of proposed method with the state-of-the-art techniques is shown. In GBP/JPY ER forecasting, for the first month prediction our suggested technique result is 21.75% bigger than ARIMA, 67.66%bigger than MLP,35.48%bigger than LR. For the second month the result of R 2 of the proposed model is 21.17% bigger than ARIMA, 59.22% bigger than MLP, 35.12% bigger than LR. For the third month the result of R 2 of the suggested model is 20.39% bigger than ARIMA, 65.11% bigger than MLP, 34.40% bigger than LR. For the fourth month the result of R 2 of the proposed model is 19.19% bigger than ARIMA, 75.38% bigger than MLP,35.16% bigger than LR. For the fifth month the result of R 2 of the suggested model is 27.86% bigger than ARIMA,50.05% bigger than MLP,39.95% bigger than LR. For the sixth month the result of R 2 of the proposed model is 31.73% bigger than ARIMA, 50.95% bigger than MLP,42.56% bigger than LR. For the seventh month the result of R 2 of the suggested model is 50.12% bigger than ARIMA, 51.58% bigger than MLP, 50.28% bigger than LR.
The R 2 outcome of the GBP / JPY from 1 to 7 months ahead is given in Fig. 9 using several methodologies such as CNN-RF, ARIMA, MLP, and LR. Using multiple techniques such as CNN-RF, ARIMA, MLP, and LR, the MAE outcome of the GBP/JPY from 1 to 7 months ahead is shown in Fig. 10. The RMSE outcome of the GBP/JPY from 1 to 7 months ahead is given in Fig. 11 using multiple methodologies such as CNN-RF, ARIMA, MLP, and LR.

D. Performance Comparison
The proposed CNN with random forest model was compared against MLP, ARIMA, and LR layer to discover how good a model is. The forecast for 1 month, 2 months, 3 months, 4 months, 5 months, 6 months and 7 months is created as a proof-of-concept using data from January 2, 2001 to May 31, 2020 for AUD/JPY and GBP/JPY and data from January 1, 2003 to May 31, 2020 for NZD/USD. We have used past every minute opening price, closing price, low price, high price and volume for forecasting the closing price in advance. Tables I to III shows the comparison for 1 to 7 months' ahead prediction in terms of R 2 , MAE, RMSE values for AUD/JPY currency pair using different algorithms. The R 2 metric, sometimes called the coefficient of determination, implies that the model is more fit. R 2 can have a value between 0 and 1, with 0 indicating that the model does not fit the given data and 1 indicating that the model fits the dataset completely. The average R 2 value of the proposed model for AUD/JPY is 0.9616. Tables IV to VI compares the R 2 , MAE, RMSE values for the NZD/USD currency across a 1 to 7-month time frame. When we examine the results, we can find that the proposed model yields lower MSE, RMSE and MAE over the 1 to 7month timeframe, implying that the NZD/USD currency pair is more accurate. For the NZD/USD currency pair, the proposed model's average R 2 value is 0.9640. Tables VII to IX compare R 2 , MAE, RMSE values for the GBP/JPY currency across a 1 to 7-month time frame. The average R 2 value for GBP/JPY of the proposed model is 0.9620. Hence as all the average value comes near to 1, hence our model is best suitable for all the datasets.

VI. CONCLUSION WITH FUTURE ENHANCEMENT
Time series forecasting accuracy is crucial to many decision-makers. In this research, the capabilities of CNN model with random forest technique for currency exchange rate forecasting have been investigated and compared with other forecasting methods. After performing an experiments of the exchange rates between the datasets such as AUD/JPY, NZD/USD and GBP/JPY for 1 month, 2 months, 3months,4 months, 5 months, 6 months and 7 months in advance. The model is compared with ARIMA, MLP, LR which clearly establish that the model not only predict the close price but also able to guide the investor to invest in Forex market. Four evaluation criteria such as R 2 , MAE and RMSE consider for estimating the performance of the models. Based on the forecasting result our suggested model performs superior than all other models. Furthermore, there are other future research directions for this study. This model will be applied to all remaining significant currency pairs in the future, and the correctness of our suggested model will be estimated. In addition developing a framework for predicting performance based on dynamic data sets which will enhance the exchange rate prediction more efficiently.