Skip to main content
Glama
amahpour

Income Screener MCP Server

by amahpour

收益筛选器 MCP 服务器

一个 Python MCP 服务器,通过 pyetrade 将 Claude 连接到 E*Trade,用于收益导向的交易研究:

  • 实时报价(股票、优先股、小型债券)

  • 期权链查询

  • 带有年化收益率过滤器的卖出看跌期权候选筛选

  • 投资组合持仓监控

架构

Claude (Claude Code / Claude Desktop)
    ↓ MCP protocol (stdio)
server.py  (FastMCP + pyetrade)
    ↓ OAuth1 REST
E*Trade API (api.etrade.com)

先决条件

  1. 一个有效的 E*Trade 经纪账户。

  2. 来自 developer.etrade.com 的开发者 API 密钥。生产环境密钥需要 3-5 个工作日才能获得批准。

  3. Python 3.10+。

设置

pip install -r requirements.txt
cp .env.example .env
# edit .env and set ETRADE_CONSUMER_KEY / ETRADE_CONSUMER_SECRET
python auth.py

auth.py 会引导完成 OAuth1 流程:它会打印一个 URL(并尝试打开您的浏览器),您在 E*Trade 网站上授权该应用程序,将验证码粘贴回终端,生成的访问令牌将写入 .env 文件。

注意: E*Trade 访问令牌在美东时间午夜过期。每天早上使用服务器前请重新运行 python auth.py

运行服务器

python server.py

该服务器通过 stdio 进行 MCP 通信,旨在由 MCP 客户端(Claude Desktop、Claude Code 等)启动,而不是交互式运行。

Claude Desktop 配置

添加到 claude_desktop_config.json

{
  "mcpServers": {
    "income-screener": {
      "command": "python",
      "args": ["server.py"],
      "cwd": "/home/amahpour/code/pyetrade-mcp"
    }
  }
}

工具

工具

描述

get_quote(symbols)

最多 25 个代码的实时报价。

get_option_expire_dates(symbol)

某代码可用的期权到期日。

get_option_chain(symbol, chain_type, expiry_date, strike_price_near, num_strikes)

获取期权链窗口。

screen_put_candidates(symbols, max_strike_pct, min_annual_yield, min_open_interest, months_out)

按年化收益率对卖出看跌期权候选进行排名。

get_portfolio()

认证账户下的第一个账户的持仓情况。

年化收益率

screen_put_candidates 计算 (bid / strike) * (365 / DTE) 并按 min_annual_yield 进行过滤。结果按收益率从高到低排序。

默认观察列表

如果您在调用 screen_put_candidates 时不提供 symbols,它将使用内置的股票列表(HPQ, HPE, PFE, T, VZ, F, INTC, DOW, KHC, WBA)。server.py 中定义了一个优先股/小型债券观察列表,可与 get_quote 一起使用。

注意事项

  • server.py 使用 dev=False(生产 API)。E*Trade 的沙盒环境不返回真实的期权链数据。

  • 优先股代码格式(例如 JPM-CJPMpC)可能会有所不同;请针对您的特定代码进行测试。

  • screen_put_candidates 中的调用会以 0.5 秒的延迟进行序列化,以保持在 E*Trade 的速率限制之内。

文件

.
├── README.md
├── LICENSE
├── requirements.txt    # pyetrade, mcp[cli], python-dotenv
├── .env.example        # template — copy to .env and fill in
├── auth.py             # one-shot OAuth token refresh
└── server.py           # FastMCP server + all 5 tools
-
security - not tested
A
license - permissive license
-
quality - not tested

Resources

Unclaimed servers have limited discoverability.

Looking for Admin?

If you are the server author, to access and configure the admin panel.

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/amahpour/pyetrade-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server