py_alpaca_api.stock.assets ========================== .. py:module:: py_alpaca_api.stock.assets Exceptions ---------- .. autoapisummary:: py_alpaca_api.stock.assets.APIRequestError Classes ------- .. autoapisummary:: py_alpaca_api.stock.assets.Requests py_alpaca_api.stock.assets.AssetModel py_alpaca_api.stock.assets.Assets Functions --------- .. autoapisummary:: py_alpaca_api.stock.assets.asset_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: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:: AssetModel .. py:attribute:: id :type: str .. py:attribute:: asset_class :type: str .. py:attribute:: easy_to_borrow :type: bool .. py:attribute:: exchange :type: str .. py:attribute:: fractionable :type: bool .. py:attribute:: maintenance_margin_requirement :type: float .. py:attribute:: marginable :type: bool .. py:attribute:: name :type: str .. py:attribute:: shortable :type: bool .. py:attribute:: status :type: str .. py:attribute:: symbol :type: str .. py:attribute:: tradable :type: bool .. py:function:: asset_class_from_dict(data_dict: dict) -> AssetModel Create AssetModel from dictionary data. :param data_dict: A dictionary containing the data for creating an instance of AssetModel. :returns: An instance of the AssetModel class. :raises None: .. py:class:: Assets(base_url: str, headers: dict[str, str]) .. py:method:: get(symbol: str) -> py_alpaca_api.models.asset_model.AssetModel Retrieves an AssetModel for the specified symbol. :param symbol: The symbol of the asset to retrieve. :type symbol: str :returns: The AssetModel for the specified asset. :rtype: AssetModel :raises Exception: If the asset is not a US Equity (stock). .. py:method:: get_all(status: str = 'active', exchange: str = '', excluded_exchanges: list[str] | None = None) -> pandas.DataFrame Retrieves a DataFrame of all active, fractionable, and tradable assets. Excluding those from the OTC exchange. :param status: The status of the assets to retrieve. Defaults to "active". :type status: str, optional :param exchange: The exchange to filter the assets by. Defaults to an empty string, which retrieves assets from all exchanges. :type exchange: str, optional :param excluded_exchanges: A list of exchanges to exclude from the results. Defaults to ["OTC"]. :type excluded_exchanges: List[str], optional :returns: A DataFrame containing the retrieved assets. :rtype: pd.DataFrame