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
19 changes: 15 additions & 4 deletions docs/API_REFERENCE.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@

| 指标 | 数量 |
|---|---:|
| SDK 方法总数 | 228 |
| SDK 方法总数 | 229 |

## 专题分布

| ftshare-doc 专题 | SDK 方法数 | API mixin 模块 | Endpoint 模块 |
|---|---:|---|---|
| 股票数据 | 120 | `ftshare.apis.stock` | `ftshare.endpoints.stock` |
| 股票数据 | 121 | `ftshare.apis.stock` | `ftshare.endpoints.stock` |
| 港股数据 | 3 | `ftshare.apis.hk` | `ftshare.endpoints.hk` |
| 美股数据 | 2 | `ftshare.apis.us` | `ftshare.endpoints.us` |
| 指数专题 | 15 | `ftshare.apis.index` | `ftshare.endpoints.index` |
Expand Down Expand Up @@ -78,6 +78,7 @@
| [`limit_up_public_report`](#api-limit-up-public-report) | 涨停对外归因报告 | `GET` | `api/v3/market/data/limit-up-reports/public-report` | `date`, `security_code` | `涨停对外归因报告.md` |
| [`margin_trading_details`](#api-margin-trading-details) | 融资融券明细 | `GET` | `api/v1/market/data/margin-trading-details` | `date`, `start_date`, `end_date`, `stock`, `page`, `page_size` | `融资融券明细.md` |
| [`namechange`](#api-namechange) | 股票曾用名 | `GET` | `api/v1/market/data/namechange` | `trade_code`, `start_date`, `end_date` | `股票曾用名.md` |
| [`news_reaction_snapshot`](#api-news-reaction-snapshot) | 消息量价共振 | `GET` | `api/v3/market/data/news-reaction-snapshot` | `symbol`, `start_date`, `end_date`, `lookback_hours`, `page`, `page_size` | `消息量价共振.md` |
| [`nth_trade_date`](#api-nth-trade-date) | 第N个交易日 | `GET` | `api/v1/market/data/time/get-nth-trade-date` | `n` | `第N个交易日.md` |
| [`northbound`](#api-northbound) | 北向资金交易 | `GET` | `api/v1/market/data/northbound` | `date` | `北向资金交易.md` |
| [`performance_forecasts_paginated`](#api-performance-forecasts-paginated) | 业绩预告 | `GET` | `api/v1/market/data/finance/stock-performance-forecast` | `stock_code`, `year`, `report_type`, `page`, `page_size` | `业绩预告.md` |
Expand Down Expand Up @@ -4021,7 +4022,7 @@ Documented endpoint: ``get_fund_classification``.

Args:
fund_code: 基金代码 (type: string; required: Y).
classify_std: 分类标准:证监会基金分类/晨星基金分类/银河证券分类2017版/Gangtise基金分类/Gangtise基金概念分类,缺省全部 (type: string; required: N).
classify_std: 分类标准:证监会基金分类/晨星基金分类/银河证券分类2017版,缺省全部 (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.
Expand Down Expand Up @@ -4533,7 +4534,7 @@ Documented endpoint: ``get_china_futures_base_data_handler``.

Args:
trade_date: 交易日 YYYYMMDD;不传则使用前一交易日(CST) (type: int; required: N).
symbol: WIND 合约全码如 A2605.DCE;大小写不敏感;不传或空表示该日全部 (type: string; required: N).
symbol: 合约全码如 A2605.DCE;大小写不敏感;不传或空表示该日全部 (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.
Expand Down Expand Up @@ -5871,3 +5872,13 @@ Returns:
- Path:`api/v2/market/data/stock-dividends-effective`
- 参数:`symbol, since_date, until_date, page, page_size`
- 来源文档:`股票有效分红记录.md`

<h4 id="api-news-reaction-snapshot"><code>news_reaction_snapshot</code></h4>

- 接口名称:消息量价共振
- HTTP:`GET`
- Path:`api/v3/market/data/news-reaction-snapshot`
- 参数:`symbol`, `start_date`, `end_date`, `lookback_hours`, `page`, `page_size`
- 来源文档:`消息量价共振.md`
- 原始接口:`news_reaction_snapshot`
- 说明:返回 `code/message/data` 分页信封,快照记录位于 `data.records`;`symbol`、`start_date`、`end_date` 必填,`lookback_hours` 仅 `24` 或 `48`,日期跨度不超过 31 天,`page_size` 上限 200。
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.6"
version = "1.0.7"
description = "Python SDK for FTShare market data APIs."
readme = "README.md"
requires-python = ">=3.9"
Expand Down
2 changes: 1 addition & 1 deletion src/ftshare/apis/fund.py
Original file line number Diff line number Diff line change
Expand Up @@ -469,7 +469,7 @@ def fund_classification(

Args:
fund_code: 基金代码 (type: string; required: Y).
classify_std: 分类标准:证监会基金分类/晨星基金分类/银河证券分类2017版/Gangtise基金分类/Gangtise基金概念分类,缺省全部 (type: string; required: N).
classify_std: 分类标准:证监会基金分类/晨星基金分类/银河证券分类2017版,缺省全部 (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.
Expand Down
2 changes: 1 addition & 1 deletion src/ftshare/apis/futures.py
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ def china_futures_base_data(

Args:
trade_date: 交易日 YYYYMMDD;不传则使用前一交易日(CST) (type: int; required: N).
symbol: WIND 合约全码如 A2605.DCE;大小写不敏感;不传或空表示该日全部 (type: string; required: N).
symbol: 合约全码如 A2605.DCE;大小写不敏感;不传或空表示该日全部 (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.
Expand Down
27 changes: 27 additions & 0 deletions src/ftshare/apis/stock.py
Original file line number Diff line number Diff line change
Expand Up @@ -4212,3 +4212,30 @@ def stock_st_history(self, symbol: Any | None = None, st_type: Any | None = None
params = {'symbol': symbol, 'st_type': st_type}
params.update(kwargs)
return self._call_endpoint('stock_st_history', raw=raw, fields=fields, as_dataframe=as_dataframe, **params)

def news_reaction_snapshot(self, symbol: Any | None = None, start_date: Any | None = None, end_date: Any | None = None, lookback_hours: Any | None = None, page: int | None = None, page_size: int | None = None, limit: int | None = None, all_pages: bool = False, max_pages: int | None = None, *, raw: bool = False, fields: Sequence[str] | str | None = None, as_dataframe: bool = True, **kwargs: Any) -> Any:
"""消息量价共振.

Endpoint: ``api/v3/market/data/news-reaction-snapshot``.
Method: ``GET``.
Documented endpoint: ``news_reaction_snapshot``.

Args:
symbol: 股票代码,必须带交易所后缀,如 000333.SZ (type: string; required: Y).
start_date: 起始交易日(含),YYYYMMDD 或 YYYY-MM-DD (type: string; required: Y).
end_date: 截止交易日(含),与起始日期相隔不超过 31 天 (type: string; required: Y).
lookback_hours: 新闻回看窗口,仅 24 或 48;不传则两套窗口都返回 (type: number; 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.
"""
params = {'symbol': symbol, 'start_date': start_date, 'end_date': end_date, 'lookback_hours': lookback_hours}
params.update(kwargs)
path = ENDPOINTS['news_reaction_snapshot'].path
return self.get_paginated(path, page=page, page_size=page_size, limit=limit, all_pages=all_pages, max_pages=max_pages, max_page_size=200, raw=raw, fields=fields, as_dataframe=as_dataframe, **params)
9 changes: 9 additions & 0 deletions src/ftshare/endpoints/stock.py
Original file line number Diff line number Diff line change
Expand Up @@ -917,4 +917,13 @@
'params': ('symbol', 'st_type'),
},

'news_reaction_snapshot': {
'path': 'api/v3/market/data/news-reaction-snapshot',
'title': '消息量价共振',
'doc_file': '消息量价共振.md',
'original_api': 'news_reaction_snapshot',
'params': ('symbol', 'start_date', 'end_date', 'lookback_hours', 'page', 'page_size'),
'max_page_size': 200,
},

})
1 change: 1 addition & 0 deletions tests/endpoint_cases.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@
"limit": 5,
"limit_type": "up",
"listing_date_since": "20260101",
"lookback_hours": 48,
"market": "cn",
"market_code": "000300",
"market_id": 1,
Expand Down
30 changes: 30 additions & 0 deletions tests/test_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -467,6 +467,36 @@ def test_new_paginated_endpoints_forward_parameters():
assert session.calls[3]["params"] == {"start_date": "20260805", "end_date": "20260805", "board_name": "证券", "page": 1, "page_size": 1000}


def test_news_reaction_snapshot_forwards_filters_and_extracts_records():
records = [{"trade_date": "20260819", "symbol": "600519.SH", "lookback_hours": 48}]
session = FakeSession([FakeResponse(payload=paginated_records(records))])
client = FtshareClient(session=session)

frame = client.news_reaction_snapshot(
symbol="600519.SH",
start_date="20260818",
end_date="20260828",
lookback_hours=48,
page=1,
page_size=5,
)

assert session.calls[0]["url"] == "https://market.ft.tech/gateway/" + ENDPOINTS["news_reaction_snapshot"].path
assert "json" not in session.calls[0]
assert session.calls[0]["params"] == {
"symbol": "600519.SH",
"start_date": "20260818",
"end_date": "20260828",
"lookback_hours": 48,
"page": 1,
"page_size": 5,
}
assert list(frame.columns) == ["trade_date", "symbol", "lookback_hours"]

with pytest.raises(ValueError, match="page_size must be between 1 and 200"):
client.news_reaction_snapshot(symbol="600519.SH", start_date="20260818", end_date="20260828", page_size=201)


def test_eastmoney_sector_flow_forwards_board_parameters():
session = FakeSession([FakeResponse(payload=paginated_records([]))])
client = FtshareClient(session=session)
Expand Down
Loading