https://github.com/franksunye/quantdb
High-performance stock data caching service based on AKShare data source, providing intelligent caching, RESTful API, and professional frontend interface. π Cloud Deployment Ready! Now provides complete cloud deployment solutions, including local development environment and Streamlit Cloud deployment version.
https://github.com/franksunye/quantdb
streamlit webapp
Last synced: 9 months ago
JSON representation
High-performance stock data caching service based on AKShare data source, providing intelligent caching, RESTful API, and professional frontend interface. π Cloud Deployment Ready! Now provides complete cloud deployment solutions, including local development environment and Streamlit Cloud deployment version.
- Host: GitHub
- URL: https://github.com/franksunye/quantdb
- Owner: franksunye
- License: mit
- Created: 2025-05-13T10:57:23.000Z (about 1 year ago)
- Default Branch: main
- Last Pushed: 2025-08-11T14:19:43.000Z (11 months ago)
- Last Synced: 2025-08-11T14:54:22.123Z (11 months ago)
- Topics: streamlit, webapp
- Language: Python
- Homepage: https://quantdb-cloud.streamlit.app/
- Size: 6.39 MB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# QuantDB - High-Performance Python Stock Data Toolkit π
*English | [δΈζηζ¬](README.zh-CN.md)*
> **Intelligent caching wrapper for AKShare with 90%+ performance boost** - Complete stock data ecosystem with smart SQLite caching for Chinese financial markets. Perfect for quantitative trading, financial analysis, and algorithmic trading in Python.



