Add trading amount and leverage information to trade displays

- Enhanced API response to include tradingAmount, leverage, and positionSize for all trades
- Added realistic trading examples with varying leverage (2x-5x) and amounts (50-00)
- Updated automation page UI to display trading details in dedicated section
- Added leverage badges and position size information for better trade transparency
- Enhanced trade summary to show trading amount and leverage context
- Improved trade visualization with color-coded leverage indicators

Features added:
- Trading Amount: Shows base capital used (50-00)
- Leverage: Visual badges showing multiplier (2x-5x)
- Position Size: Calculated total exposure (tradingAmount × leverage)
- Enhanced trade cards with comprehensive trading parameters
This commit is contained in:
mindesbunister
2025-07-19 00:00:04 +02:00
parent 6ad97301ec
commit 16f9b2f5e8
3 changed files with 80 additions and 1 deletions

View File

@@ -33,6 +33,9 @@ export async function GET() {
id: 'demo-trade-1',
side: 'BUY',
amount: 1.5,
tradingAmount: 250, // Trading amount in USD
leverage: 5, // 5x leverage
positionSize: 1250, // Total position size (tradingAmount * leverage)
price: 174.25,
status: 'OPEN',
profit: null,
@@ -76,6 +79,9 @@ export async function GET() {
id: 'demo-trade-2',
side: 'SELL',
amount: 2.04,
tradingAmount: 180, // Trading amount in USD
leverage: 3, // 3x leverage
positionSize: 540, // Total position size (tradingAmount * leverage)
price: 176.88,
status: 'COMPLETED',
profit: 3.24,
@@ -117,6 +123,9 @@ export async function GET() {
id: 'demo-trade-3',
side: 'BUY',
amount: 1.8,
tradingAmount: 300, // Trading amount in USD
leverage: 4, // 4x leverage
positionSize: 1200, // Total position size (tradingAmount * leverage)
price: 173.15,
status: 'COMPLETED',
profit: -1.89,
@@ -153,6 +162,50 @@ export async function GET() {
timeBasedExit: false,
analysisInvalidated: true
}
},
{
id: 'demo-trade-4',
side: 'SELL',
amount: 1.2,
tradingAmount: 150, // Trading amount in USD
leverage: 2, // 2x leverage
positionSize: 300, // Total position size (tradingAmount * leverage)
price: 175.90,
status: 'COMPLETED',
profit: 1.86,
createdAt: new Date(Date.now() - 6 * 60 * 60 * 1000).toISOString(), // 6 hours ago
aiAnalysis: 'SELL signal with 81% confidence - Bearish momentum confirmed',
stopLoss: 177.20,
takeProfit: 174.35,
confidence: 81,
// Enhanced analysis context
triggerAnalysis: {
decision: 'SELL',
confidence: 81,
timeframe: '1h',
keySignals: ['Bearish engulfing pattern', 'Volume spike on rejection', 'RSI divergence'],
marketCondition: 'Strong bearish momentum',
riskReward: '1:1.2',
invalidationLevel: 177.50
},
// Exit metrics
exitMetrics: {
exitPrice: 174.35,
exitReason: 'Take profit hit',
timeInTrade: '52 minutes',
maxUnrealizedPnL: 2.10,
maxDrawdown: -0.42,
analysisAccuracy: 'Good - TP hit with minor slippage',
actualRiskReward: '1:1.2'
},
// Exit conditions
exitConditions: {
stopLossHit: false,
takeProfitHit: true,
manualExit: false,
timeBasedExit: false,
analysisInvalidated: false
}
}
]
@@ -268,6 +321,9 @@ export async function GET() {
type: trade.type || 'MARKET',
side: trade.side,
amount: trade.amount,
tradingAmount: trade.tradingAmount || 100, // Default to $100 if not specified
leverage: trade.leverage || 1, // Default to 1x leverage if not specified
positionSize: trade.positionSize || (trade.tradingAmount || 100) * (trade.leverage || 1),
price: trade.price,
status: trade.status,
pnl: trade.profit,

View File

@@ -589,6 +589,7 @@ export default function AutomationPage() {
{trade.side}
</span>
<span className="text-white font-semibold">{trade.amount}</span>
<span className="text-yellow-400 font-semibold">{trade.leverage}x</span>
<span className={`px-2 py-1 rounded text-xs ${
trade.isActive ? 'bg-blue-600 text-white' :
trade.result === 'PROFIT' ? 'bg-green-600 text-white' :
@@ -604,6 +605,28 @@ export default function AutomationPage() {
</div>
</div>
{/* Trading Details */}
<div className="mb-3 p-3 bg-gray-900/30 rounded border border-gray-700">
<div className="grid grid-cols-2 gap-2 text-xs">
<div className="flex justify-between">
<span className="text-gray-300">Trading Amount:</span>
<span className="text-white">${trade.tradingAmount}</span>
</div>
<div className="flex justify-between">
<span className="text-gray-300">Leverage:</span>
<span className="text-yellow-400">{trade.leverage}x</span>
</div>
<div className="flex justify-between">
<span className="text-gray-300">Position Size:</span>
<span className="text-white">${trade.positionSize}</span>
</div>
<div className="flex justify-between">
<span className="text-gray-300">Entry Price:</span>
<span className="text-white">${trade.entryPrice.toFixed(2)}</span>
</div>
</div>
</div>
{/* Analysis Context */}
{trade.triggerAnalysis && (
<div className="mb-3 p-3 bg-gray-900 rounded border border-gray-600">
@@ -693,7 +716,7 @@ export default function AutomationPage() {
{/* Trade Summary */}
<div className="flex justify-between items-center text-xs border-t border-gray-700 pt-2">
<div className="text-gray-400">
{trade.duration}
{trade.duration} | ${trade.tradingAmount} @ {trade.leverage}x
</div>
<div className="flex items-center space-x-4">
<div className="text-gray-400">

Binary file not shown.