# Forecasting Stock Prices of Companies Producing Solar Panels Using Machine Learning Methods

Authors: Zaffar A. Shaikh; Andrey Kraikin; Alexey Mikhaylov; Gabor Pinter
Journal: Complexity
 (2022)

---

## Abstract

Solar energy has become an integral part of the economy of developed countries, so it is important to monitor the pace of its development, prospects, as well as the largest companies that produce solar panels since the supply of solar energy in a particular country directly depends on them. The study analyzes the shares of Canadian Solar Inc. and First Solar Inc. The purpose of the study is to study the possibility of forecasting the stock price of solar energy companies using neural networks for the purpose of subsequent investment. The recurrent neural network LSTM is used in the article and this approach is based on complexity theory. Machine learning technologies are now being actively implemented in various sectors of the economy and are considered effective. The program used assigns different significance to the data of the last months and the data for the first months of the 1st year. The first year of the last 5 years of the company’s activity is taken as the first year since more distant data no longer have significant significance for the forecast. In the course of the study, a forecast of the stock price of Canadian Solar Inc. and First Solar Inc. for 245 days was obtained. Based on the results obtained, the following conclusions were made: 20 neurons of the network is not enough to make an accurate forecast, but the level of confidence in such a forecast is high enough, neural network forecasts are applicable in investing and are accurate enough to determine medium- and long-term trends, but these forecasts are not applicable for traders. The direction of improving the accuracy of neural network predictions is promising for further research.


---

## Body

## 1. Introduction

