Skip to content

epfl-ada/ada-2025-project-adacore

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

189 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

King of White House, Wolf of Wall Street: How US presidential elections impact sectors' performance on the stock market

Brought to you by Team Adacore: Abboud Ghassan, Braha Eliota, Pafumi Nicolas, Pedroia Asia, Sánchez Fernández Elsa

Check out our data story website, as well as the repo we used to create it

Abstract

It is an established fact that presidential elections have a significant impact on the stock market. Investors react to the uncertainty and potential policy changes that come with a new administration. Understanding these dynamics can help investors anticipate these movements and hedge their portfolios around election cycles. These insights also provide a window into the market's perceptions of different candidates and their proposed policies.

In this project, we explore how presidential elections influence company performance and investor sentiment over time. Using historical stock market data and election data, we explore how different sectors of the market respond to election outcomes and if these responses are influenced by certain characteristics of the elections themselves.

Our goal is to show how politics and markets move together in a clear, data-driven way. By analyzing past elections and the upcoming 2024 race, we hope to uncover patterns that explain when, why, and how the market reacts.

Research questions

  • Do different sectors of the stock market such as Technology, Healthcare, or Financials respond differently to presidential elections?
  • Which sectors respond favorably to Democrat or Republican administrations? - Is there a consistent pattern in the returns of certain sectors following elections? And can these be exploited as an investment strategy?
  • Is the market more volatile before or after election results are announced and is this volatility sector-dependent?
  • How does the economic and political context of the election, as well as the characteristics of the candidates, influence market reactions, if at all?

Data

Nasdaq ticker data

Our main dataset consists of historical stock prices for Nasdaq-traded stocks and ETFs. While the original dataset was found on Kaggle, it only contained data up to the beginning of 2020. In order to cover the 2020 and 2024 US election cycles, we downloaded more recent data using Yahoo Finance's API. To download this updated dataset yourself, run the following command from the repo's root:

python -m src.scripts.download_ticker_data

Please note that running this script takes a significant amount of time as it is limited by Yahoo Finance's rate limits. We provide it for reproducibility purposes, though one can check all components of our analysis on our Results notebook without running any code. Note that if you choose to download the dataset, it will not contain an Adj Close column. No need to panic! All columns will already have been adjusted for stock splits and dividends, hence why we use Close prices directly in our analyses.

We have supplemented the stock metadata with information about each company's industry in order to analyze sector-specific effects. Once you have the dataset downloaded, run the the following script from root:

python -m src.scripts.augment_metadata

This allows for sector retrieval using Yahoo Finance's API and adds columns for start and end dates of available data for easier downstream querying. As this script takes around 2 hours to run (limited by Yahoo Finance's rate limits), we have provided the augmented metadata file symbols_valid_meta_labeled.csv in the data/ folder for convenience.

Election data

We have compiled several datasets. The first one covers US presidential elections from 2000 to 2024. It contains election dates, which are key to our event study methodology, names of candidates, outcomes, and other relevant details. It also includes characteristics of the different elections such as economic backdrop and geopolitical tension as made available by Botta & Sakariyahu in their paper on market volatility around elections. This dataset is available in the data folder as elections.csv.

While our analysis only utilize election dates an the aforementioned characteristics provided by Botta & Sakariyahu, we describe here additional datasets we collected and we think could be interesting for future works.

The first additional analysis dataset contains the dates of presidential and vice-presidential debates, as well as the number of viewers (in millions), and is available in the data folder as debates.csv. The data was mainly collected from the Commission on Presidential Debates and updated to 2024 using the 2024 United States presidential debates. Data was also collected from the American Presidency Project, which contains data on public perception.

Since 2000, multiple national polls from Gallup have asked the public the same question: 'Do you approve or disapprove of the way [president's name] is handling his job as president?' The data contains the start and end dates of polling, as well as the percentages of those who approved, disapproved, and did not vote. This dataset is available in the data folder as approval.csv.

