Skip to main content

jcdata

连接 JCDATA 数据服务,详情可查看官网:https://jicequant.com/

用户注册后即可在个人中心使用一定额度的数据服务。

安装

pip install jcdata

配置

访问令牌任选一种方式提供:

import jcdata

jcdata.login("你的访问令牌")

或设置环境变量后直接 jcdata.login():

# Linux / macOS
export JCDATA_TOKEN="你的访问令牌"

# Windows PowerShell
$env:JCDATA_TOKEN="你的访问令牌"

服务地址默认为 https://api.jicequant.com(可在安装包内 config.py 的 BASE_URL 修改)。

使用

import jcdata

jcdata.login("你的访问令牌")
print(jcdata.whoami())

bars = jcdata.get_market_data("600000.SH", "2025-01-01", "2025-01-31")
df = bars["600000.SH"]

主要接口

  • 行情:get_market_data
  • 基础信息:get_instrument、get_adj_factor
  • 期货/转债:get_settlement、get_future_contract
  • 股票因子:get_valuation、get_market_value、get_finance
  • 其它:get_trade_dates、get_all_sectors、get_stock_list_by_sector、get_option_bars、get_option_info

代码格式为 代码.交易所,如 600000.SH。

大批量日 K 流式读取

get_market_data() 使用 Arrow IPC + Zstandard 分批传输,并为兼容返回值聚合成完整的 {symbol: DataFrame}。它适合常规查询;结果量很大时仍会占用与完整结果相当的客户端内存。

百万/千万行历史数据应使用 iter_market_data_batches()。每次迭代只接收、解压并转换一个 TDengine 读取批次;调用方可立即写盘或计算后释放该批次:

import jcdata

jcdata.login("你的访问令牌")
for symbols, frames in jcdata.iter_market_data_batches(
    ["000001.SZ", "600000.SH"],
    "2015-01-01",
    "2025-12-31",
    stream_batch_rows=65_536,
):
    for symbol, frame in frames.items():
        frame.to_parquet(f"{symbol}.parquet", index=False)

传输协议为 POST /api/v1/data/query,请求 Accept: application/vnd.jcdata.arrow-zstd。服务端将日K代码切为最多 60 个代码的 TDengine 分片;有效登录请求始终受理,频率超过配置时仅延迟入队,不返回 429/503。空闲时一个用户可使用全部流式连接预算;多用户竞争时按用户在分片级轮转。请求排队期间不占 TDengine 连接,客户端读超时应不低于服务端预期排队时间。服务端从 TDengine fetchmany() 增量读取并以独立 Arrow IPC Zstd 段发送;Arrow 流不经过 HTTP GZip。stream_batch_rows 仅控制单批内存窗口,不限制返回行数;zstd_level 默认 3,可显式传入 -7 至 22。客户端承担 Zstd 解压、pandas 转换与按 symbol 拆分。

requests_per_second 默认 1 次/秒;超过时请求继续保持连接并按用户 FIFO 延迟,而不会被拒绝。设为 0 可显式关闭频率延迟。运行 python bin/benchmark_jcdata_server.py 可基于 5、60、300 个代码记录未压缩 Arrow 与 Zstd 流的首字节、总耗时、解码、线上字节、批次数和 RSS 变化。

使用限制

  • 大批量代码使用 POST body 传输,不受 GET URL 长度影响。
  • 取数服务不会添加隐式 SQL LIMIT;仅当调用方传入 row_limit 时才原样下推。
  • get_market_data() 会完整物化返回字典;大结果请使用 iter_market_data_batches()。

Metadata

Release files for jcdata 0.2.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for jcdata 0.2.0
File Size Uploaded Provenance Actions
jcdata-0.2.0.tar.gz 18.8 kB Without provenance Details for jcdata-0.2.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for jcdata 0.2.0
File Interpreter ABI Platform Actions
jcdata-0.2.0-py3-none-any.whl Python 3 none any Details for jcdata-0.2.0-py3-none-any.whl

Total release size: 38.3 kB

Release files / jcdata-0.2.0.tar.gz

Download URL jcdata-0.2.0.tar.gz
Size 18.8 kB
Tags Source
SHA-256 checksum
How to use checksums
469196e6172fa30fc74278d40b29e9050d1606f8d1db6ad1d1135b2eef7fc5d7
BLAKE2b-256 checksum
How to use checksums
6edde18ccc784fc1c0d8c656c0a0af459ec6c1278d1ea97abd312c8a157a0db6
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.12.13

Release files / jcdata-0.2.0-py3-none-any.whl

Download URL jcdata-0.2.0-py3-none-any.whl
Size 19.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
8241a50acb4882dbbf62ca728ded6d3935be52a0a05c61e935710c5e85340a84
BLAKE2b-256 checksum
How to use checksums
3a95988418c9b42f1c00821bb7fb6b943510b935d1520f2caa41a591a1497920
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.12.13

Security for jcdata 0.2.0

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.

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