The paper considers the shares of Canadian Solar Inc. and First Solar Inc., which are considered among the most stable, which means that they are much easier to predict than stocks with high volatility. The largest companies operating in the field of solar energy production, that is, all large companies engaged in the production of solar energy, as well as the production of equipment for its production, are very promising for investment, as they have all the advantages that are inherent in large companies, however, due to the overwhelming majority of traditional energy sources, solar energy companies have significant potential for growth, primarily due to the annual reduction of oil and gas reserves. Many developed countries are aware of the need to switch to alternative energy sources not only because of the reduction in the world’s reserves of traditional energy sources, but also because of the need to reduce dependence on oil and gas importing countries.All this, combined with the recent global increase in oil and gas prices, forces countries to switch more actively to alternative energy sources, and increasing solar activity encourages them to choose mainly solar among various types of alternative energy. It is obvious that the cost of traditional energy sources will only increase as their reserves are depleted, and in a few decades their prices may bring down a number of economies of developed countries. Therefore, it is important to monitor the dynamics of the supply of solar electricity in different countries and make forecasts for the further development of this industry.The issues related to the development of solar energy have been worrying scientists for many years. At the same time, thanks to modern technologies, the use of solar energy is becoming more and more widespread, and the problems of the development of solar energy are becoming more and more urgent. The prediction of solar radiation is one of the most important indicators that directly affect the supply of solar energy [1–3]. It was proposed to use an unconditional method for territories with a high number of sunny days, and for territories with low solar activity to apply the method of conditional probability. According to them, to further improve the accuracy of forecasting, it makes sense to use different forecasting methods for different periods of the year. Other authors intend to create forecasts of solar radiation based on humidity and cloud cover, which are components of the clarity index [4–9]. Scientists in the following work managed to make an hourly forecast of solar radiation, thanks to machine learning technologies such as GRU and LSTM. Various models of deep irradiation were used to make the forecast [10–12]. Machine learning can also be used to predict oil prices [13, 14]. The machine learning algorithm can be found in an article by other authors [8]. Another article is devoted to the consumption of electricity in the process of mining cryptocurrencies. As an example, the 4 most famous cryptocurrencies using the Herfindahl-Hirschman method were given [15–18]. The following articles show an approach using machine learning that should solve problems in insecure systems [19, 20]. It developed a hybrid computational model for predicting solar power generation under normal conditions at various time intervals (PI), such as twenty-minute, fifteen-minute, ten-minute, five-minute, and one-minute. The approach is planned to be applied in countries with a large number of sunny days per year. The project of placing solar energy companies of their power plants in South America and Africa emphasizes that this approach is relevant and effective [21–25]. The work of other authors talks about achieving sustainable development in Russia through the use of e-learning financing models based on complexity theory. It is that the study of complex systems, including subjects such as chaos theory, genetic algorithms, and theoretical computer science dealing with the resources required during computation to solve a given problem.Sustainable development is an important factor in making a forecast, so the example of countries that are not considered in this article is also useful [26, 27]. Alternative forecasting methods are useful in evaluating the effectiveness of machine learning in forecasting. The shares of the largest solar energy companies directly depend on the projected oil prices, which the authors of the following article talk about [28, 29]. The same authors wrote another article that continues the idea of improving the accuracy of forecasting oil prices, but within the framework of this article, the authors use a new modification of the autoregressive integrated model using additional exponential smoothing [30, 31]. Another study is devoted to climate change under the influence of greenhouse gases [32]. They proposed using the reduction method and the multiplication method, the latter of which was recognized as more effective as a result of their research. The energy sector in Africa, especially in the context of solar energy, is of interest in many countries outside Africa. In their work, researchers write about deglobalization in the energy sector in Africa, as well as about the market reaction in China and the United States to their trade relations [10].To predict the share prices of companies producing solar panels, as well as the supply of solar energy in different countries, it is necessary to use not only such direct factors as the price of traditional energy sources, but also indirect factors affecting the value of shares through the impact on the cost of energy sources. For example, another team of authors found a certain degree of dependence of the gross domestic product of the world’s leading oil-supplying countries and proved this dependence on the example of Saudi Arabia and Russia [25]. The topic of dependence of economic growth on energy consumption was considered by another author using the example of Tanzania. Energy consumption is the most significant factor in assessing the supply of solar electricity since demand is necessary for supply growth [33]. Now let us look at the work of the authors, directly about the countries, which will be discussed later in this article. In their article, the authors reviewed the EU countries, including those countries that will be discussed later. More precisely, the relationship between the GDP of different EU member states in the period from 1971 to 2005. The authors conducted their analysis using a panel test of causality. The exponential smoothing method of the state space can be used to refute or confirm the forecast and its accuracy, which is particularly useful for cities where solar panels are mainly installed on roofs and windows of houses. In this case, these are usually multistore offices, skyscrapers, and the windows of which are able to fully provide such knowledge with electricity, despite the high electricity consumption by the office itself [20, 22]. It is worth adding that there is a diagnostic approach to the assessment of predictive indicators, which is used to calibrate predictive indicators, the principle of which was considered in detail by scientists in their work [25].An innovative method of controlled introduction of nanoclusions into a polymer matrix was proposed in the article [22, 23]. In two papers at once, the authors examined the impact of the human development index on energy quality, one of the global indicators of sustainable growth and on its consumption [22]. The full cycle of operation of a solar power plant sometimes takes even more than a year, and forecasts of solar electricity supply very rarely take into account the size of the reserve that the power plant can stock and the amount of energy that consumers can actually spend at the moment. Solar electricity in the largest quantities is generated exactly when it is least needed. That is, in warm sunny weather, people are less inclined to heat the premises and turn on the lights than in cold and cloudy weather, when solar electricity is generated significantly less, so the issue of reserve is extremely important. In another paper, the authors proposed a new method for calculating the reserve [23].One of the ways to predict electricity production based on solar radiation is the analysis and fixation of spatio-temporal dependencies in the generation of photovoltaic signals with the modeling of multidimensional predictive distributions and further formation of spatio-temporal trajectories that describe the potential evolution of prediction errors depending on location and execution time [26]. In 2016, the same authors published another article on the use of the Extreme Irradiation Machine (ELM) as a regression model for obtaining short forecasts for a time interval from 1 minute to an hour [27]. The solution to this problem was the GHI method.Wind energy is a direct competitor to solar, as it is not only an alternative energy, but also requires similar climatic conditions for maximum successful operation. That is, there is a problem of competition for territories where both solar power plants and wind power plants can be located, so it is important to evaluate the development of competitors for the successful promotion of the industry.Now let us move on to the issue of investing in solar energy. Solar energy, like any other industry, needs investments, and this gives an investor the opportunity to earn money on the transition to renewable electricity. Various factors are important in investing, such as the economic growth of the country as a whole, since the economic growth of the country affects developing industries. However, economic growth is also a multifactorial indicator, which depends, in particular, on inflation. The work of two authors talks about the impact of inflation on economic growth, which is especially relevant in connection with recent events in Europe and the USA, where inflation is breaking records of the 21st century [24]. Another factor influencing economic growth is electricity consumption per capita. In the course of the study, a conclusion was made about the effectiveness of increasing electricity consumption for developing countries and a recommendation was developed for developed countries to save electricity since the increase in electricity consumption in these countries does not lead to the same result [1]. Another author wrote about the relationship between GDP growth and foreign direct investment, based on the Granger causality criterion and the theory of cointegration [16]. The relationship between the economic growth of Greece in 1960–1996 was the subject of study by a team of scientists who applied a vector error correction model in their work [30]. The relationship between economic growth and energy consumption, which has already been discussed earlier, was considered by two more researchers several decades earlier [31–35]. One example of an investment strategy that can be used when investing in companies related to solar energy was given in the work of a group of researchers [24, 25].


