aboutsummaryrefslogtreecommitdiff
path: root/README.md
blob: b3cf7e43091bb110a6282a4314e8ccd84a094f47 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
# 🔷 Prism

A local financial analysis dashboard. Search any stock ticker to get a comprehensive view of financials, valuation, options flow, insider activity, SEC filings, and news — all in your browser.

---

## Features

### Market Bar
Live S&P 500, NASDAQ, DOW, and VIX at the top of every page.

### Top Movers
Day gainers, losers, and most-active tickers shown below the market bar — expandable from 3 to 8 entries per category.

### Overview
- **Score card** — at-a-glance green/yellow/red signal badges for Valuation, Growth, Profitability, Leverage, Momentum, and Short Interest
- **52-week range bar** — visual indicator showing where the current price sits between the 52W low and high, with % context
- **Short interest** — % of float, days to cover, shares short vs. prior month
- Price chart (1M / 3M / 6M / 1Y / 5Y), key stats (market cap, P/E, volume, beta)

The sidebar also shows a live price (with day change), exchange, currency, sector, employee count, and website link for the selected ticker.

### Financials
Annual and quarterly Income Statement, Balance Sheet, and Cash Flow Statement with year-over-year % change columns color-coded green/red (cost/debt rows are correctly inverted). CSV export on every statement.

### Valuation
Seven sub-tabs:

| Tab | Contents |
|---|---|
| Key Ratios | P/E, Forward P/E, P/S, P/B, EV/EBITDA, EV/Revenue, margins, ROE, ROA, ROIC, D/E, current/quick ratio, interest coverage, dividend yield, payout ratio |
| Historical Ratios | Annual P/E, P/B, P/S, EV/EBITDA, margins, ROE, ROA, D/E charted over time |
| Models | Four collapsible valuation models: **DCF** (adjustable WACC, terminal growth, projection years, FCF growth, waterfall chart), **EV/EBITDA**, **EV/Revenue**, and **P/B** — each with an implied price, bridge breakdown, and reasoning summary |
| Comps | Peer valuation table with editable ticker set |
| Forward Estimates | Analyst revenue, EPS, and EBITDA estimates with low/avg/high ranges and chart overlay |
| Analyst Targets | Price target range (low/mean/median/high), upside to mean, recommendation distribution chart |
| Earnings History | EPS actual vs. estimate, surprise %, color-coded table, chart; CSV export |

> All Key Ratios are self-computed from raw yfinance quarterly statements — no FMP quota consumed.

### Options
- Put/call ratio by volume and open interest (with Bullish / Neutral / Bearish label)
- IV smile chart (calls and puts) with ATM marker
- Open interest by strike (calls above axis, puts mirrored below)
- Full options chain table (expandable)

### Insiders
Buy/sell transaction history with monthly activity bar chart and filterable table.

### Filings
Recent 10-K, 10-Q, and 8-K filings with direct EDGAR exhibit links, color-coded by type.

### News
Recent articles with Bullish / Bearish / Neutral sentiment badges and a 7-day sentiment summary.

---

## Setup

### 1. Navigate to the project

```bash
cd ~/Work/prism
```

### 2. Activate the virtual environment

```bash
source .venv/bin/activate
```

### 3. Add API keys

```bash
cp .env.example .env
```

Open `.env` and fill in your keys:

```
FMP_API_KEY=your_key_here
FINNHUB_API_KEY=your_key_here
```

Both are **free**:
- **FMP** (Financial Modeling Prep) — [financialmodelingprep.com](https://financialmodelingprep.com/developer/docs) — 250 requests/day
- **Finnhub** — [finnhub.io](https://finnhub.io) — 60 requests/minute

> **No keys?** Most of Prism still works. Overview, Financials, Key Ratios, Historical Ratios (yfinance fallback), Options, Insiders, Filings, and the DCF model all run without any API key. The Comps peer list, Forward Estimates, and News require FMP/Finnhub keys.

### 4. Run the app

```bash
streamlit run app.py
```

Opens at `http://localhost:8501`

---

## Daily Usage

```bash
cd ~/Work/prism
source .venv/bin/activate
streamlit run app.py
```

---

## Project Structure

```
prism/
├── app.py                        # Entry point — sidebar, market bar, tab routing
├── requirements.txt
├── .env                          # Your API keys (not committed)
├── .env.example                  # Key template
├── .streamlit/
│   └── config.toml               # Dark theme + layout settings
├── assets/
│   └── logo.png                  # Sidebar logo
├── services/
│   ├── data_service.py           # yfinance — price, financials, options, compute_ttm_ratios
│   ├── fmp_service.py            # FMP API — peers, forward estimates, news, historical ratios
│   ├── news_service.py           # Finnhub — news + sentiment
│   └── valuation_service.py      # DCF, EV/EBITDA, EV/Revenue, and P/B valuation engines
├── components/
│   ├── market_bar.py             # Index metrics row
│   ├── top_movers.py             # Day gainers, losers, most active
│   ├── overview.py               # Score card, 52W bar, short interest, price chart
│   ├── financials.py             # Color-coded statement tables + CSV export
│   ├── valuation.py              # 7-tab valuation panel
│   ├── options.py                # Options flow — P/C ratio, IV smile, OI chart
│   ├── insiders.py               # Insider buy/sell history
│   ├── filings.py                # SEC filings
│   └── news.py                   # News feed + sentiment
└── utils/
    └── formatters.py             # Number formatting helpers
```

---

## Valuation Models Notes

The **Models** tab contains four collapsible valuation models, each computing an implied price per share with a bridge breakdown:

### DCF

Uses historical **Free Cash Flow** from yfinance and projects forward:

| Input | Default | Range |
|---|---|---|
| WACC | 10% | 5–20% |
| Terminal Growth Rate | 2.5% | 0.5–5% |
| Projection Years | 5 | 3–10 |
| FCF Growth Rate | Historical median (uncapped) | −50–50% |

Terminal value uses the **Gordon Growth Model**. Enterprise value is bridged to equity value using net debt. The FCF growth slider shows the raw historical median and can be overridden.

### EV/EBITDA

Applies a target EV/EBITDA multiple to trailing EBITDA (sourced from income statement). Slider defaults to the current computed market multiple.

### EV/Revenue

Applies a target EV/Revenue multiple to TTM revenue. Useful for pre-profit or high-growth companies.

### P/B (Price-to-Book)

Applies a target P/B multiple to book value per share. Shown by default for financial companies (banks, insurance, REITs) and as a fallback when cash-flow models are not reliable.

---

## API Usage

| Source | Limit | Used For |
|---|---|---|
| yfinance | None | Price, financials, options, insiders, filings, all key ratios |
| FMP (free) | 250 req/day | Peer discovery, forward estimates, historical ratios, news |
| Finnhub (free) | 60 req/min | News sentiment |

All key ratios are computed locally from quarterly statements — Prism only calls FMP for data that cannot be derived from raw statements. Data is cached per session (financials: 1h, news: 10min, indices: 5min, options: 15min).