Extracting GameStop Stock Data Using yfinance?
Python Project
some code that uses the yfinance library to extract historical stock data for GameStop:
Code:import yfinance as yf
# Set the ticker symbol for GameStop
symbol = "GME"
# Use yfinance to download historical data for GameStop
stock_data = yf.download(symbol, start="2020-01-01", end="2022-02-23")
# Print the first 5 rows of the data
print(stock_data.head())
In this code, we first set the symbol variable to the ticker symbol for GameStop. Then, we use the yf.download function to download historical stock data for GameStop from January 1st, 2020 to February 23rd, 2022. The data is stored in a pandas DataFrame, which we can manipulate and analyze as needed. Finally, we print the first 5 rows of the data using the head method.
You can modify the start and end dates to download stock data for different time periods, and you can also adjust the parameters of the yf.download function to customize the data that is returned (e.g. by adding additional columns or specifying a different interval).
Comments
Post a Comment