38835-vm/README.md

151 lines
5.9 KiB
Markdown

<p align="center">
<h1 align="center">πŸ“Š FinanceIQ</h1>
<p align="center">
<strong>Real-time Financial Analytics & Portfolio Simulation Platform</strong>
</p>
<p align="center">
<img src="https://img.shields.io/badge/python-3.10+-blue?style=flat-square&logo=python" alt="Python">
<img src="https://img.shields.io/badge/flask-3.x-green?style=flat-square&logo=flask" alt="Flask">
<img src="https://img.shields.io/badge/version-5.2-purple?style=flat-square" alt="Version">
<img src="https://img.shields.io/badge/license-MIT-yellow?style=flat-square" alt="License">
</p>
</p>
---
A full-stack financial analytics web application built with **Flask**, **yfinance**, and **Google Gemini AI**. Features interactive charting, professional-grade portfolio simulation, options pricing, backtesting, AI-driven advisory, and a live market dashboard β€” all in a sleek, responsive single-page dashboard.
## ✨ Features
### πŸ“ˆ Market Analysis
- **Interactive Candlestick Charts** β€” powered by TradingView Lightweight Charts
- **Technical Indicators** β€” RSI, MACD, Bollinger Bands, SMA/EMA, ATR, Stochastic
- **Candlestick Pattern Recognition** β€” Doji, Hammer, Engulfing, Morning Star, and more
- **Key Financial Metrics** β€” P/E, ROE, D/E, Quick Ratio, Dividend Yield
- **Sector Peer Comparison** β€” heatmap of competitors across 7 sectors
- **Valuation Models** β€” DCF, Graham Number, PEG Ratio, DDM
### πŸ’Ό Portfolio Simulation
- **$100K Paper Trading** β€” buy/sell with real-time prices from Yahoo Finance
- **Advanced Order Types** β€” Market, Limit, and Stop orders
- **Short Selling** β€” open and cover short positions with margin tracking
- **Slippage & Commission Modeling** β€” realistic IBKR-style execution costs
- **Equity Curve** β€” track portfolio value over time with interactive charts
- **Performance Analytics** β€” Sharpe, Sortino, Calmar ratios, profit factor, max drawdown
### 🎯 Options Pricing
- **Black-Scholes Model** β€” call/put pricing with real-time IV
- **Greeks Dashboard** β€” Delta, Gamma, Theta, Vega, Rho
- **Monte Carlo Simulation** β€” 10,000-path price projections
- **Interactive Payoff Charts** β€” visualize P&L at expiration
### πŸ€– AI-Powered Advisory
- **Gemini AI Integration** β€” personalized investment analysis
- **Macro Dashboard** β€” Fed rates, Treasury yields, VIX, DXY, oil, gold
- **Risk Assessment** β€” automated risk scoring with traffic-light indicators
- **Natural Language Insights** β€” ask questions about any stock
### πŸ“° News & Sentiment
- **Real-time News Feed** β€” latest headlines for any ticker
- **AI Sentiment Analysis** β€” bullish/bearish/neutral classification
- **Currency Converter** β€” 150+ currency pairs with live rates
### πŸ”¬ Backtesting Engine
- **Strategy Backtester** β€” SMA crossover, RSI, MACD, Bollinger Band strategies
- **Bi-directional Trading** β€” long and short strategy support
- **Performance Metrics** β€” Sharpe ratio, win rate, max drawdown, trade log
### 🌍 Market Dashboard
- **Global Indices** β€” S&P 500, NASDAQ, Dow, FTSE, Nikkei, DAX
- **Commodities** β€” Gold, Silver, Crude Oil, Natural Gas
- **Currency Pairs** β€” EUR/USD, GBP/USD, USD/JPY, and more
- **Live Pulse** β€” auto-refreshing with animated counters
## πŸš€ Quick Start
### Prerequisites
- Python 3.10+
- Google Gemini API key ([Get one here](https://makersuite.google.com/app/apikey))
### Installation
```bash
# Clone the repo
git clone https://github.com/YOUR_USERNAME/FinanceIQ.git
cd FinanceIQ
# Install dependencies
pip install -r requirements.txt
# Set up environment variables
cp .env.example .env
# Edit .env and add your GEMINI_API_KEY
# Run the application
python app.py
```
Then open `http://localhost:5000` in your browser.
## πŸ“ Project Structure
```
FinanceIQ/
β”œβ”€β”€ app.py # Flask server & API routes
β”œβ”€β”€ portfolio_engine.py # Portfolio simulation engine (SQLite-backed)
β”œβ”€β”€ options_engine.py # Black-Scholes, Greeks, Monte Carlo
β”œβ”€β”€ backtester.py # Strategy backtesting engine
β”œβ”€β”€ advisor.py # Gemini AI financial advisory
β”œβ”€β”€ technical_analyzer.py # Technical indicators & patterns
β”œβ”€β”€ news_analyzer.py # News fetching & sentiment analysis
β”œβ”€β”€ requirements.txt # Python dependencies
β”œβ”€β”€ .env.example # Environment variable template
β”œβ”€β”€ templates/
β”‚ └── index.html # Single-page dashboard UI
└── static/
β”œβ”€β”€ script.js # Frontend logic & chart rendering
└── style.css # Glassmorphism UI design system
```
## πŸ› οΈ Tech Stack
| Layer | Technology |
|-------|-----------|
| **Backend** | Flask, Python 3.10+ |
| **Data** | yfinance, Yahoo Finance API |
| **AI** | Google Gemini 2.0 Flash |
| **Database** | SQLite (WAL mode) |
| **Charts** | TradingView Lightweight Charts |
| **Frontend** | Vanilla JS, CSS (Glassmorphism) |
## πŸ“Š API Endpoints
| Endpoint | Method | Description |
|----------|--------|-------------|
| `/api/analyze` | POST | Full stock analysis |
| `/api/suggest` | GET | Ticker autocomplete |
| `/api/portfolio` | GET | Portfolio summary |
| `/api/portfolio/buy` | POST | Buy long |
| `/api/portfolio/sell` | POST | Sell long |
| `/api/portfolio/short` | POST | Short sell |
| `/api/portfolio/cover` | POST | Cover short |
| `/api/portfolio/limit-order` | POST | Place limit order |
| `/api/portfolio/stop-order` | POST | Place stop order |
| `/api/portfolio/analytics` | GET | Performance metrics |
| `/api/portfolio/equity-curve` | GET | Equity curve data |
| `/api/market-summary` | GET | Market dashboard data |
| `/api/options/price` | POST | Options pricing |
| `/api/backtest` | POST | Run backtests |
| `/api/advisor/analyze` | POST | AI advisory |
| `/api/news` | GET | News & sentiment |
## πŸ“œ License
This project is for educational purposes. Built as part of a university finance course.
---
<p align="center">
Built with ❀️ using Flask & yfinance
</p>