Skip to content

Data for SPY etc #402

@phatcher

Description

@phatcher

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")

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions