Created
January 23, 2024 17:53
-
-
Save romanmichaelpaolucci/e4b0c549812164eea30b44f96391d732 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import yfinance as yf | |
import pandas as pd | |
# Define the stock symbols | |
# Define the time period | |
start_date = '2021-01-01' | |
end_date = '2022-01-01' | |
# Download the stock data | |
stock_data = yf.download(large_cap_tickers, start=start_date, end=end_date) | |
# Annual Returns for 2021 | |
r_2021 = (stock_data.iloc[-1] - stock_data.iloc[0])/stock_data.iloc[0] | |
# Closing Price 2021 | |
p_2021 = stock_data.iloc[-1] | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment