docs: Document Dec 1 adaptive leverage UI enhancements
- Updated adaptive leverage configuration section with current values (10x/5x) - Added Settings UI documentation with 5 configurable fields - Documented direction-specific thresholds (LONG/SHORT split) - Added dynamic collateral display implementation details - Documented new /api/drift/account-health endpoint - Added commit history for Dec 1 changes (2e511ce,21c13b9,a294f44,67ef5b1) - Updated API endpoints section with account-health route Changes reflect full UI implementation completed Dec 1, 2025: - Independent LONG (95) and SHORT (90) quality threshold controls - Real-time collateral fetching from Drift Protocol - Position size calculator with dynamic balance updates - Complete production-ready adaptive leverage system
This commit is contained in:
42
.github/copilot-instructions.md
vendored
42
.github/copilot-instructions.md
vendored
@@ -1727,7 +1727,8 @@ const { size, leverage } = getActualPositionSizeForSymbol(driftSymbol, config, q
|
||||
- `/api/trading/cancel-orders` - **Manual order cleanup** (for stuck/ghost orders after rate limit failures)
|
||||
- `/api/trading/positions` - Query open positions from Drift
|
||||
- `/api/trading/market-data` - Webhook for TradingView market data updates (GET for debug, POST for data)
|
||||
- `/api/settings` - Get/update config (writes to .env file, **includes per-symbol settings**)
|
||||
- `/api/drift/account-health` - **GET account metrics** (Dec 1, 2025) - Returns { totalCollateral, freeCollateral, totalLiability, marginRatio } from Drift Protocol for real-time UI display
|
||||
- `/api/settings` - Get/update config (writes to .env file, **includes per-symbol settings** and **direction-specific leverage thresholds**)
|
||||
- `/api/analytics/last-trade` - Fetch most recent trade details for dashboard (includes quality score)
|
||||
- `/api/analytics/reentry-check` - **Validate manual re-entry** with fresh TradingView data + recent performance
|
||||
- `/api/analytics/version-comparison` - Compare performance across signal quality logic versions (v1/v2/v3/v4)
|
||||
@@ -5224,22 +5225,41 @@ const tracker = new StopHuntTracker() // ❌ Don't do this
|
||||
- **Results:** $405.88 PnL, 569 trades, 60.98% WR, 1.022 PF, -$1,360.58 max DD
|
||||
- **Baseline established:** Nov 28, 2025
|
||||
|
||||
**Adaptive Leverage Implementation (Nov 28, 2025):**
|
||||
**Adaptive Leverage Implementation (Nov 28, 2025 - Updated Dec 1, 2025):**
|
||||
- **Purpose:** Increase profit potential while maintaining risk management
|
||||
- **Configuration:**
|
||||
- **CURRENT Configuration (Dec 1, 2025):**
|
||||
```bash
|
||||
USE_ADAPTIVE_LEVERAGE=true
|
||||
HIGH_QUALITY_LEVERAGE=5 # 5x for quality ≥95 LONGs, ≥90 SHORTs
|
||||
LOW_QUALITY_LEVERAGE=1 # 1x for borderline quality (Q90-94 LONGs, Q80-89 SHORTs)
|
||||
QUALITY_LEVERAGE_THRESHOLD=95
|
||||
HIGH_QUALITY_LEVERAGE=10 # 10x for high-quality signals
|
||||
LOW_QUALITY_LEVERAGE=5 # 5x for borderline signals
|
||||
QUALITY_LEVERAGE_THRESHOLD_LONG=95 # LONG quality threshold (configurable via UI)
|
||||
QUALITY_LEVERAGE_THRESHOLD_SHORT=90 # SHORT quality threshold (configurable via UI)
|
||||
QUALITY_LEVERAGE_THRESHOLD=95 # Backward compatibility fallback
|
||||
```
|
||||
- **Rationale:** User chose "option 1" (quality-based adaptive leverage) with 5x instead of 6x for "less risk"
|
||||
- **Settings UI (Dec 1, 2025 - FULLY IMPLEMENTED):**
|
||||
* Web interface at http://localhost:3001/settings
|
||||
* **Adaptive Leverage Section** with 5 configurable fields:
|
||||
- Enable/Disable toggle (USE_ADAPTIVE_LEVERAGE)
|
||||
- High Quality Leverage (10x default)
|
||||
- Low Quality Leverage (5x default)
|
||||
- **LONG Quality Threshold (95 default)** - independent control
|
||||
- **SHORT Quality Threshold (90 default)** - independent control
|
||||
* **Dynamic Collateral Display:** Fetches real-time balance from Drift account
|
||||
* **Position Size Calculator:** Shows notional positions for each leverage tier
|
||||
* **API Endpoint:** GET /api/drift/account-health returns { totalCollateral, freeCollateral, totalLiability, marginRatio }
|
||||
* **Real-time Updates:** Collateral fetched on page load via React useEffect
|
||||
* **Fallback:** Uses $560 if Drift API unavailable
|
||||
- **Direction-Specific Thresholds:**
|
||||
* LONGs: Quality ≥95 → 5x, Quality 90-94 → 1x
|
||||
* SHORTs: Quality ≥90 → 5x, Quality 80-89 → 1x
|
||||
* LONGs: Quality ≥95 → 10x, Quality 90-94 → 5x
|
||||
* SHORTs: Quality ≥90 → 10x, Quality 80-89 → 5x
|
||||
* Lower quality than thresholds → blocked by execute endpoint
|
||||
- **Expected Impact:** 5× profit on high-quality signals without increasing risk on borderline setups
|
||||
- **Status:** ✅ ACTIVE in production (container restarted Nov 28, 2025)
|
||||
- **Expected Impact:** 10× profit on high-quality signals, 5× on borderline (2× better than Nov 28 config)
|
||||
- **Status:** ✅ ACTIVE in production with full UI control (Dec 1, 2025)
|
||||
- **Commits:**
|
||||
* 2e511ce - Config update to 10x/5x (Dec 1 morning)
|
||||
* 21c13b9 - Initial adaptive leverage UI (Dec 1 afternoon)
|
||||
* a294f44 - Docker env vars for UI controls (Dec 1 afternoon)
|
||||
* 67ef5b1 - Direction-specific thresholds + dynamic collateral (Dec 1 evening)
|
||||
- **See:** `ADAPTIVE_LEVERAGE_SYSTEM.md` for implementation details
|
||||
|
||||
**Parameter Sweep Strategy:**
|
||||
|
||||
Reference in New Issue
Block a user