# 🏆 Gold Trading Simulator

**An AI-powered gold trading scenario simulator with professional-grade charting, analytics, and risk management tools.**

[![FastAPI](https://img.shields.io/badge/FastAPI-0.109+-009688?logo=fastapi&logoColor=white)](https://fastapi.tiangolo.com/)
[![React](https://img.shields.io/badge/React-18.2+-61DAFB?logo=react&logoColor=black)](https://react.dev/)
[![TypeScript](https://img.shields.io/badge/TypeScript-5.3+-3178C6?logo=typescript&logoColor=white)](https://www.typescriptlang.org/)
[![TailwindCSS](https://img.shields.io/badge/TailwindCSS-3.4+-06B6D4?logo=tailwindcss&logoColor=white)](https://tailwindcss.com/)

---

## 📖 Documentation

**All comprehensive documentation has been consolidated in the [`docs/`](./docs) directory.**

### Quick Links
- 🚀 **[Quick Start Guide](./docs/QUICKSTART.md)** - Get running in 5 minutes
- 📋 **[Complete Documentation](./docs/README.md)** - Full project documentation
- 💡 **[Feature Overview](./docs/ENHANCEMENT_SUMMARY.md)** - All features explained
- 📊 **[Daily Workflow](./docs/DAILY_TRADING_WORKFLOW.md)** - Trading best practices

---

## ✨ Key Features

- **Real-time candlestick charts** with WebSocket streaming
- **AI-powered trade analysis** using Claude/GPT-4
- **9+ technical indicators** (SMA, EMA, RSI, MACD, Bollinger Bands, etc.)
- **Advanced analytics** (Win rate, Sharpe ratio, drawdown analysis)
- **Risk management tools** with position sizing
- **Live financial news** with AI summarization
- **Customizable dashboard** with 5+ presets
- **22+ professional UI components**

---

## 🚀 Quick Start

### Prerequisites
- Node.js 18+ and Python 3.11+
- Docker (for PostgreSQL)
- API Keys: [Alpha Vantage](https://www.alphavantage.co/) (free) + [OpenRouter](https://openrouter.ai/) (~$5)

### Setup (5 minutes)

```bash
# 1. Clone and navigate
git clone <repository-url>
cd gold-trading-simulator

# 2. Start database
docker-compose up -d

# 3. Backend setup (Terminal 1)
cd backend
python -m venv venv
source venv/bin/activate  # Windows: venv\Scripts\activate
pip install -r requirements.txt
# Create backend/.env and add your API keys
python -m app.main

# 4. Frontend setup (Terminal 2)
cd frontend
npm install
npm run dev
```

**Open browser**: http://localhost:3000

👉 **See [QUICKSTART.md](./docs/QUICKSTART.md) for detailed instructions**

---

## 🏗️ Project Structure

```
gold-trading-simulator/
├── backend/              # FastAPI Python backend
│   ├── app/
│   │   ├── api/         # REST API endpoints
│   │   ├── services/    # Business logic
│   │   ├── streaming/   # WebSocket handlers
│   │   └── models/      # Database models
│   └── requirements.txt
├── frontend/            # React + TypeScript frontend
│   ├── src/
│   │   ├── components/  # 22+ UI components
│   │   ├── services/    # API clients
│   │   └── utils/       # Indicators & helpers
│   └── package.json
├── database/            # DB initialization
├── docs/                # 📚 Complete documentation
└── docker-compose.yml   # PostgreSQL setup
```

---

## 🛠️ Technology Stack

**Backend**: FastAPI • PostgreSQL • SQLAlchemy • WebSockets • Pandas  
**Frontend**: React 18 • TypeScript • Vite • TailwindCSS • Lightweight Charts  
**APIs**: Alpha Vantage • OpenRouter AI  

---

## 📡 API Endpoints

### Market Data
- `GET /api/market/gold/current` - Current price
- `GET /api/market/gold/historical` - Historical data
- `GET /api/ohlcv/klines` - Live OHLCV data

### Trading
- `POST /api/trading/buy` - Execute buy
- `POST /api/trading/sell` - Execute sell
- `GET /api/trading/portfolio` - Portfolio status

### AI Analysis
- `POST /api/ai/analyze` - AI trade recommendation
- `POST /api/ai/summarize-news` - News summary

### News & Alerts
- `GET /api/news/headlines` - Latest news
- `POST /api/alerts/create` - Create alert

### Live Streaming
- `WS /api/stream/price` - Real-time price updates

---

## 🎯 Use Cases

- **Trading Education** - Learn technical analysis and trading strategies
- **Strategy Testing** - Backtest and validate trading ideas
- **Portfolio Management** - Practice risk management and position sizing
- **AI Integration** - Explore AI-powered trading recommendations
- **Full-Stack Demo** - Showcase modern web development skills

---

## 📚 Full Documentation

For complete setup instructions, feature guides, customization options, and more:

👉 **[Visit the docs/ directory](./docs/README.md)**

### Documentation Index
- Setup & Configuration
  - [Quick Start](./docs/QUICKSTART.md)
  - [Setup Notes](./docs/SETUP_NOTES.md)
  - [Production Controls](./docs/PRODUCTION_READY_CONTROLS.md)

- Features & Capabilities
  - [Enhancement Summary](./docs/ENHANCEMENT_SUMMARY.md)
  - [Live Chart Implementation](./docs/LIVE_CHART_IMPLEMENTATION.md)
  - [News & Alerts](./docs/NEWS_AND_ALERTS_GUIDE.md)

- Usage Guides
  - [Daily Trading Workflow](./docs/DAILY_TRADING_WORKFLOW.md)
  - [Dashboard Customization](./docs/DASHBOARD_CUSTOMIZATION_GUIDE.md)
  - [Simulated Feed Guide](./docs/SIMULATED_FEED_GUIDE.md)

- Development
  - [Testing Checklist](./docs/TESTING_CHECKLIST.md)
  - [Chart Fix Summary](./docs/CHART_FIX_SUMMARY.md)

---

## ⚠️ Disclaimer

This is a **simulation and educational tool**. Not financial advice. Do not use for actual trading decisions. No real money involved.

---

## 📄 License

This is a demonstration project. Feel free to fork and modify for educational purposes.

---

**Built with ❤️ using FastAPI, React, and modern web technologies**
