fix: harden drift verifier and validation flow
This commit is contained in:
@@ -349,7 +349,8 @@ export class PositionManager {
|
||||
this.activeTrades.delete(tradeId)
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('❌ Error checking Drift position during trade removal:', error)
|
||||
const errorMessage = `❌ Error checking Drift position during trade removal: ${error instanceof Error ? error.message : String(error)}`
|
||||
console.error(errorMessage)
|
||||
console.warn('⚠️ Removing from tracking without canceling orders (safety first)')
|
||||
|
||||
// On error, err on side of caution - don't cancel orders
|
||||
|
||||
@@ -102,9 +102,9 @@ class SmartValidationQueue {
|
||||
},
|
||||
qualityScore: params.qualityScore,
|
||||
blockedAt: Date.now(),
|
||||
entryWindowMinutes: 30, // Watch for 30 minutes (extended from 10 - Dec 7, 2025)
|
||||
confirmationThreshold: 0.3, // Need +0.3% move to confirm
|
||||
maxDrawdown: -0.4, // Abandon if -0.4% against direction
|
||||
entryWindowMinutes: 90, // Two-stage: watch for 90 minutes
|
||||
confirmationThreshold: 0.15, // Two-stage: need +0.15% move to confirm
|
||||
maxDrawdown: -0.4, // Abandon if -0.4% against direction (unchanged)
|
||||
highestPrice: params.originalPrice,
|
||||
lowestPrice: params.originalPrice,
|
||||
status: 'pending',
|
||||
@@ -112,7 +112,7 @@ class SmartValidationQueue {
|
||||
|
||||
this.queue.set(signalId, queuedSignal)
|
||||
console.log(`⏰ Smart validation queued: ${params.symbol} ${params.direction.toUpperCase()} @ $${params.originalPrice.toFixed(2)} (quality: ${params.qualityScore})`)
|
||||
console.log(` Watching for ${queuedSignal.entryWindowMinutes}min: +${queuedSignal.confirmationThreshold}% confirms, ${queuedSignal.maxDrawdown}% abandons`)
|
||||
console.log(` Two-stage watch ${queuedSignal.entryWindowMinutes}min: +${queuedSignal.confirmationThreshold}% confirms, ${queuedSignal.maxDrawdown}% abandons`)
|
||||
|
||||
// Send Telegram notification
|
||||
await sendValidationNotification({
|
||||
@@ -463,14 +463,14 @@ export async function startSmartValidation(): Promise<void> {
|
||||
const { getPrismaClient } = await import('../database/trades')
|
||||
const prisma = getPrismaClient()
|
||||
|
||||
// Find signals blocked within last 30 minutes (entry window)
|
||||
const thirtyMinutesAgo = new Date(Date.now() - 30 * 60 * 1000)
|
||||
// Find signals blocked within last 90 minutes (two-stage entry window)
|
||||
const ninetyMinutesAgo = new Date(Date.now() - 90 * 60 * 1000)
|
||||
|
||||
const recentBlocked = await prisma.blockedSignal.findMany({
|
||||
where: {
|
||||
blockReason: 'QUALITY_SCORE_TOO_LOW',
|
||||
signalQualityScore: { gte: 50, lt: 90 }, // Marginal quality range
|
||||
createdAt: { gte: thirtyMinutesAgo },
|
||||
createdAt: { gte: ninetyMinutesAgo },
|
||||
},
|
||||
orderBy: { createdAt: 'desc' },
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user