@@ -1184,7 +1184,7 @@ async def send_alarm_message(text):
11841184 bot = Bot (token = TELEGRAM_TOKEN )
11851185 await bot .send_message (chat_id = TELEGRAM_CHAT_ID , text = text )
11861186
1187- def check_and_alarm_high_volume (context = None ):
1187+ async def check_and_alarm_high_volume (context = None ):
11881188 """Check all symbols for volume > MIN_VOLUME and send Telegram alarm if found."""
11891189 stats = load_symbol_stats ()
11901190 if not stats :
@@ -1198,13 +1198,11 @@ def check_and_alarm_high_volume(context=None):
11981198 msg = "🚨 High Volume Alert:\n "
11991199 for symbol , vol in alarmed :
12001200 msg += f"- { symbol } : Volume = { vol :,.0f} \n "
1201- # Use asyncio to send alarm
1202- import asyncio
1203- asyncio .run (send_alarm_message (msg ))
1201+ await send_alarm_message (msg )
12041202
12051203# --- Telegram alarm job setup ---
12061204async def alarm_job (context : CallbackContext ):
1207- check_and_alarm_high_volume ()
1205+ await check_and_alarm_high_volume (context )
12081206
12091207if __name__ == "__main__" :
12101208 refresh_symbols ()
@@ -1221,3 +1219,5 @@ async def alarm_job(context: CallbackContext):
12211219 print ("\n [INFO] Shutting down gracefully..." )
12221220 finally :
12231221 print ("[INFO] Goodbye!" )
1222+ finally :
1223+ print ("[INFO] Goodbye!" )
0 commit comments