Skip to content

Instantly share code, notes, and snippets.

@koliadych
Created May 10, 2026 22:15
Show Gist options
  • Select an option

  • Save koliadych/fbb01aebb93d6b4fb7c0b4f4c0abc546 to your computer and use it in GitHub Desktop.

Select an option

Save koliadych/fbb01aebb93d6b4fb7c0b4f4c0abc546 to your computer and use it in GitHub Desktop.
fintechner balance + strategy audit
#!/bin/bash
set -euo pipefail
export AWS_PAGER=""
REGION=ap-northeast-1
INSTANCE_ID=i-089ad4a6b76132ba2
CMD_ID=$(aws --region "$REGION" ssm send-command \
--instance-ids "$INSTANCE_ID" \
--document-name AWS-RunShellScript \
--parameters '{"commands":[
"echo === connector binary SHA ===",
"sudo sha256sum /opt/fintechner/bin/connector | cut -d\" \" -f1",
"echo",
"echo === active env from DB ===",
"sudo docker exec timescale psql -U fintechner -d fintechner -c \"SELECT * FROM hl_runtime_settings;\" 2>&1 | head -10",
"echo",
"echo === hl_credentials ===",
"sudo docker exec timescale psql -U fintechner -d fintechner -c \"SELECT id, env, account_addr, instruments FROM hl_credentials;\" 2>&1 | head -10",
"echo",
"echo === strategies in DB ===",
"sudo docker exec timescale psql -U fintechner -d fintechner -c \"SELECT id, name, type, state, created_at FROM strategy_configs;\" 2>&1 | head -15",
"echo",
"echo === recent strategy_decisions (10 newest) ===",
"sudo docker exec timescale psql -U fintechner -d fintechner -c \"SELECT ts, strategy_id, coin, side, price, size, reason, state FROM strategy_decisions ORDER BY ts DESC LIMIT 10;\" 2>&1 | head -25",
"echo",
"echo === orders in DB (10 newest) ===",
"sudo docker exec timescale psql -U fintechner -d fintechner -c \"SELECT cloid, origin, owner_id, coin, side, status, submitted_at, error_msg FROM orders ORDER BY submitted_at DESC LIMIT 10;\" 2>&1 | head -20",
"echo",
"echo === connector logs about strategy / order intent / risk ===",
"sudo journalctl -u fintechner-connector --since \"15 min ago\" --no-pager 2>&1 | grep -iE \"strategy|intent|risk.*reject|order.*reject|halted\" | tail -25",
"echo",
"echo === current account state (direct from connector) ===",
"curl -sS http://localhost:8080/admin/account 2>&1 | head -30 || echo curl-failed"
]}' \
--query Command.CommandId --output text)
for i in $(seq 1 25); do
sleep 4
STATUS=$(aws --region "$REGION" ssm get-command-invocation --command-id "$CMD_ID" --instance-id "$INSTANCE_ID" --query Status --output text 2>/dev/null || echo Pending)
case "$STATUS" in Success|Failed|Cancelled|TimedOut) echo " $STATUS"; break ;; *) echo " $STATUS";; esac
done
echo
aws --region "$REGION" ssm get-command-invocation --command-id "$CMD_ID" --instance-id "$INSTANCE_ID" --query StandardOutputContent --output text
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment