Skip to main content

Overview

CryptoView Pro features a comprehensive alert system that monitors cryptocurrency prices and technical indicators 24/7. Get instant notifications via Telegram when your conditions are met.

Alert Types

The system supports multiple alert condition types:

Price Alerts

Trigger when price crosses a thresholdExample: Alert when BTC > $100,000

RSI Alerts

Trigger on overbought/oversold conditionsExample: Alert when RSI < 30

Percentage Change

Trigger on price movementsExample: Alert when +5% in 24h

Setting Up Alerts

Basic Alert Creation

from utils.alerts import AlertSystem

# Initialize alert system
alert_system = AlertSystem()

# Create a price alert
price_alert = {
    'crypto': 'BTC/USDT',
    'type': 'Precio',
    'condition': 'Mayor que',
    'threshold': 95000.0,
    'methods': ['App', 'Telegram']
}

alert_system.add_alert(price_alert)

# Create an RSI alert
rsi_alert = {
    'crypto': 'ETH/USDT',
    'type': 'RSI',
    'condition': 'Menor que',
    'threshold': 30,
    'methods': ['Telegram']
}

alert_system.add_alert(rsi_alert)

Alert Configuration Options

crypto
string
required
Cryptocurrency pair (e.g., “BTC/USDT”, “ETH/USDT”)
type
string
required
Alert type: “Precio”, “RSI”, or “Cambio %”
condition
string
required
Condition operator: “Mayor que” (greater than) or “Menor que” (less than)
threshold
number
required
Threshold value to trigger alert
methods
array
Notification methods: [“App”, “Telegram”, “Email”]

Checking Alerts

The system automatically evaluates alerts against current market data:
from utils.alerts import alert_system

# Current market data
current_data = {
    'precio': 96500.0,  # Current price
    'rsi': 28.5,        # Current RSI
    'cambio %': 3.2     # 24h change percentage
}

# Check all active alerts
triggered = alert_system.check_alerts(current_data)

for alert in triggered:
    print(f"🔔 ALERT: {alert['crypto']} - {alert['type']} {alert['condition']} {alert['threshold']}")
    # Notification is automatically sent

Alert Evaluation Logic

def _evaluate_condition(alert: dict, data: dict) -> bool:
    """
    Evaluates if an alert condition is met
    
    Returns True if alert should trigger
    """
    alert_type = alert['type']
    condition = alert['condition']
    threshold = alert['threshold']
    
    # Get current value based on alert type
    value = data.get(alert_type.lower())
    
    if value is None:
        return False
    
    # Evaluate condition
    if condition == "Mayor que":
        return value > threshold
    elif condition == "Menor que":
        return value < threshold
    
    return False
View implementation at utils/alerts.py:38

Telegram Integration

Setup

1

Create Telegram Bot

  1. Open Telegram and search for @BotFather
  2. Send /newbot command
  3. Follow prompts to create your bot
  4. Save the bot token (looks like 123456789:ABCdefGHIjklMNOpqrsTUVwxyz)
2

Get Chat ID

  1. Start a chat with your new bot
  2. Send any message to the bot
  3. Visit: https://api.telegram.org/bot<YOUR_BOT_TOKEN>/getUpdates
  4. Find your chat_id in the JSON response
3

Configure Environment

Add credentials to your .env file:
TELEGRAM_BOT_TOKEN=123456789:ABCdefGHIjklMNOpqrsTUVwxyz
TELEGRAM_CHAT_ID=987654321
4

Initialize Notifier

from utils.telegram_notifier import TelegramNotifier

notifier = TelegramNotifier(
    bot_token=os.getenv('TELEGRAM_BOT_TOKEN'),
    chat_id=os.getenv('TELEGRAM_CHAT_ID')
)

# Test connection
if notifier.test_connection():
    print("✅ Telegram connected!")

Sending Messages

Basic Text Message

from utils.telegram_notifier import TelegramNotifier

