# A Meta-heuristic Approach for Copper Price Forecasting

Fabián Seguel, Raúl Carrasco, Pablo Adasme, Miguel Alfaro, Ismael Soto

► To cite this version:

Fabián Seguel, Raúl Carrasco, Pablo Adasme, Miguel Alfaro, Ismael Soto. A Meta-heuristic Approach for Copper Price Forecasting. 16th International Conference on Informatics and Semiotics in Organisations (ICISO), Mar 2015, Toulouse, France. pp.156-165, 10.1007/978-3-319-16274-4_16.hal-01324974

HAL Id: hal-01324974

https://inria.hal.science/hal-01324974

Submitted on 1 Jun 2016

HAL is a multi-disciplinary open access
archive for the deposit and dissemination of sci-
entific research documents, whether they are pub-
lished or not. The documents may come from
teaching and research institutions in France or
abroad, or from public or private research centers.

L'archive ouverte pluridisciplinaire HAL, est
destinée au dépôt et à la diffusion de documents
scientifiques de niveau recherche, publiés ou non,
émanant des établissements d'enseignement et de
recherche français ou étrangers, des laboratoires
publics ou privés.

<figure><img src="image_1.png" /></figure>

Distributed under a Creative Commons Attribution 4.0 International License
# A Meta-Heuristic Approach for Copper Price Forecasting

Fabián Seguel<fnref n="1" />, Raúl Carrasco<fnref n="1" />, Pablo Adasme<fnref n="1" />, Miguel Alfaro²
Ismael Soto<fnref n="1" />

¹ Department of Electrical Engineering, Universidad de Santiago de Chile,
Avenida Ecuador 3519, Estación Central, Chile

² Department of Industrial Engineering, Universidad de Santiago de Chile,
Avenida Ecuador 3769, Estación Central, Chile
{Fabian.Seguelg, Raul.Carrasco.A, Pablo.Adasme
Miguel.Alfaro, Ismael.Soto}@usach.cl

**Abstract.** The price of copper and its variations represent a very important financial issue for mining companies and for the Chilean government because of its impact on the national economy. The price of commodities such as copper is highly volatile, dynamic and troublous. Due to this, forecasting is very complex. Using publicly data from October 24th of 2013 to August 29th of 2014 a multivaried based model using meta-heuristic optimization techniques is proposed. In particular, we use Genetic Algorithms and Simulated Annealing in order to find the best fitting parameters to forecast the variation on the copper price. A non-parametric test proposed by Timmermann and Pesaran is used to demonstrate the forecasting capacity of the models. Our numerical results show that the Genetic Algorithmic approach has a better performance than Simulated Annealing, being more effective for long range forecasting.

**Keywords:** Genetic Algorithms · Simulated Annealing · Forecasting · Simulated Annealing · Copper

## 1 Introduction

As suggested by Adrian E. Drake: "The increasing availability of computing power in the last two decades has been used to develop new techniques of forecasting"<fnref n="1" />. This paper presents a multivaried based model to forecast the copper price variation. For this purpose, we propose two meta-heuristic algorithmic approaches in order to find the best fitting parameters for our multivaried model.

<footnote n="1">¹ Drake, Adrian E. Genetic Algorithms in Economics and Finance: Forecasting Stock Market Prices and Foreign Exchange: a Review. Sydney: Australian Graduate School of Management, University of New South Wales, 1998.</footnote>
The first one corresponds to a Genetic Algorithm (GA) which is inspired by natural selection [1]. Genetic algorithms were initially proposed by Holland [2] and have found applications in diverse areas such a process optimization [3], machine learning [4], and so on. Particularly, Recursive Genetic algorithms have been used for time series forecasting in [5] while adjusting the parameters of a dynamic multivaried model [6]. The second one, is based on Simulated Annealing (SA) approach. In particular, SA has been combined with artificial neutral networks and fuzzy systems to forecast time series as well [7] [8]. As far as we know, it has never been used in order to adjust a dynamic multivaried model to forecast a financial time series.

