feat: implement per-symbol cooldown period
CRITICAL: Cooldown was global across ALL symbols, causing missed opportunities Example: ETH trade at 10:00 blocked SOL trade at 10:04 (5min cooldown) Changes: - Added getLastTradeTimeForSymbol() function to query last trade per symbol - Updated check-risk endpoint to use symbol-specific cooldown - Each coin (SOL/ETH/BTC) now has independent cooldown timer - Cooldown message shows symbol: 'Must wait X min before next SOL-PERP trade' Result: Can trade ETH and SOL simultaneously without interference Example: ETH LONG at 10:00, SOL SHORT at 10:01 = both allowed
This commit is contained in:
@@ -276,6 +276,26 @@ export async function getLastTradeTime(): Promise<Date | null> {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the most recent trade time for a specific symbol
|
||||
*/
|
||||
export async function getLastTradeTimeForSymbol(symbol: string): Promise<Date | null> {
|
||||
const prisma = getPrismaClient()
|
||||
|
||||
try {
|
||||
const lastTrade = await prisma.trade.findFirst({
|
||||
where: { symbol },
|
||||
orderBy: { entryTime: 'desc' },
|
||||
select: { entryTime: true },
|
||||
})
|
||||
|
||||
return lastTrade?.entryTime || null
|
||||
} catch (error) {
|
||||
console.error(`❌ Failed to get last trade time for ${symbol}:`, error)
|
||||
return null
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the most recent trade with full details
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user