shaikhmarketing's picture
Update utils.py
a0aca79 verified
raw
history blame
1.35 kB
import requests
import smtplib
from email.mime.text import MIMEText
from email.mime.multipart import MIMEMultipart
def get_live_usdt_dominance():
"""Fetches global USDT Dominance to act as a Macro Kill Switch."""
try:
url = "https://api.coingecko.com/api/v3/global"
response = requests.get(url, timeout=5).json()
return response['data']['market_cap_percentage']['usdt']
except Exception as e:
print(f"Error fetching macro data: {e}")
# Returns a high number on failure to trigger safety kill switch
return 100.0
def send_email_alert(sender_email, sender_password, receiver_email, symbol, message):
"""Packages and sends the AI trade signal directly to your email inbox."""
try:
msg = MIMEMultipart()
msg['From'] = sender_email
msg['To'] = receiver_email
msg['Subject'] = f"🎯 AI TRADE ALERT: Prime Setup on {symbol}"
msg.attach(MIMEText(message, 'plain'))
# Standard Gmail SMTP server settings
server = smtplib.SMTP('smtp.gmail.com', 587)
server.starttls()
server.login(sender_email, sender_password)
server.send_message(msg)
server.quit()
print(f"Email successfully sent for {symbol}")
except Exception as e:
print(f"Failed to send email: {e}")