Commit Graph

43 Commits

Author SHA1 Message Date
mindesbunister
a669058636 docs: V11 progressive sweep results - 1,024 configs complete
SWEEP COMPLETED: 33.2 minutes, 4 workers, ALL 1,024 configs tested

KEY FINDINGS:
 NO zero-signal configs (flip_threshold fix successful)
 Top strategy: 1.97 PF, 74.7% WR, $2,416 PnL (766 trades)
 5× better P&L than v9 baseline ($405 → $2,416)
 96% less drawdown than v9 (-$1,360 → -$55)

CRITICAL ANOMALY DISCOVERED:
 flip_threshold=0.35/0.40 generating 3-4× FEWER signals than expected
  - flip=0.30: 1,271 avg signals (Worker1) ✓
  - flip=0.35: 304 avg signals (Worker2) ⚠️
  - flip=0.40: 276 avg signals (Worker2) ⚠️
  - flip=0.45: 920 avg signals (Worker1) ✓

Expected: 0.30 > 0.35 > 0.40 > 0.45 (linear decrease)
Actual: 0.30 (1,271) > 0.45 (920) > 0.35 (304) > 0.40 (276)

Possible causes:
1. Indicator bug in mid-range flip detection
2. Worker2 deployment issue (stale code?)
3. Dataset artifact (2024 SOL specific pattern)

OPTIMAL PRODUCTION CONFIG:
- flip_threshold=0.45 (all top 10 use this)
- adx_min=15 (strictest filter, all top 10)
- long_pos_max=95, short_pos_min=5 (permissive)
- vol_min=0.0 (no volume filter)
- RSI parameters DON'T MATTER (identical results)

ADX FILTER VALIDATION:
 adx=0: 1,162 signals (most, as expected)
 adx=5: 582 signals (50% reduction)
 adx=10: 572 signals (similar to adx=5)
 adx=15: 455 signals (least, as expected)

NEXT STEPS:
1. Investigate flip=0.35/0.40 anomaly (re-run on Worker1)
2. Forward test flip=0.45, adx=15 config on 2025 data
3. Deploy to production if validation passes

Files:
- cluster/V11_SWEEP_RESULTS.md (comprehensive analysis)
- cluster/v11_results/*.csv (local copies of all 4 chunks)
2025-12-07 00:34:49 +01:00
copilot-swe-agent[bot]
5e21028c5e fix: Replace flip_threshold=0.5 with working values [0.3, 0.35, 0.4, 0.45]
- Updated PARAMETER_GRID in v11_test_worker.py
- Changed from 2 flip_threshold values to 4 values
- Total combinations: 1024 (4×4×2×2×2×2×2×2)
- Updated coordinator to create 4 chunks (256 combos each)
- Updated all documentation to reflect 1024 combinations
- All values below critical 0.5 threshold that produces 0 signals
- Expected signal counts: 0.3 (1400+), 0.35 (1200+), 0.4 (1100+), 0.45 (800+)
- Created FLIP_THRESHOLD_FIX.md with complete analysis

Co-authored-by: mindesbunister <32161838+mindesbunister@users.noreply.github.com>
2025-12-06 22:40:16 +00:00
mindesbunister
dcd72fb8d1 docs: Document flip_threshold=0.5 zero signals discovery
CRITICAL FINDING - Parameter Value Investigation Required:
- Worker1 (flip_threshold=0.4): 1,096-1,186 signals per config ✓
- Worker2 (flip_threshold=0.5): 0 signals for ALL 256 configs ✗
- Statistical significance: 100% failure rate (256/256 combos)
- Evidence: flip_threshold increased 0.4→0.5 eliminates ALL signals

Impact:
- Parallel deployment working perfectly (both workers active) ✓
- But 50% of parameter space unusable (flip_threshold=0.5)
- Effectively 256-combo sweep, not 512-combo sweep

Possible causes:
1. Bug in v11 flip_threshold logic (threshold check inverted?)
2. Parameter too strict (0.5% EMA diff never occurs in 2024 SOL data)
3. Dataset incompatibility (need higher volatility or different timeframe)

Next steps:
- Wait for worker1 completion (~5 min)
- Analyze flip_threshold=0.4 results to confirm viability
- Investigate v11_moneyline_all_filters.py flip_threshold implementation
- Consider adjusted grid: [0.3, 0.35, 0.4, 0.45] instead of [0.4, 0.5]

Files:
- cluster/FLIP_THRESHOLD_0.5_ZERO_SIGNALS.md (full analysis)
- cluster/PARALLEL_DEPLOYMENT_ACHIEVED.md (parallel execution docs)
2025-12-06 23:21:38 +01:00
mindesbunister
3fc161a695 fix: Enable parallel worker deployment with subprocess.Popen + deploy to workspace root
CRITICAL FIX - Parallel Execution Now Working:
- Problem: coordinator blocked on subprocess.run(ssh_cmd) preventing worker2 deployment
- Root cause #1: subprocess.run() waits for SSH FDs even with 'nohup &' and '-f' flag
- Root cause #2: Indicator deployed to backtester/ subdirectory instead of workspace root
- Solution #1: Replace subprocess.run() with subprocess.Popen() + communicate(timeout=2)
- Solution #2: Deploy v11_moneyline_all_filters.py to workspace root for direct import
- Result: Both workers start simultaneously (worker1 chunk 0, worker2 chunk 1)
- Impact: 2× speedup achieved (15 min vs 30 min sequential)

Verification:
- Worker1: 31 processes, generating 1,125+ signals per config ✓
- Worker2: 29 processes, generating 848-898 signals per config ✓
- Coordinator: Both chunks active, parallel deployment in 12 seconds ✓

User concern addressed: 'if we are not using them in parallel how are we supposed
to gain a time advantage?' - Now using them in parallel, gaining 2× advantage.

Files modified:
- cluster/v11_test_coordinator.py (lines 287-301: Popen + timeout, lines 238-255: workspace root)
2025-12-06 23:17:45 +01:00
mindesbunister
4291f31e64 fix: v11 worker missing use_quality_filters + RSI bounds + wrong import path
THREE critical bugs in cluster/v11_test_worker.py:

1. Missing use_quality_filters parameter when creating MoneyLineV11Inputs
   - Parameter defaults to True but wasn't being passed explicitly
   - Fix: Added use_quality_filters=True to inputs creation

2. Missing fixed RSI parameters (rsi_long_max, rsi_short_min)
   - Worker only passed rsi_long_min and rsi_short_max (sweep params)
   - Missing rsi_long_max=70 and rsi_short_min=30 (fixed params)
   - Fix: Added both fixed parameters to inputs creation

3. Import path mismatch - worker imported OLD version
   - Worker added cluster/ to sys.path, imported from parent directory
   - Old v11_moneyline_all_filters.py (21:40) missing use_quality_filters
   - Fixed v11_moneyline_all_filters.py was in backtester/ subdirectory
   - Fix: Deployed corrected file to /home/comprehensive_sweep/

Result: 0 signals → 1,096-1,186 signals per config ✓

Verified: Local test (314 signals), EPYC dataset test (1,186 signals),
Worker log now shows signal variety across 27 concurrent configs.

Progressive sweep now running successfully on EPYC cluster.
2025-12-06 22:52:35 +01:00
copilot-swe-agent[bot]
468e4a22c9 docs: Add v11 progressive sweep quick start guide
Co-authored-by: mindesbunister <32161838+mindesbunister@users.noreply.github.com>
2025-12-06 20:34:15 +00:00
copilot-swe-agent[bot]
f678a027c2 feat: Implement v11 progressive parameter sweep starting from zero filters
Co-authored-by: mindesbunister <32161838+mindesbunister@users.noreply.github.com>
2025-12-06 20:30:57 +00:00
mindesbunister
e97ab483e4 fix: v11 test sweep - performance fix + multiprocessing fix
Critical fixes applied:
1. Performance: Converted pandas .iloc[] to numpy arrays in supertrend_v11() (100x speedup)
2. Multiprocessing: Changed to load CSV per worker instead of pickling 95k row dataframe
3. Import paths: Fixed backtester module imports for deployment
4. Deployment: Added backtester/ directory to EPYC cluster

Result: v11 test sweep now completes (4 workers tested, 129 combos in 5 min)

Next: Deploy with MAX_WORKERS=27 for full 256-combo sweep
2025-12-06 21:15:51 +01:00
copilot-swe-agent[bot]
29f6c983bb docs: Add ASCII architecture diagram for v11 test sweep system
Co-authored-by: mindesbunister <32161838+mindesbunister@users.noreply.github.com>
2025-12-06 19:22:15 +00:00
copilot-swe-agent[bot]
1bebd0f599 docs: Add v11 implementation summary - project complete and ready to deploy
Co-authored-by: mindesbunister <32161838+mindesbunister@users.noreply.github.com>
2025-12-06 19:20:17 +00:00
copilot-swe-agent[bot]
73887ac4f3 docs: Add comprehensive v11 test sweep documentation and deployment script
Co-authored-by: mindesbunister <32161838+mindesbunister@users.noreply.github.com>
2025-12-06 19:18:37 +00:00
copilot-swe-agent[bot]
4599afafaa chore: Add Python cache files to .gitignore and remove from repo
Co-authored-by: mindesbunister <32161838+mindesbunister@users.noreply.github.com>
2025-12-06 19:16:46 +00:00
copilot-swe-agent[bot]
eb0d41aed5 feat: Add v11 test sweep system (256 combinations) with office hours scheduling
Co-authored-by: mindesbunister <32161838+mindesbunister@users.noreply.github.com>
2025-12-06 19:15:54 +00:00
mindesbunister
eefee98818 docs: Document BlockedSignal data contamination from old v9 alerts
- Discovery: All TradingView alerts (5min/15min/1H/4H/Daily) attached to OLD v9 version
- Impact: 11,429 records from wrong indicator settings (confirmBars=0 vs current)
- Solution: Marked as DATA_COLLECTION_OLD_V9_VERSION to prevent analysis contamination
- Exception: 1-minute data (11,398) kept as DATA_COLLECTION_ONLY (unaffected)
- Fresh data from corrected alerts will use DATA_COLLECTION_ONLY going forward
- Old data preserved for historical reference, clearly marked
2025-12-05 10:37:01 +01:00
mindesbunister
a15f17f489 revert: Undo exit strategy optimization based on corrupted MFE data
CRITICAL DATA BUG DISCOVERED (Dec 5, 2025):
Previous commits a67a338 and f65aae5 implemented optimizations based on
INCORRECT analysis of maxFavorableExcursion (MFE) data.

Problem: Old Trade records stored MFE in DOLLARS, not PERCENTAGES
- Appeared to show 20%+ average favorable movement
- Actually only 0.76% (long) and 1.20% (short) average movement
- 26× inflation of perceived performance due to unit mismatch

Incorrect Changes Reverted:
- ATR_MULTIPLIER_TP1: 1.5 → back to 2.0
- ATR_MULTIPLIER_TP2: 3.0 → back to 4.0
- ATR_MULTIPLIER_SL: 2.5 → back to 3.0
- TAKE_PROFIT_1_SIZE_PERCENT: 75 → back to 60
- LEVERAGE: 5 → back to 1
- Safety bounds restored to original values
- TRAILING_STOP_ATR_MULTIPLIER: back to 2.5

REAL FINDINGS (after data correction):
- TP1 orders ARE being placed (tp1OrderTx populated)
- TP1 prices NOT being reached (only 2/11 trades in sample)
- Recent trades (6 total): avg MFE 0.74%, only 2/6 reached TP1
- Problem is ENTRY QUALITY, not exit timing
- Quality 90+ signals barely move favorably before reversing

See Common Pitfall #54 - MFE data stored in mixed units
Need to filter by createdAt >= '2025-11-23' for accurate analysis
2025-12-05 10:05:39 +01:00
mindesbunister
a67a338d18 critical: Optimize exit strategy based on data analysis (Dec 5, 2025)
PROBLEM DISCOVERED:
- Average MFE: 17-24% (massive favorable moves happening)
- But win rate only 15.8% (we capture NONE of it)
- Blocked signals analysis: avg MFE 0.49% (correctly filtered)
- Executed signals: targets being hit but reversing before monitoring loop detects

ROOT CAUSE:
- ATR multipliers too aggressive (2x/4x)
- Targets hit during spike, price reverses before 2s monitoring loop
- Position Manager software monitoring has inherent delay
- Need TIGHTER targets to catch moves before reversal

SOLUTION IMPLEMENTED:
1. ATR Multipliers REDUCED:
   - TP1: 2.0× → 1.5× (catch moves earlier)
   - TP2: 4.0× → 3.0× (still allows trends)
   - SL: 3.0× → 2.5× (tighter protection)

2. Safety Bounds OPTIMIZED:
   - TP1: 0.4-1.0% (was 0.5-1.5%)
   - TP2: 0.8-2.5% (was 1.0-3.0%)
   - SL: 0.7-1.8% (was 0.8-2.0%)

3. Position Sizing ADJUSTED:
   - TP1 close: 60% → 75% (bank more profit immediately)
   - Runner: 40% → 25% (smaller risk on extended moves)
   - Leverage: 1x → 5x (moderate increase, still safe during testing)

4. Trailing Stop TIGHTENED:
   - ATR multiplier: 2.5× → 1.5×
   - Min distance: 0.25% → 0.20%
   - Max distance: 2.5% → 1.5%

EXPECTED IMPACT:
- TP1 hit rate: 0% → 40-60% (catch moves before reversal)
- Runner protection: Tighter trail prevents giving back gains
- Lower leverage keeps risk manageable during testing
- Once TP1 hit rate improves, can increase leverage back to 10x

DATA SUPPORTING CHANGES:
- Blocked signals (80-89 quality): 16.7% WR, 0.37% avg MFE
- Executed signals (90+ quality): 15.8% WR, 20.15% avg MFE
- Problem is NOT entry selection (quality filter working)
- Problem IS exit timing (massive MFE not captured)

Files modified:
- .env: ATR multipliers, safety bounds, TP1 size, trailing config, leverage
2025-12-05 09:53:46 +01:00
mindesbunister
302511293c feat: Add production logging gating (Phase 1, Task 1.1)
- Created logger utility with environment-based gating (lib/utils/logger.ts)
- Replaced 517 console.log statements with logger.log (71% reduction)
- Fixed import paths in 15 files (resolved comment-trapped imports)
- Added DEBUG_LOGS=false to .env
- Achieves 71% immediate log reduction (517/731 statements)
- Expected 90% reduction in production when deployed

Impact: Reduced I/O blocking, lower log volume in production
Risk: LOW (easy rollback, non-invasive)
Phase: Phase 1, Task 1.1 (Quick Wins - Console.log Production Gating)

Files changed:
- NEW: lib/utils/logger.ts (production-safe logging)
- NEW: scripts/replace-console-logs.js (automation tool)
- Modified: 15 lib/*.ts files (console.log → logger.log)
- Modified: .env (DEBUG_LOGS=false)

Next: Task 1.2 (Image Size Optimization)
2025-12-05 00:32:41 +01:00
mindesbunister
09825782bb feat: Bypass quality scoring for manual Telegram trades
User requirement: Manual long/short commands via Telegram shall execute
immediately without quality checks.

Changes:
- Execute endpoint now checks for timeframe='manual' flag
- Added isManualTrade bypass alongside isValidatedEntry bypass
- Manual trades skip quality threshold validation completely
- Logs show 'MANUAL TRADE BYPASS' for transparency

Impact: Telegram commands (long sol, short eth) now execute instantly
without being blocked by low quality scores.

Commit: Dec 4, 2025
2025-12-04 19:56:17 +01:00
mindesbunister
c4cc16ede2 docs: EPYC cluster status report Dec 4, 2025
- Worker2 time restriction implementation complete
- Stuck chunk 14 resolved
- Performance impact analysis
- Monitoring commands and verification tests
- Expected behavior documentation
2025-12-04 15:19:21 +01:00
mindesbunister
f2f2992a98 fix: Add is_worker_allowed_to_run function definition
Function was referenced but not defined - added implementation
2025-12-04 15:16:18 +01:00
mindesbunister
0babd1ea1a docs: Add worker2 time restriction documentation
- Complete guide for noise constraint management
- Time-based scheduling logic explained
- Performance impact analysis (27% reduction)
- Monitoring commands and troubleshooting
- Fixed stuck chunk 14 documentation
2025-12-04 14:12:09 +01:00
mindesbunister
f40fd66486 feat: Add time-restricted scheduling for worker2 (noise constraint)
- Worker2 (bd-host01) now only runs 19:00-06:00 due to noise
- Added is_worker_allowed_to_run() function for time-based control
- Worker1 continues 24/7 operation
- Reset stuck chunk 14 that was blocking progress since Dec 2
2025-12-04 14:12:00 +01:00
mindesbunister
dc674ec6d5 docs: Add 1-minute simplified price feed to reduce TradingView alert queue pressure
- Create moneyline_1min_price_feed.pinescript (70% smaller payload)
- Remove ATR/ADX/RSI/VOL/POS from 1-minute alerts (not used for decisions)
- Keep only price + symbol + timeframe for market data cache
- Document rationale in docs/1MIN_SIMPLIFIED_FEED.md
- Fix: 5-minute trading signals being dropped due to 1-minute flood (60/hour)
- Impact: Preserve priority for actual trading signals
2025-12-04 11:19:04 +01:00
mindesbunister
4c36fa2bc3 docs: Major documentation reorganization + ENV variable reference
**Documentation Structure:**
- Created docs/ subdirectory organization (analysis/, architecture/, bugs/,
  cluster/, deployments/, roadmaps/, setup/, archived/)
- Moved 68 root markdown files to appropriate categories
- Root directory now clean (only README.md remains)
- Total: 83 markdown files now organized by purpose

**New Content:**
- Added comprehensive Environment Variable Reference to copilot-instructions.md
- 100+ ENV variables documented with types, defaults, purpose, notes
- Organized by category: Required (Drift/RPC/Pyth), Trading Config (quality/
  leverage/sizing), ATR System, Runner System, Risk Limits, Notifications, etc.
- Includes usage examples (correct vs wrong patterns)

**File Distribution:**
- docs/analysis/ - Performance analyses, blocked signals, profit projections
- docs/architecture/ - Adaptive leverage, ATR trailing, indicator tracking
- docs/bugs/ - CRITICAL_*.md, FIXES_*.md bug reports (7 files)
- docs/cluster/ - EPYC setup, distributed computing docs (3 files)
- docs/deployments/ - *_COMPLETE.md, DEPLOYMENT_*.md status (12 files)
- docs/roadmaps/ - All *ROADMAP*.md strategic planning files (7 files)
- docs/setup/ - TradingView guides, signal quality, n8n setup (8 files)
- docs/archived/2025_pre_nov/ - Obsolete verification checklist (1 file)

**Key Improvements:**
- ENV variable reference: Single source of truth for all configuration
- Common Pitfalls #68-71: Already complete, verified during audit
- Better findability: Category-based navigation vs 68 files in root
- Preserves history: All files git mv (rename), not copy/delete
- Zero broken functionality: Only documentation moved, no code changes

**Verification:**
- 83 markdown files now in docs/ subdirectories
- Root directory cleaned: 68 files → 0 files (except README.md)
- Git history preserved for all moved files
- Container running: trading-bot-v4 (no restart needed)

**Next Steps:**
- Create README.md files in each docs subdirectory
- Add navigation index
- Update main README.md with new structure
- Consolidate duplicate deployment docs
- Archive truly obsolete files (old SQL backups)

See: docs/analysis/CLEANUP_PLAN.md for complete reorganization strategy
2025-12-04 08:29:59 +01:00
mindesbunister
93dd950821 critical: Fix ghost detection P&L compounding - delete from Map BEFORE check
Bug: Multiple monitoring loops detect ghost simultaneously
- Loop 1: has(tradeId) → true → proceeds
- Loop 2: has(tradeId) → true → ALSO proceeds (race condition)
- Both send Telegram notifications with compounding P&L

Real incident (Dec 2, 2025):
- Manual SHORT at $138.84
- 23 duplicate notifications
- P&L compounded: -$47.96 → -$1,129.24 (23× accumulation)
- Database shows single trade with final compounded value

Fix: Map.delete() returns true if key existed, false if already removed
- Call delete() FIRST
- Check return value
 proceeds
- All other loops get false → skip immediately
- Atomic operation prevents race condition

Pattern: This is variant of Common Pitfalls #48, #49, #59, #60, #61
- All had "check then delete" pattern
- All vulnerable to async timing issues
- Solution: "delete then check" pattern
- Map.delete() is synchronous and atomic

Files changed:
- lib/trading/position-manager.ts lines 390-410

Related: DUPLICATE PREVENTED message was working but too late
2025-12-02 18:25:56 +01:00
mindesbunister
79ab30782c fix: MarketData storage now working in execute endpoint
- Added debug logging to trace execution
- Confirmed 1-minute signals being stored continuously
- Database accumulating rows every 1-3 minutes
- All indicators (ATR, ADX, RSI, volume, price position) storing correctly
- 1-year retention active (365 days)
- Foundation ready for 8-hour blocked signal tracking
2025-12-02 12:43:35 +01:00
mindesbunister
5773d7d36d feat: Extend 1-minute data retention from 4 weeks to 1 year
- Updated lib/maintenance/data-cleanup.ts retention period: 28 days → 365 days
- Storage requirements validated: 251 MB/year (negligible)
- Rationale: 13× more historical data for better pattern analysis
- Benefits: 260-390 blocked signals/year vs 20-30/month
- Cleanup cutoff: Now Dec 2, 2024 (vs Nov 4, 2025 previously)
- Deployment verified: Container restarted, cleanup scheduled for 3 AM daily
2025-12-02 11:55:36 +01:00
mindesbunister
6cec2e8e71 critical: Fix Smart Entry Validation Queue wrong price display
- Bug: Validation queue used TradingView symbol format (SOLUSDT) to lookup market data cache
- Cache uses normalized Drift format (SOL-PERP)
- Result: Cache lookup failed, wrong/stale price shown in Telegram abandonment notifications
- Real incident: Signal at $126.00 showed $98.18 abandonment price (-22.08% impossible drop)
- Fix: Added normalizeTradingViewSymbol() call in check-risk endpoint before passing to validation queue
- Files changed: app/api/trading/check-risk/route.ts (import + symbol normalization)
- Impact: Validation queue now correctly retrieves current price from market data cache
- Deployed: Dec 1, 2025
2025-12-01 23:45:21 +01:00
mindesbunister
4fb301328d docs: Document 70% CPU deployment and Python buffering fix
- CRITICAL FIX: Python output buffering caused silent failure
- Solution: python3 -u flag for unbuffered output
- 70% CPU optimization: int(cpu_count() * 0.7) = 22-24 cores per server
- Current state: 47 workers, load ~22 per server, 16.3 hour timeline
- System operational since Dec 1 22:50:32
- Expected completion: Dec 2 15:15
2025-12-01 23:27:17 +01:00
mindesbunister
e748cf709d fix: Correct SSH hop for EPYC worker2 connectivity
- ProxyJump (-J) doesn't work from Docker container
- Changed to nested SSH: hop -> target
- Proper command escaping for nested SSH
- Worker2 (srv-bd-host01) only accessible via worker1 (pve-nu-monitor01)
2025-12-01 19:42:08 +01:00
mindesbunister
7e1fe1cc30 feat: V9 advanced parameter sweep with MA gap filter (810K configs)
Parameter space expansion:
- Original 15 params: 101K configurations
- NEW: MA gap filter (3 dimensions) = 18× expansion
- Total: ~810,000 configurations across 4 time profiles
- Chunk size: 1,000 configs/chunk = ~810 chunks

MA Gap Filter parameters:
- use_ma_gap: True/False (2 values)
- ma_gap_min_long: -5.0%, 0%, +5.0% (3 values)
- ma_gap_min_short: -5.0%, 0%, +5.0% (3 values)

Implementation:
- money_line_v9.py: Full v9 indicator with MA gap logic
- v9_advanced_worker.py: Chunk processor (1,000 configs)
- v9_advanced_coordinator.py: Work distributor (2 EPYC workers)
- run_v9_advanced_sweep.sh: Startup script (generates + launches)

Infrastructure:
- Uses existing EPYC cluster (64 cores total)
- Worker1: bd-epyc-02 (32 threads)
- Worker2: bd-host01 (32 threads via SSH hop)
- Expected runtime: 70-80 hours
- Database: SQLite (chunk tracking + results)

Goal: Find optimal MA gap thresholds for filtering false breakouts
during MA whipsaw zones while preserving trend entries.
2025-12-01 18:11:47 +01:00
mindesbunister
2993bc8895 feat: Update v9 with optimal parameters from exhaustive sweep + consolidate files
Parameter updates (from 4,096 config sweep analysis):
- flipThreshold: 0.6 → 0.5 (optimal for reversal confirmation)
- adxMin: 18 → 21 (stronger trend filter)
- longPosMax: 85 → 75 (prevent chasing tops)
- shortPosMin: 15 → 20 (catch momentum shorts)
- volMin: 0.7 → 1.0 (stronger conviction requirement)

File consolidation:
- Archived moneyline_v9_ma_gap_clean.pinescript (suboptimal defaults)
- Archived moneyline_v9_test.pinescript (suboptimal defaults, missing MA gap)
- Kept moneyline_v9_ma_gap.pinescript as canonical v9 (optimal + MA gap analysis)

Result: Single v9 file with optimal defaults producing 19.44% returns
over 4 months (194.4% annualized) from sweep validation.
2025-12-01 16:04:42 +01:00
mindesbunister
11a0ea324b critical: Fix distributed worker quality_filter - dict to lambda function
Root cause: Passing dict {'min_adx': 15, 'min_volume_ratio': vol_min} when
simulate_money_line() expects callable function.

Bug caused ALL 2,096 backtests to fail with 'dict' object is not callable.

Fix: Changed to lambda function matching comprehensive_sweep.py pattern:
  quality_filter = lambda s: s.adx >= 15 and s.volume_ratio >= vol_min

Verified fix working: Workers running at 100% CPU, no errors after 2+ minutes.
2025-12-01 14:59:08 +01:00
mindesbunister
a886555d44 docs: Complete SSH timeout + resumption logic fix documentation
**Comprehensive documentation including:**
- Root cause analysis for both bugs
- Manual test procedures that validated fixes
- Code changes with before/after comparisons
- Verification results (24 worker processes running)
- Lessons learned for future debugging
- Current cluster state and next steps

Files: cluster/SSH_TIMEOUT_FIX_COMPLETE.md (288 lines)
2025-12-01 12:58:03 +01:00
mindesbunister
323ef03f5f critical: Fix SSH timeout + resumption logic bugs
**SSH Command Fix:**
- CRITICAL: Removed && after background command (&)
- Pattern: 'cmd & echo Started' works, 'cmd && echo' waits forever
- Manually tested: Works perfectly on direct SSH
- Result: Chunk 0 now starts successfully on worker1 (24 processes running)

**Resumption Logic Fix:**
- CRITICAL: Only count completed/running chunks, not pending
- Query: Added 'AND status IN (completed, running)' filter
- Result: Starts from chunk 0 when no chunks complete (was skipping to chunk 3)

**Database Cleanup:**
- CRITICAL: Delete pending/failed chunks on coordinator start
- Prevents UNIQUE constraint errors on retry
- Result: Clean slate allows coordinator to assign chunks fresh

**Verification:**
-  Chunk v9_chunk_000000: status='running', assigned_worker='worker1'
-  Worker1: 24 Python processes running backtester
-  Database: Cleaned 3 pending chunks, created 1 running chunk
- ⚠️  Worker2: SSH hop still timing out (separate infrastructure issue)

Files changed:
- cluster/distributed_coordinator.py (3 critical fixes: line 388-401, 514-533, 507-514)
2025-12-01 12:56:35 +01:00
mindesbunister
1f83a7d7c4 feat: Add coordinator log viewer to cluster UI
- Created /api/cluster/logs endpoint to read coordinator.log
- Added real-time log display in cluster UI (updates every 3s)
- Shows last 100 lines of coordinator.log in terminal-style display
- Includes manual refresh button
- Improves debugging experience - no need to SSH for logs

User feedback: 'why dont we add the output of the log at the bottom of the page so i know whats going on'

This addresses poor visibility into coordinator errors and failures.
Next step: Fix SSH timeout issue blocking worker execution.
2025-12-01 11:49:23 +01:00
mindesbunister
ef371a19b9 fix: EPYC cluster SSH timeout - increase timeout 30s→60s + add SSH options
CRITICAL FIX (Dec 1, 2025): Cluster start was failing with 'operation failed'

Problem:
- SSH commands timing out after 30s (too short for 2-hop SSH to worker2)
- Missing SSH options caused prompts/delays
- Result: Coordinator failed to start worker processes

Solution:
- Increased timeout from 30s to 60s for nested SSH hops
- Added SSH options: -o StrictHostKeyChecking=no -o ConnectTimeout=10
- Applied options to both ssh_command() and worker startup commands

Verification (Dec 1, 09:40):
- Worker1: 23 processes running (chunk 0-2000)
- Worker2: 24 processes running (chunk 2000-4000)
- Cluster status: ACTIVE with 2 workers
- Both chunks processing successfully

Files changed:
- cluster/distributed_coordinator.py (lines 302-314, 388-414)
2025-12-01 09:41:42 +01:00
mindesbunister
67ef5b1ac6 feat: Add direction-specific quality thresholds and dynamic collateral display
- Split QUALITY_LEVERAGE_THRESHOLD into separate LONG and SHORT variants
- Added /api/drift/account-health endpoint for real-time collateral data
- Updated settings UI to show separate controls for LONG/SHORT thresholds
- Position size calculations now use dynamic collateral from Drift account
- Updated .env and docker-compose.yml with new environment variables
- LONG threshold: 95, SHORT threshold: 90 (configurable independently)

Files changed:
- app/api/drift/account-health/route.ts (NEW) - Account health API endpoint
- app/settings/page.tsx - Added collateral state, separate threshold inputs
- app/api/settings/route.ts - GET/POST handlers for LONG/SHORT thresholds
- .env - Added QUALITY_LEVERAGE_THRESHOLD_LONG/SHORT variables
- docker-compose.yml - Added new env vars with fallback defaults

Impact:
- Users can now configure quality thresholds independently for LONG vs SHORT signals
- Position size display dynamically updates based on actual Drift account collateral
- More flexible risk management with direction-specific leverage tiers
2025-12-01 09:09:30 +01:00
mindesbunister
c5a8f5e32d docs: Add comprehensive status detection fix documentation 2025-11-30 22:27:08 +01:00
mindesbunister
cc56b72df2 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
2025-11-30 22:23:01 +01:00
mindesbunister
83b4915d98 fix: Reduce coordinator chunk_size from 10k to 2k for small explorations
- Changed default chunk_size from 10,000 to 2,000
- Fixes bug where coordinator exited immediately for 4,096 combo exploration
- Coordinator was calculating: chunk 1 starts at 10,000 > 4,096 total = 'all done'
- Now creates 2-3 appropriately-sized chunks for distribution
- Verified: Workers now start and process assigned chunks
- Status:  Docker rebuilt and deployed to port 3001
2025-11-30 22:07:59 +01:00
mindesbunister
b77282b560 feat: Add EPYC cluster distributed sweep with web UI
New Features:
- Distributed coordinator orchestrates 2x AMD EPYC 16-core servers
- 64 total cores processing 12M parameter combinations (70% CPU limit)
- Worker1 (pve-nu-monitor01): Direct SSH access at 10.10.254.106
- Worker2 (bd-host01): 2-hop SSH through worker1 (10.20.254.100)
- Web UI at /cluster shows real-time status and AI recommendations
- API endpoint /api/cluster/status serves cluster metrics
- Auto-refresh every 30s with top strategies and actionable insights

Files Added:
- cluster/distributed_coordinator.py (510 lines) - Main orchestrator
- cluster/distributed_worker.py (271 lines) - Worker1 script
- cluster/distributed_worker_bd_clean.py (275 lines) - Worker2 script
- cluster/monitor_bd_host01.sh - Monitoring script
- app/api/cluster/status/route.ts (274 lines) - API endpoint
- app/cluster/page.tsx (258 lines) - Web UI
- cluster/CLUSTER_SETUP.md - Complete setup and access documentation

Technical Details:
- SQLite database tracks chunk assignments
- 10,000 combinations per chunk (1,195 total chunks)
- Multiprocessing.Pool with 70% CPU limit (22 cores per EPYC)
- SSH/SCP for deployment and result collection
- Handles 2-hop SSH for bd-host01 access
- Results in CSV format with top strategies ranked

Access Documentation:
- Worker1: ssh root@10.10.254.106
- Worker2: ssh root@10.10.254.106 "ssh root@10.20.254.100"
- Web UI: http://localhost:3001/cluster
- See CLUSTER_SETUP.md for complete guide

Status: Deployed and operational
2025-11-30 13:02:18 +01:00
mindesbunister
2a8e04fe57 feat: Continuous optimization cluster for 2 EPYC servers
- Master controller with job queue and result aggregation
- Worker scripts for parallel backtesting (22 workers per server)
- SQLite database for strategy ranking and performance tracking
- File-based job queue (simple, robust, survives crashes)
- Auto-setup script for both EPYC servers
- Status dashboard for monitoring progress
- Comprehensive deployment guide

Architecture:
- Master: Job generation, worker coordination, result collection
- Worker 1 (pve-nu-monitor01): AMD EPYC 7282, 22 parallel jobs
- Worker 2 (srv-bd-host01): AMD EPYC 7302, 22 parallel jobs
- Total capacity: ~49,000 backtests/day (44 cores @ 70%)

Initial focus: v9 parameter refinement (27 configurations)
Target: Find strategies >00/1k P&L (current baseline 92/1k)

Files:
- cluster/master.py: Main controller (570 lines)
- cluster/worker.py: Worker execution script (220 lines)
- cluster/setup_cluster.sh: Automated deployment
- cluster/status.py: Real-time status dashboard
- cluster/README.md: Operational documentation
- cluster/DEPLOYMENT.md: Step-by-step deployment guide
2025-11-29 22:34:52 +01:00