feat: Add phantom trade detection and database tracking
- Detect position size mismatches (>50% variance) after opening - Save phantom trades to database with expectedSizeUSD, actualSizeUSD, phantomReason - Return error from execute endpoint to prevent Position Manager tracking - Add comprehensive documentation of phantom trade issue and solution - Enable data collection for pattern analysis and future optimization Fixes oracle price lag issue during volatile markets where transactions confirm but positions don't actually open at expected size.
This commit is contained in:
@@ -103,9 +103,15 @@ model Trade {
|
||||
timeframe String? // "5", "15", "60"
|
||||
|
||||
// Status
|
||||
status String @default("open") // "open", "closed", "failed"
|
||||
status String @default("open") // "open", "closed", "failed", "phantom"
|
||||
isTestTrade Boolean @default(false) // Flag test trades for exclusion from analytics
|
||||
|
||||
// Phantom trade detection
|
||||
isPhantom Boolean @default(false) // Position opened but size mismatch >50%
|
||||
expectedSizeUSD Float? // Expected position size (when phantom)
|
||||
actualSizeUSD Float? // Actual position size from Drift (when phantom)
|
||||
phantomReason String? // "ORACLE_PRICE_MISMATCH", "PARTIAL_FILL", "ORDER_REJECTED"
|
||||
|
||||
// Relations
|
||||
priceUpdates PriceUpdate[]
|
||||
|
||||
|
||||
Reference in New Issue
Block a user