feat: phantom trade auto-closure system

- Auto-close phantom positions immediately via market order
- Return HTTP 200 (not 500) to allow n8n workflow continuation
- Save phantom trades to database with full P&L tracking
- Exit reason: 'manual' category for phantom auto-closes
- Protects user during unavailable hours (sleeping, no phone)
- Add Docker build best practices to instructions (background + tail)
- Document phantom system as Critical Component #1
- Add Common Pitfall #30: Phantom notification workflow

Why auto-close:
- User can't always respond to phantom alerts
- Unmonitored position = unlimited risk exposure
- Better to exit with small loss/gain than leave exposed
- Re-entry possible if setup actually good

Files changed:
- app/api/trading/execute/route.ts: Auto-close logic
- .github/copilot-instructions.md: Documentation + build pattern
This commit is contained in:
mindesbunister
2025-11-14 05:37:51 +01:00
parent 4ad509928f
commit 6590f4fb1e
7 changed files with 383 additions and 17 deletions

View File

@@ -145,7 +145,7 @@ export const DEFAULT_TRADING_CONFIG: TradingConfig = {
trailingStopActivation: 0.5, // Activate trailing when runner is +0.5% in profit
// Signal Quality
minSignalQualityScore: 65, // Minimum quality score for initial entry (raised from 60)
minSignalQualityScore: 60, // Minimum quality score for initial entry (lowered from 65 on Nov 12, 2025 - data showed 60-64 tier outperformed)
// Position Scaling (conservative defaults)
enablePositionScaling: false, // Disabled by default - enable after testing