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
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### 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.
- New limit-up and sentiment endpoints: `limit_ladder_daily` (连板天梯明细), `limit_ladder_summary` (连板天梯汇总) and `market_sentiment` (市场情绪) for daily limit-up tiers, board distribution, promotion/break rates and previous-day limit-up performance.
- New Hong Kong announcement endpoints: `hk_market_announcements` (港股公告列表) and `hk_periodic_announcements` (港股定期公告列表) with category, date and pagination filters.
- New parsed research report endpoints: `parsed_stock_reports` / `parsed_industry_reports` list, `_preview` for content preview and `_download` for ZIP packages with `ETag` conditional download.

### 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.
Expand Down
391 changes: 387 additions & 4 deletions docs/API_REFERENCE.md

Large diffs are not rendered by default.

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.14"
version = "1.0.15"
description = "Python SDK for FTShare market data APIs."
readme = "README.md"
requires-python = ">=3.9"
Expand Down
138 changes: 138 additions & 0 deletions src/ftshare/apis/hk.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,144 @@ def hk_candlesticks(
params.update(kwargs)
return self._call_endpoint('hk_candlesticks', raw=raw, fields=fields, as_dataframe=as_dataframe, **params)

def hk_market_announcements(
self,
keyword: Any | None = None,
category: Any | None = None,
stock_code: Any | None = None,
start_date: Any | None = None,
end_date: 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/v2/market/data/announcements/hk-market-announcements``.
Method: ``GET``.
Documented endpoint: ``hk_market_announcements``.

Args:
keyword: 标题关键词,只匹配简体标题,最多 60 字符 (type: string; required: N).
category: 港交所分类:5 位码、完整简体名或短别名,逗号多选,最多 20 个 (type: string; required: N).
stock_code: 港股主代码,支持裸码、``.HK``、``.XHKG``、``HK:`` 前缀 (type: string; required: N).
start_date: 公告日期起点 YYYYMMDD;只传 start_date 时为单日查询 (type: string; required: N).
end_date: 公告日期终点 YYYYMMDD;只给 end_date 返回 400 (type: string; required: N).
page: Page number, starting from 1. If omitted, the server default is used unless ``limit`` or ``all_pages`` is set.
page_size: Rows per page. The SDK validates this against the endpoint-specific maximum.
limit: Maximum number of rows to return. The SDK may fetch multiple pages to satisfy this limit.
all_pages: Fetch and combine pages until the server reports the last page.
max_pages: Optional safety cap for ``all_pages``.
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``。不带
``stock_code`` 时未传日期默认近 1 年、显式日期跨度最长 1 年;带
``stock_code`` 时不限跨度。
"""
request_params = {
'keyword': keyword,
'category': category,
'stock_code': stock_code,
'start_date': start_date,
'end_date': end_date,
}
request_params.update(kwargs)
return self.get_paginated(
ENDPOINTS['hk_market_announcements'].path,
page=page,
page_size=page_size,
limit=limit,
all_pages=all_pages,
max_pages=max_pages,
max_page_size=ENDPOINTS['hk_market_announcements'].max_page_size,
raw=raw,
fields=fields,
as_dataframe=as_dataframe,
**request_params,
)

def hk_periodic_announcements(
self,
keyword: Any | None = None,
report_type: Any | None = None,
stock_code: Any | None = None,
start_date: Any | None = None,
end_date: 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/v2/market/data/announcements/hk-periodic-announcements``.
Method: ``GET``.
Documented endpoint: ``hk_periodic_announcements``.

Args:
keyword: 标题关键词,只匹配简体标题,最多 60 字符 (type: string; required: N).
report_type: ``annual`` / ``semi_annual`` / ``quarterly``;不传为三类全部 (type: string; required: N).
stock_code: 港股主代码,支持裸码、``.HK``、``.XHKG``、``HK:`` 前缀 (type: string; required: N).
start_date: 公告日期起点 YYYYMMDD;只传 start_date 时为单日查询 (type: string; required: N).
end_date: 公告日期终点 YYYYMMDD;只给 end_date 返回 400 (type: string; required: N).
page: Page number, starting from 1. If omitted, the server default is used unless ``limit`` or ``all_pages`` is set.
page_size: Rows per page. The SDK validates this against the endpoint-specific maximum.
limit: Maximum number of rows to return. The SDK may fetch multiple pages to satisfy this limit.
all_pages: Fetch and combine pages until the server reports the last page.
max_pages: Optional safety cap for ``all_pages``.
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``。同一
公告涉及多个报告类型且未指定 ``report_type`` 时,按
``annual > semi_annual > quarterly`` 取第一个。
"""
request_params = {
'keyword': keyword,
'report_type': report_type,
'stock_code': stock_code,
'start_date': start_date,
'end_date': end_date,
}
request_params.update(kwargs)
return self.get_paginated(
ENDPOINTS['hk_periodic_announcements'].path,
page=page,
page_size=page_size,
limit=limit,
all_pages=all_pages,
max_pages=max_pages,
max_page_size=ENDPOINTS['hk_periodic_announcements'].max_page_size,
raw=raw,
fields=fields,
as_dataframe=as_dataframe,
**request_params,
)

def stk_ah_comparison(self, hk_code: Any | None = None, ts_code: Any | None = None, trade_date: Any | None = None, start_date: Any | None = None, end_date: 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:
"""AH股对比."""
params = {'hk_code': hk_code, 'ts_code': ts_code, 'trade_date': trade_date, 'start_date': start_date, 'end_date': end_date}
Expand Down
Loading
Loading