Strategy: Grid Bot ()
Backtest, optimize, and run automated grid trading strategies.
Auth required. Make sure
is installed and configured before running these commands. If any command fails with an auth-related error —
,
,
Authentication failed (401)
,
,
, or a missing key/config file at
—
invoke the skill immediately and apply the fix yourself. Do not interrupt the user to ask them to run setup. Only escalate to the user for steps only they can perform (pasting the API key, registering the public key in their Revolut X profile, choosing a passphrase). After the fix, retry the original command.
Symbols use
format with a dash:
,
,
.
Backtest
Test a grid strategy on historical data:
bash
revx strategy grid backtest BTC-USD
revx strategy grid backtest BTC-USD --levels 10 --range 10 --investment 1000
revx strategy grid backtest ETH-USD --days 60 --interval 4h
revx strategy grid backtest BTC-USD --split
revx strategy grid backtest BTC-USD --json
| Flag | Default | Description |
|---|
| 5 | Grid levels per side (2-25) |
| 10 | Grid range +/- % from mid price |
| 1000 | Capital in quote currency |
| 3 | Historical data period |
| 1m | Candle resolution |
| off | Split investment across buy and sell levels (market-buy base for levels above start price) |
Not long-running — completes and returns results. Run normally via the
tool.
Always confirm these key parameters before running: pair, investment, levels, range, and split mode. These affect capital and strategy behavior — never assume them silently. Other parameters (days, interval) can use defaults unless the user specifies otherwise.
Optimize
Test multiple parameter combinations, ranked by return:
bash
revx strategy grid optimize BTC-USD
revx strategy grid optimize BTC-USD --investment 5000 --days 60
revx strategy grid optimize BTC-USD --levels 5,10,15,20 --ranges 3,5,10 --top 5
revx strategy grid optimize BTC-USD --split
| Flag | Default | Description |
|---|
| 3,5,8,10,15 | Level counts to test |
| 3,5,7,10,12,15,20 | Range percentages to test |
| 10 | Top results to display |
| 1000 | Capital in quote currency |
| 3 | Historical data period |
| 1m | Candle resolution |
| off | Split investment across buy and sell levels (market-buy base for levels above start price) |
Max 200 parameter combinations. Not long-running — completes and returns results.
Always confirm these key parameters before running: pair, investment, and split mode. These affect capital and strategy behavior — never assume them silently. Other parameters (levels list, ranges list, days, interval, top) can use defaults unless the user specifies otherwise.
Run (Live Trading)
Human Confirmation Required
NEVER execute (without ) without explicit user confirmation. This command places real orders with real money.
Before running a live grid bot, present a confirmation summary to the user:
Grid bot to launch:
- Pair: BTC-USD
- Investment: $500
- Levels: 10 per side
- Range: +/-5%
- Mode: LIVE (real orders)
This will place real buy and sell orders. Shall I proceed?
Only execute after the user explicitly approves.
does
not require confirmation (no real orders).
Always Suggest Dry Run First
When the user asks to run a live grid bot,
always suggest starting with before going live — unless the user has already completed a dry run in the current session or explicitly says they want to skip it.
Example response:
Before going live, I'd recommend a dry run first to verify the grid setup:
bash
revx strategy grid run BTC-USD --investment 500 --levels 10 --range 5 --dry-run
This simulates the bot without placing real orders. Want to start with a dry run?
If the user confirms they want to skip the dry run, proceed to the live confirmation flow above.
Missing Parameters — Always Ask, Never Guess
The
flag is required by the CLI, but also confirm the user's intent for all key parameters:
- Symbol — which pair?
- Investment — how much capital?
- Levels — how many grid levels per side? (default 5 if user says "use defaults")
- Range — what percentage range? (default 5% if user says "use defaults")
If the user says "run a grid bot on BTC", ask for the investment amount at minimum.
Run a live grid bot with real-time dashboard:
bash
revx strategy grid run BTC-USD --investment 500
revx strategy grid run BTC-USD --levels 10 --range 5 --investment 1000 --interval 15
revx strategy grid run BTC-USD --investment 500 --split
revx strategy grid run BTC-USD --investment 100 --dry-run
revx strategy grid run BTC-USD --investment 500 --reset
| Flag | Default | Description |
|---|
| required | Capital in quote currency |
| 5 | Grid levels per side (2-25) |
| 5 | Grid range +/- % from mid |
| off | Split investment across buy and sell levels (market-buy base for levels above current price) |
| 10 | Polling interval in seconds |
| off | Simulate without real orders |
| off | Discard saved state, start fresh |
Ctrl+C for graceful shutdown (cancels open orders, prints summary).
Persistence: State auto-saved for crash recovery. Clean shutdown deletes state. Crashed sessions auto-reconcile on restart.
If Telegram connectors are configured (see
skill), notifications are sent on startup, shutdown, fills, and P&L changes.
Long-Running Command — Behavioral Instructions for Claude
(including
) runs
indefinitely as a continuous polling loop.
How to handle:
- Run the command using the tool with — this frees Claude immediately while the process runs asynchronously
- Periodically read the background task output file with the tool to monitor status and report key events to the user (orders placed, fills, errors)
- If the user asks to stop, use the tool with the task ID
- Also print the command to the user so they can optionally run it in a separate terminal for the full live dashboard experience (with colors, real-time tables, Ctrl+C to stop)
Example — starting a grid bot:
Bash tool call:
json
{ "command": "revx strategy grid run BTC-USD --investment 500 --levels 10 --range 5", "run_in_background": true }
Response to user:
Started grid bot for BTC-USD in the background. I'll check for updates periodically.
If you'd like to see the live dashboard, run this in a separate terminal:
bash
revx strategy grid run BTC-USD --investment 500 --levels 10 --range 5
Press Ctrl+C to stop (gracefully cancels open orders).
When to Suggest Split
When the user sets up a grid strategy (backtest, optimize, or run),
ask whether they want split mode if they haven't specified
. Present it as a simple choice with context:
Would you like to use split mode (
)?
- Without split — all capital goes to buy orders below the current price. Best for uptrending markets where you expect price to dip into buy levels and bounce back.
- With split — capital is divided across both buy and sell levels. A market buy at the start price funds sell positions above. Best for ranging/sideways markets where price oscillates around the current level.
If the user is unsure, recommend running both variants in backtest/optimize to compare results.
Use
consistently across backtest, optimize, dry-run, and live when the user has chosen split mode.
P&L Metrics
Realized P&L = sum of profit from each completed sell (sell revenue − cost per level). Measures pure grid trading profit. The initial split buy (if
is used) does not affect this metric.
Total P&L = (final quote balance + final base × final price) − initial investment. The mark-to-market portfolio value change. No assets are force-sold at the end.
Without : only buy levels (below start price) are funded. In uptrending markets all grid cycles may complete, making Realized and Total P&L equal.
With : investment is divided across all levels. Levels above start price get positions via a simulated market buy at start price. This creates Realized/Total P&L divergence and allows profiting from both up and down moves within the grid.
Common Workflow: Backtest Then Run
bash
# 1. Optimize to find best parameters
revx strategy grid optimize BTC-USD --investment 1000 --days 30
# 2. Backtest the top result
revx strategy grid backtest BTC-USD --levels 10 --range 7 --investment 1000
# 3. Dry run first
revx strategy grid run BTC-USD --investment 1000 --levels 10 --range 7 --dry-run
# 4. Go live
revx strategy grid run BTC-USD --investment 1000 --levels 10 --range 7
Use
consistently across all steps if you want to test and run with split investment.
Related Skills
| Skill | Purpose |
|---|
| Get Telegram notifications for grid bot events |
| Check prices and pair data before configuring a grid |
| Check balances and order status |
| Manual order placement (grid bot places orders automatically) |
| API key setup and configuration |