Skills Plugins MCP Prompt Model 博客 我的中心
数据分析与咨询 #trading #security #agent

llm-trading-agent-security

Security patterns for autonomous trading agents with wallet or transaction authority. Covers prompt injection, spend limits, pre-send simulation, circuit breakers, MEV protection, and key handling. Use when an autonomous agent holds wallet or transaction authority and its limits, simulation, or key handling need review.

DeepseekModel 官方收录技能 质量 优秀 · 90 v1.0.0

获取

https://deepseekmodel.com/api/download.php?id=affaan-m-ecc-skills-llm-trading-agent-security-skill-md&format=skill
下载 .skill 标准格式,含 system_prompt 与 model_config,导入任意 Agent 框架即可使用
.skill 文件中 system_prompt 字段的实际内容。
name llm-trading-agent-security description Security patterns for autonomous trading agents with wallet or transaction authority. Covers prompt injection, spend limits, pre-send simulation, circuit breakers, MEV protection, and key handling. Use when an autonomous agent holds wallet or transaction authority and its limits, simulation, or key handling need review. metadata {"version":"1.0.0","origin":"ECC direct-port adaptation"} LLM Trading Agent Security Autonomous trading agents have a harsher threat model than normal LLM apps: an injection or bad tool path can turn directly into asset loss. When to Use Building an AI agent that signs and sends transactions Auditing a trading bot or on-chain execution assistant Designing wallet key management for an agent Giving an LLM access to order placement, swaps, or treasury operations How It Works Layer the defenses. No single check is enough. Treat prompt hygiene, spend policy, simulation, execution limits, and wallet isolation as independent controls. Examples Treat prompt injection as a financial attack import re INJECTION_PATTERNS = [ r'ignore (previous|all) instructions' , r'new (task|directive|instruction)' , r'system prompt' , r'send .{0,50} to 0x[0-9a-fA-F]{40}' , r'transfer .{0,50} to' , r'approve .{0,50} for' , ] def sanitize_onchain_data ( text: str ) -> str : for pattern in INJECTION_PATTERNS: if re.search(pattern, text, re.IGNORECASE): raise ValueError( f"Potential prompt injection: {text[: 100 ]} " ) return text Do not blindly inject token names, pair labels, webhooks, or social feeds into an execution-capable prompt. Hard spend limits from decimal import Decimal MAX_SINGLE_TX_USD = Decimal( "500" ) MAX_DAILY_SPEND_USD = Decimal( "2000" ) class SpendLimitError ( Exception ): pass class SpendLimitGuard : def check_and_record ( self, usd_amount: Decimal ) -> None : if usd_amount > MAX_SINGLE_TX_USD: raise SpendLimitError( f"Single tx $ {usd_amount} exceeds max $ {MAX_SINGLE_TX_USD} " ) daily = self ._get_24h_spend() if daily + usd_amount > MAX_DAILY_SPEND_USD: raise SpendLimitError( f"Daily limit: $ {daily} + $ {usd_amount} > $ {MAX_DAILY_SPEND_USD} " ) self ._record_spend(usd_amount) Simulate before sending class SlippageError ( Exception ): pass async def safe_execute ( self, tx: dict , expected_min_out: int | None = None ) -> str : sim_result = await self .w3.eth.call(tx) if expected_min_out is None : raise ValueError( "min_amount_out is required before send" ) actual_out = decode_uint256(sim_result) if actual_out < expected_min_out: raise SlippageError( f"Simulation: {actual_out} < {expected_min_out} " ) signed = self .account.sign_transaction(tx) return await self .w3.eth.send_raw_transaction(signed.raw_transaction) Circuit breaker class TradingCircuitBreaker : MAX_CONSECUTIVE_LOSSES = 3 MAX_HOURLY_LOSS_PCT = 0.05 def check ( self, portfolio_value: float ) -> None : if self .consecutive_losses >= self .MAX_CONSECUTIVE_LOSSES: self .halt( "Too many consecutive losses" ) if self .hour_start_value <= 0 : self .halt( "Invalid hour_start_value" ) return hourly_pnl = (portfolio_value - self .hour_start_value) / self .hour_start_value if hourly_pnl < - self .MAX_HOURLY_LOSS_PCT: self .halt( f"Hourly PnL {hourly_pnl: .1 %} below threshold" ) Wallet isolation import os from eth_account import Account private_key = os.environ.get( "TRADING_WALLET_PRIVATE_KEY" ) if not private_key: raise EnvironmentError( "TRADING_WALLET_PRIVATE_KEY not set" ) account = Account.from_key(private_key) Use a dedicated hot wallet with only the required session funds. Never point the agent at a primary treasury wallet. MEV and deadline protection import time PRIVATE_RPC = "https://rpc.flashbots.net" MAX_SLIPPAGE_BPS = { "stable" : 10 , "volatile" : 50 } deadline = int (time.time()) + 60 Pre-Deploy Checklist External data is sanitized before entering the LLM context Spend limits are enforced independently from model output Transactions are simulated before send min_amount_out is mandatory Circuit breakers halt on drawdown or invalid state Keys come from env or a secret manager, never code or logs Private mempool or protected routing is used when appropriate Slippage and deadlines are set per strategy All agent decisions are audit-logged, not just successful sends
Agent 识别该技能的关键词,点击任意一个即可复制。

该技能未提供触发词。

下载的 .skill 包内含以下字段。
字段 说明
format格式标识(skill/v1)
skill_id技能唯一 ID
name技能名称
version版本号
description技能描述
category所属分类(数组)
trigger_words触发词列表
tags标签列表
source来源标识
source_url来源链接(本页地址)
exported_at导出时间(每次下载生成)
system_prompt系统提示词正文
model_config模型参数:provider / model / temperature / max_tokens / top_p
examples示例
install_guide各平台导入说明(Coze / Dify / Claude / 自定义框架)
同一份技能可按不同平台格式导出。
.skill 标准格式,含 system_prompt 与 model_config,导入任意 Agent 框架即可使用 下载
.skillpro 增强格式,额外含脚本 / 工具 / 依赖 / 钩子占位 下载
.json 纯 JSON 导出,只含 system_prompt 与模型参数 下载
Coze 带 frontmatter 的 Markdown,Coze 平台导入用 下载
Dify Dify DSL,创建应用后直接导入 下载

每日精选 Skill 推荐,免费送到你邮箱

输入邮箱,每天接收一个精选 AI Agent 技能推荐。完全免费,持续更新。

提交后我们会发送一封确认邮件,点击邮件里的链接才会开始收信。

完全免费,取消任意时间。我们不会发送垃圾邮件。