Abstract

Price forecasting and trading in the international crude oil market are important issues for investors in energy finance. In this study, we propose an alternative forecasting approach for financial derivative price multiple days ahead and simulated trading based on long short-term memory (LSTM). This study aims to evaluate for different multiple days ahead forecasting and trading by deep LSTM-based model using technical analytic features, which have nonlinear behaviors. The effectiveness of LSTM networks trained by backpropagation through time for test objective prediction is explored. Moreover, instead of using only one crude oil market's spot price data as a data source, we build up a crude oil database with the two most important crude oil markets. The results indicate that the proposed approach outperforms others in terms of accuracy, return, and risk aspect. The forecasting and holding (for trade) time horizons are 1–3 days ahead, respectively. For all three multiple days ahead forecasting and trading, the average test accuracy (judged by root mean square error) of two crude oil markets for four datasets of deep LSTM-based model yields best results among all methods. This study also developed trading strategies, and the proposed LSTM-based method also outperforms other benchmark methods on both return and return-risk ratio (judged by Sharpe ratio). The experimental results indicate that the proposed method can help traders make profits in the financial derivative market and is more effective than the state-of-the-art methods in actual trading.

1. Introduction

In 1970, the oil crisis brought a huge impact on the world oil market, and the oil price volatility directly promoted the birth of oil futures. Oil future trading volume is been growing fast and is already beyond metal futures, which become an important part of the international future market. Moreover, the oil future is also a kind of important financial derivative.

Crude oil, as the most actively traded and commonly used commodity in the international financial market, plays a significant role, which accounts for over 10%, and attaches great importance in the international financial market. It is dual and complicated why there is so large volume of trade in the crude oil market. Because it attaches to pivotal significance in the world economy, there is a worldwide serious demand for crude oil in order to satisfy rising energy demands, especially in developed and developing countries. With the huge progress in economic globalization and the continuous development of financial markets, crude oil becomes not only a commodity but also one of an important trading asset. From the movement trend of Brent and WTI, it is obvious that crude oil prices in Brent Crude and WTI have an observable correlation. However, the change in the price of Brent and WTI is not always simultaneous and the same due to the different quality characteristics and diverse places where they are stockpiled. Nevertheless, the similar trend of the spot price of the two crude oil markets indicates the change in price in one market could be useful information for price forecasting in the other market. A nation's economy may be tremendously influenced by the fluctuation in crude oil prices for better or worse. Forecasting price in crude oil fields assists in minimizing many risks, which arise from the ambiguity and uncertainty of surrounding crude oil prices in the future. In order to achieve this, it is crucial to work for the prediction exercise modeling and to forecast crude oil prices. Although many people like market traders, business practitioners, and financial researchers tried to invent and develop various forecasting methods to predict future crude oil prices, it is still quite difficult to design a model that meets these strict criteria and captures the diverse dimensions.

In the last few decades, market traders and researchers usually used technical indicators as technical analysis methods, in order to find out some valuable information in financial time series, by which they can forecast several investment decision-making (like buy or sell) [13]. Several noted technical indicators are proved to be useful for analyzing trends (such as moving average (MA) indicator) or buying or selling points in time series movements. In the existing research, many researchers use this technical analysis method to try to identify and figure out the trend of financial derivative prices in a certain time series. For instance, technical analysis is applied for oil forecasting based on the MA indicator [4]. These wonderful studies have inspired the latter and clearly demonstrated that the technical indicators can be indispensable tools for helping researchers to figure out and then recognize useful patterns in financial series data like stock price and FX time series data.

In addition, many researchers have referred to results and conclusions based on old methods invented by their predecessors. For example, autoregressive integrated moving average (ARIMA) and cointegration analysis are used for reference to predict the economic activity and financial prices. For instance, Huntington predicted crude oil prices by using a sophisticated econometric model [5]. Some researchers predicted wind speed with the help of an ARIMA model [6, 7]. Ravindran et al. predicted the foreign exchange rate by using the higher-order ARIMA model [8]. However, it is abundantly clear that crude oil markets are highly nonlinear and irregular and sophisticated to anticipate. Those models are not expected to perform well, and at the same time, they are not suitable to forecast fluctuations in the future. Considering the importance of the crude oil price to the economic development of a country and the high risk in the crude oil trading market for many investors, how to develop a practical and good-performed model with high forecasting accuracy and high return-risk ratio is no doubt a crucial requirement for investors.

As these models mentioned before are not performed well as those based on linearity assumptions, they are certainly not appropriate for us to forecast nonlinear patterns, which is completely performing in a different situation. So, this problem has drawn significant attention in the energy finance literature in recent years. Hence, our study is focused on how to develop nonlinear models in order to satisfy the changing scenario while we try to predict prices. For the past few years, several ML-based methods such as SVM are generally used by many scholars in time series [911]; however, there are some limitations and disadvantages that are still needed to be solved in those models. In addition, the artificial neural network model training algorithms sometimes produce overfitting models, often falling into local minima [1214]. In recent years, RNN and LSTM have been expected to solve the gradient exploding problem and are applied in the field of time series prediction [1517], image captioning [18], health monitoring [19], speech recognition [20], and natural language processing [21]. As one of the neural networks, deep LSTMs require no further domain knowledge but still can perfectly integrate representation learning and model training together [2227]. Moreover, this architecture helps researchers to find out some hidden structure in the dataset and enhance the generality of the model.

In the last few decades, several scholars have been used RNN- or LSTM-based method to predict prices in the stock market. For example, Sun and Ni used RNN for stock price forecasting [28], Chen et al. predicted the China stock market by a LSTM-based method [29], and David et al. [30] and Buczkowski [31] predicted the price of the stock by deep LSTM. RNN- and LSTM-based methods have been proved to offer more feasible ways in the prediction of nonlinear stock price movements [29, 30]. In this study, to address the limitations of the state-of-the-art machine learning methods such as ANN or SVM, we present the first empirical study about crude oil forecasting and trading systems based on LSTMs backed by RNN architecture. We use an open dataset in this study: WTI Crude Oil and Brent Crude Oil data are sampled from the website of energy information administration and the Department of Energy. The research target is scoped to the accurate prediction and trading on crude oil market based on crude oil spot time series data using LSTM RNN. 

This study mainly has three contributions: (1) we consider the long dependency from the time series data for crude oil price forecasting by using a deep LSTM-based model. (2) For prediction of the target prices, we use not only the data from the target time series but another important crude oil market. (4) Multiple data sources are used, and multiple days ahead prediction and trading are explored.

The remaining sections of this study are arranged as follows: Section 2 describes the background for this study. The structure and introduction of the proposed method are described in Section 3. Section 4 demonstrates the study design with charts and formulas. Experimental results and discussions are provided in Section 5. Finally, Section 6 concludes this study.

2. Background

2.1. Technical Indicator

In order to analyze financial time series, there are many technical indicators to be discussed and they can be classified as trend indicator and oscillator indicator. Moving average (MA) indicator is the most stock market well-known trend indicator, and most of the other indicators are based on it. There are three technical indicators, namely, SMA, EMA, and MACD, which are used in the experiments.

The MA method is a useful technique to smooth out short-term fluctuations, and it is calculated by counting the mean value of the price of financial products such as futures and spot prices in the past. SMA is one of the MA methods, and it is calculated as follows:

Unlike SMA, EMA pays more attention to the nearer movements, which assumes more influences on the nearer changes than that from older changes. The calculation of EMA is defined as follows:where is the EMA of the price at time t, and a = 2/(n+1), which is commonly used for the n-period EMA.

Among these indicators, MA is used by market traders to highlight the direction of a particular trend and to smooth out random price fluctuations. Compared with MA, SMA is a simple mean value through identical weights to those used for past prices and the EMA is the average value of the prices of a financial time series for a given length, which adds greater weight on newer changes and lower weights on older ones.

In addition, MACD is also one of the classic indicators to forecast the price tendency change in the financial market. The default parameters (12, 26, and 9) of the MACD indicator can be altered based on the traders' demand. Therefore, in the experiments, MACD with default parameters (12, 26, and 9) will be applied because this value set is broadly acknowledged and applied by market traders and researchers around the world.

2.2. Basic Single LSTMs

The key of LSTM is to more accurately capture remote dependencies by using several gates at each time step to control the information passing along the sequence. A most useful LSTM framework proposed will be applied for this study [32]. The LSTM hidden layer consists of cells with sigmoid input, output, and forgetting gates. This allows the network to learn when to forget, accept input, and output. The Input gate, output gate, and forget gate of a single LSTM structure are shown in Figure 1.

Figure 2 shows the introduction for basic LSTM method in the field of regression for sequential data. The LSTM layer is represented by the gray block, and the linear regression layer is denoted by the write block.

2.3. Deep LSTMs

At present, in presentation learning, the application of deep architectures has already succeeded. So, it is great to practically integrate multiple LSTM layers to ensemble and construct a deep LSTM. The input of the method must pass through multiple nonlinear layers in deep LSTM.

Figure 3 shows the introduction for the 3-layer deep LSTM method in the field of regression for sequential data. The LSTM layer is represented by the gray block, and the updated formula of layer one is calculated as follows:

For the first layer, the input data are the raw signal. The output of the last-layer LSTM at the terminal time step is used as the representation of the input signal for regression. Deep LSTM has the following two advantages: (1) it has some advantages in sequence modeling and long-term memory and is easy to implement. (2) It solves the problems of gradient disappearance and gradient explosion in long sequence training.

2.4. Evaluation Methods

In order to evaluate the performance of our proposed model and compare the results of the benchmark models, the following three factors are used: (1) root mean square error (RMSE), which is used to evaluate the predictive accuracy of the model, (2) the average profit percentage (APP), which is used to calculate the profitability of the trading model, and (3) the Sharpe ratio [33], that is, an indicator used to comprehensively measure a specific trading strategy in the portfolio returns and risks, and in this study, we not only need to consider the model for financial derivative price time series prediction accuracy and the training of fitting degree but also need to forecast the test set, through my trading strategy for benefits in terms of evaluation and risk assessment, so as to conduct a comprehensive evaluation of our proposed model and trading strategy, to test whether it can achieve good results in the real financial market.

3. Proposed Method

Figure 4 shows the proposed model for price prediction and simulated trading system, and it is made up of five different parts.

Our proposed model is including the following five component parts:(i)Part A. Data preprocessing (DPP) component(ii)Part B. Feature extraction (FE) component(iii)Part C. Deep LSTM (DL) component(iv)Part D. Forecasting and trading (F&T) component(v)Part E. Performance evaluation (PE) component

First, the DPP component preprocesses the original data to be the experimental data (see Section 4.1 for details). Then, the part of feature extraction changes the initial price data into MACD-based features, including four MACD value features and four MACD signal features.

Subsequently, the part of DL is applied to forecast the time series prices both in WTI and Brent. Unlike the other researchers, this study proposed a model that applied three different time frameworks with 1 and 3 days ahead prediction.

As for the deep LSTM model and other benchmark models, the input data come from two major crude oil trading markets in the global oil market. Therefore, the models trained based on different markets are expected to have more accuracy. At the same time, the trading strategies proposed based on our training models will also have very good adaptability.

Finally, the part of performance evaluation is applied to evaluate our proposed model throughout the three different indicators; the details are in Section 5.

4. Data Processing

4.1. Research Dataset

At present, the world oil market and oil prices are diverse. Among them, the two main crude oil price datasets are WTI and Brent Crude oil spot price, and these two sources are carefully chosen by our researchers as our research initial datasets. These two oil markets are important and representative in terms of market trading size, market reputation, and recognition in the financial system. To sum up, crude oil data using these two markets are relatively comprehensive.

The record data for oil prices in WTI began in 1986, the record data for oil prices in Brent began in 1987, the price of crude oil rapidly changes, and there will be different trends and patterns in different historical periods. Using data from a longer period will increase the size of our training set so that the model can learn better. However, at the same time, adding more data from earlier periods will also bring the noise. As we all know, a well-trained and useful trading strategy cannot achieve a high risk-free rate of return in all time periods, it can only profit in certain types of financial derivatives or certain time periods, the too old data might not be useful for the recent prediction and trading, and for the reason of convenience, the data ranging from January 2, 2009, to December 31, 2016, are chosen for experiments, in both cases. In this study, we set the training and testing length’s ratio to be 4 : 1.

4.2. Multiple Steps ahead Prediction

In this study, to further evaluate the experiment training results about the model, which is different from other researchers' practices, we adopted different cycle rolling forecasting methods, specifically, we trained the model with data of a certain period (1,024 samples) and made regression prediction (256 samples), and then, we used the data of a period of time in advance to train and forecast again. For example, we trained the model and predicted the price in 2005 through data from 2001 to 2004. In the second stage, we will use the data from 2002 to 2005 to train the model and forecast the price in 2006, and by analogy, we will train the forecasting method four times. Figure 5 more vividly illustrates this.

In addition, we also apply different forecasting models. The usual practice is to use the data one day in advance as the model feature input for forecasting the price of the next day. However, the change in oil price is often very complicated. In our experiment, we will use different time intervals for forecasting. This multistep forecasting and trading method is expected to produce better results. Three days is taken as an example. Today, we will forecast the price after three days. We will hold trading positions for three days and close positions after three days. Figure 5 shows the method for training and test with 3 days ahead prediction.

N-A and n-B mean the period of n-th with training, and the period of n-B means with testing, respectively.

4.3. Benchmark Methods

Table 1 shows a list of some models in our experiment. We use some commonly used methods to compare the experimental results with our proposed method. In Table 1, the deep LSTM-based prediction and trading system is our proposed method. ARIMA is a famous traditional linear model for time series forecasting (method 1). Method 2 uses NN (neural network) as the learner for regression prediction and trading based on the direction prediction. Method 3 is a SVM regression-based system, which uses a single kernel method with the same input [34]. Method 4 uses the simple method based on the RNN model. Method 5 is a single LSTM-based method, which is used for comparison with our deep LSTM-based method to test the improvement of multiple layer learning. Keras is used for the proposed deep LSTM models. Buy and hold mean buy at the beginning and close at the end [35], Sell and hold mean short at the beginning and close at the end, and they are two commonly used benchmark investment strategies in the financial market.

5. Results and Analysis

5.1. Prediction Results

From the results for average RMSE shown in Table 2 and Table 3, we found the following: (1) our deep LSTM-based model obtained the best average RMSE results ((for RMSE, the lower the better) for 1 day (1.1042 for WTI and 1.0744 for Brent), 2 days (1.1129 for WTI and 1.0841 for Brent), and 3 days(1.0792 for WTI and 1.0852 for Brent) ahead price prediction); (2) deep LSTM-based model yield much better results than the conventional machine learning methods (NN and SVM) and time series prediction method (ARIMA), which indicates crude oil price prediction, and deep LSTMs are better than some conventional methods; (3) deep LSTM-based model performs better than results of simple RNN and single LSTM-based model, which indicates that proposed model outperforms simple RNN and single LSTM-based method.

There have the following findings from Table 2: (1) for price prediction in WTI, our proposed model obtained best results for 1 and 3 days ahead prediction, compared with all other benchmark methods. (2) In addition, for the proposed method deep LSTMs, it obtained the best prediction result for 3 days ahead prediction, which indicates our proposed method might be better for a relatively longer time horizon prediction. (3) RMSE results of NN are too large compared with that of SVM, RNN, and single LSTM-based method, and it indicates that NN might not be a good model for prediction.

We conclude the results as follows from Table 3: (1) similar to the results for WTI, our proposed method obtained the best results (for RMSE, the lower the better) for 1 and 3 days ahead prediction, compared with all other benchmark methods. (2) In addition, for the proposed method deep LSTMs, it obtained the best prediction result for 1 day ahead prediction, which indicates that our proposed method might be better for a relatively shorter time horizon prediction. (3) Similar to the results for WTI, RMSE results of NN are too large compared with that of SVM and RNN, which indicates that NN might not be a good method in this study.

Table 4 and Table 5 show the average profit percentage (APP) for 1 and 3 days ahead simulated trading on WTI and Brent (all APP results are accumulated results for the 1-year testing period). Note that for both the two naïve trading strategies, we only calculate for one value since the holding time is the whole period for each of the four datasets. From the results, we found that for the ARIMA-based method, it always obtained negative APP results, for both WTI and Brent, and for any time horizons (1 day, 2 days, and 3 days), which indicates that ARIMA is not an appropriate method for crude oil trading. For method NN, it yields very good profit-making results for WTI 1 day (about 2.89 for a year) and Brent 1 day (about 2.64 for a year) ahead prediction and trading; however, it obtained a negative return for WTI 2 days and Brent 2 days and Brent 3 days ahead trading, which indicates NN is a good method for 1 day ahead trading but may not good for 2 and 3 days ahead trading. We also found SVM obtained a positive return except for WTI 1 day (about 0.01) and WTI 3 days ahead trading ( 0.09). For the proposed deep LSTM-based model, it always obtained positive results for both markets' prediction and trading, and its results are better than those of simple RNN, single LSTM, and SVM. In summary, we have the following conclusions: (1) only the proposed deep LSTM-based method yielded positive returns for both markets and three time horizon trading. (2) The proposed method obtained much better results than naïve methods (“buy and hold” or “sell and hold”). (3) In the conventional methods, the SVM-based model yielded good results. Compared with the SVM-based method, our proposed deep LSTM-based model performs better, which shows that the deep LSTM-based model is better than conventional methods for crude oil trading.

5.2. Sharpe Ratio Results

Table 6 and Table 7 show the Sharpe ratio results for Brent and WTI simulated trading for 1 and 3 days ahead trading. Note that for the two naive trading strategies, we only calculate for once since the holding time is the whole period for each of four datasets. From the results of WTI, we could find that among the proposed and benchmark methods, only proposed method obtained positive results for two market (Brent and WTI) trading and three time horizon trading, which indicates that deep LSTM-based model could consistently beat conventional methods from not only return but also risk-return ratio.

6. Conclusions

This study investigated the performances of a deep LSTM-based crude oil spot price prediction and its trading system. Without any financial expert knowledge, our proposed deep LSTM-based trading method is independent and practical, and it does not even need to feature engineering and to describe the forget gates that make deep LSTMs capable of capturing long-term dependencies. The proposed deep LSTM-based system is able to capture and discover meaningful features under historical crude oil price timeframe for prediction. From the experimental results shown above, we found out our proposed deep LSTM system obtained the best returns in four testing periods (about 5.48% on average for WTI 1 day ahead prediction and trading), and the deep LSTM structure improved the trading profits (improved about 65.17% in average, compared with 3.32% APP of single LSTM method for WTI 1 day ahead prediction and trading). In addition, the proposed method obtained the best Sharpe ratio (about 2.25, 2.32, and 2.27 for WTI 1 day ahead, WTI2 days ahead, and WTI3 days ahead, respectively, and about 4.17, 2.27, and 2.61 for Brent 1 day, Brent 2 days, and Brent 3 days, respectively) among all the tested models, which indicates that our proposed method outperforms all other benchmark methods not only in returns but also in return-risk ratio. The experimental results have verified the superior performance of deep LSTMs for crude oil price prediction and trading. Thus, the proposed deep LSTM-based system can find some meaningful features under historical time series price data for trading and prediction.

Our model can be applied to the price prediction and trading of other financial derivatives, such as coal and gold. In future work, we can also develop more indicators to predict the price of crude oil and combine other methods, such as wavelet analysis, to forecast more markets and a wider range of time periods. There are also some future directions of this study such as a task-specific LSTM model. For example, it is meaningful to introduce wavelet transformation, which is an effective tool to analyze historical crude oil prices, into the LSTM models.

Data Availability

The experimental data used to support the findings of this study are available from the corresponding author upon request.

Conflicts of Interest

The authors declare that they have no conflicts of interest regarding this work.

Acknowledgments

This work was sponsored in part by the Hebei Intelligent Financial Technology Innovation Center. The authors thank the EIA website for making the data available for this research.