Skip to main content

Python reader for DataHub-style sharded OHLCV Arrow datasets

Project description

ohlcvpy

ohlcvpy 是一个针对 DataHub 风格数据目录的 Python 包。

数据结构(来自 DataHub lib)

  • stock.json:索引文件,记录 exchange/symbol/name/arrow_file
  • stock_XXX.arrow:分片文件,包含列
    • exchange: utf8
    • symbol: utf8
    • name: utf8
    • daily: list<struct<date, open, high, low, close, volume, amount>>

安装

pip install -e ".[io]"

API 设计(极简)

from ohlcvpy import open_store

store = open_store("/path/to/docs/data")

print(store.list_exchanges())
print(store.list_symbols("SSE"))

stock = store.get_stock("600519", exchange="SSE")
bars = store.get_bars("600519", exchange="SSE", limit=20)
bar = store.get_bar("600519", date=20260310, exchange="SSE")

market = store.get_market(date=20260310, exchange="SSE")  # 已自动过滤非主板、ST/退市、停牌股票

print(store.latest_date())  # e.g. 20260310
print(store.latest_date(exchange="SSE"))

Example

运行仓库内示例:

python examples/api_usage.py \
  --data-dir /Users/10005612/Projects/DataHub/docs/data \
  --exchange SSE \
  --symbol 600519 \
  --date 20260310

设计要点

  • 按分片懒加载,不会在初始化时读全量 Arrow。
  • symbol+exchange 作为主键,避免跨交易所冲突。
  • 查询入口聚焦两个角度:按股票(get_stock/get_bars/get_bar)和按日期(get_market)。
  • 内置基础过滤函数:is_main_boardis_st_or_delistedis_suspended
  • 过滤在数据源阶段生效:索引加载时过滤非主板/ST退市,分片加载时过滤停牌(最新交易日成交量为 0 即停牌)。

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

ohlcvpy-0.1.1.tar.gz (6.6 kB view details)

Uploaded Source

Built Distribution

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

ohlcvpy-0.1.1-py3-none-any.whl (6.1 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: ohlcvpy-0.1.1.tar.gz
  • Upload date:
  • Size: 6.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.9

File hashes

Hashes for ohlcvpy-0.1.1.tar.gz
Algorithm Hash digest
SHA256 923e061da1d1b736879e677f9f88fa4007c8f7caa4fb2b1c79bbe681600b03d9
MD5 16bcab43b5e0788cd9062970b5ce326a
BLAKE2b-256 a3df0cb3dc7820be97da8e34734d91ff3f0904275cc91f3588cfbb6729187ce7

See more details on using hashes here.

File details

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

File metadata

  • Download URL: ohlcvpy-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 6.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.9

File hashes

Hashes for ohlcvpy-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 ef92c6576db1a2f65998d1d0c0a273102ad8ce21e385f82d8f3c94c88b355c91
MD5 c2c07f7017d0874d1db37695076c862c
BLAKE2b-256 828794015aa51304e826184bb108177b63d495607b35c9b825c81693ae92dd2d

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