notifier = TelegramNotifier(bot_token, chat_id)

# Send plain text
message = "Bitcoin reached $100,000!"
notifier.send_message(message)

# Send formatted message (Markdown)
message = """
*BITCOIN ALERT* 🚀

Price: $100,000
Change: +15.3%

_This is a historic moment!_
"""
notifier.send_message(message, parse_mode='Markdown')

Price Alert Notification

# Send price alert
notifier.send_alert(
    crypto='BTC/USDT',
    alert_type='Precio',
    current_value=96500.0,
    threshold=95000.0,
    condition='Mayor que'
)

# This sends a formatted message:
# 🚨 ALERTA CRYPTOVIEW PRO
# 
# 💰 BTC/USDT
# 📊 Tipo: Precio
# 
# 🎯 Condición: Mayor que 95000.0
# 📈 Valor actual: 96500.00
# 
# ⏰ 2026-03-07 14:32:15
View implementation at utils/telegram_notifier.py:51

Prediction Alert

# Send ML prediction alert
notifier.send_prediction_alert(
    crypto='BTC/USDT',
    current_price=94532.45,
    predicted_price=98450.00,
    hours=24,
    change_pct=4.14,
    confidence=87.5
)

# Formatted output:
# 🔮 PREDICCIÓN ML - CRYPTOVIEW PRO
# 
# 💰 BTC/USDT
# 
# 📊 Precio Actual: $94,532.45
# 📈 Predicción (24h): $98,450.00
# 📈 Cambio Esperado: +4.14%
# 🎯 Confianza: 87.5%
View implementation at utils/telegram_notifier.py:85

Trading Signal

# Send trading signal
notifier.send_signal(
    crypto='BTC/USDT',
    signal='COMPRA',  # or 'VENTA', 'NEUTRAL'
    current_price=94532.45,
    rsi=28.5,
    macd_signal='bullish'
)

# Output:
# 🟢 SEÑAL DE TRADING
# 
# 💰 BTC/USDT
# 💵 Precio: $94,532.45
# 
# 🎲 Señal: COMPRA
# 
# 📊 Indicadores:
# • RSI: 28.5
# • MACD: bullish
View implementation at utils/telegram_notifier.py:124

Advanced Usage

Automatic Alert Monitoring

import time
from utils.alerts import alert_system
from utils.telegram_notifier import TelegramNotifier
from data.collectors import CryptoDataCollector
from utils.indicators import TechnicalIndicators

def monitor_alerts(interval_seconds: int = 60):
    """
    Continuously monitor and trigger alerts
    """
    notifier = TelegramNotifier(bot_token, chat_id)
    collector = CryptoDataCollector('kraken')
    
    print("🔔 Alert monitoring started...")
    
    while True:
        try:
            # Fetch current data
            df = collector.fetch_ohlcv('BTC/USDT', '1h', limit=100)
            df = TechnicalIndicators.add_all_indicators(df)
            
            # Get current metrics
            current_price = df['close'].iloc[-1]
            current_rsi = df['rsi'].iloc[-1]
            
            price_24h_ago = df['close'].iloc[-24]
            change_24h = ((current_price - price_24h_ago) / price_24h_ago) * 100
            
            current_data = {
                'precio': current_price,
                'rsi': current_rsi,
                'cambio %': change_24h
            }
            
            # Check alerts
            triggered = alert_system.check_alerts(current_data)
            
            if triggered:
                print(f"⚠️ {len(triggered)} alert(s) triggered!")
            
            # Sleep until next check
            time.sleep(interval_seconds)
            
        except Exception as e:
            print(f"Error in monitoring loop: {e}")
            time.sleep(interval_seconds)

# Run monitoring (checks every 60 seconds)
monitor_alerts(interval_seconds=60)

Scheduled Reports

import schedule
import time
from utils.telegram_notifier import TelegramNotifier
from data.collectors import CryptoDataCollector

notifier = TelegramNotifier(bot_token, chat_id)
collector = CryptoDataCollector('kraken')

def send_daily_report():
    """
    Send daily market summary
    """
    cryptos = ['BTC/USDT', 'ETH/USDT', 'SOL/USDT']
    report_lines = ["📊 *REPORTE DIARIO*\n"]
    
    for crypto in cryptos:
        df = collector.fetch_ohlcv(crypto, '1h', limit=24)
        
        current_price = df['close'].iloc[-1]
        start_price = df['close'].iloc[0]
        change_pct = ((current_price - start_price) / start_price) * 100
        
        emoji = "📈" if change_pct > 0 else "📉"
        
        report_lines.append(
            f"{emoji} *{crypto}*\n"
            f"Precio: ${current_price:,.2f}\n"
            f"24h: {change_pct:+.2f}%\n"
        )
    
    report = "\n".join(report_lines)
    notifier.send_message(report)

# Schedule daily report at 9:00 AM
schedule.every().day.at("09:00").do(send_daily_report)

print("📅 Daily reports scheduled")

while True:
    schedule.run_pending()
    time.sleep(60)

Alert Management

Viewing Active Alerts

from utils.alerts import alert_system

# Get all active alerts
active_alerts = [a for a in alert_system.alerts if a['active']]

print(f"Active Alerts: {len(active_alerts)}")

for alert in active_alerts:
    print(f"\n  ID: {alert['id']}")
    print(f"  Crypto: {alert['crypto']}")
    print(f"  Type: {alert['type']}")
    print(f"  Condition: {alert['condition']} {alert['threshold']}")
    print(f"  Created: {alert['created'].strftime('%Y-%m-%d %H:%M:%S')}")

Deactivating Alerts

# Deactivate specific alert
alert_id = 3
for alert in alert_system.alerts:
    if alert['id'] == alert_id:
        alert['active'] = False
        print(f"✅ Alert {alert_id} deactivated")

# Deactivate all alerts for a crypto
crypto = 'BTC/USDT'
for alert in alert_system.alerts:
    if alert['crypto'] == crypto:
        alert['active'] = False

print(f"✅ All alerts for {crypto} deactivated")

Alert History

# View alert history
from utils.alerts import alert_system

print("Alert History:")
for event in alert_system.history:
    print(f"\n  {event['timestamp'].strftime('%Y-%m-%d %H:%M:%S')}")
    print(f"  {event['alert']['crypto']}: {event['alert']['type']} {event['alert']['condition']} {event['alert']['threshold']}")
    print(f"  Triggered at value: {event['value']}")

UI Integration

The web interface provides a visual alert management system:
# In Streamlit app (app.py:888)
import streamlit as st

st.markdown("## 🔔 Sistema de Alertas")

# Alert creation form
with st.form("alert_form"):
    col1, col2 = st.columns(2)
    
    with col1:
        alert_type = st.selectbox("Tipo", ["Precio", "RSI", "Cambio %"])
        condition = st.selectbox("Condición", ["Mayor que", "Menor que"])
    
    with col2:
        if alert_type == "Precio":
            threshold = st.number_input("Valor", value=float(current_price), step=100.0)
        else:
            threshold = st.number_input("Valor", value=70.0, step=5.0)
    
    if st.form_submit_button("✅ Crear Alerta", use_container_width=True):
        new_alert = {
            'crypto': crypto_symbol,
            'type': alert_type,
            'condition': condition,
            'threshold': threshold,
            'created': datetime.now()
        }
        st.session_state.alerts.append(new_alert)
        
        # Send to Telegram
        if st.session_state.telegram_notifier:
            st.session_state.telegram_notifier.send_alert(
                crypto_symbol, alert_type,
                current_price if alert_type == "Precio" else current_rsi,
                threshold, condition
            )
        
        st.success("✅ Alerta creada")

