Some platforms (e.g. older macOS, exotic Linux distros) cannot build the
curl-impersonate binary that backs curl_cffi, leaving yfinance unusable.
This change keeps curl_cffi as the preferred and default backend but no
longer hard-requires it at runtime.
- New `yfinance/_http.py` abstracts the HTTP backend. If `curl_cffi` is
importable it is used as before; otherwise yfinance falls back to plain
`requests` with a realistic Chrome User-Agent and logs a warning so the
downgrade is explicit.
- `data.py`, `base.py`, `multi.py`, `scrapers/history.py` build sessions
via `_http.new_session()`.
- Scrapers and screener catch `_http.HTTPError` instead of importing
`curl_cffi.requests.exceptions.HTTPError` directly.
- `is_supported_session()` accepts either backend; `cookie_jar()` papers
over the small API difference between curl_cffi (`cookies.jar`) and
requests (`cookies` is itself the jar).
- New Advanced > Installation page documents the curl_cffi-free install
recipe; README links to it just under the install instruction.
Empirically verified that plain `requests` with a Chrome UA does not hit
the 401-after-~10-requests issue that the earlier `curl_adapter` approach
ran into; 15/15 quoteSummary calls succeed without rate limiting.
`setup.py` is unchanged -- `curl_cffi>=0.15` remains the default install
requirement (CVE-pinned). The fallback only activates when the import
fails at runtime; moving curl_cffi to extras_require can be a follow-up
decision for the maintainer.
Yahoo's v7 (`/v7/quote`) and v10 (`/quoteSummary`) endpoints accept
`lang` and `region` parameters and return localized fields (`longName`,
`shortName`, ...) when the ticker has been translated for that locale —
e.g. 1810.HK returns '小米集團-W' under `lang=zh-Hant-HK`, GAZP.ME
returns 'Публичное акционерное общество Газпром' under `lang=ru-RU`.
Previously these params were not exposed and `Ticker.info["longName"]`
always came back in U.S. English.
Surfaced as global config (`YfConfig.locale.lang` / `YfConfig.locale.region`)
rather than per-Ticker constructor params: a typical user wants the
same locale for every call in their session, and the config approach
also covers the v10 calendar/earnings endpoint in `_fetch_history_metadata`
without threading kwargs through three layers.
- Add `YfConfig.locale.lang` (default `"en-US"`) and `YfConfig.locale.region`
(default `"US"`).
- `Quote._fetch` (v10/quoteSummary) and `Quote._fetch_additional_info`
(v7/quote) read the locale from `YfConfig` on every call.
- `_fetch_history_metadata` (v1 calendar) reads the same locale, replacing
a hardcoded `lang=en-US, region=US`.
- The `v8/chart` endpoint ignores `lang` server-side, so we don't forward
there — would only generate noise.
- Verified live for Latin/diacritics (it-IT), CJK (zh-Hant-HK, ja-JP),
Cyrillic (ru-RU); Apple under ja-JP correctly stays "Apple Inc." since
it's a U.S. listing.
Closes#2582
Yahoo's `/v1/finance/sectors/{key}` and `/industries/{key}` endpoints accept
an ISO 3166-1 alpha-2 `region` query parameter and return regional top
companies/ETFs/funds accordingly. The Domain base class hard-coded `region=US`,
so `Sector("technology").top_companies` always returned U.S. names regardless
of the user's interest.
- Add `region: str = "US"` to `Domain.__init__` and propagate through
`Sector` and `Industry`.
- Normalize input via `.strip().upper()` so "us", " GB ", and "Fr" all work.
- Use `self._region` in the request params.
- Document and test the behavior.
Closes#2601
Yahoo's markettime endpoint silently ignores the `market` parameter and
always returns U.S. data, so `Market("EUROPE").status` previously returned
U.S. status while pretending to be European. The summary endpoint does
honor the parameter and is unaffected.
- Introduce `MarketRegion(str, Enum)` as the single source of truth for
the supported region values, exposed as `yfinance.MarketRegion`.
- Validate `Market(...)` input against the enum and raise `ValueError`
on unknown regions.
- Detect the markettime mismatch: when a non-`US` region is requested
but the response id is `us`, set `status` to `None` and log a warning
rather than returning misleading data.
- Document the markettime limitation and add tests covering validation
and the EUROPE/US fetch behavior.
Closes#2784
This change fixes some stray documentation issues. The first fix addresses a broken link within the file, while the second removes a line saying to go into the directory before running the sphinx command to build the documentation.
And update docs to support
- fix duplication of class attributes in methods block
- repurpose 'SECTOR_INDUSTY_MAPPING' to back new EquityQuery field 'industry'
- Fetches the TTM values for cash flow and income statement from Yahoo.
- Added tests test_ttm_income_statement and test_ttm_cash_flow.
- When trailing 12 months income statement is fetched Yahoo returns
income statement for last 5 quarters out of which only the latest is
fully populated. Rest have NaN values and can be ignored.
- get_financials_time_series when called with timescale trailing removes
from data frame the extra columns.
- Added quarterly_income_stmt to financials documentation
- Added ttm_income_stmt to financials documentation
- Added quarterly_cashflow to financials documentation
- Added ttm_cashflow to financials documentation
- screener now just a function, not a class
- add 'FundQuery' query class
- add 'IS-IN' operator
- fix 'GTE' & 'LTE' operators
- more exchanges
Predefined tweaks:
- convert predefined query strings to use EquityQuery (better docs)
- send predefined queries to Yahoo's predefined endpoint
- expose PREDEFINED_SCREENER_QUERIES via __init__.py
- screen() argument defaults don't apply to predefineds