Alert System with Python
Poll the API at regular intervals and fire webhooks when conditions are triggered:
from flask import Flask, jsonify
import requests, schedule, threading, time
app = Flask(__name__)
API_KEY = "YOUR_API_KEY"
BASE = "https://tickatlas.com/v1"
WEBHOOK_URL = "https://your-app.com/webhook" # or Discord/Slack URL
def check_alerts():
"""Check indicator conditions and fire webhooks."""
headers = {"X-API-Key": API_KEY}
symbols = ["EURUSD", "GBPUSD", "XAUUSD"]
for sym in symbols:
rsi = requests.get(f"{BASE}/indicator",
headers=headers,
params={"symbol": sym, "indicator": "RSI_14", "timeframe": "H1"}
).json()
value = rsi["data"]["value"]
if value < 30:
fire_alert(sym, "RSI OVERSOLD", value)
elif value > 70:
fire_alert(sym, "RSI OVERBOUGHT", value)
def fire_alert(symbol, condition, value):
"""Send alert via webhook."""
payload = {
"text": f"Alert: {symbol} - {condition} (RSI: {value:.1f})",
"symbol": symbol,
"condition": condition,
"value": value
}
requests.post(WEBHOOK_URL, json=payload)
print(f"Alert fired: {symbol} {condition}")
# Check every 5 minutes
schedule.every(5).minutes.do(check_alerts)
def run_scheduler():
while True:
schedule.run_pending()
time.sleep(30)
threading.Thread(target=run_scheduler, daemon=True).start()
check_alerts() # Run immediately Popular Alert Conditions
Production hardening
The code above is the happy path. These are the concerns that decide whether it survives contact with a real deployment.
Related Guides
Everything this guide touches, linked directly — so it never dead-ends.