Thanks to visit codestin.com
Credit goes to GitHub.com

Skip to content

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.

License

Notifications You must be signed in to change notification settings

franksunye/quantdb

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

QuantDB - High-Performance Python Stock Data Toolkit πŸš€

English | δΈ­ζ–‡η‰ˆζœ¬

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.

Version License Python Package codecov API Database Tests Frontend Cloud Performance Integration Status

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! PyPI version Downloads

pip install quantdb  # One command, instant 90%+ speed boost!
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

pip install quantdb
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

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 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)

# Install the package
pip install quantdb
# 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)

# 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
  • Complete Features: Stock data query, asset information, cache monitoring, watchlist management

Option 3: Local API Service

1. Installation and Setup

# 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)

# 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

# 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

# Run Streamlit Cloud version (integrated backend services)
cd cloud/streamlit_cloud
streamlit run app.py
# Access URL: http://localhost:8501

3. Using API

# 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

# 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

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

🎯 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.

πŸ”§ 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 Current progress and priorities
πŸ“… Changelog Version history and changes
πŸ—οΈ System Architecture Architecture design and components
πŸ—„οΈ Database Architecture Database design and models
πŸ“Š API Documentation Complete API usage guide
πŸ› οΈ Development Guide Development environment and workflow
πŸ§ͺ Testing Guide Test execution and writing
πŸ“… Trading Calendar Upgrade Multi-market trading calendar system upgrade
πŸ“– DeepWiki Knowledge Base 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

πŸ’­ Community Discussion

πŸ“š Documentation & Resources

πŸš€ Stay Connected


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 file for details.

πŸ”— Links


⭐ If this project helps you, please give it a Star!

About

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.

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages