Be Financially Secure: Predicting Auto 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 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 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 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 of the , these models can be used by 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 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 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 , the index, the , 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 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. This model’s prediction matched the prediction of the majority of the indicators when such a majority existed. However, when two indicators predicted a price increase and the other two predicted a price decrease, a preference was given to the relative strength index indicator since this indicator is regarded as Parikh 6 one of the most robust indicators by technical analysts. Thus, there were a total of five different models.

The accuracy of these models was tested using data from eight distinct auto companies across the globe: General Motors, Subaru, Ford, Honda, BMW, Tata Motors, Hyundai, and

Toyota. Six years of data, from 2013 to 2018, were examined for each auto company.

Consequently, a full year of data was used for each test, and the first two months of the following year were used to gauge the actual behavior of the market. Specifically, the number of trading days throughout the first two months of a certain year during which the closing prices increased was compared against the number of days during which these prices decreased in the same two months; the higher number would represent the overall direction of the market and would be used to test the models’ predictions. In the event that these two numbers were equal, the closing price of the first trading day of the first month was compared against the closing price of the last trading day of the second month; if the former was greater, prices decreased, but if the latter was greater, prices increased. Each model’s prediction was compared against the actual behavior of prices for each dataset in to gauge the accuracies of the models. After the accuracies of each of the models were obtained through this method, a decision matrix was employed to pick the best model. A statistical test, Fisher’s Exact Test, was then used to determine the significance of this best model.

4. Results

After all testing was conducted, the accuracy level of each model was determined. The rate of change indicator model had the highest accuracy of all models, correctly predicting the behavior of stock prices in 69% of the tests conducted. This was followed by the combined model, the relative strength index model, the money flow index model, and the moving average Parikh 7 model. The performance of each model can be seen in Figure 1 and an individual test case breakdown for three of the auto companies that the models were tested on can be viewed in

Table 1.

Figure 1. Accuracy of Models. RSI = Relative Strength Index. MFI = Money Flow Index. ROC = ​ ​ Rate of Change Indicator. Mean accuracy of all models = 59.4%. n = 48.

Table 1. Model Accuracy Test Cases. Accuracies of all models for three auto companies. ​

Company Year Moving RSI - MFI - ROC - Combined - Average - Accurate? Accurate? Accurate? Accurate? Accurate?

Subaru 2018 No Yes Yes Yes Yes

Subaru 2017 No Yes No Yes Yes

Subaru 2016 No Yes No Yes Yes

Subaru 2015 No Yes Yes Yes Yes

Subaru 2014 Yes Yes No No Yes Parikh 8

Subaru 2013 No Yes Yes Yes Yes

Ford 2018 No Yes Yes Yes Yes

Ford 2017 No Yes Yes Yes Yes

Ford 2016 No No No No No

Ford 2015 Yes Yes Yes No Yes

Ford 2014 No Yes Yes No Yes

Ford 2013 No Yes Yes Yes Yes

BMW 2018 No Yes Yes Yes Yes

BMW 2017 No Yes Yes Yes Yes

BMW 2016 No Yes No Yes Yes

BMW 2015 No Yes No Yes Yes

BMW 2014 Yes No No No No

BMW 2013 No Yes Yes Yes Yes

The rate of change indicator model was chosen as the best model. This model was very precise; it predicted that prices would increase and decrease in 48% and 52% of the 48 tests conducted, respectively. A more detailed overview of its predictions and how they compared to the market’s actual behavior can be seen in Table 2.

Table 2. ROC Indicator Model Data. The breakdown of predictions from the ROC indicator compared ​ with actual market behavior.

Predicted Up Predicted Down

Actual Up 14 6

Actual Down 9 19

Parikh 9

A p-value of 0.018179168 was produced by the rate of change indicator model. This value successfully rejects the null hypothesis that this model is based on chance and highlights the fact that there is a statistically significant relationship between its predictions and the actual behavior of the stock market. The performance of this model among distinct auto companies is shown in Figure 2.

Figure 2. ROC = Rate of Change Indicator. Mean accuracy of all companies = 69%. n = 48. ​ ​ 5. Discussion

The objective of this study was to develop models to predict the future behavior of auto stocks using solely technical indicators. This objective was met, as four distinct indicators were utilized to establish these models. Based on the accuracies and performances of these models, technical analysis is an effective method for examining auto stocks and forming conclusions about their short-term price movements, as most models displayed accuracies that were well over Parikh 10

50%. Such a conclusion supports the existing belief that technical indicators exhibit some relationship to actual stock prices (Kul, 2019). Specifically, the rate of change indicator is very applicable to this industry, given that a statistically significant relationship exists between this model’s predictions and the actual behavior of the stock market. However, this result opposes the claim that the relative strength index is the most accurate based on performance (Prorsi Staff, 2018). Additionally, stock market volatility causes stock prices to experience large movements and shifts (Kuepper, 2020). However, this study’s conclusion about technical analysis being a strong tool to employ in the auto industry highlights that this volatility can be studied and used in an ’s favor.

