# yfd

Offline Yahoo Finance data for 17,000+ US-listed securities (stocks, ETFs, REITs). Daily OHLCV prices, financial statements, holders, analyst estimates, and 40 data types — served from Cloudflare R2, updated nightly. No API keys needed.

## Install

```
pip install yfd
```

## Python API

Three functions:

```python
import yfd

# Fetch any data type for a symbol
yfd.get(symbol, data_type="price", start=None, end=None)
# Returns: DataFrame for tabular data, dict/list/str for other types, or None

# List all 39 available data types
yfd.types()
# Returns: {"price": "Daily OHLCV price history", ...}

# List all available ticker symbols
yfd.symbols()
# Returns: ["A", "AA", "AAPL", ...]
```

## CLI

```bash
yfd <data_type> <SYMBOL> [--start YYYY-MM-DD] [--end YYYY-MM-DD] [--json]
yfd types
yfd symbols
```

CLI accepts hyphens: `income-stmt` = `income_stmt`.

## Data Types

### Price & Actions
- `price` — Daily OHLCV price history (columns: Open, High, Low, Close, Volume)
- `dividends` — Dividend payment history
- `splits` — Stock split history
- `actions` — Dividends and splits combined
- `capital_gains` — Capital gains distributions (ETFs/funds only)

### Financial Statements
- `income_stmt` — Annual income statement
- `income_stmt_quarterly` — Quarterly income statement
- `income_stmt_ttm` — Trailing 12-month income statement
- `balance_sheet` — Annual balance sheet
- `balance_sheet_quarterly` — Quarterly balance sheet
- `cashflow` — Annual cash flow statement
- `cashflow_quarterly` — Quarterly cash flow statement
- `cashflow_ttm` — Trailing 12-month cash flow

### Holders
- `major_holders` — Insider/institution ownership %
- `institutional_holders` — Top institutional holders
- `mutualfund_holders` — Top mutual fund holders
- `insider_transactions` — Insider buy/sell transactions
- `insider_purchases` — Net insider purchase activity
- `insider_roster` — Insider roster with positions

### Analyst & Estimates
- `recommendations` — Analyst recommendation trend (buy/hold/sell counts)
- `upgrades_downgrades` — Analyst upgrade/downgrade history
- `earnings_estimate` — EPS estimates by period
- `revenue_estimate` — Revenue estimates by period
- `earnings_history` — Historical EPS vs estimates (surprise %)
- `eps_trend` — EPS trend
- `eps_revisions` — EPS revision history
- `growth_estimates` — Growth estimates (stock/industry/sector)
- `analyst_price_targets` — Target high/low/mean/median price

### Company
- `info` — Full company information (sector, industry, officers, description, ...)
- `fast_info` — Quick price/volume stats (market cap, 52-week range, averages)
- `sustainability` — ESG scores
- `calendar` — Upcoming earnings and dividend dates
- `history_metadata` — Exchange, currency, trading hours
- `news` — Latest news articles
- `sec_filings` — SEC 10-K/10-Q filing history

### TradingView Screener
- `screener` — 1,000+ fields from TradingView: classification (type, subtype, sector, industry), fundamentals (EPS, margins, growth rates, ratios), daily technicals (RSI, MACD, EMA, SMA, Bollinger, Stochastic, ADX), analyst ratings, ETF metrics

### Other
- `earnings` — Earnings dates with EPS surprise
- `options` — Full options chain (all expiries, calls and puts)
- `isin` — ISIN identifier string
- `funds_data` — ETF/mutual fund details (holdings, allocations)

## Examples

```python
import yfd

# Get AAPL price for March 2026
df = yfd.get("AAPL", "price", start="2026-03-01", end="2026-03-31")

# Get annual income statement
inc = yfd.get("AAPL", "income_stmt")
# DataFrame: rows = line items (TotalRevenue, NetIncome, ...), columns = fiscal year dates

# Get company info
info = yfd.get("AAPL", "info")
# dict with 180+ keys: sector, industry, marketCap, fullTimeEmployees, ...

# Get analyst price targets
targets = yfd.get("AAPL", "analyst_price_targets")
# {"currentPrice": 248.8, "highprice": 350.0, "lowprice": 205.0, "meanprice": 295.3, ...}
```

```bash
# CLI equivalents
yfd price AAPL --start 2026-03-01
yfd income-stmt AAPL
yfd info AAPL --json
yfd analyst-price-targets AAPL
```
