Skip to main content

Client SDK for FinSight read-only latest-trade-day data API

Project description

FinSight Data SDK

FinSight 数据服务提供只读行情接口。实时接口只支持全市场统一快照,不支持按单个股票代码查询。

1. 安装

pip install finsight-data

2. 初始化

from finsight_data import FinSightDataClient

client = FinSightDataClient(token="YOUR_DATA_API_TOKEN")

完整示例脚本见 examples/finsight_data_demo.py

参数 必填 类型 说明
token str 数据接口 token
timeout int 请求超时秒数,默认 20

初始化会自动校验 token 并完成当前设备绑定。后续数据接口不需要再传设备绑定参数。 同一个 token 默认绑定一台设备;如需迁移设备,请先完成账户侧确认后再执行初始化。

3. 最新交易日板块资金流向

data = client.get_stock_sector_fund_flow_daily_latest(
    board_type="行业",
    keyword="半导体",
    limit=50,
    offset=0,
)

数据口径:按最新交易日返回板块资金流。board_type 为空时,返回行业、概念、板块三类各 Top50;指定类型时,返回该类型 Top50。

参数 必填 类型 说明
board_type str 板块类型:行业概念板块;为空表示不限
keyword str 按板块代码或名称搜索
limit int 最大 50,默认 50;指定 board_type 时表示返回条数,未指定时表示每类返回条数
offset int 偏移量,默认 0

输出:

{
  "ok": true,
  "trade_date": "2026-05-18",
  "total": 86,
  "items": [
    {
      "code": "BK1036",
      "name": "半导体",
      "board_type": "行业",
      "pct_chg": 2.15,
      "main_net_inflow_amount": 123456789.0,
      "main_net_inflow_ratio": 4.32
    }
  ]
}

4. 最新交易日个股资金流向

data = client.get_stock_individual_fund_flow_daily_latest(
    codes=["600519", "000858"],
    keyword="",
    limit=100,
    offset=0,
)
参数 必填 类型 说明
codes list[str] 股票代码列表;为空表示不限
keyword str 按股票代码或名称搜索
limit int 返回条数;不填返回筛选后的全部结果
offset int 偏移量,默认 0

输出:

{
  "ok": true,
  "trade_date": "2026-05-18",
  "total": 2,
  "items": [
    {
      "code": "600519",
      "name": "贵州茅台",
      "latest_price": 1688.0,
      "pct_chg": 1.25,
      "main_net_inflow_amount": 123456789.0,
      "main_net_inflow_ratio": 3.21
    }
  ]
}

5. 最新交易日前复权日线

data = client.get_stock_daily_kline_q_latest(
    codes=["600519"],
    keyword="",
    limit=100,
    offset=0,
)
参数 必填 类型 说明
codes list[str] 股票代码列表;为空表示不限
keyword str 按股票代码搜索
limit int 返回条数;不填返回筛选后的全部结果
offset int 偏移量,默认 0

输出:

{
  "ok": true,
  "trade_date": "2026-05-18",
  "total": 1,
  "items": [
    {
      "code": "600519",
      "open_price": 1680.0,
      "close_price": 1688.0,
      "high_price": 1699.0,
      "low_price": 1666.0,
      "volume": 123456,
      "amount": 234567890.0,
      "pct_chg": 1.25
    }
  ]
}

6. 实时全市场个股快照

单次拉取:

frame = client.get_realtime_full_market_snapshot(include_rows=True)
print(frame["seq"], frame["timestamp"], frame["returned_rows"])

持续接收:

for frame in client.iter_realtime_full_market_snapshot():
    print(frame["seq"], frame["timestamp"], frame["returned_rows"])

模拟实盘:

for frame in client.iter_realtime_full_market_snapshot(
    simulate_live=True,
    simulation_interval_seconds=1,
):
    print(frame["simulate_live"], frame["seq"])
参数 必填 类型 说明
include_rows bool 是否返回解压后的 rows,默认 True
keep_packed_rows bool 解压后是否保留 rows_gzip_b64
simulate_live bool 是否启用模拟实盘模式
simulation_interval_seconds float 模拟实盘推送间隔
reconnect bool SSE 断线后是否自动重连,仅持续接收接口支持
max_reconnects int 最大自动重连次数,仅持续接收接口支持

输出:

{
  "ok": true,
  "mode": "full_market_only",
  "data_key": "full_market",
  "seq": 123456,
  "timestamp": "2026-05-18 09:31:03",
  "total": 5300,
  "cols": ["code", "name", "price", "pct_chg", "zljlr"],
  "sorted_by": "zljlr_desc",
  "packed": true,
  "min_interval_seconds": 3,
  "token_scope": "data_api",
  "rows": [
    ["600000", "浦发银行", 10.25, 1.18, 28340000.0]
  ],
  "returned_rows": 5300
}

7. Token 用量

usage = client.get_token_usage()
print(usage["summary"]["day"]["remaining"])

输出:

{
  "ok": true,
  "service": "finsight-data",
  "token_scope": "data_api",
  "account": {
    "username": "demo_user",
    "is_admin": false
  },
  "device_binding": {
    "mode": "bind_on_first_use",
    "is_bound": true,
    "rebind_remaining": 1
  },
  "summary": {
    "day": {
      "limit": 100,
      "used": 2,
      "remaining": 98,
      "resets_at": "2026-05-19T00:00:00+08:00"
    }
  },
  "endpoints": []
}

8. 错误码

状态码 说明
400 参数错误
401 token 缺失或无效
403 token 无权限、设备不匹配或实时接口不在可用时段
429 频率、额度、并发或队列限制
503 服务滚动更新中,请稍后重试

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distributions

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

finsight_data-1.0.2-cp312-cp312-manylinux_2_28_x86_64.whl (743.9 kB view details)

Uploaded CPython 3.12manylinux: glibc 2.28+ x86-64

finsight_data-1.0.2-cp39-cp39-macosx_10_9_universal2.whl (228.7 kB view details)

Uploaded CPython 3.9macOS 10.9+ universal2 (ARM64, x86-64)

File details

Details for the file finsight_data-1.0.2-cp312-cp312-manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for finsight_data-1.0.2-cp312-cp312-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 fb0c8bc6198d034558849061d3d15ac1946d6cd535c98e24a16a75b3c09291ae
MD5 c13d89518306be4f4a714d6be825d2b2
BLAKE2b-256 d5efcb0baae73ad880b9ce2e61aff63d481a2c78adc08d506b34f53f875eb5c2

See more details on using hashes here.

File details

Details for the file finsight_data-1.0.2-cp39-cp39-macosx_10_9_universal2.whl.

File metadata

File hashes

Hashes for finsight_data-1.0.2-cp39-cp39-macosx_10_9_universal2.whl
Algorithm Hash digest
SHA256 a39491bc85ae3724fa5f490d6ffde2d436085c226ccd7d3029e245ebd4f57a94
MD5 3ce659434e387f88216b9587c4242cf3
BLAKE2b-256 3cb186b3aa5678784889563990e5c7bd583b99040e1b86bbe259b415f9f91b7d

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