stock_news_global
Fetch global financial news updates to monitor market developments and economic trends for informed investment decisions.
Instructions
获取最新的全球财经快讯
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- mcp_aktools/__init__.py:323-333 (handler)The main handler function for the 'stock_news_global' tool. It fetches global finance news from akshare's stock_info_global_sina and the custom newsnow_news helper, formats it, and returns as a string.def stock_news_global(): news = [] try: dfs = ak.stock_info_global_sina() csv = dfs.to_csv(index=False, float_format="%.2f").strip() csv = csv.replace(datetime.now().strftime("%Y-%m-%d "), "") news.extend(csv.split("\n")) except Exception: pass news.extend(newsnow_news()) return "\n".join(news)
- mcp_aktools/__init__.py:319-322 (registration)The @mcp.tool decorator registers the 'stock_news_global' tool with title and description.@mcp.tool( title="全球财经快讯", description="获取最新的全球财经快讯", )
- mcp_aktools/__init__.py:336-365 (helper)Helper function newsnow_news() called by the handler to fetch additional news from NewsNow API using POST request.def newsnow_news(channels=None): base = os.getenv("NEWSNOW_BASE_URL") if not base: return [] if not channels: channels = os.getenv("NEWSNOW_CHANNELS") or "wallstreetcn-quick,cls-telegraph,jin10" if isinstance(channels, str): channels = channels.split(",") all = [] try: res = requests.post( f"{base}/api/s/entire", json={"sources": channels}, headers={ "User-Agent": USER_AGENT, "Referer": base, }, timeout=60, ) lst = res.json() or [] for item in lst: for v in item.get("items", [])[0:15]: title = v.get("title", "") extra = v.get("extra") or {} hover = extra.get("hover") or title info = extra.get("info") or "" all.append(f"{hover} {info}".strip().replace("\n", " ")) except Exception: pass return all