Skip to content

Commit d0aaab2

Browse files
authored
Merge pull request #17 from FTShare-Lab/howe_dev
feat:新增消息量价共振接口
2 parents 29cfded + f54b8a6 commit d0aaab2

8 files changed

Lines changed: 85 additions & 7 deletions

File tree

‎docs/API_REFERENCE.md‎

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,13 @@
66

77
| 指标 | 数量 |
88
|---|---:|
9-
| SDK 方法总数 | 228 |
9+
| SDK 方法总数 | 229 |
1010

1111
## 专题分布
1212

1313
| ftshare-doc 专题 | SDK 方法数 | API mixin 模块 | Endpoint 模块 |
1414
|---|---:|---|---|
15-
| 股票数据 | 120 | `ftshare.apis.stock` | `ftshare.endpoints.stock` |
15+
| 股票数据 | 121 | `ftshare.apis.stock` | `ftshare.endpoints.stock` |
1616
| 港股数据 | 3 | `ftshare.apis.hk` | `ftshare.endpoints.hk` |
1717
| 美股数据 | 2 | `ftshare.apis.us` | `ftshare.endpoints.us` |
1818
| 指数专题 | 15 | `ftshare.apis.index` | `ftshare.endpoints.index` |
@@ -78,6 +78,7 @@
7878
| [`limit_up_public_report`](#api-limit-up-public-report) | 涨停对外归因报告 | `GET` | `api/v3/market/data/limit-up-reports/public-report` | `date`, `security_code` | `涨停对外归因报告.md` |
7979
| [`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` |
8080
| [`namechange`](#api-namechange) | 股票曾用名 | `GET` | `api/v1/market/data/namechange` | `trade_code`, `start_date`, `end_date` | `股票曾用名.md` |
81+
| [`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` |
8182
| [`nth_trade_date`](#api-nth-trade-date) | 第N个交易日 | `GET` | `api/v1/market/data/time/get-nth-trade-date` | `n` | `第N个交易日.md` |
8283
| [`northbound`](#api-northbound) | 北向资金交易 | `GET` | `api/v1/market/data/northbound` | `date` | `北向资金交易.md` |
8384
| [`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` |
@@ -4021,7 +4022,7 @@ Documented endpoint: ``get_fund_classification``.
40214022
40224023
Args:
40234024
fund_code: 基金代码 (type: string; required: Y).
4024-
classify_std: 分类标准:证监会基金分类/晨星基金分类/银河证券分类2017版/Gangtise基金分类/Gangtise基金概念分类,缺省全部 (type: string; required: N).
4025+
classify_std: 分类标准:证监会基金分类/晨星基金分类/银河证券分类2017版,缺省全部 (type: string; required: N).
40254026
raw: Return the decoded JSON payload without tabular extraction.
40264027
fields: Optional field list or comma-separated field string applied after extraction.
40274028
as_dataframe: Return a pandas ``DataFrame`` by default; set to ``False`` for Python rows.
@@ -4533,7 +4534,7 @@ Documented endpoint: ``get_china_futures_base_data_handler``.
45334534
45344535
Args:
45354536
trade_date: 交易日 YYYYMMDD;不传则使用前一交易日(CST) (type: int; required: N).
4536-
symbol: WIND 合约全码如 A2605.DCE;大小写不敏感;不传或空表示该日全部 (type: string; required: N).
4537+
symbol: 合约全码如 A2605.DCE;大小写不敏感;不传或空表示该日全部 (type: string; required: N).
45374538
raw: Return the decoded JSON payload without tabular extraction.
45384539
fields: Optional field list or comma-separated field string applied after extraction.
45394540
as_dataframe: Return a pandas ``DataFrame`` by default; set to ``False`` for Python rows.
@@ -5871,3 +5872,13 @@ Returns:
58715872
- Path:`api/v2/market/data/stock-dividends-effective`
58725873
- 参数:`symbol, since_date, until_date, page, page_size`
58735874
- 来源文档:`股票有效分红记录.md`
5875+
5876+
<h4 id="api-news-reaction-snapshot"><code>news_reaction_snapshot</code></h4>
5877+
5878+
- 接口名称:消息量价共振
5879+
- HTTP:`GET`
5880+
- Path:`api/v3/market/data/news-reaction-snapshot`
5881+
- 参数:`symbol`, `start_date`, `end_date`, `lookback_hours`, `page`, `page_size`
5882+
- 来源文档:`消息量价共振.md`
5883+
- 原始接口:`news_reaction_snapshot`
5884+
- 说明:返回 `code/message/data` 分页信封,快照记录位于 `data.records`;`symbol`、`start_date`、`end_date` 必填,`lookback_hours` 仅 `24` 或 `48`,日期跨度不超过 31 天,`page_size` 上限 200。

‎pyproject.toml‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ build-backend = "hatchling.build"
44

55
[project]
66
name = "ftshare"
7-
version = "1.0.6"
7+
version = "1.0.7"
88
description = "Python SDK for FTShare market data APIs."
99
readme = "README.md"
1010
requires-python = ">=3.9"

‎src/ftshare/apis/fund.py‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -469,7 +469,7 @@ def fund_classification(
469469
470470
Args:
471471
fund_code: 基金代码 (type: string; required: Y).
472-
classify_std: 分类标准:证监会基金分类/晨星基金分类/银河证券分类2017版/Gangtise基金分类/Gangtise基金概念分类,缺省全部 (type: string; required: N).
472+
classify_std: 分类标准:证监会基金分类/晨星基金分类/银河证券分类2017版,缺省全部 (type: string; required: N).
473473
raw: Return the decoded JSON payload without tabular extraction.
474474
fields: Optional field list or comma-separated field string applied after extraction.
475475
as_dataframe: Return a pandas ``DataFrame`` by default; set to ``False`` for Python rows.

‎src/ftshare/apis/futures.py‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,7 @@ def china_futures_base_data(
172172
173173
Args:
174174
trade_date: 交易日 YYYYMMDD;不传则使用前一交易日(CST) (type: int; required: N).
175-
symbol: WIND 合约全码如 A2605.DCE;大小写不敏感;不传或空表示该日全部 (type: string; required: N).
175+
symbol: 合约全码如 A2605.DCE;大小写不敏感;不传或空表示该日全部 (type: string; required: N).
176176
raw: Return the decoded JSON payload without tabular extraction.
177177
fields: Optional field list or comma-separated field string applied after extraction.
178178
as_dataframe: Return a pandas ``DataFrame`` by default; set to ``False`` for Python rows.

‎src/ftshare/apis/stock.py‎

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4212,3 +4212,30 @@ def stock_st_history(self, symbol: Any | None = None, st_type: Any | None = None
42124212
params = {'symbol': symbol, 'st_type': st_type}
42134213
params.update(kwargs)
42144214
return self._call_endpoint('stock_st_history', raw=raw, fields=fields, as_dataframe=as_dataframe, **params)
4215+
4216+
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:
4217+
"""消息量价共振.
4218+
4219+
Endpoint: ``api/v3/market/data/news-reaction-snapshot``.
4220+
Method: ``GET``.
4221+
Documented endpoint: ``news_reaction_snapshot``.
4222+
4223+
Args:
4224+
symbol: 股票代码,必须带交易所后缀,如 000333.SZ (type: string; required: Y).
4225+
start_date: 起始交易日(含),YYYYMMDD 或 YYYY-MM-DD (type: string; required: Y).
4226+
end_date: 截止交易日(含),与起始日期相隔不超过 31 天 (type: string; required: Y).
4227+
lookback_hours: 新闻回看窗口,仅 24 或 48;不传则两套窗口都返回 (type: number; required: N).
4228+
page: 页码,从 1 开始,默认 1,最大 1000.
4229+
page_size: 每页条数,默认 50,最大 200.
4230+
limit: Maximum number of rows to return when aggregating pages.
4231+
all_pages: Fetch every page.
4232+
max_pages: Safety bound when ``all_pages`` is enabled.
4233+
raw: Return the decoded JSON payload without tabular extraction.
4234+
fields: Optional field list or comma-separated field string applied after extraction.
4235+
as_dataframe: Return a pandas ``DataFrame`` by default; set to ``False`` for Python rows.
4236+
**kwargs: Extra request parameters forwarded unchanged. Useful when the service adds parameters before the SDK is regenerated.
4237+
"""
4238+
params = {'symbol': symbol, 'start_date': start_date, 'end_date': end_date, 'lookback_hours': lookback_hours}
4239+
params.update(kwargs)
4240+
path = ENDPOINTS['news_reaction_snapshot'].path
4241+
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)

‎src/ftshare/endpoints/stock.py‎

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -917,4 +917,13 @@
917917
'params': ('symbol', 'st_type'),
918918
},
919919

920+
'news_reaction_snapshot': {
921+
'path': 'api/v3/market/data/news-reaction-snapshot',
922+
'title': '消息量价共振',
923+
'doc_file': '消息量价共振.md',
924+
'original_api': 'news_reaction_snapshot',
925+
'params': ('symbol', 'start_date', 'end_date', 'lookback_hours', 'page', 'page_size'),
926+
'max_page_size': 200,
927+
},
928+
920929
})

‎tests/endpoint_cases.py‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@
7575
"limit": 5,
7676
"limit_type": "up",
7777
"listing_date_since": "20260101",
78+
"lookback_hours": 48,
7879
"market": "cn",
7980
"market_code": "000300",
8081
"market_id": 1,

‎tests/test_client.py‎

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -467,6 +467,36 @@ def test_new_paginated_endpoints_forward_parameters():
467467
assert session.calls[3]["params"] == {"start_date": "20260805", "end_date": "20260805", "board_name": "证券", "page": 1, "page_size": 1000}
468468

469469

470+
def test_news_reaction_snapshot_forwards_filters_and_extracts_records():
471+
records = [{"trade_date": "20260819", "symbol": "600519.SH", "lookback_hours": 48}]
472+
session = FakeSession([FakeResponse(payload=paginated_records(records))])
473+
client = FtshareClient(session=session)
474+
475+
frame = client.news_reaction_snapshot(
476+
symbol="600519.SH",
477+
start_date="20260818",
478+
end_date="20260828",
479+
lookback_hours=48,
480+
page=1,
481+
page_size=5,
482+
)
483+
484+
assert session.calls[0]["url"] == "https://market.ft.tech/gateway/" + ENDPOINTS["news_reaction_snapshot"].path
485+
assert "json" not in session.calls[0]
486+
assert session.calls[0]["params"] == {
487+
"symbol": "600519.SH",
488+
"start_date": "20260818",
489+
"end_date": "20260828",
490+
"lookback_hours": 48,
491+
"page": 1,
492+
"page_size": 5,
493+
}
494+
assert list(frame.columns) == ["trade_date", "symbol", "lookback_hours"]
495+
496+
with pytest.raises(ValueError, match="page_size must be between 1 and 200"):
497+
client.news_reaction_snapshot(symbol="600519.SH", start_date="20260818", end_date="20260828", page_size=201)
498+
499+
470500
def test_eastmoney_sector_flow_forwards_board_parameters():
471501
session = FakeSession([FakeResponse(payload=paginated_records([]))])
472502
client = FtshareClient(session=session)

0 commit comments

Comments
 (0)