Forecasting of copper price is an important task not only for investors, but also for the government and agents who are involved on copper mining businesses. Particularly, mining is one of the pillars of Chilean economy. Chile is the largest copper producer around the world<fnref n="2" /> and the production of this product represents the 12.2% of the Gross Domestic Product (GDP)<fnref n="3" />.

The price of copper, as well as all the commodities, has a highly volatile, dynamic and troublous behavior making the forecasting a complex task. Antonino Parisi, Franco Parisi and David Díaz suggest that “...transaction strategies based on forecast of the direction in the price level fluctuation are more effective and can generate higher benefits than those based on a specific price level prediction.”<fnref n="4" />.

The proposed model uses both Genetic and Simulated Annealing algorithm procedure to forecast the sign of the variation on copper price. The publicly data used to this purpose correspond to copper price from October 24th of 2013 to August 29th of 2014 and Dow Jones price for the same period. The organization of the paper is as follows.

The methodology and model formulation is described in Section 2. The meta-heuristic algorithms used to fit the model parameters are explained in Section 3. The analysis of the numerical results is explained in Section 4. A discussion section is presented in 5. Finally, the conclusions of the study are presented in Section 6.

## 2 Methodology

In this section, both the management of the data and the model formulation are presented. The non-parametric test and the sign predictive percentage are also explained and mathematically described.

<footnote n="2">² Edelstein, Daniel L. «US Geological Survey: Mineral Commodity Summaries - Copper» January 2012.</footnote>

<footnote n="3">³ SOFOFA «Estructura de la industria Chilena». 2012
http://web.sofofa.cl/informacion-economica/indicadores-economicos/estructura-de-la-industria/</footnote>

<footnote n="4">⁴ Parisi, Antonino and Parisi, Franco and Diaz, David, Forecasting Gold Price Changes: Rolling and Recursive Neural Network Models. Journal of Multinational Financial Management, Vol. 18, No. 5, pp. 477-487, November 26 2007</footnote>
## 2.1 Data Management

The publicly data obtained for copper and Dow Jones price corresponds to two hundred and twenty four observations from October 24th of 2013 to August 29th of 2014. The data was divided in two sets. The first one is used to train initially the multivaried model whereas the remaining data correspond to out-of-sample data and it is used to measure the predictive capacity of the model. Several models estimate their forecasting rates based on the entire amount of observations. In particular, the proposed model uses a "Rolling operation" methodology which means that the in-sample size remains constant to "n" samples. For each iteration, the algorithm includes the next observation and discards the oldest one. The rolling time considered in the present paper corresponds to n = 45 observations. By doing this, a recently added sample is considered by the model and the oldest one is discarded. Therefore, our model can predict until a three-step ahead forecasting.

## 2.2 Model Formulation

A dynamic multivaried model is proposed to forecast the price variation of copper considering the past four variations on the copper price and Dow Jones. For this purpose, we first define the variation on the copper price at instant "t" as

$$ \nabla Cu_t = Cu_t - Cu_{t-1}. \qquad (1) $$

Where

$\nabla Cu_t$: Variation on the copper price from t-1 to t.

Cu_t: Copper price at time t.

Cu_{t-1}: Copper price at time t-1.

Similarly, the variation of Dow Jones price at time "t" is defined as

$$ \nabla Dow = Dow_t - Dow_{t-1}. \qquad (2) $$

Where

$\nabla Dow_t$: Variation on the Dow Jones price from t-1 to t.

Dow_t: Dow Jones price at time t.

Dow_{t-1}: Dow Jones price at time t-1.
To forecast the variation on the copper price, we use the past four variations on the copper price, Dow Jones price and the error of the forecasted prices. The model can be expressed formally as

$$ \nabla \overline{Cu_t} = \sum_{i=1}^{4} \beta_{di} \nabla Dow_{t-i} + \beta_{ci} \nabla Cu_{t-i} + \beta_{ei} \epsilon_{t-i}. \quad (3) $$

Where

$\nabla \overline{Cu_t}$: Forecasted variation on the copper price.

$\nabla Dow_{t-i}$: Real variation on the Dow Jones price at time t - i.

$\nabla Cu_{t-i}$: Real variation on the copper price at time t - i.

