Skip to main content

LiteQuant Python SDK

LiteQuant Python SDK 用于在本地下载和读取 LiteQuant 数据。SDK 会自动处理连接、同步、本地 Parquet 缓存和常见错误提示。

支持 Python 3.8 及以上版本。

Installation

pip install litequant

Quick Start

from litequant import LiteQuantClient

client = LiteQuantClient(
    api_token="your_api_token",
    save_path="./litequant_data",
)

client.UpdateAllCategory(update_method="incremental")
df = client.GetCategory("cn_stock_pivot#open")
print(df.tail())

client.close()

推荐使用上下文管理器自动关闭连接:

from litequant import LiteQuantClient

with LiteQuantClient(api_token="your_api_token", save_path="./litequant_data") as client:
    categories = client.ListCategories()
    df = client.GetCategory(categories[0])

默认 API 地址为 https://www.litequant.pro。如需连接测试环境,可以传入 api_url 或设置环境变量 LITEQUANT_API_URL。

Transport Security

  • API Token 只会发送到 HTTPS 地址;仅允许 localhost、127.0.0.1 和 ::1 使用 HTTP 本地调试。
  • SDK 不跟随 API 重定向,避免临时连接凭证被转发到其他地址。
  • 第三方 API 返回的外部明文 Redis/Tair 连接会被拒绝;官方生产 API 仅可在服务端明确声明受限传输策略、目标地址和端口均匹配时使用短期连接凭证。
  • 远端数据写入本地前必须通过 SHA-256 校验;不完整或异常元数据会被拒绝。
  • 数据类别名称会经过严格校验,不能越过 save_path 读写或删除文件。

Windows wheel 会将连接与同步核心编译为 .pyd,不随包分发对应的 Python 源文件。这可以提高查看和修改内部实现的门槛,但不应被视为不可逆向的安全边界;长期密钥和权限判断始终保留在服务端。

Error Handling

SDK 默认会在 Python 终端输出功能面错误提示,同时抛出类型化异常。错误信息不会展示后端细节。

from litequant import LiteQuantClient, LiteQuantError

try:
    with LiteQuantClient(api_token="your_api_token", save_path="./litequant_data") as client:
        df = client.GetCategory("cn_stock_pivot#open")
except LiteQuantError as exc:
    print(exc.code)
    print(exc.user_message)
    print(exc.retryable)

如果你希望完全自己处理错误提示,可以关闭终端输出:

client = LiteQuantClient(
    api_token="your_api_token",
    save_path="./litequant_data",
    display_errors=False,
)

常见公开错误码:

  • AUTH_INVALID:API 凭证无效或已过期
  • ACCOUNT_UNAVAILABLE:账号不可用
  • SUBSCRIPTION_UNAVAILABLE:套餐不可用或已过期
  • PERMISSION_DENIED:权限不足
  • CONNECTION_LIMIT:连接数已达上限
  • CONNECTION_INTERRUPTED:连接已中断,请重新连接
  • REQUEST_INVALID:请求参数无效
  • SERVICE_UNAVAILABLE:服务暂时不可用
  • DATA_UNAVAILABLE:数据暂时不可用
  • DATA_VERIFY_FAILED:数据校验失败

Data Cache

SDK 会把数据保存为本地 Parquet 缓存。再次读取同一数据类别时,会优先使用本地缓存;如果本地没有该数据类别,SDK 会自动同步。

当前 pivot 数据支持 monthly 和 daily 两种分区模式。后续可以在服务端元信息和客户端缓存层一起扩展更多分区模式。

Metadata Contract

数据服务会提供客户端可识别的类别列表、类别元信息和分区元信息。客户端会自动读取这些元信息并完成数据同步。

公开稳定字段包括:

  • partition_mode:pivot 分区模式,目前支持 monthly 和 daily
  • partition_keys:数据分区标识列表
  • hash:数据校验值
  • key_columns / dedupe_keys:unstack 数据去重键

普通用户通常不需要直接使用这些字段。

Metadata

Release files for litequant 3.0.5

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

Built distributions (wheels)

Table of built distributions (wheels) for litequant 3.0.5
File Actions
litequant-3.0.5-cp314-cp314-win_amd64.whl CPython 3.14 CPython 3.14 Windows x86-64 Details for litequant-3.0.5-cp314-cp314-win_amd64.whl
litequant-3.0.5-cp313-cp313-win_amd64.whl CPython 3.13 CPython 3.13 Windows x86-64 Details for litequant-3.0.5-cp313-cp313-win_amd64.whl
litequant-3.0.5-cp312-cp312-win_amd64.whl CPython 3.12 CPython 3.12 Windows x86-64 Details for litequant-3.0.5-cp312-cp312-win_amd64.whl
litequant-3.0.5-cp311-cp311-win_amd64.whl CPython 3.11 CPython 3.11 Windows x86-64 Details for litequant-3.0.5-cp311-cp311-win_amd64.whl
litequant-3.0.5-cp310-cp310-win_amd64.whl CPython 3.10 CPython 3.10 Windows x86-64 Details for litequant-3.0.5-cp310-cp310-win_amd64.whl
litequant-3.0.5-cp39-cp39-win_amd64.whl CPython 3.9 CPython 3.9 Windows x86-64 Details for litequant-3.0.5-cp39-cp39-win_amd64.whl
litequant-3.0.5-cp38-cp38-win_amd64.whl CPython 3.8 CPython 3.8 Windows x86-64 Details for litequant-3.0.5-cp38-cp38-win_amd64.whl

Total release size: 1.2 MB

Release files / litequant-3.0.5-cp314-cp314-win_amd64.whl

Download URL litequant-3.0.5-cp314-cp314-win_amd64.whl
Size 171.0 kB
Tags CPython 3.14 Windows x86-64
SHA-256 checksum
How to use checksums
9d4b7c8355a8505c38899fe123212b2dff51d32d4a143ce0484cc96b4e021935
BLAKE2b-256 checksum
How to use checksums
3de03472150f4b2b759afa29f0cf7760a7839b82afda4e61e6721a1e1260d19d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.13

Release files / litequant-3.0.5-cp313-cp313-win_amd64.whl

Download URL litequant-3.0.5-cp313-cp313-win_amd64.whl
Size 168.1 kB
Tags CPython 3.13 Windows x86-64
SHA-256 checksum
How to use checksums
1a18ab06d5fc0da2569ca877d5a096e1d5cc46882363b538042307ed79b96154
BLAKE2b-256 checksum
How to use checksums
5106b12a749bc155747db2007a1cbc66d019a8acb42874af4636cd5d98b8cc3d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.13

Release files / litequant-3.0.5-cp312-cp312-win_amd64.whl

Download URL litequant-3.0.5-cp312-cp312-win_amd64.whl
Size 168.5 kB
Tags CPython 3.12 Windows x86-64
SHA-256 checksum
How to use checksums
a0fc44d22432b9a0e09a0f91a17e730740db959b73fcd23a1e7b8e33c54ad82e
BLAKE2b-256 checksum
How to use checksums
284d130a5b39bb46e021c4b962fd3d7027b1e73777d1dd8f5fa22eb104205ee1
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.13

Release files / litequant-3.0.5-cp311-cp311-win_amd64.whl

Download URL litequant-3.0.5-cp311-cp311-win_amd64.whl
Size 177.9 kB
Tags CPython 3.11 Windows x86-64
SHA-256 checksum
How to use checksums
784a939341a87f4bbf133e72f9520b9de3400a6a097064f2bb8718b1083842d8
BLAKE2b-256 checksum
How to use checksums
809067e40f4057713e9986fa0b0f886958ad147c96e896fad504ec309de90c6e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.13

Release files / litequant-3.0.5-cp310-cp310-win_amd64.whl

Download URL litequant-3.0.5-cp310-cp310-win_amd64.whl
Size 176.1 kB
Tags CPython 3.10 Windows x86-64
SHA-256 checksum
How to use checksums
69ece906812f31057a6d2266ef11746ccdfb4efb9d9de98aa0353371f3ad2c12
BLAKE2b-256 checksum
How to use checksums
0556686e60cdd678749d2e1c37045e8e9c0529975ce14266611c492448d28c7c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.13

Release files / litequant-3.0.5-cp39-cp39-win_amd64.whl

Download URL litequant-3.0.5-cp39-cp39-win_amd64.whl
Size 176.5 kB
Tags CPython 3.9 Windows x86-64
SHA-256 checksum
How to use checksums
fb43053fa528d58b273d55eaf1c6bdd15b1cca25d5d33e1b529ad385d58b1bcd
BLAKE2b-256 checksum
How to use checksums
a03a7f5689487c2b17c5de711eeb89d3c789254cde9ceb9db7415ba545394684
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.13

Release files / litequant-3.0.5-cp38-cp38-win_amd64.whl

Download URL litequant-3.0.5-cp38-cp38-win_amd64.whl
Size 167.4 kB
Tags CPython 3.8 Windows x86-64
SHA-256 checksum
How to use checksums
5eb02202605791c2ce74dad38b4081391cd1d9d8630fd20eb1b3efc653f6ba2a
BLAKE2b-256 checksum
How to use checksums
bf32f06837187ebbb9c92f78321f2efe189752fcfd149c2f1f51bb7086ac61fc
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.13

Security for litequant 3.0.5

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