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 > Data Analysis on Stock Market Indexes after Trump's Win

Data Analysis on Stock Market Indexes after Trump's Win

Lakshmi Prabha Sudharsanom
Posted on Feb 4, 2018
The skills the author demoed here can be learned through taking Data Science with Machine Learning bootcamp with NYC Data Science Academy.

Introduction

This post is about the first of the four projects we are supposed to deliver at the NYC Data Science Academy Data Science Bootcamp program.

I framed the question for this project as, "How did world stock market indexes react to President Trump's win?"

What is a stock market index?

Let us begin with a simple example.

The ABC index is made up of four companies.  As of the end of yesterdayโ€™s trading day, the ABC index was set at 4,123 points.  Today, two of the companies went up in value, one company dropped in price and the fourth company stayed the same โ€“ the total value of those stocks went up by 2% so the ABC index is now 2% higher or 4205 points.

A stock market index (or just โ€œindex") is a number that measures the relative value of a group of stocks. As the stocks in this group change value, the index also changes value. If an index goes up by 1% then that means the total value of the securities which make up the index have gone up by 1% in value.

Major World Stock Market indexes

For analysis purpose, we divide the major world stock indexes based on regions: US, Global, Asia Pacific, Europe, Americas and others.

Before answering the question,"How did world stock markets react to Trumpโ€™s win?", it is also important to consider, "What did people predict about President Trumpโ€™s win and stock markets?"

Literature Review

CNN-money - October 24, 2016:

  • โ€œIf Donald Trump wins the election, U.S. stocks (and likely many other markets overseas) will almost certainly tankโ€.
  • Analysts bet on Clintonโ€™s win.

The Telegraph, UKโ€“Nov 5, 2016:

  • โ€œGlobal markets will be plunged into turmoil this week if Donald Trump wins the race for the White House, analysts have warned, with currency turbulence and a drop in US stocks not seen since the financial crisisโ€.
  • โ€œAs Americans prepare to head to the polls on Tuesday, experts said a victory for the Republican presidential candidate would trigger short-term market ructions and inflict long-term damage on the worldโ€™s biggest economyโ€.
  • Simon Johnson, a former IMF chief economist, said a Trump victory and the protectionist policies that might follow could take the world โ€œback to the Great Depression in terms of the impact on trade and consequencesโ€.
  • Mr.Johnson, who has warned that a Trump victory could trigger a global recession, said that in a โ€œnightmare scenarioโ€ the damage caused by the downturn would be โ€œpermanent ---on the economic side and in terms of the US in the worldโ€ .

The New York Times โ€“ Nov 9, 2016:

  • Paul Krugman, โ€œStill, I guess people want an answer: If the question is when markets will recover, a first-pass answer is neverโ€.

What happened? Did their predictions come true?

This is my topic of interest. I collected data from Wall Street Journal (WSJ)  for two years from Jan 2016 to Jan 2018. I used R, ggplot2, plotly and Shiny for analysis and visualization.

Source Data

I sourced the data from the Wall Street Journal.  I had to collect two different kinds of data, on the one hand, daily data for the present scenario and on the other, ten years of data for comparison.  For the first case, I downloaded the daily data for each major world stock index for two years from Jan 01, 2016 โ€“ Jan 18, 2018, directly from the website, whereas for the second case, I had to collect data for the period of ten years from 2008 โ€“ 2018 in order to compare the present scenario with the past history. This data was not available for download. I copied the tables  to MS-Excel and then processed it using R.

The data was in very good quality so that I had to do almost no cleaning.  Few of the index data were missing. But, as they were not major indexes, I removed those rows from the table.  I converted dates which were in character format to date object, so they would become suitable for analysis.

Data Visualization in Shiny

The visualization of the data had to be done in Shiny, which is an open source R package that provides an elegant and powerful web framework for building web applications using R. Shiny helps you turn your analyses into interactive web applications . Furthermore, I used Shiny Dashboard to create a management dashboard-like application.

Start

First, I grouped the indexes, charts and maps based on regions and then added two more items for comparison.  These are USA, Global, Asia Pacific, Europe, Americas, Others, Distribution Comparison and Comparison with the Past History (i.e., comparing 2018 with 2008-2017), which can be seen in the image below. Let us discuss them in detail.

Data Analysis on Stock Market Indexes after Trump's Win

Start

 

Region-based Tabs

Each of the tabs:USA, Global, Asia Pacific, Americas and Others are organized in the following manner.

The main tab (region-based) page contains information about the respective region indexes. Each of the main tab (region-based) page has five sub-tabs.

Data Analysis on Stock Market Indexes after Trump's Win

Main Page of Region Tabs

  • The first sub- tab, 'Map', displays the location of the respective stock exchanges where the indexes are used. The other four sub-tabs display the closing price of respective region Stock indexes for different periods using various chart types.
  • The second sub-tab 'General', gives information on the stock indexes for the entire period from  January 2016 to January 2018.
  • The third sub-tab, 'Before Trump's Win',  displays information of stock indexes before President Trump's win, that is, from January 2016 to mid-October 2016.
  • The fourth sub-tab, 'Crucial Moment', highlights the stock index values from October 15, 2016 to December 31, 2016. This period is the crucial moment of stock market because of U.S.Presidential elections and President Trump's win.
  • The final sub -tab, 'Upward (Historical Moment)', gives information on stock indexes from January 2017 to the middle of January 2018. This period is the historical moment, because of the historical increase in stock market indexes over the period of ten years.

In each of the sub-tabs (except 'Map'), three select boxes are available, the first to select the index, the second to select date range  and the third to select a chart to be displayed.

Different Chart Types

Data Analysis on Stock Market Indexes after Trump's Win

 Sub-Tabs

There are five different chart types available for display, which are line, candlestick, mountain (area), bar and dot (scatter) plots.

  • Line charts display the line graph of Closing points of the index for various periods.
  • Candlestick charts display the OHLC  (open, high, low and close) values for various periods. In addition,  sliders are available below the charts to zoom in and vary the periods for users choice.
  • Mountain (area) charts display the area graph of closing values for various periods.
  • Bar charts display the bar graph of closing values for various periods. In addition, sliders are available below the charts and selectors are available above the charts to vary the periods for two weeks, 1 month, 3 months, 6 months and the entire period.
  • Dot plots display the scatter plot of closing values for various periods. In this case, sliders and selectors are available for users to interact with as well.

Various Charts for Display

 

Data Distribution Comparison

This tab allows users to compare the line graph of various major indexes simultaneously. This tab has four sub-tabs to compare the indexes in general period, before Trump's win, during  'Crucial Moment' and during 'Upward Moment'. This gives a clear picture of what was happening during the election week, how much the indexes went down, when they did recover and so on.

Some observations from this tab for the whole period:

  • Almost all graphs follow an increasing trend, with ups and downs here and there.
  • The exceptions are China Shanghai Composite and Mexico IPC, which also show an increasing trend but with lots of fluctuations.

We canโ€™t just stop with an increasing trend. I wanted to get some more deeper insights. So, I focused on the 'Crucial Moment' and 'Upward Moment'.

Observations for 'Crucial Moment':

  • Almost all curves have a dip during Nov 4, 2016 โ€“ Nov 10, 2016.
  • US and global indexes, Euro Stoxx, indexes of Japan, France and Canada follow an S-shaped curve, i.e., they started to increase immediately from the week after the election. The S shape is uniform but the difference is that some curves started to increase from the week after the election, while some other curves, two weeks after the election and some Europe indexes started to increase from December 7, 2016.
  • On the other hand, indexes of Asia Pacific and Americas show a decreasing trend, i.e., they could not recover at all until December 2016.
  • The exception is China Shanghai composite, which showed a normal distribution, i.e., it increased immediately but then decreased. It could not maintain its state of level.

Crucial Moment Comparison

 

Observations for 'Upward Moment':

All curves show an increasing trend but with difference in shapes of the curves, that is, they took time to settle down.

Some indexes showed steady performance from Jan 2017, some from July 2017, while others (e.g., DAX in Germany) showed steady performance from Oct 2017. The exception is Mexico. It could not recover at all until Dec 7, 2017, but then it started to increase from Dec 11, 2017 on.

 Upward Moment Comparison

 

Comparison with Past History

This tab displays bar charts of region-wise high values and percentage changes, for ten years, i.e., from 2008 - 2018. It has two select boxes, one to select the region and the other to select the variable (High or Percentage Change) to display for comparison.

This tab highlights what is so special and unique in Trumpโ€™s win.

All-Time High

 

Observations:

Almost all major indexes (with some exceptions) reached an all-time peak during this period (Jan 2018). This is the uniqueness in Trumpโ€™s win.

Advantages

  • Even small companies around the world have gained a substantial amount.
  • Majority of the investors have gained more than before in this period and in fact, some investors who might have waited patiently for ten years, must have reaped an unexpected huge gain in this period.

Conclusion

Almost all major indexes

  1. Show a dip during Nov 4, 2016โ€“Nov 10, 2016, but the dip was not the minimum (except for Denmark and Iceland). The markets just reacted to uncertainty, but the dip did not become a historical calamity.
  2. Started to show steady performance uniformly from Oct 2017
  3. Reached all-time peak in Jan 2018

I collected data until Jan 18, 2018. The indexes were increasing (with fluctuations) until that period, but, some of them have started to decrease from last week. This leads to the following future directions.

Future Directions

  • President Trump has recently set a target for Dow Jones Industrial Average (DJIA) to achieve 30000 points.
  • Analyze the trend using various ML algorithms and predict...
    • if DJIA will achieve his target
    • when it will happen
    • if it will go above the target
    • how other world stock indexes would react

The data set provided a great way to apply Shiny. It was a great experience to work on this project. Thanks to NYC Data Science Academy for providing me a wonderful opportunity to work with ggplot2,  Plotly, Leaflet Maps and Shiny Dashboard.

Code and data can be found on Github, while the app itself is online at shinyapps.io

 

About Author

Lakshmi Prabha Sudharsanom

Lakshmi Prabha Sudharsanom is a life-long learner. She was a post doc, funded by Department of Atomic Energy, India. She had been spending time in writing graph algorithms for social network applications and analyzing data using MS-Excel. When...
View all posts by Lakshmi Prabha Sudharsanom >

Related Articles

Data Analysis
Car Sales Report R Shiny App
R Shiny
Forecasting NY State Tax Credits: R Shiny App for Businesses
R Shiny
Behind the Curtains: Insights into NYC Broadway Shows
Meetup
What can data say about work-life balance and achievement?
Python
Tech Layoffs: Exploring the Trends and Industry Shifts

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