yfinance-pl
English | 日本語 | 中文 | 한국어 | Español
A Python wrapper for yfinance-rs using PyO3 and Polars.
Get stock market data with a yfinance-compatible API, but with Polars DataFrames instead of pandas.
Features
- yfinance-compatible API - Familiar interface for yfinance users
- Polars DataFrames - Returns
pl.DataFrameinstead ofpd.DataFrame - Rust backend - Fast data fetching powered by yfinance-rs
- Type-safe API - IDE autocompletion for
period,interval, and return types
Installation
From PyPI
pip install yfinance-pl
From Source
Requires protobuf compiler:
# macOS
brew install protobuf
# Ubuntu/Debian
sudo apt install protobuf-compiler
Then build:
git clone https://github.com/rmc8/yfinance-pl.git
cd yfinance-pl
pip install maturin
maturin develop --release
Quick Start
import yfinance_pl as yf
ticker = yf.Ticker("AAPL")
history = ticker.history(period="1mo")
print(history)
API Reference
Price History
| Method/Property | Return Type | Description |
|---|---|---|
history(period, interval, start, end) |
pl.DataFrame |
Historical price data (date column as Datetime) |
Parameters for history():
period: 1d, 5d, 1mo, 3mo, 6mo, 1y, 2y, 5y, 10y, ytd, maxinterval: 1m, 2m, 5m, 15m, 30m, 60m, 90m, 1h, 1d, 5d, 1wk, 1mo, 3mostart: Start date (YYYY-MM-DD)end: End date (YYYY-MM-DD)
Company Info
| Property | Return Type | Description |
|---|---|---|
info |
dict |
Full company information |
fast_info |
dict |
Quick access to key metrics |
calendar |
dict |
Upcoming events (earnings dates, etc.) |
Dividends & Corporate Actions
| Property | Return Type | Description |
|---|---|---|
dividends |
pl.DataFrame |
Dividend history |
splits |
pl.DataFrame |
Stock split history |
actions |
pl.DataFrame |
Combined dividends and splits |
capital_gains |
pl.DataFrame |
Capital gains (for funds/ETFs) |
Financial Statements
| Property | Return Type | Description |
|---|---|---|
income_stmt |
pl.DataFrame |
Annual income statement |
quarterly_income_stmt |
pl.DataFrame |
Quarterly income statement |
balance_sheet |
pl.DataFrame |
Annual balance sheet |
quarterly_balance_sheet |
pl.DataFrame |
Quarterly balance sheet |
cashflow |
pl.DataFrame |
Annual cash flow statement |
quarterly_cashflow |
pl.DataFrame |
Quarterly cash flow statement |
earnings |
dict |
Earnings summary |
Shareholders
| Property | Return Type | Description |
|---|---|---|
major_holders |
pl.DataFrame |
Major holders summary |
institutional_holders |
pl.DataFrame |
Institutional holders |
mutualfund_holders |
pl.DataFrame |
Mutual fund holders |
insider_transactions |
pl.DataFrame |
Insider transactions |
insider_roster_holders |
pl.DataFrame |
Insider roster |
Analyst Recommendations
| Property | Return Type | Description |
|---|---|---|
recommendations |
pl.DataFrame |
Analyst recommendations summary |
upgrades_downgrades |
pl.DataFrame |
Rating changes history |
Options (US stocks only)
| Property/Method | Return Type | Description |
|---|---|---|
options |
list[str] |
Available expiration dates |
option_chain(date) |
OptionChain |
Option chain for expiration date |
The option_chain() method returns an OptionChain named tuple:
chain = ticker.option_chain("2024-01-19")
chain.calls # pl.DataFrame
chain.puts # pl.DataFrame
Other
| Method | Return Type | Description |
|---|---|---|
get_isin() |
str |
ISIN identifier |
Examples
See the examples/ directory for detailed usage examples:
01_quick_start.py- Minimal example02_history.py- Price history options03_company_info.py- Company information04_dividends_splits.py- Corporate actions05_financials.py- Financial statements06_holders.py- Shareholder information07_analysis.py- Analyst recommendations08_options.py- Options data
Run examples:
uv run python examples/01_quick_start.py
Development
# Install dependencies
uv sync
# Build Rust module (run after changes)
uv run maturin develop
# Release build
uv run maturin develop --release
# Format and lint
uv run ruff format .
uv run ruff check .
Differences from yfinance
| Aspect | yfinance | yfinance-pl |
|---|---|---|
| DataFrame type | pd.DataFrame |
pl.DataFrame |
| Backend | Python | Rust (yfinance-rs) |
| Series type | pd.Series |
pl.DataFrame |
License
MIT
Metadata
Release files for yfinance-pl 0.7.2.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| yfinance_pl-0.7.2.2.tar.gz | 88.5 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| yfinance_pl-0.7.2.2-cp313-cp313-macosx_11_0_arm64.whl | CPython 3.13 | CPython 3.13 | macOS 11.0+ ARM64 | Details |
Total release size: 7.0 MB
Release files / yfinance_pl-0.7.2.2.tar.gz
| Download URL | yfinance_pl-0.7.2.2.tar.gz |
|---|---|
| Size | 88.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
8ec6cdad44b5e3d9649806972c3d79637c4d9dc684b97b6e5507e9900cb691d5
|
|
BLAKE2b-256 checksum How to use checksums |
7a4dbe8ce760c7deb5ab81564089e7429170f487cf1308a5074bb3a08fe37c28
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
maturin/1.10.2
|
Release files / yfinance_pl-0.7.2.2-cp313-cp313-macosx_11_0_arm64.whl
| Download URL | yfinance_pl-0.7.2.2-cp313-cp313-macosx_11_0_arm64.whl |
|---|---|
| Size | 6.9 MB |
| Tags | CPython 3.13 macOS 11.0+ ARM64 |
|
SHA-256 checksum How to use checksums |
895d899dd43c1f6fd7d738ac8d2406261aeff97ec184bbbb6c0776307baa00c3
|
|
BLAKE2b-256 checksum How to use checksums |
52cc669ff95337b94ce9f684b6188d2e78ea6324a52bbb06f88e9d6361a83040
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
maturin/1.10.2
|