Agent
Auto-trading agent with built-in risk management and Algorithm Agent (MCP) reference
Reversion has two AI agents, both built into the web app and both connectable via MCP/API:
| Agent | What It Does |
|---|---|
| Auto-Trading Agent | Autonomous market watching, chart analysis, trade execution, and position management with built-in risk management |
| Algorithm Agent (MCP) | 60+ tools for building algorithms, backtesting, optimization, and trading via natural language. Connect from Claude Desktop, Cursor, VS Code, or any MCP-compatible app |
For a hands-on setup guide, see the Agent Walkthrough →
On this page: Auto-Trading Agent · Algorithm Agent (MCP)
Auto-Trading Agent
Section titled “Auto-Trading Agent”A fully autonomous trading agent that watches markets, analyzes charts with vision, executes trades, and manages positions — with risk management enforced at the system level so the agent literally cannot place an unprotected trade.
Deep Dives
Section titled “Deep Dives”- Discretionary Agent Overview
- System Context Construction
- Live State UI & Update Flow
- Multi-Thread Runtime Architecture
- Alert Lifecycle & Autonomous Threads
- Reconciliation, Risk & Exchange Consistency
How It Works
Section titled “How It Works”The agent operates in two continuous loops:
Market Watch Loop
- You (or the agent) set price alerts on markets of interest, with a thesis and proposed trade setup for each direction
- When price hits a level, an alert thread spawns automatically
- The agent analyzes the current chart to validate whether the setup is still valid
- If valid → executes the trade with mandatory stop loss and position sizing derived from your risk settings
- If invalid → re-arms the watch at updated levels
Trade Management Loop
- Every active trade has three automatic alerts: early warning (soft invalidation), profit target, and stop loss verification
- When an alert triggers, a management thread spawns with a mandatory first action
- The agent evaluates the situation: tighten the stop loss, take partial profit, trail into profit, or hold
- Alerts are refreshed at new levels — the cycle continues until the position closes
Risk Management
Section titled “Risk Management”The core principle: you set your maximum risk in USD per trade, and everything else is derived.
When the agent places a trade, it specifies an entry price, stop loss, target, and risk amount. The system automatically calculates:
position size = risk amount / distance from entry to stop lossThis means a tighter stop loss → larger position, wider stop loss → smaller position. Your maximum dollar loss is always what you specified, regardless of leverage or position size.
What the system enforces (not the agent — the system):
| Rule | What It Means |
|---|---|
| Every trade has a mandatory stop loss | Placed on the exchange atomically with the entry — impossible to have an unprotected position |
| Stop loss can only tighten | After entry, the SL can move closer to price (reducing risk) but never further away |
| Risk caps are hard limits | Per-trade and portfolio-wide caps checked before every execution — violations are rejected |
| Minimum reward-to-risk ratio | Trades below your min R:R are rejected before execution |
Risk Settings
Section titled “Risk Settings”Configure from the risk panel in Agent mode:
| Setting | Description | Suggested Start |
|---|---|---|
| Max risk per trade | Maximum USD at risk on any single trade | $10-50 |
| Max portfolio risk | Total USD at risk across all open trades combined | $50-200 |
| Min R:R | Minimum reward-to-risk ratio for any trade setup | 1.0 |
| Loss decay (minutes) | After a losing trade, the effective risk cap shrinks and recovers linearly over this many minutes. Prevents revenge trading. | 5 min |
| Max drawdown % | Hard lockout — blocks all new trades if equity drops this much from peak. Requires manual reset. | 20% |
| Margin mode | Isolated (risk capped per position) or Cross (shared collateral) | Isolated |
| Max entry deviation % | How far price can move from the intended entry before the system aborts | 0.5% |
| Execution timeout | How long to wait for a limit order fill before chasing with a market order | 3s |
| Auto-risk adjustment | Let the agent periodically adjust the portfolio risk cap within bounds you set | Off |
Operating Modes
Section titled “Operating Modes”| Mode | Description |
|---|---|
| Copilot | The agent proposes trades and you approve or reject each one via a popup. Analysis, market watching, and note-taking proceed without approval — only trade execution is gated. |
| Full Autonomy | All trades execute immediately. The agent operates as a closed-loop system — watching markets, executing trades, managing positions, and re-arming alerts — even while you’re disconnected. |
Chart Analysis
Section titled “Chart Analysis”The agent uses vision to analyze candlestick charts across multiple timeframes. When evaluating a setup, it:
- Renders charts with candles, volume, and volume profile (price density)
- Reads the chart image to identify market structure (trend, range, breakout, consolidation)
- Identifies key price levels (support, resistance, high-volume nodes, liquidity zones)
- Proposes a trade setup with specific entry, stop loss, and target — or determines no valid setup exists
This structured analysis feeds directly into trade execution. The agent doesn’t guess at levels — it reads the chart.
Trade Lifecycle
Section titled “Trade Lifecycle”Every trade follows this path:
| Stage | What Happens |
|---|---|
| Watch | Agent monitors a market with paired price alerts (upper and lower bounds) and a thesis per direction |
| Alert | Price hits a watch level → alert thread spawns automatically |
| Validate | Agent analyzes the current chart to check if the proposed setup is still valid |
| Execute | Smart execution places the entry (market or limit, auto-determined) and stop loss atomically |
| Manage | Three auto-created alerts monitor the trade: early warning, profit target, SL verification |
| Adjust | On alert trigger: tighten stop, take partial profit, trail into profit, or hold |
| Close | Position closes via stop loss hit, profit target, or manual close. Risk is freed for new trades. |
After a trade closes, the market can optionally return to the Watch stage — creating a continuous autonomous loop.
Pyramiding
Section titled “Pyramiding”The agent can open multiple trades on the same market, each with independent risk parameters. Each trade has its own stop loss, entry, and target. When adding layers:
- Previous trade stop losses should be tightened (moved to breakeven or profit)
- Total portfolio risk is checked against your cap
- Each trade is tracked separately in the ledger
Trading Notes
Section titled “Trading Notes”The agent maintains persistent trading notes — a hierarchical notes system that serves as its memory across all threads. Notes contain:
- Market thesis and analysis
- Active trade management instructions
- Strategy context that persists across alert threads
Only a table of contents is loaded into the agent’s context by default — full notes are read on demand to keep context lean. Notes auto-prune when total size exceeds budget.
Supported LLM Providers
Section titled “Supported LLM Providers”| Provider | Models |
|---|---|
| Anthropic | Claude (recommended for chart analysis) |
| OpenAI | GPT models |
| Gemini models | |
| xAI | Grok models |
| Groq | Fast inference models |
Multi-provider fallback is supported — if your primary provider has an outage, the system automatically falls back to the next provider in your chain.
Thread Architecture
Section titled “Thread Architecture”The agent runs multiple concurrent threads:
| Thread Type | Lifetime | Triggered By |
|---|---|---|
| Chat | Persistent | Your messages — the main conversational interface |
| Alert | Ephemeral (auto-completes) | Price alerts, trade management alerts, or scheduled time alerts |
Up to 8 alert threads can run concurrently. Excess alerts are queued and processed in order. Each alert thread has a mandatory first action (e.g., update the trade setup) before it can take other actions — ensuring critical responses are never skipped.
Algorithm Agent (MCP)
Section titled “Algorithm Agent (MCP)”The Algorithm Agent is an open-source Model Context Protocol server built into the Reversion platform. Connect from Claude Desktop, Cursor, VS Code, or any MCP-compatible app — describe what you want in natural language and the agent picks the right tool.
Deep Dives
Section titled “Deep Dives”Architecture
Section titled “Architecture”Agent App (Claude Desktop, Cursor, etc.) ↕ stdio or HTTPreversion-mcp ↕ HTTP (Bearer token auth)Reversion Backend ├── Trading, algos, market data (direct) └── Charting, backtesting, optimization (proxied to compute worker)Your AI app talks to the MCP server, which talks to the Reversion backend. No API keys or private keys are exposed to the AI — only a scoped API token.
The MCP server is stateless — no local storage, no sessions. You can restart it anytime or run multiple instances safely.
Installation
Section titled “Installation”npm (Recommended)
Section titled “npm (Recommended)”The fastest way to get started:
npx -y reversion-mcpSee the Agent Walkthrough for full config examples per app (Claude Desktop, Cursor, VS Code).
Alternative: From Source
Section titled “Alternative: From Source”Requires Bun runtime. Use this if you want to modify the MCP server or contribute:
git clone https://github.com/reversion-trade/reversion-mcp.gitcd reversion-mcpbun installConfig:
{ "mcpServers": { "reversion": { "command": "bun", "args": ["run", "/path/to/reversion-mcp/src/index.ts"], "env": { "REVERSION_API_TOKEN": "rvt_your_token_here", "REVERSION_BACKEND_URL": "http://localhost:3001" } } }}Alternative: HTTP Transport
Section titled “Alternative: HTTP Transport”For remote or web-based agents:
REVERSION_API_TOKEN=rvt_... bun run src/index.ts --transport http --port 3002Connect over HTTP:
{ "mcpServers": { "reversion": { "type": "streamable-http", "url": "http://localhost:3002/mcp" } }}Health check: GET http://localhost:3002/health
Environment & Authentication
Section titled “Environment & Authentication”| Variable | Required | Default | Description |
|---|---|---|---|
REVERSION_API_TOKEN | Yes | — | API token (rvt_...) from the web app |
REVERSION_BACKEND_URL | No | http://localhost:3001 | Backend URL. Use https://api.reversion.trade for production |
How Authentication Works
Section titled “How Authentication Works”The MCP server never touches your private keys. Here’s the flow:
- Connect wallet (MetaMask, etc.) to reversion.trade via SIWE
- Backend creates an API wallet — a separate encrypted keypair for trade execution
- Approve the API wallet on Hyperliquid (builder fee approval)
- Generate an API token (
rvt_...) scoped to your account - MCP server uses the token to authenticate; backend resolves your user and trades via the API wallet
Token Scopes
Section titled “Token Scopes”| Scope | What It Grants |
|---|---|
read | Account overview, watchlist, market data, economic calendar |
trade | Order placement & cancellation, position management, leverage & margin |
algo | Algorithm CRUD, charting, backtesting, optimization |
Tokens are SHA-256 hashed in the database. The plaintext is shown once at creation. Tokens support optional expiry and can be revoked at any time.
Tools Reference
Section titled “Tools Reference”The Algorithm Agent exposes 60+ tools organized by scope. You don’t need to memorize these — just describe what you want in natural language and the agent picks the right tool.
Account & Watchlist — read
Section titled “Account & Watchlist — read”Manage your account and track markets:
| Tool | Description |
|---|---|
get_account_overview | Account snapshot: balance, positions, open orders, TWAPs, recent fills, algo runs, wallet status |
get_watchlist | Get tracked trading pairs |
add_to_watchlist | Add a trading pair |
remove_from_watchlist | Remove a trading pair |
Market Data — read
Section titled “Market Data — read”Get real-time and historical market information:
| Tool | Description |
|---|---|
get_ticker | Current price, bid, ask, 24h volume and change |
search_markets | Search available trading pairs |
get_orderbook | Orderbook bids and asks |
get_candles | OHLCV candlestick data |
get_funding_rate | Current funding rate |
get_mark_price | Mark price for PnL/liquidation |
get_open_interest | Current open interest |
Trading — trade
Section titled “Trading — trade”Place and manage orders:
| Tool | Description |
|---|---|
place_market_order | Immediate fill at market price |
place_limit_order | Fill at specific price or better |
place_stop_loss | Stop-loss trigger order (market or limit) |
place_take_profit | Take-profit trigger order (market or limit) |
place_twap_order | Split execution over a duration |
cancel_order | Cancel a specific order |
cancel_all_orders | Cancel all open orders |
cancel_twap_order | Cancel an active TWAP |
Position Management — trade
Section titled “Position Management — trade”Control leverage, margin, and open positions:
| Tool | Description |
|---|---|
set_leverage | Set leverage multiplier |
set_margin_mode | Set cross or isolated margin |
close_position | Close via reduce-only market order |
Charting — algo
Section titled “Charting — algo”Generate charts and explore indicators visually:
| Tool | Description |
|---|---|
generate_chart | Candlestick chart (PNG) with indicators and overlays |
explore_indicator | Test indicator + trigger against real data |
fetch_candles_json | Raw OHLCV data as columnar JSON |
Algorithms — algo
Section titled “Algorithms — algo”Create, read, and update algorithm configurations:
| Tool | Description |
|---|---|
list_indicators | List available indicator types |
get_indicator_schema | Parameter schema for an indicator |
list_algorithms | List all algorithm configs |
get_algorithm | Full algorithm config |
create_algorithm | Create a new algorithm |
update_algorithm | Update algorithm (creates new version) |
Backtesting — algo
Section titled “Backtesting — algo”Run backtests, cross-validation, and view results:
| Tool | Description |
|---|---|
run_backtest | Run a backtest; returns run ID |
get_backtest_results | Get metrics for a completed backtest |
plot_backtest | Generate equity curve + drawdown chart (PNG) |
rolling_cv_backtest | Rolling cross-validation backtest |
list_runs | List runs (backtests and live) with status |
update_run_status | Update run status (STOPPED, CANCELLED) |
Optimization — algo
Section titled “Optimization — algo”Run and monitor parameter optimization:
| Tool | Description |
|---|---|
bayesian_optimize | Hands-off Bayesian optimization (Optuna TPE) |
get_optimization_status | Poll progress, best score/params, trial history |
stop_optimization | Early-stop; results preserved |
bo_suggest | Agent-driven BO step: get next suggested params |
compute_backtest_score | Run custom scoring function on results |
plot_optimization | Generate optimization trajectory charts |
Economic Calendar — read
Section titled “Economic Calendar — read”Stay ahead of market-moving events:
| Tool | Description |
|---|---|
get_economic_calendar | Query events by date, impact, currency |
get_upcoming_events | Events in the next N hours |
get_high_impact_events | High-impact events (FOMC, NFP, CPI) |
get_market_hours | Trading hours for exchanges |
is_market_open | Check if an exchange is currently open |
Usage Examples
Section titled “Usage Examples”Market Analysis
Section titled “Market Analysis”"What's the current funding rate and open interest for ETH?""Show me a 1h chart for SOL with MACD and volume""Search for all available markets on Hyperliquid"Strategy Development
Section titled “Strategy Development”"List available indicators""Explore RSI on BTC 4h with oversold threshold at 30 — show me the signals""Create a mean reversion algorithm for ETH using Bollinger Bands"Backtesting
Section titled “Backtesting”"Backtest my algorithm over the last 6 months""Plot the equity curve for that backtest""Run a rolling cross-validation with 30-day train and 10-day test windows"Optimization
Section titled “Optimization”"Optimize my RSI algorithm — try 20 trials varying the period and thresholds""What's the optimization status?""Plot the optimization trajectory"Trading
Section titled “Trading”"Buy 0.1 ETH at market""Place a limit buy for 1 SOL at $120""Set a stop loss at $3,200 for my ETH position""Close my BTC position"Built-in Skills
Section titled “Built-in Skills”The MCP server includes built-in skill prompts that guide structured workflows:
reversion-skill-algo-researcher— full pipeline from market analysis to optimized strategyreversion-skill-trader— trading-focused workflowsreversion-skill-general— general platform interaction
Supported Exchanges
Section titled “Supported Exchanges”- Hyperliquid — native perpetual futures (all listed pairs)
- HIP-3 XYZ DEX markets — perpetual markets for tradfi assets on Hyperliquid’s HIP-3 protocol
The exchangeId parameter defaults to hyperliquid across all tools.
Deployment Notes
Section titled “Deployment Notes”- Single dependency — only needs
REVERSION_BACKEND_URL - Stateless — safe to restart or run multiple instances
- Auth forwarding — API token sent as
Authorization: Bearer rvt_...on every request - Production — point
REVERSION_BACKEND_URLtohttps://api.reversion.trade
What’s Next?
Section titled “What’s Next?”| Want to… | Go to |
|---|---|
| Walk through agent setup | Agent Walkthrough → |
| Take your algorithm live | Deploy Features → |