$\epsilon_{t-i}$: Error on the past forecasted variations obtained as $\epsilon_{t-i} = \nabla Cu_{t-i} - \nabla \overline{Cu_t}$.

$\beta_{di}$, $\beta_{ci}$ and $\beta_{ei}$ are parameters determined by using the meta-heuristic approaches.

The parameters are adjusted within three steps as follows:

1) The parameters of the model are obtained for the "n" samples.

2) Then, a one (two or three) step ahead price is forecasted.

3) Subsequently, the new observation is added on the in-sample data and the oldest value is discarded. Steps 1) and 2) are repeated.

This method requires to be adjusted permanently with new real data. The model parameters are not supplied in this paper, but only the sign predictive percentage is reported in Section 3.1.

## 2.3 Sign Prediction Percentage

As it was exposed in Section 1, determining the sign of the variation of copper price is an effective strategy which allows generating higher benefits. To determine the sign variation percentage of each forecasted period we use the following equation

$$ SPP = \frac{\sum_{t=1}^{m} \theta(\nabla Cu_t \cdot \nabla \overline{Cu_t})}{m} * 100\%. \quad (4) $$

Where

SPP: Sign prediction percentage.

$\nabla Cu_t$: Variation on the price of copper from t - 1 to t.

$\nabla Cu_t$: Forecasted variation on the price of copper.

$\theta()$: The Heavyside function where $\theta(\nabla Cu_t \cdot \nabla \overline{Cu_t}) = 1$ if $\nabla Cu_t \cdot \nabla \overline{Cu_t} > 0$ and $\theta(\nabla Cu_t \cdot \nabla \overline{Cu_t}) = 0$ if $\nabla Cu_t \cdot \nabla \overline{Cu_t} < 0$.
m: Number of forecasts made.

In case, the SPP is lower than 50% the predicted variation on the copper price will have the opposite sign of the model (−$\overline{\nabla Cu_t}$). Due to this the prediction percentage is obtained by

$$SPP = \max(SPP, 1 - SPP). \qquad (5)$$

## 2.4 Non-parametric Test of Predictive Performance

Pesatan and Timmermann proposed a non-parametric test of predictive performance based on the correct direction of the forecasted variable [9] (Directional accuracy). This procedure proves the null hypothesis that the observed variations on the price are independently distributed from the forecasted variations. If the hypothesis is rejected, it means that there is statistical evidence that the model is able to forecast a future variation on the price. The Pesatan and Timmermann test compares the sign of the real variation on the price and the sign of the forecasted variation on the price. In order to obtain the real positive variations on the copper price, we use the equation (6)

$$P = \frac{\sum_{t=1}^{m} \theta(\nabla Cu_t)}{m}. \qquad (6)$$

Where

P: Percentage of the real positive variation on the price of copper.

Similarly, the percentage of positive variations on the forecasted price is obtained by means of

$$\bar{P} = \frac{\sum_{t=1}^{m} \theta(\nabla \overline{Cu_t})}{m}. \qquad (7)$$

Where

P: Percentage of the forecasted positive variation on the copper price.

Furthermore, the success ratio index (SRI) when the forecasted variations and the real variations on the price are independently distributed is obtained by means of

$$SRI = P \cdot \bar{P} + (1 - P) \cdot (1 - \bar{P}). \qquad (8)$$

The variance of SRI rate is obtained by means of equation (9) as follows
$$ \mathrm{var}(\mathrm{SRI}) = \frac{(n(2\bar{P}-1)^2\mathrm{P}(1-\mathrm{P})+n(2\mathrm{P}-1)^2\bar{P}(1-\bar{P})+4\mathrm{P}\bar{P}(1-\mathrm{P})(1-\bar{P}))}{m^2}. \quad (9) $$

Consequently, the variance on the success ratio(SPP) is defined as

$$ \mathrm{var}(\mathrm{SPP}) = \frac{\mathrm{SRI}(1-\mathrm{SRI})}{m}. \quad (10) $$

Finally, the directional accuracy test (DAT) is given by the equation

$$ \mathrm{DAT} = \frac{\mathrm{SPP}-\mathrm{SRI}}{\sqrt{\mathrm{var}(\mathrm{SPP})-\mathrm{var}(\mathrm{SRI})}} \sim N(0,1). \quad (11) $$

