Signed-off-by: TIANHE <TIANHE@GMAIL.COM>
This commit is contained in:
TIANHE
2025-12-29 19:05:17 +08:00
parent 278b88ec71
commit 3337bcfc14
32 changed files with 5275 additions and 2770 deletions
+438 -55
View File
@@ -1,65 +1,169 @@
<div align="center">
<img src="https://ai.quantdinger.com/img/logo.e0f510a8.png" alt="QuantDinger" width="160" />
<h2>QuantDinger</h2>
<p>
A local-first quant research & trading workspace: market data, indicators, AI analysis, backtesting, and strategy execution in one place.
<a href="https://github.com/brokermr810/QuantDinger">
<img src="https://ai.quantdinger.com/img/logo.e0f510a8.png" alt="QuantDinger Logo" width="160" height="160">
</a>
<h1 align="center">QuantDinger</h1>
<p align="center">
<strong>🤖 AI-Native · 🔒 Privacy-First · 🚀 All-in-One Quant Workspace</strong>
</p>
<p>
<a href="https://www.quantdinger.com">Website</a>
·
<a href="https://ai.quantdinger.com">Live Demo</a>
<p align="center">
<i>The Next-Gen Local Quant Platform: Multi-Market Data, AI Research, Visual Backtesting, and Automated Trading.</i>
</p>
<p>
<a href="LICENSE"><img alt="License" src="https://img.shields.io/badge/License-Apache%202.0-blue.svg" /></a>
<img alt="Backend" src="https://img.shields.io/badge/Backend-Flask%20%2B%20SQLite-black" />
<img alt="Frontend" src="https://img.shields.io/badge/Frontend-Vue%202%20%2B%20Ant%20Design%20Vue-2c7be5" />
<a href="https://ai.quantdinger.com"><img alt="Demo" src="https://img.shields.io/badge/Demo-ai.quantdinger.com-00b894" /></a>
<p align="center">
<a href="https://www.quantdinger.com"><strong>Website</strong></a> ·
<a href="https://ai.quantdinger.com"><strong>Live Demo</strong></a> ·
<a href="https://github.com/brokermr810/QuantDinger/issues"><strong>Report Bug</strong></a> ·
<a href="https://github.com/brokermr810/QuantDinger/discussions"><strong>Discussions</strong></a>
</p>
<p align="center">
<a href="LICENSE"><img src="https://img.shields.io/badge/License-Apache%202.0-blue.svg?style=flat-square&logo=apache" alt="License"></a>
<img src="https://img.shields.io/badge/Python-3.10+-3776AB?style=flat-square&logo=python&logoColor=white" alt="Python">
<img src="https://img.shields.io/badge/Vue.js-2.x-4FC08D?style=flat-square&logo=vue.js&logoColor=white" alt="Vue">
<img src="https://img.shields.io/badge/Docker-Ready-2496ED?style=flat-square&logo=docker&logoColor=white" alt="Docker">
<img src="https://img.shields.io/github/stars/brokermr810/QuantDinger?style=flat-square&logo=github" alt="Stars">
</p>
<p align="center">
<a href="https://t.me/worldinbroker"><img src="https://img.shields.io/badge/Telegram-Join%20Chat-26A5E4?style=for-the-badge&logo=telegram" alt="Telegram"></a>
<a href="https://discord.gg/cn6HVE2KC"><img src="https://img.shields.io/badge/Discord-Join%20Server-5865F2?style=for-the-badge&logo=discord" alt="Discord"></a>
<a href="https://x.com/HenryCryption"><img src="https://img.shields.io/badge/X-Follow%20Us-000000?style=for-the-badge&logo=x" alt="X"></a>
</p>
</div>
---
This repository is intentionally simple (no PHP gateway): it contains **one Python backend** and **one web UI**.
## 📖 Introduction
- **`backend_api_python/`**: Flask API + strategy runtime + AI agents
- **`quantdinger_vue/`**: Vue 2 UI (Ant Design Vue based) with charts, backtests, and strategy management
**QuantDinger** is a **Local-First** quantitative trading workspace designed for traders, researchers, and geeks.
> This repo does not include real secrets. Configure API keys and credentials via `.env` / environment variables.
Unlike expensive SaaS platforms, QuantDinger returns **data ownership** to you. It features a built-in **LLM-based Multi-Agent Research Team** that autonomously gathers financial intelligence from the web, combines it with local market data, generates professional analysis reports, and seamlessly integrates with your strategy development, backtesting, and live trading workflows.
### Core Value
- **🛡️ Privacy First**: All strategies, trading logs, and API keys are stored locally in your SQLite database.
- **🧠 AI Empowered**: Not just code completion, but a real AI Research Analyst (powered by OpenRouter/LLM).
- **⚡ Multi-Market**: Native support for **Crypto**, **US Stocks**, **CN/HK Stocks**, **Forex**, and **Futures**.
- **🔌 Out-of-the-Box**: One-click deployment via Docker. No complex environment setup required.
---
### Why QuantDinger
## 📸 Visual Tour
- **Local-first (SQLite) out of the box**: no external database required to run a full workflow locally.
- **AI research team in code**: multi-agent analysis produces structured reports (with optional web search + LLMs).
- **Multi-market data layer**: a factory-based data source abstraction for crypto, US stocks, CN/HK stocks, forex, and futures.
- **From signals to execution**: strategy runtime + a pending-order worker to dispatch queued actions reliably.
<div align="center">
<h3>📊 Professional Quant Dashboard</h3>
<p>Real-time monitoring of market dynamics, assets, and strategy status.</p>
<img src="docs/screenshots/dashboard.png" alt="QuantDinger Dashboard" width="100%" style="border-radius: 10px; box-shadow: 0 4px 8px rgba(0,0,0,0.1);">
</div>
<br/>
<table align="center" width="100%">
<tr>
<td width="50%" align="center" valign="top">
<h3>🤖 AI Deep Research</h3>
<p>Multi-agent collaboration for market sentiment & technical analysis.</p>
<img src="docs/screenshots/ai_analysis1.png" alt="AI Market Analysis" style="border-radius: 6px;">
</td>
<td width="50%" align="center" valign="top">
<h3>💬 Smart Trading Assistant</h3>
<p>Natural language interface for instant market insights.</p>
<img src="docs/screenshots/trading_assistant.png" alt="Trading Assistant" style="border-radius: 6px;">
</td>
</tr>
<tr>
<td width="50%" align="center" valign="top">
<h3>📈 Interactive Indicator Analysis</h3>
<p>Rich library of technical indicators with drag-and-drop analysis.</p>
<img src="docs/screenshots/indicator_analysis.png" alt="Indicator Analysis" style="border-radius: 6px;">
</td>
<td width="50%" align="center" valign="top">
<h3>🐍 Python Strategy Gen</h3>
<p>Built-in editor with AI-assisted strategy coding.</p>
<img src="docs/screenshots/indicator_creat_python_code.png" alt="Code Generation" style="border-radius: 6px;">
</td>
</tr>
</table>
---
### Highlights (What You Get)
## ✨ Key Features
- **Multi-market market data**
- Data source factory in `backend_api_python/app/data_sources/`.
- Optional proxy support for restricted networks (see `.env`).
### 1. Universal Data Engine
Stop worrying about data APIs. QuantDinger features a powerful Data Source Factory pattern:
- **Crypto**: Seamless integration with **CCXT**, supporting Binance, OKX, Bybit, and 100+ exchanges.
- **Stocks**: Integrates Yahoo Finance, Finnhub, Tiingo (US), and AkShare (CN/HK).
- **Futures/Forex**: Supports OANDA and major futures data sources.
- **Proxy Support**: Built-in proxy configuration for restricted network environments.
- **AI multi-agent analysis**
- Coordinator + role agents in `backend_api_python/app/services/agents/`.
- Optional web search (Google/Bing) and LLM access (OpenRouter).
### 2. AI Multi-Agent Research
Your tireless team of analysts:
- **Coordinator Agent**: Decomposes tasks and manages workflows.
- **Research Agent**: Performs full-web searches (Google/Bing) for macro news.
- **Crypto/Stock Agent**: Specializes in technical and capital flow analysis for specific markets.
- **Report Generation**: Automatically produces structured Daily/Weekly research reports.
- **Indicator engine + backtesting**
- Indicator code storage with safe execution utilities.
- Backtest endpoints + persisted run history (SQLite).
### 3. Robust Strategy Runtime
- **Thread-Based Executor**: Independent thread pool management for strategy execution.
- **Auto-Restore**: Automatically resumes running strategies after system restarts.
- **Pending Order Worker**: Reliable background queue ensures precise signal execution and prevents slippage.
- **Strategy runtime**
- Thread-based executor with startup auto-restore (configurable).
- Background pending-order worker that polls queued orders and dispatches signals (can be disabled).
### 4. Modern Tech Stack
- **Backend**: Python (Flask) + SQLite + Redis (Optional) — Simple, powerful, extensible.
- **Frontend**: Vue 2 + Ant Design Vue + KlineCharts/ECharts — Responsive and interactive.
- **Deployment**: Docker Compose orchestration.
- **Live trading integrations**
- Exchange execution adapters in `backend_api_python/app/services/live_trading/` (CCXT-based where applicable).
---
- **Local auth (single-user)**
- Simple login (`/login`) with env-configured admin credentials (JWT token).
## 🏦 Supported Exchanges
Powered by the robust CCXT library, we support nearly all major cryptocurrency exchanges:
| Binance | OKX | Bybit | Bitget | Gate.io | KuCoin |
|:---:|:---:|:---:|:---:|:---:|:---:|
| <img src="https://user-images.githubusercontent.com/1294454/29604020-d5483cdc-87ee-11e7-94c7-d1a8d9169293.jpg" width="50"> | <img src="https://user-images.githubusercontent.com/1294454/29604052-fc7770a6-87ee-11e7-91f4-34adcb17cb83.jpg" width="50"> | <img src="https://user-images.githubusercontent.com/1294454/59143324-00445d80-89b9-11e9-9807-742261596e00.jpg" width="50"> | <img src="https://user-images.githubusercontent.com/1294454/152643503-4554366b-4e60-466d-97e3-057d29219808.jpg" width="50"> | <img src="https://user-images.githubusercontent.com/1294454/31784034-0d5b4a04-b514-11e7-9d78-2d886895b6c3.jpg" width="50"> | <img src="https://user-images.githubusercontent.com/1294454/32065879-e58f0004-ba91-11e7-9092-22589e472624.jpg" width="50"> |
> Plus Kraken, Huobi, Coinbase Pro, and 100+ others.
---
### Multi-Language Support
<details>
<summary><b>Show supported languages</b></summary>
QuantDinger is built for a global audience with comprehensive internationalization:
<p>
<img src="https://img.shields.io/badge/🇺🇸_English-Supported-2563EB?style=flat-square" alt="English" />
<img src="https://img.shields.io/badge/🇨🇳_简体中文-Supported-2563EB?style=flat-square" alt="Simplified Chinese" />
<img src="https://img.shields.io/badge/🇹🇼_繁體中文-Supported-2563EB?style=flat-square" alt="Traditional Chinese" />
<img src="https://img.shields.io/badge/🇯🇵_日本語-Supported-2563EB?style=flat-square" alt="Japanese" />
<img src="https://img.shields.io/badge/🇰🇷_한국어-Supported-2563EB?style=flat-square" alt="Korean" />
<img src="https://img.shields.io/badge/🇩🇪_Deutsch-Supported-2563EB?style=flat-square" alt="German" />
<img src="https://img.shields.io/badge/🇫🇷_Français-Supported-2563EB?style=flat-square" alt="French" />
<img src="https://img.shields.io/badge/🇹🇭_ไทย-Supported-2563EB?style=flat-square" alt="Thai" />
<img src="https://img.shields.io/badge/🇻🇳_Tiếng_Việt-Supported-2563EB?style=flat-square" alt="Vietnamese" />
<img src="https://img.shields.io/badge/🇸🇦_العربية-Supported-2563EB?style=flat-square" alt="Arabic" />
</p>
All UI elements, error messages, and documentation are fully translated. Language is auto-detected based on browser settings or can be manually switched in the app.
</details>
---
### Supported Markets
| Market Type | Data Sources | Trading |
|-------------|--------------|---------|
| **Cryptocurrency** | Binance, OKX, Bitget, + 100 exchanges | ✅ Full support |
| **US Stocks** | Yahoo Finance, Finnhub, Tiingo | ✅ Via broker API |
| **CN/HK Stocks** | AkShare, East Money | ⚡ Data only |
| **Forex** | Finnhub, OANDA | ✅ Via broker API |
| **Futures** | Exchange APIs, AkShare | ⚡ Data only |
---
@@ -98,25 +202,247 @@ This repository is intentionally simple (no PHP gateway): it contains **one Pyth
---
### Quick Start (Local Development)
## Quick Start
### Option 1: Docker Deployment (Recommended)
The fastest way to get QuantDinger running.
#### 1. Prepare Configuration
Linux/macOS:
```bash
cp docker.env.example backend_api_python/.env
nano backend_api_python/.env
```
Windows PowerShell:
```powershell
Copy-Item docker.env.example backend_api_python/.env
notepad backend_api_python/.env
```
**Required settings:**
- `SECRET_KEY` - Application secret, use a random string
- `ADMIN_USER` / `ADMIN_PASSWORD` - Login credentials
- `OPENROUTER_API_KEY` - OpenRouter API key (required for AI analysis)
#### 2. Build and Start
```bash
# Build images and start (first run)
docker-compose up -d --build
# Subsequent starts (no rebuild needed)
docker-compose up -d
```
#### 3. Access the Application
- **Frontend UI**: http://localhost
- **Backend API**: http://localhost:5000
#### Docker Commands Reference
```bash
# View running status
docker-compose ps
# View logs
docker-compose logs -f
# View backend logs only
docker-compose logs -f backend
# View frontend logs only
docker-compose logs -f frontend
# Stop services
docker-compose down
# Stop and remove volumes (WARNING: deletes database!)
docker-compose down -v
# Restart services
docker-compose restart
# Rebuild and restart
docker-compose up -d --build
# Enter backend container
docker exec -it quantdinger-backend /bin/bash
# Enter frontend container
docker exec -it quantdinger-frontend /bin/sh
```
#### Docker Architecture
```
┌─────────────────┐ ┌─────────────────┐
│ Frontend │ │ Backend │
│ (Nginx) │────▶│ (Python) │
│ Port: 80 │ │ Port: 5000 │
└─────────────────┘ └─────────────────┘
│ │
└───────────────────────┘
Docker Network
```
- **Frontend**: Vue.js app served by Nginx, proxies API requests to backend
- **Backend**: Python Flask API service
#### Data Persistence
The following data is mounted to the host and persists across container restarts:
```yaml
volumes:
- ./backend_api_python/quantdinger.db:/app/quantdinger.db # Database
- ./backend_api_python/logs:/app/logs # Logs
- ./backend_api_python/data:/app/data # Data directory
- ./backend_api_python/.env:/app/.env # Configuration
```
#### Customization
**Change ports** - Edit `docker-compose.yml`:
```yaml
services:
frontend:
ports:
- "8080:80" # Change to port 8080
backend:
ports:
- "5001:5000" # Change to port 5001
```
**Configure HTTPS** - Use a reverse proxy (like Caddy/Nginx):
```bash
# Using Caddy (automatic HTTPS)
caddy reverse-proxy --from yourdomain.com --to localhost:80
```
#### Production Recommendations
**Security:**
```bash
# Generate strong SECRET_KEY
openssl rand -hex 32
# Set secure admin password
ADMIN_PASSWORD=your-very-secure-password
```
**Resource limits** - Add to `docker-compose.yml`:
```yaml
services:
backend:
deploy:
resources:
limits:
cpus: '2'
memory: 2G
reservations:
cpus: '0.5'
memory: 512M
```
**Log management:**
```yaml
services:
backend:
logging:
driver: "json-file"
options:
max-size: "100m"
max-file: "3"
```
#### Docker Troubleshooting
**Frontend can't connect to backend:**
```bash
docker-compose logs backend
curl http://localhost:5000/api/health
```
**Database permission issues:**
```bash
chmod 666 backend_api_python/quantdinger.db
```
**Build failures:**
```bash
# Clear Docker cache and rebuild
docker-compose build --no-cache
```
**Out of memory:**
```bash
# Check memory usage
docker stats
# Add swap space (Linux)
sudo fallocate -l 2G /swapfile
sudo chmod 600 /swapfile
sudo mkswap /swapfile
sudo swapon /swapfile
```
#### Updating
```bash
# Pull latest code
git pull
# Rebuild and restart
docker-compose up -d --build
```
#### Backup
```bash
# Backup database
cp backend_api_python/quantdinger.db backup/quantdinger_$(date +%Y%m%d).db
# Backup configuration
cp backend_api_python/.env backup/.env_$(date +%Y%m%d)
```
---
### Option 2: Local Development
**Prerequisites**
- Python 3.10+ recommended
- Node.js 16+ recommended
#### 1) Start the backend (Flask API)
#### 1. Start the backend (Flask API)
```bash
cd backend_api_python
pip install -r requirements.txt
copy env.example .env # Windows PowerShell users can use: Copy-Item env.example .env
cp env.example .env # Windows: copy env.example .env
python run.py
```
Backend will be available at `http://localhost:5000`.
#### 2) Start the frontend (Vue UI)
#### 2. Start the frontend (Vue UI)
```bash
cd quantdinger_vue
@@ -146,8 +472,8 @@ Use `backend_api_python/env.example` as a template. Common settings include:
The backend provides REST endpoints for login, market data, indicators, backtesting, strategies, and AI analysis.
- Health: `GET /health`
- Auth: `POST /login`, `POST /logout`, `GET /info`
- Health: `GET /health` (also supports `GET /api/health` for deployment probes)
- Auth (frontend-compatible): `POST /api/user/login`, `POST /api/user/logout`, `GET /api/user/info`
For the full route list, see `backend_api_python/app/routes/`.
@@ -159,17 +485,74 @@ Licensed under the **Apache License 2.0**. See `LICENSE`.
---
## 🤝 Community & Support
Join our global community for strategy sharing and technical support:
- **Telegram (Official)**: [t.me/worldinbroker](https://t.me/worldinbroker)
- **Discord**: [Join Server](https://discord.gg/cn6HVE2KC)
- **YouTube**: [@quantdinger](https://youtube.com/@quantdinger)
- **Email**: [brokermr810@gmail.com](mailto:brokermr810@gmail.com)
- **GitHub Issues**: [Report bugs / Request features](https://github.com/brokermr810/QuantDinger/issues)
---
## ☕ Support the Project
If QuantDinger helps you profit, consider buying the developers a coffee. Your support keeps the project alive!
<details>
<summary><b>View Crypto Donation Addresses</b></summary>
**ERC-20 / BEP-20 / Polygon / Arbitrum**
```
0x96fa4962181bea077f8c7240efe46afbe73641a7
```
<img src="https://img.shields.io/badge/USDT-Accepted-26A17B?style=flat-square&logo=tether" alt="USDT">
<img src="https://img.shields.io/badge/ETH-Accepted-3C3C3D?style=flat-square&logo=ethereum" alt="ETH">
</details>
---
### Commercial Services
<details>
<summary><b>Show services</b></summary>
We offer professional services to help you get the most out of QuantDinger:
| Service | Description |
|---------|-------------|
| **Deployment & Setup** | One-on-one assistance with server deployment, configuration, and optimization |
| **Custom Strategy Development** | Tailored trading strategies designed for your specific needs and markets |
| **Enterprise Upgrade** | Commercial license, priority support, and advanced features for businesses |
| **Training & Consulting** | Hands-on training sessions and strategic consulting for your trading team |
**Interested?** Contact us via:
- 📧 Email: [brokermr810@gmail.com](mailto:brokermr810@gmail.com)
- 💬 Telegram: [@worldinbroker](https://t.me/worldinbroker)
</details>
---
### Acknowledgements
QuantDinger stands on the shoulders of great open-source projects, including:
- **Flask** / **flask-cors**
- **Pandas**
- **CCXT**
- **yfinance**, **akshare**, **requests**
- **Vue 2** and **Ant Design Vue**
- Charting libraries used in the UI (e.g., **KlineCharts**)
Thanks to maintainers and contributors across these ecosystems.
QuantDinger stands on the shoulders of great open-source projects:
| Project | Description | Link |
|---------|-------------|------|
| **Flask** | Lightweight WSGI web framework | [flask.palletsprojects.com](https://flask.palletsprojects.com/) |
| **flask-cors** | Cross-Origin Resource Sharing extension | [GitHub](https://github.com/corydolphin/flask-cors) |
| **Pandas** | Data analysis and manipulation library | [pandas.pydata.org](https://pandas.pydata.org/) |
| **CCXT** | Cryptocurrency exchange trading library | [github.com/ccxt/ccxt](https://github.com/ccxt/ccxt) |
| **yfinance** | Yahoo Finance market data downloader | [github.com/ranaroussi/yfinance](https://github.com/ranaroussi/yfinance) |
| **akshare** | China financial data interface | [github.com/akfamily/akshare](https://github.com/akfamily/akshare) |
| **requests** | HTTP library for Python | [requests.readthedocs.io](https://requests.readthedocs.io/) |
| **Vue.js** | Progressive JavaScript framework | [vuejs.org](https://vuejs.org/) |
| **Ant Design Vue** | Enterprise-class UI components | [antdv.com](https://antdv.com/) |
| **KlineCharts** | Lightweight financial charting library | [github.com/klinecharts/KLineChart](https://github.com/klinecharts/KLineChart) |
| **Lightweight Charts** | TradingView charting library | [github.com/nicepkg/lightweight-charts](https://github.com/nicepkg/lightweight-charts) |
| **ECharts** | Apache data visualization library | [echarts.apache.org](https://echarts.apache.org/) |
Thanks to all maintainers and contributors across these ecosystems! ❤️