py_alpaca_api.stock.quotes
Historical quotes functionality for Alpaca Market Data API.
Exceptions
Raised when input validation fails. |
Classes
Handles historical quote data retrieval from Alpaca API. |
Module Contents
- exception py_alpaca_api.stock.quotes.ValidationError[source]
Bases:
PyAlpacaAPIErrorRaised when input validation fails.
- class py_alpaca_api.stock.quotes.Requests[source]
- request(method: str, url: str, headers: dict[str, str] | None = None, params: dict[str, str | bool | float | int] | None = None, json: dict[str, Any] | None = None, raw_response: bool = False)[source]
Execute HTTP request with retry logic.
- Parameters:
method – A string representing the HTTP method to be used in the request.
url – A string representing the URL to send the request to.
headers – An optional dictionary containing the headers for the request.
params – An optional dictionary containing the query parameters for the request.
json – An optional dictionary containing the JSON payload for the request.
raw_response – If True, return the raw response object without status checks. Defaults to False.
- Returns:
The response object returned by the server.
- Raises:
APIRequestError – If the response status code is not one of the acceptable statuses (200, 204, 207) and raw_response is False.
- class py_alpaca_api.stock.quotes.Quotes(headers: dict[str, str])[source]
Handles historical quote data retrieval from Alpaca API.
- get_historical_quotes(symbols: str | list[str], start: str, end: str, limit: int = 10000, asof: str | None = None, feed: str = 'iex', page_token: str | None = None, sort: str = 'asc') pandas.DataFrame | dict[str, pandas.DataFrame][source]
Get historical quote data for one or more symbols.
Retrieves historical quote (bid/ask) data between specified dates.
- Parameters:
symbols – Symbol(s) to get quote data for. Can be a string for single symbol or list of strings for multiple symbols.
start – Start date/time in ISO 8601 format (e.g., “2021-01-01” or “2021-01-01T00:00:00Z”).
end – End date/time in ISO 8601 format.
limit – Maximum number of quotes to return per symbol. Defaults to 10000.
asof – As-of date for corporate actions adjustments in YYYY-MM-DD format.
feed – The data feed to use (“iex”, “sip”, or “otc”). Defaults to “iex”.
page_token – Pagination token from previous request.
sort – Sort order for results (“asc” or “desc”). Defaults to “asc”.
- Returns:
pd.DataFrame with quote data. For multiple symbols: dict mapping symbols to DataFrames with quote data.
- Return type:
For single symbol
- Raises:
ValidationError – If parameters are invalid.
Exception – If the API request fails or returns no data.