skills$openclaw/clawback
mainfraame1.4k

by mainfraame

clawback – OpenClaw Skill

clawback is an OpenClaw Skills integration for coding workflows. Mirror congressional stock trades with automated broker execution and risk management. Use when you want to track and automatically trade based on congressional disclosures from House Clerk and Senate eFD sources.

1.4k stars9.9k forksSecurity L1
Updated Feb 7, 2026Created Feb 7, 2026coding

Skill Snapshot

nameclawback
descriptionMirror congressional stock trades with automated broker execution and risk management. Use when you want to track and automatically trade based on congressional disclosures from House Clerk and Senate eFD sources. OpenClaw Skills integration.
ownermainfraame
repositorymainfraame/clawback
languageMarkdown
licenseMIT
topics
securityL1
installopenclaw add @mainfraame/clawback
last updatedFeb 7, 2026

Maintainer

mainfraame

mainfraame

Maintains clawback in the OpenClaw Skills directory.

View GitHub profile
File Explorer
45 files
.
bin
clawback.py
559 B
config
config.template.json
2.0 KB
congress_config.json
1.3 KB
scripts
auth_script.py
1.3 KB
run_bot.sh
3.4 KB
setup_cron.sh
2.8 KB
src
clawback
congress_data
__init__.py
460 B
alert_manager.py
12.5 KB
broker_integration.py
17.2 KB
config.py
4.4 KB
cron_manager.py
11.0 KB
cron_scheduler.py
10.3 KB
data_collector.py
15.1 KB
main.py
12.5 KB
run_cron.sh
1.9 KB
setup_cron.py
6.9 KB
__init__.py
218 B
backtester.py
20.2 KB
broker_adapter.py
8.8 KB
cli.py
10.8 KB
config_loader.py
9.9 KB
congress_tracker.py
48.5 KB
database.py
20.9 KB
etrade_adapter.py
25.2 KB
integration.py
18.5 KB
main.py
27.7 KB
notifications.py
5.6 KB
telegram_notifier.py
9.4 KB
trade_engine.py
29.2 KB
_meta.json
627 B
CHANGELOG.md
3.2 KB
CLAUDE.md
2.0 KB
install.sh
1.4 KB
pyproject.toml
3.3 KB
README.md
4.5 KB
requirements.txt
448 B
setup.py
2.0 KB
setup.sh
1.9 KB
SKILL.md
10.0 KB
SKILL.md

name: clawback description: Mirror congressional stock trades with automated broker execution and risk management. Use when you want to track and automatically trade based on congressional disclosures from House Clerk and Senate eFD sources. version: 1.1.0 author: mainfraame homepage: https://github.com/mainfraame/clawback user-invocable: true metadata: {"openclaw": {"emoji": "🦀", "requires": {"bins": ["python3", "pip"]}, "install": {"pip": "{baseDir}"}, "primaryEnv": "BROKER_API_KEY"}}

ClawBack

Mirror congressional stock trades with automated broker execution

Agent Instructions

When the user invokes /clawback, execute the appropriate command based on the argument:

Commands

CommandAction
/clawback setupInteractive setup - prompt for credentials (see below)
/clawback statusCheck status: cd {baseDir} && source venv/bin/activate && python -m clawback.cli status
/clawback runStart trading: cd {baseDir} && source venv/bin/activate && python -m clawback.cli run
/clawbackDefault to status check

/clawback setup - Interactive Setup Flow

When 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:

  1. Environment: Ask "Do you want to use sandbox (testing) or production (real money)?"

    • Default: sandbox
  2. Consumer Key: Ask "Enter your E*TRADE Consumer Key (from developer.etrade.com):"

    • Required field
  3. Consumer Secret: Ask "Enter your E*TRADE Consumer Secret:"

    • Required field
  4. Account ID: Ask "Enter your E*TRADE Account ID (or leave blank to get it after OAuth):"

    • Optional - can be obtained later

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."

Getting E*TRADE API Credentials

Direct user to: https://developer.etrade.com

  1. Create a developer account
  2. Create a new app (sandbox first for testing)
  3. Copy the Consumer Key and Consumer Secret

Configuration Location

  • Config file: ~/.clawback/config.json
  • Skill directory: {baseDir}

Reading Saved Configuration

To check if the user has configured credentials, read ~/.clawback/config.json:

  • If file doesn't exist or credentials are empty → prompt for setup
  • If credentials exist → can proceed with status/run commands

The CLI automatically reads from ~/.clawback/config.json for all operations.

Checking Setup Status

Before running /clawback status or /clawback run, verify:

  1. {baseDir}/venv exists (dependencies installed)
  2. ~/.clawback/config.json exists with non-empty broker.credentials.apiKey

If 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.

Default Target Politicians

ClawBack monitors these politicians by default (configurable):

PoliticianChamberPriority
Nancy PelosiHouse1 (highest)
Dan CrenshawHouse2
Tommy TubervilleSenate2
Marjorie Taylor GreeneHouse3

Trading Strategy Defaults

ParameterDefaultDescription
Trade Delay3 daysWait after disclosure before trading
Holding Period30 daysTarget hold time for positions
Position Size5%Max allocation per trade
Stop-Loss8%Per-position stop-loss
Portfolio Drawdown15%Max portfolio loss before halt
Disclosure Checks10:00, 14:00, 18:00 ETDaily check times

Features

  • Real-time disclosure tracking from official House Clerk and Senate eFD sources
  • Automated trade execution via E*TRADE API (only supported broker)
  • 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)

StrategyWin RateReturnSharpe
3-day delay, 30-day hold42.9%+6.2%0.39
9-day delay, 90-day hold57.1%+4.7%0.22

Congressional leaders have outperformed the S&P 500 by 47% annually according to NBER research.

Installation via ClawHub

# Install from ClawHub registry
clawhub install clawback

# Or install from local directory
clawhub install ./clawback

Post-Installation Setup

After installation via ClawHub, the install.sh script runs automatically:

  1. Python Environment Setup - Creates virtual environment
  2. Package Installation - Installs ClawBack via pip
  3. Directory Structure - Creates logs/, data/, config/ directories
  4. Setup Prompt - Asks if you want to run the setup wizard

If you skip setup during installation, run it manually:

cd ~/.openclaw/skills/clawback
./setup.sh          # Interactive setup wizard
# or
clawback setup      # CLI-based setup

Improved Setup Features

  • Better input handling - Works in both interactive and non-interactive modes
  • Input validation - Validates E*TRADE API key formats
  • Timeout handling - Automatically uses defaults if no input
  • Error recovery - Fallback to manual setup if CLI fails
  • Configuration check - Detects existing config and offers options

Interactive Setup Wizard

The setup wizard guides you through configuration:

Step 1: Environment Selection

  • Sandbox (recommended for testing): No real trades, uses E*TRADE developer sandbox
  • Production: Real trading with real money

Step 2: E*TRADE API Credentials

  • Consumer Key: From E*TRADE developer portal
  • Consumer Secret: From E*TRADE developer portal

Step 3: Authentication

  • Automatic OAuth flow with E*TRADE
  • Opens browser for authorization
  • Returns verification code

Step 4: Account Selection

  • Lists all available E*TRADE accounts
  • Choose which account to trade with

Step 5: Telegram Setup (Optional)

  • Configure notifications via Telegram bot
  • Uses OpenClaw's built-in Telegram channel if available

Environment Variables

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

Usage

# 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

Automated Trading

The clawback daemon command runs continuously with:

  • Disclosure checks at 10:00, 14:00, 18:00 ET (when filings are typically released)
  • Trade execution at 9:35 AM ET (5 min after market open)
  • Token refresh every 90 minutes (keeps E*TRADE session alive)
  • Market hours enforcement (9:30 AM - 4:00 PM ET)

Data Sources

Supported Brokers

ClawBack currently only supports ETRADE. The adapter pattern allows for future broker support, but only ETRADE is implemented and tested.

BrokerAdapterStatus
E*TRADEetrade_adapter.pySupported

Risk Management

  • Position limits: 5% max per symbol, 20 positions max
  • Stop-losses: 8% per position, 15% portfolio drawdown
  • Daily limits: 3% max daily loss
  • PDT compliance: Conservative 2 trades/day limit

Authentication Helpers

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 Locations

FilePurpose
~/.clawback/config.jsonMain configuration
~/.clawback/.access_tokens.jsonE*TRADE OAuth tokens
~/.clawback/data/trading.dbSQLite database

Security

  • No hardcoded credentials in source code
  • Environment variable based configuration
  • Encrypted token storage for E*TRADE
  • Git-ignored .env file
  • Optional production encryption

Support

Disclaimer

Trading 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.

README.md

ClawBack 🦀

Mirror congressional stock trades with automated broker execution

ClawHub Version Python

ClawBack tracks stock trades disclosed by members of Congress and executes scaled positions in your brokerage account. Built on the premise that congressional leaders consistently outperform the market.

Installation

Via ClawHub (Recommended)

# Install from ClawHub registry
clawhub install clawback

# Run setup wizard
clawback setup

Manual Installation

# Clone the repository
git clone https://github.com/mainfraame/clawback.git
cd clawback

# Install
pip install -e .

# Run setup
clawback setup

From Source with Make

git clone https://github.com/mainfraame/clawback.git
cd clawback

# Create venv and install
make deps

# Activate and setup
source venv/bin/activate
clawback setup

Quick Start

# Check system status
clawback status

# Run interactive trading mode
clawback run

# Run as background daemon
clawback daemon

Configuration

Configuration is stored in ~/.clawback/config.json. The setup wizard will guide you through:

  1. Broker Selection - E*TRADE (currently the only supported broker)
  2. Environment - Sandbox (testing) or Production (real money)
  3. API Credentials - From E*TRADE developer portal
  4. Account Selection - Choose which account to trade
  5. Telegram Notifications - Optional alerts via Telegram

Environment Variables

# E*TRADE API (required)
BROKER_API_KEY=your_consumer_key
BROKER_API_SECRET=your_consumer_secret
BROKER_ACCOUNT_ID=your_account_id

# Telegram (optional)
TELEGRAM_BOT_TOKEN=your_bot_token
TELEGRAM_CHAT_ID=your_chat_id

Features

  • Real-time disclosure tracking from official House Clerk and Senate eFD sources
  • Automated trade execution via E*TRADE API
  • Smart position sizing - scales trades to your account size
  • Risk management - stop-losses, drawdown limits, position limits
  • Telegram notifications - alerts for new trades and events
  • OpenClaw integration - works as an OpenClaw skill

Architecture

ComponentDescription
Congressional TrackerFetches trade data from official disclosures
Broker AdapterHandles authentication and trading (E*TRADE)
Trade EngineExecutes orders with risk management
Telegram NotifierSends alerts and notifications
DatabaseSQLite storage for trades and positions

Data Sources

Default Tracked Politicians

PoliticianChamberPriority
Nancy PelosiHouse1 (highest)
Dan CrenshawHouse2
Tommy TubervilleSenate2
Marjorie Taylor GreeneHouse3

Trading Strategy

ParameterDefault
Trade Delay3 days after disclosure
Holding Period30 days
Disclosure Checks10:00, 14:00, 18:00 ET

Risk Management

ControlDefault
Max position size5% of portfolio
Max positions20
Daily loss limit3%
Portfolio stop-loss15%
Position stop-loss8%

Authentication Helpers

For manual E*TRADE OAuth authentication:

# Standalone authentication script
source venv/bin/activate
python scripts/auth_script.py

Development

# Show all make commands
make help

# Linting (required before release)
make lint          # Run ruff linter
make lint-fix      # Auto-fix issues

# Version management
make bump-patch    # 1.0.x → 1.0.x+1
make bump-minor    # 1.x.0 → 1.x+1.0
make bump-major    # x.0.0 → x+1.0.0

# Release workflow (lint runs automatically)
make ship-patch    # bump + lint + release + publish
make ship-minor
make ship-major

Support

Disclaimer

Trading involves substantial risk of loss. This software is for educational purposes only. Past congressional trading performance does not guarantee future results. Always test with sandbox accounts before live trading.


Version: 1.1.0 | License: MIT | Author: mainfraame

Permissions & Security

Security level L1: Low-risk skills with minimal permissions. Review inputs and outputs before running in production.

- No hardcoded credentials in source code - Environment variable based configuration - Encrypted token storage for E*TRADE - Git-ignored `.env` file - Optional production encryption

Requirements

  • OpenClaw CLI installed and configured.
  • Language: Markdown
  • License: MIT
  • Topics:

Configuration

- Config file: `~/.clawback/config.json` - Skill directory: `{baseDir}`

FAQ

How do I install clawback?

Run openclaw add @mainfraame/clawback in your terminal. This installs clawback into your OpenClaw Skills catalog.

Does this skill run locally or in the cloud?

OpenClaw Skills execute locally by default. Review the SKILL.md and permissions before running any skill.

Where can I verify the source code?

The source repository is available at https://github.com/openclaw/skills/tree/main/skills/mainfraame/clawback. Review commits and README documentation before installing.