Trump’s Twitter and the Stock Market

Penn Data Project
6 min readJan 8, 2020

--

A Data Oriented Analysis

Love him or hate him, Trump’s Twitter is probably the most influential social media account in the world. During the 2016 election, Donald Trump strategically leveraged his Twitter account to increase popular support, and he sure didn’t stop Tweeting after getting into the white house. Over the 33+ months of the Trump white house, he has sent over 11,000 tweets. Tweets are now an essential part of Trump’s communication to the world. As Trump advisor Kellyanne Conway so eloquently puts it:

“He needs to tweet like we need to eat.”

The reason why Trump’s Twitter in particular is so interesting is because of its unparalleled clout. Sure, Kanye may have more followers, but Kanye can’t swing the entire S&P 500 in under 140 characters. Singular tweets such as the one pictured below have caused measurable swings across the US stock market. Considering the position of the US as the world’s foremost economic power, that is no small feat.

So that brings us to the question of how much Trump tweets actually affect the stock market. People have done similar analyses in the past. For example, this Barron’s article analyzes correlations between Trump’s overall tweet frequency and market movements. I think the problem with this is that Trump tweets a LOT of random stuff that has not a damn thing to do with the market. Like, how are investors supposed to react to this?

Realistically speaking, a lot of those tweets are going to be white noise that shouldn’t have an impact either way on the market. The relevant tweets are going to be around topics such as the China trade deal, possible US military action, and federal reserve interest rates. The reason why the trade deal and federal reserve rates were chosen is because people who actually know what they are doing tend to pay attention to these indicators, and the reason why military interventions is also relevant is because those have a history of quantifiably changing the market.

So those are the ones we will attempt to examine. Between 2018–2019, Trump tweeted around 6900 times (including retweets). This data was obtained from The Trump Twitter archive. To represent the US stock market as a whole, we chose to use Yahoo’s free yearly data on the S&P 500 (SPY), a collection of 505 stocks of major companies on the US market.

S&P 500 Performance (2019)

The first test we will conduct is to see correlations between tweet frequencies and deltas. “Deltas” refers to the day to day change in closing values for the SPY and shows how much the market has moved in a particular day. To measure the frequency of tweets about China for instance, we categorize all of the tweets by date. For all tweets on a particular day, we measure how many of the tweets had keywords such as “china”, “tariff”, “trade”, “xi”, “tariffs”, “transactions”, “intellectual”, “deficit”, and “deal” in them. To be completely honest, I don’t have a scientific way of choosing these keywords. It’s pretty much whatever I personally associate with the China trade talks. Afterwards, we plot all of our available data points in a scatter plot format, such as the one shown below. Only days in which China is mentioned are plotted on the graph.

The x axis measures the Delta, or how much the SPY dropped or increased on a particular day, and the Y axis measures the number of tweets about the Chinese or trade on the same day. The Pearson’s correlation coefficient, which measures the strength of a relationship between the 2 data sets, was -0.128. This indicates that there is a weak negative correlation between the frequency of Trump’s China tweets and market movement. When Trump tweets a lot about China, the market moves in slightly negative fashion.

For tweets regarding the federal reserve, the list of keywords included “rates”, “rate”, “inflation”, “powell”, “fed”, “feds”, “federal”, “reserve”, “hike”, “devaluation”, “quantitative”, “easing”, “cut”, “stimulus”, and “recession”. The Pearson correlation coefficient is 0.075, indicating a slight positive relationship between federal reserve related tweets and SPY performance.

For tweets regarding military intervention, the keywords list included “war”, “iran”, “military”, “conflict”, “afghanistan”, “defense”, “north korea”, “wars”, “combat”, “ceasefire”, “battle”, “battles”, “soldier”, “soldiers”, “syria”, “yemen”, “iraq”, “isis”, “troops”, “fighting”, “combat”, “army”, “navy”, “deploy”, “deployment”, and “nuclear”. The Pearson correlation coefficient was -0.058, indicating a very weak negative correlation between tweets mentioning the military and SPY performance.

Why are the correlations so weak? There are a few possible explanations. On one hand, the market has been desensitized to Trump’s tweets due to their frequency. If the market shifted significantly for every one of the 6900 tweets in the past year, the market would be more volatile than a college student on an acid trip. SPY is more likely to respond to a few select tweets announcing major policy while being unaffected by most tweets, thus accounting for the weak correlation. Second, it is very difficult to filter out tweets that don’t matter using our methodology. For example, a tweet that states “we support our troops fighting in Afghanistan” is sure to have less of a market impact than a tweet that states “it’s time for war on Iran”, but they are both counted as valid tweets about war.

Here’s another metric to look at: the above graph shows the average SPY delta/change on days in which Trump tweets about the aforementioned topics as opposed to the days in which he doesn’t. The results show that on average, the market does significantly worse on days when trump tweets about China and military intervention, but not so much of a difference when Trump tweets about the Federal Reserve. This is also an imperfect metric due to outliers and the previously discussed problems with the methodology, but there appears to be a clear relationship nonetheless.

Finally, the last thing that I’d like to take a look at is when Trump tweets about these topics.

Looking at the China graph, we can see that the most major escalation of the tweets was around the May-June 2019 period. This makes sense, since this was during a significant escalation of the trade war during which China imposed tariffs on 60 billion dollars of US goods, with the US threatening retaliation in turn. In terms of the federal reserve graph, we can see that the biggest spike was around the August-September 2019 period. According to a September 2019 Politico article, Trump, at the time, was putting intense public pressure on Jerome Powell to further cut interest rates, which Powell eventually acquiesced to. The spike is a reflection of that pressure. Finally, looking at the war tweets graph, it looks like Trump’s affinity for military action is pretty much continuous year round.

As a first foray into Python data visualization and analysis as a beginner, this was a pretty fun project to do. I recognize that there pretty significant ways in which the methodology could be improved. For one, if tweets could be classified into specific categories such as “increase likelihood of trade deal” and “decrease likelihood of trade deal”, we would probably see stronger positive or negative correlations. For another, if we had access to SPY data on a minute to minute basis, we would be able to measure more granular market changes. But alas, here is where we will end our analysis. If you have any suggestions for how to improve our methods or ideas, let us know.

--

--

Penn Data Project
0 Followers

Producing relevant data analysis for the student body of the University of Pennsylvania