clawback
Mirror congressional stock trades with automated broker execution and risk management
- License 许可
- MIT
- 最近更新
- 2026-08-23
- Stars
- ★ 1
- Forks
- 0
01 前言 Front Matter
- name
- clawback
- author
- dayne
- version
- 1.0.0
- metadata
- { "openclaw": { "config": [ "BROKER_API_KEY", "BROKER_API_SECRET", "BROKER_ACCOUNT_ID" ], "requires": [ "python3", "pdfplumber", "selenium", "yfinance" ], "optional_config": [ "TELEGRAM_BOT_TOKEN", "TELEGRAM_CHAT_ID" ] } }
- description
- Mirror congressional stock trades with automated broker execution and risk management
02 资源文件 55
- 参考文档_meta.json290 B
- 脚本add_trade.py2.2 KB
- 脚本auth_step1.py626 B
- 脚本auth_step2.py1.4 KB
- 参考文档AUTOMATED_SYSTEM_SUMMARY.md6.7 KB
- 参考文档config/config.json1.8 KB
- 参考文档config/config.template.json2.0 KB
- 参考文档config/congress_config.json1.3 KB
- 参考文档CONGRESSIONAL_DATA.md4.5 KB
- 参考文档data/seed/congressional_trades.json4.8 KB
- 参考文档docs/CONGRESSIONAL_DATA.md4.5 KB
- 脚本final_setup.sh11.5 KB
- 脚本install_deps.sh448 B
- 其他pytest.ini333 B
- 参考文档QUICK_START.md4.2 KB
- 参考文档README.md4.6 KB
- 参考文档requirements.txt448 B
- 脚本scripts/run_bot.sh3.4 KB
- 脚本scripts/setup_cron.sh2.8 KB
- 脚本setup_automated_trading.sh12.0 KB
- 脚本setup_congress.sh2.9 KB
- 脚本setup_integration.sh10.0 KB
- 脚本setup.py6.7 KB
- 脚本src/backtester.py20.0 KB
- 脚本src/broker_adapter.py6.6 KB
- 脚本src/config_loader.py6.1 KB
- 脚本src/congress_data/__init__.py459 B
- 脚本src/congress_data/alert_manager.py13.4 KB
- 脚本src/congress_data/config.py4.4 KB
- 脚本src/congress_data/cron_manager.py11.5 KB
- 脚本src/congress_data/cron_scheduler.py10.9 KB
- 脚本src/congress_data/data_collector.py15.1 KB
- 脚本src/congress_data/etrade_integration.py16.7 KB
- 脚本src/congress_data/main.py13.2 KB
- 脚本src/congress_data/run_cron.sh1.9 KB
- 脚本src/congress_data/setup_cron.py7.1 KB
- 脚本src/congress_tracker.py48.8 KB
- 脚本src/database.py17.0 KB
- 脚本src/etrade_adapter.py20.2 KB
- 脚本src/integration.py19.4 KB
- 脚本src/main.py20.1 KB
- 脚本src/notifications.py5.7 KB
- 参考文档src/requirements.txt359 B
- 脚本src/telegram_notifier.py4.9 KB
- 脚本src/trade_engine.py28.4 KB
- 脚本test_setup.py5.5 KB
- 脚本test_system.py6.6 KB
- 脚本test_telegram_setup.py2.5 KB
- 脚本tests/__init__.py16 B
- 脚本tests/conftest.py5.5 KB
- 脚本tests/test_broker_adapter.py10.5 KB
- 脚本tests/test_config_loader.py8.5 KB
- 脚本tests/test_congress_tracker.py11.1 KB
- 脚本tests/test_database.py10.3 KB
- 脚本tests/test_trade_engine.py12.4 KB
03 SKILL.md 正文
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
# Clone and setup
git clone https://github.com/openclaw/clawback
cd clawback
python3 -m venv venv && source venv/bin/activate
pip install -r requirements.txt
# Configure secrets
python3 src/config_loader.py setup
# Authenticate with broker
python3 src/main.py interactive
# Select option 1 to authenticate
# Set up automation
./scripts/setup_cron.sh
Configuration
ClawBack reads secrets from environment variables or config/secrets.json:
{
"BROKER_API_KEY": "your-broker-api-key",
"BROKER_API_SECRET": "your-broker-api-secret",
"BROKER_ACCOUNT_ID": "your-account-id",
"TELEGRAM_BOT_TOKEN": "optional-for-notifications",
"TELEGRAM_CHAT_ID": "optional-for-notifications"
}
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 | etrade_adapter.py |
Supported |
| Schwab | schwab_adapter.py |
Planned |
| Fidelity | fidelity_adapter.py |
Planned |
To specify which broker to use, set broker.adapter in your config:
{
"broker": {
"adapter": "etrade",
"credentials": {
"apiKey": "${BROKER_API_KEY}",
"apiSecret": "${BROKER_API_SECRET}"
}
}
}
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:
{
"strategy": {
"entryDelayDays": 3,
"holdingPeriodDays": 30,
"purchasesOnly": true,
"minimumTradeSize": 50000
},
"riskManagement": {
"positionStopLoss": 0.08,
"trailingStopActivation": 0.10,
"trailingStopPercent": 0.05,
"maxDrawdown": 0.15
}
}
Commands
# Interactive mode
python3 src/main.py interactive
# Single check cycle
python3 src/main.py run
# Scheduled trading
python3 src/main.py schedule 24
# Run backtest
python3 src/backtester.py
Cron Automation
# Install cron jobs
./scripts/setup_cron.sh
# Manual runs
./scripts/run_bot.sh check # Check for new trades
./scripts/run_bot.sh monitor # Check stop-losses
./scripts/run_bot.sh full # Both
Architecture
clawback/
├── src/
│ ├── main.py # Main entry point
│ ├── congress_tracker.py # Congressional data collection
│ ├── trade_engine.py # Trade execution & risk management
│ ├── broker_adapter.py # Abstract broker interface
│ ├── etrade_adapter.py # E*TRADE broker implementation
│ ├── database.py # SQLite state management
│ └── config_loader.py # Configuration handling
├── config/
│ ├── config.json # Main configuration
│ └── secrets.json # API keys (git-ignored)
├── scripts/
│ ├── run_bot.sh # Cron runner
│ └── setup_cron.sh # Cron installer
└── data/
└── trading.db # SQLite database
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
04 同仓库更多 Skills
crowd-prompting
A marketplace where AI agents improve prompts, system instructions, tool descriptions, and other text-based content with domain expertise from real-world operations — and earn tokens for valuable contributions.
dilemm-ai
Compete in DilemmAI, the prisoner's dilemma AI arena at dilemm.ai. Use when an OpenClaw agent wants to create an account, design and submit strategy prompts for their bot, enter matchmaking, analyze historical matches and leaderboards, and iterate on bot strategy. Requires headless browser automation (no API available yet).
arxiv-paper-reviews
Interact with arXiv Crawler API to fetch papers, read reviews, and submit comments. Use when working with arXiv papers, fetching paper lists by date/category/interest, viewing paper details with comments, or submitting paper reviews via API at http://150.158.152.82:8000.
arxiv-paper-reviews
Interact with arXiv Crawler API to fetch papers, read reviews, and submit comments. Use when working with arXiv papers, fetching paper lists by date/category/interest, viewing paper details with comments, or submitting paper reviews via API at http://150.158.152.82:8000.
git-summary
Get a quick summary of the current Git repository including status, recent commits, branches, and contributors.
agent-constitution
Interact with AgentConstitution governance contracts on Base Sepolia. Check compliance, read rules, log actions, query governance state.