Fix database persistence and add analytics
- Fixed Prisma client not being available in Docker container - Added isTestTrade flag to exclude test trades from analytics - Created analytics views for net positions (matches Drift UI netting) - Added API endpoints: /api/analytics/positions and /api/analytics/stats - Added test trade endpoint: /api/trading/test-db - Updated Dockerfile to properly copy Prisma client from builder stage - Database now successfully stores all trades with full details - Supports position netting calculations to match Drift perpetuals behavior
This commit is contained in:
@@ -42,6 +42,7 @@ export interface CreateTradeParams {
|
||||
signalSource?: string
|
||||
signalStrength?: string
|
||||
timeframe?: string
|
||||
isTestTrade?: boolean
|
||||
}
|
||||
|
||||
export interface UpdateTradeExitParams {
|
||||
@@ -90,6 +91,7 @@ export async function createTrade(params: CreateTradeParams) {
|
||||
signalStrength: params.signalStrength,
|
||||
timeframe: params.timeframe,
|
||||
status: 'open',
|
||||
isTestTrade: params.isTestTrade || false,
|
||||
},
|
||||
})
|
||||
|
||||
@@ -204,6 +206,7 @@ export async function getTradeStats(days: number = 30) {
|
||||
where: {
|
||||
createdAt: { gte: since },
|
||||
status: 'closed',
|
||||
isTestTrade: false, // Exclude test trades from stats
|
||||
},
|
||||
})
|
||||
|
||||
|
||||
Reference in New Issue
Block a user