MAHMOUD ABDELNABY
Media Buying · CLI SCRIPT · 2

Ad Spend Anomaly & Seasonal Circuit Breaker

Protect client ad accounts from runaway budgets, checkout crashes, and accidental overspending with an automated circuit breaker.

Problem it addresses

Create a Python spend anomaly detection script (circuit_breaker.py) that monitors campaign spend records against hourly velocity thresholds, conversion drop-off anomalies, and CPA ceilings. Features: 1) Configurable JSON rules for spend limits, 2) Mock simulation test suite replicating flash-sale pacing spikes, 3) Out-of-the-box Telegram and Discord alert webhook dispatchers, 4) Complete operational runbook.

Who it is for

PRO operating in high-growth e-commerce, digital publishing, and direct-response marketing across Saudi Arabia, UAE, and Egypt.

What is inside

Key files listed in the README repository architecture:

  • config/alert_rules.sample.json
  • examples/simulated_spend_log.json
  • LICENSE
  • playbooks/emergency-runbook.md
  • README.md
  • src/circuit_breaker.py
  • tests/test_circuit_breaker.py

How to evaluate and use it

  1. Read the README first and confirm that the documented problem matches your use case.
  2. Inspect the listed files to find the data, tools, templates, and tests relevant to your task.
  3. Follow the repository’s Quick Start and check prerequisites before running commands.
  4. Compare outputs with documented examples and review limitations before using them in a decision or client workflow.

Quick Start from the README: python -m unittest discover -s tests · python src/circuit_breaker.py --help

Scope and limitations

  • Multi-Platform API Latency: Real-time spend anomaly detection must account for 15-to-45 minute reporting delays on Meta and TikTok APIs.
  • Seasonal Spend Spikes: Circuit breakers during White Friday or Ramadan require dynamic thresholds to avoid pausing profitable hyper-scaling campaigns.
  • Safe Auto-Pause Execution: Automated script errors default to notifying on-call media buyers via webhook rather than silently killing high-ROI ads.

This page summarizes the available documentation; it does not establish performance or business results. Verify data and prerequisites before use.

Related repositories