Intelligent caching wrapper for AKShare with 90%+ performance boost - 100% English codebase (import as 'qdb')
Project description
QuantDB - Intelligent Stock Data Caching
Intelligent caching wrapper for AKShare with 90%+ performance boost - Complete stock data ecosystem with smart SQLite caching for Chinese financial markets.
๐ Note: Download statistics may take 24-48 hours to appear on PyPI and third-party services after a new release.
๐ Quick Start
pip install quantdb # One command, instant 90%+ speed boost!
import qdb # Note: import name is 'qdb' for simplicity
# Multiple ways to get stock data - all 90%+ faster than AKShare!
df = qdb.get_stock_data("000001", days=30) # Simple: last 30 days
df = qdb.get_stock_data("000001", "20240101", "20240131") # Date range
df = qdb.get_stock_data("000001", start_date="20240101", end_date="20240131") # Keywords
โจ Key Features
- ๐ 90%+ Performance Boost: Local SQLite cache avoids repeated network requests
- ๐ง Smart Incremental Updates: Only fetch missing data, maximize cache efficiency
- โก Millisecond Response: Cache hit response time < 10ms
- ๐ Multi-Market Trading Calendar: Professional-grade calendars for China A-shares + Hong Kong stocks
- ๐ญ๐ฐ Hong Kong Stock Support: Native HKEX support with intelligent market detection
- ๐ง Zero Configuration: Automatically initialize local cache database
- ๐ Full AKShare Compatibility: Drop-in replacement with same API interface
- ๐ 100% English Codebase: International developer friendly
- ๐ฏ Multi-Market Support: A-shares + Hong Kong stocks unified API
- ๐ Real-time Data: Live stock prices with intelligent caching
- ๐ Financial Indicators: Comprehensive financial metrics and ratios
- ๐ Stock Discovery: Complete stock list with market filtering
๐ Performance Comparison
| Operation | AKShare | QuantDB | Improvement |
|---|---|---|---|
| First Request | ~1000ms | ~1000ms | Same |
| Cache Hit | ~1000ms | ~18ms | 98.1% faster |
| Bulk Operations | Very Slow | Lightning Fast | 90%+ faster |
๐ง Core API
Basic Usage
import qdb
# Historical stock data (multiple call patterns supported)
df = qdb.get_stock_data("000001", days=30) # Last 30 days
df = qdb.get_stock_data("000001", "20240101", "20240131") # Date range
df = qdb.get_stock_data("000001", start_date="20240101", end_date="20240131") # Keywords
df = qdb.get_stock_data("600000", start_date="20240101", end_date="20240201")
# Multiple stocks
stocks_data = qdb.get_multiple_stocks(["000001", "000002"], days=30)
# Asset information
asset_info = qdb.get_asset_info("000001")
# Cache management
stats = qdb.cache_stats() # View cache statistics
qdb.clear_cache() # Clear cache if needed
Advanced Features (v2.2.9)
import qdb
# Multi-market support with intelligent detection
df_china = qdb.get_stock_data("000001", days=30) # China A-shares (auto-detected)
df_hk = qdb.get_stock_data("00700", days=30) # Hong Kong stocks (auto-detected)
# Real-time stock quotes with intelligent caching
realtime = qdb.get_realtime_data("000001")
batch_realtime = qdb.get_realtime_data_batch(["000001", "000002"])
# Complete stock list with market filtering
all_stocks = qdb.get_stock_list() # All markets
shse_stocks = qdb.get_stock_list(market="SHSE") # Shanghai Stock Exchange
szse_stocks = qdb.get_stock_list(market="SZSE") # Shenzhen Stock Exchange
hkex_stocks = qdb.get_stock_list(market="HKEX") # Hong Kong Exchange
# Index data (now available via top-level qdb)
index_hist = qdb.get_index_data("000001", start_date="20240101", end_date="20240201")
index_rt = qdb.get_index_realtime("000001")
index_list = qdb.get_index_list() # Or filter by category
# Financial data and indicators
financial_summary = qdb.get_financial_summary("000001") # Key metrics
financial_indicators = qdb.get_financial_indicators("000001") # Detailed ratios
AKShare Compatibility
import qdb
# 100% compatible with AKShare API
df = qdb.stock_zh_a_hist("000001", start_date="20240101", end_date="20240201")
Configuration
import qdb
# Custom cache directory
qdb.set_cache_dir("./my_custom_cache")
# Logging level
qdb.set_log_level("INFO") # DEBUG, INFO, WARNING, ERROR
๐ Feature details
- Real-time data: Trading-hours TTL vs. off-hours TTL to minimize latency and API calls; automatic cache hit detection and graceful fallback
- Stock list: Market filter via market="SHSE"/"SZSE"/"HKEX"; daily caching with force_refresh toggle
- Financial metrics: Summary and indicators endpoints designed for quick lookups and lightweight analysis
๐ฏ Use Cases
- Quantitative Research: Frequent backtesting with cached historical data
- Algorithm Trading: Real-time data access with minimal latency
- Financial Analysis: Large-scale data processing with performance optimization
- Portfolio Management: Multi-asset data retrieval and analysis
- Academic Research: Reliable data source for financial studies
๐ What's new in v2.2.9
- โ Multi-Market Trading Calendar: Upgraded from AKShare to pandas_market_calendars with Hong Kong support
- โ Hong Kong Stock Exchange: Native HKEX support with intelligent symbol detection (00700 โ HK, 000001 โ China)
- โ 197+ Global Exchanges: Professional-grade calendar support for future expansion
- โ Enhanced Performance: Improved test coverage (77%+) and error handling
- โ AI Agent Ready: Enhanced documentation for better AI tool integration
- โ 100% Backward Compatible: All existing code continues to work unchanged
๐ Documentation & Support
- GitHub Repository: https://github.com/franksunye/quantdb
- Full Documentation: https://github.com/franksunye/quantdb/docs
- Issue Tracker: https://github.com/franksunye/quantdb/issues
- API Reference: Complete API documentation with examples
๐๏ธ Architecture
QuantDB provides multiple deployment options:
- ๐ฆ Python Package (This Package): Local caching for individual developers
- ๐ API Service: Enterprise-grade REST API with advanced features
- โ๏ธ Cloud Platform: Web interface with visualization and monitoring
๐ค Contributing
We welcome contributions! Please see our Contributing Guide for details.
๐ License
This project is licensed under the MIT License - see the LICENSE file for details.
๐ Acknowledgments
- Built on top of the excellent AKShare library
- Inspired by the need for high-performance financial data access in Python
Note: Package name is quantdb, import name is qdb (similar to scikit-learn โ sklearn)
Made with โค๏ธ for the Python quantitative finance community
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file quantdb-2.2.9.tar.gz.
File metadata
- Download URL: quantdb-2.2.9.tar.gz
- Upload date:
- Size: 182.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.10.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7c8c3f6af569388dbc2e667534020f4430f9587eb43523e71e0c5dce42e1353f
|
|
| MD5 |
3c6f408559a559b11d38050278a85c98
|
|
| BLAKE2b-256 |
024ccab055b82840c9f80299065aec4bd4ea3ab61e9b3c3730c8fc45b81550f9
|
File details
Details for the file quantdb-2.2.9-py3-none-any.whl.
File metadata
- Download URL: quantdb-2.2.9-py3-none-any.whl
- Upload date:
- Size: 95.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.10.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
3c2c56c7b51008aa35fb59d922f755b4ea6895cf618c2b9f3aa2164459ab8150
|
|
| MD5 |
882a60f9e6b48dd15e51fc0add258928
|
|
| BLAKE2b-256 |
ad4c04b44eea41a3486707e6d69cc524572b2d098be6d372cfc4eee1719a21d9
|