Commit Graph

692 Commits

Author SHA1 Message Date
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
mindesbunister
c7f2df09b9 critical: Fix v11 missing use_quality_filters parameter + RSI index bug
TWO CRITICAL BUGS FIXED:

1. Missing use_quality_filters parameter (Pine Script parity):
   - Added use_quality_filters: bool = True to MoneyLineV11Inputs
   - Implemented bypass logic in signal generation for both long/short
   - When False: only trend flips generate signals (no filtering)
   - When True: all filters must pass (original v11 behavior)
   - Matches Pine Script: finalSignal = buyReady and (not useQualityFilters or (...filters...))

2. RSI index misalignment causing 100% NaN values:
   - np.where() returns numpy arrays without indices
   - pd.Series(gain/loss) created NEW integer indices (0,1,2...)
   - Result: RSI values misaligned with original datetime index
   - Fix: pd.Series(gain/loss, index=series.index) preserves alignment
   - Impact: RSI NaN count 100 → 0, all filters now work correctly

VERIFICATION:
- Test 1 (no filters): 1,424 signals ✓
- Test 2 (permissive RSI): 1,308 signals ✓
- Test 3 (moderate RSI 25-70/30-80): 1,157 signals ✓

Progressive sweep can now proceed with corrected signal generation.
2025-12-06 22:26:50 +01:00
mindesbunister
0ebbdbeb0d Merge pull request #16 from mindesbunister/copilot/create-progressive-sweep-v11
Implement v11 progressive parameter sweep starting from zero filters
2025-12-06 21:38:50 +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
copilot-swe-agent[bot]
e92ba6df83 Initial plan 2025-12-06 20:21:42 +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
mindesbunister
71cad3b188 Merge pull request #15 from mindesbunister/copilot/create-v11-test-sweep-512-combinations
Implement v11 test parameter sweep with 256 combinations and office hours scheduling
2025-12-06 20:25:32 +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
copilot-swe-agent[bot]
67cc7598f2 Initial plan 2025-12-06 19:08:42 +00:00
mindesbunister
31ebb24f5f Merge pull request #13 from mindesbunister/copilot/create-v11-indicator-filters
[WIP] Create v11 indicator with all filter options functional
2025-12-06 19:08:18 +01:00
mindesbunister
6a1f649326 Merge pull request #12 from mindesbunister/copilot/add-fartcoin-perp-market
Add FARTCOIN-PERP market with percentage-based position sizing
2025-12-06 19:07:58 +01:00
copilot-swe-agent[bot]
40fd60fa8f docs: Add comprehensive v11 indicator documentation
- Create V11_INDICATOR_GUIDE.md (complete testing and usage guide)
- Create V11_QUICK_REFERENCE.md (quick reference card)
- Document bug fix, filter logic, testing workflow
- Include configuration presets and troubleshooting
- Add performance expectations and comparison tables

Co-authored-by: mindesbunister <32161838+mindesbunister@users.noreply.github.com>
2025-12-06 18:03:04 +00:00
copilot-swe-agent[bot]
fae899a1f6 feat: Create v11 indicator with all filter options functional
- Copy v9 indicator as base for v11
- Add master useQualityFilters toggle (line 10-11)
- Fix final signal logic to apply ALL filters (lines 261-272)
- Update metadata: title, shorttitle to "v11 All Filters"
- Update indicatorVer to "v11" (line 283)
- Update comments to reflect v11 behavior

Key fix: v9 calculated filters but never applied them. v11 applies all 10 filter variables:
- longOk/shortOk (MACD)
- adxOk (ADX minimum)
- longBufferOk/shortBufferOk (entry buffer)
- longPositionOk/shortPositionOk (price position)
- volumeOk (volume ratio)
- rsiLongOk/rsiShortOk (RSI momentum)

Master toggle allows A/B testing:
- useQualityFilters=false → behaves like v9 (timing only)
- useQualityFilters=true → all filters must pass

