This commit is contained in:
dsyoon
2025-04-27 15:52:41 +09:00
parent aa3c15d924
commit b726c32548

View File

@@ -113,14 +113,13 @@ def get_stock_data(symbol, retries=3):
return None
def sendAlertMsg(info, market="US"):
if market == "US":
message = "🔔 [US] {} ({}) 현재가: ${:.2f}, 근접도: {:.2f}%".format(info['name'], info['symbol'], info['price'],
info['distance'])
def sendAlertMsg(info, market="US", alert=False):
if alert:
message = "🔔"
else:
message = "🔔 [KR] {} ({}) 현재가: ₩{:.0f}, 근접도: {:.2f}%".format(info['name'], info['symbol'].replace('.KS', ''),
info['price'], info['distance'])
message = ""
message += "[{}] {} ({}) 현재가: ${:.2f}, 근접도: {:.2f}%".format(market, info['name'], info['symbol'], info['price'], info['distance'])
try:
send_telegram_message(message)
except Exception as e:
@@ -140,9 +139,12 @@ def monitor_us_stocks():
info['name'] = US_STOCKS[symbol]
print(" - {} ({}): {:.2f} ({:.2f})".format(info['name'], symbol, info['price'], info['distance']))
if info['distance'] <= ALERT_THRESHOLD:
if info['distance'] > ALERT_THRESHOLD:
sendAlertMsg(info, "US")
else:
sendAlertMsg(info, "US", alert=True)
print(f"Alert generated for {symbol}")
except Exception as e:
print(f"Error processing data for {symbol}: {str(e)}")
else:
@@ -164,9 +166,12 @@ def monitor_kr_stocks():
info['name'] = KR_ETFS[symbol]
print(" - {} ({}): {:.2f} ({:.2f})".format(info['name'], symbol, info['price'], info['distance']))
if info['distance'] <= ALERT_THRESHOLD:
if info['distance'] > ALERT_THRESHOLD:
sendAlertMsg(info, "KR")
else:
sendAlertMsg(info, "KR", alert=True)
print(f"Alert generated for {symbol}")
except Exception as e:
print(f"Error processing data for {symbol}: {str(e)}")
else:
@@ -178,7 +183,7 @@ def monitor_kr_stocks():
def monitor_coins():
# 코인 모니터링
print("KR Coins {}".format(datetime.now().strftime('%Y-%m-%d %H:%M:%S')))
print("KRW Coins {}".format(datetime.now().strftime('%Y-%m-%d %H:%M:%S')))
for symbol in KR_COINS:
data = get_coin_data(symbol)
if data is not None and not data.empty:
@@ -188,9 +193,12 @@ def monitor_coins():
info['name'] = KR_COINS[symbol]
print(" - {} ({}): {:.2f} ({:.2f})".format(info['name'], symbol, info['price'], info['distance']))
if info['distance'] <= ALERT_THRESHOLD:
sendAlertMsg(info, "US")
if info['distance'] > ALERT_THRESHOLD:
sendAlertMsg(info, "KRW")
else:
sendAlertMsg(info, "KRW", alert=True)
print(f"Alert generated for {symbol}")
except Exception as e:
print(f"Error processing data for {symbol}: {str(e)}")
else: