Files
learn-trading/aapl_yfinance.md
tomatocream b5bf689e72 docs: add API references, mapping corrections, and verification script
- Add yfinance.org and defeatbeta-api.org reference docs
- Fix defeatbeta_mapping.org: deprecated yfinance property names
  (quarterly_financials→quarterly_income_stmt, financials→income_stmt),
  longName vs longBusinessSummary conceptual mismatch, cashflow note typo
- Add Mapping Limitations section with live verification results (AAPL):
  DuckDB 1.4.3 incompatibility, format differences, coverage gaps
- Add docs/test_mapping.py as runnable mapping verification script
- Add offline.py, persistent_cache.py, download_data.py, warmup_cache.py
  for offline/cached defeatbeta usage
- Add aapl_yfinance.py exploration script and quant.py scaffold
- Add .envrc (uv layout) and update pyproject.toml + uv.lock

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-26 15:33:21 +08:00

120 lines
1.8 KiB
Markdown

# AAPL - All yfinance Data
```python
import yfinance as yf
import marimo as mo
ticker = yf.Ticker("AAPL")
```
## Price History
```python
history = ticker.history(period="1y", interval="1d")
mo.ui.table(history.tail(30))
```
## Dividends
```python
mo.ui.table(ticker.dividends.tail(20))
```
## Splits
```python
mo.ui.table(ticker.splits)
```
## Income Statement
```python
mo.ui.table(ticker.get_income_stmt())
```
## Balance Sheet
```python
mo.ui.table(ticker.get_balance_sheet())
```
## Cash Flow
```python
mo.ui.table(ticker.get_cashflow())
```
## Analyst Recommendations
```python
mo.ui.table(ticker.recommendations.tail(20))
```
## Analyst Target Prices
```python
mo.ui.table([ticker.target_prices])
```
## Earnings Dates
```python
mo.ui.table(ticker.earnings_dates)
```
## Options Expirations
```python
expirations = ticker.get_options()
f"Available: {expirations}"
```
```python
if expirations:
chain = ticker.option_chain(expirations[0])
mo.ui.table(chain.calls)
mo.ui.table(chain.puts)
```
## Major Holders
```python
mo.ui.table(ticker.major_holders)
```
## Institutional Holders
```python
mo.ui.table(ticker.institutional_holders)
```
## Sustainability / ESG
```python
mo.ui.table([ticker.sustainability])
```
## Calendar / Events
```python
mo.ui.table(ticker.calendar)
```
## Company Info Summary
```python
info = ticker.info
{
"name": info.get("longName"),
"sector": info.get("sector"),
"industry": info.get("industry"),
"marketCap": info.get("marketCap"),
"peRatio": info.get("trailingPE"),
"fwdDividend": info.get("dividendYield"),
"52wkHigh": info.get("fiftyTwoWeekHigh"),
"52wkLow": info.get("fiftyTwoWeekLow"),
"avgTarget": info.get("targetMeanPrice"),
"recommendation": info.get("recommendationKey"),
}
```