# Yahoo Finance Historical Stock Price (`superhero99999/yahoo-finance-ohlcv`) Actor

Fetch clean historical OHLCV candles from Yahoo Finance for one or many tickers. Supports daily and intraday intervals and returns stable JSON rows in the default dataset.

- **URL**: https://apify.com/superhero99999/yahoo-finance-ohlcv.md
- **Developed by:** [David Brown](https://apify.com/superhero99999) (community)
- **Categories:** Integrations, Developer tools
- **Stats:** 2 total users, 1 monthly users, 100.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

from $0.0001 / actor start

This Actor is paid per event. You are not charged for the Apify platform usage, but only a fixed price for specific events.

Learn more: https://docs.apify.com/platform/actors/running/actors-in-store#pay-per-event

## What's an Apify Actor?

Actors are a software tools running on the Apify platform, for all kinds of web data extraction and automation use cases.
In Batch mode, an Actor accepts a well-defined JSON input, performs an action which can take anything from a few seconds to a few hours,
and optionally produces a well-defined JSON output, datasets with results, or files in key-value store.
In Standby mode, an Actor provides a web server which can be used as a website, API, or an MCP server.
Actors are written with capital "A".

## How to integrate an Actor?

If asked about integration, you help developers integrate Actors into their projects.
You adapt to their stack and deliver integrations that are safe, well-documented, and production-ready.
The best way to integrate Actors is as follows.

In JavaScript/TypeScript projects, use official [JavaScript/TypeScript client](https://docs.apify.com/api/client/js.md):

```bash
npm install apify-client
```

In Python projects, use official [Python client library](https://docs.apify.com/api/client/python.md):

```bash
pip install apify-client
```

In shell scripts, use [Apify CLI](https://docs.apify.com/cli/docs.md):

````bash
# MacOS / Linux
curl -fsSL https://apify.com/install-cli.sh | bash
# Windows
irm https://apify.com/install-cli.ps1 | iex
```bash

In AI frameworks, you might use the [Apify MCP server](https://docs.apify.com/platform/integrations/mcp.md).

If your project is in a different language, use the [REST API](https://docs.apify.com/api/v2.md).

For usage examples, see the [API](#api) section below.

For more details, see Apify documentation as [Markdown index](https://docs.apify.com/llms.txt) and [Markdown full-text](https://docs.apify.com/llms-full.txt).


# README

## Yahoo Finance Historical OHLCV Data

Fetch clean historical OHLCV candles from Yahoo Finance for one or many ticker symbols. Results are written as stable JSON rows to the Apify default dataset, ready for backtests, dashboards, spreadsheets, and data pipelines.

### Input

Input:

```json
{
  "tickers": ["AAPL", "MSFT"],
  "start_date": "2024-01-02",
  "end_date": "2024-01-05",
  "interval": "1d",
  "priceAdjustment": "adjusted"
}
````

`start_date` is inclusive. `end_date` is exclusive, matching yfinance behavior, so `end_date: "2024-01-05"` returns trading days before January 5. `interval` defaults to `1d`. Provide one or more ticker symbols in `tickers`.

`priceAdjustment` defaults to `adjusted`, which applies the Yahoo `Adj Close / Close` ratio to Open, High, Low, and Close. Use `raw` if you want unadjusted Yahoo chart OHLC prices.

Supported intervals include `1m`, `2m`, `5m`, `15m`, `30m`, `60m`, `90m`, `1h`, `1d`, `5d`, `1wk`, `1mo`, and `3mo`.

Proxy retry modes:

```json
{
  "tickers": ["AAPL", "MSFT"],
  "start_date": "2024-01-02",
  "end_date": "2024-01-05",
  "interval": "1d",
  "priceAdjustment": "adjusted",
  "proxyMode": "auto",
  "proxyCountryCode": "US",
  "proxyMaxAttempts": 5
}
```

`proxyMode` controls Apify Proxy usage:

- `auto` tries Yahoo Finance directly first. If Yahoo returns `403`, `429`, or a `5xx` response, the Actor falls back to Apify Proxy and retries with fresh proxy sessions.
- `on` always sends Yahoo Finance requests through Apify Proxy.
- `off` never uses Apify Proxy. A direct `403` fails immediately because retrying would reuse the same blocked IP.

`proxyGroups` is optional. Leave it empty to let Apify use an available proxy group, or set it to a group you know your account can access, such as `["RESIDENTIAL"]`.

### Output

Each dataset item represents one requested ticker. The shape is intentionally close to common Yahoo Finance Actors that group quote metadata and history together:

```json
{
  "ticker": "AAPL",
  "resolved_symbol": "AAPL",
  "stock_info": {
    "symbol": "AAPL",
    "name": "N/A",
    "quote_type": "EQUITY",
    "sector": "N/A",
    "industry": "N/A",
    "market_cap": "N/A",
    "current_price": 183.56,
    "previous_close": "N/A",
    "day_high": "N/A",
    "day_low": "N/A",
    "volume": 82488700,
    "pe_ratio": "N/A",
    "dividend_yield": "N/A",
    "beta": "N/A"
  },
  "price_info": {
    "symbol": "AAPL",
    "current_price": 183.56,
    "previous_close": "N/A",
    "change": "N/A",
    "change_percent": "N/A",
    "timestamp": "2026-07-05T03:30:00.000Z"
  },
  "history": {
    "symbol": "AAPL",
    "period": "custom",
    "interval": "1d",
    "start": "2024-01-02",
    "end": "2024-01-05",
    "data": [
      {
        "date": "2024-01-02",
        "open": 185.06,
        "high": 186.33,
        "low": 181.83,
        "close": 183.56,
        "volume": 82488700
      }
    ]
  }
}
```

The key-value store `OUTPUT` record contains a compact run summary with requested symbols, dataset item count, OHLCV row count, interval, and timestamp range.

### Local Run

```bash
npm ci
npm start
```

Local input lives at `storage/key_value_stores/default/INPUT.json`. Output rows are written to `storage/datasets/default`.

### Smoke Test

```bash
npm run smoke:local
```

The smoke test clears local storage, runs the Actor with an AAPL date range, then asserts that the dataset contains real Yahoo Finance OHLCV rows with the requested symbol and interval.

If Yahoo Finance returns HTTP `403` or `429` locally, the test fails intentionally. That means the current network/IP is blocked or rate limited, not that demo data was accepted. Use the Apify smoke test below to verify the real run plus default dataset flow from Apify cloud.

### Deploy To Apify

```bash
export APIFY_TOKEN="your token"
npx apify login --token "$APIFY_TOKEN"
npm run apify:push
```

After the push, set `APIFY_ACTOR_ID` to the Actor id shown by Apify, usually `username/yahoo-finance-ohlcv`.

### Apify Smoke Test

```bash
export APIFY_TOKEN="your token"
export APIFY_ACTOR_ID="username/yahoo-finance-ohlcv"
npm run smoke:apify
```

This uses the stable Actor run plus default dataset flow: it waits for a successful run, fetches items from that run's dataset, and fails if the dataset is empty or does not match the requested Yahoo Finance symbol/interval.

To smoke test the Apify Proxy path:

```bash
export SMOKE_PROXY_MODE=on
export SMOKE_PROXY_GROUPS="RESIDENTIAL"
export SMOKE_PROXY_COUNTRY_CODE="US"
npm run smoke:apify
```

To smoke test the automatic fallback path, use `SMOKE_PROXY_MODE=auto`.

# Actor input Schema

## `tickers` (type: `array`):

Yahoo Finance ticker symbols, for example AAPL, MSFT, QQQ, ^GSPC, or BTC-USD.

## `start_date` (type: `string`):

Inclusive start date in YYYY-MM-DD format.

## `end_date` (type: `string`):

Exclusive end date in YYYY-MM-DD format, matching yfinance behavior.

## `interval` (type: `string`):

Yahoo Finance chart interval.

## `priceAdjustment` (type: `string`):

Controls OHLC price adjustment. Adjusted matches yfinance auto\_adjust behavior by applying Adj Close / Close to Open, High, Low, and Close.

## `proxyMode` (type: `string`):

Controls when to use Apify Proxy. Auto tries Yahoo Finance directly first, then falls back to Apify Proxy for HTTP 403, 429, and 5xx responses. On always uses Apify Proxy. Off never uses Apify Proxy.

## `proxyGroups` (type: `array`):

Optional Apify Proxy groups to use, for example RESIDENTIAL. Leave empty to let Apify choose from available proxy groups.

## `proxyCountryCode` (type: `string`):

Optional two-letter country code for Apify Proxy geolocation, for example US.

## `proxyMaxAttempts` (type: `integer`):

Maximum attempts per Yahoo Finance host. With Apify Proxy enabled, each retry uses a fresh proxy session.

## Actor input object example

```json
{
  "tickers": [
    "AAPL",
    "MSFT"
  ],
  "start_date": "2024-01-02",
  "end_date": "2024-01-05",
  "interval": "1d",
  "priceAdjustment": "adjusted",
  "proxyMode": "auto",
  "proxyCountryCode": "US",
  "proxyMaxAttempts": 5
}
```

# Actor output Schema

## `results` (type: `string`):

One clean result object per requested ticker, with stock\_info, price\_info, and nested history.data OHLCV rows.

## `summary` (type: `string`):

Compact JSON summary with item count, requested symbols, per-symbol counts, interval, and timestamp range.

# API

You can run this Actor programmatically using our API. Below are code examples in JavaScript, Python, and CLI, as well as the OpenAPI specification and MCP server setup.

## JavaScript example

```javascript
import { ApifyClient } from 'apify-client';

// Initialize the ApifyClient with your Apify API token
// Replace the '<YOUR_API_TOKEN>' with your token
const client = new ApifyClient({
    token: '<YOUR_API_TOKEN>',
});

// Prepare Actor input
const input = {
    "tickers": [
        "AAPL",
        "MSFT"
    ],
    "start_date": "2024-01-02",
    "end_date": "2024-01-05",
    "proxyCountryCode": "US"
};

// Run the Actor and wait for it to finish
const run = await client.actor("superhero99999/yahoo-finance-ohlcv").call(input);

// Fetch and print Actor results from the run's dataset (if any)
console.log('Results from dataset');
console.log(`💾 Check your data here: https://console.apify.com/storage/datasets/${run.defaultDatasetId}`);
const { items } = await client.dataset(run.defaultDatasetId).listItems();
items.forEach((item) => {
    console.dir(item);
});

// 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/js/docs

```

## Python example

```python
from apify_client import ApifyClient

# Initialize the ApifyClient with your Apify API token
# Replace '<YOUR_API_TOKEN>' with your token.
client = ApifyClient("<YOUR_API_TOKEN>")

# Prepare the Actor input
run_input = {
    "tickers": [
        "AAPL",
        "MSFT",
    ],
    "start_date": "2024-01-02",
    "end_date": "2024-01-05",
    "proxyCountryCode": "US",
}

# Run the Actor and wait for it to finish
run = client.actor("superhero99999/yahoo-finance-ohlcv").call(run_input=run_input)

# Fetch and print Actor results from the run's dataset (if there are any)
print("💾 Check your data here: https://console.apify.com/storage/datasets/" + run["defaultDatasetId"])
for item in client.dataset(run["defaultDatasetId"]).iterate_items():
    print(item)

# 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/python/docs/quick-start

```

## CLI example

```bash
echo '{
  "tickers": [
    "AAPL",
    "MSFT"
  ],
  "start_date": "2024-01-02",
  "end_date": "2024-01-05",
  "proxyCountryCode": "US"
}' |
apify call superhero99999/yahoo-finance-ohlcv --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "command": "npx",
            "args": [
                "mcp-remote",
                "https://mcp.apify.com/?tools=superhero99999/yahoo-finance-ohlcv",
                "--header",
                "Authorization: Bearer <YOUR_API_TOKEN>"
            ]
        }
    }
}

