Skip to content

Commit 254f3d2

Browse files
authored
Merge pull request #16 from FTShare-Lab/howe_dev
feat: 新增股票历史ST状态接口
2 parents 1762fb7 + 65df10a commit 254f3d2

6 files changed

Lines changed: 76 additions & 3 deletions

File tree

‎docs/API_REFERENCE.md‎

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

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

1111
## 专题分布
1212

1313
| ftshare-doc 专题 | SDK 方法数 | API mixin 模块 | Endpoint 模块 |
1414
|---|---:|---|---|
15-
| 股票数据 | 119 | `ftshare.apis.stock` | `ftshare.endpoints.stock` |
15+
| 股票数据 | 120 | `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` |
@@ -133,6 +133,7 @@
133133
| [`stock_realtime_minute_kline`](#api-stock-realtime-minute-kline) | 股票实时分钟K线 | `GET` | `api/v4/market/data/stock-realtime-minute-kline` | `symbols` | `股票实时分钟K线.md` |
134134
| [`stock_share`](#api-stock-share) | 股本 | `GET` | `api/v2/market/data/share/get-stock-share` | `stock_code`, `date` | `股本.md` |
135135
| [`stock_share_chg`](#api-stock-share-chg) | 股东增减持 | `GET` | `api/v1/market/data/holder/stock-share-chg` | `stock_code`, `is_last`, `page`, `page_size` | `股东增减持.md` |
136+
| [`stock_st_history`](#api-stock-st-history) | 股票历史ST状态 | `GET` | `api/v1/market/data/stock-st-history` | `symbol`, `st_type` | `股票历史ST状态.md` |
136137
| [`stock_unlock`](#api-stock-unlock) | 限售解禁 | `GET` | `api/v1/market/data/unlock/stock_unlock` | `stock_code`, `start_date`, `end_date`, `page`, `page_size` | `限售解禁.md` |
137138
| [`supply_chain_company_supply_chain_companies`](#api-supply-chain-company-supply-chain-companies) | 供应链公司候选 | `GET` | `api/v3/market/data/supply-chain/company-supply-chain-companies` | `trade_code`, `direction`, `page`, `page_size` | `供应链公司候选.md` |
138139
| [`supply_chain_subindustry_subsubindustries`](#api-supply-chain-subindustry-subsubindustries) | 供应链子行业层级展开 | `GET` | `api/v3/market/data/supply-chain/subindustry-subsubindustries` | `industry_name` | `供应链子行业层级展开.md` |
@@ -2823,6 +2824,31 @@ Returns:
28232824
payloads when multi-page fetching is used with ``raw=True``.
28242825
```
28252826

2827+
<h4 id="api-stock-st-history"><code>stock_st_history</code></h4>
2828+
2829+
- 接口名称:股票历史ST状态
2830+
- HTTP:`GET`
2831+
- Path:`api/v1/market/data/stock-st-history`
2832+
- 参数:`symbol`, `st_type`
2833+
- 来源文档:`股票历史ST状态.md`
2834+
- 原始接口:`stock_st_history`
2835+
2836+
```text
2837+
股票历史ST状态.
2838+
2839+
Endpoint: ``api/v1/market/data/stock-st-history``.
2840+
Method: ``GET``.
2841+
Documented endpoint: ``stock_st_history``.
2842+
2843+
Args:
2844+
symbol: 股票代码(带 .SH/.SZ 后缀),逗号分隔支持批量,去重后最多 50 只 (type: string; required: Y).
2845+
st_type: 阶段类型过滤,取值 ST / *ST / PT / 退市整理期 (type: string; required: N).
2846+
raw: Return the decoded JSON payload without tabular extraction.
2847+
fields: Optional field list or comma-separated field string applied after extraction.
2848+
as_dataframe: Return a pandas ``DataFrame`` by default; set to ``False`` for Python rows.
2849+
**kwargs: Extra request parameters forwarded unchanged. Useful when the service adds parameters before the SDK is regenerated.
2850+
```
2851+
28262852
<h4 id="api-stock-unlock"><code>stock_unlock</code></h4>
28272853

28282854
- 接口名称:限售解禁

‎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.5"
7+
version = "1.0.6"
88
description = "Python SDK for FTShare market data APIs."
99
readme = "README.md"
1010
requires-python = ">=3.9"

‎src/ftshare/apis/stock.py‎

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4192,3 +4192,23 @@ def stock_minutes_batch(self, symbols: Any | None = None, interval_value: Any |
41924192
params = {'symbols': symbols, 'interval_value': interval_value, 'adjust_kind': adjust_kind, 'since_ts_millis': since_ts_millis, 'until_ts_millis': until_ts_millis, 'limit': limit}
41934193
params.update(kwargs)
41944194
return self._call_endpoint('stock_minutes_batch', raw=raw, fields=fields, as_dataframe=as_dataframe, **params)
4195+
4196+
4197+
def stock_st_history(self, symbol: Any | None = None, st_type: Any | None = None, *, raw: bool = False, fields: Sequence[str] | str | None = None, as_dataframe: bool = True, **kwargs: Any) -> Any:
4198+
"""股票历史ST状态.
4199+
4200+
Endpoint: ``api/v1/market/data/stock-st-history``.
4201+
Method: ``GET``.
4202+
Documented endpoint: ``stock_st_history``.
4203+
4204+
Args:
4205+
symbol: 股票代码(带 .SH/.SZ 后缀),逗号分隔支持批量,去重后最多 50 只 (type: string; required: Y).
4206+
st_type: 阶段类型过滤,取值 ST / *ST / PT / 退市整理期 (type: string; required: N).
4207+
raw: Return the decoded JSON payload without tabular extraction.
4208+
fields: Optional field list or comma-separated field string applied after extraction.
4209+
as_dataframe: Return a pandas ``DataFrame`` by default; set to ``False`` for Python rows.
4210+
**kwargs: Extra request parameters forwarded unchanged. Useful when the service adds parameters before the SDK is regenerated.
4211+
"""
4212+
params = {'symbol': symbol, 'st_type': st_type}
4213+
params.update(kwargs)
4214+
return self._call_endpoint('stock_st_history', raw=raw, fields=fields, as_dataframe=as_dataframe, **params)

‎src/ftshare/endpoints/stock.py‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -909,4 +909,12 @@
909909
'params': ('symbol', 'since_date', 'until_date', 'page', 'page_size'),
910910
},
911911

912+
'stock_st_history': {
913+
'path': 'api/v1/market/data/stock-st-history',
914+
'title': '股票历史ST状态',
915+
'doc_file': '股票历史ST状态.md',
916+
'original_api': 'stock_st_history',
917+
'params': ('symbol', 'st_type'),
918+
},
919+
912920
})

‎tests/endpoint_cases.py‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,7 @@
117117
"start_date": "20260701",
118118
"start_week": "202628",
119119
"start_time": "09:30:00",
120+
"st_type": "*ST",
120121
"stat_date": "20260717",
121122
"stati_perd": "日",
122123
"stock_code": "000001.SZ",

‎tests/test_client.py‎

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,24 @@ def test_new_endpoints_forward_documented_parameters():
8383
assert session.calls[4]["params"] == {"n": 5}
8484

8585

86+
def test_stock_st_history_forwards_documented_parameters():
87+
session = FakeSession(
88+
[
89+
FakeResponse(payload={"code": 200, "message": "success", "data": [{"symbol": "600735.SH", "st_type": "ST"}]}),
90+
FakeResponse(payload={"code": 200, "message": "success", "data": []}),
91+
]
92+
)
93+
client = FtshareClient(session=session)
94+
95+
rows = client.stock_st_history(symbol="600735.SH,000004.SZ", as_dataframe=False)
96+
client.stock_st_history(symbol="000004.SZ", st_type="退市整理期", as_dataframe=False)
97+
98+
assert session.calls[0]["url"] == "https://market.ft.tech/gateway/api/v1/market/data/stock-st-history"
99+
assert session.calls[0]["params"] == {"symbol": "600735.SH,000004.SZ"}
100+
assert rows == [{"symbol": "600735.SH", "st_type": "ST"}]
101+
assert session.calls[1]["params"] == {"symbol": "000004.SZ", "st_type": "退市整理期"}
102+
103+
86104
def test_stock_ggcg_em_rejects_page_size_above_200():
87105
client = FtshareClient(session=FakeSession([]))
88106

0 commit comments

Comments
 (0)