市场要闻

初始化

本页所有示例均假设已完成以下初始化:

from tigeropen.news.news_client import NewsClient
from tigeropen.tiger_open_config import TigerOpenClientConfig

client_config = TigerOpenClientConfig(props_path='your_config_directory_path')
news_client = NewsClient(client_config)

配置文件路径说明详见准备工作。


查询市场要闻

NewsClient.get_market_news(lang=None, last_id=None)

说明

查询市场要闻列表,对应接口 news_highlight_list。

  • 无必填参数,不传 last_id 时从最新一条开始返回。
  • 翻页只走 last_id 游标:取上一页 items 最后一条的 id,作为下一次调用的 last_id。
  • 响应中的 page_count 恒为 1,翻页请使用 last_id,不要按页码翻页。

参数

参数名类型是否必填描述
langLanguage 或 strNo返回内容语言:zh_CN / zh_TW / en_US
last_idstrNo游标翻页参数,取上一页 items 最后一条的 id;不传时从最新一条开始返回

返回

NewsPage(tigeropen.news.domain.news_page.NewsPage)对象,结构同 get_stock_news 查询个股新闻。

示例

# 首页:不传 last_id,从最新一条开始
page = news_client.get_market_news(lang='zh_CN')
for item in page.items:
    print(item.id, item.title)

# 翻页:取上一页最后一条的 id 作为 last_id
page = news_client.get_market_news(lang='zh_CN', last_id=page.items[-1].id)

返回示例

{
  "items": [
    {
      "id": "",
      "title": "",
      "summary": "",
      "pub_timestamp": 1793957176,
      "url": "https://xxxx"
    }
  ],
  "page_count": 1,
  "page_size": 20,
  "total_page": 8,
  "total_size": 143
}

请求频率

基础限流为 60 次/分钟。


Did this page help you?