Knowledge Base | How to Load Historical Stock Prices from Yahoo Finance to CSV

How to Load Historical Stock Prices from Yahoo Finance to CSV

Updated: August 28, 2019


Historical Prices at Yahoo Finance

Yahoo Finance provides data for a lot of exchanges.

You can open, search a ticker like AAPL, and click the 'Historical Data' tab.

You can use URLs like to open pages with historical prices directly.

You can download historical prices to a CSV file using the 'Download Data' link above the Volume column.

You can download data for the required selected period.
Unfortunately, Yahoo disabled loading historical prices using download utilities in May 2017.

Undocumented URLs to Download Historical Prices from Yahoo Finance

Yahoo Finance uses an internal web service to load historical stock and currency prices into its web pages.

You can use any tool like CURL to download data.

Also, you can use a specialized tool, gsqlcmd, to download and convert JSON data to CSV.

For example, to get daily historical prices, use the command:

gsqlcmd convert ^
    "" AAPL.csv ^

To get weekly historical prices:

gsqlcmd convert ^
    "" AAPL-weekly.csv ^

To get monthly historical prices:

gsqlcmd convert ^
    "; AAPL-monthly.csv ^

To get 1-minute intraday prices:

gsqlcmd convert ^
    "" AAPL-1.csv

To get 5-minute intraday prices:

gsqlcmd convert ^
    "" AAPL-5.csv

To get 15-minute intraday prices:

gsqlcmd convert ^
    "" AAPL-15.csv

To get 60-minute intraday prices:

gsqlcmd convert ^
    "" AAPL-15.csv

Use the convert mode to download and convert JSON to CSV.

Use the /rootpath=*.*.timestamp,*.*.*.quote,*.*.*.unadjquote option to point to the JSON root of historical prices.

You can load historical prices for currencies. Just use tickers like GBPUSD=X.

Loading Historical Prices from Yahoo Finance with Batch Files

gsqlcmd allows automating downloads using batch files.

Create a text file like 'task.txt' and place tickers one by line like:


Create a batch file like 'load.cmd' with the following commands:

@echo off

@for /F %%i in (tickers.txt) do (
    gsqlcmd convert ^
        "" %%i.CSV ^
        /delay=200 /echoOutputFileName /rootpath=*.*.timestamp,*.*.*.quote,*.*.*.unadjquote

Run it. You will see the result:

AAPL.CSV - 504 rows
FB.CSV - 504 rows
GOOGL.CSV - 504 rows

Pay attention to the /delay parameter. Use the delay to avoid banning your IP due to frequent multiple automatic requests.

Downloading Historical Prices from Yahoo Finance using MARKET.CSV

MARKET.CSV is a specialized tool for loading data from Yahoo Finance and MSN Money.

For example, you can place the required tickers to a file like tickers.txt.


Then, you can execute the following commands to download data using the required data providers:

market.csv.exe download YahooHistoricalPricesDaily
market.csv.exe download YahooHistoricalPricesWeekly
market.csv.exe download YahooHistoricalPricesMonthly
market.csv.exe download YahooIntradayPrices1m
market.csv.exe download YahooIntradayPrices5m
market.csv.exe download YahooIntradayPrices15m
market.csv.exe download YahooIntradayPrices60m

The tool downloads data, archives the data to zip files, and converts the data to CSV.

You can get results in the output files like YahooHistoricalPricesDaily.csv, YahooHistoricalPricesWeekly.csv, etc.

Moreover, MARKET.CSV includes ready-to-use SQL codes and format files to import CSV data into a Microsoft SQL Server database.


Products for Traders and Investors
The app loads data from Yahoo Finance and MSN Money to CSV and SQL Server
Version: 2.24 | 08/23/2023 | 1.5MB | Getting Started | What's New | Edition Comparison
This tool downloads, converts, and imports data from Yahoo Finance and MSN Money
Version: 6.10 | 10/10/2023 | 14.6MB |


Yahoo Finance is a logo and registered trademark of Yahoo! Inc.