py_alpaca_api.stock.snapshots ============================= .. py:module:: py_alpaca_api.stock.snapshots Exceptions ---------- .. autoapisummary:: py_alpaca_api.stock.snapshots.APIRequestError py_alpaca_api.stock.snapshots.ValidationError Classes ------- .. autoapisummary:: py_alpaca_api.stock.snapshots.Requests py_alpaca_api.stock.snapshots.SnapshotModel py_alpaca_api.stock.snapshots.Snapshots Functions --------- .. autoapisummary:: py_alpaca_api.stock.snapshots.snapshot_class_from_dict Module Contents --------------- .. py:exception:: APIRequestError(status_code: int | None = None, message: str = '') Bases: :py:obj:`PyAlpacaAPIError` Raised when an API request fails. .. py:exception:: ValidationError Bases: :py:obj:`PyAlpacaAPIError` Raised when input validation fails. .. py:class:: Requests .. py:method:: 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) Execute HTTP request with retry logic. :param method: A string representing the HTTP method to be used in the request. :param url: A string representing the URL to send the request to. :param headers: An optional dictionary containing the headers for the request. :param params: An optional dictionary containing the query parameters for the request. :param json: An optional dictionary containing the JSON payload for the request. :param 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. .. py:class:: SnapshotModel .. py:attribute:: symbol :type: str .. py:attribute:: latest_trade :type: py_alpaca_api.models.trade_model.TradeModel | None :value: None .. py:attribute:: latest_quote :type: py_alpaca_api.models.quote_model.QuoteModel | None :value: None .. py:attribute:: minute_bar :type: BarModel | None :value: None .. py:attribute:: daily_bar :type: BarModel | None :value: None .. py:attribute:: prev_daily_bar :type: BarModel | None :value: None .. py:function:: snapshot_class_from_dict(data: dict) -> SnapshotModel .. py:class:: Snapshots(headers: dict[str, str]) .. py:method:: get_snapshot(symbol: str, feed: str = 'iex') -> py_alpaca_api.models.snapshot_model.SnapshotModel Get a snapshot of a single stock symbol. The snapshot includes the latest trade, latest quote, minute bar, daily bar, and previous daily bar data. :param symbol: The stock symbol to get snapshot for. :param feed: The data feed to use ("iex", "sip", or "otc"). Defaults to "iex". :returns: A SnapshotModel containing the snapshot data. :raises ValidationError: If symbol is invalid or feed is invalid. :raises APIRequestError: If the API request fails. .. py:method:: get_snapshots(symbols: list[str] | str, feed: str = 'iex') -> list[py_alpaca_api.models.snapshot_model.SnapshotModel] | dict[str, py_alpaca_api.models.snapshot_model.SnapshotModel] Get snapshots for multiple stock symbols. The snapshot includes the latest trade, latest quote, minute bar, daily bar, and previous daily bar data for each symbol. :param symbols: A list of stock symbols or comma-separated string of symbols. :param feed: The data feed to use ("iex", "sip", or "otc"). Defaults to "iex". :returns: A dictionary mapping symbols to their SnapshotModel objects, or a list of SnapshotModel objects if only one symbol is provided. :raises ValidationError: If symbols are invalid or feed is invalid. :raises APIRequestError: If the API request fails.