Make sure you have the yfinance package installed first. If you don’t, you can run the following command in your Jupyter notebook:
!pip install yfinance
Input:
import pandas as pd import numpy as np import yfinance as yf
Input:
spy_ohlc_df = yf.download('SPY', start='1993-02-01', end='2019-12-01')
Output:
[*********************100%***********************] 1 of 1 downloaded
Input:
spy_ohlc_df.head()
Output:

Conclusion
This is a very brief summary of how you can download stock data information for the S&P 500 from Yahoo Finance, using the Python programming language. If there is something you want to learn about, please let me know in the comments below and I can cover it in a future blog post.
You must be logged in to post a comment.