llm-trading-agent-security
Skill0 starsChanged 5 months agoMITView on GitHub
Security patterns for LLM-driven trading agents that can place real orders — for centralized-venue systems (REST APIs + keys, not on-chain wallets). Covers prompt-injection defense on signal prompts that ingest external data, hard spend/position limits, pre-submit order validation, circuit breakers (drawdown/consecutive-loss halts), key handling, and audit logging. Use when building/auditing an executor, giving an LLM order-placement authority, or reviewing how external market data/news enters a decision prompt. Trigger on: "trading bot security", "executor safety", "can the agent place orders", "prompt injection in signals", "spend/position limit", "circuit breaker", "kill switch". Adapted from ECC (affaan-m/ECC, MIT), re-scoped for centralized REST trading.
9 other projects use a version of this.
Adopted by
Most recently taken up by
- Rojios/everything-claude-codetheir own version, first seen Nov 8, 2026
- renepf/claude-skillstheir own version, first seen Oct 25, 2026
- davidanthonyn/claude-skillstheir own version, first seen Oct 20, 2026
- gongyijie85/dsh-ecctheir own version, first seen Oct 13, 2026
- NISTALTALSON/essential-claude-skillstheir own version, first seen Oct 11, 2026
- Fmarzochi/EGCtheir own version, first seen Sep 16, 2026
Used with
Projects with it also use pdf.
Other files people use alongside this one.
Files found in the same public projects as a version of this one, more often than they turn up anywhere else. Each project counts once, large collections count for less, and this file's own repository is left out.
AnthropicSkillpdf
Comprehensive PDF manipulation toolkit for extracting text and tables, creating new PDFs, merging/splitting documents, and handling forms. When Claude needs to fill in a PDF form or programmatically process, generate, or analyze PDF documents at scale.
Also in 3 projects that use this
Other versions9 projects use a version of this.
Word for word · 0
None found.
Edited · 0
None found.
Wrote their own version · 9
- Fmarzochi/EGC★ 61same name
- gongyijie85/dsh-ecc★ 8same name
- ronmkr/PromptBook★ 2same name
- NISTALTALSON/essential-claude-skills★ 1same name
- Rojios/everything-claude-code★ 1same name
- romaintoso78/claude-skills★ 1same name
- SamuelNDCE/claude-super-skill-library★ 1same name
- davidanthonyn/claude-skills★ 0same name
- renepf/claude-skills★ 0same name
How matches are found. Word for word: the exact same text. Edited: shares passages with this file (“99% same” means 99% of its five-word phrases also appear here; 10% or more counts). Their own version: similar meaning, or, weakest, the same name. We can’t tell which project had it first. Projects are counted among the 200 most-starred candidates, and mentions are links to the repository we found, up to 50 per site, so both counts are a floor.
In this repository12 other files it gives its agents.
- CLAUDE.mdCLAUDE.md
- agent-architecture-auditSkill
- code-review-disciplineSkill
- cost-aware-llm-pipelineSkill
- dataviz-designSkill
- design-systemSkill
- docs-designSkill
- editorial-report-designSkill
- layout-interaction-designSkill
- marketing-microsite-designSkill
- tool-calculator-designSkill
- working-with-claudeSkill
The file
We split this skill into the rules it gives an agent
4 rules. 0 are common, 1 is distinctive, and 3 are very specific to this project.
0
Common
Most of the 9 edited versions we read keep these.
1
Distinctive
This author's own choices. Worth a look.
3
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Very specific: line 32
Never blind-inject token names, headlines, webhooks, or social feeds into the decide prompt.
- Very specific: line 46
Before sending an order: assert symbol is tradable, side/qty/price within sane bounds, leverage ≤ allowed, reduce_only set on SL/TP, and …
- Very specific: line 59
Keep an env kill-switch (pattern: *_ENABLED=0 / ACTIVE_ASSETS=none) that stops generation+execution.
- Distinctive: line 63
Use a dedicated trading key with least privilege.
“Common” is measured: kept by at least 6 in 10 of the 9 edited versions of this file we could read. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
LLM Trading-Agent Security
Trading agents have a harsher threat model than normal LLM apps: an injection or a bad tool path turns directly into money lost. Layer independent controls — no single check is enough. (This drops the on-chain/MEV/wallet-signing parts of the original ECC skill and keeps what applies to centralized REST-API executors with your exchange/broker.)
1. Treat prompt injection as a financial attack ✅
Signal prompts ingest external data (news, social, market feeds, other-venue data). Sanitize anything that could carry an instruction before it enters an execution-capable prompt.
INJECTION = [r'ignore (previous|all) instructions', r'new (task|directive|instruction)',
r'system prompt', r'(buy|sell|close|transfer|withdraw) .{0,40}(now|immediately|all)']
def sanitize_external(text: str) -> str:
for p in INJECTION:
if re.search(p, text, re.I): raise ValueError(f"possible injection: {text[:100]}")
return textNever blind-inject token names, headlines, webhooks, or social feeds into the decide prompt. Keep the decision schema strict (direction/size/levels) so free text can't become an order.
2. Hard spend / position limits (independent of model output) ✅
Enforce in code, separate from whatever the LLM says. Your existing risk gates and reduce-only SL+TP should be guards in code, not conventions.
MAX_SINGLE_NOTIONAL, MAX_DAILY_NOTIONAL = Decimal("15000"), Decimal("60000")
def check(amount): # raise before any order submit
if amount > MAX_SINGLE_NOTIONAL: raise SpendLimit(f"{amount} > single cap")
if day_total() + amount > MAX_DAILY_NOTIONAL: raise SpendLimit("daily cap")3. Validate before submit (the centralized analog of "simulate") ✅
Before sending an order: assert symbol is tradable, side/qty/price within sane bounds, leverage ≤ allowed,
reduce_only set on SL/TP, and the computed notional matches the intended size (catch decimal/lot-size
bugs). Reject on mismatch — never submit an order you didn't fully re-derive.
4. Circuit breakers / kill switch ✅
Halt on drawdown or invalid state. Formalize your existing risk gates and per-app pause flags:
MAX_CONSEC_LOSSES, MAX_HOURLY_LOSS = 3, 0.05
def guard(consec, portfolio, hour_start):
if consec >= MAX_CONSEC_LOSSES: halt("consecutive losses")
if hour_start <= 0: halt("invalid hour_start"); return
if (portfolio - hour_start)/hour_start < -MAX_HOURLY_LOSS: halt("hourly drawdown")Keep an env kill-switch (pattern: *_ENABLED=0 / ACTIVE_ASSETS=none) that stops generation+execution.
5. Key handling & audit ✅
Keys from env / your secret store, never in code or logs; the secret-scan hook backstops prompts.
Use a dedicated trading key with least privilege. Audit-log every decision (including rejected/not-sent),
not just successful orders — you can't debug or trust an executor whose refusals are invisible.
Pre-deploy checklist
- external data sanitized before the decide prompt - [ ] spend/position limits enforced in code, independent of model output - [ ] order re-derived & validated before submit (notional, lot size, reduce-only) - [ ] circuit breakers + env kill-switch wired - [ ] keys from env, never logged - [ ] every decision audit-logged (sent and not-sent) - [ ] paper-mode path tested before live.
Sources
Adapted from ECC skills/llm-trading-agent-security (MIT), re-scoped from on-chain wallets to centralized
REST trading; aligns with reduce-only SL+TP, risk gates, kill-switch flags, and env-based secret handling.
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

