Beginner ~15 min Python Build guide

Webhook Alerts

Get notified instantly when indicator conditions are met. Send alerts to Discord, Slack, Telegram, or any custom webhook endpoint.

1 sections 1 copy-paste code sample Python
1Guide sections
1Code samples
BeginnerLevel
15 minTime

Alert System with Python

Poll the API at regular intervals and fire webhooks when conditions are triggered:

Python Alert System with Python
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

RSI Extremes Alert when RSI crosses above 70 (overbought) or below 30 (oversold)
MACD Crossover Alert when MACD line crosses the signal line in either direction
Bollinger Band Touch Alert when price touches or crosses the upper/lower band
ADX Trend Start Alert when ADX crosses above 25 (new trend forming)

Production hardening

The code above is the happy path. These are the concerns that decide whether it survives contact with a real deployment.

Keep the key server-side. The API key authenticates with the X-API-Key header and must never reach a browser bundle. Proxy it, or use a public widget key, which is domain-scoped and revocable. Authentication
Handle 429 before you need to. Rate limits are per key and per minute. Back off on 429 rather than retrying immediately, and read the X-RateLimit-* headers on every response. Rate limits
Branch on the error code, not the message. Errors carry a stable machine-readable code; the human-readable text can change. Codes were unified in v3.15. Error handling
Expect gaps, and do not invent values. Markets close, feeds stall, and a retention window can reject a request outright. Surface an explicit unavailable state rather than substituting a zero or the last known price. Troubleshooting
Cache what you poll. Responses are already cached briefly upstream, so polling faster than the data changes spends credits without improving freshness. Cache on your side and poll on the cadence your timeframe actually updates. Pricing and credits
Watch retention per timeframe. History depth is set per timeframe, never per plan, so a request that works on D1 can fall outside the window on M1. Check the published windows before backfilling. Timeframes
Rotate keys and scope them. Issue a separate key per deployment so one can be revoked without taking the others down, and rotate on a schedule rather than after an incident. Authentication
Log the request, not the key. Record endpoint, parameters, status and latency so a failure is reproducible. Never log the key itself, and scrub it from error reports.

Related Guides

Everything this guide touches, linked directly — so it never dead-ends.

Build against live market data

Start with the data layer already solved.

Create an API key, run the first request, then extend one layer at a time. Every account starts pay-as-you-go with $2.50 of credit.