## 2. Materials and Methods

In our work, we use machine learning technologies and complexity theory to predict time series. In particular, it is a recurrent neural network program with long short-term memory-LSTM. The principle of operation of LSTM algorithms is based on the fact that each successive value of a time series (in this work, this is the price) is analyzed by the program based on previous values, that is, it accumulates.The advantage of LSTM over other recurrent neural networks is the ability to analyze long-term dependencies, such as company shares. This is achieved due to the presence of four interacting layers within the neural network module, whereas in simple recurrent neural networks, the module consists of only 1 layer. LSTM determines the amount of information that needs to be skipped further depending on the tasks. To do this, gates are used, consisting of a pointwise multiplication operation and a sigmoid layer.The work of LSTM begins with the training stage. At this stage, the neural network analyzes the input data, automatically adjusting the strength of the input data signals. Thus, the neural network learns to understand which data can be deleted, and which to pay special attention to. Next, the test data is analyzed using the following formula:(1)ft=σWf∗ht−1,xt+bf.In this formula, it can be seen that we initially fasten the vectorsXt and ht−1 multiply them by the weight matrix Wf, while adding the shift bf and, as mentioned earlier, pass through the sigmoid activation function. The result is a vector ft that evaluates the need for individual parts of the data.Next, the vectorsht−1 and Xt are passed through two independent layers using the formulas:(2)it=σWi∗ht−1,xt+bi,aCt′=tanhWC∗ht−1,xt+bC,Here is the same principle as in the previous formula, except that in the second formula the vectors pass through the hyperbolic tangent function. As a result, the neural network determines which data needs to be added.The source data is multiplied byf (t), and Ćt multiplied by it and added to the weighted source data:(3)Ct=ft∗Ct−1+it∗Ct′.At the next stage of allocating the necessary information, a prediction is formed directly—the result of LSTM work.(4)ot=σWo∗ht−1,xt+bo,ht=ot∗tanhCt.As training data for LSTM, we used the closing price values for each day of stock trading over the past 5 years, but without taking into account the last 245 days. The data of the last 245 days is used as a test. This means that two graphs can be included in the results—the actual and the forecast graph from the neural network and evaluate the effectiveness of the work. We also used the dropout layer in our model to prevent overfitting, which leads to the classic paradox of machine learning models, in which the program shows significantly more accurate results on training data than on test data. In the LSTM layer, we use 20 nodes. This value was determined by us as optimal for the purposes of our analysis.Also, to increase the reliability of the model, we added a dense layer with 1 neuron. The root-mean-square error was used as a loss function.


