Parameters
Space-separated ticker symbols (e.g., ‘SPY AAPL MSFT’). Must contain at least one ticker.
Time period to retrieve. Valid values include:
1d,5d,1mo,3mo,6mo,1y,2y,5y,10y,ytd,max
start and end parameters.Data interval/granularity. Valid values include:
1m,2m,5m,15m,30m,60m,90m,1h,1d,5d,1wk,1mo,3mo
1d (daily).Start date for the historical data (format: YYYY-MM-DD). Use with
end instead of period.End date for the historical data (format: YYYY-MM-DD). Use with
start instead of period.Automatically adjust OHLC (Open, High, Low, Close) data for splits and dividends. Default is
true.Include dividend and split events in the data. Default is
false.Include pre-market and post-market trading data. Default is
false. Only available for intraday intervals.Repair bad data (missing values, outliers) using yfinance’s repair logic. Default is
false.Keep rows with NaN values instead of dropping them. Default is
false.How to organize the returned data:
column: Group by data columns (Open, High, Low, Close, etc.) - each column contains data for all tickersticker: Group by ticker symbol - each ticker has its own set of columns
Format of the response:
json(default): Return structured JSON datamarkdown: Return formatted markdown table
Number of rows to include in markdown preview. Must be between 1 and 200. Default is 25.
Save the result to a file:
format: Eithercsvorjsonfilename(optional): Custom filename (defaults toyf_tickers_history-{timestamp}.{format})
Example Usage
Get data for multiple tickers grouped by column
Get data grouped by ticker
Get data with custom date range
Get intraday data for multiple tickers
Compare tickers and save to CSV
Get historical data with actions
Response Format
JSON Response with group_by: "column" (default)
Data is organized by price/volume columns, with each ticker as a sub-column:
JSON Response with group_by: "ticker"
Data is organized by ticker, with each ticker having its own set of OHLCV columns:
Markdown Response
Whenresponse_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
periodfor relative time ranges orstart/endfor absolute dates, but not both - The
group_byparameter is essential for organizing multi-ticker data effectively - Intraday intervals (1m, 5m, etc.) have limited historical availability
- The
prepostparameter 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