Mirror congressional stock trades with automated broker execution
When the user invokes /clawback, execute the appropriate command based on the argument:
When the user invokes /clawback with any arguments, execute the corresponding command:
| Command | Action |
|---|---|
| --------- | -------- |
/clawback setup | Run the setup wizard: Execute {baseDir}/bin/clawback.py setup |
/clawback status | Check system status: Execute {baseDir}/bin/clawback.py status |
/clawback run | Start trading bot: Execute {baseDir}/bin/clawback.py run |
/clawback daemon | Run as background service: Execute {baseDir}/bin/clawback.py daemon |
/clawback test | Test notifications: Execute {baseDir}/bin/clawback.py test |
/clawback (no args) | Show help: Execute {baseDir}/bin/clawback.py --help |
Option 1: Using the wrapper script (recommended)
When executing ClawBack commands, always:
{baseDir}/bin/clawback.py{baseDir}/bin/clawback.py status)Option 2: Direct Python execution (if wrapper doesn't work)
If the wrapper script fails, you can run ClawBack directly:
cd {baseDir}source venv/bin/activatepython -m clawback.cli [command]Important: Always check if the virtual environment exists at {baseDir}/venv. If not, you may need to run the setup first.
/clawback setup - Interactive Setup FlowWhen user runs /clawback setup, follow these steps:
Step 1: Install dependencies (if needed)
Check if {baseDir}/venv exists. If not, run:
cd {baseDir} && python3 -m venv venv && source venv/bin/activate && pip install -e .
Step 2: Prompt for E*TRADE credentials
Ask the user for each value:
Step 3: Save configuration
Create/update ~/.clawback/config.json with the provided values:
{
"broker": {
"adapter": "etrade",
"environment": "<sandbox or production>",
"credentials": {
"apiKey": "<consumer_key>",
"apiSecret": "<consumer_secret>"
}
},
"trading": {
"accountId": "<account_id>",
"initialCapital": 50000,
"tradeScalePercentage": 0.01,
"maxPositionPercentage": 0.05,
"dailyLossLimit": 0.02
},
"notifications": {
"telegram": {
"enabled": true,
"useOpenClaw": true
}
},
"congress": {
"dataSource": "official",
"pollIntervalHours": 24,
"minimumTradeSize": 10000
}
}
Step 4: Confirm setup
Tell the user: "Configuration saved to ~/.clawback/config.json. Run /clawback status to verify."
Direct user to: https://developer.etrade.com
~/.clawback/config.json{baseDir}To check if the user has configured credentials, read ~/.clawback/config.json:
The CLI automatically reads from ~/.clawback/config.json for all operations.
Before running /clawback status or /clawback run, verify:
{baseDir}/venv exists (dependencies installed)~/.clawback/config.json exists with non-empty broker.credentials.apiKeyIf either is missing, suggest running /clawback setup first.
ClawBack tracks stock trades disclosed by members of Congress (House and Senate) and executes scaled positions in your E*TRADE brokerage account. Built on the premise that congressional leaders consistently outperform the market due to informational advantages.
ClawBack monitors these politicians by default (configurable):
| Politician | Chamber | Priority |
|---|---|---|
| ------------ | --------- | ---------- |
| Nancy Pelosi | House | 1 (highest) |
| Dan Crenshaw | House | 2 |
| Tommy Tuberville | Senate | 2 |
| Marjorie Taylor Greene | House | 3 |
| Parameter | Default | Description |
|---|---|---|
| ----------- | --------- | ------------- |
| Trade Delay | 3 days | Wait after disclosure before trading |
| Holding Period | 30 days | Target hold time for positions |
| Position Size | 5% | Max allocation per trade |
| Stop-Loss | 8% | Per-position stop-loss |
| Portfolio Drawdown | 15% | Max portfolio loss before halt |
| Disclosure Checks | 10:00, 14:00, 18:00 ET | Daily check times |
| 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.
# Install from ClawHub registry
clawhub install clawback
# Or install from local directory
clawhub install ./clawback
/clawback doesn't work in OpenClaw:{baseDir}/chmod +x {baseDir}/bin/clawback.py{baseDir}/venv/python {baseDir}/scripts/auth_utility.py --auth{baseDir}/bin/clawback.py setup to reconfigure~/.clawback/config.jsonpython {baseDir}/scripts/auth_utility.py --refreshpython {baseDir}/scripts/auth_utility.py --authpip install -e . in {baseDir}/{baseDir}/srcTo debug skill execution, add DEBUG=1 environment variable:
DEBUG=1 {baseDir}/bin/clawback.py status
This will show additional information about the execution context.
After installation via ClawHub, the install.sh script runs automatically:
If you skip setup during installation, run it manually:
cd ~/.openclaw/skills/clawback
./setup.sh # Interactive setup wizard
# or
clawback setup # CLI-based setup
The setup wizard guides you through configuration:
After setup, credentials are stored in .env:
# E*TRADE API (required)
BROKER_API_KEY=your_consumer_key_here
BROKER_API_SECRET=your_consumer_secret_here
BROKER_ACCOUNT_ID=your_account_id_here
# Telegram (optional)
TELEGRAM_BOT_TOKEN=your_bot_token_here
TELEGRAM_CHAT_ID=your_chat_id_here
# FMP API (optional)
FMP_API_KEY=your_fmp_api_key_here
# Use the installed CLI command
clawback run # Start interactive trading mode
clawback daemon # Run as background service
clawback status # Check system status
clawback setup # Re-run setup wizard
clawback test # Test Telegram notifications
The clawback daemon command runs continuously with:
ClawBack currently only supports ETRADE. The adapter pattern allows for future broker support, but only ETRADE is implemented and tested.
| Broker | Adapter | Status |
|---|---|---|
| -------- | --------- | -------- |
| E*TRADE | etrade_adapter.py | Supported |
For manual E*TRADE authentication outside the main CLI:
# Standalone OAuth authentication script
cd {baseDir}
source venv/bin/activate
python scripts/auth_script.py
This generates an authorization URL, prompts for the verification code, and completes authentication.
| File | Purpose |
|---|---|
| ------ | --------- |
~/.clawback/config.json | Main configuration |
~/.clawback/.access_tokens.json | E*TRADE OAuth tokens |
~/.clawback/data/trading.db | SQLite database |
.env fileTrading involves substantial risk of loss. This software is for educational purposes only. Past congressional trading performance does not guarantee future results. Always test with E*TRADE sandbox accounts before live trading.
共 1 个版本