Predicting Apple Stock Prices Using Sentiment and Technical Analysis

Verified

Added on  2022/12/23

|13
|1598
|1
Project
AI Summary
This project undertakes a comprehensive analysis of Apple's stock prices, leveraging both technical and sentiment data. The study begins by scraping and analyzing tweets related to Apple to gauge public sentiment, which is then correlated with technical indicators such as moving averages, exponential smoothing, and money flow indices. The analysis focuses on the 2018-2019 period. Forecasting methods like technical analysis algorithms and OLS regression are employed to predict stock prices. The findings reveal a weak positive correlation between polarity and sentiment with stock prices. Moreover, the sentiment variable demonstrates statistical significance in predicting stock prices. The project also examines the impact of cumulative and daily returns, concluding that cumulative returns, rather than daily returns, are a key factor in influencing stock prices. Overall, the project provides insights into how sentiment and technical indicators can be used to predict stock movements, and highlights the importance of cumulative returns in stock price analysis.
Document Page
1
Introduction
It is with no doubt that social media which has grown to be a landmark of the evolution in
communication of the 21st century and communication media in general, has become an integral
part of the everyday life of almost any person. For instance, a Facebook post by a banker in some
place in South Africa can be instantly accessed from anywhere in the world that has an internet
connection. Generally, social media opinions by persons spread in astonishingly high and so are
news components in the digital world of today. The unrestricted freedom that has been brought
about by the adoption of digital revolution in communication begs the question as to what are the
effects of the freedom of expression that underlay the whole idea of social media (Ranco,
Caldarelli, Aleksovski, Grčar, & Mozetič, 2015).
Human are sentimental creatures, well at least many of them. As such an idea or just a statement
made by an individual is most likely going to influence a reaction of another individual regarding
the topic in focus (QuantPedia, 2017). Statistical studies on the effect of consumer reviews on
the willingness of other buyers to purchase an item indicate that, “…consumers tend to trust the
thoughts of other consumers more than they do trust the word of producers concerning the
product” (Render, 2018). The case of consumer reviews has been applied to stock purchasing
also where information influences stock investment (Jegadeesh & Titman, 2001). As to who
bears the brute part of negative or reaps the positive outcomes of sentiments expressed all over
media remains a key question.
Information and stock
Stock and information are often correlated in which new information is posited to affect stock
prices. An argument that,“… a basic tenet of financial economics is that asset prices change in
tabler-icon-diamond-filled.svg

Secure Best Marks with AI Grader

Need help grading? Try our AI Grader for instant feedback on your assignments.
Document Page
2
response to unexpected fundamental information” (Boudoukh, Feldman, Kogan, & Richardson,
2013) sums it perfectly well and forms the basis of this papers objective.
The objective
Information media forms a medium for fast information channeling and access. It is therefore a
basic supposition of this paper that the more access to information there is, the more volatile the
stock prices of a firm are likely to be. In this case the analysis will focus on technical and
sentimental analysis to predict stock of the tech giant Apple.
Basics
There are lots of sources of information out there, the main task underlies as to how to obtain the
relevant information and from credible. For this task, we scrape tweets relating to the apple firm
for the closing period of 2018 to 2019 and analyze different technical information such as stock
forecasting using moving average and exponential smoothing then use the information to
compare how the predicted stock is predicted by sentiment confidence if at all sentiments predict
stock prices. This study uses forecasting methods such as the “TA (Technical analysis
algorithms” and predictive algorithms i.e. OLS regression in machine learning to address the
paper’s objective.
Technical analysis and prediction
In this section we analyze the performance of Apple’s stock using the “Technical analysis”
package in python. The main focus will be on: forecasting the stock prices which will show if
prices will go up or down in the future, examining the trend to understand the volume and price
trend of the stock, momentum to understand the buying pressure where the prices rise if there is
buying pressure and falls when there is selling pressure, daily returns, money flow and KST
Document Page
3
Oscillator (KST), Chaikin Money Flow to measure the amount of Money Flow Volume over the
trading period.
The graphs below show basic trends of different stock performance.
Opening stock prices
Document Page
4
After conducting a forecasting of Apple’s stock prices using both moving averages and
exponential smoothening in “ta” library we note that the stock prices show an upward trend at
the start of January but is forecasted to drop sharply after the close of march 2019.
tabler-icon-diamond-filled.svg

Secure Best Marks with AI Grader

Need help grading? Try our AI Grader for instant feedback on your assignments.
Document Page
5
The flow of money index shows an increment trend from mid -February but drops at the start of
March and remains constant at the close of March 2019.
Document Page
6
Correlation
Polarity has a weak positive correlation with sentiment, daily returns, opening stock price and the
predicted price. On the other hand, the sentiment has a weak negative correlation with high stock
price, and the predicted stock prices.
Predictive power of Sentiment
Document Page
7
The sentiment scores over the 2018-2019 trading period given in the data vary in percentage
where 0 represents zero sentiment and 1 representing highly sentimental opinions of the firm by
the public.
We analyze the effect of this sentiments on both the predicted stock price and the stock volumes.
tabler-icon-diamond-filled.svg

Paraphrase This Document

Need a fresh take? Get an instant paraphrase of this document with our AI Paraphraser
Document Page
8
Prediction of stock price using sentiment
Sentiment
First we run a regression model which is adopted for predictive analysis in this study. We try and
examine whether sentiment can be used to predict the opening price of stock.
Document Page
9
Next we fit a model taking polarity as the x variable the stock opening price as the response
variable.
Document Page
10
Note that in the above two tables we are presented with statistics such as the p-value of the F-
statistic as well as that of the t-statistic. The model containing sentiment has an F-statistic of
57.33 and a corresponding p-value of approximately 0.000 implying the model is significant at
0.05 level of significance. In addition, the p-value of the t-test which analyzes the significance of
the sentiment variable to be used in predicting stock price is 0.005 which is less than 0.05, as
such we can conclude that sentiment does indeed predict stock prices.
Shifting our focus back to the model with “Polarity” variable as the explanatory, we note that the
p-value of the F-statistic is 0.233 thus the model is not a good fit at 95% confidence interval. In
addition to this the p-value of the t-test for polarity is also 0.233 which is also not significant. We
can therefore conclude that polarity does not predict stock prices for the apple company.
Prediction of stock using technical information
In this subsection we examine how cumulative returns and the expected daily returns affect the
prices of stock. Our argument is based on a study by Pettinger (2017) who argues that, “..the
main effect underlying dropping of the stock price is that the firm will almost always reduce the
amount of shares hence fail to make shares” (Pettinger, 2017).
tabler-icon-diamond-filled.svg

Secure Best Marks with AI Grader

Need help grading? Try our AI Grader for instant feedback on your assignments.
Document Page
11
Examining the p-value of both the daily returns and cumulative returns, it is evident that
cumulative returns do predict the stock price while daily returns do not predict the stock price as
indicated by their respective p-values of 0.000 and 0.258.
Many factors influence stock prices which is part of the explanation of the high volatility of
stocks. In this case we realize that sentiment and cumulative returns as opposed to daily returns
and polarity are among the key factors that influence stock prices.
The paper’s results can be proofed by a simple argument. For instance, it is not always that
investors sell their shares by just a single drop of the returns in a day or want to buy shares if a
stock performs well in one day but when the winnings or losses become cumulative over time
then the investors might consider selling of losing shares or buying of winning shares. In such a
situation there might be cases in which there are more shares in supply than the buyers if the
Document Page
12
investors begin selling their stock hence leading to low prices due to the demand and supply
effect or where there is more demand than supply hence prices go up.
Document Page
13
References
Boudoukh, J., Feldman, R., Kogan, S., & Richardson, M. (2013, January 15). Which News
Moves Stock Prices? A Textual Analysis. NBER Working Paper No. 18725, pp. 56-92.
Jegadeesh, N., & Titman, S. (2001, April). Profitability of Momentum Strategies: An Evaluation
of Alternative Explanations. The journal of Finance, 56(2), 699-720.
Pettinger, T. (2017, August 18). How do share prices affect firms? Retrieved from Economics:
https://www.economicshelp.org/blog/3137/economics/how-do-share-prices-affect-firms/
QuantPedia. (2017, January 12). Momentum Factor Effect in Stocks. Real-time implementation
by QuantConnect, pp. 1-7.
Ranco, G., Caldarelli, G., Aleksovski, D., Grčar, M., & Mozetič, I. (2015). The Effects of
Twitter Sentiment on Stock Price Returns. PLoS ONE, 10(9), 39-54.
doi:10.1371/journal.pone.0138441
Render, J. (2018, June 17). Why consumers trust each other more than brands. Retrieved from
Consumer Affairs: https://blog.consumeraffairs.com/why-consumers-trust-each-other-
more-than-brands-908a440ed8d7
chevron_up_icon
1 out of 13
circle_padding
hide_on_mobile
zoom_out_icon
logo.png

Your All-in-One AI-Powered Toolkit for Academic Success.

Available 24*7 on WhatsApp / Email

[object Object]