This test follows a standard normal distribution and it is used to prove the null hypothesis that the forecasted prices are independently distributed. This means, the larger the value of DAT the better the accuracy of the model.

# 3 Meta-Heuristic Optimization Algorithms

In this section, the meta-heuristic optimization algorithms used to adjust the model parameters are briefly described.

## 3.1 Genetic Algorithm

Genetic algorithms were initially proposed by Holland in 1975 [2]. A genetic algorithm is a meta-heuristic approach inspired by Darwin's theory which is based on the survival of the fittest [1]. Genetic Algorithms use a direct analogy of natural evolution. A possible solution is codified as an individual and each individual is composed of variables (or chromosomes). Each individual will have as many chromosomes as variables in the problem. In order to obtain an initial solution for the problem, a population of individuals is generated randomly. The population is modified within each iteration of the algorithm depending on the following operators:

1. Fitness Function: The fitness function (objective function) must be defined. In this particular optimization problem there are no constraints on the optimization problem. Thus, the fitness function is defined as:
$$ \max \mathrm{SPP} \quad (12) $$

2. Selection: A portion of the existing population is selected. The best solutions are more likely to be selected as parents for the next generation.
3. Crossover: Crossover combines the chromosomes of each parent in order to create new solutions called offsprings.

4. Mutation. Some offsprings are randomly modified by a mutation process. Mutation changes a particular gen on the chromosome. The mutation operator enables the population to explore new zones of the feasible space.

The process is continuously repeated creating new generations of individuals until a stopping criteria is met. In this particular problem the stopping criteria selected was four hundred generations of individuals. In particular, Genetic Algorithms have been previously used on financial forecasting [6] [10].

## 3.1 Simulated Annealing

Simulated Annealing is a meta-heuristic optimization method proposed independently by Scott Kirkpatrick, C. Daniel Gelatt and Mario P. Vecchi in 1983 and by Vlado Černý in 1985 [11] [12]. The Simulated Annealing algorithm is inspired from the process of annealing in the metallurgical industry. It starts with an initial high temperature and then it slowly decreases during the execution of the algorithm. This reduction allows the algorithm to explore the solution space and avoid a possible local optimal. As the temperature is reduced so is the chance of accepting worse solutions. This temperature reduction allows the algorithm to focus on areas of the solution space where the global optimum may lie. Simulated Annealing has not been applied for multivaried dynamic models, however it has been mixed with fuzzy models [7] and artificial neural networks [8] for time series forecasting. Similarly, as in our genetic algorithmic approach, we use the objective function given by the equation (12) and the stopping criteria selected was four hundred iterations.

# 4 Numerical Results

The numerical results are presented in two subsections. The first one summarizes the model results for the adjustment of the parameters using in-sample data while the second one summarizes the forecasting results of the out-of-sample data.

## 4.1 In-sample Data Results

For each time step the model parameters where adjusted in order to maximize the SPP. A total of one hundred and seventy nine different iterations were performed using the multivaried model. Figure 1 shows the values of SPP for each iteration of the model.
<figure><img src="image_2.png" /><figcaption>**Fig. 1.** a) Sign Predictive Percentage using Genetic algorithm. b) Sign Predictive Percentage using Simulated Annealing</figcaption></figure>

From the numerical results presented in Figure 1a), the SPP is larger than 50% when using Genetic Algorithms for all the iterations. In Figure 1b), we observe similar trends when using Simulated Annealing approach. For in-sample data the Genetic Algorithmic approach has a sign predictive performance mean of 66.96% while Simulated Annealing has a mean of 64.59%. This clearly shows that the genetic algorithmic approach is more effective.

## 4.2 Out-of-Sample Data Results

