feat: Integrate ADX validation into revenge system using 1-min market data

ENHANCEMENTS:
- Revenge system now checks fresh ADX from 1-minute market data cache
- Blocks revenge if ADX < 20 (weak trend - not worth re-entering)
- Executes revenge if ADX >= 20 (strong trend - high probability)
- Saves revengeFailedReason='ADX_TOO_LOW_X.X' for blocked attempts
- Telegram notification shows ADX check result

DATABASE:
- Added revengeFailedReason field to StopHunt table
- Added revengePnL field to track revenge trade outcomes

INTEGRATION:
- Uses getPythPriceMonitor().getCachedPrice() for fresh data
- Falls back to originalADX if cache unavailable
- Logs ADX validation: 'ADX check: X.X (threshold: 20)'

1-MINUTE DATA COLLECTION COMPLETE:
- TradingView alerts recreated with new format
- Bot correctly filters timeframe='1' → BlockedSignal
- Market data cache updates every 60 seconds
- Verified working: 2 signals collected, 0 trades executed
This commit is contained in:
mindesbunister
2025-11-27 10:16:59 +01:00
parent 649628a5c2
commit 702d08b0ba
2 changed files with 79 additions and 0 deletions

View File

@@ -173,3 +173,37 @@ async function sendWithdrawalNotification(options: TelegramWithdrawalOptions): P
console.error('❌ Error sending Telegram notification:', error)
}
}
/**
* Send a generic text message to Telegram
* Used for alerts, revenge blocks, system notifications
*/
export async function sendTelegramMessage(message: string): Promise<void> {
try {
const token = process.env.TELEGRAM_BOT_TOKEN
const chatId = process.env.TELEGRAM_CHAT_ID
if (!token || !chatId) {
console.log('⚠️ Telegram credentials not configured, skipping notification')
return
}
const url = `https://api.telegram.org/bot${token}/sendMessage`
const response = await fetch(url, {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({
chat_id: chatId,
text: message,
parse_mode: 'HTML'
})
})
if (!response.ok) {
const errorData = await response.json()
console.error('❌ Telegram notification failed:', errorData)
}
} catch (error) {
console.error('❌ Error sending Telegram notification:', error)
}
}