# Display active alerts
if st.session_state.alerts:
    st.markdown("### 📋 Alertas Activas")
    for i, alert in enumerate(st.session_state.alerts):
        col1, col2 = st.columns([4, 1])
        with col1:
            st.write(f"**{alert['crypto']}** - {alert['type']} {alert['condition']} {alert['threshold']}")
        with col2:
            if st.button("🗑️", key=f"del_{i}"):
                st.session_state.alerts.pop(i)
                st.rerun()
View implementation at app.py:888

Automation Script

For 24/7 monitoring without the UI:
# scripts/check_alerts.py
import os
import time
import sys
from pathlib import Path

# Add parent directory to path
sys.path.insert(0, str(Path(__file__).parent.parent))

from data.collectors import CryptoDataCollector
from utils.indicators import TechnicalIndicators
from utils.alerts import AlertSystem
from utils.telegram_notifier import TelegramNotifier
from config.settings import TELEGRAM_BOT_TOKEN, TELEGRAM_CHAT_ID

def main():
    # Initialize
    collector = CryptoDataCollector('kraken')
    alert_system = AlertSystem()
    notifier = TelegramNotifier(TELEGRAM_BOT_TOKEN, TELEGRAM_CHAT_ID)
    
    # Add your alerts
    alert_system.add_alert({
        'crypto': 'BTC/USDT',
        'type': 'Precio',
        'condition': 'Mayor que',
        'threshold': 100000.0
    })
    
    print("🔔 Alert monitoring started (Ctrl+C to stop)")
    
    while True:
        try:
            # Check each crypto
            for crypto in ['BTC/USDT', 'ETH/USDT']:
                df = collector.fetch_ohlcv(crypto, '1h', limit=100)
                df = TechnicalIndicators.add_all_indicators(df)
                
                current_data = {
                    'precio': df['close'].iloc[-1],
                    'rsi': df['rsi'].iloc[-1],
                    'cambio %': df['close'].pct_change(24).iloc[-1] * 100
                }
                
                triggered = alert_system.check_alerts(current_data)
                
                if triggered:
                    print(f"⚠️ Alert triggered for {crypto}")
            
            time.sleep(60)  # Check every minute
            
        except KeyboardInterrupt:
            print("\n👋 Monitoring stopped")
            break
        except Exception as e:
            print(f"Error: {e}")
            time.sleep(60)

if __name__ == "__main__":
    main()
Run with:
python scripts/check_alerts.py

Telegram Notifier Reference

Complete class documentation:
send_message
method
Send plain text or Markdown message
send_message(message: str, parse_mode: str = 'Markdown') -> bool
send_alert
method
Send formatted alert notification
send_alert(
    crypto: str,
    alert_type: str,
    current_value: float,
    threshold: float,
    condition: str
) -> bool
send_prediction_alert
method
Send ML prediction notification
send_prediction_alert(
    crypto: str,
    current_price: float,
    predicted_price: float,
    hours: int,
    change_pct: float,
    confidence: float
) -> bool
send_signal
method
Send trading signal notification
send_signal(
    crypto: str,
    signal: str,
    current_price: float,
    rsi: float,
    macd_signal: str
) -> bool
test_connection
method
Test Telegram connection
test_connection() -> bool

Best Practices

Alert Frequency

Don’t set too many alerts - focus on key levels to avoid notification fatigue

Threshold Spacing

Space thresholds apart (e.g., alerts at 95k,95k, 100k, not 95k,95k, 95.5k)

Test First

Always test Telegram connection before relying on alerts

Backup Methods

Use multiple notification methods for critical alerts

Code Reference

Key files for alert functionality:
  • utils/alerts.py:8 - AlertSystem class
  • utils/alerts.py:38 - Condition evaluation logic
  • utils/telegram_notifier.py:8 - TelegramNotifier class
  • utils/telegram_notifier.py:51 - Alert formatting
  • app.py:888 - UI alert management
Keep your Telegram bot token secret! Never commit it to version control. Always use environment variables.

Build docs developers (and LLMs) love