With the out-of-sample data, we compute the sign prediction percentage and perform the directional accuracy test for one, two and three step ahead forecasting. Table 2 shows the performances obtained.
<table><caption>**Table 2.** Sign predictive percentage and directional accuracy test for one, two and three step ahead forecasting obtained with Genetic and Simulated Annealing approaches.</caption><thead><tr><th colspan="4">One Step Ahead</th></tr><tr><th>Model</th><th>SPP (%)</th><th>DAT</th><th>p-value of DAT</th></tr></thead><tbody><tr><td>Genetic Algorithm</td><td>57.54%</td><td>2.0282</td><td>0.05100</td></tr><tr><td>Simulated Annealing</td><td>58.10%</td><td>2.1724</td><td>0.03768</td></tr></tbody><thead><tr><th colspan="4">Two Steps Ahead</th></tr><tr><th>Model</th><th>SPP (%)</th><th>DAT</th><th>p-value of DAT</th></tr></thead><tbody><tr><td>Genetic Algorithm</td><td>57.54%</td><td>1.9773</td><td>0.0564</td></tr><tr><td>Simulated Annealing</td><td>50.28%</td><td>0.03135</td><td>0.3987</td></tr></tbody><thead><tr><th colspan="4">Three Steps Ahead</th></tr><tr><th>Model</th><th>SPP (%)</th><th>DAT</th><th>p-value of DAT</th></tr></thead><tbody><tr><td>Genetic Algorithm</td><td>53.63%</td><td>0.9772</td><td>0.2474</td></tr><tr><td>Simulated Annealing</td><td>51.40%</td><td>0.3211</td><td>0.3788</td></tr></tbody></table>

In Table 2, column 1 presents the name of the algorithmic approach. Column 2 shows the SPP values obtained in percentage. Finally, in columns 4 and 5 we present the values obtained for the DAT and p-values for the DAT, respectively. For the one hundred and sixty nine forecasted variations, the Genetic Algorithm has a Sign Predictive Performance of 57.54%, 57.54% and 53.63% for one, two and three step ahead forecasting, respectively. While the Directional Accuracy tests are 2.0282, 1.9773 and 0.9772 for one, two and three steps ahead forecasting, respectively. These values prove that the predictive capacity of the model is useful up to two steps ahead forecasting.

On the other hand, the Simulated Annealing based model has a Sign Predictive Performance of 58.1%, 50.28% and 51.40% and a Directional Accuracy Test of 2.1724, 0.03135 and 0.3211 for one, two and three steps ahead forecasting, respectively. These values prove that the model can be used only for one step ahead forecasting while using Simulated Annealing.

# 5 Discussion

Other authors have adapted their forecasting models by using genetic algorithms [13] [14]. Nevertheless, there are still meta-heuristic approaches which have not yet been tested in order to compare their performances with Genetic Algorithms. Both algorithms used the same model to predict future prices. In the current literature, different models and their advantages to forecast future price of commodities based on the spot prices are well described [15] [16]. However, the algorithms used to adapt these models have not been compared in order to guarantee that the decision of using genetic algorithms is the right choice. This paper compares Simulated Annealing and Genetic Algorithms in a dynamic multivaried model. Both have been compared for learning problems showing that
Simulated Annealing found meanly better solutions than Genetic Algorithms in less computational cost [17] [18]. In this paper, we confirm that the Genetic Algorithmic approach is the right choice as it gives better solutions when compared to Simulated Annealing for short and long range forecasting. Finally, the decision maker can use the adapted parameters in order to forecast future copper prices using the equation (3) proposed in subsection 2.2.

# 6 Conclusions

In this article, we proposed two different meta-heuristic approaches to forecast the variation on the copper price. The proposed model requires to be adjusted every time the copper price changes. An initial adjusted model would not have the capability of forecast many steps in the future if it does not have the most recent information about the copper price behavior. Genetic Algorithms have proved be an efficient optimization approach to forecast time series. In particular, when compared with another meta-heuristic optimization technique such as Simulated Annealing as it has proved to be superior for short and long range forecasting. Forecasting on the copper price can increase the return and reduce the risk associated with the transactions of this base metal. Therefore, this methodology can be used on a real scenario. As future research, we plan to use Genetic Algorithms hybridized with nonlinear model architectures such as Non-linear autoregressive with exogenous input networks (NARX) for long range forecasting.

**Acknowledgments.** The authors acknowledge the financial support of the “Center for Multidisciplinary Research on Signal Processing” (CONICYT/ACT1120 Project) and the USACH/DICYT 061413SG Project.

# References

1. Darwin, C. The Origin of Species. Penguin Classics, 1859

2. Holland, J. H. Adaptation in Natural and Artificial Systems. Ann Arbor, MI: University of Michigan Press, (1975).

3. Kumar, M.P., Vijayachitra, S., "Process optimization using genetic algorithm," Control, Automation, Communication and Energy Conservation, 2009. INCACEC 2009. 2009 International Conference on, vol., no., pp.1, 6, 4-6 June 2009.

4. Chisholm, K.J., Bradbeer, P.V.G., "Machine learning using a genetic algorithm to optimise a draughts program board evaluation function," Evolutionary Computation, 1997., IEEE International Conference on, vol., no., pp.715,720, 13-16 Apr 1997.

5. Chin Teck Chai, Chua Hong Chuek, Mital, D.P., Tan Thiam Huat, "Time series modelling and forecasting using genetic algorithms," Knowledge-Based Intelligent Electronic Systems, 1997.
KES '97. Proceedings, 1997 First International Conference on, vol.1, no., pp.260,268 vol.1, 27-23 May 1997.

6. Parisi, Antonino, Parisi, Franco, Cornejo, Edinson, "Algoritmos genéticos y modelos multivariados recursivos en la predicción de índices bursátiles de América del norte: IPC, TSE, NASDAQ Y DJI*." El Trimestre Económico. Fondo De Cultura Economica. 2004. HighBeam Research. 8 Oct. 2014.

7. Almaraashi, M., John, R., Coupland, S., Hopgood, A., "Time series forecasting using a TSK fuzzy system tuned with simulated annealing," Fuzzy Systems (FUZZ), 2010 IEEE International Conference on July 2010, vol., no., pp.1,6, 18-23.

8. Wu, Jui-Yu, "Advanced simulated annealing-based BPNN for forecasting chaotic time series," Electronics and Information Engineering (ICEIE), 2010 International Conference On, vol.1, no., pp.V1-38, V1-43, 1-3 Aug. 2010.

9. M. H. Pesaran and A. Timmermann, "A Simple Nonparametric Test of Predictive Performance,"

10. Journal of Business & Economic Statistics, vol. 10, no. 4, pp. 461-465, 1992.

11. Bongju Jeong, Ho-Sang Jung, and Nam-Kyu Park. 2002. A computerized causal forecasting system using genetic algorithms in supply chain management. J. Syst. Softw. 60, 3 (February 2002), 223-237.

12. Kirkpatrick, S., Gelatt Jr, C. D., Vecchi, M. P. "Optimization by Simulated Annealing". Science 220 (4598): 671–680 1983.

13. V. Černý. "Thermodynamical Approach to the Traveling Salesman Problem: An Efficient Simulation Algorithm." Journal of Optimization Theory and Applications: 41–51.

14. B. Jeong, H. Jung, and N. Park, "A computerized causal forecasting system using genetic algorithms in supply chain management," vol. 60, pp. 223–237, 2002.

15. M. S. Khadka, B. Popp, K. M. George, and N. Park, "A NEW APPROACH FOR TIME SERIES FORECASTING BASED ON GENETIC ALGORITHM."

16. Chakriya Bowman and Aasim M. Husain, "Forecasting Commodity Prices: Futures

17. Versus Judgment “, International Monetary Foung, March 2004.

18. Trevor A. Reeve and Robert J. Vigfusson, "Evaluating the Forecasting Performance of Commodity Futures Prices", Board of Governors of the Federal Reserve System, International Finance Discussion Papers, Number 1025,August 2011.

19. M. Ghazanfari, S. Alizadeh, M. Fathian, and D. E. Koulouriotis, "Comparing simulated annealing and genetic algorithm in learning FCM," *Appl. Math. Comput.*, vol. 192, no. 1, pp. 56-68, Sep. 2007.

20. S. Soares, C. H. Antunes, and R. Araújo, "Comparison of a genetic algorithm and simulated annealing for automatic neural network ensemble development," *Neurocomputing*, vol. 121, pp. 498-511, Dec. 2013.