Skip to content

In this notebook, I investigate how the various sectors performed on the stock market in 2022 by creating a market cap-weighted index of each sector (according to the GCIS), and plotting its returns over the year.

darrendube/2022-stock-market-analysis

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

16 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

2022 US Stock Market Analysis

In this Jupyter Notebook, I investigate how the various sectors of the US economy performed on the stock market in 2022 by creating a market cap-weighted index of each sector, and plotting its returns over the year.

The stocks are classified into sectors according to the Global Industry Classification Standard (GICS):

  • Communication Services
  • Consumer Discretionary
  • Consumer Staples
  • Energy
  • Financials
  • Healthcare
  • Industrials
  • Information Technology
  • Materials
  • Real Estate
  • Utilities

How to use

The analysis was done in a Jupyter Notebook. This analysis can be viewed by opening the notebook, but to run it again, you'll need

  • a dev environment that can run Jupyter Notebooks (e.g. through a VS Code extension, or by installing conda
  • the following libraries:
    • yfinance - a library that enables downloading of price data from Yahoo! Finance
    • numpy
    • pandas
    • matplotlib

The sixth code block involves downloading the price data of about 5000 stocks, and may therefore take a while.

Result

(the y-axis shows the return, and the x-axis shows the trading day in 2022 (there were 251 trading days in total))

output

The Energy sector gained a whooping 60%! This was largely the result of the war in Ukraine pushing up oil prices to record highs. The Information Technology sector, on the other hand, declined about 30%. Analysts attribute this to high interest rates, high inflation, and a generally uncertain business environment.

About

In this notebook, I investigate how the various sectors performed on the stock market in 2022 by creating a market cap-weighted index of each sector (according to the GCIS), and plotting its returns over the year.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published