Be Financially Secure: Predicting Auto Stock Prices with Past Data
Total Page:16
File Type:pdf, Size:1020Kb
Be Financially Secure: Predicting Auto Stock Prices with Past Data Rutvik Parikh Massachusetts Academy of Math & Science at WPI [email protected] Table of Contents Abstract 1 Introduction 1 Methods and Materials 3 Moving Average 3 Relative Strength Index (RSI) 4 Money Flow Index (MFI) 4 Rate of Change Indicator (ROC) 5 Models 5 Results 6 Discussion 9 References 13 Parikh 1 1. Abstract Deciding which auto stocks to invest in can be overwhelming and frightening for many individuals due to the great amount of past data available, and the ambiguity of its effects on future outcomes. Therefore, the goal of this project is to develop a model for auto stock price prediction using technical analysis based on multiple indicators. First, a few quantitative indicators were chosen to assist with prediction. Next, computer algorithms were used to calculate numerical values of these indicators using stock price data. These values were then employed to predict whether the closing price of a particular auto stock would rise or fall in the short term; distinct subsets of these indicators were tested in an effort to obtain the strongest and most helpful model. These models were tested on stock price data from several major auto companies, including General Motors, Subaru, and Ford. This data was from 2013 to 2018. The accuracies of the models were spread out over a range of 42% to 69%. The most successful model relied on the rate of change indicator, suggesting that this indicator may have been the most applicable to the auto industry during the aforementioned years. The performance of the models shows that technical analysis effectively gauges the future behavior of auto stocks. Considering the complex volatility of the stock market, these models can be used by investors to help make important financial decisions and feel more confident about their investments. 2. Introduction Many people invest in an effort to accomplish future financial goals. By allowing individuals to try selling investments for more than they were originally purchased for, investing has the potential to help one make more money (Principal Financial Staff, 2020). There are several different types of investments that one may choose, and stocks are common ones. Stocks, which are bought and sold in the stock market, are pieces of possession in a particular Parikh 2 company. After a company lists its stock, individuals may purchase shares of that company’s stock (Davis & O’Shea, 2020). However, many individuals are scared of investing in stocks. There are a variety of reasons for this, but a major one is that people fear making poor investments that will lead to them losing money. Although it is true that losing money in the stock market is almost inevitable at some point, these losses are not significantly detrimental in the long term; continuously saving up money ensures that such losses are not potent (Becker, 2020). Furthermore, one can feel more confident of their investments by trying to predict future stock prices. Investors use different types of methods to analyze stocks, including fundamental analysis and technical analysis. Fundamental analysis examines several economic factors to determine the actual value of a stock at a certain time (Segal, 2020). On the other hand, technical analysis solely relies on past stock prices. Moreover, technical analysts may choose from a wide array of quantitative technical indicators to assist them with their analysis, with each indicator forming a conclusion about the future behavior of stock prices; multiple indicators are often used in conjunction to form final predictions (Chen, 2020a). Deciding which auto stocks to invest in can be an overwhelming experience for many individuals, as there are great quantities of past data available, but the effects of this data on future outcomes is unclear. This goal of this study was to develop a model that can predict auto stocks using technical analysis based on multiple technical indicators. The indicators that were employed included the exponential moving average, the relative strength index, the money flow index, and the rate of change indicator. The exponential moving average is an indicator that is not influenced by short-lived price deviations and that places an emphasis on more recent data Parikh 3 (Hayes, 2020). The relative strength index investigates whether a particular stock is overbought or oversold, and how this will affect the future behavior of prices (Chen, 2020b). Similarly, the money flow index uses a slightly different process to determine if a stock is overbought or oversold (Mitchell, 2020a). Finally, the rate of change indicator establishes the long-term trend of a certain stock and uses this trend to predict the future behavior of prices (Mitchell, 2020b). Overall, these indicators formed a prediction about the future behavior of stock prices for auto stocks. This study adds another reference point to other existing models; investors may use this as a comparison point with other models before making important decisions. To predict auto stock prices, the values of the technical indicators being used must be computed. 3. Methods and Materials Calculating each indicator value required different steps, and each indicator formed its own conclusion about the behavior of stock prices in the near future. The materials used in this study included RStudio (an integrated development environment for the programming language R) and stock price data from Yahoo Finance. It is important to note that unless otherwise noted, a stock price refers to the closing price of a particular stock over a certain interval of time. The calculation and interpretation of each indicator are described below: 3.1. Moving Average First, the most recent 50 trading days of a particular dataset were examined. The closing prices of the first 30 of these 50 days were used to calculate a simple moving average to be used as a starting point for a series of exponential moving averages. The exponential moving averages for the last 20 of the 50 original days were then calculated and placed in an array. Next, the differences between the values in this array were placed into another array. At this point, the two highest and two lowest values were removed from this array of differences to Parikh 4 remove outliers, and the mean of the 15 values that remained in this array was computed. If this mean was greater than zero, the moving average indicator predicted an increase in prices; likewise, this indicator predicted a decrease in prices when the mean was less than zero. Also, the indicator could not make a prediction when the mean equalled zero, as the data would be inconclusive in this case. 3.2. Relative Strength Index (RSI) First, the most recent 34 trading days of a certain dataset were identified. The first 14 of these 34 days were used to compute an initial average gain and initial average loss. These two values were then used as the starting values to compute the average gain and average loss over the interval containing the remaining 20 days of the original 34. Each new gain would be accounted for using a formula: new average gain = ((previous average gain) x 13 + new gain) / 14. This formula would hold true for average losses as well, replacing “gain” with “loss.” Next, the relative strength was found by dividing the average gain by the absolute value of the average loss. Finally, a formula was utilized to calculate the relative strength index: RSI = 100 - (100 / (1 + relative strength)). This indicator predicted an increase in prices when its value was less than 50 and a decrease when its value was greater than 50. In the scenario that the relative strength index equalled 50, the relative strength index would avoid making a definite prediction, as the data would be inconclusive. 3.3. Money Flow Index (MFI) First, the most recent 15 trading days of the dataset were identified. An array containing the typical prices of a particular stock for each of these 15 days was created. Next, another array containing the raw money flows during a time span of 14 days (the original 15 days minus the first of these 15 days), with negative values representing days on which the typical price was Parikh 5 smaller than the typical price on the previous day, was created. The positive money flow was then calculated by adding all positive values from the array of raw money flows, while the negative money flow was calculated by adding all negative values from this same array before multiplying by negative one. At this point, the money flow ratio was found by dividing the positive money flow by the negative money flow, and the money flow index was computed using a formula: MFI = 100 - (100 / (1 + money flow ratio)). When this indicator’s value was less than 50, it predicted an increase in prices; on the other hand, when its value was greater than 50, this indicator predicted a decrease in prices. A money flow index of exactly 50 made no prediction as a result of the inconclusive data. 3.4. Rate of Change Indicator (ROC) First, the closing price of the most recent trading day of the given dataset was found. Additionally, this same closing price 90 days earlier was also found. Referring to these values as recent and previous respectively, the rate of change indicator was computed through a formula: ROC = ((recent - previous) / (previous)) * 100. A negative ROC predicted an increase in prices, while a positive ROC predicted a decrease in prices. Lastly, the indicator did not make a prediction due to inconclusive data when ROC was equal to zero. 3.5. Models Each indicator was treated as its own model with its own prediction. In addition, a combined model that examines all four indicators was developed.