TradeTrap is a community-driven and developer-friendly tool for testing LLM-based trading Agents' reliability. A slight perturbation to the input instructions for LLM-based agents can upend an entire investment schemeοΌTherefore, our mission is to build the reliable financial agent community. Welcome to share feedback and issues you encounter, and invite more developers to contribute πππ
- Market Intelligence
- Data fabrication (indirect prompt injection) β panic sell-offs and irrational buying cascades.
- MCP tool hijacking β polluted responses steer the planner straight off a cliff.
- Strategy Formulation
- Direct prompt injection β catastrophic pivots like forced liquidation and margin wipeouts.
- Model backdoor β hidden triggers siphon assets on demand.
- Malicious collusion β compromised sub-agents twist shared decision loops.
- Portfolio & Ledger
- Memory poisoning β strategy drift causes the model to learn incorrect experiences.
- State tampering β cognitive confusion regarding one's own positions/order status.
- Trading Execution
- Latency flooding / DoS β missed exits, frozen hedges, unstoppable drawdowns.
- Tool misuse β execution of unintended orders, violation of risk/compliance rules.
Currently, we provides a set of plug-and-play attack modules designed to integrate directly with the AI-Trader platform. Once connected, these plugins can actively interfere with a running LLM trading agent, allowing you to test its resilience in real-time through two primary attack vectors:
- Prompt Injection
- Reverse Expectation: Invert the agent's interpretation of market signals, causing it to make bullish moves in bearish conditions and vice versa.
- Reverse Actions: Tamper with the historical or simulated outcome data the agent receives, leading to flawed strategy adjustments based on a fabricated past.
- MCP Tool Hijacking
- Seize control of the agent's external data sourcesβsuch as price feeds, news APIs, or social sentiment toolsβand replace real-world data with manipulated streams to steer its decisions off-course.
For example:
π΅ blueοΌnews-enhanced runs wire into X/Twitter and Reddit feeds.
π΄ redοΌpoisoned agents tasked with the same capital.
All start with USD 5,000 - watch how the battlefield splits.
Experiments were specifically conducted on two types of attacks: "reverse expectation injection" and "fake news shockwave" with significant results, with the detailed walkthrough below focused on the
deepseek-v3model.

The poisoned reasoning trace pushes the planner to fight its own positions.

The poisoned prompt keeps doubling down on losing positions and cashing out early, so every rally stalls into a crash.

