Skip to main content

Moomoo OpenD data provider for HKSE/KLSE markets with capital flow analysis

Project description

moomoo-data

PyPI version Python versions License: MIT

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-api package (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 quotes
  • 02_kline_analysis.py - K-line data retrieval
  • 03_capital_flow.py - Capital flow analysis
  • 04_chip_distribution.py - Chip distribution visualization

Documentation

Full API documentation: GitHub

License

MIT License - see LICENSE file for details.

Contributing

Contributions welcome! Please:

  1. Fork the repository
  2. Create a feature branch (git checkout -b feature/amazing-feature)
  3. Commit your changes (git commit -m 'Add amazing feature')
  4. Push to the branch (git push origin feature/amazing-feature)
  5. Open a Pull Request

Changelog

See CHANGELOG.md for version history.

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

moomoo_data-0.2.0.tar.gz (22.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

moomoo_data-0.2.0-py3-none-any.whl (25.0 kB view details)

Uploaded Python 3

File details

Details for the file moomoo_data-0.2.0.tar.gz.

File metadata

  • Download URL: moomoo_data-0.2.0.tar.gz
  • Upload date:
  • Size: 22.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.3

File hashes

Hashes for moomoo_data-0.2.0.tar.gz
Algorithm Hash digest
SHA256 11e8836e79cc9139d20b189b2682fa182db256e566a19ff8dfae162814f2eb7f
MD5 113f92c8a2983d305aa7599c8730c3b9
BLAKE2b-256 77e85725c4b95380698d6964643e51a7b1e2c4e00f053748e06bb0c57d71046f

See more details on using hashes here.

File details

Details for the file moomoo_data-0.2.0-py3-none-any.whl.

File metadata

  • Download URL: moomoo_data-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 25.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.3

File hashes

Hashes for moomoo_data-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 3094899a33f46542d3bb780a8d62facb2274bef50bc8201a0ceab2785ebe6188
MD5 f348312cf11d5a8332ed145c23fb2851
BLAKE2b-256 02867a16f62925ce5a06ccd80a044a4c2f2356d756f84596927fc07dc4a034f8

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page