Introduction
The purpose of this project was to analyze stock market trends based on data that was provided. Many people depend on the stock market for a multitude of reasons. Whether that be for personal gain or wagering their retirement in order to increase wealth. The stock market can be a dangerous place but can also be a very profitable place. Analyzing the stock market is the only way to gain a better since of knowledge of it. It is not something you can just put money in and expect money to come out. If you do not do you research there is a very high possibility you could be walking away with nothing or less than what you started with.
Problem Statement
When investing in the stock market it is important to know where to put your money. The task assigned was to have each team member code a program, using MATLAB, assessing various well-known companies’ stock over a several year period. This exercise allows investors to make educated decisions when investing in stocks.
Background Research
Stock Market Background
In the 1500s the first official stock market was created. Belgium was the birthplace of the stock trading even though it began with no real shares being traded. It worked with affairs of government, individual debt, and businesses. The East India Company became the first publicly traded company to reduce the risk of risk. Investors split up their money so there was less likelihood of losing everything on one investment. History has made its mark on changing the way humankind uses the stock market today vastly compared to how it was originally designed. Its fundamentals are the same, but the scale is exponentially greater.
In the early days the lines of what was right, and wrongs of the stock markets were blurred. Companies took advantage of the system and poured in investment money before the investors had any real return. In 1825, the government of England banned the issuing of sharing stocks (bebusinessed) because there was no clear idea of fake companies from legitimate ones. This created a break in the bubble and slowed economic growth. This dip in European economic growth allowed for the opportunity to have other countries come in and take the power. Although, not the first or only stock exchange in the united states at the time, the New York stock exchange took advantage of this open gate and ran with it. Not having any other competitors standing in its way the NYSE quickly shot to the top of the power chain when it came to economic trading systems. This boosted American economics and comradery amongst the country.
Today, the stock market is a way for companies to sell and share part ownership know as stocks. Almost all countries have their own functioning stock markets. Countries that are experiencing generalized lows, such as Iraq, can still have a functioning stock market today. Iraq was one of the only stock markets not to be affected by the economic crisis of 2008 (bebusinessed).
Investors can carefully spread out their risk into many different aspects of business through stock markets. The stock market is seen as being part of the glue that holds many economies together. It can have a tremendous effect of the lives of people, counties, and economies.
Current Stock-Related Software
Current Stock-Related software is vital to anyone who plans to invest into the stock market. The different types of software were created to make trading in the stock market much simpler and easier so anyone could invest by themselves. There are several different types of software marketed towards consumers and it can be very intimidating when trying to choose the specific software that is right for you. Some of the different types of software include TradingView, MetaStock, TC2000, etc.. Each of the software’s listed above have their own perks, but their end goal as a trading software is to try and help you make the most money possible.
TradingView is great for beginners, it is easy to use and very intuitive. It makes stock trading as simple as possible while maintaining a level sophistication. According to TradingView’s website, you can “Get real-time information and market insights” which is great when trying to invest wisely (“How It Works”). Also TradingView boast about its ability to create and maintain a community when it comes to trading. For instance, they have an excerpt on their website that reads “Trading the financial markets is lonely. TradingView – lets you discover investment ideas and showcase your talents to a large and active community of traders. Freely discuss, share and learn with thousands of market participants using TradingView” (“How It Works”). They also display statistics on their website that consist of how many investor they have using their software and charts created based on stock market data and the community predictions.
MetaStock is another type of software you can purchase for stock market trading. It is marketed towards all skill levels of trading in the stock market. This software has been around 1988 according to MetaStock’s website (“MetaStock-A Global Leader..”). MetaStock’s website makes claims such as “MetaStock has been providing award-winning charting and analysis tools for the self-directed trader for over 30 years. Capitalizing on technical analysis, our line of trading software and market data are designed for active traders of all levels so they can backtest, scan and analyze the markets with confidence” and “The result is buy and sell signals you can count on” (“MetaStock-A Global Leader..”). MetaStock scored a 10/10 on the 2018 review of stock market-related software with the article boasting about how this software covers all types of stocks.
The third and final software is TC2000. TC2000 is an “online software company that focuses on providing top-notch analysis tools for stock and option traders with their main services including charting, scanning and trading through an affiliated broker” (“TC2000 Broker Review”). This software is different from the others due to the fact that in this software, you are going through an affiliated Broker within this software whereas the other two mentioned are all completed by yourself with no help from an affiliated Broker. One cool feature this software offers is a stock market simulator. This is where they set up a scenario with fake money in order to help you navigate the stock market better.
Each software listed has its benefits. Whether it be from a simulator integrated into the software to give you practice or complete freedom to navigate the stock market without any input from anyone. While researching for different software’s, I noticed one main theme for choosing the correct software for yourself and that was to realize what is right for you and what will work best for you. If you like more guidance I would recommend TC2000 but if you like freedom, I would recommend MetaStock. Stock software can be useful but make sure you first conduct research to see which is right for you.
Historical Stock Market Trends
The stock market has been on a steady rise since its creation in 1817. Our country has steadily grown over the last 200 years causing stocks to rise. There are a lot of things that will affect the stock market in the short run, but as long as our country grows economically so will our stock market. It has been known to dip down, but always seems to recover. Things like war can cause a big jump or fall in it, but it always seems to stay on a steady increase in the long run. There was a big crash in early 2009 under the Obama administration. It had a lot to do with the housing industry. It was caused by an over-valued market and cause many banks to foreclose on houses. The natural fluctuation of the stock market is caused my supply and demand. If there is a greater number of sellers, buyers bid up prices causing stocks to go up. On the other hand of there are more sellers than buyers than sellers lower their prices to entice buying. This causes a fluctuation in stock prices.
Another trend seen in the stock market is the bull and bear trends. A bull market is where the market rises about 160%, and during a bear period typically falls about 43%. Bull markets last approx. 3.5 years while bear markets usually last only 1.5 years. This pattern has been seen time and time again. It can be seen on two separate occasions in figure 1.
Figure 1
Stock market prediction
Stock market prediction is the act of trying to determine the future value of a company stock or other financial instrument traded on an exchange. The successful prediction of a stock's future price could yield significant profit. The efficient-market hypothesis suggests that stock prices reflect all currently available information and any price changes that are not based on newly revealed information thus are inherently unpredictable. Others disagree and those with this viewpoint possess myriad methods and technologies which purportedly allow them to gain future price information.
PREDICTION METHODS
Prediction methodologies fall into three broad categories which can (and often do) overlap. They are fundamental analysis, technical analysis (charting) and technological methods.
Fundamental analysis
Fundamental Analysts are concerned with the company that underlies the stock itself. They evaluate a company's past performance as well as the credibility of its accounts. Many performance ratios are created that aid the fundamental analyst with assessing the validity of a stock, such as the P/E ratio. Warren Buffet is perhaps the most famous of all Fundamental Analysts.
Fundamental analysis is built on the belief that human society needs capital to make progress and if a company operates well, it should be rewarded with additional capital and result in a surge in stock price. Fundamental analysis is widely used by fund managers as it is the most reasonable, objective and made from publicly available information like financial statement analysis.
Another meaning of fundamental analysis is beyond bottom-up company analysis, it refers to top-down analysis from first analyzing the global economy, followed by country analysis and then sector analysis, and finally the company level analysis.
2. Technical analysis
Technical analysts or chartists are not concerned with any of the company's fundamentals. They seek to determine the future price of a stock based solely on the (potential) trends of the past price (a form of time series analysis). Numerous patterns are employed such as the head and shoulders or cup and saucer. Alongside the patterns, techniques are used such as the exponential moving average (EMA). Candle stick patterns, believed to have been first developed by Japanese rice merchants, are nowadays widely used by technical analysts.
3. Machine learning
With the advent of the digital computer, stock market prediction has since moved into the technological realm. The most prominent technique involves the use of artificial neural networks (ANNs) and Genetic Algorithms. Scholars found bacterial chemotaxis optimization method may perform better than GA. ANNs can be thought of as mathematical function approximators. The most common form of ANN in use for stock market prediction is the feed forward network utilizing the backward propagation of errors algorithm to update the network weights. These networks are commonly referred to as Backpropagation network. Another form of ANN that is more appropriate for stock prediction is the time recurrent neural network (RNN) or time delay neural network (TDNN). Examples of RNN and TDNN are the Elman, Jordan, and Elman-Jordan networks. (See the Elman And Jordan Networks)..
For stock prediction with ANNs, there are usually two approaches taken for forecasting different time horizons: independent and joint. The independent approach employs a single ANN for each time horizon, for example, 1-day, 2-day, or 5-day. The advantage of this approach is that network forecasting error for one horizon won't impact the error for another horizon—since each time horizon is typically a unique problem. The joint approach, however, incorporates multiple time horizons together so that they are determined simultaneously. In this approach, forecasting error for one-time horizon may share its error with that of another horizon, which can decrease performance. There are also more parameters required for a joint model, which increases the risk of overfitting.
Of late, the majority of academic research groups studying ANNs for stock forecasting seem to be using an ensemble of independent ANNs methods more frequently, with greater success. An ensemble of ANNs would use low price and time lags to predict future lows, while another network would use lagged highs to predict future highs. The predicted low and high predictions are then used to form stop prices for buying or selling. Outputs from the individual "low" and "high" networks can also be input into a final network that would also incorporate volume, intermarket data or statistical summaries of prices, leading to a final ensemble output that would trigger buying, selling, or market directional change. A major finding with ANNs and stock prediction is that a classification approach (vs. function approximation) using outputs in the form of buy(y=+1) and sell(y=-1) results in better predictive reliability than a quantitative output such as low or high price. Since NNs require training and can have a large parameter space; it is useful to optimize the network for optimal predictive ability.
Methodology
Problem 1
To start off with all of that data from the excel sheet had to be called to MATLAB to create the vector for each data set. For each spreadsheet all the data was called from day, open, high, low, close, and adj close. This created six vectors per spreadsheet. A semicolon was added after call of these commands to suppress the vectors from the command window.
Problem 2
For the second problem a variable name was assigned to each vector while being care to name it appropriately. This was done by putting the variable name and setting it equal to the vector needed. This was done on the same line.
Problem 3
Next 4 plots were made to compare the open and close of two stocks on the same graph. To do so the plot function was used. To get this working correctly the line started with the word plot which was the followed by a parentheses. After that the code was entered as the x variable followed by a comma and the y variable of the first stock’s open or close values. Then, still inside the parentheses the same was repeated for the remaining open or closed values. This would then be followed by the same thing for the other stock still inside the same parentheses, and after all variables are in place you place a closing parentheses. To get the legend a legend function was used while making sure to put the legend titles in the same order of the plot function. On a new line an xlabel and a ylabel function were used. The xlabel function was “xlabel('Days [Days]')” and the y function was “ylabel('Stock [Dollars]')” making the x axis days, and the y axis stock prices. A title function was then added with the title being something related the stocks of that particular graph. The final step to this problem was that the code figure was added at the end to signify the end a new plot function began. This was repeated for the remaining 3 plots. After all of this is completed your plot will look like figure 2.
Figure 2
Problem 4
To find the max values for problem 4 the max command was used. The max values for the open, close, high, and low were found. To do this a simple max command was used for each vector used. This found the max values for all of the given stock sections. To find the day a find function was used. The find command was used. In side of the find command the max value variable name was set equal to the matching vector with it coming out looking like “Day_Max_Open_Lululemon=find(Open_(company name) ==Max_Open__(company name))”. This found the day that the max occurred. This was done for every stock section for all of the stocks making 8 lines of code in total per stock. After that is all done the table made using the fprintf command. The first line of the code for the table was made to get the headings and was in the following format “fprintf(' | Company | Day | Max Open | Day | Max High | Day | Max Close | Day | Max Low |n').” Every line after that was in the same format, but the actual company name was put in and the rest of the headings were changed to %.f. Also at the end before the parenthesis the variables names for the numbers needs in the order in which they appear right to left separated by commas. This was then repeated for each company and their respective values. This should look something like figure 3.
Figure 3
Problem 5
To get the max open and the max closed value for each respective year the max function was used again, but this time it was only the max of a certain amount of the vector. For year three day 479 to 739 was used. Year four was day 739 to 999, and year 5 was day 999 to 1259. This was done for every stock open, and every stock closed values. It was then the data was then put in a fprintf table to the previous one, but this time the values were headed by years.
Problem 6
Then it was needed to display the average high and low for all of the stocks assigned. To do so a mean function was used of the high and low of each stock. This gave the average high and low for each high and low stock. Then that information was put into in an fprintf function. It was put in the following form “fprintf('For (Company Name) the average high was $%.2f and the average low was $%.2f n',Average_High_(Company Name),Average_Low_(Company Name))”
Problem 7
Problem 7 was to plot the high stock versus the day. For this a plot function was used. This one needed the high stock of each company as the y variable. So, to do so the x variable was the days. So for the plot function they were put in the order of day of day of company followed by the high. This was done inside the function for all separated by commas. Then on the next line the xlabel command to get the x axis label followed by the ylabel command to get the y axis label. The legend command was then put on the next line. It was very important to keep the legend names in the same order as they appeared in the plot function or the legends would represent the wrong data. After that the title command was used to title the graph as “Stock High VS Days”
Problem 8
Problem 8 asked to find the standard deviation of each company close stock and display it in a table. To find the standard deviation a std command was used by just placing the close vector of each company inside. Then a simple fprint f table was used in the same fashion as the last table. This time the headings were just company and STD. When finished the table would only have two columns as seen in figure 4.
Figure 4
Problem 9
For problem 8 it was asked to pick the best stock to invest in and why. Cracker Barrel was chosen and put into an fprintf statement with it reasoning.
Problem 10
For the final problem it was asked to plot the close versus the day, and to label the start of the year on the plot using text for the stock chosen as the best. It was plotted as the others were plotted with the plot function, xlabel, ylabel. legend, and title commands, but this time a text command was used after. Inside the command it was the day and the close value of the given day separated by commas. Then another comma was added then the label was put in apostrophes. This was done for day 1, 260, 520, 780, and 1040. They were labeled in chronological order with day having year one and day 260 having year two, and so on.
Results
The data collected was graded on the size of the standard deviation that each company’s stock yielded. PepsiCo for pair one, Ford for pair two, Cracker barrel for pair three, and Tesla for stock four were found to be the smartest investment decisions due to their small standard deviation.
Discussion
The Open/Close graphs for the provided stocks represent the opening the opening and close prices of a stock during a certain amount of time. The opening price is the price at the beginning of the day while the closing price is the price at the end of the day. These plots can be used to identify which stock has the highest opening and closing prices. The different maximum values table provides the day and the value when each characteristic of a stock is at its peak. With this table, it’s easy to identify when it might be good to make an investment to get the maximum profit. The last three years table provides the evolution of the maximum values for the last three years for a better estimation of the future evolution of the maximum prices when an investment is to be made. The average High and Low values found provide an overview of the mean of the maximum and minimum prices for each company for five years, this in order to let an investor know the range of the price of a stock during a five-year period. The standard deviation of the close value for each company is its volatility; a good company is one presenting a low standard deviation. Pepsi was the chosen as the best company to invest in because based on the it presents a moderate standard deviation with a max high of $122 and high opening and close prices.
Conclusion
In conclusion, the stock market refers to the collection of markets and exchanges where the issuing and trading of equities or stocks of publicly held companies, bonds, and other classes of securities take place. The purpose of this project was to be able to recommend the best stock market to invest in by understanding the fluctuations which occur over periods of time and what events can impact the market’s value before investing in a stock market. To do so, each team member analyzed four different pairs of stocks based on their characteristics such as high, low, open, close and adj. close. Based on the information provided, each of them was able to plot Close Vs Day, Open Vs Day, High Vs Day for his assigned pairs and use these graphs, the maximum values and the different standard deviations to determine which stock he would recommend. They ended up having different results depending on the pairs assigned to them. For the first four pairs, the best stock was Pepsi because it had a moderate standard deviation with a max high of $122. For the next four, Cracker Barrel was the best because of the low standard deviation. For the following four, the best stock was Ford and for the last four the best stock was Tesla. With the data collected, the best stocks to invest in would be PepsiCo.
Future Work
By completing this project, one would be able to use data to provide one’s own recommendations about an investment in a stock. But is it enough to be confident that the investor will make profit when investing in the recommended stock? What about a new stock more attractive coming into the market? How can one avoid urging someone to invest in a stock where he might lose his money? Stock Market Prediction is essential in helping improve analysis of the stock market to avoid being surprised and penalized by any unexpected change. Our future work, in order to improve the reliability of our recommendation, should focus on the different ways to predict the evolution of a stock market.