The staged βgood newsβ inflates expectations, the agent commits heavily, and the book collapses on impact.
- [Update on 19/11/2025] AI-Trader Long-term Memory β Added historical trading memory to AI-Trader prompts. Agents now review past positions, prices, and wins/losses before making decisions, improving consistency and testing for memory-related vulnerabilities. See
AI-Trader/README.mdfor visuals and configuration details. - [Update on 18/11/2025] Valuecell Agent Option β Introduced the Valuecell standalone auto-trading agent alongside AI-Trader. Users can now choose either pipeline directly from the project root (
READMEexplains how to run both flows). - [Update on 14/11/2025] State Tampering Attack β Manipulates trading agents by tampering with their position state perception. Full documentation:
plugins/README.mdΒ· δΈζη.
Infrastructure
- Integrated trading-agent platform combining core capabilities from mainstream stacks
- Simple attack interfaces for rapid experimentation
- Lightweight plugin system for extending payloads
- Adaptable to more trading platforms (e.g., NoFX, ValueCell)
Attack capabilities (delivered and planned)
-
Direct prompt injection β force catastrophic strategy pivots
-
MCP tool hijacking β let polluted data drive wrong decisions
-
Memory poisoning β corrupt learned experiences to force strategy drift
-
State tampering β induce cognitive confusion to desync from real positions
-
Data forgery (indirect prompt injection) β spark panic selling and irrational buying
-
Model backdoors β hidden triggers to drain assets on demand
-
Malicious collusion β compromised sub-agents twisting collective choices
-
Latency / DoS shocks β block exits, freeze hedges, let losses run
-
Tool misuse β execute rogue orders to breach risk and compliance hard limits
MCP hijacking layout
βββ agent_tools
β βββ start_mcp_services.py
β βββ tool_alphavantage_news.py
β βββ tool_get_price_local.py
β βββ tool_jina_search.py
β βββ tool_math.py
β βββ tool_trade.py
β βββ fake_agent_tools
β βββ start_fake_mcp_services.py
β βββ ...Prompt-injection layout
βββ agent
β βββ base_agent
β β βββ base_agent_hour.py
β β βββ base_agent.py
β βββ base_agent_astock
β β βββ base_agent_astock.py
β βββ plugins
β βββ prompt_injection_agent_hour.py # hourly injections
β βββ prompt_injection_agent.py # daily injections
β βββ prompt_injection_manager.py # rule matching
βββ prompts
β βββ prompt_injections.json # injection payloads# Clone the repository
git clone https://github.com/TradeTrap/Safe-TradingAgent.git
cd Safe-TradingAgent
# Install dependencies (unified requirements.txt in root directory)
pip install -r requirements.txt
# Configure environment variables
cp .env.example .env
# Edit .env and fill in your API keys (OPENAI_API_KEY, TUSHARE_TOKEN, etc.)TradeTrap supports testing two different trading agent implementations. Choose one based on your testing needs:
AI-Trader is the original trading agent with MCP (Model Context Protocol) integration.
# 1. Launch the official MCP services (required for AI-Trader)
cd AI-Trader/agent_tools
python start_mcp_services.py &
cd ../..
# 2. Run AI-Trader with a configuration file
python main.py configs/default_config.json
# Or use other AI-Trader configs:
# python main.py configs/default_astock_config.json # A-shares market
# python main.py configs/default_crypto_config.json # Cryptocurrency marketAvailable AI-Trader agent types:
BaseAgent- Standard trading agentBaseAgent_Hour- Hourly trading agentBaseAgentAStock- A-shares market agentBaseAgentCrypto- Cryptocurrency agentPromptInjectionAgent- For prompt injection testingPositionAttackAgent_Hour- For position attack testing
Valuecell is a standalone auto-trading agent with built-in technical analysis and portfolio management.
# Valuecell doesn't require MCP services, run directly:
python main.py configs/valuecell_config.json
# Or use other valuecell configs:
# python main.py configs/default_auto_trading_standalone_config.json # Crypto
# python main.py configs/default_auto_trading_stock_config.json # StockValuecell agent type:
Valuecell- Unified agent supporting both stock and crypto markets
TradeTrap supports various attack scenarios to test agent reliability:
-
MCP Hijacking: Test how agents respond to manipulated external data
-
State Tampering Attack: Test how agents handle tampered position state information
- Uses file hooks via
LD_PRELOADto intercept and modify position data read by agents at runtime - Causes agents to make trading decisions based on incorrect state perception while the actual ledger remains unchanged
- See:
plugins/README.mdfor detailed usage instructions
- Uses file hooks via
-
Plugins Attack Module: The
AI-Trader/agent/plugins/directory contains multiple attack plugins that can be used to test agent vulnerabilities:- Prompt Injection: Test how agents handle adversarial prompts injected into the decision-making process
- Position Attack: Test how agents handle tampered position records that modify trading history
- See:
AI-Trader/agent/plugins/README.mdfor detailed usage instructions
- AI-Trader - Autonomous trading agent system
- valuecell - Autonomous trading agent system
- LangChain - AI application development framework
- MCP - Model Context Protocol
- Alpha Vantage - Financial data API
- Jina AI - Information search service
This project exists to surface the risks hidden inside todayβs trading agents.
Always run experiments in controlled environments; do not deploy or weaponise them in live markets.
Every reproduced case feeds back into discussions and improvements around defensive measures.
Apache 2.0 Β© TradeTrap team β because even disruptive research should stay open-source.
𧨠TradeTrap: Are LLM-based Trading Agents Truly Reliable and Faithful?









