Design a site like this with WordPress.com
Get started

How to download S&P 500 data from Yahoo Finance using Python

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:

spy 12-1-19

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.

Advertisement

Author: Trader Court

CPA first, pivoted to python programmer focused on data science which I apply to my own stock and options trading.

Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: