使用说明
罗宾汉工具
提供CLI和MCP访问的monorepo 罗宾股票 (非官方)Robinhood API。
包装
| 包装 | 描述 |
|---|---|
robinhood-core |
共享库:客户端、模型、服务 |
robinhood-cli |
CLI工具(rh 命令)用于终端访问 |
robinhood-mcp |
用于AI助手的MCP服务器(Claude、OpenCode等) |
快速开始
命令行界面
# Clone and install globally
git clone https://github.com/ach968/robinhood-tools.git
cd robinhood-tools
uv tool install ./robinhood-cli
# Login (prompts for username/password)
rh login
# Use
rh price AAPL MSFT
rh quote TSLA
rh portfolio
rh positions
rh options-chain SPY --expiry 2026-06-20 --type call
rh history AAPL --interval day --span month
rh orders --type stock --since 2026-01-01
rh watchlists
rh news NVDA
rh fundamentals AMD
rh status
rh logout
所有命令支持 --json 用于原始JSON输出。
MCP服务器
添加到您的OpenCode配置(~/.config/opencode/opencode.json):
{
"mcp": {
"robinhood": {
"type": "local",
"command": [
"uvx",
"--from", "git+https://github.com/ach968/robinhood-tools.git",
"robinhood-mcp",
"--username", "your_username",
"--password", "your_password"
],
"enabled": true
}
}
}
看 罗宾汉mcp/README.md 获取完整的MCP文档。
发展
# Clone
git clone https://github.com/ach968/robinhood-tools.git
cd robinhood-tools
# Install all packages
cd robinhood-core && uv pip install -e ".[dev]"
cd ../robinhood-cli && uv pip install -e ".[dev]"
cd ../robinhood-mcp && uv pip install -e ".[dev]"
# Run tests
cd robinhood-core && uv run pytest tests/ -v
cd ../robinhood-cli && uv run pytest tests/ -v
cd ../robinhood-mcp && uv run pytest tests/ -v
CLI命令
| 命令 | 描述 |
|---|---|
rh login |
通过Robinhood进行身份验证 |
rh logout |
清除已保存的会话 |
rh status |
显示身份验证状态 |
rh price SYMBOLS... |
当前价格 |
rh quote SYMBOLS... |
详细报价有变化 |
rh history SYMBOL |
历史OHLCV数据 |
rh portfolio |
投资组合摘要 |
rh positions |
未平仓股票头寸 |
rh options-chain SYMBOL |
期权链 |
rh options-positions |
未平仓期权头寸 |
rh watchlists |
列出观察名单 |
rh news SYMBOL |
最新动态 |
rh fundamentals SYMBOL |
公司基本面 |
rh orders |
订单历史 |
所有命令接受 --json 用于机器可读输出。
MCP工具
| 工具 | 说明 |
|---|---|
robinhood.market.current_price |
当前报价 |
robinhood.market.price_history |
历史OHLCV数据 |
robinhood.market.quote |
详细报价 |
robinhood.options.chain |
期权链 |
robinhood.orders.history |
订单历史 |
robinhood.portfolio.summary |
投资组合摘要 |
robinhood.portfolio.positions |
当前职位 |
robinhood.watchlists.list |
观察名单 |
robinhood.news.latest |
最新动态 |
robinhood.fundamentals.get |
公司基本面 |
robinhood.auth.status |
身份验证状态 |
建筑
robinhood-core/ # Shared library
├── robinhood_core/
│ ├── client.py # RobinhoodClient (robin-stocks wrapper)
│ ├── errors.py # Exception types
│ ├── models/ # Pydantic models
│ └── services/ # Business logic services
robinhood-cli/ # CLI tool
├── robinhood_cli/
│ ├── main.py # Typer app entry point
│ ├── auth.py # Session management
│ ├── output.py # Rich formatting helpers
│ └── commands/ # Command modules
robinhood-mcp/ # MCP server
├── robin_stocks_mcp/
│ └── server.py # MCP tool implementations
安全说明
- 所有工具都是 只读 --无法下订单或修改帐户
- CLI将会话令牌存储在
~/.config/robinhood/(pickle文件+配置) - MCP通过CLI参数或环境变量接受凭据
- 密码和令牌从不记录
代理技能
技能包含在 skills/rh-cli.md.
要使用它,请复制到您的代理技能目录:
mkdir -p ~/.claude/skills/rh-cli
cp skills/rh-cli.md ~/.claude/skills/rh-cli/SKILL.md
安装后,您的代理将自动建议使用 rh 当您询问Robinhood数据时,可以使用命令。
免责声明
此项目使用 罗宾股票,一个非官方的Python库。它不隶属于Robinhood Markets,股份有限公司或由其背书。使用风险自负。