## 3. Results

The Figure1 and the Figure2 show results of the work of our neural network. The blue color shows the real stock price, and red color shows projected stock price. The actual stock price of First Solar Inc. and Canadian Solar Inc., respectively, and in red—the forecast that the neural network received. We can say that the forecast is very accurate, because, despite the discrepancy between many values of the actual and predicted stock prices, the neural network sees the bulk of local trends and even approaches the actual values quite closely.Figure 1
Predicting the stock price of First Solar Inc (The blue color shows the real stock price, red color shows projected stock price). Sources: authors.Figure 2
Predicting the stock price of Canadian Solar Inc (The blue color shows the real stock price, red color shows projected stock price). Source: authors.It can be noted that this forecast slightly does not coincide with the time of reaching the maximum and minimum values, which is not critical for an investor who changes the composition of his portfolio every six months or even less often, but in this case the investor will still not have the opportunity to get the maximum possible benefit. One of the main achievements for an investor is to save time on analyzing the fundamental indicators of the company and constantly monitoring their changes. Thanks to the neural network, an investor can evaluate hundreds of companies in 1 day to select a suitable one, provided that the computer performing the calculations has sufficient power, since for modern personal computers this value will be within 10.For a trader, this forecast is applicable only if the trader has been trading for at least a week, since in addition to the time lag, the forecast has many other drawbacks, such as the mismatch of local trends, the intersection of the predicted maximum points with the actual minimum, and the inaccuracy of the values of the break points. It is also impossible to say that these problems can be solved by the daily release of a new forecast, because, as you can see, at the very beginning of the chart, the forecast trend goes in the opposite direction to the actual trend, which once again confirms its inapplicability for traders.Currently, neural networks are already used by large investors to predict stock prices, but their number is significantly less than investors who do not use neural networks. Thus, we can talk about a human factor affecting the stock price, which reduces the accuracy of the neural network forecast. It is also possible to compare the effectiveness of forecasting using modern LSTM neural networks (Figures1 and 2) with a more classical way of predicting stock prices, such as ARMA (Figures 3 and 4). The graphs clearly show that the accuracy of LSTM is much higher. The reason for this is that ARMA makes a forecast based on the average values of the training sample period. To demonstrate this, the actual data of the training period is also added to the forecast graph. LSTM, in turn, uses a combination of long-term and short-term memory, that is, not only long-term, as in ARMA, which allows you to achieve such results. It can be said that ARMA is more suitable for creating a forecast of the stock price of traditional energy companies, the value of which is relatively stable or has a long-term trend. In the case of alternative energy, in this case solar, there is a high volatility of the stock price, which further enhances the advantage of LSTM.Figure 3
Predicting the stock price of First Solar Inc (The blue color shows the real stock price, yellow color shows projected stock price). Sources: authors.Figure 4
Predicting the stock price of Canadian Solar Inc (The blue color shows the real stock price, yellow color shows projected stock price). Source: authors.Based on official data, forecasts were also made for the supply of solar electricity in developed countries until the end of 2025. For comparison, forecasts were made for countries with different levels of development of the solar energy industry. The following are graphs for 6 countries, which contain both the actual values of the supply of solar electricity from previous years and the projected supply values until 2025:The graph shows that the Netherlands as a percentage will become the country with the highest growth rate of solar energy supply in the coming years (Figure5). This is due to the fact that the country has suffered the least from the coronavirus pandemic among those presented in this study, as well as due to the relatively low level of solar energy supply at present, that is, the Netherlands has a high potential for growth. Despite the fact that the annual global horizontal solar radiation (IGH) in the Netherlands is about 1000kWh/m2, significantly less than in a number of European countries, the Netherlands intends to become a leader in replacing traditional energy with alternative energy. So, in March 2017, the Dutch Government published the “Energy Program: towards a Low-carbon energy supply,” according to which the only goal of energy policy in the coming years will be to reduce greenhouse gas emissions, that is, all financial resources within the framework of the implementation of the Dutch energy policy will be directed to alternative energy and mainly solar, which will ensure accelerated development.Figure 5
Solar energy supply in the Netherlands by year, gigawatts per hour. Source: IEA; author’s calculations.The graph of the forecast of solar energy supply in Portugal (Figure6) shows that solar energy in this country will develop unevenly due to lack of funding. The country has been significantly affected by COVID-19 and because of this, Portugal will have a lack of alternative energy financing in the coming years, but due to the country’s desire to meet European standards, funds will still be allocated as far as possible and this amount will vary greatly from year to year. However, due to the fact that most of the country is located in a zone where IGH is greater 1600kWh/m2, then we can talk about the potential for growth in the long term for 2030–2040.Figure 6
Solar energy supply in Portugal by year, gigawatts per hour. Source: IEA; author’s calculations.Germany (Figure7) and France (Figure 8) are currently in a similar situation, if we talk about the growth rate of solar energy supply in percentage terms. Despite significant differences in the current level of solar energy supply, these countries are the largest economies in Europe and have opportunities to finance the development of solar energy. The development of solar energy in Germany and France over the past 10 years has been going on evenly and one should not expect significant deviations from the main trend line. The plan for the transition to carbon neutrality in France and Germany is based on a gradual transition to alternative energy and in a crisis it is planned to maintain the pace of this transition.Figure 7
Solar energy supply in Germany by year, gigawatts per hour. Source: IEA; author’s calculations.Figure 8
Solar energy supply in France by year, gigawatts per hour. Source: IEA; author‘s calculations.The graph of the dynamics of the supply of solar energy in Italy (Figure9) shows that in recent years there has been a very weak positive trend of development and, moreover, in some years, the dynamics of development is negative. This is due to the fact that the Italian authorities have limited funding under the CEF program, as well as the introduction of a tax on the production of electricity consumed by own forces. Thus, part of the production capacity in Italy becomes unprofitable, especially in the northern regions. This leads to the abandonment of solar energy and the transition back to traditional energy sources. In the current state of crisis, there is no reason to assume that the tax will be abolished and funding will be increased. This may later lead to the fact that Italy, as part of the transition to alternative energy, will become different from most developed countries, even if it is now one of the world leaders in terms of the supply of solar electricity. However, the average IGH in Italy is 1450kWh/m2, which inspires hope for the further development of this industry.Figure 9
Solar energy supply in Italy by year, gigawatts per hour. Source: IEA; author’s calculations.The USA is an advanced country in the production of solar electricity (Figure10). This is due to both high financial capabilities and the area of the country itself. On the offer of solar energy, the United States competes for world leadership only with China, since all other countries lag far behind in this indicator. The sharp rise in prices for traditional energy sources, which has recently been observed in the United States, may become an incentive for the development of solar energy since the profitability of this industry has recently increased dramatically. IGH in the southern regions of this country exceeds 2000kWh/m2, which is the highest indicator among the countries considered in this study. Thus, it is highly likely that in the near future we can expect an acceleration in supply growth in the United States.Figure 10
Solar energy supply in the USA by year, gigawatts per hour. Sources: IEA; author’s calculations.Also, for comparison, a diagram of the forecast values of solar electricity supply for all 6 countries was made (Figure11).Figure 11
Comparison of projected solar electricity supplies to developed countries in 2025, gigawatts per hour. Source: author’s calculations.On the diagram of the forecast of solar electricity supply in developed countries in 2025, it can be seen that the United States will still remain the leaders in solar electricity generation compared to European countries. Despite the southernmost position, Germany will occupy the 2nd place among the countries considered in this paper. The Netherlands is expected to overtake Italy in the supply of solar electricity due to the crisis in the Italian solar energy industry and, conversely, the rise of solar energy in the Netherlands. France will develop solar energy at a more accelerated pace, but due to lack of funding, it will not be able to catch up with the advanced European countries in this industry, and Portugal’s solar energy supply will remain the smallest among the countries under consideration.


