Tulitula commited on
Commit
d4f513a
·
verified ·
1 Parent(s): ab0239b

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +67 -59
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
- - your-username/LensIQ-Synthetic-Portfolio-1000
15
  ---
16
 
17
  # LensIQ — CAPM + CML Portfolio Advisor
18
 
19
- LensIQ is a Gradio app for portfolio analysis using CAPM and the Capital Market Line (CML), with embedding-aided suggestions.
 
 
 
20
 
21
- - **Plot**
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
- - **Efficient mixes** (market/bills only)
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
- - **Suggestions**
32
- - Exactly **one** candidate per band (**Low / Medium / High**).
33
- - Built from **1,000** random long-only mixes using **your tickers** (+ `VOO` as market proxy).
34
- - Ranking uses CAPM metrics + **FinLang/finance-embeddings-investopedia** with MMR for diversity.
 
 
35
 
36
- - **Export**
37
- - Each run saves a CSV with all candidate mixes (downloadable from the UI).
38
 
39
- > **Note:** Include **VOO** in your portfolio (market proxy) before computing.
40
 
41
- ---
42
 
43
- ## Run Locally
44
 
45
- docker build -t lensiq .
46
- docker run -p 7860:7860 -e GRADIO_SERVER_NAME=0.0.0.0 lensiq
47
- # Open http://localhost:7860
48
 
49
- ---
 
 
50
 
51
- ## Using the App
52
 
53
- 1. Add tickers and include **VOO**.
54
- 2. Enter **$ amounts** for each ticker.
55
- 3. Set **Horizon** and **Lookback** (years).
56
- 4. Click **Compute**.
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
- ## Method
63
 
64
- - Prices: Yahoo Finance monthly (`yfinance`)
65
- - Risk-free: FRED tenor by horizon (1–30y)
66
- - Market: `VOO`
67
- - ERP: market CAPM E[r] rf
68
- - β: covariance vs. market (excess returns)
69
- - σ (hist): annualized from monthly covariance
70
- - Suggestions: 1,000 long-only mixes; embedding-aided ranking + MMR
 
 
 
 
 
71
 
72
- ---
73
-
74
- ## Synthetic Dataset
75
 
76
- A CSV is written under `data/`, e.g. `data/investor_profiles_<timestamp>.csv`.
 
 
 
 
 
 
 
77
 
78
- **Columns:** `tickers`, `weights`, `beta`, `mu_capm`, `sigma_hist`, `sigma_capm`
 
 
 
 
 
 
79
 
80
- If you publish the dataset to Hugging Face, set the repo to:
81
- `your-username/LensIQ-Synthetic-Portfolio-1000` and include this README.
82
-
83
- ---
84
 
85
- ## Project Structure
86
 
87
- .
88
- ├─ app.py
89
- ├─ Dockerfile
90
- ├─ requirements.txt
91
- ├─ data/ # generated CSVs
92
- └─ README.md
93
 
94
- ## License
95
 
96
- - Code: MIT (or your choice)
97
- - Dataset: CC BY 4.0
 
 
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.