$ show ranaroussi/yfinance
yfinance is a mature Python library that provides programmatic access to Yahoo Finance market data. It is primarily an application/library, not a data research project, though it includes data repair and cleaning utilities. The library exposes a high-level API (Ticker, download, Search, Lookup, Market, Screener) that fetches historical prices, fundamentals, financial statements, holders, analysis, and more from Yahoo's various JSON endpoints. It handles Yahoo's quirks (cookie/crumb authentication, timezone issues, data errors) and includes a sophisticated price repair pipeline that detects and corrects common data anomalies like 100x unit mixups, bad stock splits, zero values, and dividend double-counting. The architecture is monolithic with modular scrapers and utilities. It has extensive test coverage (though currently failing in CI), active maintenance, and a large user base (25k+ stars). The codebase is well-structured with reusable utility functions, but some legacy artifacts (Travis CI, disabled pytest workflow) and heavy reliance on heuristic repair logic introduce medium technical drift.
The LLM identified 3 files worth highlighting for reuse:
Contains several self-contained utility functions reusable across projects: `camel2title` converts camelCase to Title Case with acronym support; `_interval_to_timedelta` converts interval strings (e.g., '1mo', '1wk') to timedelta/relativedelta; `safe_merge_dfs` merges event DataFrames into price data with out-of-range handling; `IndentationContext` and `log_indent_decorator` provide indented debug logging; `dynamic_docstring` and `generate_list_table_from_dict` auto-generate Sphinx documentation from dicts. These functions have minimal internal dependencies and can be extracted into new projects with little modification.
The `HistoryMetadata` class implements a lazy dictionary pattern over Yahoo Finance metadata. It defers loading of `tradingPeriods` until first access, caching the result. This pattern is reusable for any API response where some fields are expensive to fetch. The class is self-contained and can be extracted as a generic lazy dict wrapper.
Provides a `frozendict` fallback implementation (hashable, read-only dict) for use as `lru_cache` keys. This is a common need in Python caching and is implemented cleanly without external dependencies. It can be reused in any project requiring immutable dicts for caching or hashing.