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

| 指标 | 数量 |
|---|---:|
| SDK 方法总数 | 201 |
| SDK 方法总数 | 200 |

## 专题分布

接口分组、`src/ftshare/apis/` 方法模块和 `src/ftshare/endpoints/` 注册表模块均按 `ftshare-doc/api-doc` 顶层专题对齐。

| ftshare-doc 专题 | SDK 方法数 | API mixin 模块 | Endpoint 模块 |
|---|---:|---|---|
| 股票数据 | 96 | `ftshare.apis.stock` | `ftshare.endpoints.stock` |
| 股票数据 | 95 | `ftshare.apis.stock` | `ftshare.endpoints.stock` |
| 港股数据 | 14 | `ftshare.apis.hk` | `ftshare.endpoints.hk` |
| 美股数据 | 9 | `ftshare.apis.us` | `ftshare.endpoints.us` |
| 指数专题 | 10 | `ftshare.apis.index` | `ftshare.endpoints.index` |
Expand Down Expand Up @@ -132,7 +132,6 @@ df = market.baidu_financial_calendar(
| [`stock_share`](#api-stock-share) | 股本 | `GET` | `api/v1/market/data/share/get-stock-share` | `stock_code`, `date` | `股本.md` |
| [`stock_share_chg`](#api-stock-share-chg) | 股东增减持 | `GET` | `api/v1/market/data/holder/stock-share-chg` | `stock_code`, `is_last`, `page`, `page_size` | `股东增减持.md` |
| [`stock_signal_latest_snapshot`](#api-stock-signal-latest-snapshot) | 信号最新快照 | `GET` | `api/v1/market/data/stock-signal-latest-snapshot` | `signal_type`, `page`, `page_size` | `信号最新快照.md` |
| [`stock_trade`](#api-stock-trade) | 标的逐笔成交 | `GET` | `api/v1/market/data/daec/history/trades` | `symbol` | `标的逐笔成交.md` |
| [`stock_unlock`](#api-stock-unlock) | 限售解禁 | `GET` | `api/v1/market/data/unlock/stock-unlock` | `stock_code`, `page`, `page_size` | `限售解禁.md` |
| [`stock_unlock_by_date`](#api-stock-unlock-by-date) | 限售解禁按日期 | `GET` | `api/v1/market/data/unlock/stock-unlock-by-date` | `start_date`, `end_date`, `page`, `page_size` | `限售解禁按日期.md` |
| [`suspension_list`](#api-suspension-list) | 停牌列表 | `GET` | `api/v1/market/data/suspension-list` | `trade_date`, `page`, `page_size` | `停牌列表.md` |
Expand Down Expand Up @@ -3074,35 +3073,6 @@ Returns:
payloads when multi-page fetching is used with ``raw=True``.
```

<h4 id="api-stock-trade"><code>stock_trade</code></h4>

- 接口名称:标的逐笔成交
- HTTP:`GET`
- Path:`api/v1/market/data/daec/history/trades`
- 参数:`symbol`
- 来源文档:`标的逐笔成交.md`
- 原始接口:`stock_trade`

```text
股票分时成交.

Endpoint: ``api/v1/market/data/daec/history/trades``.
Method: ``GET``.
Documented endpoint: ``stock_trade``.

Args:
symbol: 标的代码 (type: SymbolKey; required: Y).
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``, or raw page
payloads when multi-page fetching is used with ``raw=True``.
```

<h4 id="api-stock-unlock"><code>stock_unlock</code></h4>

- 接口名称:限售解禁
Expand Down
37 changes: 0 additions & 37 deletions src/ftshare/apis/stock.py
Original file line number Diff line number Diff line change
Expand Up @@ -4540,43 +4540,6 @@ def stock_signal_latest_snapshot(
**request_params,
)

def stock_trade(
self,
symbol: Any | None = None,
*,
raw: bool = False,
fields: Sequence[str] | str | None = None,
as_dataframe: bool = True,
**kwargs: Any,
) -> Any:
"""股票分时成交.

Endpoint: ``api/v1/market/data/daec/history/trades``.
Method: ``GET``.
Documented endpoint: ``stock_trade``.

Args:
symbol: 标的代码 (type: SymbolKey; required: Y).
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``, or raw page
payloads when multi-page fetching is used with ``raw=True``.
"""
request_params = {'symbol': symbol}
request_params.update(kwargs)
return self._call_endpoint(
'stock_trade',
raw=raw,
fields=fields,
as_dataframe=as_dataframe,
**request_params,
)

def stock_unlock(
self,
stock_code: Any | None = None,
Expand Down
7 changes: 0 additions & 7 deletions src/ftshare/endpoints/stock.py
Original file line number Diff line number Diff line change
Expand Up @@ -598,13 +598,6 @@
'original_api': 'stock_signal_latest_snapshot',
'params': ('signal_type', 'page', 'page_size'),
},
'stock_trade': {
'path': 'api/v1/market/data/daec/history/trades',
'title': '标的逐笔成交',
'doc_file': '标的逐笔成交.md',
'original_api': 'stock_trade',
'params': ('symbol',),
},
'stock_unlock': {
'path': 'api/v1/market/data/unlock/stock-unlock',
'title': '限售解禁',
Expand Down
8 changes: 6 additions & 2 deletions tests/test_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ def test_endpoint_methods_map_to_expected_paths(method_name, kwargs):

def test_all_documented_endpoints_are_available_as_client_methods():
client = FtshareClient(session=FakeSession([]))
assert len(ENDPOINTS) >= 180
assert len(ENDPOINTS) >= 200

missing = [
name
Expand All @@ -186,6 +186,11 @@ def test_all_documented_endpoints_are_available_as_client_methods():
assert missing == []


def test_removed_stock_trade_is_not_exposed():
assert "stock_trade" not in ENDPOINTS
assert not hasattr(FtshareClient, "stock_trade")


def test_generated_method_docstring_includes_parameter_metadata():
doc = FtshareClient.baidu_financial_calendar.__doc__ or ""

Expand Down Expand Up @@ -270,7 +275,6 @@ def test_missing_path_parameter_raises_value_error():

def test_confirmed_todo_endpoints_map_to_public_server_paths():
cases = [
("stock_trade", {"symbol": "600000.XSHG"}, "api/v1/market/data/daec/history/trades", {"symbol": "600000.XSHG"}),
(
"stock_prev_close",
{"symbol": "600000.XSHG", "since": "20240501", "until": "20240531"},
Expand Down
2 changes: 1 addition & 1 deletion tests/test_endpoint_contracts.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ def _response_payload(name: str) -> Any:


def test_contract_cases_cover_all_public_sdk_methods():
assert len(PUBLIC_CONTRACTS) == 197
assert len(PUBLIC_CONTRACTS) == 196
assert PUBLIC_CONTRACTS | NON_PUBLISHED_ENDPOINTS == set(ENDPOINTS)
assert not (PUBLIC_CONTRACTS & NON_PUBLISHED_ENDPOINTS)

Expand Down
Loading