Loading source
Pulling the file list, source metadata, and syntax-aware rendering for this listing.
Source from repo
Fetch daily multi-ticker stock data with RSI, Bollinger Bands, Stochastic, and BUY/HOLD/SELL signals.
Files
Skill
Size
Entrypoint
Format
Open file
Syntax-highlighted preview of this file as included in the skill package.
TODO.md
1# Stock Analysis - Future Enhancements23## Roadmap Overview45### v4.0.0 (Current) - Geopolitical Risk & News Sentiment6✅ 8 analysis dimensions with Fear/Greed, short interest, VIX structure, put/call ratio7✅ Safe-haven indicators (GLD, TLT, UUP) with risk-off detection8✅ Breaking news alerts via Google News RSS9✅ Geopolitical risk mapping (Taiwan, China, Russia, Middle East, Banking)10✅ Sector-specific crisis flagging with confidence penalties11✅ 1h caching for shared indicators (Fear/Greed, VIX structure, breaking news)12✅ Async parallel sentiment fetching (5 indicators with 10s timeouts)1314### v5.0.0 (Current) - Portfolio & Crypto15✅ Portfolio management (create, add, remove, show assets)16✅ Cryptocurrency support (Top 20 by market cap)17✅ Portfolio analysis with --portfolio flag18✅ Periodic returns (--period daily/weekly/monthly/quarterly/yearly)19✅ Concentration warnings (>30% single asset)20✅ Crypto fundamentals (market cap, category, BTC correlation)2122### v4.1.0 - Performance & Completeness23✅ Full insider trading parsing via edgartools (Task #1)24✅ Market context caching with 1h TTL (Task #3b)25🔧 SEC EDGAR rate limit monitoring (Task #4 - low priority)2627### Future (v6.0+)28💡 Research phase: Social sentiment, fund flows, on-chain metrics2930---3132## Sentiment Analysis Improvements3334### 1. Implement Full Insider Trading Parsing35**Status**: ✅ DONE36**Priority**: Medium37**Effort**: 2-3 hours3839**Current State**:40- ✅ `get_insider_activity()` fetches Form 4 filings via edgartools41- ✅ SEC identity configured (`[email protected]`)42- ✅ Aggregates buys/sells over 90-day window43- ✅ Scoring logic: strong buying (+0.8), moderate (+0.4), neutral (0), moderate selling (-0.4), strong (-0.8)4445**Tasks**:46- [ ] Research edgartools API for Form 4 parsing47- [ ] Implement transaction aggregation (90-day window)48- [ ] Calculate net shares bought/sold49- [ ] Calculate net value in millions USD50- [ ] Apply scoring logic:51- Strong buying (>100K shares or >$1M): +0.852- Moderate buying (>10K shares or >$0.1M): +0.453- Neutral: 054- Moderate selling: -0.455- Strong selling: -0.856- [ ] Add error handling for missing/incomplete filings57- [ ] Test with multiple tickers (BAC, TSLA, AAPL)58- [ ] Verify SEC rate limit compliance (10 req/s)5960**Expected Impact**:61- Insider activity detection for 4th sentiment indicator62- Increase from 3/5 to 4/5 indicators typically available6364---6566### 2. Add Parallel Async Fetching67**Status**: ✅ DONE (sentiment indicators)68**Priority**: High69**Effort**: 4-6 hours7071**Current State**:72- ✅ Sentiment indicators fetched in parallel via `asyncio.gather()`73- ✅ 10s timeout per indicator74- Main data fetches (yfinance) still sequential (acceptable)7576**Tasks**:77- [ ] Convert sentiment helper functions to async78- [ ] `async def get_fear_greed_index()`79- [ ] `async def get_short_interest(data)`80- [ ] `async def get_vix_term_structure()`81- [ ] `async def get_insider_activity(ticker)`82- [ ] `async def get_put_call_ratio(data)`83- [ ] Update `analyze_sentiment()` to use `asyncio.gather()`84- [ ] Handle yfinance thread safety (may need locks)85- [ ] Add timeout per indicator (10s max)86- [ ] Test with multiple stocks in sequence87- [ ] Measure actual runtime improvement88- [ ] Update SKILL.md with new runtime (target: 3-4s)8990**Expected Impact**:91- Reduce runtime from 6-10s to 3-4s per stock92- Better user experience for multi-stock analysis9394---9596### 3. Add Caching for Shared Indicators97**Status**: ✅ DONE (sentiment + breaking news)98**Priority**: Medium99**Effort**: 2-3 hours100101**Current State**:102- ✅ Fear & Greed Index cached (1h TTL)103- ✅ VIX term structure cached (1h TTL)104- ✅ Breaking news cached (1h TTL)105- ✅ Market context (VIX/SPY/QQQ/GLD/TLT/UUP) cached (1h TTL)106107**Tasks**:108- [ ] Design cache structure (simple dict or functools.lru_cache)109- [ ] Implement TTL (time-to-live):110- Fear & Greed: 1 hour111- VIX structure: 1 hour112- Short interest: No cache (per-stock)113- Insider activity: No cache (per-stock)114- Put/Call ratio: No cache (per-stock)115- [ ] Add cache invalidation logic116- [ ] Add verbose logging for cache hits/misses117- [ ] Test multi-stock analysis (e.g., `BAC TSLA AAPL`)118- [ ] Measure performance improvement119- [ ] Document caching behavior in SKILL.md120121**Expected Impact**:122- Multi-stock analysis faster (e.g., 3 stocks: 18-30s → 10-15s)123- Reduced API calls to Fear/Greed and VIX data sources124- Same-session analysis efficiency125126---127128### 4. Monitor SEC EDGAR Rate Limits129**Status**: Not Started130**Priority**: Low (until insider trading implemented)131**Effort**: 1-2 hours132133**Current State**:134- SEC EDGAR API has 10 requests/second rate limit135- No rate limit tracking or logging136- edgartools may handle rate limiting internally137138**Tasks**:139- [ ] Research edgartools rate limit handling140- [ ] Add request counter/tracker if needed141- [ ] Implement exponential backoff on 429 errors142- [ ] Add logging for rate limit hits143- [ ] Test with high-volume scenarios (10+ stocks in quick succession)144- [ ] Document rate limit behavior145- [ ] Add error message if rate limited: "SEC API rate limited, try again in 1 minute"146147**Expected Impact**:148- Robust handling of SEC API limits in production149- Clear user feedback if limits hit150- Prevent API blocking/banning151152---153154## Stock Analysis 4.0: Geopolitical Risk & News Sentiment155156### What's Currently Missing157158The current implementation captures:159- ✅ VIX (general market fear)160- ✅ SPY/QQQ trends (market direction)161- ✅ Sector performance162163What we **don't** have yet:164- ❌ Geopolitical risk indicators165- ❌ News sentiment analysis166- ❌ Sector-specific crisis flags167168---169170### 7. Geopolitical Risk Index171**Status**: ✅ DONE (keyword-based)172**Priority**: High173**Effort**: 8-12 hours174175**Proposed Approach**:176Option A: Use GPRD (Geopolitical Risk Daily Index) from policyuncertainty.com177Option B: Scan news APIs (NewsAPI, GDELT) for geopolitical keywords178179**Tasks**:180- [ ] Research free geopolitical risk data sources181- [ ] Check policyuncertainty.com API availability182- [ ] Evaluate NewsAPI free tier limits183- [ ] Consider GDELT Project (free, comprehensive)184- [ ] Design risk scoring system (0-100 scale)185- [ ] Implement data fetching with caching (4-hour TTL)186- [ ] Map risk levels to sentiment scores:187- Low risk (0-30): +0.2 (bullish)188- Moderate risk (30-60): 0 (neutral)189- High risk (60-80): -0.3 (caution)190- Extreme risk (80-100): -0.5 (bearish)191- [ ] Add to sentiment analysis as 6th indicator192- [ ] Test with historical crisis periods193- [ ] Update SKILL.md with geopolitical indicator194195**Expected Impact**:196- Early warning for market-wide risk events197- Better context for earnings-season volatility198- Complement to VIX (VIX is reactive, geopolitical is predictive)199200**Example Output**:201```202⚠️ GEOPOLITICAL RISK: HIGH (72/100)203Context: Elevated Taiwan tensions detected204Market Impact: Risk-off sentiment likely205```206207---208209### 8. Sector-Specific Crisis Mapping210**Status**: ✅ DONE211**Priority**: High212**Effort**: 6-8 hours213214**Current Gap**:215- No mapping between geopolitical events and affected sectors216- No automatic flagging of at-risk holdings217218**Proposed Risk Mapping**:219220| Geopolitical Event | Affected Sectors | Example Tickers |221|-------------------|------------------|-----------------|222| Taiwan conflict | Semiconductors | NVDA, AMD, TSM, INTC |223| Russia-Ukraine | Energy, Agriculture | XLE, MOS, CF, NTR |224| Middle East escalation | Oil, Defense | XOM, CVX, LMT, RTX |225| China tensions | Tech supply chain, Retail | AAPL, QCOM, NKE, SBUX |226| Banking crisis | Financials | JPM, BAC, WFC, C |227228**Tasks**:229- [ ] Build event → sector → ticker mapping database230- [ ] Implement keyword detection in news feeds:231- "Taiwan" + "military" → Semiconductors ⚠️232- "Russia" + "sanctions" → Energy ⚠️233- "Iran" + "attack" → Oil, Defense ⚠️234- "China" + "tariffs" → Tech, Consumer ⚠️235- [ ] Add sector exposure check to analysis236- [ ] Generate automatic warnings in output237- [ ] Apply confidence penalty for high-risk sectors238- [ ] Test with historical crisis events239- [ ] Document in SKILL.md240241**Expected Impact**:242- Automatic detection of sector-specific risks243- Clear warnings for exposed holdings244- Reduced false positives (only flag relevant sectors)245246**Example Output**:247```248⚠️ SECTOR RISK ALERT: Semiconductors249Event: Taiwan military exercises (elevated tensions)250Impact: NVDA HIGH RISK - supply chain exposure251Recommendation: HOLD → downgraded from BUY252```253254---255256### 9. Breaking News Check257**Status**: ✅ DONE258**Priority**: Medium259**Effort**: 4-6 hours260261**Current Gap**:262- No real-time news scanning before analysis263- User might get stale recommendation during breaking events264265**Proposed Solution**:266- Scan Google News or Reuters RSS before analysis267- Flag high-impact keywords within last 24 hours268269**Tasks**:270- [ ] Choose news source (Google News RSS, Reuters API, or NewsAPI)271- [ ] Implement news fetching with 24-hour lookback272- [ ] Define crisis keywords:273- **War/Conflict**: "war", "invasion", "military strike", "attack"274- **Economic**: "recession", "crisis", "collapse", "default"275- **Regulatory**: "sanctions", "embargo", "ban", "investigation"276- **Natural disaster**: "earthquake", "hurricane", "pandemic"277- [ ] Add ticker-specific news check (company name + keywords)278- [ ] Generate automatic caveat in output279- [ ] Cache news check results (1 hour TTL)280- [ ] Add `--skip-news` flag for offline mode281- [ ] Test with historical crisis dates282- [ ] Document in SKILL.md283284**Expected Impact**:285- Real-time awareness of breaking events286- Automatic caveats during high volatility287- User protection from stale recommendations288289**Example Output**:290```291⚠️ BREAKING NEWS ALERT (last 6 hours):292"Fed announces emergency rate hike"293Impact: Market-wide volatility expected294Caveat: Analysis may be outdated - rerun in 24h295```296297---298299### 10. Safe-Haven Indicators300**Status**: ✅ DONE301**Priority**: Medium302**Effort**: 3-4 hours303304**Current Gap**:305- No detection of "risk-off" market regime306- VIX alone is insufficient (measures implied volatility, not capital flows)307308**Proposed Indicators**:309- Gold (GLD) - Flight to safety310- US Treasuries (TLT) - Bond market fear311- USD Index (UUP) - Dollar strength during crisis312313**Risk-Off Detection Logic**:314```315IF GLD +2% AND TLT +1% AND UUP +1% (all rising together)316THEN Market Regime = RISK-OFF317```318319**Tasks**:320- [ ] Fetch GLD, TLT, UUP price data (5-day change)321- [ ] Implement risk-off detection algorithm322- [ ] Add to market context analysis323- [ ] Apply broad risk penalty:324- Risk-off detected → Reduce all BUY confidence by 30%325- Add caveat: "Market in risk-off mode - defensive positioning recommended"326- [ ] Test with historical crisis periods (2008, 2020, 2022)327- [ ] Add verbose output for safe-haven movements328- [ ] Document in SKILL.md329330**Expected Impact**:331- Detect market-wide flight to safety332- Automatic risk reduction during panics333- Complement geopolitical risk scoring334335**Example Output**:336```337🛡️ SAFE-HAVEN ALERT: Risk-off mode detected338- Gold (GLD): +3.2% (5d)339- Treasuries (TLT): +2.1% (5d)340- USD Index: +1.8% (5d)341Recommendation: Reduce equity exposure, favor defensives342```343344---345346## General Improvements347348### 11. Add Social Sentiment (Future Phase)349**Status**: Deferred350**Priority**: Low351**Effort**: 8-12 hours352353**Notes**:354- Requires free API (Twitter/Reddit alternatives?)355- Most sentiment APIs are paid (StockTwits, etc.)356- Research needed for viable free sources357358### 12. Add Fund Flows (Future Phase)359**Status**: Deferred360**Priority**: Low361**Effort**: 6-8 hours362363**Notes**:364- Requires ETF flow data365- May need paid data source366- Research free alternatives367368---369370## Implementation Priorities371372### v4.1.0 Complete373- ✅ Task #1 - Insider trading parsing via edgartools374- ✅ Task #3b - Market context caching (1h TTL)375- 🔧 Task #4 - SEC EDGAR rate limits (low priority, only if hitting limits)376377### Completed in v4.0.0378- ✅ Task #2 - Async parallel fetching (sentiment)379- ✅ Task #3 - Caching for shared indicators (sentiment + news)380- ✅ Task #7 - Geopolitical risk (keyword-based)381- ✅ Task #8 - Sector-specific crisis mapping382- ✅ Task #9 - Breaking news check383- ✅ Task #10 - Safe-haven indicators384385---386387## Version History388389- **v5.0.0** (2026-01-16): Portfolio management, cryptocurrency support (Top 20), periodic analysis390- **v4.1.0** (2026-01-16): Full insider trading parsing via edgartools, market context caching391- **v4.0.0** (2026-01-15): Geopolitical risk, breaking news, safe-haven detection, sector crisis mapping392- **v3.0.0** (2026-01-15): Sentiment analysis added with 5 indicators (3-4 typically working)393- **v2.0.0**: Market context, sector performance, earnings timing, momentum394- **v1.0.0**: Initial release with earnings, fundamentals, analysts, historical395