kraken-alert-patterns
Price alerts, threshold monitoring, and notification triggers for agents.
Example driver: turn incoming webhook signals into validated paper trades inside a recorded session.
Claude Code
$ npx -y skills add krakenfx/kraken-cli --skill recipe-playground-webhook --agent claude-code
Codex
$ npx skills add krakenfx/kraken-cli --skill recipe-playground-webhook -a codex -y
Cursor
$ npx skills add krakenfx/kraken-cli --skill recipe-playground-webhook -a cursor -y
Gemini CLI
$ npx skills add krakenfx/kraken-cli --skill recipe-playground-webhook -a gemini-cli -y
GitHub Copilot
$ npx skills add krakenfx/kraken-cli --skill recipe-playground-webhook -a github-copilot -y
OpenCode
$ npx skills add krakenfx/kraken-cli --skill recipe-playground-webhook -a opencode -y
Windsurf
$ npx skills add krakenfx/kraken-cli --skill recipe-playground-webhook -a windsurf -y
name: recipe-playground-webhook
version: 1.0.0
description: "Example driver: turn incoming webhook signals into validated paper trades inside a recorded session."
metadata:
openclaw:
category: "recipe"
domain: "sessions"
requires:
bins: ["kraken", "python3"]
skills: ["kraken-playground"]> **PREREQUISITE:** Load `kraken-playground` to run this recipe. > **This recipe is an example, not a boundary.** Adapt the steps to your signal source, or write your own driver (see `kraken-playground` → Driving Your Own Hypothesis).
Bridge an external system into the sandbox: a TradingView alert, a CI job, or a plain `curl` POSTs a signal to a local listener, and each valid signal becomes a paper order inside a recorded session. The market tape, the fills, and the signal-to-order decisions all land in one window for replay and P&L.
Use this skill for:
This recipe records a session inside a paper workspace. With that workspace named on every session and order call and checked before the listener starts (see Hard Rules), it never places a live order.
The webhook payload is **untrusted input**. Every field is validated against an allowlist or a numeric bound before it reaches an order — a signal that fails any check is logged as a skip, never executed, and never interpolated into a command.
The listener binds `127.0.0.1` only. Do not bind other interfaces and do not port-forward it; anyone who can reach the port can trade the paper account. If the signal source is remote, tunnel (e.g. `ssh -R`) rather than expose.
The signal stream is the loop, not `/loop` — the same long-lived-process exception as the dip-triggered recipe (see `kraken-playground` → Pacing).
One JSON object per POST body:
{"symbol": "BTC/USD", "side": "buy", "qty": "0.001", "token": "<shared-secret>", "note": "free text"}`symbol`, `side`, `qty` are required; `token` is required when the loop has a token set; `note` is echoed into the decision reason.
Every bound that gates execution goes in `--strategy-params`:
Natural language:
Listen on localhost:8787 for webhook signals. Trade only BTC/USD, at most $500 per signal, at most 10 signals, then stop. Record every accepted and rejected signal with its reason. At the end, show P&L.
Work inside a paper workspace (create one once: `kraken workspace create hook --capital 10000 --mode paper`). Every session and order command below names it with `--workspace hook`. An exported `KRAKEN_WORKSPACE` does not reach a loop started from another shell, and without a workspace `kraken order` trades the real account.
kraken --workspace hook session start \
--symbols BTC/USD --channels ticker,trade --to duckdb,jsonl \
--label hook-btc-$(date +%Y%m%d-%H%M%S) \
--strategy recipe-playground-webhook \
--strategy-params '{"port":8787,"allowed_symbols":["BTC/USD"],"max_notional_per_signal":500,"max_signals":10}' \
-o json 2>/dev/null &
# The session_started stdout line carries the id: {"type":"session_started","session":"s<n>",...}Print the session id to the user right after starting, and again in the final report.
The listener appends each POST body to a signals file **outside the session directory** (the recorder owns that tree); the decision loop tails it. Both die with the session.
PORT=8787
ALLOWED_SYMBOLS="BTC/USD" # space-separated allowlist
MAX_NOTIONAL=500
MAX_SIGNALS=10
TOKEN="${HOOK_TOKEN:-}" # empty accepts signals without a token
SIGNALS=$(mktemp -t hook-signals)
# The orders below are simulated only while hook is a paper workspace.
[ "$(kraken workspace show hook -o json 2>/dev/null | jq -r '.mode')" = paper ] \
|| { echo "workspace hook is missing or not paper; not listening" >&2; exit 1; }
python3 - "$PORT" "$SIGNALS" <<'PY' &
import http.server, sys
port, path = int(sys.argv[1]), sys.argv[2]
class H(http.server.BaseHTTPRequestHandler):
def do_POST(self):
body = self.rfile.read(int(self.headers.get("Content-Length", 0)))
with open(path, "ab") as f:
f.write(body.strip() + b"\n")
self.send_response(204); self.end_headers()
def log_message(self, *args): pass
http.server.HTTPServer(("127.0.0.1", port), H).serve_forever()
PY
LISTENER=$!
DONE=0
tail -n +1 -f "$SIGNALS" | while read -r sig; do
SYMBOL=$(echo "$sig" | jq -r '.symbol // empty')
SIDE=$(echo "$sig" | jq -r '.side // empty')
QTY=$(echo "$sig" | jq -r '.qty // empty')
NOTE=$(echo "$sig" | jq -r '.note // ""')
# The token never goes into a reason: reasons are recorded in the session.
if [ -n "$TOKEN" ] && [ "$(echo "$sig" | jq -r '.token // empty')" != "$TOKEN" ]; then
kraken --workspace hook session note --kind skip --reason "webhook rejected: missing or wrong token" -o json 2>/dev/null; continue
fi
# Untrusted input: allowlist the enum and the pair, bound the number.
# A failed check is a recorded skip — never a clamped or guessed order.
case "$SIDE" in buy|sell) ;; *)
kraken --workspace hook session note --kind skip --reason "webhook rejectedTrade on Kraken from your terminal, or let your AI agent trade for you. One install covers crypto, tokenized U.S. stocks and ETFs (for non-U.S. customers), forex, and futures. Every command can answer in JSON.
Price alerts, threshold monitoring, and notification triggers for agents.
Progress from manual trading to full agent autonomy with controlled risk at each level.
Capture the spot-futures price spread with delta-neutral basis trades.
Dollar cost averaging with scheduled buys and performance tracking.
Discover staking strategies, allocate funds, and track earn positions.
Handle order failures, network errors, and duplicate submissions safely.
Complete, populate and fill out 3-statement financial model templates (Income Statement, Balance Sheet, Cash Flow Statement) .…
Complete, populate and fill out 3-statement financial model templates (Income Statement, Balance Sheet, Cash Flow Statement) .…