Yahoo Finance Historical Data Scraper avatar
Yahoo Finance Historical Data Scraper

Pricing

$0.30 / 1,000 results

Go to Store
Yahoo Finance Historical Data Scraper

Yahoo Finance Historical Data Scraper

Developed by

Eray Diler

Eray Diler

Maintained by Community

Get detailed historical price and volume data from Yahoo Finance for multiple stocks and custom year ranges

0.0 (0)

Pricing

$0.30 / 1,000 results

0

Total users

3

Monthly users

3

Runs succeeded

>99%

Last modified

3 days ago

This Apify actor scrapes historical stock data from Yahoo Finance for one or more specified ticker symbols and a defined period.

Features

  • Fetches historical daily stock data including Open, High, Low, Close, Adjusted Close, and Volume.
  • Supports multiple ticker symbols in a single run.
  • Allows specifying the number of years of historical data to retrieve.
  • Outputs data in a structured JSON format to the Apify dataset.
  • Includes the ticker symbol in each data record for easy identification.

Input

The actor uses an input schema to define the parameters you can set when running it. You can provide these inputs via the Apify Console, API, or a local INPUT.json file.

Input Schema Fields:

  • tickerSymbols (Array of strings)

    • Title: Stock Ticker Symbols
    • Description: Enter one or more stock ticker symbols (e.g., ^GSPC, AAPL, MSFT).
    • Example: ["AAPL", "TSLA"]
    • Default Value: ["^GSPC"]
    • Required: Yes
  • yearsOfData (Integer)

    • Title: Years of Historical Data
    • Description: How many years of historical data to fetch (e.g., 1, 5, 10).
    • Example: 5
    • Default Value: 1
    • Minimum: 1
    • Maximum: 50 (Set to prevent excessive run times or potential blocking)
    • Required: Yes

Example INPUT.json:

{
"tickerSymbols": ["MSFT", "GOOG"],
"yearsOfData": 3
}

Output

The actor stores its results in the default Apify Dataset. Each item in the dataset is a JSON object representing one day of historical data for a specific stock.

Example Output Item (JSON):

{
"date": "May 30, 2025",
"open": 170.50,
"high": 172.30,
"low": 170.10,
"close": 171.95,
"adjClose": 171.95,
"volume": 25000000,
"symbol": "AAPL"
}

Fields:

  • date: The date of the record.
  • open: Opening price.
  • high: Highest price during the day.
  • low: Lowest price during the day.
  • close: Closing price.
  • adjClose: Adjusted closing price (accounts for dividends and stock splits).
  • volume: Trading volume for the day.
  • symbol: The ticker symbol for the stock.

Usage

Running Locally

  1. Ensure you have Node.js and npm installed.
  2. Clone this project (or your Apify actor project).
  3. Install dependencies: npm install
  4. If you want to provide custom input, create a file at apify_storage/key_value_stores/default/INPUT.json with your desired input parameters (see example above).
  5. Run the actor: apify run (or apify run --purge to clear previous storage).

Running on the Apify Platform

  1. Push this actor to your Apify account: apify push
  2. On the Apify platform, find your actor and click "Run".
  3. Provide your input parameters in the "Input" tab or as a JSON object.
  4. Click "Start" to run the actor.
  5. Once the run is finished, you can find the results in the "Dataset" tab of the run. You can download the data in various formats (JSON, CSV, Excel, etc.).

Limitations

  • The scraper relies on Yahoo Finance's website structure. Significant changes to the Yahoo Finance website may break the actor.
  • Fetching very long periods (e.g., 30+ years) for multiple tickers might lead to long run times and increased resource consumption. The yearsOfData input is capped at 50 years by default.
  • The actor does not currently handle pagination for extremely long historical data requests if Yahoo Finance were to implement it differently (currently, it loads all requested data on one page via URL parameters).
  • Cookie consent pop-ups are handled based on common selectors; if Yahoo changes its consent mechanism drastically, it might require an update.

Support

If you encounter any issues or have suggestions for improvement, please open an issue on GitHub or contact eray.diler@gmail.com.


This README was generated with assistance from an AI coding assistant.