Both the number of viewers of debates and the presidential approval ratings can serve as proxies for how polarising an election is and how likely and incumbent president is to win re-election, respectively. These factors can influence market reactions around election periods and could be used to further enrich our analysis with more granular day-to-day analysis.

Usage

Environment setup

To set up the Python environment, we recommend using conda with the provided environment.yml file. Create the environment with the following command:

conda env create -f environment.yml

Activate the environment using:

conda activate adacore-2025

Methods

To study the stock market reaction around presidential elections, we used event-study approaches as well as linear regression. The event-study method goes as follows:

  • Define an event window around the election date (e.g., 30 days before and after the election).
  • Calculate a financial metric (e.g., abnormal returns or volatility) for each stock in the event window.
  • Aggregate the results across stocks and sectors to identify patterns.

We have mainly implemented two types of event-study analyses. The first is based on abnormal returns and focuses on which whether sectors perform better or worse depending on the outcome of elections. The second is based on abnormal volatility and focuses on investor sentiment and panic around elections. Abnormal returns for a stock $i$ at time $t$ is defined as follows:

$$ R_{t,i}^{abnormal} = R_{t,i} - \left( \alpha_i + \beta_i \cdot R_{t,ref} \right) $$

where $R_{t,i}$ is the realized return for stock $i$ at time $t$, $R_{t,ref}$ is the return of a reference index (e.g., S&P 500) and $\alpha_i$, $\beta_i$ are parameters fitted over an estimation period. A more detailed explanation of their meaning is given in the Results.ipynb notebook. Similarly, we defined $AV_{t,i}$ as the abnormal volatility for a stock $i$ at time $t$ based on a GARCH(1,1) model for time-series data. Details of this implementation are also given in the Results.ipynb notebook. Because our analysis is sector-specific, we have discussed a way to represent the behaviour of a sector using a family of well-established ETFs. Our modules are organized as follows:

src/
├── scripts/
│   ├── download_ticker_data.py
│   └── augment_metadata.pyend dates
└── utils/
    └── assign_sectors.py: utils for augment_metadata.py
    └── calculate_financials.py
    └── select_stocks.py
    └── create_web_visualizations.py
    └── CONFIGS.py

CONFIGS.py contains global constants such as data paths and plotting colors. select_stocks.py contains functions to query stock data based on date ranges and sector labels. calculate_financials.py contains functions to calculate financial metrics and implement the main event-study methods. create_web_visualizations.py contains functions to create visualizations for our website based on our results.

Contributions

  • Abboud Ghassan: abnormal volatility calculations, statistical tests, regression analysis, repo organization, notebook textual descriptions.
  • Braha Eliota: sector labeling and data storytelling.
  • Pafumi Nicolas: alpha/beta and abnormal returns calculations, website development and deployment, data storytelling.
  • Pedroia Asia: Election data collection and cleaning, interactive visualizations, data storytelling.
  • Sánchez Fernández Elsa: interactive dashboards development, correlation analysis, bubble plot.

References

  1. Białkowski J, Gottschalk K, Wisniewski TP. Stock market volatility around national elections. Journal of Banking & Finance. 2008;32(9):1941-1953. doi:10.1016/j.jbankfin.2007.12.021
  2. Botta C, Sakariyahu R. Market volatility across asset classes during U.S. presidential and mid-term elections. Finance Research Letters. 2025;84:107754. doi:10.1016/j.frl.2025.107754
  3. Mnasri A, Essaddam N. Impact of U.S. presidential elections on stock markets’ volatility: Does incumbent president’s party matter? Finance Research Letters. 2021;39:101622. doi:10.1016/j.frl.2020.101622
  4. Markets soar on Trump win as big banks rocket higher - POLITICO
  5. Oil price crests $41 on vaccine-fueled market rally. September 11, 2020
  6. Oil, Coal Seen as Winners With Donald Trump Victory - WSJ

About

ada-2025-project-adacore created by GitHub Classroom

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors