Skip to main content

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.

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.1.tar.gz (18.9 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.1-py3-none-any.whl (25.3 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for moomoo_data-0.2.1.tar.gz
Algorithm Hash digest
SHA256 63a3546eb8cb7a53e6739f9342059b0eaaa264f0ea2da7c6cfb783916bb770d8
MD5 fbdfe6d7f3b16ad2fa0919edc232068f
BLAKE2b-256 b68e530b2c84a0b1cc00df3fa71f1dcc4291cb781e2ad37416d88c5a8e794d6f

See more details on using hashes here.

File details

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

File metadata

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

File hashes

Hashes for moomoo_data-0.2.1-py3-none-any.whl
Algorithm Hash digest
SHA256 9597c46073f02d3b574f2b22eca6adc23c747ad8e92d45a210a2e67a88156c2a
MD5 1f7f5915cfb79e6f82a8b9642c8dd5bc
BLAKE2b-256 763455dc8243ccfd6e7af8416a18f3e090807242084838c5cfd2435550227e34

See more details on using hashes here.

Release history Release notifications | RSS feed

This release

0.2.1 This release

2 files

0.2.0

2 files

0.1.1

2 files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page