## 4. Discussion

The question of the applicability of neural networks to forecasting is still debatable. Most opponents of the mathematical method of forecasting refer to the “natural instinct” of a successful investor. At the stage of the company’s inception, that is, when a new brand has only minor experience in the market or the company is looking for investors even before its official opening, computer algorithms cannot make a forecast about the future of the brand in such a way that this forecast differs significantly from the method of predicting the loss of one or the other side of the coin in probability theory. An investor who has knowledge of the market and is able to evaluate a future product from a human point of view can tell whether a new company has prospects or not.The investment is in start-ups based on complexity theory that allow enterprising people to earn millions, because, despite the high risk, some products already at the stage of their origin look successful and can bring high profits. Of course, people still make forecasts for the development of young companies better than neural networks, however, when it comes to companies that have gone through an IPO, neural networks already occupy a leading position in forecasting accuracy. LSTM, for example, analyzes data arrays much more accurately and faster than a person and makes a forecast of the development of large companies. It can also be said that the accuracy of LSTM in comparison with less modern methods such as ARMA is significantly higher.Turning directly to the issue of solar energy, it is worth saying that few people have doubts about the promising future of this energy industry. The key question is how quickly it will develop and what periods will become critical in the process of its formation as one of the main sources of energy of mankind. The potential of solar energy is currently used by less than 0.000000001%, and the success of the transition to this type of energy is already obvious. Solar energy will definitely experience crisis phenomena this century due to cheaper traditional energy and competition with other types of alternative energy. Nevertheless, solar energy can develop quite efficiently with appropriate financing, as it happens, for example, in the United States, and if there is a lack of financing, a recession may occur, as in Italy. Financing is an important factor in the development of any industry, but if the development of traditional energy leads to the successful development of the state in the coming decades, then alternative energy is the way to energy independence for the coming centuries. Thus, countries such as Germany and the Netherlands, investing heavily in the development of solar energy, allow this industry to go through crisis phenomena and become a good source of income in the long term. Solar energy companies receiving state support during the formation of this industry are likely to become leading energy companies in a few decades.


