Skip to main content
Retrieve historical price and volume data for a single ticker symbol with extensive customization options.

Parameters

ticker
string
required
Ticker symbol (e.g., ‘AAPL’, ‘MSFT’). Must be a valid stock symbol.
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.
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_ticker_history-{timestamp}.{format})

Example Usage

Get 1 year of daily data

{
  "ticker": "AAPL",
  "period": "1y",
  "interval": "1d"
}

Get historical data with custom date range

{
  "ticker": "TSLA",
  "start": "2024-01-01",
  "end": "2024-06-30",
  "interval": "1d"
}

Get intraday data with pre/post market

{
  "ticker": "MSFT",
  "period": "1d",
  "interval": "5m",
  "prepost": true
}

Get data with dividend and split actions

{
  "ticker": "GOOGL",
  "period": "2y",
  "actions": true,
  "auto_adjust": false
}

Get all-time data and save to CSV

{
  "ticker": "SPY",
  "period": "max",
  "interval": "1wk",
  "save": {
    "format": "csv",
    "filename": "spy_weekly.csv"
  }
}

Get data with repair and keep NaN values

{
  "ticker": "NVDA",
  "period": "6mo",
  "repair": true,
  "keepna": true
}

Response Format

JSON Response (default)

The response contains a data field with the historical data and an optional saved_path:
{
  "data": {
    "__type__": "dataframe",
    "columns": ["Open", "High", "Low", "Close", "Volume"],
    "index": ["2024-01-01", "2024-01-02", "..."],
    "data": [
      [180.0, 182.5, 179.0, 181.5, 75000000],
      [181.5, 184.0, 181.0, 183.0, 72000000]
    ]
  },
  "saved_path": null
}

With Actions

When actions is true, the response includes additional columns:
{
  "data": {
    "__type__": "dataframe",
    "columns": ["Open", "High", "Low", "Close", "Volume", "Dividends", "Stock Splits"],
    "index": ["2024-01-01", "2024-02-15"],
    "data": [
      [180.0, 182.5, 179.0, 181.5, 75000000, 0.0, 0.0],
      [181.5, 184.0, 181.0, 183.0, 72000000, 0.25, 0.0]
    ]
  },
  "saved_path": null
}

Markdown Response

When response_format is set to markdown:
index | Open | High | Low | Close | Volume
--- | --- | --- | --- | --- | ---
2024-01-01 | 180.0 | 182.5 | 179.0 | 181.5 | 75000000
2024-01-02 | 181.5 | 184.0 | 181.0 | 183.0 | 72000000

Notes

  • Use period for relative time ranges or start/end for absolute dates, but not both
  • Intraday intervals (1m, 5m, etc.) have limited historical availability (typically 1-60 days)
  • The prepost parameter only works with intraday intervals
  • The auto_adjust parameter is recommended for price continuity across corporate actions
  • The repair option can fix common data quality issues like missing values or outliers
  • When keepna is false, rows with missing data are automatically removed

Build docs developers (and LLMs) love