Elon Musk's statements move Tesla's stock price


LETS GET STARTED

Introduction


Elon Musk is undeniably one of the most influential figures in the world nowadays. In addition to being the richest person on the planet, he has been selected to be Time Magazine’s Person of the Year for 2021.
Being Tesla’s face figure, he is reputed for his several achievements at the industry level. The company has been a key player in triggering the automobile industry’s shift towards electric cars. Being a pioneer in this field, the company’s worth has skyrocketed in the last few years. With all of that, Musk has obtained a heavy weight in the domain of finance as well. For instance, the cryptocurrency market always gets shaken by his tweets recently. His social networks have also become a consequent marketing platform for his companies.
In the shadow of this observation, the aim of this study will be to analyse the influence of Elon Musk’s quotes on Tesla’s stock price shifts by seeking correlations. We will also try to build a prediction model which forecasts the daily stock return.


This blog begins by analysing Tesla's stock price from 2015 until 2020, to see if we can gain insight into its future changes. Then, we inspect Elon Musk's quotations using sentiment analysis. Afterwads, based on our analyses, we try to observe a relationships between Elon Musk's quotes and the returns of Tesla's stock price and we will provide some predictive models that could help us make predictions.
Finally,we will present the main conclusions in addition to the limitions of the study.

Motivation


Tesla stock (TSLA) has always been a volatile story, the company's economics are very challenging and there is no telling what Musk will say or do at any given time. This makes Tesla's stock a big attraction for share sellers.

In this study, our main hypothesis is that Elon Musk has an influence on Tesla's stock market. First let's take a look at the major swings Tesla's stock price experienced, two periods pop out: June 2016, August 2018. Then we explore the quotations of Elon Musk during these periods. From the quotations in the dataset we discovered that the 30th of june 2016, tesla driver dies in first fatal crash while using autopilot mode. The 7th of august 2018, Elon Musk tweeted he had "funding secured" to take the company private at 420$, then on the 27 September 2018, Elon Musk settled with the SEC over allegations that he had mislead investors with his tweet where he announced the potential privatization of the company. Adding even more fuel to the stock, Musk emailed the employees saying Tesla is "very close to achieving profitability".

All these events may explain the sudden change in Tesla's stock price. This make us think about the potential possibility of building a model to predict Tesla's stock using the quotations of Elon Musk, through this blog we will determine to which extent our idea is realistic.



Main Analysis



To get insight of the common topics Elon Musk talk about we decided to find the most frequent words in our dataset, note that more the word is frequent in the dataset more its size in the image is big. Notice that the words tesla and car are the most common words, which is useful for our study since we will only use the quotations that contain the words car, tesla and vehicule.


Sentiment Analysis


To be able to get the most out of our data we need to perform sentiment analysis, It’s a very powerful natural language processing tool that we use in our case as the main feature that relates Musk’s quotes to Tesla’s stock price. In this study, to get an accurate sentiment analysis we will be using two pretrained models : Vader and TextBlob.
Vader and TextBlob mainly output a continuous value varying between -1 and 1, the first being the extreme negative sentiment and the second is the extreme positive one. TextBlob comes with an additional feature : Subjectivity. Before running them on the quotes, we decide on the polarity (positive or negative) based on fixed thresholds.
The bellow pie charts show the results obtained when running Vader and Blob:

To compare the performance of the two models we visualize the result of the both on the same plot:


As we can see from the plot, the outputs of the two algorithms are pretty similar. It seems that the difference between them is just a relatively small offset. We thus decided to continue to work with the both of them using the adequate offset for each.


TF-IDF


In order to add some more features into our study, we also perform TF-IDF weighting on our quotes.
This method was proven to be efficient as it significantly boosted the built models performance both for correlation seeking and prediction.


Correlation between polarity score and stock returns


Here we examine if there is any predictive relationship between the sentiment analysis score and the stock returns.


From this plot, it seems that there's a slight correlation between the stock retuns and the sentiment analysis outputs. We will see later how will this impact the results.

Predictive Models


In this part of the study, we try several machine learning classification and regression methods to try to predict the stock returns/shifts of Tesla. To maximize the performance of our models, the first thing to do was to build more features based on some common methods. Thus, in addition to the TF-IDF matrix and to the sentiment analysis outputs, we one-hot encode them.
The first step was to try a basic linear regression model, which performed poorly. After that, a gradient boosting regressor was implemented using the same features and outcomes, which performed better but not good enough. Based on the previous observation, a hyperparameter tuning was used to get the best possible combination of the number of estimators and the learning rate for the gradient boosting regressor which improved the prediction score a lot. We also tried some classifiers in order to predict the daily stock shift (categorical value ,up or down).
The used classifiers were SVM and MLPClassifier: Unfortunately, both of them performed very poorly.