Alternatively, based on the rate of change indicator model’s accuracies for each of the eight companies it was tested on, it appears that the model is not greatly affected by the fact that these eight companies represent stocks that come from five different markets around the world.

In other words, this model continues operating with similar levels of accuracy when tested on stocks that belong to different global markets. This observation agrees with the belief that investors may examine data from international markets while the U.S. market is closed in order to gauge the behavior of U.S. stocks before the market reopens (Smith, 2020). As such, this study highlights that in the auto industry, there is a close relationship between several markets across the globe.

The step of removing the two greatest and two smallest differences between moving averages prior to the interpretation of the moving average indicator was an error and may have impacted the predictions of the moving average indicator and thus also the accuracy of the moving average model. Although outliers should be removed before a conclusion is formed, removing exactly four of the highest and lowest differences may have eliminated some values Parikh 11 that would have been helpful and were not outliers. On the other hand, there could still have been some outliers remaining after these four values were dismissed. Either way, this significant step of removing exactly four values contributed negatively to the moving average model. In addition, the decision to allow the relative strength index indicator to determine the prediction of the combined model when the indicators were evenly divided on a prediction was an error. This error may have impacted the predictions of the combined model and thus decreased its accuracy, as the relative strength index was not the most accurate indicator in this instance. Instead, employing a fifth indicator to make a decision in such a scenario may have yielded a better accuracy on the part of the combined model. Also, not including companies from other markets in addition to the five that were represented in this study was an error. Although this error had no influence on the data that was collected, more specific interpretations could have been made if more markets had been incorporated to test the models. In addition, a more complete perspective of the auto industry as a whole may have been possible if more markets were considered.

Ultimately, the rate of change index model, along with the other models generated from this study, can be used by investors to make important financial decisions. Financial risk, which describes the possibility that money will be lost as a result of a decision, exists in all investments to some degree (Chen, 2020c). However, the models produced in this study can help manage this risk and help individuals who are not confident about investing become more confident.

This is because these individuals would benefit from a plan to help them control their area of weakness (Boyes, 2018). Thus, the models developed in this study would help such individuals make choices about their portfolios. Furthermore, these models could also be applied with other similar models, providing investors with more confidence and less uncertainty about the future behavior of the stock market. Overall, this study and the stock prediction models it constructed Parikh 12 have the potential to assist countless investors in making significant investment decisions that could pave the way for future financial success.

Parikh 13

References

Becker, M. (2020). Don’t Let These Fears Stop You From Investing. TheSimpleDollar. ​ ​ Retrieved from

https://www.thesimpledollar.com/investing/too-many-millennials-are-afraid-of-investin

g

Boyes, A. (2018). 7 Tips for Increasing Your Self-Confidence About Investing. Psychology ​ ​ Today. Retrieved from

https://www.psychologytoday.com/blog/in-practice/201810/7-tips-increasing-your-self-

confidence-about-investing

Chen, J. (2020a). Technical Indicator. Investopedia. Retrieved from ​ ​ https://www.investopedia.com/terms/t/technicalindicator.asp

Chen, J. (2020b). Relative Strength Index (RSI). Investopedia. Retrieved from ​ ​ https://www.investopedia.com/terms/r/rsi.asp

Chen, J. (2020c). Risk. Investopedia. Retrieved from ​ ​ ​ https://www.investopedia.com/terms/r/risk.asp

Davis, C., & O’Shea, A. (2020). What Is the Stock Market and How Does It Work? ​ NerdWallet. Retrieved from

https://www.nerdwallet.com/article/investing/what-is-the-stock-market

Hayes, A. (2020). Moving Average (MA). Investopedia. Retrieved from ​ ​ https://www.investopedia.com/terms/m/movingaverage.asp

Kuepper, J. (2020). Volatility. Investopedia. Retrieved from ​ ​ https://www.investopedia.com/terms/v/volatility.asp Parikh 14

Kul, J. (2019). Does technical analysis work? Here’s proof! Medium. Retrieved from ​ ​ ​ https://towardsdatascience.com/does-technical-analysis-work-heres-proof-a2b626a3fbe

9

Mitchell, C. (2020a). Money Flow Index—MFI Definition and Uses. Investopedia. Retrieved ​ ​ from https://www.investopedia.com/terms/m/mfi.asp ​ ​ Mitchell, C. (2020b). Price Rate Of Change Indicator—ROC. Investopedia. Retrieved from ​ ​ https://www.investopedia.com/terms/p/pricerateofchange.asp

Principal Financial Staff. (2020). How investing works. Principal. Retrieved from ​ ​ https://www.principal.com/individuals/explore-life-money/how-investing-works

Prorsi Staff. (2018). Which technical indicator is the most accurate? Prorsi. Retrieved from ​ ​ ​ https://prorsi.com/accurate-technical-indicator/

Segal, T. (2020). Fundamental Analysis. Investopedia. Retrieved from ​ ​ ​ ​ https://www.investopedia.com/terms/f/fundamentalanalysis.asp

Smith, L. (2020). How to Predict Where the Market Will Open. Investopedia. Retrieved ​ ​ from

https://www.investopedia.com/articles/active-trading/081313/ways-gauge-market-open-

direction.asp