StockFlow MCP服务器
模型上下文协议(MCP)服务器,通过雅虎财经提供实时股票数据和期权分析。使LLM能够访问市场数据、分析股票和评估期权策略。
特性
股票数据
- 实时股票价格和关键指标
- 具有OHLC值的历史价格数据
- 公司基本面和财务报表
- 市场指标和比率
期权分析
- 完整的期权链数据
- 希腊语(δ、γ、θ、维加)
- 交易量和未平仓合约跟踪
- 期权策略分析
安装
# Install dependencies
pip install mcp yfinance
# Clone the repository
git clone https://github.com/twolven/stockflow
cd stockflow用法
- 克隆存储库:
git clone https://github.com/twolven/mcp-stockflow.git
cd mcp-stockflow- 安装依赖项:
pip install -r requirements.txt- 添加到您的Claude配置中:
在你的 claude-desktop-config.json,将以下内容添加到 mcpServers 章节:
{
"mcpServers": {
"stockflow": {
"command": "python",
"args": ["path/to/stockflow.py"]
}
}
}将“path/to/stockflow.py”替换为保存stockflow.py文件的完整路径。
Claude使用提示
使用Claude时,您可以使用此提示帮助它了解可用的工具:
“我启用了股票流工具,可以让你访问股票市场数据。你可以使用以下三个主要功能:
get_stock_data-获取全面的股票信息:
{
"symbol": "AAPL",
"include_financials": true, # optional
"include_analysis": true, # optional
"include_calendar": true # optional
}get_historical_data-获取价格历史和技术指标:
{
"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
"prepost": false # optional - include pre/post market data
}get_options_chain-获取选项数据:
{
"symbol": "AAPL",
"expiration_date": "2024-12-20", # optional - uses nearest date if not specified
"include_greeks": true # optional
}所有回复都包括当前价格数据、错误处理和全面的市场信息。"
运行服务器
python stockflow.py与MCP客户端一起使用
from mcp import ClientSession, StdioServerParameters
from mcp.client.stdio import stdio_client
server_params = StdioServerParameters(
command="python",
args=["stockflow.py"]
)
async def run():
async with stdio_client(server_params) as (read, write):
async with ClientSession(read, write) as session:
await session.initialize()
# Get current stock data
result = await session.call_tool(
"get-stock-data",
arguments={"symbol": "AAPL"}
)
# Get options chain
options = await session.call_tool(
"get-options-chain",
arguments={
"symbol": "AAPL",
"expiration_date": "2024-12-20"
}
)
if __name__ == "__main__":
import asyncio
asyncio.run(run())可用工具
get-stock-data
- 当前价格和数量 - 市值和市盈率 - 52周高点/低点
get-historical-data
- OHLC价格 - 可配置的时间段 - 体积数据
get-options-chain
- 呼叫和发送 - 执行价格 - 希腊人和IV - 交易量和未平仓合约
可用资源
company-info://{symbol}
- 企业简介 - 部门和行业 - 员工人数 - 网站
financials://{symbol}
- 利润表 - 资产负债表 - 现金流量表
鼓励
analyze-options
- 期权策略分析 - 风险/回报评估 - 市场状况评估
需求
- Python 3.12+
- 主控程序
- 金融
局限性
- 数据来源于雅虎财经,可能存在延迟
- 选项数据可用性取决于市场时间
- 根据雅虎金融API限制适用费率限制
贡献
欢迎投稿!请随时提交拉取请求。
许可证
此项目根据MIT许可证获得许可-请参阅 许可证 文件以获取详细信息。
作者
托德·沃尔文(https://github.com/twolven)
致谢
致谢
- 使用Anthropic的模型上下文协议(MCP)构建
- 数据由 雅虎财经
- 为与Anthropic的Claude一起使用而开发
