ClawBack
Mirror congressional stock trades with automated broker execution
ClawBack tracks stock trades disclosed by members of Congress (House and Senate) and executes scaled positions in your brokerage account. Built on the premise that congressional leaders consistently outperform the market due to informational advantages.
Features
- - Real-time disclosure tracking from official House Clerk and Senate eFD sources
- Automated trade execution via broker API (E*TRADE adapter included)
- Smart position sizing - scales trades to your account size
- Trailing stop-losses - lock in profits, limit losses
- Risk management - drawdown limits, consecutive loss protection
- Telegram notifications - get alerts for new trades and stop-losses
- Backtesting engine - test strategies on historical data
Performance (Backtest Results)
| Strategy | Win Rate | Return | Sharpe |
|---|
| 3-day delay, 30-day hold | 42.9% | +6.2% | 0.39 |
| 9-day delay, 90-day hold |
57.1% | +4.7% | 0.22 |
Congressional leaders have outperformed the S&P 500 by 47% annually according to NBER research.
Quick Start
CODEBLOCK0
Configuration
ClawBack reads secrets from environment variables or config/secrets.json:
CODEBLOCK1
Supported Brokers
ClawBack uses an adapter pattern for broker integration. Each broker implements a common interface defined in broker_adapter.py.
| Broker | Adapter | Status |
|---|
| E*TRADE | INLINECODE2 | Supported |
| Schwab |
schwab_adapter.py | Planned |
| Fidelity |
fidelity_adapter.py | Planned |
To specify which broker to use, set broker.adapter in your config:
CODEBLOCK2
Data Sources
All data is scraped directly from official government sources:
| Source | Data | Method |
|---|
| House Clerk | House PTR filings | PDF parsing |
| Senate eFD |
Senate PTR filings | Selenium scraping |
No third-party APIs required for congressional data.
Strategy Settings
Edit config/config.json to customize:
CODEBLOCK3
Commands
CODEBLOCK4
Cron Automation
CODEBLOCK5
Architecture
CODEBLOCK6
Risk Disclaimer
This software is for educational purposes only. Trading stocks involves substantial risk of loss. Past performance of congressional trades does not guarantee future results. The authors are not financial advisors. Use at your own risk.
License
MIT License - See LICENSE file
Built with ClawBack for the OpenClaw community
ClawBack
通过自动券商执行,镜像国会股票交易
ClawBack追踪美国国会(众议院和参议院)议员披露的股票交易,并在您的券商账户中执行按比例调整的头寸。其核心理念是:国会领导人凭借信息优势,其投资表现持续跑赢市场。
功能特性
- - 实时披露追踪:来自众议院书记官和参议院eFD官方数据源
- 自动交易执行:通过券商API(内置E*TRADE适配器)
- 智能仓位管理:根据账户规模按比例调整交易
- 移动止损:锁定利润,限制亏损
- 风险管理:回撤限制、连续亏损保护
- Telegram通知:新交易和止损触发时推送提醒
- 回测引擎:基于历史数据测试策略
表现(回测结果)
| 策略 | 胜率 | 收益率 | 夏普比率 |
|---|
| 3天延迟,持有30天 | 42.9% | +6.2% | 0.39 |
| 9天延迟,持有90天 |
57.1% | +4.7% | 0.22 |
根据NBER研究,国会领导人的年化收益率比标普500指数高出47%。
快速开始
bash
克隆并配置
git clone https://github.com/openclaw/clawback
cd clawback
python3 -m venv venv && source venv/bin/activate
pip install -r requirements.txt
配置密钥
python3 src/config_loader.py setup
券商认证
python3 src/main.py interactive
选择选项1进行认证
设置自动化
./scripts/setup_cron.sh
配置
ClawBack从环境变量或config/secrets.json读取密钥:
json
{
BROKERAPIKEY: 你的券商API密钥,
BROKERAPISECRET: 你的券商API密钥密码,
BROKERACCOUNTID: 你的账户ID,
TELEGRAMBOTTOKEN: 可选,用于通知,
TELEGRAMCHATID: 可选,用于通知
}
支持的券商
ClawBack使用适配器模式进行券商集成。每个券商实现broker_adapter.py中定义的通用接口。
| 券商 | 适配器 | 状态 |
|---|
| E*TRADE | etradeadapter.py | 已支持 |
| Schwab |
schwabadapter.py | 计划中 |
| Fidelity | fidelity_adapter.py | 计划中 |
要指定使用的券商,请在配置中设置broker.adapter:
json
{
broker: {
adapter: etrade,
credentials: {
apiKey: ${BROKERAPIKEY},
apiSecret: ${BROKERAPISECRET}
}
}
}
数据源
所有数据直接从官方政府来源抓取:
| 数据源 | 数据 | 方法 |
|---|
| 众议院书记官 | 众议院PTR申报文件 | PDF解析 |
| 参议院eFD |
参议院PTR申报文件 | Selenium爬取 |
国会数据无需第三方API。
策略设置
编辑config/config.json进行自定义:
json
{
strategy: {
entryDelayDays: 3,
holdingPeriodDays: 30,
purchasesOnly: true,
minimumTradeSize: 50000
},
riskManagement: {
positionStopLoss: 0.08,
trailingStopActivation: 0.10,
trailingStopPercent: 0.05,
maxDrawdown: 0.15
}
}
命令
bash
交互模式
python3 src/main.py interactive
单次检查周期
python3 src/main.py run
定时交易
python3 src/main.py schedule 24
运行回测
python3 src/backtester.py
Cron自动化
bash
安装cron任务
./scripts/setup_cron.sh
手动运行
./scripts/run_bot.sh check # 检查新交易
./scripts/run_bot.sh monitor # 检查止损
./scripts/run_bot.sh full # 两者都执行
架构
clawback/
├── src/
│ ├── main.py # 主入口
│ ├── congress_tracker.py # 国会数据收集
│ ├── trade_engine.py # 交易执行与风险管理
│ ├── broker_adapter.py # 抽象券商接口
│ ├── etrade_adapter.py # E*TRADE券商实现
│ ├── database.py # SQLite状态管理
│ └── config_loader.py # 配置处理
├── config/
│ ├── config.json # 主配置
│ └── secrets.json # API密钥(被git忽略)
├── scripts/
│ ├── run_bot.sh # Cron运行器
│ └── setup_cron.sh # Cron安装器
└── data/
└── trading.db # SQLite数据库
风险声明
本软件仅供教育目的。股票交易涉及重大亏损风险。国会交易的历史表现不保证未来结果。作者并非财务顾问。使用风险自负。
许可证
MIT许可证 - 详见LICENSE文件
由ClawBack为OpenClaw社区构建