# Liquidation alert bot (Python) The Python twin of [liquidation-alert-bot](../liquidation-alert-bot/): alerts on big liquidations and liquidation cascades, and warns once per cluster when the price comes close to a large liquidation cluster of the heatmap. Alerts go to stdout and, optionally, to any JSON webhook (`ALERT_WEBHOOK_URL`, e.g. a Slack incoming webhook). Standard library plus the `blockmetric` SDK. | `BOT_MODE` | Plan | How | |---|---|---| | `stream` | API Pro | live stream, reconnects with `Last-Event-ID` (`client.stream(..., stop_event=...)`) | | `webhook` | API Dev, API Pro | signed webhooks pushed to this process; verifies `Blockmetric-Signature` | | `poll` | every key | `client.follow("liquidations", ...)`: new liquidations >= `BOT_MIN_USD` | | `auto` (default) | | `stream`, falling back to `poll` without API Pro | ```bash export BLOCKMETRIC_API_KEY=bm_live_... # create one on /account/api export BLOCKMETRIC_BASE_URL=https:///api/v1 export PYTHONPATH=../../sdk/python # until the SDK is on PyPI (PowerShell: $env:PYTHONPATH="..\..\sdk\python") python bot.py # auto BOT_MODE=webhook BLOCKMETRIC_WEBHOOK_SECRET=whsec_... PORT=3000 python bot.py ``` The variables are the same as for the Node bot: `BOT_COINS` (`BTC,ETH`), `BOT_KINDS`, `BOT_MIN_SEVERITY` (`2`), `BOT_MIN_USD` (`250000`), `BOT_CLUSTER_MIN_USD` (`5000000`), `BOT_CLUSTER_DISTANCE` (`0.01` = 1 %), `BOT_CLUSTER_MINUTES` (`5`, `0` = off), `POLL_SECONDS` (`15`), `PORT`, `HOOK_PATH` (`/hook`), `ALERT_WEBHOOK_URL`, `BOT_EXIT_AFTER` (`0` = run until Ctrl+C). Ctrl+C sets the bot's stop event: the stream connection is closed right away, polling and the webhook server end at once. Each alert is sent once. Not investment advice.