Update README.md
Browse files
README.md
CHANGED
|
@@ -7,91 +7,99 @@ sdk: docker
|
|
| 7 |
app_port: 7860
|
| 8 |
pinned: false
|
| 9 |
short_description: CAPM + CML portfolio advisor w/ embeddings
|
| 10 |
-
license: cc-by-4.0
|
| 11 |
models:
|
| 12 |
- FinLang/finance-embeddings-investopedia
|
| 13 |
datasets:
|
| 14 |
-
-
|
| 15 |
---
|
| 16 |
|
| 17 |
# LensIQ — CAPM + CML Portfolio Advisor
|
| 18 |
|
| 19 |
-
|
|
|
|
|
|
|
|
|
|
| 20 |
|
| 21 |
-
|
| 22 |
-
- **x-axis**: historical σ (annualized, from monthly covariance of your tickers)
|
| 23 |
-
- **y-axis**: CAPM E[r] = rf + β·ERP
|
| 24 |
-
- CML drawn from risk-free to market (**VOO**).
|
| 25 |
|
| 26 |
-
|
| 27 |
-
- **Same σ** as your portfolio → point on the CML at your σ
|
| 28 |
-
- **Same E[r]** as your portfolio → σ on the CML for that return
|
| 29 |
-
- Weights are shown so you can replicate the mixes.
|
| 30 |
|
| 31 |
-
|
| 32 |
-
|
| 33 |
-
|
| 34 |
-
|
|
|
|
|
|
|
| 35 |
|
| 36 |
-
|
| 37 |
-
- Each run saves a CSV with all candidate mixes (downloadable from the UI).
|
| 38 |
|
| 39 |
-
|
| 40 |
|
| 41 |
-
|
| 42 |
|
| 43 |
-
|
| 44 |
|
| 45 |
-
|
| 46 |
-
|
| 47 |
-
|
| 48 |
|
| 49 |
-
|
|
|
|
|
|
|
| 50 |
|
| 51 |
-
|
| 52 |
|
| 53 |
-
|
| 54 |
-
|
| 55 |
-
|
| 56 |
-
|
| 57 |
-
5. Review your portfolio, the two efficient mixes (with weights), and the **one** Low/Medium/High suggestion (with % and $).
|
| 58 |
-
6. Download the generated CSV.
|
| 59 |
|
| 60 |
-
|
| 61 |
|
| 62 |
-
|
| 63 |
|
| 64 |
-
|
| 65 |
-
|
| 66 |
-
|
| 67 |
-
-
|
| 68 |
-
-
|
| 69 |
-
-
|
| 70 |
-
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 71 |
|
| 72 |
-
|
| 73 |
-
|
| 74 |
-
## Synthetic Dataset
|
| 75 |
|
| 76 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 77 |
|
| 78 |
-
**
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 79 |
|
| 80 |
-
|
| 81 |
-
|
| 82 |
-
|
| 83 |
-
---
|
| 84 |
|
| 85 |
-
##
|
| 86 |
|
| 87 |
-
|
| 88 |
-
├─ app.py
|
| 89 |
-
├─ Dockerfile
|
| 90 |
-
├─ requirements.txt
|
| 91 |
-
├─ data/ # generated CSVs
|
| 92 |
-
└─ README.md
|
| 93 |
|
| 94 |
-
##
|
| 95 |
|
| 96 |
-
-
|
| 97 |
-
-
|
|
|
|
|
|
| 7 |
app_port: 7860
|
| 8 |
pinned: false
|
| 9 |
short_description: CAPM + CML portfolio advisor w/ embeddings
|
|
|
|
| 10 |
models:
|
| 11 |
- FinLang/finance-embeddings-investopedia
|
| 12 |
datasets:
|
| 13 |
+
- Tulitula/LensIQ-Synthetic-Portfolio-1000
|
| 14 |
---
|
| 15 |
|
| 16 |
# LensIQ — CAPM + CML Portfolio Advisor
|
| 17 |
|
| 18 |
+
- **Plot:** x = historical σ (annualized, from monthly covariances), y = CAPM E[r] = rf + β·ERP.
|
| 19 |
+
- **Efficient mixes:** market/bills with (i) same σ, (ii) same E[r] as your portfolio (weights shown).
|
| 20 |
+
- **Suggestions:** one Low/Medium/High, from 1,000 long-only mixes built **from your tickers** (+ VOO), ranked with CAPM + embeddings (MMR).
|
| 21 |
+
- **Export:** every run writes a CSV of all 1,000 candidates in `data/`.
|
| 22 |
|
| 23 |
+
> Include **VOO** in your portfolio before computing.
|
|
|
|
|
|
|
|
|
|
| 24 |
|
| 25 |
+
## Run Locally
|
|
|
|
|
|
|
|
|
|
| 26 |
|
| 27 |
+
```bash
|
| 28 |
+
docker build -t lensiq .
|
| 29 |
+
docker run -p 7860:7860 -e GRADIO_SERVER_NAME=0.0.0.0 lensiq
|
| 30 |
+
# open http://localhost:7860
|
| 31 |
+
Create & Upload the Dataset
|
| 32 |
+
In the app, add tickers (incl. VOO), set amounts, horizon, lookback → Compute.
|
| 33 |
|
| 34 |
+
Download the generated CSV from the UI (saved under data/).
|
|
|
|
| 35 |
|
| 36 |
+
Create a dataset repo on Hugging Face named Tulitula/LensIQ-Synthetic-Portfolio-1000 and upload:
|
| 37 |
|
| 38 |
+
the CSV you downloaded
|
| 39 |
|
| 40 |
+
the dataset README from below (Section B).
|
| 41 |
|
| 42 |
+
swift
|
| 43 |
+
Kopiér
|
| 44 |
+
Rediger
|
| 45 |
|
| 46 |
+
**B) Dataset README (for `Tulitula/LensIQ-Synthetic-Portfolio-1000`)**
|
| 47 |
+
```markdown
|
| 48 |
+
# LensIQ Synthetic Portfolio 1000
|
| 49 |
|
| 50 |
+
Synthetic portfolio dataset generated by the LensIQ app for CAPM/CML-based analysis and ranking.
|
| 51 |
|
| 52 |
+
- **Size:** 1,000 rows (per export)
|
| 53 |
+
- **Modality:** Tabular (text fields for lists)
|
| 54 |
+
- **License:** CC BY 4.0
|
| 55 |
+
- **Intended use:** Research/teaching on portfolio construction, risk/return modeling, ranking/retrieval. *Not financial advice.*
|
|
|
|
|
|
|
| 56 |
|
| 57 |
+
## Generation Process
|
| 58 |
|
| 59 |
+
Given a user universe **U** (their tickers + `VOO` as market):
|
| 60 |
|
| 61 |
+
1. Sample `k ~ U{2…min(8, |U|)}` tickers from **U** (no replacement).
|
| 62 |
+
2. Draw long-only weights `w ~ Dirichlet(1,…,1)`.
|
| 63 |
+
3. Compute:
|
| 64 |
+
- Prices: Yahoo Finance monthly (auto-adjusted), last *N* years (lookback).
|
| 65 |
+
- Risk-free `rf`: FRED tenor chosen by horizon (e.g., DGS10).
|
| 66 |
+
- Market `m`: `VOO`.
|
| 67 |
+
- Market ERP `= E[m] − rf` (from monthly returns, annualized).
|
| 68 |
+
- Asset betas vs. market (excess returns).
|
| 69 |
+
- **mu_capm** `= rf + β_p·ERP`, where `β_p = Σ_i w_i β_i`.
|
| 70 |
+
- **sigma_hist**: annualized portfolio σ from monthly covariance.
|
| 71 |
+
- **sigma_capm**: `|β_p| · σ_market` (for reference to CML).
|
| 72 |
+
4. Rank candidates with CAPM metrics + finance embeddings (MMR) to surface Low/Medium/High picks in the app.
|
| 73 |
|
| 74 |
+
## Columns
|
|
|
|
|
|
|
| 75 |
|
| 76 |
+
| column | type | description |
|
| 77 |
+
|--------------|--------|--------------------------------------------------------|
|
| 78 |
+
| `tickers` | string | comma-separated tickers in the candidate mix |
|
| 79 |
+
| `weights` | string | comma-separated floats summing to 1 (long-only) |
|
| 80 |
+
| `beta` | float | portfolio beta (weighted by `weights`) |
|
| 81 |
+
| `mu_capm` | float | CAPM expected annual return |
|
| 82 |
+
| `sigma_hist` | float | annualized historical σ from covariance |
|
| 83 |
+
| `sigma_capm` | float | CAPM σ on the CML for equivalent return |
|
| 84 |
|
| 85 |
+
**Example row**
|
| 86 |
+
tickers: "VOO,QQQ,IBIT"
|
| 87 |
+
weights: "0.53,0.41,0.06"
|
| 88 |
+
beta: 1.18
|
| 89 |
+
mu_capm: 0.153
|
| 90 |
+
sigma_hist: 0.209
|
| 91 |
+
sigma_capm: 0.191
|
| 92 |
|
| 93 |
+
markdown
|
| 94 |
+
Kopiér
|
| 95 |
+
Rediger
|
|
|
|
| 96 |
|
| 97 |
+
## Files
|
| 98 |
|
| 99 |
+
- `investor_profiles_<timestamp>.csv` — 1,000 synthetic candidates.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 100 |
|
| 101 |
+
## Notes
|
| 102 |
|
| 103 |
+
- Requires the user to include `VOO` in **U** (market proxy).
|
| 104 |
+
- Returns/σ are computed from monthly data; figures are annualized.
|
| 105 |
+
- For reproducibility, a fixed RNG seed is used in the app when sampling mixes.
|