## 5. Conclusions

Based on the presented results and complexity theory, it can be concluded that neural networks can be used to predict stock prices for investment purposes. From a trader’s point of view, neural networks are not applicable, except for weekly traders, because they cannot always accurately detect a local trend and almost always the maximum and minimum values in the forecast occur later than the same actual values. Moreover, there is no way to determine how much the forecast differs from the actual values in time.Nevertheless, it is obvious that neural networks are a promising direction for the development of forecasting and investment quality. Research in this area needs to be continued, which may lead to the emergence of neural networks that make it possible to make a forecast not only for the investor, but also for the trader, which will be the main goal of our further research. Speaking about the effectiveness of recurrent neural networks, in this case LSTM, it is worth mentioning that in comparison with classical methods, for example, ARMA, they are significantly more effective for predicting stock prices of companies in conditions of high volatility.According to the forecasts made for the supply of solar electricity in 6 developed countries until 2025, the Netherlands has the most chances to make a sharp jump in this industry, which is highly likely to overtake Italy in this indicator due to the energy crisis in Italy, which was caused by the actions of local authorities. Portugal, despite the high rate of solar radiation in the region, is unlikely to be able to even come close to the European leaders in the production of solar energy due to the weak current development of this industry due to lack of funding. The USA will remain the leader in solar power generation compared to any European country due to high financing, as well as due to the fact that the IGH in the southern regions of this country exceeds2000kWh/m2, which is the highest indicator among the countries considered in this study. Germany will remain the leader among the European countries considered in this study, and France will strive to catch up with Italy in terms of solar power generation, but it is unlikely to do so before 2025. Nevertheless, if the energy crisis continues in Italy, then France has every chance to catch up with it in terms of solar electricity supply this decade.



---

*Source: 9186265-2022-10-07.xml*