```

## OpenAPI specification

```json
{
    "openapi": "3.0.1",
    "info": {
        "title": "Yahoo Finance Historical Stock Price",
        "description": "Fetch clean historical OHLCV candles from Yahoo Finance for one or many tickers. Supports daily and intraday intervals and returns stable JSON rows in the default dataset.",
        "version": "0.1",
        "x-build-id": "fUItpRHVGOuUTuTax"
    },
    "servers": [
        {
            "url": "https://api.apify.com/v2"
        }
    ],
    "paths": {
        "/acts/superhero99999~yahoo-finance-ohlcv/run-sync-get-dataset-items": {
            "post": {
                "operationId": "run-sync-get-dataset-items-superhero99999-yahoo-finance-ohlcv",
                "x-openai-isConsequential": false,
                "summary": "Executes an Actor, waits for its completion, and returns Actor's dataset items in response.",
                "tags": [
                    "Run Actor"
                ],
                "requestBody": {
                    "required": true,
                    "content": {
                        "application/json": {
                            "schema": {
                                "$ref": "#/components/schemas/inputSchema"
                            }
                        }
                    }
                },
                "parameters": [
                    {
                        "name": "token",
                        "in": "query",
                        "required": true,
                        "schema": {
                            "type": "string"
                        },
                        "description": "Enter your Apify token here"
                    }
                ],
                "responses": {
                    "200": {
                        "description": "OK"
                    }
                }
            }
        },
        "/acts/superhero99999~yahoo-finance-ohlcv/runs": {
            "post": {
                "operationId": "runs-sync-superhero99999-yahoo-finance-ohlcv",
                "x-openai-isConsequential": false,
                "summary": "Executes an Actor and returns information about the initiated run in response.",
                "tags": [
                    "Run Actor"
                ],
                "requestBody": {
                    "required": true,
                    "content": {
                        "application/json": {
                            "schema": {
                                "$ref": "#/components/schemas/inputSchema"
                            }
                        }
                    }
                },
                "parameters": [
                    {
                        "name": "token",
                        "in": "query",
                        "required": true,
                        "schema": {
                            "type": "string"
                        },
                        "description": "Enter your Apify token here"
                    }
                ],
                "responses": {
                    "200": {
                        "description": "OK",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/runsResponseSchema"
                                }
                            }
                        }
                    }
                }
            }
        },
        "/acts/superhero99999~yahoo-finance-ohlcv/run-sync": {
            "post": {
                "operationId": "run-sync-superhero99999-yahoo-finance-ohlcv",
                "x-openai-isConsequential": false,
                "summary": "Executes an Actor, waits for completion, and returns the OUTPUT from Key-value store in response.",
                "tags": [
                    "Run Actor"
                ],
                "requestBody": {
                    "required": true,
                    "content": {
                        "application/json": {
                            "schema": {
                                "$ref": "#/components/schemas/inputSchema"
                            }
                        }
                    }
                },
                "parameters": [
                    {
                        "name": "token",
                        "in": "query",
                        "required": true,
                        "schema": {
                            "type": "string"
                        },
                        "description": "Enter your Apify token here"
                    }
                ],
                "responses": {
                    "200": {
                        "description": "OK"
                    }
                }
            }
        }
    },
    "components": {
        "schemas": {
            "inputSchema": {
                "type": "object",
                "required": [
                    "tickers",
                    "start_date",
                    "end_date"
                ],
                "properties": {
                    "tickers": {
                        "title": "Tickers",
                        "maxItems": 50,
                        "type": "array",
                        "description": "Yahoo Finance ticker symbols, for example AAPL, MSFT, QQQ, ^GSPC, or BTC-USD.",
                        "items": {
                            "type": "string"
                        }
                    },
                    "start_date": {
                        "title": "Start date",
                        "pattern": "^\\d{4}-\\d{2}-\\d{2}$",
                        "type": "string",
                        "description": "Inclusive start date in YYYY-MM-DD format."
                    },
                    "end_date": {
                        "title": "End date",
                        "pattern": "^\\d{4}-\\d{2}-\\d{2}$",
                        "type": "string",
                        "description": "Exclusive end date in YYYY-MM-DD format, matching yfinance behavior."
                    },
                    "interval": {
                        "title": "Interval",
                        "enum": [
                            "1d",
                            "5d",
                            "1wk",
                            "1mo",
                            "3mo",
                            "1h",
                            "60m",
                            "90m",
                            "30m",
                            "15m",
                            "5m",
                            "2m",
                            "1m"
                        ],
                        "type": "string",
                        "description": "Yahoo Finance chart interval.",
                        "default": "1d"
                    },
                    "priceAdjustment": {
                        "title": "Price adjustment",
                        "enum": [
                            "adjusted",
                            "raw"
                        ],
                        "type": "string",
                        "description": "Controls OHLC price adjustment. Adjusted matches yfinance auto_adjust behavior by applying Adj Close / Close to Open, High, Low, and Close.",
                        "default": "adjusted"
                    },
                    "proxyMode": {
                        "title": "Proxy mode",
                        "enum": [
                            "auto",
                            "on",
                            "off"
                        ],
                        "type": "string",
                        "description": "Controls when to use Apify Proxy. Auto tries Yahoo Finance directly first, then falls back to Apify Proxy for HTTP 403, 429, and 5xx responses. On always uses Apify Proxy. Off never uses Apify Proxy.",
                        "default": "auto"
                    },
                    "proxyGroups": {
                        "title": "Proxy groups",
                        "type": "array",
                        "description": "Optional Apify Proxy groups to use, for example RESIDENTIAL. Leave empty to let Apify choose from available proxy groups.",
                        "items": {
                            "type": "string"
                        }
                    },
                    "proxyCountryCode": {
                        "title": "Proxy country code",
                        "pattern": "^[A-Za-z]{2}$",
                        "type": "string",
                        "description": "Optional two-letter country code for Apify Proxy geolocation, for example US."
                    },
                    "proxyMaxAttempts": {
                        "title": "Proxy max attempts",
                        "minimum": 1,
                        "maximum": 20,
                        "type": "integer",
                        "description": "Maximum attempts per Yahoo Finance host. With Apify Proxy enabled, each retry uses a fresh proxy session.",
                        "default": 5
                    }
                }
            },
            "runsResponseSchema": {
                "type": "object",
                "properties": {
                    "data": {
                        "type": "object",
                        "properties": {
                            "id": {
                                "type": "string"
                            },
                            "actId": {
                                "type": "string"
                            },
                            "userId": {
                                "type": "string"
                            },
                            "startedAt": {
                                "type": "string",
                                "format": "date-time",
                                "example": "2025-01-08T00:00:00.000Z"
                            },
                            "finishedAt": {
                                "type": "string",
                                "format": "date-time",
                                "example": "2025-01-08T00:00:00.000Z"
                            },
                            "status": {
                                "type": "string",
                                "example": "READY"
                            },
                            "meta": {
                                "type": "object",
                                "properties": {
                                    "origin": {
                                        "type": "string",
                                        "example": "API"
                                    },
                                    "userAgent": {
                                        "type": "string"
                                    }
                                }
                            },
                            "stats": {
                                "type": "object",
                                "properties": {
                                    "inputBodyLen": {
                                        "type": "integer",
                                        "example": 2000
                                    },
                                    "rebootCount": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "restartCount": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "resurrectCount": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "computeUnits": {
                                        "type": "integer",
                                        "example": 0
                                    }
                                }
                            },
                            "options": {
                                "type": "object",
                                "properties": {
                                    "build": {
                                        "type": "string",
                                        "example": "latest"
                                    },
                                    "timeoutSecs": {
                                        "type": "integer",
                                        "example": 300
                                    },
                                    "memoryMbytes": {
                                        "type": "integer",
                                        "example": 1024
                                    },
                                    "diskMbytes": {
                                        "type": "integer",
                                        "example": 2048
                                    }
                                }
                            },
                            "buildId": {
                                "type": "string"
                            },
                            "defaultKeyValueStoreId": {
                                "type": "string"
                            },
                            "defaultDatasetId": {
                                "type": "string"
                            },
                            "defaultRequestQueueId": {
                                "type": "string"
                            },
                            "buildNumber": {
                                "type": "string",
                                "example": "1.0.0"
                            },
                            "containerUrl": {
                                "type": "string"
                            },
                            "usage": {
                                "type": "object",
                                "properties": {
                                    "ACTOR_COMPUTE_UNITS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATASET_READS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATASET_WRITES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "KEY_VALUE_STORE_READS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "KEY_VALUE_STORE_WRITES": {
                                        "type": "integer",
                                        "example": 1
                                    },
                                    "KEY_VALUE_STORE_LISTS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "REQUEST_QUEUE_READS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "REQUEST_QUEUE_WRITES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATA_TRANSFER_INTERNAL_GBYTES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATA_TRANSFER_EXTERNAL_GBYTES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "PROXY_RESIDENTIAL_TRANSFER_GBYTES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "PROXY_SERPS": {
                                        "type": "integer",
                                        "example": 0
                                    }
                                }
                            },
                            "usageTotalUsd": {
                                "type": "number",
                                "example": 0.00005
                            },
                            "usageUsd": {
                                "type": "object",
                                "properties": {
                                    "ACTOR_COMPUTE_UNITS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATASET_READS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATASET_WRITES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "KEY_VALUE_STORE_READS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "KEY_VALUE_STORE_WRITES": {
                                        "type": "number",
                                        "example": 0.00005
                                    },
                                    "KEY_VALUE_STORE_LISTS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "REQUEST_QUEUE_READS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "REQUEST_QUEUE_WRITES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATA_TRANSFER_INTERNAL_GBYTES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATA_TRANSFER_EXTERNAL_GBYTES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "PROXY_RESIDENTIAL_TRANSFER_GBYTES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "PROXY_SERPS": {
                                        "type": "integer",
                                        "example": 0
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
    }
}
```