[](https://codecov.io/gh/franksunye/quantdb)








**Intelligent caching wrapper for AKShare with 90%+ performance boost** - Complete stock data ecosystem with smart SQLite caching for Chinese financial markets.
**π NOW AVAILABLE ON PyPI!**
[](https://pypi.org/project/quantdb/)
[](https://pepy.tech/project/quantdb)
```bash
pip install quantdb # One command, instant 90%+ speed boost!
```
```python
import qdb # Note: import name is 'qdb' for simplicity
df = qdb.get_stock_data("000001", days=30)
# New in v2.2.9: Multi-market support!
df_china = qdb.get_stock_data("000001", days=30) # China A-shares
df_hk = qdb.get_stock_data("00700", days=30) # Hong Kong stocks
realtime = qdb.get_realtime_data("000001") # Real-time quotes
financials = qdb.get_financial_summary("000001") # Financial data
```
**Three product formats**: Python Package, API Service, and Cloud Platform for different user needs.
## π― Product Matrix
### π¦ **QuantDB Python Package** - For Developers
```bash
pip install quantdb
```
```python
import qdb # Note: Package name is 'quantdb', import name is 'qdb'
df = qdb.get_stock_data("000001", days=30) # 90%+ faster than AKShare!
```
**Perfect for**: Quantitative researchers, Python developers, data scientists
**Import Note**: Install as `quantdb`, import as `qdb` (like scikit-learn β sklearn)
### π **API Service** - For Enterprises
```bash
curl "https://your-api.com/api/v1/stocks/000001/data?days=30"
```
**Perfect for**: Enterprise teams, multi-user applications, production systems
### βοΈ **Cloud Platform** - For Individual Investors
Visit: [QuantDB Cloud Platform](https://quantdb-cloud.streamlit.app)
**Perfect for**: Individual investors, data analysis, visualization
## β¨ Core Features
- **π 90%+ Performance Boost**: Smart SQLite caching, millisecond response time
- **π¦ Multiple Product Forms**: Python package, API service, cloud platform
- **π Full AKShare Compatibility**: Same API interface, seamless replacement
- **πΎ Local Caching**: Offline available, intelligent incremental updates
- **π
Trading Calendar Integration**: Smart data fetching based on real trading days
- **π οΈ Zero Configuration**: pip install and ready to use
- **βοΈ Cloud Deployment Ready**: Supports Railway, Render, Alibaba Cloud, etc.
- **π§ Intelligent Updates**: Automatic missing data detection and fetching
- **β‘ Real-time Data**: Live stock quotes and market data
- **π Financial Analytics**: Complete financial indicators and ratios
- **π Index Data**: Major market indices support (SSE, SZSE, etc.)
- **π Stock Lists**: Complete market coverage and filtering
## β‘ Performance Highlights
| Metric | Direct AKShare Call | QuantDB Package | Performance Improvement |
|--------|-------------------|-------------|------------------------|
| **Response Time** | ~1000ms | ~10ms | **99%** β¬οΈ |
| **Cache Hit** | N/A | 90%+ | **Smart Cache** β
|
| **Trading Day Recognition** | Manual | Automatic | **Intelligent** π§ |
| **Installation** | Complex setup | `pip install quantdb` | **One Command** π |
## π¦ Installation & Import
**Important**: Package name and import name are different (common practice in Python ecosystem)
```bash
# Install the package
pip install quantdb
```
```python
# Import the package (note: import name is 'qdb')
import qdb
# Start using immediately
df = qdb.get_stock_data("000001", days=30)
stats = qdb.cache_stats()
```
**Why different names?**
- **Package name**: `quantdb` (descriptive, searchable on PyPI)
- **Import name**: `qdb` (concise, easy to type)
- **Similar to**: `scikit-learn` β `sklearn`, `beautifulsoup4` β `bs4`
## π Quick Start
### Option 1: Python Package (Recommended)
```bash
# Install the package
pip install quantdb
# Import and use (note the different import name)
python -c "
import qdb # Package: quantdb, Import: qdb
df = qdb.get_stock_data('000001', days=30)
print(f'Got {len(df)} records with 90%+ speed boost!')
print('β
QuantDB package working perfectly!')
"
```
### Option 2: Cloud Platform Access
Direct access to deployed Streamlit Cloud version:
- **Frontend Interface**: [QuantDB Cloud](https://quantdb-cloud.streamlit.app)
- **Complete Features**: Stock data query, asset information, cache monitoring, watchlist management
### Option 3: Local API Service
#### 1. Installation and Setup
```bash
# Clone repository
git clone https://github.com/franksunye/quantdb.git
cd quantdb
# Install dependencies
pip install -r requirements.txt
# Initialize database
python src/scripts/init_db.py
```
#### 2. Start Services
**Method 1: One-click Start (Recommended)**
```bash
# Enter frontend directory and run startup script
cd quantdb_frontend
python start.py
# Script will automatically start backend API and frontend interface
```
**Method 2: Manual Start**
```bash
# 1. Start backend API (in project root)
python src/api/main.py
# 2. Start frontend interface (in new terminal)
cd quantdb_frontend
streamlit run app.py
# Access URLs
# Frontend Interface: http://localhost:8501
# API Documentation: http://localhost:8000/docs
```
**Method 3: Cloud Version Local Run**
```bash
# Run Streamlit Cloud version (integrated backend services)
cd cloud/streamlit_cloud
streamlit run app.py
# Access URL: http://localhost:8501
```
### 3. Using API
```bash
# Health check
curl http://localhost:8000/api/v1/health
# Get stock data (auto-cached, displays real company names)
curl "http://localhost:8000/api/v1/historical/stock/600000?start_date=20240101&end_date=20240131"
# Get asset information (includes financial metrics)
curl "http://localhost:8000/api/v1/assets/symbol/600000"
# View cache status
curl http://localhost:8000/api/v1/cache/status
```
### 4. Run Tests
```bash
# Run backend tests
python scripts/test_runner.py --all
# Run frontend tests
cd quantdb_frontend
python run_tests.py
# Run performance tests
python scripts/test_runner.py --performance
```
## π€ For AI Agents
QuantDB is optimized for AI agent integration with comprehensive machine-readable documentation and standardized APIs.
### β¨ AI Agent Features
- **π Standardized Docstrings**: All functions use Google Style format with detailed parameter constraints
- **π§ Machine-Readable Schema**: Complete API specification in JSON format
- **π‘ Usage Examples**: Comprehensive examples for financial and index data analysis
- **β οΈ Error Handling**: Detailed exception documentation with recovery strategies
- **π― Type Safety**: Full type hints for all function parameters and return values
### π Quick AI Agent Integration
```python
import qdb
# AI agents can access complete documentation
help(qdb.get_stock_data) # Detailed function documentation
help(qdb.get_financial_summary) # Financial analysis functions
help(qdb.get_index_data) # Market index functions
# Example: AI agent can generate this code confidently
df = qdb.get_stock_data("000001", days=30) # Get recent stock data
summary = qdb.get_financial_summary("000001") # Get financial metrics
realtime = qdb.get_realtime_data("000001") # Get current quotes
```
### π AI Agent Resources
- **API Schema**: [qdb-ai-agent-schema.json](docs/ai-agent/qdb-ai-agent-schema.json) - Machine-readable API specification
- **Usage Examples**: [AI Agent Examples](examples/ai_agent_usage_examples.py) - Complete usage patterns
- **Financial Analysis**: [Financial Examples](examples/financial_and_index_analysis.py) - Advanced analysis workflows
- **Documentation Guide**: [AI Agent Guide](docs/ai-agent/ai-agent-documentation-guide.md) - Integration best practices
### π― AI Agent Capabilities
With QuantDB, AI agents can:
- β
**Understand precise API functionality** with detailed parameter constraints
- β
**Generate correct code** with proper error handling
- β
**Perform advanced financial analysis** with 80+ financial indicators
- β
**Access comprehensive market data** including stocks, indices, and real-time quotes
- β
**Optimize performance** using intelligent caching strategies
### π Supported Analysis Types
- **Stock Analysis**: Historical data, real-time quotes, technical indicators
- **Financial Analysis**: Quarterly reports, financial ratios, profitability metrics
- **Index Analysis**: Market indices, sector performance, trend analysis
- **Portfolio Management**: Multi-stock analysis, performance comparison
## ποΈ Architecture Overview
QuantDB adopts modern microservice architecture with the following core components:
- **π§ Core Services**: Unified business logic layer supporting multiple deployment modes
- **π‘ FastAPI Backend**: High-performance REST API service
- **π± Streamlit Frontend**: Interactive data analysis interface
- **βοΈ Cloud Deployment**: Cloud deployment version supporting Streamlit Cloud
- **π§ͺ Comprehensive Testing**: Complete test suite covering unit, integration, API, E2E tests
- **π Smart Caching**: Intelligent caching system based on trading calendar
For detailed architecture design, please refer to [System Architecture Documentation](./docs/10_ARCHITECTURE.md).
## π§ Technology Stack
- **Backend**: FastAPI + SQLAlchemy + SQLite
- **Frontend**: Streamlit + Plotly + Pandas
- **Data Source**: AKShare (Official Stock Data)
- **Caching**: Smart database caching + trading calendar
- **Testing**: pytest + unittest (259 tests, 100% pass rate)
- **Monitoring**: Real-time performance monitoring and data tracking
- **Logging**: Unified logging system with completely consistent recording
- **Integration**: Complete frontend-backend integration solution
## π Documentation
| Document | Description |
|----------|-------------|
| [π Project Status](./docs/00_BACKLOG.md) | Current progress and priorities |
| [π
Changelog](./docs/01_CHANGELOG.md) | Version history and changes |
| [ποΈ System Architecture](./docs/10_ARCHITECTURE.md) | Architecture design and components |
| [ποΈ Database Architecture](./docs/11_DATABASE_ARCHITECTURE.md) | Database design and models |
| [π API Documentation](./docs/20_API.md) | Complete API usage guide |
| [π οΈ Development Guide](./docs/30_DEVELOPMENT.md) | Development environment and workflow |
| [π§ͺ Testing Guide](./docs/31_TESTING.md) | Test execution and writing |
| [π
Trading Calendar Upgrade](./docs/TRADING_CALENDAR_UPGRADE.md) | Multi-market trading calendar system upgrade |
| [π **DeepWiki Knowledge Base**](https://deepwiki.com/franksunye/quantdb) | Comprehensive knowledge base and documentation |
## π¬ Support & Feedback
We welcome your feedback and are here to help! Choose the best channel for your needs:
### π Bug Reports & Feature Requests
- **GitHub Issues**: [Report bugs or request features](https://github.com/franksunye/quantdb/issues)
- Please include version info, error messages, and reproduction steps
### π Community Discussion
- **GitHub Discussions**: [Join the conversation](https://github.com/franksunye/quantdb/discussions)
- [π Q&A](https://github.com/franksunye/quantdb/discussions/categories/q-a) - Get help with usage questions
- [π‘ Ideas](https://github.com/franksunye/quantdb/discussions/categories/ideas) - Share feature ideas and suggestions
- [π Show and Tell](https://github.com/franksunye/quantdb/discussions/categories/show-and-tell) - Share your projects using QuantDB
- [π£ Announcements](https://github.com/franksunye/quantdb/discussions/categories/announcements) - Stay updated with latest news
### π Documentation & Resources
- **Quick Help**: [FAQ](./docs/faq.md)
- **Migration Guide**: [AKShare β QuantDB](./docs/guides/migration_akshare_to_quantdb.md)
- **Full Documentation**: [https://franksunye.github.io/quantdb/](https://franksunye.github.io/quantdb/)
### π Stay Connected
- **PyPI Package**: [https://pypi.org/project/quantdb/](https://pypi.org/project/quantdb/)
- **Live Demo**: [https://quantdb-cloud.streamlit.app/](https://quantdb-cloud.streamlit.app/)
---
*Response time: We aim to respond to issues within 24-48 hours. For urgent matters, please use GitHub Issues.*
## π― Project Status
**Current Version**: v2.2.8 (Complete Multi-Feature Extension)
**Next Version**: v2.3.0 (Enhanced Analytics and Performance)
**MVP Score**: 10/10 (Core features complete, cloud deployment ready)
**Test Coverage**: 259/259 passed (100%) - 222 backend + 37 frontend
**Data Quality**: βββββ (5/5) - Real company names and financial metrics
**Frontend Experience**: βββββ (5/5) - Professional quantitative data platform interface
**Integration Status**: β
Complete frontend-backend integration, cloud deployment ready
**Production Ready**: βββββ (5/5) - Cloud deployment version complete
**Cloud Deployment**: β
Streamlit Cloud version, directly using backend services
## π License
This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.
## π Links
- **GitHub**: [https://github.com/franksunye/quantdb](https://github.com/franksunye/quantdb)
- **API Documentation**: http://localhost:8000/docs (access after starting service)
- **Project Maintainer**: frank
---
β If this project helps you, please give it a Star!