Skip to content

ellenzishanli/SignalForge

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

38 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

SignalForge πŸ”­

Smart money tracker + quant research terminal + defensive portfolio engine. Follows 20+ top hedge funds via SEC filings. 5-factor quant engine (Kalman filter, Markov chains, Hurst exponent) scoring 150+ stocks across the full AI infrastructure value chain. Beta-adjusted alpha + downside-protected portfolio construction (AQR Total Portfolio Approach) β€” win when the market is down. Congressional & insider trade monitoring. Real-time macro shock alerts. Delivered to your inbox every morning at 7 AM.

Python License: MIT LLM: Groq Data: SEC EDGAR

Built for investors who want to think like the world's best allocators: buy great businesses at fair prices and hold. Not a trading tool. No day-trading noise. Buffett/Klarman-style fundamental analysis enriched with quant scoring and AI.

"The stock market is a device for transferring money from the impatient to the patient." β€” Warren Buffett


What It Does

πŸ›°οΈ AI Infrastructure Value Chain β€” Hunt the "Next Micron" (--mode aii)

The full picks-and-shovels stack behind the AI buildout β€” ~50 names mapped across every layer, from the chip to the power grid. This is where the next 10x ideas live before the market finds them.

Layer What it is Tickers
🧠 Compute Silicon GPUs, accelerators, CPUs NVDA, AMD, AVGO, ARM, MRVL, ALAB
🏭 Foundry & Equipment The factories making the chips TSM, ASML, AMAT, LRCX, KLAC
πŸ’Ύ Memory & Storage HBM, NAND, flash MU, WDC, STX, SNDK
πŸ”Œ Networking & Optics Moving data at AI speed ANET, CSCO, CRDO, CIEN, COHR, FN
πŸ–₯️ Servers & Cooling The physical body of AI SMCI, DELL, HPE, VRT, ETN, MOD
☁️ Neoclouds & Data Centers GPU cloud landlords NBIS, CRWV, IREN, APLD, CORZ
⚑ Power & Energy The fuel (most underpriced layer) CEG, VST, NEE, GEV, TLN, EQT
πŸ›οΈ Hyperscalers The buyers driving all demand MSFT, GOOGL, AMZN, META, ORCL

Opportunity Score (0–100) β€” built to find asymmetric setups before re-rating:

Opportunity = Valuation (0–30)   ← GARP + forward P/E
            + Upside    (0–25)   ← analyst consensus target
            + Growth    (0–25)   ← revenue + earnings growth
            + Quant     (0–20)   ← 5-factor quant confirmation
            βˆ’ Extended  penalty  ← demotes names up >80% on rich multiples

Labels: πŸš€ EMERGING WINNER Β· πŸ’Ž UNDERVALUED Β· πŸ”₯ HIGH UPSIDE Β· ⚑ MOMENTUM Β· ⚠️ EXTENDED Asymmetric "next Micron" setups are flagged ⭐ β€” high growth, fair value, real upside, not overextended.

python3 main.py --mode aii

πŸ›‘οΈ Defensive Alpha β€” Portfolio Construction (--mode portfolio)

A beta-adjusted alpha engine + downside-protected portfolio constructor, built on AQR's Total Portfolio Approach research. The goal: keep most of the upside, lose far less when the market falls.

Beta-adjusted alpha β€” every name's return is split into the free market ride (beta) and genuine unique edge (alpha), then scored by the appraisal ratio (alpha Γ· idiosyncratic vol β€” AQR's prescribed weighting metric):

