py_alpaca_api.stock.latest_quote

Classes

Requests

QuoteModel

LatestQuote

Functions

quote_class_from_dict(→ QuoteModel)

param data_dict:

A dictionary containing data for creating an instance of QuoteModel.

Module Contents

class py_alpaca_api.stock.latest_quote.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.latest_quote.QuoteModel[source]
symbol: str
timestamp: datetime.datetime
ask: float
ask_size: int
bid: float
bid_size: int
py_alpaca_api.stock.latest_quote.quote_class_from_dict(data_dict: dict) QuoteModel[source]
Parameters:

data_dict – A dictionary containing data for creating an instance of QuoteModel.

Returns:

An instance of QuoteModel created using the data from data_dict.

Raises:

None.

class py_alpaca_api.stock.latest_quote.LatestQuote(headers: dict[str, str])[source]
BATCH_SIZE = 200[source]
get(symbol: list[str] | str | None, feed: str = 'iex', currency: str = 'USD') list[py_alpaca_api.models.quote_model.QuoteModel] | py_alpaca_api.models.quote_model.QuoteModel[source]

Get latest quotes for one or more symbols.

Parameters:
  • symbol – A string or list of strings representing the stock symbol(s).

  • feed – The data feed source. Default is “iex”.

  • currency – The currency for the quotes. Default is “USD”.

Returns:

A single QuoteModel or list of QuoteModel objects.

Raises:

ValueError – If symbol is None/empty or if feed is invalid.