fix: Block disabled symbols (FARTCOIN) from risk check to prevent unwanted Telegram notifications

This commit is contained in:
mindesbunister
2025-12-21 14:27:33 +01:00
parent aafc4ce506
commit e60e6d4030

View File

@@ -190,9 +190,38 @@ export async function POST(request: NextRequest): Promise<NextResponse<RiskCheck
console.log('🔍 Risk check for:', body)
// Get configuration
const config = getMergedConfig()
// CRITICAL FIX (Dec 21, 2025): Check if symbol is enabled FIRST
// Reject disabled symbols early so n8n doesn't send Telegram notifications for them
// Only affects 5-minute trading signals (data collection signals bypass this check)
const normalizedSymbol = normalizeTradingViewSymbol(body.symbol)
const timeframe = body.timeframe || '5'
if (timeframe === '5') {
// Check if this symbol is enabled for trading
let symbolEnabled = true
if (normalizedSymbol === 'SOL-PERP' && config.solana) {
symbolEnabled = config.solana.enabled
} else if (normalizedSymbol === 'ETH-PERP' && config.ethereum) {
symbolEnabled = config.ethereum.enabled
} else if (normalizedSymbol === 'FARTCOIN-PERP' && config.fartcoin) {
symbolEnabled = config.fartcoin.enabled
}
if (!symbolEnabled) {
console.log(`⛔ Risk check BLOCKED: ${normalizedSymbol} trading disabled (data collection only)`)
return NextResponse.json({
allowed: false,
reason: 'Symbol trading disabled',
details: `${normalizedSymbol} is configured for data collection only (not trading)`,
})
}
}
// 🔬 MULTI-TIMEFRAME DATA COLLECTION
// Allow all non-5min signals to bypass risk checks (they'll be saved as data collection in execute endpoint)
const timeframe = body.timeframe || '5'
if (timeframe !== '5') {
console.log(`📊 DATA COLLECTION: ${timeframe}min signal bypassing risk checks (will save in execute endpoint)`)
return NextResponse.json({
@@ -202,8 +231,6 @@ export async function POST(request: NextRequest): Promise<NextResponse<RiskCheck
})
}
const config = getMergedConfig()
// Check for existing positions on the same symbol
const positionManager = await getInitializedPositionManager()
const existingTrades = Array.from(positionManager.getActiveTrades().values())