Hackathon submission for LabLab.ai "AI Trading Agents with ERC-8004"
AI-powered trading agent achieving 82.2% out-of-sample win rate across 8 pair-direction combos, validated through Walk-Forward Optimization (8 windows, IS=90d, OOS=30d, 366 OOS trades). Unlike typical backtest-only agents, every parameter is proven on unseen data — ensuring live performance matches validation results, not curve-fit parameters.
The agent combines three complementary strategies (WaveRider, BB Squeeze, MACD Divergence) with regime-adaptive routing, automated risk management, and ERC-8004 on-chain identity for verifiable reputation.
Built for the LabLab.ai AI Trading Agents with ERC-8004 hackathon. Agent identity registered on Sepolia following the ERC-8004 standard (Agent ID: 2328).
| Strategy | Description | Signal Type |
|---|---|---|
| WaveRider | EMA trend + RSI momentum + Volume confirmation | Primary (trend-following) |
| BB Squeeze | Bollinger Band compression → breakout detection | Secondary (mean-reversion) |
| MACD Divergence | Swing-point price-MACD divergence for reversal signals | Secondary (reversal) |
The agent automatically detects market conditions using ADX + Bollinger Band width:
| Regime | Action | Position Sizing |
|---|---|---|
| Trending Up | Full long strategies | 100% |
| Trending Down | Block longs, use shorts as exits | 100% shorts |
| Ranging | Longs allowed, wider SL (1.5x ATR) | 75% |
| High Volatility | Longs allowed, wider SL (1.8x ATR) | 50% |
| EMA Convergence | Block all trading | 0% |
- Max 5% portfolio per trade (risk-based position sizing)
- 3% daily loss → automatic stop
- 10% total drawdown → emergency close all
- 5 consecutive losses → pause trading
- 3 consecutive losses → reduce position size to 50%
- Trailing stop: TP1 → breakeven, TP2 → tighten, TP3 → close
┌─────────────────────────────────────────────┐
│ KrakenTradingAgent (main loop) │
│ 4H signal scan + 5min position monitor │
├─────────────────────────────────────────────┤
│ KrakenDataAdapter │
│ OHLC + ticker via kraken CLI │
├─────────────────────────────────────────────┤
│ StrategyEngine │
│ WaveRider + BB Squeeze + MACD Divergence │
│ + Regime Detection (ADX/BB/EMA) │
├─────────────────────────────────────────────┤
│ KrakenExecutor │
│ Paper buy/sell + SL/TP monitoring │
├─────────────────────────────────────────────┤
│ RiskManager │
│ Position sizing + daily/total limits │
├─────────────────────────────────────────────┤
│ ERC-8004 Identity │
│ Agent Card + Sepolia registration │
└─────────────────────────────────────────────┘
- Python 3.11+
- Kraken CLI —
krakencommand must be available in PATH (install guide) - numpy, pandas —
pip install -r requirements.txt - For ERC-8004 on-chain registration (optional):
cp .env.example .envand fill in your Sepolia wallet keys- Get Sepolia test ETH from Google Cloud Faucet or Chainlink Faucet
pip install web3or install Foundry forcastCLI
# Install dependencies
make install # or: pip install -r requirements.txt
# Run tests (63 tests)
make test # or: pytest tests/ -v --tb=short
# Check status
make status # or: python3 agent.py --status
# Run single scan (test)
make scan # or: python3 agent.py --single-scan
# Dry run — see signals without executing
make dry-run # or: python3 agent.py --dry-run
# Start main loop (4H scan + 5min monitor)
make run # or: python3 agent.py
# Reset paper balance
make reset # or: python3 agent.py --reset
# Generate ERC-8004 Agent Card
make card # or: python3 erc8004.py --generate-card
# Register on Sepolia
make register # or: python3 erc8004.py --register$ python3 agent.py --single-scan
2026-03-28 22:30:05 | INFO | Agent initialized | Balance: $100000.00 | Pairs: 6 | Scan interval: 4h
2026-03-28 22:30:05 | INFO | === Full Scan #1 ===
2026-03-28 22:30:05 | INFO | Portfolio value: $100000.00
2026-03-28 22:30:12 | INFO | [BTC/USDT] Regime: TRENDING_UP | ADX: 28.5
2026-03-28 22:30:14 | INFO | [ETH/USDT] Regime: RANGING | ADX: 18.2
2026-03-28 22:30:16 | INFO | [SOL/USDT] WaveRider LONG | Entry: $186.42 | SL: $180.15 | TP1: $193.28
2026-03-28 22:30:18 | INFO | Found 3 signals (2 long, 1 short)
2026-03-28 22:30:18 | INFO | Executed 2/2 long signals
$ python3 agent.py --status
============================================================
JudyAI WaveRider Trading Agent
============================================================
Paper Account:
Starting Balance: $100,000.00
Current Value: $100,014.65
Unrealized PnL: +$14.65 (+0.01%)
Total Trades: 3
Risk: 0/5 positions | Daily PnL: $0.00 | Scale: 100%
Positions: (none open)
$ python3 erc8004.py --show
{
"name": "JudyAI WaveRider",
"registrations": [{"agentId": 2328, ...}],
"performance": {"oosWinRate": 82.2, "strategies": 3},
"livePerformance": {"currentValue": 100014.65, "realizedPnl": 12.40}
}
| Pair | Long | Short | OOS Win Rate | Notes |
|---|---|---|---|---|
| BTC/USDT | Blacklisted | WaveRider | 75.4% | Long WFO OOS 40% — short only |
| ETH/USDT | WaveRider | WaveRider | 93.3% / 97.8% | |
| SOL/USDT | WaveRider | WaveRider | 72.5% / 75.9% | |
| XRP/USDT | WaveRider | WaveRider | 78.7% / 75.5% | |
| DOGE/USDT | Blacklisted | WaveRider | 87.8% | Long WR 30.3% — degraded |
| ADA/USDT | Observe | Observe | N/A | No OOS data — monitoring only |
Note: Kraken paper trading is spot-only. Short signals are used as exit indicators for open long positions rather than executed directly. Long positions are still opened during ranging/volatile regimes with reduced sizing and wider stop-losses to capture opportunities.
All strategy parameters are validated via Walk-Forward Optimization — no cherry-picked parameters:
- 360-day WFO period, 8 rolling windows (IS=90d, OOS=30d)
- Pass criteria: OOS Win Rate >= 65%, IS-OOS gap < 15%
- 366 out-of-sample trades across all combos
- Blacklisted pairs automatically excluded when OOS performance degrades
| Metric | Value |
|---|---|
| Expectancy per trade | +0.61R |
| Profit Factor | 3.79 |
| Max OOS Drawdown | -8.7% |
| Recovery Factor | 3.1 |
See docs/wfo_summary.md for full WFO methodology and per-pair results.
| File | Lines | Purpose |
|---|---|---|
agent.py |
463 | Main agent loop (4H scan + 5min monitor, crash recovery) |
strategies.py |
607 | Multi-strategy engine (WaveRider, BB Squeeze, MACD swing-point divergence) |
executor.py |
360 | Kraken paper execution (immutable Position, trailing stop via replace()) |
risk_manager.py |
182 | Portfolio risk controls |
kraken_data.py |
152 | Market data adapter |
kraken_cli.py |
36 | Shared Kraken CLI wrapper (DRY) |
erc8004.py |
65 | ERC-8004 CLI entry point + backward-compatible re-exports |
erc8004_card.py |
123 | Agent Card generation, save/load, live performance |
erc8004_chain.py |
337 | On-chain registration + reputation updates (web3.py / cast) |
erc8004_abi.py |
80 | ABI fragments for Identity & Reputation contracts |
config.py |
93 | Configuration (pairs, intervals, WFO parameters) |
tests/test_core.py |
576 | 48 unit tests: risk, indicators, strategy, SL/TP, ERC-8004, MACD swing |
tests/test_integration.py |
252 | 15 integration tests: data adapter, executor, position immutability |
docs/wfo_summary.md |
86 | Walk-Forward Optimization results + risk-adjusted metrics |
Dockerfile |
17 | Container image (Python 3.11-slim) |
Makefile |
34 | Build/test/run targets |
.env.example |
— | Environment variable template |
- Language: Python 3.11+
- Data: Kraken CLI (
kraken ohlc/ticker) - Execution: Kraken paper trading (
kraken paper buy/sell) - Indicators: numpy + pandas (no external TA library)
- Identity: ERC-8004 on Sepolia testnet (web3.py or Foundry
cast) - Container: Docker (python:3.11-slim)
- Tests: 63 tests (pytest) — 48 unit + 15 integration
- Source: Ported from judy-crypto (private, 12K+ lines)
# 1. Install + run tests
make install && make test
# 2. Check agent status and paper balance
make status
# 3. Run a single scan — shows signals and risk decisions
make scan
# 4. Generate ERC-8004 Agent Card
make card && make show
# 5. Register on Sepolia (needs test ETH in wallet)
make register
# 6. Start continuous loop (4H scans + 5min monitoring)
make runThe agent registers an on-chain identity following the ERC-8004 standard and posts realized PnL on-chain after every trade closure:
- Identity Registry (0x8004A818...): ERC-721 NFT per agent — portable, transferable
- Reputation Registry (0x8004B663...):
tradingYieldfeedback posted after each trade close (realized PnL, not unrealized) - Agent Card: JSON metadata synced on every state save — live performance, risk controls, capabilities
- Runtime integration:
agent.pyimportserc8004.pyand callsupdate_reputation()after SL/TP hits, short exits, and emergency closes
| Field | Value |
|---|---|
| Agent ID | 2328 |
| Identifier | eip155:11155111:0x8004A818BFB912233c491871b3d84c89A494BD9e:2328 |
| Chain | Sepolia (11155111) |
| Wallet | 0x95C8B49C2A6124C436EA1a3f378991313f6f1c0A |
| Registration TX | 0x348195e99e900014b2c48db4840dfed8b6693854444141b00f94c7c737fe93ac |
After registration, the agent posts PnL snapshots on-chain as reputation updates, building a verifiable trading track record.
Proprietary — JudyAI Lab 2026