quant-trading-system
Complete quantitative trading stack with risk management, circuit breakers, and execution hooks
View on GitHubTable of content
Complete quantitative trading stack with risk management, circuit breakers, and execution hooks
Installation
npx claude-plugins install @jmanhype/multi-agent-intelligence-marketplace/quant-trading-system
Contents
Files: README.md, plugin.json
Documentation
Complete production-grade quantitative trading stack for cryptocurrency markets.
Features
๐ก๏ธ Safety First
- Circuit Breaker - Automatic failover to paper trading on risk/latency errors
- Kill Switch - Emergency stop all trading with one command
- Approval Guards - Manual approval required for live trades
- Pre-trade Validation - Risk checks before every execution
๐ Trading Infrastructure
- Risk Manager - Multi-layer risk validation and position sizing
- CCXT Integration - Support for 100+ cryptocurrency exchanges
- Metrics Tracking - Comprehensive trade logging and analytics
- Paper/Live Modes - Safe testing before going live
๐ Automated Workflows
- 5-Minute Loop - Continuous trading execution (configurable)
- Pre-Trade Hooks - Validation, risk checks, approvals
- Post-Trade Hooks - Logging, metrics, notifications
Installation
/plugin install quant-trading-system
Configuration
Required Environment Variables
EXCHANGE_API_KEY=your_api_key
EXCHANGE_SECRET=your_api_secret
Optional Configuration
PAPER_TRADING=true # Default: true (safe mode)
TRADE_INTERVAL=5 # Minutes between trades
MAX_POSITION_SIZE=1000 # Maximum position size in USD
RISK_LIMIT_PERCENT=2 # Max risk per trade (%)
Usage
Paper Trading (Safe)
# Hooks automatically enforce paper mode without PIN
/crypto-trader start
Live Trading (Requires Approval)
# Set environment
export PAPER_TRADING=false
# Start trading (will prompt for PIN via guard_approve.sh)
/crypto-trader start
Emergency Stop
# Immediately halt all trading
.claude/hooks/kill_switch.sh
Circuit Breaker
The circuit breaker automatically triggers when:
- Risk limits exceeded
- API latency > threshold
- Unexpected errors occur
- Loss limit reached
Status: Automatically flips to paper trading mode
Hooks
pre_trade.sh
Runs before every trade:
- Validates exchange connection
- Checks risk limits
- Verifies API keys
- Requires approval for live trades
post_trade.sh
Runs after every trade:
- Logs trade details to
logs/trades.jsonl - Updates metrics database
- Calculates P&L
- Sends notifications (if configured)
circuit_breaker.sh
Continuously monitors:
- API latency
- Error rates
- Position sizes
- P&L thresholds
Auto-recovery: Resumes paper trading after cooldown
Commands
/ccxt-exchange
CCXT exchange operations:
/ccxt-exchange balance # Check account balance
/ccxt-exchange ticker BTC/USDT # Get ticker data
/ccxt-exchange markets # List available markets
/metrics-write
Write custom metrics:
/metrics-write trade_count 42
/metrics-write total_pnl 1250.50
Safety Checklist
Before going live:
- Test in paper mode for 7+ days
- Verify risk limits are appropriate
- Set up kill switch access
- Configure notification alerts
- Review circuit breaker thresholds
- Backup API keys securely
- Document emergency procedures
Workflows
crypto-trader.md
5-minute trading loop:
- Fetch market data
- Run strategy signals
- Pre-trade validation
- Execute trades
- Post-trade logging
- Sleep until next interval
quant-trading-workflow.md
Complete workflow:
- Research phase (DSPy optimization)
- Backtesting
- Paper trading validation
- Gradual live deployment
- Continuous monitoring
Risk Management
The risk-manager agent enforces:
- Position Sizing - Kelly Criterion or fixed %
- Stop Losses - Automatic exit on loss threshold
- Take Profits - Lock in gains at targets
- Exposure Limits - Max total portfolio risk
- Correlation Limits - Avoid concentrated risk
Troubleshooting
Trade Rejected
Check:
pre_trade.shlogs in.claude/hooks/logs/- Risk limits in configuration
- Exchange API connectivity
- Account balance
Circuit Breaker Triggered
- Check
.claude/hooks/logs/circuit_breaker.json - Review error messages
- Wait for cooldown period
- Restart in paper mode
- Investigate root cause
Kill Switch Activated
- All positions immediately closed
- All orders cancelled
- System halted
- Manual intervention required to restart
Examples
Basic Setup
# Install plugin
/plugin install quant-trading-system
# Configure
export EXCHANGE_API_KEY=xxx
export EXCHANGE_SECRET=yyy
export PAPER_TRADING=true
# Start paper trading
/crypto-trader start
Production Deployment
# After successful paper trading
export PAPER_TRADING=false
export MAX_POSITION_SIZE=500
export RISK_LIMIT_PERCENT=1
# Start with approval guard
/crypto-trader start
# (Will prompt for PIN approval)
Monitoring
Logs stored in:
.claude/hooks/logs/
โโโ trades.jsonl # All trades
โโโ circuit_breaker.json # Circuit breaker events
โโโ pre_trade.json # Pre-trade validations
โโโ post_trade.json
...(truncated)
## Source
[View on GitHub](https://github.com/jmanhype/claude-code-plugin-marketplace)