Add last trade details to analytics dashboard
- Add getLastTrade() function to database service - Create /api/analytics/last-trade endpoint - Display last trade with full details on analytics page - Show entry/exit prices, P&L, position size, targets - Visual indicators for trade direction and exit reason - Helps quickly diagnose where trades went (TP1, TP2, or SL)
This commit is contained in:
@@ -272,6 +272,24 @@ export async function getLastTradeTime(): Promise<Date | null> {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the most recent trade with full details
|
||||
*/
|
||||
export async function getLastTrade() {
|
||||
const prisma = getPrismaClient()
|
||||
|
||||
try {
|
||||
const lastTrade = await prisma.trade.findFirst({
|
||||
orderBy: { createdAt: 'desc' },
|
||||
})
|
||||
|
||||
return lastTrade
|
||||
} catch (error) {
|
||||
console.error('❌ Failed to get last trade:', error)
|
||||
return null
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get count of trades in the last hour
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user