# Функция для отправки email def send_email(subject, message): msg = MIMEMultipart() msg['From'] = email_from msg['To'] = email_to msg['Subject'] = subject
msg.attach(MIMEText(message, 'plain')) server = smtplib.SMTP(smtp_server, smtp_port) server.starttls() server.login(smtp_username, smtp_password) text = msg.as_string() server.sendmail(email_from, email_to, text) server.quit()
# Основная логика def check_large_trades(): trades = exchange.fetch_trades(symbol) for trade in trades: if trade['amount'] >= large_trade_volume: if trade['side'] == 'buy': send_email('Buy Alert', f'Large buy trade detected: {trade}') elif trade['side'] == 'sell': send_email('Sell Alert', f'Large sell trade detected: {trade}')
# Запуск проверки в бесконечном цикле import time while True: try: check_large_trades() time.sleep(60) # Проверка каждые 60 секунд except Exception as e: print(f'Error: {e}') time.sleep(60)
The information and publications are not meant to be, and do not constitute, financial, investment, trading, or other types of advice or recommendations supplied or endorsed by TradingView. Read more in the Terms of Use.