Merge remote-tracking branch 'github/master'
This commit is contained in:
142
.github/copilot-instructions.md
vendored
142
.github/copilot-instructions.md
vendored
@@ -34,6 +34,148 @@
|
||||
|
||||
---
|
||||
|
||||
## 🔍 "DO I ALREADY HAVE THIS?" - Quick Feature Discovery
|
||||
|
||||
**Before implementing ANY feature, check if it already exists!** This system has 70+ features built over months of development.
|
||||
|
||||
### Quick Reference Table
|
||||
|
||||
| "I want to..." | Existing Feature | Search Term |
|
||||
|----------------|------------------|-------------|
|
||||
| Re-enter after stop-out | **Stop Hunt Revenge System** - Auto re-enters quality 85+ signals after price reverses through original entry | `grep -i "stop hunt revenge"` |
|
||||
| Scale position by quality | **Adaptive Leverage System** - 10x for quality 95+, 5x for borderline signals | `grep -i "adaptive leverage"` |
|
||||
| Test different timeframes | **Multi-Timeframe Data Collection** - Parallel data collection for 5min/15min/1H/4H/Daily | `grep -i "multi-timeframe"` |
|
||||
| Monitor blocked signals | **BlockedSignal Tracker** - Tracks quality-blocked signals with price analysis | `grep -i "blockedsignal"` |
|
||||
| Survive server failures | **HA Failover** - Secondary server with auto DNS failover (90s detection) | `grep -i "high availability"` |
|
||||
| Validate re-entries | **Re-Entry Analytics System** - Fresh TradingView data + recent performance scoring | `grep -i "re-entry analytics"` |
|
||||
| Backtest parameters | **Distributed Cluster Backtester** - 65,536 combo sweep on EPYC cluster | `grep -i "cluster\|backtester"` |
|
||||
| Handle RPC rate limits | **Retry with Exponential Backoff** - 5s → 10s → 20s retry for 429 errors | `grep -i "retryWithBackoff"` |
|
||||
| Track best/worst P&L | **MAE/MFE Tracking** - Built into Position Manager, updated every 2s | `grep -i "mae\|mfe"` |
|
||||
|
||||
### Quick Search Commands
|
||||
|
||||
```bash
|
||||
# Search main documentation
|
||||
grep -i "KEYWORD" .github/copilot-instructions.md
|
||||
|
||||
# Search all documentation
|
||||
grep -ri "KEYWORD" docs/
|
||||
|
||||
# Check live system logs
|
||||
docker logs trading-bot-v4 | grep -i "KEYWORD" | tail -20
|
||||
|
||||
# List database tables (shows what data is tracked)
|
||||
docker exec trading-bot-postgres psql -U postgres -d trading_bot_v4 -c "\dt"
|
||||
|
||||
# Check environment variables
|
||||
cat .env | grep -i "KEYWORD"
|
||||
|
||||
# Search codebase
|
||||
grep -r "KEYWORD" lib/ app/ --include="*.ts"
|
||||
```
|
||||
|
||||
### Feature Discovery by Category
|
||||
|
||||
**📊 Entry/Exit Logic:**
|
||||
- ATR-based TP/SL (dynamic targets based on volatility)
|
||||
- TP2-as-runner (40% runner after TP1, configurable)
|
||||
- ADX-based runner SL (adaptive positioning by trend strength)
|
||||
- Adaptive trailing stop (real-time 1-min ADX adjustments)
|
||||
- Emergency stop (-2% hard limit)
|
||||
|
||||
**🛡️ Risk Management:**
|
||||
- Adaptive leverage (quality-based position sizing)
|
||||
- Direction-specific thresholds (LONG 90+, SHORT 80+)
|
||||
- Per-symbol sizing (SOL/ETH independent controls)
|
||||
- Phantom trade auto-closure (size mismatch detection)
|
||||
- Dual stops (soft TRIGGER_LIMIT + hard TRIGGER_MARKET)
|
||||
|
||||
**🔄 Re-Entry & Recovery:**
|
||||
- Stop Hunt Revenge (auto re-entry after reversal)
|
||||
- Re-Entry Analytics (validation with fresh data)
|
||||
- Market Data Cache (5-min expiry TradingView data)
|
||||
|
||||
**📈 Monitoring & Analysis:**
|
||||
- Position Manager (2s price checks, MAE/MFE tracking)
|
||||
- BlockedSignal Tracker (quality-blocked signal analysis)
|
||||
- Multi-timeframe collection (parallel data gathering)
|
||||
- Rate limit monitoring (429 error tracking + analytics)
|
||||
- Drift health monitor (memory leak detection + auto-restart)
|
||||
|
||||
**🏗️ High Availability:**
|
||||
- Secondary server (Hostinger standby)
|
||||
- Database replication (PostgreSQL streaming)
|
||||
- DNS auto-failover (90s detection via INWX API)
|
||||
- Orphan position recovery (startup validation)
|
||||
|
||||
**🔧 Developer Tools:**
|
||||
- Distributed cluster (EPYC parameter sweep)
|
||||
- Test suite (113 tests, 7 test files)
|
||||
- CI/CD pipeline (GitHub Actions)
|
||||
- Persistent logger (survives container restarts)
|
||||
|
||||
### Decision Flowchart: Does This Feature Exist?
|
||||
|
||||
```
|
||||
┌─────────────────────────────────────────────────────────────┐
|
||||
│ 1. Search copilot-instructions.md │
|
||||
│ grep -i "feature-name" .github/copilot-instructions.md │
|
||||
│ │ │
|
||||
│ ▼ │
|
||||
│ Found? ──YES──► READ THE SECTION │
|
||||
│ │ │
|
||||
│ NO │
|
||||
│ ▼ │
|
||||
│ 2. Search docs/ directory │
|
||||
│ grep -ri "feature-name" docs/ │
|
||||
│ │ │
|
||||
│ ▼ │
|
||||
│ Found? ──YES──► READ THE DOCUMENTATION │
|
||||
│ │ │
|
||||
│ NO │
|
||||
│ ▼ │
|
||||
│ 3. Check database schema │
|
||||
│ cat prisma/schema.prisma | grep -i "related-table" │
|
||||
│ │ │
|
||||
│ ▼ │
|
||||
│ Found? ──YES──► FEATURE LIKELY EXISTS │
|
||||
│ │ │
|
||||
│ NO │
|
||||
│ ▼ │
|
||||
│ 4. Check docker logs │
|
||||
│ docker logs trading-bot-v4 | grep -i "feature" | tail │
|
||||
│ │ │
|
||||
│ ▼ │
|
||||
│ Found? ──YES──► FEATURE IS ACTIVE │
|
||||
│ │ │
|
||||
│ NO │
|
||||
│ ▼ │
|
||||
│ 5. Check git history │
|
||||
│ git log --oneline --all | grep -i "feature" | head -10 │
|
||||
│ │ │
|
||||
│ ▼ │
|
||||
│ Found? ──YES──► MAY BE ARCHIVED/DISABLED │
|
||||
│ │ │
|
||||
│ NO │
|
||||
│ ▼ │
|
||||
│ FEATURE DOES NOT EXIST - SAFE TO BUILD │
|
||||
└─────────────────────────────────────────────────────────────┘
|
||||
```
|
||||
|
||||
### Why This Matters: Historical Examples
|
||||
|
||||
| Feature | Built Date | Trigger Event | Value |
|
||||
|---------|------------|---------------|-------|
|
||||
| **Stop Hunt Revenge** | Nov 20, 2025 | Quality 90 signal stopped out, missed $490 profit on 8.8% reversal | Captures reversal moves |
|
||||
| **Adaptive Leverage** | Nov 24, 2025 | Quality 95+ signals had 100% win rate, wanted to scale winners | 2× profit on high quality |
|
||||
| **HA Failover** | Nov 25, 2025 | Server went down during active trades | Zero-downtime protection |
|
||||
| **Phantom Detection** | Nov 16, 2025 | Position opened with wrong size, no monitoring | Prevents unprotected positions |
|
||||
| **BlockedSignal Tracker** | Nov 22, 2025 | Needed data to optimize quality thresholds | Data-driven threshold tuning |
|
||||
|
||||
**Don't rebuild what exists. Enhance what's proven.**
|
||||
|
||||
---
|
||||
|
||||
## ⚠️ CRITICAL: VERIFICATION MANDATE - READ THIS FIRST ⚠️
|
||||
|
||||
**THIS IS A REAL MONEY TRADING SYSTEM - EVERY CHANGE AFFECTS USER'S FINANCIAL FUTURE**
|
||||
|
||||
Reference in New Issue
Block a user