feat: Implement comprehensive positions tracking system

- Real-time positions tracking with live P&L updates
- PositionsPanel component with auto-refresh every 10s
- Position creation on trade execution (DEX, Perp, Standard)
- One-click position closing functionality
- Stop Loss and Take Profit display with monitoring

- /api/trading/positions API for CRUD operations
- Real-time price updates via CoinGecko integration
- Automatic position creation on successful trades
- In-memory positions storage with P&L calculations
- Enhanced trading page layout with positions panel

- Entry price, current price, and unrealized P&L
- Percentage-based P&L calculations
- Portfolio summary with total value and total P&L
- Transaction ID tracking for audit trail
- Support for leverage positions and TP/SL orders

 Confirmed Working:
- Position created: SOL/USDC BUY 0.02 @ 68.10
- Real-time P&L: -/bin/bash.0052 (-0.15%)
- TP/SL monitoring: SL 60, TP 80
- Transaction: 5qYx7nmpgE3fHEZpjJCMtJNb1jSQVGfKhKNzJNgJ5VGV4xG2cSSpr1wtfPfbmx8zSjwHnzSgZiWsMnAWmCFQ2RVx

- Clear positions display on trading page
- Real-time updates without manual refresh
- Intuitive close buttons for quick position management
- Separate wallet holdings vs active trading positions
- Professional trading interface with P&L visualization
This commit is contained in:
mindesbunister
2025-07-14 15:59:44 +02:00
parent f1e0be8c79
commit 0d7b46fdcf
8 changed files with 637 additions and 14 deletions

View File

@@ -0,0 +1,48 @@
<svg width="800" height="600" viewBox="0 0 800 600" xmlns="http://www.w3.org/2000/svg">
<defs>
<linearGradient id="bg" x1="0%" y1="0%" x2="100%" y2="100%">
<stop offset="0%" style="stop-color:#1e3a8a;stop-opacity:1" />
<stop offset="100%" style="stop-color:#312e81;stop-opacity:1" />
</linearGradient>
<linearGradient id="chart" x1="0%" y1="0%" x2="100%" y2="100%">
<stop offset="0%" style="stop-color:#10b981;stop-opacity:0.8" />
<stop offset="100%" style="stop-color:#059669;stop-opacity:0.8" />
</linearGradient>
</defs>
<!-- Background -->
<rect width="800" height="600" fill="url(#bg)"/>
<!-- Chart Area -->
<rect x="50" y="50" width="700" height="400" fill="#1f2937" stroke="#374151" stroke-width="2" rx="8"/>
<!-- Chart Title -->
<text x="400" y="80" text-anchor="middle" fill="#f9fafb" font-family="Arial, sans-serif" font-size="20" font-weight="bold">BTCUSD - AI Analysis Chart</text>
<!-- Mock Chart Line -->
<polyline points="70,350 120,320 170,310 220,290 270,280 320,260 370,250 420,240 470,220 520,210 570,200 620,180 670,160 720,150"
fill="none" stroke="url(#chart)" stroke-width="3"/>
<!-- Price Labels -->
<text x="30" y="160" fill="#9ca3af" font-family="Arial, sans-serif" font-size="12">$68,000</text>
<text x="30" y="220" fill="#9ca3af" font-family="Arial, sans-serif" font-size="12">$66,000</text>
<text x="30" y="280" fill="#9ca3af" font-family="Arial, sans-serif" font-size="12">$64,000</text>
<text x="30" y="340" fill="#9ca3af" font-family="Arial, sans-serif" font-size="12">$62,000</text>
<!-- Time Labels -->
<text x="100" y="480" fill="#9ca3af" font-family="Arial, sans-serif" font-size="12">12:00</text>
<text x="250" y="480" fill="#9ca3af" font-family="Arial, sans-serif" font-size="12">15:00</text>
<text x="400" y="480" fill="#9ca3af" font-family="Arial, sans-serif" font-size="12">18:00</text>
<text x="550" y="480" fill="#9ca3af" font-family="Arial, sans-serif" font-size="12">21:00</text>
<text x="700" y="480" fill="#9ca3af" font-family="Arial, sans-serif" font-size="12">00:00</text>
<!-- Analysis Panel -->
<rect x="50" y="500" width="700" height="80" fill="#374151" stroke="#4b5563" stroke-width="1" rx="6"/>
<text x="70" y="525" fill="#f9fafb" font-family="Arial, sans-serif" font-size="14" font-weight="bold">AI Analysis Results:</text>
<text x="70" y="545" fill="#10b981" font-family="Arial, sans-serif" font-size="12">● Sentiment: Bullish | Confidence: 85%</text>
<text x="70" y="560" fill="#60a5fa" font-family="Arial, sans-serif" font-size="12">● Prediction: Up 3-5% in next 24h | Support: $65,000 | Resistance: $68,000</text>
<!-- Logo -->
<circle cx="720" cy="100" r="15" fill="#3b82f6"/>
<text x="720" y="105" text-anchor="middle" fill="white" font-family="Arial, sans-serif" font-size="12" font-weight="bold">AI</text>
</svg>

After

Width:  |  Height:  |  Size: 2.8 KiB