Co-authored-by: mindesbunister <32161838+mindesbunister@users.noreply.github.com>
2025-12-06 18:00:44 +00:00
copilot-swe-agent[bot]
9712d16fdb Initial plan 2025-12-06 17:55:51 +00:00
copilot-swe-agent[bot]
2df6c69b92 feat: Add FARTCOIN-PERP market support with percentage-based sizing
- Added FARTCOIN-PERP to SUPPORTED_MARKETS (market index 22)
- Updated TradingConfig interface with fartcoin symbol settings
- Added default config: 20% portfolio, 10x leverage, disabled by default
- Updated normalizeTradingViewSymbol to detect FARTCOIN
- Enhanced getPositionSizeForSymbol for FARTCOIN-PERP handling
- Enhanced getActualPositionSizeForSymbol for percentage-based sizing
- Added FARTCOIN ENV variable loading in getConfigFromEnv
- Updated Settings UI with FARTCOIN section and percentage badge
- Added FARTCOIN fields to settings API endpoints (GET/POST)
- Created comprehensive documentation in docs/markets/FARTCOIN-PERP.md
- Build successful: TypeScript compilation and static generation complete

Co-authored-by: mindesbunister <32161838+mindesbunister@users.noreply.github.com>
2025-12-06 17:44:19 +00:00
copilot-swe-agent[bot]
d3b83ae95a Initial plan 2025-12-06 17:34:49 +00:00
mindesbunister
c140e62ac7 fix: Change logger.log to console.log for stop hunt revenge recording
ISSUE: Quality 95 trade stopped out today (ID: cmiueo2qv01coml07y9kjzugf)
but stop hunt was NOT recorded in database for revenge system.

ROOT CAUSE: logger.log() calls for revenge recording were silenced in production
(NODE_ENV=production suppresses logger.log output)

FIX: Changed 2 logger.log() calls to console.log() in position-manager.ts:
- Line ~1006: External closure revenge eligibility check
- Line ~1742: Software-based SL revenge activation

Now revenge system will properly record quality 85+ stop-outs with visible logs.

Trade details:
- Symbol: SOL-PERP LONG
- Entry: $133.74, Exit: $132.69
- Quality: 95, ADX: 28.9, ATR: 0.22
- Loss: -$26.94
- Exit time: 2025-12-06 15:16:18

This stop-out already expired (4-hour window ended at 19:16).
Next quality 85+ SL will be recorded correctly.
2025-12-06 16:30:07 +01:00
mindesbunister
e4ce61b879 Merge branch 'master' of https://github.com/mindesbunister/trading_bot_v4 2025-12-05 19:11:10 +01:00
mindesbunister
5e5a905eee docs: Add Common Pitfall #73 - Service initialization bug (k impact)
Added to copilot-instructions.md Common Pitfalls section:

PITFALL #73: Service Initialization Never Ran (Dec 5, 2025)
- Duration: 16 days (Nov 19 - Dec 5)
- Financial impact: 00-1,400 (k user estimate)
- Root cause: Services after validation with early return
- Affected: Stop hunt revenge, smart validation, blocked signal tracker, data cleanup
- Fix: Move services BEFORE validation (commits 51b63f4, f6c9a7b, 35c2d7f)
- Prevention: Test suite, CI/CD, startup health checks, console.log for critical logs
- Full docs: docs/CRITICAL_SERVICE_INITIALIZATION_BUG_DEC5_2025.md
2025-12-05 19:05:59 +01:00
mindesbunister
3f60983b11 docs: Document critical service initialization bug and k financial impact
DISCOVERY (Dec 5, 2025):
- 4 critical services never started since Nov 19 (16 days)
- Services placed AFTER validation with early return
- Silent failure: no errors, just never initialized

AFFECTED SERVICES:
- Stop Hunt Revenge Tracker (Nov 20) - No revenge attempts
- Smart Entry Validation (Nov 30) - Manual trades used stale data
- Blocked Signal Tracker (Nov 19) - No threshold optimization data
- Data Cleanup (Dec 2) - Database bloat

FINANCIAL IMPACT:
- Stop hunt revenge: 00-600 lost (missed reversals)
- Smart validation: 00-400 lost (stale data entries)
- Blocked signals: 00-400 lost (suboptimal thresholds)
- TOTAL: 00-1,400 (user estimate: ,000)

ROOT CAUSE:
Line 43: validateOpenTrades() with early return at line 111
Lines 59-72: Service initialization AFTER validation
Result: When no open trades → services never reached

