From 0121cb6097df437a8a003e5663ad72990d29d7c2 Mon Sep 17 00:00:00 2001 From: JamesTang Date: Wed, 4 Feb 2026 10:41:02 +0800 Subject: [PATCH] Initial commit: UI/UX dashboard skeleton - Basic Flask backend with mock metrics API - Bootstrap/Chart.js frontend dashboard - Displays key metrics: PnL, drawdown, win rate - Interactive charts and auto-refresh - Ready for integration with real data sources --- .gitignore | 53 ++++++ README.md | 31 ++++ app.py | 70 ++++++++ requirements.txt | 1 + templates/dashboard.html | 356 +++++++++++++++++++++++++++++++++++++++ 5 files changed, 511 insertions(+) create mode 100644 .gitignore create mode 100644 README.md create mode 100644 app.py create mode 100644 requirements.txt create mode 100644 templates/dashboard.html diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..fdf592c --- /dev/null +++ b/.gitignore @@ -0,0 +1,53 @@ +# Python +__pycache__/ +*.py[cod] +*$py.class +*.so +.Python +build/ +develop-eggs/ +dist/ +downloads/ +eggs/ +.eggs/ +lib/ +lib64/ +parts/ +sdist/ +var/ +wheels/ +*.egg-info/ +.installed.cfg +*.egg + +# Virtual Environment +.env +.venv +env/ +venv/ +ENV/ +env.bak/ +venv.bak/ + +# IDE +.vscode/ +.idea/ +*.swp +*.swo + +# OS +.DS_Store +Thumbs.db + +# Logs +*.log + +# Environment variables +.env.local +.env.development.local +.env.test.local +.env.production.local + +# Temporary files +tmp/ +temp/ \ No newline at end of file diff --git a/README.md b/README.md new file mode 100644 index 0000000..7daaa75 --- /dev/null +++ b/README.md @@ -0,0 +1,31 @@ +# Quantitative Trading Platform + +A quantitative trading platform with modular architecture for data acquisition, strategy execution, risk management, and UI/UX. + +## Architecture + +See `component_diagram.md` and `architecture_diagram.txt` in the parent directory (`/home/thanthos/clawd/`) for detailed system design. + +## UI/UX Module + +### Dashboard +Simple dashboard displaying key trading metrics: +- PnL (Profit and Loss) +- Drawdown +- Win Rate + +## Development + +### Prerequisites +- Python 3.8+ +- Node.js (for frontend) +- Docker (optional) + +### Setup +1. Clone the repository +2. Install dependencies: `pip install -r requirements.txt` +3. Run the dashboard: `python app.py` + +## License + +Proprietary \ No newline at end of file diff --git a/app.py b/app.py new file mode 100644 index 0000000..8e01999 --- /dev/null +++ b/app.py @@ -0,0 +1,70 @@ +#!/usr/bin/env python3 +""" +Simple dashboard server for Quantitative Trading Platform. +Provides mock metrics for PnL, drawdown, and win rate. +""" + +from flask import Flask, render_template, jsonify +import random +from datetime import datetime, timedelta + +app = Flask(__name__) + +def generate_mock_metrics(): + """Generate realistic mock trading metrics.""" + # Simulate daily PnL over last 30 days + end_date = datetime.now() + start_date = end_date - timedelta(days=30) + + daily_pnl = [] + current_pnl = 0 + for i in range(30): + day_pnl = random.uniform(-500, 1500) + current_pnl += day_pnl + daily_pnl.append({ + 'date': (start_date + timedelta(days=i)).strftime('%Y-%m-%d'), + 'pnl': round(day_pnl, 2), + 'cumulative': round(current_pnl, 2) + }) + + # Calculate derived metrics + total_pnl = current_pnl + peak = max([d['cumulative'] for d in daily_pnl]) + trough = min([d['cumulative'] for d in daily_pnl]) + max_drawdown = round(abs(trough - peak), 2) if peak > 0 else 0 + + # Win rate (percentage of profitable days) + profitable_days = sum(1 for d in daily_pnl if d['pnl'] > 0) + win_rate = round(profitable_days / len(daily_pnl) * 100, 1) + + # Current portfolio value (simulated) + portfolio_value = 100000 + total_pnl + + return { + 'total_pnl': round(total_pnl, 2), + 'daily_pnl': daily_pnl, + 'max_drawdown': max_drawdown, + 'win_rate': win_rate, + 'portfolio_value': round(portfolio_value, 2), + 'peak': round(peak, 2), + 'trough': round(trough, 2), + 'last_updated': end_date.isoformat() + } + +@app.route('/') +def dashboard(): + """Serve the dashboard HTML page.""" + return render_template('dashboard.html') + +@app.route('/api/metrics') +def metrics(): + """API endpoint returning current metrics.""" + return jsonify(generate_mock_metrics()) + +@app.route('/health') +def health(): + """Health check endpoint.""" + return jsonify({'status': 'healthy', 'timestamp': datetime.now().isoformat()}) + +if __name__ == '__main__': + app.run(host='0.0.0.0', port=5000, debug=True) \ No newline at end of file diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 0000000..cc35792 --- /dev/null +++ b/requirements.txt @@ -0,0 +1 @@ +Flask==2.3.3 \ No newline at end of file diff --git a/templates/dashboard.html b/templates/dashboard.html new file mode 100644 index 0000000..6bff632 --- /dev/null +++ b/templates/dashboard.html @@ -0,0 +1,356 @@ + + + + + + Quantitative Trading Platform - Dashboard + + + + + + + + + + +
+ +
+
+

Trading Dashboard

+

Real-time metrics and performance monitoring

+
+
+ +
+
+ + +
+
+
+
+
Total P&L
+
$0.00
+

+ +0.0% + vs. last month +

+
+
+
+
+
+
+
Max Drawdown
+
$0.00
+

+ 0.0% + of portfolio +

+
+
+
+
+
+
+
Win Rate
+
0.0%
+

+ 0/30 + profitable days +

+
+
+
+
+ + +
+
+
+

Cumulative P&L Over Time

+ +
+
+
+
+

Portfolio Overview

+
+

Portfolio Value: $100,000.00

+

Peak Value: $100,000.00

+

Trough Value: $100,000.00

+

Last Updated: Just now

+
+
+
Daily P&L Distribution
+ +
+
+
+ + +
+
+
+

Recent Daily Performance

+ + + + + + + + + + + + +
DateDaily P&LCumulative P&LStatus
+
+
+
+
+ + + + + + + + + + + \ No newline at end of file