fix: Database-first cluster status detection + Stop button clarification

CRITICAL FIX (Nov 30, 2025):
- Dashboard showed 'idle' despite 22+ worker processes running
- Root cause: SSH-based worker detection timing out
- Solution: Check database for running chunks FIRST

Changes:
1. app/api/cluster/status/route.ts:
   - Query exploration database before SSH detection
   - If running chunks exist, mark workers 'active' even if SSH fails
   - Override worker status: 'offline' → 'active' when chunks running
   - Log: ' Cluster status: ACTIVE (database shows running chunks)'
   - Database is source of truth, SSH only for supplementary metrics

2. app/cluster/page.tsx:
   - Stop button ALREADY EXISTS (conditionally shown)
   - Shows Start when status='idle', Stop when status='active'
   - No code changes needed - fixed by status detection

Result:
- Dashboard now shows 'ACTIVE' with 2 workers (correct)
- Workers show 'active' status (was 'offline')
- Stop button automatically visible when cluster active
- System resilient to SSH timeouts/network issues

Verified:
- Container restarted: Nov 30 21:18 UTC
- API tested: Returns status='active', activeWorkers=2
- Logs confirm: Database-first logic working
- Workers confirmed running: 22+ processes on worker1, workers on worker2
This commit is contained in:
mindesbunister
2025-11-30 22:23:01 +01:00
parent 83b4915d98
commit cc56b72df2
795 changed files with 312766 additions and 281 deletions

View File

@@ -0,0 +1,79 @@
================================================================================
V9 PARAMETER DIAGNOSTIC SUITE
================================================================================
Data: backtester/data/solusdt_5m_aug_nov.csv
Symbol: SOL-PERP
Loading data...
Loaded 34273 bars
============================================================
TEST 1: flip_threshold_percent (0.4, 0.5, 0.6, 0.7)
Expected: LOWER threshold = MORE signals
============================================================
Testing flip_threshold: 0%| | 0/4 [00:00<?, ?it/s]
Testing flip_threshold: 25%|██▌ | 1/4 [00:21<01:05, 21.71s/it]
Testing flip_threshold: 50%|█████ | 2/4 [00:42<00:42, 21.32s/it]
Testing flip_threshold: 75%|███████▌ | 3/4 [01:05<00:21, 21.82s/it]
Testing flip_threshold: 100%|██████████| 4/4 [01:25<00:00, 21.32s/it]
Testing flip_threshold: 100%|██████████| 4/4 [01:25<00:00, 21.43s/it]
flip_threshold=0.4: 581 trades, $-1852.60 PnL
flip_threshold=0.5: 581 trades, $-1852.60 PnL
flip_threshold=0.6: 581 trades, $-1852.60 PnL
flip_threshold=0.7: 581 trades, $-1852.60 PnL
============================================================
TEST 2: cooldown_bars (1, 2, 3, 4)
Expected: LOWER cooldown = MORE signals
============================================================
Testing cooldown_bars: 0%| | 0/4 [00:00<?, ?it/s]
Testing cooldown_bars: 25%|██▌ | 1/4 [00:20<01:01, 20.36s/it]
Testing cooldown_bars: 50%|█████ | 2/4 [00:40<00:40, 20.18s/it]
Testing cooldown_bars: 75%|███████▌ | 3/4 [01:01<00:20, 20.54s/it]
Testing cooldown_bars: 100%|██████████| 4/4 [01:21<00:00, 20.44s/it]
Testing cooldown_bars: 100%|██████████| 4/4 [01:21<00:00, 20.41s/it]
cooldown_bars=1: 581 trades, $-1835.05 PnL
cooldown_bars=2: 581 trades, $-1835.05 PnL
cooldown_bars=3: 581 trades, $-1852.60 PnL
cooldown_bars=4: 578 trades, $-2115.42 PnL
============================================================
TEST 3: momentum_min_adx (18, 21, 24, 27)
Expected: HIGHER ADX = FEWER signals
============================================================
Testing momentum_min_adx: 0%| | 0/4 [00:00<?, ?it/s]
Testing momentum_min_adx: 25%|██▌ | 1/4 [00:20<01:01, 20.52s/it]
Testing momentum_min_adx: 50%|█████ | 2/4 [00:41<00:41, 20.90s/it]
Testing momentum_min_adx: 75%|███████▌ | 3/4 [01:04<00:21, 21.76s/it]
Testing momentum_min_adx: 100%|██████████| 4/4 [01:26<00:00, 21.73s/it]
Testing momentum_min_adx: 100%|██████████| 4/4 [01:26<00:00, 21.54s/it]
momentum_min_adx=18.0: 581 trades, $-1852.60 PnL
momentum_min_adx=21.0: 581 trades, $-1852.60 PnL
momentum_min_adx=24.0: 581 trades, $-1852.60 PnL
momentum_min_adx=27.0: 581 trades, $-1852.60 PnL
============================================================
TEST 4: ma_gap_threshold (0.2, 0.3, 0.4, 0.5)
Expected: Different signal counts
============================================================
Testing ma_gap_threshold: 0%| | 0/4 [00:00<?, ?it/s]
Testing ma_gap_threshold: 25%|██▌ | 1/4 [00:20<01:02, 20.79s/it]
Testing ma_gap_threshold: 50%|█████ | 2/4 [00:43<00:44, 22.20s/it]
Testing ma_gap_threshold: 75%|███████▌ | 3/4 [01:06<00:22, 22.37s/it]
Testing ma_gap_threshold: 100%|██████████| 4/4 [01:27<00:00, 21.68s/it]
Testing ma_gap_threshold: 100%|██████████| 4/4 [01:27<00:00, 21.80s/it]
ma_gap_threshold=0.2: 581 trades, $-1852.60 PnL
ma_gap_threshold=0.3: 581 trades, $-1852.60 PnL
ma_gap_threshold=0.4: 581 trades, $-1852.60 PnL
ma_gap_threshold=0.5: 581 trades, $-1852.60 PnL
================================================================================
DIAGNOSTIC ANALYSIS
================================================================================
🔴 flip_threshold_percent: NO EFFECT - All configs produce identical results!
All 581 trades, $-1852.60 PnL
⚠️ Parameter is NOT being applied or is overridden