FIX COMMITS:
- 51b63f4: Move services BEFORE validation
- f6c9a7b: Use console.log for production visibility
- 35c2d7f: Fix stop hunt tracker logs

PREVENTION:
- Test suite (PR #2): 113 tests
- CI/CD pipeline (PR #5): Automated quality gates
- Service startup validation in future CI
- Production logging standard: console.log for critical operations

STATUS:  ALL SERVICES NOW ACTIVE AND VERIFIED
2025-12-05 19:03:59 +01:00
mindesbunister
35c2d7fc8a fix: Stop hunt tracker logs also need console.log for production visibility 2025-12-05 18:39:49 +01:00
mindesbunister
f6c9a7b7a4 fix: Use console.log instead of logger.log for service startup
- logger.log is silenced in production (NODE_ENV=production)
- Service initialization logs were hidden even though services were starting
- Changed to console.log for visibility in production logs
- Affects: data cleanup, blocked signal tracker, stop hunt tracker, smart validation
2025-12-05 18:32:59 +01:00
mindesbunister
e8ddd74846 Merge pull request #11 from mindesbunister/copilot/add-drift-market-discovery-script
Add Drift market discovery script for finding market indices and oracle addresses
2025-12-05 15:49:12 +01:00
mindesbunister
51b63f4a35 critical: Fix service initialization - start services BEFORE validation
CRITICAL BUG DISCOVERED (Dec 5, 2025):
- validateOpenTrades() returns early at line 111 when no trades found
- Service initialization (lines 59-72) happened AFTER validation
- Result: When no open trades, services NEVER started
- Impact: Stop hunt tracker, smart validation, blocked signal tracking all inactive

ROOT CAUSE:
- Line 43: await validateOpenTrades()
- Line 111: if (openTrades.length === 0) return  // EXIT EARLY
- Lines 59-72: Service startup code (NEVER REACHED)

FIX:
- Moved service initialization BEFORE validation
- Services now start regardless of open trades count
- Order: Start services → Clean DB → Validate → Init Position Manager

SERVICES NOW START:
- Data cleanup (4-week retention)
- Blocked signal price tracker
- Stop hunt revenge tracker
- Smart entry validation system

This explains why:
- Line 111 log appeared (validation ran, returned early)
- Line 29 log appeared (function started)
- Lines 59-72 logs NEVER appeared (code never reached)

Git commit SHA: TBD
Deployment: Requires rebuild + restart
2025-12-05 15:43:46 +01:00
copilot-swe-agent[bot]
86b69ff7c0 fix: Improve enum handling robustness in discover-drift-markets script
Co-authored-by: mindesbunister <32161838+mindesbunister@users.noreply.github.com>
2025-12-05 14:43:06 +00:00
mindesbunister
a2f32eceac debug: Add logging to trace instrumentation execution 2025-12-05 15:38:31 +01:00
copilot-swe-agent[bot]
e9472175ba feat: Add Drift market discovery script for finding market indices and oracle addresses
Co-authored-by: mindesbunister <32161838+mindesbunister@users.noreply.github.com>
2025-12-05 14:38:16 +00:00
mindesbunister
526a40d1ae fix: Correct indentation for stop hunt and smart validation startup
- Lines 68-72 had only 2 spaces indent (outside try block)
- Services were executing AFTER catch block
- Fixed to 4 spaces (inside try block)
- Now stop hunt tracker, blocked signal tracker, smart validation will initialize properly
2025-12-05 15:34:01 +01:00
copilot-swe-agent[bot]
830c08dfc7 Initial plan 2025-12-05 14:30:48 +00:00
mindesbunister
c0da602917 fix: TypeScript error - use undefined instead of null for signalQualityVersion 2025-12-05 15:25:52 +01:00
mindesbunister
1efd9bf577 Merge pull request #10 from mindesbunister/copilot/fix-instrumentation-hook-issue
fix: Enable Next.js instrumentation hook for startup services
2025-12-05 15:22:48 +01:00
mindesbunister
0bba1a6739 fix: Remove v9 label from 1-minute data collection
- 1-minute data is pure market sampling, not trading signals
- signalQualityVersion now null for timeframe='1'
- Other timeframes still labeled with v9
- Prevents confusion in analytics/reporting
2025-12-05 15:21:53 +01:00
copilot-swe-agent[bot]
5711fc2fec fix: Enable Next.js instrumentation hook to start critical services on startup
Add `instrumentationHook: true` to `next.config.js` experimental section.

This fixes a critical bug where the instrumentation.ts file was not being
executed on server startup, causing all startup services to not run:
- Stop Hunt Revenge Tracker (93 revenge opportunities missed)
- Position Manager (no monitoring of open trades)
- Ghost Position Cleanup
- Data Cleanup Service
- Blocked Signal Tracking
- Smart Validation Queue
- Database Sync Validator

The instrumentation.ts file existed and contained proper initialization code,
but Next.js requires explicit opt-in via the experimental.instrumentationHook
flag to enable this feature.

Co-authored-by: mindesbunister <32161838+mindesbunister@users.noreply.github.com>
2025-12-05 14:21:16 +00:00
copilot-swe-agent[bot]
0a768e2f5c Initial plan 2025-12-05 14:10:51 +00:00
mindesbunister
1b45d879d0 Merge pull request #9 from mindesbunister/copilot/fix-analytics-dashboard-filtering
Add indicator version filtering to analytics optimization dashboard
2025-12-05 15:10:34 +01:00
copilot-swe-agent[bot]
4f913a7ab8 feat: Add indicator version filtering to analytics dashboard
- Add version dropdown selector (v9, v8, v6, v5, all) to frontend
- Update backend API to accept ?version= query parameter
- Add version filter to all 5 broken SQL queries using Prisma parameterized queries
- Update Data Collection Status to use selected version instead of hardcoded v8
- Add version context to all recommendations
- Add URL encoding for version parameter (security best practice)
- Validate version parameter against whitelist (SQL injection protection)

Co-authored-by: mindesbunister <32161838+mindesbunister@users.noreply.github.com>
2025-12-05 14:01:41 +00:00
copilot-swe-agent[bot]
9fdabb20ae Analysis complete - begin implementing version filter fix
Co-authored-by: mindesbunister <32161838+mindesbunister@users.noreply.github.com>
2025-12-05 13:48:33 +00:00
copilot-swe-agent[bot]
8e527cafa9 Initial plan 2025-12-05 13:43:24 +00:00
mindesbunister
d49e0feb5f docs: Add mandatory npm test requirement before Position Manager deployment
- Added STEP 1: Run tests BEFORE deployment (113 tests in ~30s)
- Added STEP 2: Validate with test trade AFTER deployment
- Why mandatory: Catch bugs (tokens vs USD, false TP1, wrong SL) before real money loss
- Tests prevent Common Pitfalls #24, #43, #45, #52, #54, #67 recurrence
- DO NOT deploy if tests fail - fix issue or update tests first
2025-12-05 14:20:32 +01:00
mindesbunister
389bcd6f4c Merge remote-tracking branch 'github/master' 2025-12-05 13:49:00 +01:00
mindesbunister
c41d46b001 Merge pull request #8 from mindesbunister/copilot/add-feature-discovery-section
Add "DO I ALREADY HAVE THIS?" Feature Discovery Section
2025-12-05 13:47:58 +01:00
mindesbunister
99bfcb9b92 Merge pull request #7 from mindesbunister/copilot/fix-npm-audit-vulnerabilities
fix: Resolve npm audit security vulnerabilities
2025-12-05 13:47:34 +01:00
copilot-swe-agent[bot]
98a68ae357 docs: Add "DO I ALREADY HAVE THIS?" Feature Discovery section
Added comprehensive feature discovery section to copilot-instructions.md:
- Quick Reference Table: 9 common scenarios with existing features
- Quick Search Commands: bash commands for feature discovery
- Feature Discovery by Category: 6 categories with 30+ features
- Decision Flowchart: 5-step verification process
- Historical Examples: why each feature was built

This helps users/AI agents discover existing features before rebuilding.

Co-authored-by: mindesbunister <32161838+mindesbunister@users.noreply.github.com>
2025-12-05 12:39:19 +00:00
copilot-swe-agent[bot]
2d2510f074 Initial plan 2025-12-05 12:34:40 +00:00