Skip to content
Shell
5.8 KB
Raw Blame

Perplexity Finance Deep Integration Plan

Goal

Deeply embed Perplexity Finance throughout DeepStack - replacing news feeds, enhancing AI chat, and adding SEC filings, earnings transcripts, natural language screening, and deep research capabilities.


Phase 1: AI Chat Enhancement (MCP-Powered)

Priority: HIGHEST | Immediate value

New Files

  • /web/src/lib/llm/perplexity-finance-tools.ts - Chat tools for:
    • search_sec_filings - Query 10-K, 10-Q, S-1, 8-K filings
    • get_market_summary - AI market intelligence
    • search_earnings_transcripts - S&P 500 earnings calls
    • natural_language_screen - Conversational stock screening
    • build_company_profile - Company deep-dives
    • generate_deep_research - Comprehensive reports

Modify

  • /web/src/app/api/chat/route.ts - Integrate perplexity finance tools
  • /core/api/credits.py - Add credit costs (SEC_SEARCH=10, DEEP_RESEARCH=50)

Outcome

Chat answers "What did Apple say about AI in their 10-K?" by searching SEC filings natively.


Phase 2: Backend Perplexity Finance Client

Priority: HIGH | Foundation for everything

New Files

  • /core/data/perplexity_finance_client.py
class PerplexityFinanceClient:
    async def search_sec_filings(symbol, filing_type, date_after)
    async def get_market_summary(topics)
    async def get_earnings_transcript(symbol, quarter)
    async def natural_language_screen(query)
    async def build_profile(entity)
    async def deep_research(topic, focus_areas)

New API Endpoints

Endpoint Credit Cost
GET /api/sec/search 10
GET /api/earnings/transcript 15
GET /api/market/summary 5
POST /api/screener/natural 20
GET /api/profile/{entity} 15
POST /api/research/deep 50

Modify

  • /core/config.py - Add perplexity_api_key
  • /core/api_server.py - Register client and endpoints

Phase 3: Replace News with Perplexity Intelligence

Priority: HIGH | Visible improvement

New Files

  • /core/services/perplexity_intelligence.py - AI-synthesized market intelligence

Modify

  • /core/services/news_aggregator.py - Perplexity as primary, RSS as secondary
  • /core/api_server.py - New /api/news/intelligence endpoint
  • /web/src/lib/stores/news-store.ts - Add 'perplexity' source type
  • /web/src/components/trading/NewsPanel.tsx - Add "AI Intelligence" tab

Deprecate (keep for backward compat)

  • /core/data/finnhub_client.py
  • /core/data/newsapi_client.py

Phase 4: New UI Components

Priority: MEDIUM | User-facing features

4.1 SEC Filing Search Panel

  • /web/src/components/trading/SECFilingsPanel.tsx
  • Symbol search, filing type filter, AI summaries, EDGAR links

4.2 Earnings Transcript Viewer

  • /web/src/components/trading/EarningsTranscriptViewer.tsx
  • Quarter selector, key points summary, sentiment analysis

4.3 Market Summary Widget

  • /web/src/components/widgets/MarketSummaryWidget.tsx
  • Dashboard widget, 15-min auto-refresh, sector highlights

4.4 Natural Language Screener

  • /web/src/components/trading/NLScreenerPanel.tsx
  • "Find tech stocks with P/E < 20 growing revenue 20%+"

4.5 Company Profile Builder

  • /web/src/components/trading/CompanyProfilePanel.tsx
  • Deep-dive profiles, exec backgrounds, risk factors

4.6 Deep Research Panel

  • /web/src/components/trading/DeepResearchPanel.tsx
  • Topic input, focus areas, PDF export, progress indicator

Store

  • /web/src/lib/stores/perplexity-finance-store.ts - State for all above

Phase 5: Politicians Trading Panel

Priority: LOW | Unique alpha

New Files

  • /web/src/components/trading/PoliticiansTradePanel.tsx
  • Congressional trades, party filter, AI pattern analysis

New Endpoints

  • GET /api/politicians/trades
  • GET /api/politicians/trades/{symbol}

Phase 6: Integration & Polish

Priority: FINAL | Tie it together

Modify

  • /web/src/components/trading/SymbolSearchDialog.tsx - Quick Profile button
  • /web/src/components/trading/ThesisTracker.tsx - "Research with AI" button
  • Mobile optimization for all new panels

Technical Details

Credit System

Feature Cost Rationale
SEC Search 10 Moderate value
Earnings Transcript 15 Premium data
Market Summary 5 Encourage frequent use
NL Screener 20 AI-powered
Profile 15 Deep research
Deep Research 50 Expensive API
Politicians 0 Free data

Caching

Data TTL
SEC Filings 24h
Transcripts 7 days
Market Summary 15 min
Profiles 1h

Environment

PERPLEXITY_API_KEY=pplx-xxxx

Build Sequence

Week 1: Foundation

  • Phase 1: AI Chat Enhancement
  • Phase 2: Backend Client

Week 2: Core Features

  • Phase 3: News Replacement
  • Phase 4.3: Market Summary Widget

Week 3: Advanced Features

  • Phase 4.1: SEC Filing Search
  • Phase 4.2: Earnings Transcript Viewer
  • Phase 4.4: NL Screener

Week 4: Polish

  • Phase 4.5: Company Profile Builder
  • Phase 4.6: Deep Research Panel
  • Phase 5: Politicians Trading
  • Phase 6: Integration

Agent Assignments

Phase Agent Role
1 ai-engineer Chat tool integration
2 backend-architect Python client + API design
3 fullstack-developer News replacement
4 frontend-developer UI components
5 frontend-developer Politicians panel
6 code-reviewer Final review
* Claude (watcher) Verify each phase before proceeding

Success Criteria

  • Chat answers SEC filing questions accurately
  • News panel shows AI-synthesized intelligence (not raw feeds)
  • Users can screen stocks with natural language
  • Deep research generates comprehensive reports
  • All features work within credit budget
  • Mobile-responsive