feat: ATR-based trailing stop + rate limit monitoring

MAJOR FIXES:
- ATR-based trailing stop for runners (was fixed 0.3%, now adapts to volatility)
- Fixes runners with +7-9% MFE exiting for losses
- Typical improvement: 2.24x more room (0.3% → 0.67% at 0.45% ATR)
- Enhanced rate limit logging with database tracking
- New /api/analytics/rate-limits endpoint for monitoring

DETAILS:
- Position Manager: Calculate trailing as (atrAtEntry / price × 100) × multiplier
- Config: TRAILING_STOP_ATR_MULTIPLIER=1.5, MIN=0.25%, MAX=0.9%
- Settings UI: Added ATR multiplier controls
- Rate limits: Log hits/recoveries/exhaustions to SystemEvent table
- Documentation: ATR_TRAILING_STOP_FIX.md + RATE_LIMIT_MONITORING.md

IMPACT:
- Runners can now capture big moves (like morning's $172→$162 SOL drop)
- Rate limit visibility prevents silent failures
- Data-driven optimization for RPC endpoint health
This commit is contained in:
mindesbunister
2025-11-11 14:51:41 +01:00
parent 0700daf8ff
commit 03e91fc18d
9 changed files with 577 additions and 7 deletions

View File

@@ -64,6 +64,14 @@ TAKE_PROFIT_2_PERCENT=1.5
# Move SL to breakeven when profit reaches this level
BREAKEVEN_TRIGGER_PERCENT=0.4
# ATR-based Trailing Stop (for 25% runner after TP2)
# Trailing distance = (ATR × multiplier)
# Example: 0.5% ATR × 1.5 = 0.75% trailing (more room than fixed 0.3%)
TRAILING_STOP_ATR_MULTIPLIER=1.5
TRAILING_STOP_MIN_PERCENT=0.25
TRAILING_STOP_MAX_PERCENT=0.9
TRAILING_STOP_ACTIVATION=0.5
# Risk limits
# Stop trading if daily loss exceeds this amount (USD)
MAX_DAILY_DRAWDOWN=-50