Skip to main content
Retrieve historical price and volume data for multiple ticker symbols with flexible grouping options.

Parameters

tickers
string
required
Space-separated ticker symbols (e.g., ‘SPY AAPL MSFT’). Must contain at least one ticker.
period
string
Time period to retrieve. Valid values include:
  • 1d, 5d, 1mo, 3mo, 6mo, 1y, 2y, 5y, 10y, ytd, max
Cannot be used with start and end parameters.
interval
string
Data interval/granularity. Valid values include:
  • 1m, 2m, 5m, 15m, 30m, 60m, 90m, 1h, 1d, 5d, 1wk, 1mo, 3mo
Default is 1d (daily).
start
string
Start date for the historical data (format: YYYY-MM-DD). Use with end instead of period.
end
string
End date for the historical data (format: YYYY-MM-DD). Use with start instead of period.
auto_adjust
boolean
Automatically adjust OHLC (Open, High, Low, Close) data for splits and dividends. Default is true.
actions
boolean
Include dividend and split events in the data. Default is false.
prepost
boolean
Include pre-market and post-market trading data. Default is false. Only available for intraday intervals.
repair
boolean
Repair bad data (missing values, outliers) using yfinance’s repair logic. Default is false.
keepna
boolean
Keep rows with NaN values instead of dropping them. Default is false.
group_by
string
How to organize the returned data:
  • column: Group by data columns (Open, High, Low, Close, etc.) - each column contains data for all tickers
  • ticker: Group by ticker symbol - each ticker has its own set of columns
This parameter is critical for how you’ll access and analyze multi-ticker data.
response_format
string
Format of the response:
  • json (default): Return structured JSON data
  • markdown: Return formatted markdown table
preview_limit
number
Number of rows to include in markdown preview. Must be between 1 and 200. Default is 25.
save
object
Save the result to a file:
  • format: Either csv or json
  • filename (optional): Custom filename (defaults to yf_tickers_history-{timestamp}.{format})

Example Usage

Get data for multiple tickers grouped by column

{
  "tickers": "AAPL MSFT GOOGL",
  "period": "1y",
  "interval": "1d",
  "group_by": "column"
}

Get data grouped by ticker

{
  "tickers": "SPY QQQ IWM",
  "period": "6mo",
  "interval": "1d",
  "group_by": "ticker"
}

Get data with custom date range

{
  "tickers": "TSLA NVDA AMD",
  "start": "2024-01-01",
  "end": "2024-12-31",
  "interval": "1wk"
}

Get intraday data for multiple tickers

{
  "tickers": "AAPL MSFT",
  "period": "1d",
  "interval": "15m",
  "prepost": true,
  "group_by": "ticker"
}

Compare tickers and save to CSV

{
  "tickers": "SPY QQQ DIA",
  "period": "1y",
  "interval": "1d",
  "group_by": "column",
  "save": {
    "format": "csv",
    "filename": "etf_comparison.csv"
  }
}

Get historical data with actions

{
  "tickers": "JNJ PG KO",
  "period": "2y",
  "actions": true,
  "auto_adjust": false,
  "group_by": "ticker"
}

Response Format

JSON Response with group_by: "column" (default)

Data is organized by price/volume columns, with each ticker as a sub-column:
{
  "data": {
    "__type__": "dataframe",
    "columns": [
      ["Close", "AAPL"],
      ["Close", "MSFT"],
      ["Volume", "AAPL"],
      ["Volume", "MSFT"]
    ],
    "index": ["2024-01-01", "2024-01-02"],
    "data": [
      [180.0, 370.0, 75000000, 25000000],
      [181.5, 372.5, 72000000, 24000000]
    ]
  },
  "saved_path": null
}

JSON Response with group_by: "ticker"

Data is organized by ticker, with each ticker having its own set of OHLCV columns:
{
  "data": {
    "__type__": "dataframe",
    "columns": [
      ["AAPL", "Open"],
      ["AAPL", "High"],
      ["AAPL", "Close"],
      ["MSFT", "Open"],
      ["MSFT", "High"],
      ["MSFT", "Close"]
    ],
    "index": ["2024-01-01", "2024-01-02"],
    "data": [
      [179.0, 182.0, 180.0, 369.0, 372.0, 370.0],
      [180.5, 183.0, 181.5, 371.0, 374.0, 372.5]
    ]
  },
  "saved_path": null
}

Markdown Response

When response_format is set to markdown, returns a formatted table based on the group_by setting.

Understanding group_by

The group_by parameter determines how multi-ticker data is structured:

group_by: "column" (Wide format)

  • Each metric (Open, High, Low, Close, Volume) becomes a top-level grouping
  • Under each metric, you have columns for each ticker
  • Good for comparing the same metric across multiple tickers
  • Example structure: Close.AAPL, Close.MSFT, Volume.AAPL, Volume.MSFT

group_by: "ticker" (Long format)

  • Each ticker becomes a top-level grouping
  • Under each ticker, you have all metrics (Open, High, Low, Close, Volume)
  • Good for analyzing all metrics for each ticker separately
  • Example structure: AAPL.Open, AAPL.Close, MSFT.Open, MSFT.Close

Notes

  • Use period for relative time ranges or start/end for absolute dates, but not both
  • The group_by parameter is essential for organizing multi-ticker data effectively
  • Intraday intervals (1m, 5m, etc.) have limited historical availability
  • The prepost parameter only works with intraday intervals
  • Choose group_by: "column" for cross-ticker comparisons of specific metrics
  • Choose group_by: "ticker" for ticker-by-ticker analysis
  • All tickers use the same date range and interval settings

Build docs developers (and LLMs) love