Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Data for SPY etc #402

Open
phatcher opened this issue Jan 18, 2025 · 0 comments
Open

Data for SPY etc #402

phatcher opened this issue Jan 18, 2025 · 0 comments

Comments

@phatcher
Copy link

Just started playing with QSTrader and the SPY data can't be downloaded directly from Yahoo Finance anymore.

However it can by accessed via the yfinance python library.

Here's a little code example which will download the data necessary for the examples, gets the full date range

import yfinance as yf

def download_ticker(ticker):
  # Always get the full history
  data = yf.download(ticker, interval='1d', auto_adjust=False, multi_level_index=False) 

  # Change the path as needed
  filename = "./data/{}.csv".format(ticker) 
  data.to_csv(filename)

# sixty_forty
download_ticker("SPY")
download_ticker("AGG")

# momemtum_taa - Sector ETFs
download_ticker("XLB")
download_ticker("XLC")
download_ticker("XLE")
download_ticker("XLF")
download_ticker("XLI")
download_ticker("XLK")
download_ticker("XLP")
download_ticker("XLU")
download_ticker("XLV")
download_ticker("XLY")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant