py_alpaca_api.stock.auctions

Historical auctions functionality for Alpaca Market Data API.

Exceptions

ValidationError

Raised when input validation fails.

Classes

Requests

Auctions

Handles historical auction data retrieval from Alpaca API.

Module Contents

exception py_alpaca_api.stock.auctions.ValidationError[source]

Bases: PyAlpacaAPIError

Raised when input validation fails.

class py_alpaca_api.stock.auctions.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.auctions.Auctions(headers: dict[str, str])[source]

Handles historical auction data retrieval from Alpaca API.

get_auctions(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 auction data for one or more symbols.

Retrieves auction prices (opening and closing auctions) between specified dates.

Parameters:
  • symbols – Symbol(s) to get auction 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 auctions 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 auction data. For multiple symbols: dict mapping symbols to DataFrames with auction data.

Return type:

For single symbol

Raises:
get_daily_auctions(symbols: str | list[str], start: str, end: str, feed: str = 'iex') pandas.DataFrame | dict[str, pandas.DataFrame][source]

Get daily auction summary for one or more symbols.

Retrieves opening and closing auction prices aggregated by day.

Parameters:
  • symbols – Symbol(s) to get auction data for.

  • start – Start date in YYYY-MM-DD format.

  • end – End date in YYYY-MM-DD format.

  • feed – The data feed to use. Defaults to “iex”.

Returns:

DataFrame or dict of DataFrames with daily auction summaries.