📈 一个让您的AI与Yahoo Finance互动的模型上下文协议(MCP)服务器 - 获取全面的股市数据、新闻、财务信息等。
# 带命名空间安装
uvx yahoo-finance-server
pip install yahoo-finance-server
git clone https://github.com/AgentX-ai/AgentX-mcp-servers.git
cd AgentX-mcp-servers/yahoo_finance_server
pip install -e .
为了提高可靠性和避免速率限制,请设置代理:
# HTTP/HTTPS代理
export PROXY_URL="http://proxy.example.com:8080"
# 带认证的SOCKS代理
export PROXY_URL="socks5://user:pass@127..0.0.1:1080/"
# 基本运行
yahoo-finance-server
# 使用代理运行
PROXY_URL="http://127.0.0.1:7890" yahoo-finance-server
获取包括公司详情、财务信息和交易指标在内的综合股票信息。
{
"name": "get-ticker-info",
"arguments": {
"symbol": "AAPL"
}
}
获取特定股票代码的最新新闻文章。
{
"name": "get-ticker-news",
"arguments": {
"symbol": "AAPL",
"count": 10
}
}
搜索股票、ETF和其他金融工具及其相关新闻。
{
"name": "search",
"arguments": {
"query": "Apple Inc",
"count": 10
}
}
获取某个行业的顶级实体。
{
"name": "get-top-entities",
"arguments": {
"entity_type": "companies", // 选项:"etfs", "mutual_funds", "companies", "growth_companies", "performing_companies"
"sector": "technology", // 查看支持的行业列表
"count": 10
}
}
支持的行业:
获取可定制时间段和间隔的历史价格数据。
{
"name": "get-price-history",
"arguments": {
"symbol": "AAPL",
"period": "1y", // 选项:1d, 5d, 1mo, 3mo, 6mo, 1y, 2y, 5y, 10y, ytd, max
"interval": "1d" // 选项:1m, 2m, 5m, 15m, 30m, 60m, 90m, 1h, 1d, 5d, 1wk, 1mo, 3mo
}
}
获取股票的期权链数据。
{
"name": "ticker-option-chain",
"arguments": {
"symbol": "AAPL",
"option_type": "call", // 选项:"call", "put", "both"
"date": "2024-01-19" // 可选:YYYY-MM-DD 格式
}
}
获取包括历史和即将发布的收益数据。
{
"name": "ticker-earning",
"arguments": {
"symbol": "AAPL",
"period": "annual", // 选项:"annual", "quarterly"
"date": "2023-12-31" // 可选:YYYY-MM-DD 格式
}
}
npx @modelcontextprotocol/inspector yahoo-finance-server
python -c "
import asyncio
from yahoo_finance_server.helper import get_ticker_info
async def test():
info = await get_ticker_info('AAPL')
print(f'✅ 股票: {info[\"longName\"]}')
asyncio.run(test())
"
MIT 许可证 - 详情见LICENSE文件。
为金融社区制作 ❤️