Works with the AI Agents you already use
Algorithmic & Paper Trading Risk Auditor
by Sam3gp8
Audit algorithmic and paper-trading bots for pre-trade risk gates, signal sanity checks, crash-safe state recovery, and paper/live isolation — deterministic guardrails last, before every order.
$7.99
What it does
- Checks that paper testing environments are strictly separated from live accounts
- Identifies where to add hard limits on order sizes and trading frequency
- Audits how your bot recovers its state and positions after a crash or timeout
- Ensures external signals or AI sentiment are double-checked before triggering trades
- Verifies that orders won't be duplicated during network lag or API errors
Who it's for
Traders building their own automated bots
Check your bot for bugs that could cause runaway orders or accidental live trades.
Try asking: “Review my Python bot logic to make sure it won't place duplicate orders if it crashes.”
Founders launching a trading tool startup
Ensure your execution engine has strict walls between paper testing and real money.
Try asking: “Audit our order flow to separate paper and live environments.”
Developers writing signal-based trading scripts
Add hard risk limits that stop bad AI signals from blowing up an account.
Try asking: “Check how I validate sentiment signals before they hit the broker API.”
Algorithmic & Paper Trading Risk Auditor
Example session with this skill installed
Review my trading bot's logic. I want to make sure that if the script crashes, it won't try to buy the same stock twice when it restarts, and that my paper API keys can't touch my live account.
- Read your context and instructions
- Compiled the algorithmic & paper
Trading Pipeline Risk Audit (bot.py / execution.py)
| Severity | Location | Failure Mode | Impact |
|---|---|---|---|
| CRITICAL | config.py:load_client() | Reads API_KEY and BASE_URL from a shared .env without asserting key/endpoint alignment | A single misconfigured env var routes paper-test signals directly into live funds |
| CRITICAL | execution.py:buy() | Tracks sent orders in an in-memory set updated after submit_order() returns | A crash or API timeout mid-flight leaves no local record; restart triggers a duplicate buy |
| HIGH | signals.py:evaluate() | AI sentiment score dispatches submit_order() directly without a downstream deterministic risk gate | A hallucinated or malformed signal bypasses position-size and order-rate limits |
| MEDIUM | broker.py:poll_fill() | Retries on 504 Gateway Timeout without a deterministic client_order_id | Network lag creates phantom double fills across retries |
Drop-In Isolation & Idempotent Order Guard (risk_gate.py)
import hashlib
import os
import sqlite3
from datetime import datetime, timezone
def assert_environment_isolation(mode: str, base_url: str, api_key: str) -> None:
"""Fail-closed startup check: abort if mode, URL, and key prefix disagree."""
is_paper_url = "paper-api" in base_url.lower()
if mode == "paper" and (not is_paper_url or api_key.startswith("AKLIVE")):
raise RuntimeError("ABORT: Paper mode paired with live endpoint or live key.")
if mode == "live" and (is_paper_url or os.getenv("ALLOW_LIVE_TRADING") != "YES"):
raise RuntimeError("ABORT: Live execution requires live endpoint and explicit opt-in.")
def make_client_order_id(strategy: str, symbol: str, side: str, bar_ts: str) -> str:
"""Deterministic idempotency key so restarts/retries never double-buy."""
raw = f"{strategy}:{symbol}:{side}:{bar_ts}"
return f"ord_{hashlib.sha256(raw.encode()).hexdigest()[:24]}"
def submit_with_guardrails(conn: sqlite3.Connection, broker, intent: dict) -> str:
cid = make_client_order_id(
intent["strategy"], intent["symbol"], intent["side"], intent["bar_ts"]
)
# 1. Fail-closed deterministic limits (last gate before broker)
if intent["notional"] > intent["max_position_usd"]:
raise ValueError(f"BLOCKED: notional {intent['notional']} exceeds cap")
# 2. Persist intent BEFORE network call (WAL/SQLite) + reconcile broker
row = conn.execute("SELECT status FROM order_intents WHERE cid = ?", (cid,)).fetchone()
if row or broker.get_order_by_client_id(cid):
return f"SKIPPED_DUPLICATE:{cid}"
conn.execute(
"INSERT INTO order_intents (cid, symbol, status, created_at) VALUES (?, ?, 'PENDING', ?)",
(cid, intent["symbol"], datetime.now(timezone.utc).isoformat()),
)
conn.commit()
return broker.submit_order(symbol=intent["symbol"], qty=intent["qty"], client_order_id=cid)
Pre-Deployment Verification Checklist
- Run
assert_environment_isolation()at process boot before initializing any strategy loop - Persist
order_intentsin SQLite (WAL mode) prior to every broker HTTP call - Reconcile all
PENDINGintents againstbroker.list_orders(status="all")on startup recovery - Enforce position-size, max-orders-per-minute, and daily drawdown caps strictly after AI/sentiment scoring
Connects securely to your tools. The creator never sees your data.
About this skill
Turns your agent into a risk-engineering auditor for algorithmic and paper-execution trading pipelines.
- Deterministic pre-trade gates last — treat LLM/sentiment pre-screens and pattern models as advisory; enforce hard risk limits (position sizing, order rate, drawdown/loss, market-hours) immediately before order dispatch.
- Strict paper/live isolation — separate credentials, endpoints, and state stores so tests or bugs can't cross-contaminate live accounts.
- Crash-safe state & idempotency — atomic open-order/position persistence and idempotent order tracking across restarts and API timeouts.
- Failure-mode audit — timeouts, partial fills, duplicate-order prevention, state recovery.
Technical and risk-engineering analysis only — not financial or investment advice.
Audits risk-engineering mechanics of a trading pipeline; it does not place trades, connect to a broker, or give financial/investment advice. Bring your own codebase.
Built for Claude Code, Cursor, ChatGPT, and MCP-compatible coding agents auditing Python, Node.js, or Go trading bots (Alpaca, IBKR, CCXT, and custom broker SDKs). Audit scope: • Deterministic pre-trade risk gates (position sizing, order-rate throttles, daily drawdown caps, market-hours checks) enforced last, fail-closed, after any AI or sentiment pre-screen. • Strict paper/live isolation (separate credential namespaces, explicit endpoint-to-mode startup assertions, and hard abort on mismatch). • Crash-safe state & idempotency (deterministic client_order_id generation, broker open-order reconciliation on restart, and atomic WAL/SQLite state persistence). • Failure-mode coverage (API timeouts, partial fills, duplicate-order prevention, and stale-quote rejection).
How to use
- 1
Connect your agent to the Agensi MCP
Copy the prompt and paste it into Claude, ChatGPT, Cursor or any agent that supports MCP. It sets up the connection for you. Manual setup
- 2
Sign in to Agensi
Your agent shows a sign-in link. Sign in and click Allow.
- 3
Ask for what you need
Your agent loads this skill and uses it on your task. It always asks before buying a skill.
Reviews
No reviews yet
Be one of the first to try it. Every listed skill goes through the trust checks below.
Security scanned
Checked by our 8-point scan before listing
Fresh listing
Recently published to Agensi
Money-back guarantee
Doesn't do what its page promises? You get your money back.
Trust & safety
Security scan
Security scan passed 2 days ago
A trading bot / execution codebase to audit.
Permissions
No special permissions declared or detected
What's inside
Frequently Asked Questions
Find more skills like this on the Claude Skills Marketplace, the Codex Skills Marketplace and the Gemini Skills Marketplace, or browse All Claude Skills.