NYC Data Science Academy| Blog
Bootcamps
Lifetime Job Support Available Financing Available
Bootcamps
Data Science with Machine Learning Flagship 🏆 Data Analytics Bootcamp Artificial Intelligence Bootcamp New Release 🎉
Free Lesson
Intro to Data Science New Release 🎉
Find Inspiration
Find Alumni with Similar Background
Job Outlook
Occupational Outlook Graduate Outcomes Must See 🔥
Alumni
Success Stories Testimonials Alumni Directory Alumni Exclusive Study Program
Courses
View Bundled Courses
Financing Available
Bootcamp Prep Popular 🔥 Data Science Mastery Data Science Launchpad with Python View AI Courses Generative AI for Everyone New 🎉 Generative AI for Finance New 🎉 Generative AI for Marketing New 🎉
Bundle Up
Learn More and Save More
Combination of data science courses.
View Data Science Courses
Beginner
Introductory Python
Intermediate
Data Science Python: Data Analysis and Visualization Popular 🔥 Data Science R: Data Analysis and Visualization
Advanced
Data Science Python: Machine Learning Popular 🔥 Data Science R: Machine Learning Designing and Implementing Production MLOps New 🎉 Natural Language Processing for Production (NLP) New 🎉
Find Inspiration
Get Course Recommendation Must Try 💎 An Ultimate Guide to Become a Data Scientist
For Companies
For Companies
Corporate Offerings Hiring Partners Candidate Portfolio Hire Our Graduates
Students Work
Students Work
All Posts Capstone Data Visualization Machine Learning Python Projects R Projects
Tutorials
About
About
About Us Accreditation Contact Us Join Us FAQ Webinars Subscription An Ultimate Guide to
Become a Data Scientist
    Login
NYC Data Science Acedemy
Bootcamps
Courses
Students Work
About
Bootcamps
Bootcamps
Data Science with Machine Learning Flagship
Data Analytics Bootcamp
Artificial Intelligence Bootcamp New Release 🎉
Free Lessons
Intro to Data Science New Release 🎉
Find Inspiration
Find Alumni with Similar Background
Job Outlook
Occupational Outlook
Graduate Outcomes Must See 🔥
Alumni
Success Stories
Testimonials
Alumni Directory
Alumni Exclusive Study Program
Courses
Bundles
financing available
View All Bundles
Bootcamp Prep
Data Science Mastery
Data Science Launchpad with Python NEW!
View AI Courses
Generative AI for Everyone
Generative AI for Finance
Generative AI for Marketing
View Data Science Courses
View All Professional Development Courses
Beginner
Introductory Python
Intermediate
Python: Data Analysis and Visualization
R: Data Analysis and Visualization
Advanced
Python: Machine Learning
R: Machine Learning
Designing and Implementing Production MLOps
Natural Language Processing for Production (NLP)
For Companies
Corporate Offerings
Hiring Partners
Candidate Portfolio
Hire Our Graduates
Students Work
All Posts
Capstone
Data Visualization
Machine Learning
Python Projects
R Projects
About
Accreditation
About Us
Contact Us
Join Us
FAQ
Webinars
Subscription
An Ultimate Guide to Become a Data Scientist
Tutorials
Data Analytics
  • Learn Pandas
  • Learn NumPy
  • Learn SciPy
  • Learn Matplotlib
Machine Learning
  • Boosting
  • Random Forest
  • Linear Regression
  • Decision Tree
  • PCA
Interview by Companies
  • JPMC
  • Google
  • Facebook
Artificial Intelligence
  • Learn Generative AI
  • Learn ChatGPT-3.5
  • Learn ChatGPT-4
  • Learn Google Bard
Coding
  • Learn Python
  • Learn SQL
  • Learn MySQL
  • Learn NoSQL
  • Learn PySpark
  • Learn PyTorch
Interview Questions
  • Python Hard
  • R Easy
  • R Hard
  • SQL Easy
  • SQL Hard
  • Python Easy
Data Science Blog > R Shiny > The Trump Effect Dashboard: Tracking the Market Outcomes of All the President's Tweets

The Trump Effect Dashboard: Tracking the Market Outcomes of All the President's Tweets

Evan Frisch
Posted on Feb 19, 2017

From the 2016 U.S. presidential campaign to election day, the inauguration, and beyond, media attention and debate have maintained a focus on the Twitter account of Donald Trump. Particularly following the election, there have been many articles contending that CEOs of publicly traded companies fear — or should fear— President Trump's tweets. Others have questioned or critiqued the assertion that the President's tweets have a substantive impact on the stock prices of the corporations he addresses on Twitter.

With no signs that the new phenomenon of Presidential tweeting about companies is coming to an end soon, an opportunity presented itself to create a tool to acquire a collection of Donald Trump's tweets, search them for references to major corporations, and provide charts of stock prices against tweets that refer to the relevant companies. Given the complexity of financial markets, it would be unreasonable to expect to find rigorous proof that Trump's tweets cause stock prices to rise or fall. However, it should be possible to explore the kinds of relationships that his tweets have to stock prices. This may also help us to determine whether a similar pattern emerges in stock prices following Trump's tweets, or whether there does not appear to be any consistent pattern. It is this type of exploration that the Trump Effect Dashboard aims to facilitate.

The examination of stocks referenced in Donald Trump's Twitter feed naturally begins with a collection of his tweets. The Twitter API provides a means to acquire the most recent tweets from a user's timeline, which is limited to 3200 tweets. It also offers a means to search for the ID numbers of all tweets by a given user. After accessing a list of tweet ID numbers, it is then possible to request the text and metadata of the associated tweets. The Trump Effect Dashboard, which is an R Shiny app, uses the timeline method, as implemented in the twitteR package, to obtain recent tweets. It also downloads and uses a collection of Trump's tweets that was assembled and stored on GitHub by Sasha Perigo through a Python script. By joining the archive of tweets, which ends in July 2016, with the recently acquired tweets, the dashboard gains access to a complete collection of Donald Trump's tweets from his very first tweet on May 4, 2009 to the present. The collection of tweets is then stored using the Feather serialization package for fast access to tweets on startup of the app.

The dashboard also needs a way to identify tweets that refer to publicly traded corporations. To do this, it first uses the quantmod package to access the Yahoo Finance API and obtain company names, ticker symbols, and market capitalizations. It then determines the 1000 largest corporations by market cap that are available. This list provides the universe of companies that the dashboard is capable of seeking in Trump's tweets. The app uses R's grepl function to determine which tweets have text that matches patterns related to a company, after cleaning up company names by removing terms such as "Inc." that are unlikely to appear in a tweet. A number of options are available to allow the user to customize the search process.

In the example below, the company selector is set to search Donald Trump's tweets from November 4, 2016 until February 18, 2017 for cases that refer to General Motors by name.

SearchSettingsGM

Other options make it possible to search by ticker symbol, turn off case sensitivity, or loosen the search so that it will accept matches on just the first word or first two words of a company name. Adjusting these options can be helpful in finding tweets that refer to companies because different approaches may be needed for different companies. The date range selector can also be adjusted to enable search for tweets over a broader or narrower period of time and to allow for the display of stock prices for the same period.

The following results are provided for the search settings shown above:

StockPriceAndVolumeGM

Above the listing of tweets found to match the search criteria, in this case referencing General Motors, is a candlestick chart of the company's stock price for the selected period along with its trading volume. The candlesticks are colored green for days when the stock closed up and orange for the days it closed down. The stock price and volume chart shown above was created using the quantmod R package.

A second tab in the company information panel provides an interactive stock price chart that overlays markers for relevant tweets. When the user's mouse hovers over a marker indicating a tweet (TW), the text of the tweet is displayed on the graph. (The markers labelled E and I near the bottom of the graph indicate election day and inauguration day respectively.) The interactive chart makes it easy to see that GM's stock price actually rose following a tweet that was critical of the company on January 3. A tweet thanking General Motors for creating jobs in the U.S. was followed by a negligible rise, then a small decline after the inauguration. Trump's tweet describing a positive meeting with GM's CEO preceded an uptick, then a larger decline in the company's stock price. Overall, these examples do not suggest a clear influence on the company's stock price. The dygraphs R package was used to create the interactive stock price charts.

InteractiveStockPriceGM

The dashboard also provides another way to look up companies. A tab featuring a list of companies that Trump has tweeted about in recent years brings up the interactive stock chart for the selected company. In the case of Nordstrom, shown below, the stock price rose in the day following criticism by the President, although the subsequent movement was less decisive.

CompanyHotListNordstrom

A third company information tab attempts to compare the frequency of tweets for the selected company with that of other companies that Donald Trump tweeted about in the same period. With Boeing selected in the example below, the tweet frequency tab shows that two tweets were found that referred to Boeing for the specified period, compared with three for GM and one for Nordstrom. The tweet frequency bar chart was created using the rbokeh package, which makes it possible for the user to view the exact number of tweets by hovering over a bar with the mouse.

TweetFrequencyBoeing

However, the bar chart also illustrates limitations in the search method with respect to company names that are also common words or abbreviations. Tweets referring to the news media, for example, are counted as if they were tweets about News Corp, while those that use the abbreviation CA for California are incorrectly associated with the company CA, formerly Computer Associates. The preponderance of such common names and abbreviations, which are shared by the names of corporations, may be difficult to exclude from any search of tweets. The unstructured nature of tweets, their brevity, and the frequent use of abbreviations mean that distinguishing Intel the company from intel the abbreviation for intelligence is likely to remain a challenge.

One opportunity for future development work may be to facilitate search for companies by their subsidiaries, products, or other relevant keywords. Following the election, Donald Trump tweeted about Carrier, the air conditioner manufacturer, which had been in the news for its plans to reduce employment in Indiana and expand production in Mexico. The tweet below is not detected in the app as a reference to a company, even though the app downloaded it, because Carrier is not a publicly traded company in its own right. Instead, it is a subsidiary of United Technologies, a conglomerate that is among the largest publicly traded corporations. While United Technologies is in the universe of companies for which the app can search, additional information would need to be stored in order to detect references to its subsidiaries, such as Carrier.

trump-carrier-tweet

Overall, a preliminary exploration of Donald Trump's tweets that refer to publicly traded companies using the Trump Effect Dashboard does not find much evidence for the contention that tweets that are critical of a company precede a decline in its stock price or that tweets that praise a company precede a rise, let alone evidence that they cause such results. At times, Trump has seemed to imply that a company's stock price was affected by his remarks on Twitter, such as his retweets promoting a boycott of Macy's following that company's decision to stop selling his clothing line and fragrance. (See the chart at the top of this blog post.) However, the cause of the decline of stock in Macy's, a company Trump promoted repeatedly on Twitter while it was selling his products, not necessarily related to his tweets and that decline is not matched by other companies Trump has criticized on Twitter. While the Trump Effect Dashboard provides a means to continue to examine this emerging phenomenon, it does not appear so far that his tweets lead to any consistent pattern of stock price results.

About Author

Evan Frisch

Evan Frisch has more than a decade and a half of experience using technology and data to achieve results for organizations in the private, public, and non-profit sectors. Evan received his undergraduate degree with honors from Yale University,...
View all posts by Evan Frisch >

Related Articles

Data Visualization
Twitter Sentiment Analysis of Indian Election 2019
Student Works
Data Study on Sneaker Reselling
Student Works
The Facebook Effect
Data Visualization
Use Bitcoin in Real Life and Invest on It
Alumni
Alumni Spotlight: Claire Keser, Senior Analyst at Casper

Leave a Comment

Cancel reply

You must be logged in to post a comment.

No comments found.

View Posts by Categories

All Posts 2399 posts
AI 7 posts
AI Agent 2 posts
AI-based hotel recommendation 1 posts
AIForGood 1 posts
Alumni 60 posts
Animated Maps 1 posts
APIs 41 posts
Artificial Intelligence 2 posts
Artificial Intelligence 2 posts
AWS 13 posts
Banking 1 posts
Big Data 50 posts
Branch Analysis 1 posts
Capstone 206 posts
Career Education 7 posts
CLIP 1 posts
Community 72 posts
Congestion Zone 1 posts
Content Recommendation 1 posts
Cosine SImilarity 1 posts
Data Analysis 5 posts
Data Engineering 1 posts
Data Engineering 3 posts
Data Science 7 posts
Data Science News and Sharing 73 posts
Data Visualization 324 posts
Events 5 posts
Featured 37 posts
Function calling 1 posts
FutureTech 1 posts
Generative AI 5 posts
Hadoop 13 posts
Image Classification 1 posts
Innovation 2 posts
Kmeans Cluster 1 posts
LLM 6 posts
Machine Learning 364 posts
Marketing 1 posts
Meetup 144 posts
MLOPs 1 posts
Model Deployment 1 posts
Nagamas69 1 posts
NLP 1 posts
OpenAI 5 posts
OpenNYC Data 1 posts
pySpark 1 posts
Python 16 posts
Python 458 posts
Python data analysis 4 posts
Python Shiny 2 posts
R 404 posts
R Data Analysis 1 posts
R Shiny 560 posts
R Visualization 445 posts
RAG 1 posts
RoBERTa 1 posts
semantic rearch 2 posts
Spark 17 posts
SQL 1 posts
Streamlit 2 posts
Student Works 1687 posts
Tableau 12 posts
TensorFlow 3 posts
Traffic 1 posts
User Preference Modeling 1 posts
Vector database 2 posts
Web Scraping 483 posts
wukong138 1 posts

Our Recent Popular Posts

AI 4 AI: ChatGPT Unifies My Blog Posts
by Vinod Chugani
Dec 18, 2022
Meet Your Machine Learning Mentors: Kyle Gallatin
by Vivian Zhang
Nov 4, 2020
NICU Admissions and CCHD: Predicting Based on Data Analysis
by Paul Lee, Aron Berke, Bee Kim, Bettina Meier and Ira Villar
Jan 7, 2020

View Posts by Tags

#python #trainwithnycdsa 2019 2020 Revenue 3-points agriculture air quality airbnb airline alcohol Alex Baransky algorithm alumni Alumni Interview Alumni Reviews Alumni Spotlight alumni story Alumnus ames dataset ames housing dataset apartment rent API Application artist aws bank loans beautiful soup Best Bootcamp Best Data Science 2019 Best Data Science Bootcamp Best Data Science Bootcamp 2020 Best Ranked Big Data Book Launch Book-Signing bootcamp Bootcamp Alumni Bootcamp Prep boston safety Bundles cake recipe California Cancer Research capstone car price Career Career Day ChatGPT citibike classic cars classpass clustering Coding Course Demo Course Report covid 19 credit credit card crime frequency crops D3.js data data analysis Data Analyst data analytics data for tripadvisor reviews data science Data Science Academy Data Science Bootcamp Data science jobs Data Science Reviews Data Scientist Data Scientist Jobs data visualization database Deep Learning Demo Day Discount disney dplyr drug data e-commerce economy employee employee burnout employer networking environment feature engineering Finance Financial Data Science fitness studio Flask flight delay football gbm Get Hired ggplot2 googleVis H20 Hadoop hallmark holiday movie happiness healthcare frauds higgs boson Hiring hiring partner events Hiring Partners hotels housing housing data housing predictions housing price hy-vee Income industry Industry Experts Injuries Instructor Blog Instructor Interview insurance italki Job Job Placement Jobs Jon Krohn JP Morgan Chase Kaggle Kickstarter las vegas airport lasso regression Lead Data Scienctist Lead Data Scientist leaflet league linear regression Logistic Regression machine learning Maps market matplotlib Medical Research Meet the team meetup methal health miami beach movie music Napoli NBA netflix Networking neural network Neural networks New Courses NHL nlp NYC NYC Data Science nyc data science academy NYC Open Data nyc property NYCDSA NYCDSA Alumni Online Online Bootcamp Online Training Open Data painter pandas Part-time performance phoenix pollutants Portfolio Development precision measurement prediction Prework Programming public safety PwC python Python Data Analysis python machine learning python scrapy python web scraping python webscraping Python Workshop R R Data Analysis R language R Programming R Shiny r studio R Visualization R Workshop R-bloggers random forest Ranking recommendation recommendation system regression Remote remote data science bootcamp Scrapy scrapy visualization seaborn seafood type Selenium sentiment analysis sentiment classification Shiny Shiny Dashboard Spark Special Special Summer Sports statistics streaming Student Interview Student Showcase SVM Switchup Tableau teachers team team performance TensorFlow Testimonial tf-idf Top Data Science Bootcamp Top manufacturing companies Transfers tweets twitter videos visualization wallstreet wallstreetbets web scraping Weekend Course What to expect whiskey whiskeyadvocate wildfire word cloud word2vec XGBoost yelp youtube trending ZORI

NYC Data Science Academy

NYC Data Science Academy teaches data science, trains companies and their employees to better profit from data, excels at big data project consulting, and connects trained Data Scientists to our industry.

NYC Data Science Academy is licensed by New York State Education Department.

Get detailed curriculum information about our
amazing bootcamp!

Please enter a valid email address
Sign up completed. Thank you!

Offerings

  • HOME
  • DATA SCIENCE BOOTCAMP
  • ONLINE DATA SCIENCE BOOTCAMP
  • Professional Development Courses
  • CORPORATE OFFERINGS
  • HIRING PARTNERS
  • About

  • About Us
  • Alumni
  • Blog
  • FAQ
  • Contact Us
  • Refund Policy
  • Join Us
  • SOCIAL MEDIA

    © 2025 NYC Data Science Academy
    All rights reserved. | Site Map
    Privacy Policy | Terms of Service
    Bootcamp Application