quantdata.yahoo.client#
Yahoo finance
- class quantdata.yahoo.client.YFConnectionConfig(max_retries=5, timeout=1.0)[source]#
Bases:
objectConfiguration for managing yfinance/yaoo connectivity
- exception quantdata.yahoo.client.DataError[source]#
Bases:
ExceptionException raised when data retrieved from yahoo is inconsistent or insufficient.
- class quantdata.yahoo.client.YFClient[source]#
Bases:
objectYahoo Finance Client
- NO_EARNINGS_TYPES = {'CRYPTOCURRENCY', 'CURRENCY', 'ETF', 'FUTURE', 'INDEX', 'MUTUALFUND', 'OPTION'}#
Instrument types which do not have earnings
- SCHEMA_HAS_EARNINGS = {'date': Date, 'is_earnings': Boolean}#
Schema for the
pandas.DataFramereturned byhas_earnings()
- has_earnings(ticker, start, end)[source]#
Use yfinance to get earnings dates and ex-dividend dates for a ticker.
- PRICE_FIELDS = {'Close', 'Dividends', 'High', 'Low', 'Open', 'Stock Splits', 'Volume'}#
Fields returned by
prices()and expected to be present in the data frame returned by yahoo.
- prices(ticker, start, end, *, yfconnection_config=YFConnectionConfig(max_retries=5, timeout=1.0))[source]#
Downloads one ticker from yahoo using yfinance and applies some basic consistency checks.
The function returns a pandas data frame with the fields
Close,High,Low,Open,Volume,DividendsandStock Splits, see alsoPRICE_FIELDS. The index of the data frame are the historic dates. All rows with NaNs are removed.Checks performed:
All required fields are present.
Close, Low, High, Open are positive
High > Low (please note yahoo data does not include Open/Close in Low/High)
- Parameters:
ticker (
str) – Ticker such asAAPL.start (
date) – Start of the period.end (
date) – End of the period.yfconnection_config (
YFConnectionConfig) – Configuration for managing yfinance/yaoo connectivity, such as timeouts and retry counts.
- Returns:
Result – Non-empty dataframe with the data from yahoo. Its index are the historic dates.
- Return type:
:raises Inconsistent data returned :
AttributeError: Raised if the data returned from yahoo did not contain the expected column headers. :raises Timeout :TimeoutError: Raised if yf.downloadtimed out.
- Raises:
Data error –
DataError: Raised if data validation fails.