py_alpaca_api.trading.news
Attributes
Classes
Module Contents
- class py_alpaca_api.trading.news.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.trading.news.News(headers: dict[str, str])[source]
-
- get_news(symbol: str, limit: int = 6) list[dict[str, str]][source]
Retrieves news articles related to a given symbol from Benzinga and Yahoo Finance.
Note: Yahoo Finance has implemented anti-scraping measures that prevent fetching full article content. Yahoo news will include title, URL, publish date, and summary/description when available, but not full article text.