@@ -126,17 +126,20 @@
- **Last Updated:** Jan 3, 2026 (TP1 fixed to 1.45%)
- **Last Updated:** Jan 3, 2026 (TP1 fixed to 1.45%)
### Adaptive Leverage System
### Adaptive Leverage System
- **Status:** ❌ DISABLED (Jan 2, 2026) - Using fixed leverage (SOL 10 x, ETH 5x)
- **Status:** ❌ DISABLED (Jan 2, 2026) - Using fixed leverage (SOL 5 x, ETH 5x)
- **Configuration:**
- **Configuration:**
* ` USE_ADAPTIVE_LEVERAGE=false`
* ` USE_ADAPTIVE_LEVERAGE=false`
* ` LEVERAGE=10 ` (global default)
* ` LEVERAGE=5 ` (global default)
* ` SOLANA _LEVERAGE=10 `
* ` BASE _LEVERAGE=5 `
* ` STACK_LEVERAGE=5`
* ` MAX_LEVERAGE_TOTAL=10`
* ` SOLANA_LEVERAGE=5`
* ` ETHEREUM_LEVERAGE=5`
* ` ETHEREUM_LEVERAGE=5`
* ` HIGH_QUALITY_LEVERAGE=10 `
* ` HIGH_QUALITY_LEVERAGE=5 `
* ` LOW_QUALITY_LEVERAGE=10 `
* ` LOW_QUALITY_LEVERAGE=5 `
- **Rationale:** 10x leverage justified by 82% WR, 2.18 PF, 6.19% max DD (Jan 2 , 2026 analysis)
- **Rationale:** Reduced from 10x to 5x (Jan 30 , 2026) for risk reduction
- **Previous Config:** Was 5x fixed (Dec 26, 2025)
- **Previous Config:** Was 10x fixed (Jan 2 - Jan 30, 2026), 5x fixed before that (Dec 26, 2025)
- **Last Updated:** Jan 2 , 2026
- **Last Updated:** Jan 30 , 2026
### Projection Page & Analytics Stats (Jan 13, 2026 - UPDATED)
### Projection Page & Analytics Stats (Jan 13, 2026 - UPDATED)
- **Purpose:** 12-month financial projection dashboard showing actual vs planned progress
- **Purpose:** 12-month financial projection dashboard showing actual vs planned progress
@@ -200,7 +203,7 @@ docker logs trading-bot-v4 | grep "Server starting" | head -1
| "I want to..." | Existing Feature | Search Term |
| "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"` |
| 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"` |
| Scale position by quality | **Adaptive Leverage System** - Currently disabled, fixed 5x leverage (Jan 30, 2026) | ` grep -i "adaptive leverage"` |
| Test different timeframes | **Multi-Timeframe Data Collection** - Parallel data collection for 5min/15min/1H/4H/Daily | ` grep -i "multi-timeframe"` |
| 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"` |
| 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"` |
| Survive server failures | **HA Failover** - Secondary server with auto DNS failover (90s detection) | ` grep -i "high availability"` |
@@ -1049,7 +1052,7 @@ When you have high-resolution data (1 minute), use it immediately. Arbitrary del
- **Trading P&L:** -$6 (early v6/v7 testing before v8 optimization)
- **Trading P&L:** -$6 (early v6/v7 testing before v8 optimization)
- **Target:** $2,500 by end of Phase 1 (Month 2.5) - 4.6x growth from current
- **Target:** $2,500 by end of Phase 1 (Month 2.5) - 4.6x growth from current
- **Strategy:** Aggressive compounding, 0 withdrawals, data-driven optimization
- **Strategy:** Aggressive compounding, 0 withdrawals, data-driven optimization
- **Position Sizing:** 100% of free collateral (~$540 at 1 5x leverage = ~$8,1 00 notional)
- **Position Sizing:** 100% of free collateral (~$540 at 5x leverage = ~$2,7 00 notional)
- **Risk Tolerance:** HIGH - Proof-of-concept mode with increased capital cushion
- **Risk Tolerance:** HIGH - Proof-of-concept mode with increased capital cushion
- **Win Target:** 15-20% monthly returns to reach $2,500 (more achievable with larger base)
- **Win Target:** 15-20% monthly returns to reach $2,500 (more achievable with larger base)
- **Trades Executed:** 170+ (as of Nov 19, 2025)
- **Trades Executed:** 170+ (as of Nov 19, 2025)
@@ -1139,8 +1142,8 @@ When you have high-resolution data (1 minute), use it immediately. Arbitrary del
- **Implementation:** Nov 24, 2025 (commit 9d7932f)
- **Implementation:** Nov 24, 2025 (commit 9d7932f)
**Per-Symbol Configuration:** SOL and ETH have independent enable/disable toggles and position sizing:
**Per-Symbol Configuration:** SOL and ETH have independent enable/disable toggles and position sizing:
- ` SOLANA_ENABLED`, ` SOLANA_POSITION_SIZE`, ` SOLANA_LEVERAGE` (defaults: true, 100%, 1 5x)
- ` SOLANA_ENABLED`, ` SOLANA_POSITION_SIZE`, ` SOLANA_LEVERAGE` (defaults: true, 100%, 5x)
- ` ETHEREUM_ENABLED`, ` ETHEREUM_POSITION_SIZE`, ` ETHEREUM_LEVERAGE` (defaults: true, 100%, 1 x)
- ` ETHEREUM_ENABLED`, ` ETHEREUM_POSITION_SIZE`, ` ETHEREUM_LEVERAGE` (defaults: true, 100%, 5 x)
- BTC and other symbols fall back to global settings (` MAX_POSITION_SIZE_USD`, ` LEVERAGE`)
- BTC and other symbols fall back to global settings (` MAX_POSITION_SIZE_USD`, ` LEVERAGE`)
- **Priority:** Per-symbol ENV → Market config → Global ENV → Defaults
- **Priority:** Per-symbol ENV → Market config → Global ENV → Defaults
@@ -1160,12 +1163,10 @@ Frequency penalties (overtrading / flip-flop / alternating) now ignore 1-minute
**Adaptive Leverage System (Nov 24, 2025 - RISK-ADJUSTED POSITION SIZING):**
**Adaptive Leverage System (Nov 24, 2025 - RISK-ADJUSTED POSITION SIZING):**
- **Purpose:** Automatically adjust leverage based on signal quality score - high confidence gets full leverage, borderline signals get reduced risk exposure
- **Purpose:** Automatically adjust leverage based on signal quality score - high confidence gets full leverage, borderline signals get reduced risk exposure
- **Quality-Based Leverage Tiers:**
- **Quality-Based Leverage Tiers:**
- **Quality 95-100:** 15x leverage ($540 × 15x = $8,100 notional position )
- **Currently disabled** - fixed 5x leverage for all signals (Jan 30, 2026 )
- **Quality 90-94:** 10x leverage ($540 × 10x = $5,400 notional position)
- **Previous tiers (historical):** Quality 95-100: 15x, Quality 90-94: 10x
- **Quality <90:** Blocked by direction-specific thresholds
- **Quality <90:** Blocked by direction-specific thresholds
- **Risk Impact:** Quality 90-94 signals save $2,700 exposure (33% risk reduction) vs fixed 15x
- **Configuration:** ` USE_ADAPTIVE_LEVERAGE=false`, ` LEVERAGE=5`, ` HIGH_QUALITY_LEVERAGE=5`, ` LOW_QUALITY_LEVERAGE=5` in .env
- **Data-Driven Justification:** v8 indicator quality 95+ = 100% WR (4/4 wins), quality 90-94 more volatile
- **Configuration:** ` USE_ADAPTIVE_LEVERAGE=true`, ` HIGH_QUALITY_LEVERAGE=15`, ` LOW_QUALITY_LEVERAGE=10`, ` QUALITY_LEVERAGE_THRESHOLD=95` in .env
- **Implementation:** Quality score calculated EARLY in execute endpoint (before position sizing), passed to ` getActualPositionSizeForSymbol(qualityScore)`, leverage determined via ` getLeverageForQualityScore()` helper
- **Implementation:** Quality score calculated EARLY in execute endpoint (before position sizing), passed to ` getActualPositionSizeForSymbol(qualityScore)`, leverage determined via ` getLeverageForQualityScore()` helper
- **Log Message:** ` 📊 Adaptive leverage: Quality X → Yx leverage (threshold: 95)`
- **Log Message:** ` 📊 Adaptive leverage: Quality X → Yx leverage (threshold: 95)`
- **Trade-off:** ~$21 less profit on borderline wins, but ~$21 less loss on borderline stops = better risk-adjusted returns
- **Trade-off:** ~$21 less profit on borderline wins, but ~$21 less loss on borderline stops = better risk-adjusted returns
@@ -2001,11 +2002,19 @@ docker logs trading-bot-v4 | grep "Server starting" | head -1
|------------|--------|----------|------|
|------------|--------|----------|------|
| Documentation (` .md`) | **NONE** | 0s | Just commit and push |
| Documentation (` .md`) | **NONE** | 0s | Just commit and push |
| Workflows (` .json`, ` .pinescript`) | **NONE** | 0s | Import manually to TradingView/n8n |
| Workflows (` .json`, ` .pinescript`) | **NONE** | 0s | Import manually to TradingView/n8n |
| ENV variables (` .env`) | **RESTART ** | 5-10s | ` docker compose restart trading-bot` |
| ENV variables (` .env`) | **RECREATE ** | 5-10s | ` docker compose up -d trading-bot` (NOT ` restart` — see below) |
| Database schema | **MIGRATE + RESTART** | 10-15s | ` prisma migrate + restart` |
| Database schema | **MIGRATE + RESTART** | 10-15s | ` prisma migrate + restart` |
| Code (` .ts`, ` .tsx`, ` .js`) | **REBUILD** | 40-70s | TypeScript must recompile |
| Code (` .ts`, ` .tsx`, ` .js`) | **REBUILD** | 40-70s | TypeScript must recompile |
| Dependencies (` package.json`) | **REBUILD** | 40-70s | npm install required |
| Dependencies (` package.json`) | **REBUILD** | 40-70s | npm install required |
**⚠️ PITFALL: ` docker compose restart` liest .env NICHT neu ein (Bug #90, Jan 30 2026)**
- ` docker-compose.yml` nutzt ` environment:` mit ` ${VAR:-default}` Syntax
- Diese Variablen werden nur bei ` docker compose up` ausgewertet, NICHT bei ` restart`
- ` restart` startet den Container mit den **alten** Environment-Variablen neu
- **Richtig:** ` docker compose up -d trading-bot` → recreated den Container mit neuen Werten
- **Falsch:** ` docker compose restart trading-bot` → alte .env-Werte bleiben aktiv
- **Verifizierung:** ` docker exec trading-bot-v4 env | grep VARIABLE` zeigt die tatsächlich aktiven Werte
**Smart Batching Strategy:**
**Smart Batching Strategy:**
- **DON'T:** Rebuild after every single code change (6× rebuilds = 6 minutes downtime)
- **DON'T:** Rebuild after every single code change (6× rebuilds = 6 minutes downtime)
- **DO:** Batch related changes together (6 fixes → 1 rebuild = 50 seconds total)
- **DO:** Batch related changes together (6 fixes → 1 rebuild = 50 seconds total)
@@ -2938,8 +2947,8 @@ MIN_TP1_PERCENT=0.5 # Don't go below 0.5% for TP1
MAX_TP1_PERCENT=1.5 # Don't go above 1.5% for TP1
MAX_TP1_PERCENT=1.5 # Don't go above 1.5% for TP1
MIN_TP2_PERCENT=1.0 # Don't go below 1.0% for TP2
MIN_TP2_PERCENT=1.0 # Don't go below 1.0% for TP2
MAX_TP2_PERCENT=3.0 # Don't go above 3.0% for TP2
MAX_TP2_PERCENT=3.0 # Don't go above 3.0% for TP2
MIN_SL_PERCENT=1.3 # Fixed SL (Jan 16, 2026 - optimized for 10 x leverage)
MIN_SL_PERCENT=1.3 # Fixed SL (Jan 16, 2026 - may need adjustment for 5 x leverage)
MAX_SL_PERCENT=1.3 # Fixed SL (Jan 16, 2026 - optimized for 10 x leverage)
MAX_SL_PERCENT=1.3 # Fixed SL (Jan 16, 2026 - may need adjustment for 5 x leverage)
# Legacy fallback (used when ATR unavailable)
# Legacy fallback (used when ATR unavailable)
STOP_LOSS_PERCENT=-1.3
STOP_LOSS_PERCENT=-1.3
@@ -3028,7 +3037,7 @@ const driftSymbol = normalizeTradingViewSymbol(body.symbol)
**Adaptive Leverage Configuration:**
**Adaptive Leverage Configuration:**
- **Helper function:** ` getLeverageForQualityScore(qualityScore, config)` returns leverage tier based on quality
- **Helper function:** ` getLeverageForQualityScore(qualityScore, config)` returns leverage tier based on quality
- **Quality threshold:** Configured via ` QUALITY_LEVERAGE_THRESHOLD` (default: 95)
- **Quality threshold:** Configured via ` QUALITY_LEVERAGE_THRESHOLD` (default: 95)
- **Leverage tiers:** HIGH_QUALITY_LEVERAGE (defaul t: 1 5x), LOW_QUALITY_LEVERAGE (defaul t: 10 x)
- **Leverage tiers:** HIGH_QUALITY_LEVERAGE (curren t: 5x), LOW_QUALITY_LEVERAGE (curren t: 5 x)
- **Integration:** Pass ` qualityScore` parameter to ` getActualPositionSizeForSymbol(symbol, config, qualityScore?)`
- **Integration:** Pass ` qualityScore` parameter to ` getActualPositionSizeForSymbol(symbol, config, qualityScore?)`
- **Flow:** Quality score → getLeverageForQualityScore() → returns 15x or 10x → applied to position sizing
- **Flow:** Quality score → getLeverageForQualityScore() → returns 15x or 10x → applied to position sizing
- **Logging:** System logs adaptive leverage decisions for monitoring and validation
- **Logging:** System logs adaptive leverage decisions for monitoring and validation
@@ -3036,7 +3045,7 @@ const driftSymbol = normalizeTradingViewSymbol(body.symbol)
// Example usage in execute endpoint
// Example usage in execute endpoint
const qualityResult = scoreSignalQuality({ atr, adx, rsi, volumeRatio, pricePosition, timeframe })
const qualityResult = scoreSignalQuality({ atr, adx, rsi, volumeRatio, pricePosition, timeframe })
const { size, leverage } = getActualPositionSizeForSymbol(driftSymbol, config, qualityResult.score)
const { size, leverage } = getActualPositionSizeForSymbol(driftSymbol, config, qualityResult.score)
// leverage is now 15x for quality ≥95, or 10x for quality 90-94
// leverage is currently fixed 5x (adaptive disabled since Jan 2, 2026)
` ``
` ``
## API Endpoints Architecture
## API Endpoints Architecture
@@ -6107,9 +6116,9 @@ model Trade {
` ``
` ``
**Core Logic Flow:**
**Core Logic Flow:**
1. **First signal** → Open position with 10 x leverage (` pyramidLevel: 1`)
1. **First signal** → Open position with 5 x leverage (` pyramidLevel: 1`)
2. **Second signal within 4 hours** → Check same direction + within window + under max levels
2. **Second signal within 4 hours** → Check same direction + within window + under max levels
3. **If valid** → Add 7 x position (` pyramidLevel: 2`, ` parentTradeId` = base trade ID)
3. **If valid** → Add 5 x position (` pyramidLevel: 2`, ` parentTradeId` = base trade ID)
4. **Position Manager** tracks pyramid group via ` pyramidGroups` Map
4. **Position Manager** tracks pyramid group via ` pyramidGroups` Map
5. **Exit** → Close ALL pyramid levels together via ` closeAllPyramidLevels()` (unified exit)
5. **Exit** → Close ALL pyramid levels together via ` closeAllPyramidLevels()` (unified exit)
@@ -6424,7 +6433,7 @@ const tracker = new StopHuntTracker() // ❌ Don't do this
- **CURRENT Configuration (Dec 1, 2025):**
- **CURRENT Configuration (Dec 1, 2025):**
` ``bash
` ``bash
USE_ADAPTIVE_LEVERAGE=true
USE_ADAPTIVE_LEVERAGE=true
HIGH_QUALITY_LEVERAGE=10 # 10 x for high-quality signals
HIGH_QUALITY_LEVERAGE=5 # 5 x for high-quality signals (reduced Jan 30, 2026)
LOW_QUALITY_LEVERAGE=5 # 5x for borderline signals
LOW_QUALITY_LEVERAGE=5 # 5x for borderline signals
QUALITY_LEVERAGE_THRESHOLD_LONG=95 # LONG quality threshold (configurable via UI)
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_SHORT=90 # SHORT quality threshold (configurable via UI)