feat: Add distinction between regular SL and trailing SL

User Request: Distinguish between SL and Trailing SL in analytics overview

Changes:
1. Position Manager:
   - Updated ExitResult interface to include 'TRAILING_SL' exit reason
   - Modified trailing stop exit (line 1457) to use 'TRAILING_SL' instead of 'SL'
   - Enhanced external closure detection (line 937) to identify trailing stops
   - Updated handleManualClosure to detect trailing SL at price target

2. Database:
   - Updated UpdateTradeExitParams interface to accept 'TRAILING_SL'

3. Frontend Analytics:
   - Updated last trade display to show 'Trailing SL' with special formatting
   - Purple background/border for TRAILING_SL vs blue for regular SL
   - Runner emoji (🏃) prefix for trailing stops

Impact:
- Users can now see when trades exit via trailing stop vs regular SL
- Better understanding of runner system performance
- Trailing stops visually distinct in analytics dashboard

Files Modified:
- lib/trading/position-manager.ts (4 locations)
- lib/database/trades.ts (UpdateTradeExitParams interface)
- app/analytics/page.tsx (exit reason display)
- .github/copilot-instructions.md (Common Pitfalls #61, #62)
This commit is contained in:
mindesbunister
2025-11-24 08:40:09 +01:00
parent 046629520c
commit 9d7932ff2f
4 changed files with 102 additions and 10 deletions

View File

@@ -774,9 +774,19 @@ export default function AnalyticsPage() {
</div>
{lastTrade.exitReason && (
<div className="mt-4 p-3 bg-blue-900/20 rounded-lg border border-blue-500/30">
<div className={`mt-4 p-3 rounded-lg border ${
lastTrade.exitReason === 'TRAILING_SL'
? 'bg-purple-900/20 border-purple-500/30'
: 'bg-blue-900/20 border-blue-500/30'
}`}>
<span className="text-sm text-gray-400">Exit Reason: </span>
<span className="text-sm font-semibold text-blue-400">{lastTrade.exitReason}</span>
<span className={`text-sm font-semibold ${
lastTrade.exitReason === 'TRAILING_SL'
? 'text-purple-400'
: 'text-blue-400'
}`}>
{lastTrade.exitReason === 'TRAILING_SL' ? '🏃 Trailing SL' : lastTrade.exitReason}
</span>
</div>
)}
</div>