moomoo-data
Moomoo OpenD data provider for HKSE/KLSE markets with capital flow analysis
A comprehensive Python library for accessing Moomoo OpenD API data, featuring:
-
📈 Real-time quotes for HKSE and KLSE stocks
-
📊 K-line data (daily, weekly, monthly, intraday)
-
💰 Capital flow analysis (super/big/mid/small order tracking)
-
🎯 Chip distribution analysis (triangular distribution model)
-
💾 Built-in caching (memory + SQLite)
-
⚡ Rate limiting with configurable limits
Installation
pip install moomoo-data
Optional dependencies
# Full installation with all features
pip install moomoo-data[all]
# SQLite caching (recommended for production)
pip install moomoo-data[cache]
Requirements
- Python 3.10+
- Moomoo OpenD gateway running locally (default:
127.0.0.1:11111) moomoo-apipackage (pip install moomoo-api)
Quick Start
from moomoo_data import get_stock_quote, get_daily_kline, get_capital_flow
# Get real-time quote
quote = get_stock_quote("0700.HK")
print(f"Price: {quote['最新价']}, Change: {quote['涨跌幅']}%")
# Get daily K-line
kline = get_daily_kline("0700.HK", count=100)
print(f"Retrieved {len(kline)} days of data")
# Get capital flow
flow = get_capital_flow("0700.HK")
print(f"Net inflow: {flow['net_inflow']}")
Configuration
Configure via environment variables or .env file:
# Moomoo OpenD connection
MOOMOO_HOST=127.0.0.1
MOOMOO_PORT=11111
MOOMOO_ENABLED=true
# Cache settings
MOOMOO_CACHE_PATH=~/.cache/moomoo-data/cache.db
MOOMOO_CACHE_ENABLED=true
# Rate limits (requests per 30 seconds)
MOOMOO_RATE_LIMIT_QUOTE=30
MOOMOO_RATE_LIMIT_KLINE=20
API Reference
Core Functions
| Function | Description | Returns |
|---|---|---|
get_stock_quote(ticker) |
Real-time stock quote | Dict with OHLCV + changes |
get_daily_kline(ticker, count) |
Daily K-line data | pandas DataFrame |
get_history_kline(ticker, start, end) |
Historical K-line | pandas DataFrame |
get_capital_flow(ticker) |
Capital flow by order size | Dict with inflow/outflow |
get_capital_distribution(ticker) |
Current capital distribution | Dict with super/big/mid/small |
analyze_chip_distribution(ticker) |
Chip distribution analysis | Dict with avg_cost, concentration |
Ticker Formats
Supported formats:
- FinGenius:
0700.HK,7088.KL - Moomoo:
HK.00700,MY.07088
The library automatically converts between formats.
Markets Supported
| Market | Ticker Suffix | Example |
|---|---|---|
| HKSE | .HK |
0700.HK (Tencent) |
| KLSE | .KL |
7088.KL (Yinson) |
| A-Share | 6-digit code | 600519 (Kweichow Moutai) |
Chip Analysis
The library includes a professional-grade chip distribution analyzer using:
- Triangular distribution: Spreads turnover across price range
- L-Curve decay: Models psychological selling behavior
- Dynamic bin sizing: Market-aware granularity
- NumPy vectorization: 100x faster than loops
from moomoo_data import analyze_chip_distribution
result = analyze_chip_distribution("0700.HK")
print(f"Average cost: {result['avg_cost']}")
print(f"Concentration (90%): {result['concentration_90']}%")
print(f"Profit ratio: {result['profit_ratio']}%")
Examples
See the examples/ directory for:
01_basic_quote.py- Real-time quotes02_kline_analysis.py- K-line data retrieval03_capital_flow.py- Capital flow analysis04_chip_distribution.py- Chip distribution visualization
Documentation
Full API documentation: GitHub
License
MIT License - see LICENSE file for details.
Contributing
Contributions welcome! Please:
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
Changelog
See CHANGELOG.md for version history.
Metadata
Release files for moomoo-data 0.2.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| moomoo_data-0.2.1.tar.gz | 18.9 kB | Without provenance | Details for moomoo_data-0.2.1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| moomoo_data-0.2.1-py3-none-any.whl | Python 3 | none | any | Details for moomoo_data-0.2.1-py3-none-any.whl |
Total release size: 44.2 kB
Release files / moomoo_data-0.2.1.tar.gz
| Download URL | moomoo_data-0.2.1.tar.gz |
|---|---|
| Size | 18.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
63a3546eb8cb7a53e6739f9342059b0eaaa264f0ea2da7c6cfb783916bb770d8
|
|
BLAKE2b-256 checksum How to use checksums |
b68e530b2c84a0b1cc00df3fa71f1dcc4291cb781e2ad37416d88c5a8e794d6f
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.12.12
|
Release files / moomoo_data-0.2.1-py3-none-any.whl
| Download URL | moomoo_data-0.2.1-py3-none-any.whl |
|---|---|
| Size | 25.3 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
9597c46073f02d3b574f2b22eca6adc23c747ad8e92d45a210a2e67a88156c2a
|
|
BLAKE2b-256 checksum How to use checksums |
763455dc8243ccfd6e7af8416a18f3e090807242084838c5cfd2435550227e34
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.12.12
|
Security for moomoo-data 0.2.1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.