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:
mindesbunister
2025-10-27 09:35:01 +01:00
parent 1da5db5e75
commit 8e5c592cac
9 changed files with 589 additions and 8 deletions

View File

@@ -0,0 +1,2 @@
-- AlterTable
ALTER TABLE "Trade" ADD COLUMN "isTestTrade" BOOLEAN NOT NULL DEFAULT false;

View File

@@ -68,6 +68,7 @@ model Trade {
// Status
status String @default("open") // "open", "closed", "failed"
isTestTrade Boolean @default(false) // Flag test trades for exclusion from analytics
// Relations
priceUpdates PriceUpdate[]