Metric What it captures
Beta Market sensitivity β€” the part you can buy free from an index
Dimson Ξ² "True" beta incl. 1-day lag (Asness: plain beta understates real risk)
Alpha (Jensen's) Annualized return left after stripping out beta
Appraisal ratio Beta-adjusted alpha score = alpha Γ· idiosyncratic vol
Convexity Up-beta βˆ’ down-beta (positive = participate up, resist down)

Three-sleeve construction:

  • 🟒 Alpha β€” high beta-adjusted-alpha growth (the return engine)
  • πŸ”΅ Defensive β€” low-beta ballast (BRK-B, COST, XLU, XLP, XLV, SCHD)
  • 🟣 Convexity β€” the AQR crisis-diversifier playbook: DBMF/KMLM (managed-futures trend-following β€” AQR's #1 convex diversifier), BTAL (anti-beta), GLD, TLT

Weights ∝ appraisal ratio with a low-beta tilt (betting-against-beta), then the convexity sleeve is sized to pull whole-portfolio beta down to a target (default 0.60).

βš–οΈ Second method β€” Risk Parity (Bridgewater "All Weather"): the same universe is also built as an Equal Risk Contribution book, where position sizing ignores expected return entirely and instead equalizes each name's share of portfolio volatility (Maillard-Roncalli-Teiletche 2010, solved by cyclical coordinate descent). A 60/40 book is ~90% equity risk despite looking balanced by dollars; ERC scales low-vol ballast (bonds, gold, defensives) up and high-vol growth down until every holding carries its weight. The terminal renders both books head-to-head (annual return, vol, Sharpe, max drawdown, downside capture, beta) so you can see AQR's return-quality sizing vs Bridgewater's risk-balanced sizing on identical inputs.

Stress test β€” measures "win when the market is down": downside/upside capture, capture ratio, win-rate in down months, max drawdown vs SPY, and cumulative return through historical selloffs (2022 inflation bear, 2025 tariff shock).

python3 main.py --mode portfolio                  # target beta 0.60
python3 main.py --mode portfolio --target-beta 0.4  # more defensive

πŸ“˜ Full concept primer: docs/PORTFOLIO_METHODOLOGY.md


πŸ‹ Whale Tracker β€” Smart Money Intelligence (--mode whales)

Track what the world's best investors are actually buying β€” parsed live from SEC filings, congressional disclosures, and social signals. 23 funds, 7 tabs.

Tab Source What you get
1–2: Institutional + AI Funds SEC 13F (live EDGAR parse) Holdings, QoQ changes, new positions β€” Berkshire, Bridgewater, Renaissance, Tiger Global, Coatue, D1, Whale Rock, Situational Awareness
3: Quant Giants SEC 13F Citadel (15,000+ positions), Two Sigma, D.E. Shaw, Point72, WorldQuant
4: Crypto Whales Public disclosures Saylor/MSTR, a16z, World Liberty Financial, Pantera, Galaxy Digital
5: Insider Buying Finviz scraper C-suite & director purchases β€” the strongest buy signal that exists
6: Congressional Trades Capitol Trades / QuiverQuant Real-time STOCK Act disclosures β€” what politicians are actually buying
7: Social Intelligence StockTwits + Finviz News + SEC RSS Trending tickers, sentiment on whale holdings, 13F filing alerts

Funds tracked β€” 23 managers across 4 categories:

Category Managers
πŸ† Value / Activist Berkshire Β· Baupost Β· Pershing Square Β· Scion Β· Third Point Β· Elliott Β· Sachem Head
πŸ“ˆ Growth / Macro Duquesne Β· Viking Global Β· D1 Capital Β· Durable Capital Β· Whale Rock Β· Dragoneer
πŸ€– AI / Tech Situational Awareness (Leopold Aschenbrenner) Β· Coatue Β· Tiger Global Β· ARK
βš™οΈ Quant Giants Bridgewater Β· Renaissance Β· Citadel Β· Point72 Β· D.E. Shaw Β· Two Sigma Β· WorldQuant Millennium

Every holding enriched with:

  • 5-factor quant score β†’ follow signal: ⭐⭐⭐ STRONG FOLLOW to ❌ AVOID
  • QoQ change detection: NEW BUY / INCREASED / DECREASED / CLOSED
  • Novelty scoring: non-consensus picks from Scion/Situational Awareness boosted; mega-cap consensus down-ranked
python3 main.py --mode whales

πŸ“ˆ Sector Scan + Hidden Gems (--mode stocks)

  • 5-module quant scoring (each 0–100): Technical Β· Statistical Β· ML Trend Β· Risk Β· Fundamental
  • 100+ stocks across 10 sectors Β· 75 ETFs (Tech, Bonds, Commodities, International, Factor, Dividend)
  • 30 Hidden Gems: quantum computing, space tech, nuclear, biotech, eVTOL β€” small/mid-cap, under analyst coverage

🧠 Quantitative Engine

Method What it does
Kalman Filter Tracks "true" fair value behind noisy price data
Markov Chain Models market regime (BULL/BEAR/SIDEWAYS) via transition probability matrix
Hurst Exponent Detects mean-reverting (H<0.45) vs trending (H>0.55) via the structure-function (generalised Hurst) estimator β€” correctly centred at 0.5 for a random walk
MACD / Stochastic / ADX Momentum + trend strength signals
Bollinger Bands 20-day mid Β± 2Οƒ β€” BB% (0 = lower band, 1 = upper) flags over-extension
OBV On-Balance Volume β€” detects institutional accumulation
ATR + Fibonacci Volatility regime + key support/resistance levels
Sharpe / Sortino / VaR Risk-adjusted return + tail risk
Multi-Factor Model Value 25% Β· Growth 30% Β· Quality 25% Β· Momentum 20%
QMJ Quality AQR "Quality Minus Junk" β€” Profitability Β· Growth Β· Safety pillars (margin, ROE, leverage)
GARP / PEG Ratio Growth At Reasonable Price scoring
Linear Regression ML Price slope, RΒ², velocity, acceleration

⏱️ Entry Quality β€” "Buy today or wait?"

A separate entry-timing overlay that combines momentum direction (MACD), momentum persistence (Hurst), and over-extension (Bollinger %) into one call β€” without touching the long-term quant score. The key is the pairing: MACD-up + Hurst-trending is a real trend worth entering, while MACD-up + Hurst-mean-reverting is fake momentum that will snap back.

Rating When Meaning
🟒 BUY NOW MACD↑ + Hurst trending + not over-band Real, persistent uptrend β€” buyable today
🟑 WAIT DIP MACD↑ but through the upper band Right idea, wrong price β€” limit-order a pullback
πŸ”΄ AVOID (fake) MACD↑ + Hurst mean-reverting Momentum will revert β€” don't chase
πŸ”΅ PROBE MACD↓ + mean-reverting + oversold Faded extreme β€” small mean-reversion probe only
πŸ”΄ AVOID (trend) MACD↓ + Hurst trending Real downtrend β€” don't catch the knife
βšͺ WAIT No clean directional edge Wait for a clearer entry

Surfaced as BB% + Entry columns in the sector scan and screener tables, and in every stock's quant thesis.

🚨 Macro Shock Monitor

LLM scans live RSS from Reuters, FT, WSJ, Bloomberg β€” identifies macro shock events (rate decisions, earnings, geopolitics) and surfaces the immediate trade setup for each.

πŸ”­ Daily Tech Briefing (--mode briefing)

GitHub Trending Β· TechCrunch Β· VentureBeat Β· arXiv Β· Reddit AI communities Β· YC companies β†’ AI-generated bilingual briefing: top startups, research breakthroughs, funding intelligence, non-obvious trends.

πŸ“§ Daily Email Report (--mode email)

Runs the full pipeline and delivers a dark-themed HTML report to your inbox every morning at 7 AM. Includes all sections: AI infra leaderboard, whale tracker summary, market intelligence, macro alerts, and tech briefing β€” in English and Chinese.


Quick Start

1. Get a free LLM API key

Sign up at console.groq.com β€” free tier, very fast, uses Llama 3.3 70B.

2. Install dependencies

pip install -r requirements.txt

3. Configure

cp .env.example .env
# Required: GROQ_API_KEY
# Optional: GMAIL_ADDRESS + GMAIL_APP_PASSWORD for daily email

4. Run

# AI Infrastructure value chain β€” hunt the "next Micron"
python3 main.py --mode aii

# Defensive Alpha β€” beta-adjusted alpha + downside-protected portfolio
python3 main.py --mode portfolio

# Smart money tracker β€” 23 hedge funds, 7 tabs
python3 main.py --mode whales

# Full run: AI infra β†’ whales β†’ sectors β†’ tech briefing
python3 main.py --mode full

# Email mode: full run + deliver to inbox
python3 main.py --mode email

# Just stocks (sectors + ETFs + hidden gems)
python3 main.py --mode stocks

# Hidden gems only (~1 min, fastest)
python3 main.py --mode gems

# Tech briefing only
python3 main.py --mode briefing

5. Schedule daily 7 AM email

python3 setup_cron.py
# Installs a cron job: every day at 7:00 AM (America/Los_Angeles)
# Sends the full report to the Gmail address in your .env

6. Navigate the output

Every mode uses a built-in scrollable pager (less).

Key Action
← β†’ Scroll horizontally through wide tables
↑ ↓ or j / k Scroll vertically
G Jump to bottom
g Jump to top
/ then text Search
q Exit pager

Performance

All data fetches run on a concurrent thread pool β€” stocks, ETFs, and whale holdings are fetched in parallel, not sequentially. SEC EDGAR requests go through a global rate limiter (8 req/s, under EDGAR's 10 req/s fair-access ceiling).

Task Before After
100+ sector stocks ~3 min ~25s
75 ETFs ~90s ~8s
23 hedge fund 13F filings ~45s ~12s
30 hidden gems ~60s ~7s

Project Structure

signalforge/
β”œβ”€β”€ main.py                     # Entry point β€” 7 modes
β”œβ”€β”€ config/
β”‚   β”œβ”€β”€ universe.py             # AI infra value chain + 10 sectors + 75 ETFs + 30 hidden gems
β”‚   β”œβ”€β”€ whales.py               # 23-fund registry with CIKs, styles, known-for
β”‚   └── settings.py             # Screener thresholds, signal weights
β”œβ”€β”€ stocks/
β”‚   β”œβ”€β”€ ai_infrastructure.py    # AI infra value-chain scanner + Opportunity Score engine
β”‚   β”œβ”€β”€ parallel.py             # Thread-pool helper β€” concurrent ticker fetches
β”‚   β”œβ”€β”€ quant.py                # Master quant engine (5 sub-scores, 0–100)
β”‚   β”œβ”€β”€ technical.py            # MACD, Stochastic, ATR, OBV, Fibonacci, ADX
β”‚   β”œβ”€β”€ risk_metrics.py         # Sharpe, Sortino, VaR, CVaR, Beta, ML trend
β”‚   β”œβ”€β”€ sector_scan.py          # Sector scanner + ETF table
β”‚   β”œβ”€β”€ hidden_gems.py          # Small/mid-cap experimental picks
β”‚   β”œβ”€β”€ screener.py             # Discount buy signals + GARP value picks
β”‚   β”œβ”€β”€ backtest.py             # Walk-forward backtester + OLS weight optimization
β”‚   └── data_enrichment.py      # Finviz scraper β€” short interest, analyst ratings
β”œβ”€β”€ portfolio/                  # Defensive Alpha engine (AQR Total Portfolio Approach)
β”‚   β”œβ”€β”€ factor_model.py         # Beta-adjusted alpha: CAPM beta, Dimson beta, appraisal ratio, convexity
β”‚   β”œβ”€β”€ construction.py         # Appraisal-weighted + low-beta-tilt defensive constructor
β”‚   β”œβ”€β”€ risk_parity.py          # Equal Risk Contribution constructor (Bridgewater All Weather)
β”‚   β”œβ”€β”€ stress.py               # Downside/upside capture, drawdown, stress-window backtests
β”‚   β”œβ”€β”€ data.py                 # Parallel multi-year price fetcher
β”‚   β”œβ”€β”€ engine.py               # Orchestrator: data β†’ factor model β†’ construct β†’ stress
β”‚   └── display.py              # Rich tables + concept primer
β”œβ”€β”€ whales/
β”‚   β”œβ”€β”€ whale_display.py        # Whale tracker β€” 7 tabs, quant enrichment, novelty ranking
β”‚   β”œβ”€β”€ sec_13f.py              # SEC EDGAR 13F parser β€” rate-limited, parallel, no re-downloads
β”‚   └── social_signals.py       # Congressional trades, insider buying, StockTwits, news
β”œβ”€β”€ scrapers/
β”‚   β”œβ”€β”€ github_trending.py      # GitHub Trending
β”‚   β”œβ”€β”€ feeds.py                # TechCrunch, VentureBeat, arXiv RSS
β”‚   β”œβ”€β”€ reddit_ai.py            # Reddit AI communities
β”‚   β”œβ”€β”€ yc.py                   # YC company directory
β”‚   └── macro_news.py           # Reuters, FT, WSJ macro headlines
β”œβ”€β”€ analysis/
β”‚   β”œβ”€β”€ ai_analyst.py           # Sell-side style bilingual AI reports (EN + δΈ­ζ–‡)
β”‚   β”œβ”€β”€ llm_client.py           # Multi-provider LLM client β€” Groq, Claude, Gemini, Ollama
β”‚   β”œβ”€β”€ headline_trades.py      # Macro shock β†’ trade idea LLM analysis
β”‚   └── emailer.py              # Dark-themed HTML email via Gmail SMTP
β”œβ”€β”€ run_daily.sh                # Cron entry point
β”œβ”€β”€ setup_cron.py               # One-command cron installer (7 AM daily)
└── output/                     # Daily reports saved as Markdown

LLM Providers

Provider Cost Model Setup
Groq (default) Free Llama 3.3 70B console.groq.com
Anthropic Paid Claude Opus/Sonnet console.anthropic.com
Google Gemini Free tier Gemini 1.5 Flash aistudio.google.com
Ollama Local/free Any local model ollama.com
LLM_PROVIDER=groq
GROQ_API_KEY=your_key_here

# Optional β€” for daily email delivery
GMAIL_ADDRESS=you@gmail.com
GMAIL_APP_PASSWORD=your_16_char_app_password

For VC / PE / Finance / Quant Careers

This project demonstrates end-to-end financial engineering across four pillars:

πŸ›‘οΈ Defensive Alpha Portfolio Engine β€” CAPM factor model computing beta-adjusted alpha (appraisal ratio = alpha Γ· idiosyncratic vol), Dimson/lagged beta for true market sensitivity, betting-against-beta tilt, and a convexity sleeve (trend-following, anti-beta, gold, long bonds) sized to a target portfolio beta. Includes a second construction method β€” Equal Risk Contribution risk parity (Bridgewater All Weather, solved by cyclical coordinate descent) β€” rendered head-to-head against the AQR book on the same universe. Stress-tested with downside/upside capture, win-rate in down months, max drawdown vs SPY, and 2022 / 2025 historical selloff windows. Grounded in AQR's Total Portfolio Approach and Maillard-Roncalli risk-budgeting research.

πŸ›°οΈ AI Infrastructure Value Chain β€” ~50 picks-and-shovels names scored across 8 layers (compute silicon, foundry, memory, networking/optics, servers/cooling, neoclouds, power, hyperscalers) with a custom Opportunity Score rewarding fair valuation + high growth + analyst upside before market re-rating.

πŸ‹ Smart Money Tracker β€” Live SEC EDGAR 13F XML parsing for 20+ funds (Berkshire, Bridgewater, Renaissance, Tiger Global) with QoQ change detection, congressional trade monitoring (STOCK Act), and insider buying signals. Concurrent pipeline with global rate limiting completes in <90 seconds.

πŸ“Š 5-Factor Quant Engine β€” Kalman filter (fair value tracking), Markov chain regime detection (BULL/BEAR/SIDEWAYS), Hurst exponent (mean-reverting vs trending), and multi-factor model (Value/Growth/Quality/Momentum) scoring 150+ stocks. Walk-forward backtested with OLS factor weight optimization. LLM-generated bilingual (EN/δΈ­ζ–‡) analysis delivered by automated daily email.

Skill matrix

Skill Implementation
Portfolio construction CAPM factor model, Jensen's alpha, appraisal ratio, Dimson/lagged beta, betting-against-beta, convexity, AQR Total Portfolio Approach, risk parity / Equal Risk Contribution (Bridgewater All Weather)
Quantitative finance Kalman filter, Markov chain regime detection, Hurst exponent, Sharpe/Sortino/VaR/CVaR, multi-factor models, AQR Quality Minus Junk (QMJ), GARP/PEG, walk-forward backtesting
Data engineering Multi-source ingestion: SEC EDGAR 13F, Finviz, Yahoo Finance, StockTwits, Reddit, GitHub, RSS, with concurrent thread-pool architecture and global rate limiting
Systems design Modular CLI (8 modes), thread-safe caches, automated cron scheduling, HTML email delivery, idempotent installers
AI/LLM integration Multi-provider client (Groq/Claude/Gemini/Ollama), bilingual sell-side research, macro event analysis, portfolio strategist commentary
Financial analysis 13F XML parsing, QoQ change detection, congressional trade monitoring, insider signal tracking, value-chain mapping
Investment research Opportunity scoring, novelty ranking, asymmetric setup detection, sector rotation, defensive sleeve construction

Disclaimer

For educational and research purposes only. Not investment advice. All models have inherent limitations. Do your own due diligence.


License

MIT License β€” free to use, modify, and distribute.

About

πŸ›‘οΈ Defensive Alpha + Risk Parity portfolio engine Β· πŸ›°οΈ AI infrastructure value chain scanner Β· πŸ‹ Smart money tracker Β· Follows 20+ top hedge funds via live SEC filings Β· Kalman filter Β· Markov chains Β· Hurst exponent Β· πŸ›οΈ Congressional & insider trades Β· 🚨 Macro alerts Β· πŸ“§ Daily 7 AM email

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors