Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

### Added
- New sector knowledge endpoints: `sector_knowledge_facts` (板块事实检索) and `sector_knowledge_insights` (板块洞察检索) with keyword/expression, category, date, score and sort filters plus pagination; `sector_knowledge_sectors` (板块描述列表) and `sector_knowledge_search_options` (板块知识检索选项) for name and enum discovery.
- New `futures_dominant_mapping` (期货主力合约映射) endpoint returning each exchange/variety's dominant contract for a trade date, with the `v1`–`v4` rule selection.

### Changed
- `ashare_news_sentiment_factors` now accepts the documented single-day `date` parameter; `start_date`/`end_date` must be passed together and span no more than 31 days, and omitting all dates queries the current prediction day.
- `ashare_rating_factor_snapshot` is now paginated (`page`/`page_size` with the documented 500-row cap, plus `limit`/`all_pages`/`max_pages`); `trade_code` is optional for full-market queries and `top_k` is capped at 10 by the service.
Expand Down
188 changes: 185 additions & 3 deletions docs/API_REFERENCE.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,19 @@

| 指标 | 数量 |
|---|---:|
| SDK 方法总数 | 250 |
| SDK 方法总数 | 255 |

## 专题分布

| ftshare-doc 专题 | SDK 方法数 | API mixin 模块 | Endpoint 模块 |
|---|---:|---|---|
| 股票数据 | 131 | `ftshare.apis.stock` | `ftshare.endpoints.stock` |
| 股票数据 | 135 | `ftshare.apis.stock` | `ftshare.endpoints.stock` |
| 港股数据 | 3 | `ftshare.apis.hk` | `ftshare.endpoints.hk` |
| 美股数据 | 2 | `ftshare.apis.us` | `ftshare.endpoints.us` |
| 指数专题 | 16 | `ftshare.apis.index` | `ftshare.endpoints.index` |
| ETF专题 | 17 | `ftshare.apis.etf` | `ftshare.endpoints.etf` |
| 公募基金 | 18 | `ftshare.apis.fund` | `ftshare.endpoints.fund` |
| 期货数据 | 22 | `ftshare.apis.futures` | `ftshare.endpoints.futures` |
| 期货数据 | 23 | `ftshare.apis.futures` | `ftshare.endpoints.futures` |
| 债券专题 | 9 | `ftshare.apis.bond` | `ftshare.endpoints.bond` |
| 宏观经济 | 23 | `ftshare.apis.economic` | `ftshare.endpoints.economic` |
| 大模型语料 | 7 | `ftshare.apis.llm_corpus` | `ftshare.endpoints.llm_corpus` |
Expand Down Expand Up @@ -163,6 +163,10 @@
| [`trading_calendar`](#api-trading-calendar) | 交易日历 | `GET` | `api/v1/market/data/time/trading-calendar` | `market`, `start_date`, `end_date` | `交易日历.md` |
| [`xueqiu_rank`](#api-xueqiu-rank) | 雪球股票排名 | `GET` | `api/v1/market/data/xueqiu-rank` | `rank_group`, `period`, `trade_date`, `page`, `page_size` | `雪球股票排名.md` |
| [`yzxdr_detail`](#api-yzxdr-detail) | 一致行动人明细 | `GET` | `api/v1/market/data/yzxdr-detail` | `year`, `quarter`, `stock_code`, `page`, `page_size` | `一致行动人明细.md` |
| [`sector_knowledge_facts`](#api-sector-knowledge-facts) | 板块事实检索 | `GET` | `api/v3/market/data/sector-knowledge/facts` | `sector_name`, `sector_type`, `market`, `keyword`, `keyword_expression`, `fact_category`, `start_date`, `end_date`, `min_influence_score`, `min_reliability_score`, `sort`, `page`, `page_size` | `板块事实检索.md` |
| [`sector_knowledge_insights`](#api-sector-knowledge-insights) | 板块洞察检索 | `GET` | `api/v3/market/data/sector-knowledge/insights` | `sector_name`, `sector_type`, `market`, `keyword`, `keyword_expression`, `insight_category`, `start_date`, `end_date`, `min_influence_score`, `min_confidence`, `sort`, `page`, `page_size` | `板块洞察检索.md` |
| [`sector_knowledge_search_options`](#api-sector-knowledge-search-options) | 板块知识检索选项 | `GET` | `api/v3/market/data/sector-knowledge/search-options` | - | `板块知识检索选项.md` |
| [`sector_knowledge_sectors`](#api-sector-knowledge-sectors) | 板块描述列表 | `GET` | `api/v3/market/data/sector-knowledge/sectors` | `market`, `sector_type`, `name_keyword` | `板块描述列表.md` |

### 港股数据

Expand Down Expand Up @@ -265,6 +269,7 @@
| [`fut_weekly_detail`](#api-fut-weekly-detail) | 期货主要品种交易周报 | `GET` | `api/v1/market/data/futures/fut-weekly-detail` | `week`, `prd`, `start_week`, `end_week`, `exchange`, `page`, `page_size` | `期货主要品种交易周报.md` |
| [`fut_wsr`](#api-fut-wsr) | 期货仓单日报 | `GET` | `api/v1/market/data/futures/fut-wsr` | `trade_date`, `start_date`, `end_date`, `symbol`, `exchange`, `page`, `page_size` | `期货仓单日报.md` |
| [`futures_daily_kline`](#api-futures-daily-kline) | 期货官方日K与9999主连 | `GET` | `api/v1/market/data/futures/daily-kline` | `symbol`, `trade_date`, `start_date`, `end_date`, `rule_version`, `page`, `page_size` | `期货官方日K与9999主连.md` |
| [`futures_dominant_mapping`](#api-futures-dominant-mapping) | 期货主力合约映射 | `GET` | `api/v1/market/data/futures/dominant-mapping` | `trade_date`, `rule_version` | `期货主力合约映射.md` |
| [`futures_kline`](#api-futures-kline) | 期货合约历史K线 | `GET` | `api/v1/market/data/futures/kline` | `symbol`, `interval`, `start`, `end`, `limit` | `期货合约历史K线.md` |
| [`futures_kline_batch`](#api-futures-kline-batch) | 批量期货合约历史K线 | `GET` | `api/v2/market/data/futures/kline/batch` | `symbols`, `interval`, `start`, `end`, `limit` | `批量期货合约历史K线.md` |
| [`futures_minutes`](#api-futures-minutes) | 期货历史分钟K线 | `GET` | `api/v2/market/data/futures_minutes` | `symbol`, `symbols`, `interval`, `start`, `end`, `limit` | `期货历史分钟K线.md` |
Expand Down Expand Up @@ -3584,6 +3589,152 @@ Returns:
payloads when multi-page fetching is used with ``raw=True``.
```

<h4 id="api-sector-knowledge-facts"><code>sector_knowledge_facts</code></h4>

- 接口名称:板块事实检索
- HTTP:`GET`
- Path:`api/v3/market/data/sector-knowledge/facts`
- 参数:`sector_name`, `sector_type`, `market`, `keyword`, `keyword_expression`, `fact_category`, `start_date`, `end_date`, `min_influence_score`, `min_reliability_score`, `sort`, `page`, `page_size`
- 来源文档:`板块事实检索.md`
- 原始接口:`sector_knowledge_facts`

```text
板块事实检索.

Endpoint: ``api/v3/market/data/sector-knowledge/facts``.
Method: ``GET``.
Documented endpoint: ``sector_knowledge_facts``.

Args:
sector_name: 板块标准名称,精确匹配 (type: string; required: N).
sector_type: 板块类型:industry / concept / region / index_style / macro_asset (type: string; required: N).
market: 市场:CN / US / HK / KR / JP / global (type: string; required: N).
keyword: 关键词子串匹配 title、content,最长 200 字符;与 keyword_expression 互斥 (type: string; required: N).
keyword_expression: 布尔表达式,支持 AND、OR、括号;与 keyword 互斥 (type: string; required: N).
fact_category: 板块事实分类,可重复传入;同维度多值为 OR (type: string; required: N).
start_date: 原始发布日期下界,YYYYMMDD (type: string; required: N).
end_date: 原始发布日期上界,YYYYMMDD (type: string; required: N).
min_influence_score: 最低影响力,0–100 (type: integer; required: N).
min_reliability_score: 最低可靠性,0–100 (type: integer; required: N).
sort: 排序方式:relevance / latest / influence,默认 relevance (type: string; required: N).
page: 页码,从 1 开始,默认 1,最大 1000.
page_size: 每页条数,默认 50,最大 200.
limit: Maximum number of rows to return when aggregating pages.
all_pages: Fetch every page.
max_pages: Safety bound when ``all_pages`` is enabled.
raw: Return the decoded JSON payload without tabular extraction.
fields: Optional field list or comma-separated field string applied after extraction.
as_dataframe: Return a pandas ``DataFrame`` by default; set to ``False`` for Python rows.
**kwargs: Extra request parameters forwarded unchanged. Useful when the service adds parameters before the SDK is regenerated.

Returns:
A pandas ``DataFrame`` by default, Python rows when
``as_dataframe=False``, raw JSON when ``raw=True``。关键词或表达式检索须同时提供
``sector_name``。
```

<h4 id="api-sector-knowledge-insights"><code>sector_knowledge_insights</code></h4>

- 接口名称:板块洞察检索
- HTTP:`GET`
- Path:`api/v3/market/data/sector-knowledge/insights`
- 参数:`sector_name`, `sector_type`, `market`, `keyword`, `keyword_expression`, `insight_category`, `start_date`, `end_date`, `min_influence_score`, `min_confidence`, `sort`, `page`, `page_size`
- 来源文档:`板块洞察检索.md`
- 原始接口:`sector_knowledge_insights`

```text
板块洞察检索.

Endpoint: ``api/v3/market/data/sector-knowledge/insights``.
Method: ``GET``.
Documented endpoint: ``sector_knowledge_insights``.

Args:
sector_name: 板块标准名称,精确匹配 (type: string; required: N).
sector_type: 板块类型:industry / concept / region / index_style / macro_asset (type: string; required: N).
market: 市场:CN / US / HK / KR / JP / global (type: string; required: N).
keyword: 关键词子串匹配 title、summary,最长 200 字符;与 keyword_expression 互斥 (type: string; required: N).
keyword_expression: 布尔表达式,支持 AND、OR、括号;与 keyword 互斥 (type: string; required: N).
insight_category: 板块洞察分类,可重复传入;同维度多值为 OR (type: string; required: N).
start_date: 板块洞察生成日期下界,YYYYMMDD (type: string; required: N).
end_date: 板块洞察生成日期上界,YYYYMMDD (type: string; required: N).
min_influence_score: 最低影响力,0–100 (type: integer; required: N).
min_confidence: 最低置信度,0–1 (type: number; required: N).
sort: 排序方式:relevance / latest / influence / confidence,默认 relevance (type: string; required: N).
page: 页码,从 1 开始,默认 1,最大 1000.
page_size: 每页条数,默认 50,最大 200.
limit: Maximum number of rows to return when aggregating pages.
all_pages: Fetch every page.
max_pages: Safety bound when ``all_pages`` is enabled.
raw: Return the decoded JSON payload without tabular extraction.
fields: Optional field list or comma-separated field string applied after extraction.
as_dataframe: Return a pandas ``DataFrame`` by default; set to ``False`` for Python rows.
**kwargs: Extra request parameters forwarded unchanged. Useful when the service adds parameters before the SDK is regenerated.

Returns:
A pandas ``DataFrame`` by default, Python rows when
``as_dataframe=False``, raw JSON when ``raw=True``。关键词、表达式或
``min_confidence`` 检索须同时提供 ``sector_name``。
```

<h4 id="api-sector-knowledge-search-options"><code>sector_knowledge_search_options</code></h4>

- 接口名称:板块知识检索选项
- HTTP:`GET`
- Path:`api/v3/market/data/sector-knowledge/search-options`
- 参数:`-`
- 来源文档:`板块知识检索选项.md`
- 原始接口:`sector_knowledge_search_options`

```text
板块知识检索选项.

Endpoint: ``api/v3/market/data/sector-knowledge/search-options``.
Method: ``GET``.
Documented endpoint: ``sector_knowledge_search_options``.

Args:
raw: Return the decoded JSON payload without tabular extraction.
fields: Optional field list or comma-separated field string applied after extraction.
as_dataframe: Return a pandas ``DataFrame`` by default; set to ``False`` for Python rows.
**kwargs: Extra request parameters forwarded unchanged. Useful when the service adds parameters before the SDK is regenerated.

Returns:
默认返回单行 pandas ``DataFrame``;``as_dataframe=False`` 时返回 ``data`` 对象(含
``fact``、``insight``、``sector_type_list``、``market_list``、``sort``),``raw=True``
时返回完整 JSON 信封。
```

<h4 id="api-sector-knowledge-sectors"><code>sector_knowledge_sectors</code></h4>

- 接口名称:板块描述列表
- HTTP:`GET`
- Path:`api/v3/market/data/sector-knowledge/sectors`
- 参数:`market`, `sector_type`, `name_keyword`
- 来源文档:`板块描述列表.md`
- 原始接口:`sector_knowledge_sectors`

```text
板块描述列表.

Endpoint: ``api/v3/market/data/sector-knowledge/sectors``.
Method: ``GET``.
Documented endpoint: ``sector_knowledge_sectors``.

Args:
market: 市场过滤:CN / US / HK / KR / JP / global (type: string; required: N).
sector_type: 板块类型过滤:industry / concept / region / index_style / macro_asset (type: string; required: N).
name_keyword: 板块标准名或别名关键词,最多返回 10 个候选,最长 100 字符 (type: string; required: N).
raw: Return the decoded JSON payload without tabular extraction.
fields: Optional field list or comma-separated field string applied after extraction.
as_dataframe: Return a pandas ``DataFrame`` by default; set to ``False`` for Python rows.
**kwargs: Extra request parameters forwarded unchanged. Useful when the service adds parameters before the SDK is regenerated.

Returns:
A pandas ``DataFrame`` by default, Python rows when
``as_dataframe=False``, raw JSON when ``raw=True``。不分页,返回当前查询匹配的完整板块列表。
```

### 港股数据

<h4 id="api-hk-candlesticks"><code>hk_candlesticks</code></h4>
Expand Down Expand Up @@ -5206,6 +5357,37 @@ Returns:
payloads when multi-page fetching is used with ``raw=True``.
```

<h4 id="api-futures-dominant-mapping"><code>futures_dominant_mapping</code></h4>

- 接口名称:期货主力合约映射
- HTTP:`GET`
- Path:`api/v1/market/data/futures/dominant-mapping`
- 参数:`trade_date`, `rule_version`
- 来源文档:`期货主力合约映射.md`
- 原始接口:`futures_dominant_mapping`

```text
期货主力合约映射.

Endpoint: ``api/v1/market/data/futures/dominant-mapping``.
Method: ``GET``.
Documented endpoint: ``futures_dominant_mapping``.

Args:
trade_date: 主力映射生效交易日,格式 ``YYYYMMDD``,例如 ``20261123`` (type: string; required: Y).
rule_version: 主力规则版本,支持 ``v1``、``v2``、``v3``、``v4``,区分大小写;省略或传空值时默认 ``v1``,传入不支持的版本返回空数组 (type: string; required: N).
raw: Return the decoded JSON payload without tabular extraction.
fields: Optional field list or comma-separated field string applied after extraction.
as_dataframe: Return a pandas ``DataFrame`` by default; set to ``False`` for Python rows.
**kwargs: Extra request parameters forwarded unchanged. Useful when the service adds parameters before the SDK is regenerated.

Returns:
A pandas ``DataFrame`` by default, Python rows when
``as_dataframe=False``, raw JSON when ``raw=True``。服务端返回
``data`` 数组(``trade_date`` / ``exchange`` / ``variety`` /
``dominant_symbol`` / ``rule_version``),不分页。
```

<h4 id="api-futures-kline"><code>futures_kline</code></h4>

- 接口名称:期货合约历史K线
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ build-backend = "hatchling.build"

[project]
name = "ftshare"
version = "1.0.13"
version = "1.0.14"
description = "Python SDK for FTShare market data APIs."
readme = "README.md"
requires-python = ">=3.9"
Expand Down
21 changes: 21 additions & 0 deletions src/ftshare/apis/futures.py
Original file line number Diff line number Diff line change
Expand Up @@ -1019,3 +1019,24 @@ def member_position_ranking(self, exchange: Any | None = None, instrument_id: An
params = {'exchange': exchange, 'instrument_id': instrument_id, 'trade_date': trade_date, 'direction': direction}
params.update(kwargs)
return self.get_paginated(ENDPOINTS['member_position_ranking'].path, page=page, page_size=page_size, limit=limit, all_pages=all_pages, max_pages=max_pages, raw=raw, fields=fields, as_dataframe=as_dataframe, **params)

def futures_dominant_mapping(self, trade_date: Any | None = None, rule_version: Any | None = None, *, raw: bool = False, fields: Sequence[str] | str | None = None, as_dataframe: bool = True, **kwargs: Any) -> Any:
"""查询指定交易日的期货主力合约映射,返回交易所、品种、主力合约与规则版本;不分页。

Args:
trade_date: 主力映射生效交易日,格式 ``YYYYMMDD``,例如 ``20261123`` (type: string; required: Y).
rule_version: 主力规则版本,支持 ``v1``、``v2``、``v3``、``v4``,区分大小写;省略或传空值时默认 ``v1``,传入不支持的版本返回空数组 (type: string; required: N).
raw: Return the decoded JSON payload without tabular extraction.
fields: Optional field list or comma-separated field string applied after extraction.
as_dataframe: Return a pandas ``DataFrame`` by default; set to ``False`` for Python rows.
**kwargs: Extra request parameters forwarded unchanged.

Returns:
A pandas ``DataFrame`` by default, Python rows when
``as_dataframe=False``, raw JSON when ``raw=True``。服务端返回
``data`` 数组(``trade_date`` / ``exchange`` / ``variety`` /
``dominant_symbol`` / ``rule_version``),不分页。
"""
params = {'trade_date': trade_date, 'rule_version': rule_version}
params.update(kwargs)
return self._call_endpoint('futures_dominant_mapping', raw=raw, fields=fields, as_dataframe=as_dataframe, **params)
Loading
Loading