Skip to content

Latest commit

 

History

History
150 lines (121 loc) · 4.13 KB

File metadata and controls

150 lines (121 loc) · 4.13 KB

AI Features & Stock Tracker Setup Guide

Your portfolio tracker now has AI-powered features and advanced stock analysis! Here's the complete guide.

Free AI Options

1. Groq (Recommended - FREE)

Groq provides free access to Llama 3.1 70B and Mixtral models with very fast inference.

Features enabled:

  • Portfolio analysis & recommendations
  • Stock analysis
  • AI Chat assistant

Setup:

  1. Go to https://console.groq.com/keys
  2. Sign up (free)
  3. Create an API key
  4. Add to backend/.env:
    GROQ_API_KEY=your-groq-api-key-here
    

2. Perplexity (Optional - $5/month with Pro)

If you have Perplexity Pro subscription, you can use their API for real-time news.

Features enabled:

  • Real-time stock news
  • Market sentiment analysis

Setup:

  1. Go to https://www.perplexity.ai/settings/api
  2. Generate an API key
  3. Add to backend/.env:
    PERPLEXITY_API_KEY=your-perplexity-api-key-here
    

Features Overview

AI Chat (Bottom-right corner)

  • Ask questions about your portfolio
  • Get stock recommendations
  • Market insights
  • Requires: Groq API

AI Insights Panel (Dashboard)

  • Portfolio risk analysis
  • Sector allocation insights
  • Personalized recommendations
  • Works without API (rule-based fallback)

Stock Analysis (Stock Detail Page)

  • AI-generated stock analysis
  • Key insights and outlook
  • Requires: Groq API

Stock News (Stock Detail Page)

  • Real-time news for any stock
  • Source citations
  • Requires: Perplexity API

Without API Keys

The app still works without API keys:

  • Portfolio analysis uses rule-based calculations
  • Risk scores and recommendations are generated locally
  • News and chat features show "API required" messages

New Stock Features (No API Required)

Stock Detail Page

  • Real Fundamentals: P/E, ROE, debt ratios from Yahoo Finance
  • Fair Value Estimate: Like SimplyWall.St - shows if stock is undervalued/overvalued
  • Health Scores Radar: Snowflake chart showing Value, Growth, Health, Dividend scores
  • Investment Checklist: Auto-calculated checks based on fundamentals
  • Stock Comparison: Compare multiple stocks on same chart
  • Price Alerts: Set alerts for price targets (stored locally)
  • Improved Charts: Smoother animations, better date formatting

Portfolio Manager (Stocks Page)

  • Analytics Tab: Sector allocation, risk assessment, diversification score
  • Returns Tab: Real P&L calculations, CAGR estimates, top contributors
  • Dividends Tab: Track dividend income, yield analysis
  • Discover Tab: Stock screener with preset filters
  • Mini Charts: Sparkline charts in holdings table
  • Market Status: Live market open/closed indicator

Dashboard (Home Page)

  • Top Movers: Real gainers/losers from database
  • Sector Allocation: Pie chart of your holdings by sector
  • AI Insights: Portfolio recommendations

Backend Services

Price Cache Manager

  • Caches live prices with 30s TTL
  • Batch fetching for multiple tickers
  • Fallback to individual requests

Stock Fundamentals Service

  • Fetches from Yahoo Finance API
  • Fair value calculation
  • Health score computation

New API Endpoints

  • POST /api/stocks/live - Batch live prices
  • GET /api/stocks/<ticker>/fundamentals - Detailed fundamentals
  • GET /api/stocks/<ticker>/spark - Sparkline data
  • GET /api/stocks/<ticker>/dividends - Dividend info
  • GET /api/stocks/movers - Top gainers/losers

Testing

After adding API keys, restart the backend:

cd backend
python app.py

Then test the AI status endpoint:

GET http://localhost:5000/api/ai/status

Should return:

{
  "groq_available": true,
  "perplexity_available": true,
  "features": {
    "portfolio_analysis": true,
    "stock_analysis": true,
    "news": true,
    "chat": true,
    "market_sentiment": true
  }
}

Test fundamentals endpoint:

GET http://localhost:5000/api/stocks/RELIANCE/fundamentals

Inspired By