Commit Graph

1809 Commits

Author SHA1 Message Date
goldyard 057bc4493e Add yfin CLI + tool catalog + CLAUDE.md
Wraps the entire yfinance public API behind a single binary `yfin` with
51 subcommands across 13 namespaces (ticker, download, tickers, search,
lookup, market, sector, industry, calendars, screen, live, auth, config).
Output renders as Rich tables on TTY, JSON when piped; --format / --out
support table | json | ndjson | csv | tsv | parquet | yaml.

Highlights:
- 1857 LOC across 18 Python files under cli/yfin/
- Typer + Rich, packaged via hatchling + uv
- Install globally: `cd cli && uv tool install -e .`
- ~/.yfin/config.toml for persistent proxy/cookies/locale defaults
- Friendly YFRateLimitError handler (exit 2, no Rich traceback)
- Validated end-to-end with 33 live tests against Yahoo from a
  residential exit (AAPL, MSFT, NVDA, options, screens, calendars,
  financials, news, holders, parquet round-trip)

yfinance-tools.yaml is the single source of truth:
- tools (49)       — every public yfinance entry point with parameters
- cli (13 groups)  — exact CLI invocations, mapped back to tool names
- outputSchemas (27) — actual return shapes captured from live calls
- learnings (19)   — IP rate-limit, crumb handshake, Typer gotchas,
                     screen-build wrapping rules, upstream stubs, etc.

CLAUDE.md documents the upstream codebase layout for future agents.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-08 23:36:56 +08:00
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
ValueRaider 15ba0223cc Merge pull request #2836 from ranaroussi/dev
sync dev -> main
2026-05-28 21:00:11 +01:00
Ran Aroussi 0940e44e97 docs: changelog entry for 1df338c 2026-05-25 21:55:38 +01:00
Ran Aroussi 863f0a0be7 docs: changelog entry for c3db565 2026-05-25 21:55:37 +01:00
ValueRaider 1df338cce6 Merge pull request #2832 from dokson/fix/download-index-name
Preserve Date/Datetime index name in yf.download() output
2026-05-25 21:55:06 +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
Ran Aroussi 6b84cdecd7 docs: changelog entry for 754346f 2026-05-23 17:29:51 +01:00
Ran Aroussi 6f0525b199 docs: changelog entry for e005d2d 2026-05-23 17:29:50 +01:00
Ran Aroussi 0118573c9e docs: changelog entry for ff36bd7 2026-05-23 17:29:49 +01:00
Ran Aroussi cfb1799683 docs: changelog entry for 44cc9ba 2026-05-23 17:29:48 +01:00
Ran Aroussi e7b51ea1d3 docs: changelog entry for 89ad803 2026-05-23 17:29:47 +01:00
ValueRaider 754346f56c Merge pull request #2830 from ranaroussi/main
chore: merge main back into dev
2026-05-23 17:28:28 +01:00
ValueRaider e005d2d562 Version 1.4.0 2026-05-23 17:20:05 +01:00
ValueRaider ff36bd78b8 Merge pull request #2828 from ranaroussi/dev
sync dev -> main
2026-05-23 17:17:48 +01:00
Ran Aroussi d893ef473d docs: changelog entry for 54bef21 2026-05-23 14:48:08 +01:00
ValueRaider 54bef21e98 Fix tests 2026-05-23 14:46:39 +01:00
ValueRaider 44cc9ba32d Merge pull request #2829 from ranaroussi/dependabot/github_actions/zizmorcore/zizmor-action-0.5.6
Bump zizmorcore/zizmor-action from 0.5.3 to 0.5.6
2026-05-21 19:25:40 +01:00
dependabot[bot] 89ad803fad Bump zizmorcore/zizmor-action from 0.5.3 to 0.5.6
Bumps [zizmorcore/zizmor-action](https://github.com/zizmorcore/zizmor-action) from 0.5.3 to 0.5.6.
- [Release notes](https://github.com/zizmorcore/zizmor-action/releases)
- [Commits](https://github.com/zizmorcore/zizmor-action/compare/b1d7e1fb5de872772f31590499237e7cce841e8e...5f14fd08f7cf1cb1609c1e344975f152c7ee938d)

---
updated-dependencies:
- dependency-name: zizmorcore/zizmor-action
  dependency-version: 0.5.6
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2026-05-21 12:02:28 +00:00
Ran Aroussi 0721ed0d9a docs: changelog entry for 6ab79ed 2026-05-20 21:46:03 +01:00
Ran Aroussi f0aa468db2 docs: changelog entry for acd2c28 2026-05-20 21:46:02 +01:00
Ran Aroussi 970b40a48f docs: changelog entry for 7538c1f 2026-05-20 21:46:01 +01:00
ValueRaider 6ab79ed2a3 Merge pull request #2825 from ranaroussi/fix/download-tz
Fix localized intraday download() always returning UTC
2026-05-20 21:44:44 +01:00
ValueRaider acd2c28a0c Merge branch 'dev' into fix/download-tz 2026-05-20 21:44:17 +01:00
Ran Aroussi 7610e47b56 docs: changelog entry for 9ca1c55 2026-05-20 21:37:24 +01:00
Ran Aroussi 41147fa14d docs: changelog entry for 5d10c0c 2026-05-20 21:37:23 +01:00
Ran Aroussi 0b85b087ff docs: changelog entry for 628a417 2026-05-20 21:36:17 +01:00
Ran Aroussi 0d6e3323e2 docs: changelog entry for 0c36060 2026-05-20 21:36:16 +01:00
Ran Aroussi dcd94622c1 docs: changelog entry for 593b47c 2026-05-20 21:36:15 +01:00
Ran Aroussi bdcda2d366 docs: changelog entry for a766e8f 2026-05-20 21:36:14 +01:00
Ran Aroussi fcb36c1ed2 docs: changelog entry for 75ed996 2026-05-20 21:36:12 +01:00
Ran Aroussi 4ec214ea92 docs: changelog entry for 803893a 2026-05-20 21:36:11 +01:00
Ran Aroussi a1bbacfc1d docs: changelog entry for a497d4f 2026-05-20 21:36:10 +01:00
Ran Aroussi ac8cbdb012 docs: changelog entry for 38ad379 2026-05-20 21:36:09 +01:00
Ran Aroussi 1246cb518a docs: changelog entry for 4c544ca 2026-05-20 21:36:08 +01:00
Ran Aroussi 7dbc5aa353 docs: changelog entry for a17e8b1 2026-05-20 21:36:06 +01:00
Ran Aroussi 680a99051d docs: changelog entry for d6afeeb 2026-05-20 21:36:05 +01:00
Ran Aroussi 9a7eb58afe docs: changelog entry for 6cebd23 2026-05-20 21:36:04 +01:00
Ran Aroussi c8313e21a9 docs: changelog entry for a07bf32 2026-05-20 21:36:03 +01:00
Ran Aroussi 7740e5e1ec docs: changelog entry for cb9884c 2026-05-20 21:36:02 +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
ValueRaider 0c36060d5d Merge pull request #2821 from dokson/feature/drop-frozendict-dep
Drop frozendict hard dependency in favour of an internal fallback
2026-05-20 21:30:28 +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