Commit Graph

1065 Commits

Author SHA1 Message Date
ValueRaider 125b12e058 Version 1.4.1
Build and Deploy Sphinx Docs / build (push) Has been cancelled
zizmor / zizmor (push) Has been cancelled
2026-05-28 21:01:28 +01:00
Alessandro Colace c3db565d09 Preserve Date/Datetime index name in yf.download() output
reindex_dfs() rebuilt the combined index via sorted(set(...)) +
pd.to_datetime, dropping the index name set by history.py ('Date' for
daily, 'Datetime' for intraday). After concat, data.index.name was
None, so users doing data.stack().reset_index() got a 'level_0' column
instead of 'Date' / 'Datetime'.

Use Index.union, which preserves the name natively when sources agree.

Drive-by: narrow data.columns to MultiIndex before swaplevel to silence
a pyright attribute warning.
2026-05-25 22:20:29 +02:00
ValueRaider e005d2d562 Version 1.4.0 2026-05-23 17:20:05 +01:00
ValueRaider 54bef21e98 Fix tests 2026-05-23 14:46:39 +01:00
ValueRaider acd2c28a0c Merge branch 'dev' into fix/download-tz 2026-05-20 21:44:17 +01:00
ValueRaider 9ca1c55b12 Merge pull request #2802 from dokson/feature/optional-curl-cffi
Make curl_cffi optional with fallback to requests (closes #2692)
2026-05-20 21:34:45 +01:00
cloop-agent[bot] 628a417904 Merge pull request #2827 from ranaroussi/main
chore: merge main back into dev
2026-05-20 21:34:04 +01:00
Alessandro Colace 5d10c0c48e Make curl_cffi optional with graceful fallback to requests
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.
2026-05-20 14:17:02 +02:00
Alessandro Colace 593b47c36d Drop frozendict hard dependency in favour of an internal fallback 2026-05-20 14:08:25 +02:00
ValueRaider 7538c1fbd0 Fix localized intraday download() always returning UTC 2026-05-18 22:16:37 +01:00
ValueRaider 46ce563111 Merge pull request #2804 from dokson/feature/ticker-lang-region
Allow lang and region scoping for Ticker (closes #2582)
2026-05-17 20:16:57 +01:00
ValueRaider 71c03be45c Merge pull request #2810 from dokson/fix/extract-repair-ticker-overrides
Simplify phantom-dividend repair branch + drive-by typo/lint fixes
2026-05-17 20:15:25 +01:00
Alessandro Colace 0ffaa02f1c Simplify phantom-dividend repair branch + drive-by typo/lint fixes
- history.py: drop the hardcoded ['KAP.IL', 'SAND'] ticker whitelist
  from the phantom-dividend approval in _fix_bad_div_adjust. Per
  maintainer feedback on the original PR, the whitelist was leakage
  from a custom debug build and was never meant to be in main; phantom
  detections are safe to approve unconditionally in this branch.
- history.py: split a semicolon-joined statement that was failing
  ruff E702 in CI.
- domain/industry.py: fix `compnaies` → `companies` typo (8
  occurrences, local-variable rename only, no behavioural impact).
2026-05-15 17:27:36 +02:00
Alessandro Colace 97bdabe9dc Allow lang and region scoping for Ticker via YfConfig
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
2026-05-15 17:13:22 +02:00
ValueRaider 80e7cbda97 Merge pull request #2805 from dokson/fix/download-thread-safety
Make yf.download() reentrant by removing shared module globals
2026-05-14 22:14:29 +01:00
Alessandro Colace a710ba8340 Make yf.download() reentrant by removing shared module globals
`download()` used module-level dicts in `yfinance.shared` (`_DFS`,
`_ERRORS`, `_TRACEBACKS`, `_ISINS`) as scratch space. Concurrent calls
trampled each other; the previous fix wrapped the whole call in
`shared._LOCK`, which silently serialized parallel downloads — hiding
the race instead of removing it, and defeating the parallelism users
reach for `download()` to get.

- Introduce `_DownloadCtx` per call holding `dfs/errors/tracebacks/isins`
  plus a fine-grained lock for thread workers.
- `_download_one`, `_download_one_threaded`, `_realign_dfs` take the ctx
  explicitly and write into it.
- Drop the call-wide `shared._LOCK.acquire()`; concurrent `download()`
  calls now actually run in parallel. The polling loop on the threaded
  path reads `len(ctx.dfs)` under the ctx lock.
- `PriceHistory` records soft errors (delisted, missing tz, repair
  failure) in `self._last_error` instead of `shared._ERRORS`; the
  download loop reads it after `Ticker.history()` returns.
- `yfinance.shared` is left in place for import-compat with code that
  may still import it, but yfinance no longer reads or writes it.
- Update existing test_multi to the new `_download_one(ctx, ...)`
  signature and add regression tests covering result separation,
  no-raise on concurrent calls, and a sentinel proving `shared._DFS`
  is no longer used as scratch space.
2026-05-09 18:47:53 +02:00
Alessandro Colace ac1a7f65ca Allow region scoping for Sector and Industry
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
2026-05-09 17:55:05 +02:00
Alessandro Colace 90c267103a Validate Market region and stop returning misleading status data
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
2026-05-09 13:33:50 +02:00
ValueRaider 7cd4735e0d Fix dividends error on unlisted tickers 2026-05-05 22:04:58 +01:00
Jaypatel1511 2378a5fc09 Fix NoneType crash when data['chart'] is None (issue #2670)
Guard both chart-error and chart-result checks against data['chart']
being None, which previously raised TypeError instead of the expected
YFPricesMissingError.

- history.py L270: add 'data["chart"]' truthiness check before accessing ['error']
- history.py L274: add 'not data["chart"]' short-circuit before accessing ['result']
- Add regression test covering chart=None, result=None, missing key, and error payload
2026-04-29 16:57:17 -05:00
ValueRaider 9d989d89a6 Merge pull request #2761 from etbala/login
Add Auth class for Logging In
2026-04-29 21:09:56 +01:00
Ethan Balakumar 9a2999e340 Add Auth class for login 2026-04-27 21:14:25 -05:00
ValueRaider af8faa0ced Merge pull request #2780 from gottostartsomewhere/fix/dts-same-interval-1mo-year
Fix: _dts_in_same_interval("1mo") ignored year
2026-04-25 17:00:49 +01:00
ValueRaider dd7862b2cc Merge pull request #2779 from gottostartsomewhere/chore/fix-typos-providing-response
chore: fix typos (prividing -> providing, Reponse -> Response)
2026-04-25 16:59:45 +01:00
gottostartsomewhere 040e617041 Fix: _dts_in_same_interval("1mo") ignored year, treating same-month in different years as the same interval
The "1mo" branch compared only `dt1.month == dt2.month`, so e.g.
(2024-12-15, 2025-12-15) returned True. The "3mo" branch already
handles year differences via `year_diff`; mirror that by also
requiring `dt1.year == dt2.year`.

Added a test (`test_same_month_different_year`) that fails on the
old logic and passes on the fix. All existing tests still pass.
2026-04-24 11:24:16 +05:30
gottostartsomewhere 093ae6f864 chore: fix typos in warning message and docstring
- calendars.py: "prividing" -> "providing" (3 user-visible UserWarning messages)
- data.py: "Reponse" -> "Response" (docstring)
2026-04-24 10:32:12 +05:30
adrenaline fc53661e9a adding try block for added protection 2026-04-23 18:47:55 -05:00
ValueRaider 9b79ef76bf Add 'repair' to get_history_metadata() 2026-04-23 20:47:45 +01:00
ValueRaider a17e8b19a6 Version 1.3.0 2026-04-16 20:49:11 +01:00
ValueRaider b23433f826 Fix 'Ticker.dividends' type to be Series - fixes for tests 2026-04-16 20:46:18 +01:00
ValueRaider 6b01fb4fe9 Merge pull request #2749 from etbala/etfquery
Add ETFQuery
2026-04-16 20:23:14 +01:00
ValueRaider 2dfd727c8e Fix 'Ticker.dividends' type to be Series 2026-04-16 20:17:40 +01:00
ValueRaider fbceea958d Merge pull request #2755 from ranaroussi/main
sync main -> dev
2026-04-16 20:08:09 +01:00
Ethan Balakumar 6a1e9d1e86 Add ETFQuery 2026-04-14 23:49:39 -05:00
ValueRaider b1899b0e74 Merge pull request #2742 from etbala/valuation_measures
Add Valuation Measures Table from Statistics Page
2026-04-14 23:57:40 +01:00
Ethan Balakumar eac7f2ffa9 Add valuation measures 2026-04-13 20:16:16 -05:00
ValueRaider b1ed233f61 Version 1.2.2 2026-04-13 18:59:59 +01:00
ValueRaider eef8a3fd84 Merge pull request #2747 from ranaroussi/dev
sync dev -> main
2026-04-13 18:56:09 +01:00
ValueRaider 88072cf835 Version 1.2.1 2026-04-07 19:26:13 +01:00
Ethan Balakumar aeaa0f7ce3 Add currency column to analysis tables 2026-04-06 16:22:45 -05:00
Dhruvan Gnanadhandayuthapani 1b3ca8144b Refactor QueryBase to use typed Operator 2026-03-27 00:41:37 +01:00
ValueRaider 3fcefb92d9 Fix bug in #2695 2026-03-22 15:29:38 +00:00
ValueRaider 371511c6b4 Merge pull request #2695 from david-belbeze/fix/fill-devidends
Fix/fill devidends
2026-03-21 18:34:22 +00:00
ValueRaider b1e95bf59a Access div FX via 'Ticker.dividends' 2026-03-21 18:33:34 +00:00
Carson Jones 27589a1539 Add mutex lock to prevent concurrent download() corruption
Concurrent calls to yf.download() from separate threads share the
module-level _DFS, _ERRORS, and _TRACEBACKS dicts, causing one call
to overwrite or read another's results. Serialize access with a
threading.Lock so each download() runs atomically.

Fixes #2557
2026-03-12 17:05:08 -04:00
David BELBEZE e8504186d7 fix fill dividends to 0 when it includes currency
- Save first dividend currency in history metadata when provided
- Remove merge of dividends and currency column (when both exists) to prevent dtype changes (float to str) that cause errors when fill devidends NAN with 0.
2026-03-08 22:24:48 +01:00
ValueRaider 3c062b7141 Clarify history() period default 2026-03-04 19:53:09 +00:00
adrenaline e212c320bc extended protections to the dictionary structure and list type 2026-02-22 13:17:02 -06:00
ValueRaider f7e3a9287b Version 1.2.0 2026-02-16 19:49:02 +00:00
ValueRaider f95cdbb74a Handle Pandas to_numpy() returning read-only 2026-02-15 15:57:52 +00:00