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.1.1.tar.gz (22.2 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.1.1-py3-none-any.whl (25.1 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: moomoo_data-0.1.1.tar.gz
  • Upload date:
  • Size: 22.2 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.1.1.tar.gz
Algorithm Hash digest
SHA256 bbb6a2f272d7d9798ed76ef98f60180f5e51b090956aec2f736bfdaaf1cd6974
MD5 e61005cc6c5bc24088eaa3619063e299
BLAKE2b-256 b1c99a24e1d373ebc20aeb6ae0df84a3c0bdcaaa541631a0ec471f73ca31d8de

See more details on using hashes here.

File details

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

File metadata

  • Download URL: moomoo_data-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 25.1 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.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 61adfde36d67ddb8fea91de2550177fbaab3ffe47895371a365b34768d77be21
MD5 c5d477db1504648f71a82a2308e2b39c
BLAKE2b-256 e69e4f35dc995c3febf33c10ab2a6a86400db5633189eb2085de9d6da49238fb

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