revx-strategy

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

Strategy: Grid Bot (
revx strategy grid
)

策略:网格机器人(
revx strategy grid

Backtest, optimize, and run automated grid trading strategies.
Auth required. Make sure
revx
is installed and configured before running these commands. If any command fails with an auth-related error —
Auth not configured
,
No private key found
,
Authentication failed (401)
,
Invalid signature
,
insecure permissions
, or a missing key/config file at
~/.config/revolut-x/
invoke the
revx-auth
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
BASE-QUOTE
format with a dash:
BTC-USD
,
ETH-EUR
,
SOL-USD
.

回测、优化并运行自动化网格交易策略。
需要身份验证。执行这些命令前,请确保已安装并配置
revx
。如果任何命令因身份验证相关错误失败——
Auth not configured
No private key found
Authentication failed (401)
Invalid signature
insecure permissions
,或
~/.config/revolut-x/
路径下缺少密钥/配置文件——立即调用
revx-auth
技能并自行修复问题
。不要打断用户让他们自行完成设置。仅在需要用户执行专属步骤(粘贴API密钥、在Revolut X个人资料中注册公钥、选择密码短语)时才告知用户。修复完成后,重试原命令。
交易对采用
BASE-QUOTE
格式,用短横线分隔:
BTC-USD
ETH-EUR
SOL-USD

Backtest

回测(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
FlagDefaultDescription
--levels <n>
5Grid levels per side (2-25)
--range <pct>
10Grid range +/- % from mid price
--investment <amount>
1000Capital in quote currency
--days <n>
3Historical data period
--interval <res>
1mCandle resolution
--split
offSplit 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
Bash
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.

在历史数据上测试网格策略:
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)默认值说明
--levels <n>
5每侧的网格层数(2-25)
--range <pct>
10网格范围:相对于中间价的±百分比
--investment <amount>
1000投入资金(计价货币)
--days <n>
3历史数据周期
--interval <res>
1mK线分辨率
--split
关闭在买入和卖出层之间拆分资金(对高于起始价格的层级进行市价买入基础货币)
非长期运行——执行完成后返回结果。通过
Bash
工具正常运行。
执行前务必确认以下关键参数:交易对投入资金网格层数网格范围拆分模式。这些参数会影响资金和策略表现——切勿默认使用参数值。其他参数(天数、分辨率)除非用户指定,否则可使用默认值。

Optimize

优化(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
FlagDefaultDescription
--levels <csv>
3,5,8,10,15Level counts to test
--ranges <csv>
3,5,7,10,12,15,20Range percentages to test
--top <n>
10Top results to display
--investment <amount>
1000Capital in quote currency
--days <n>
3Historical data period
--interval <res>
1mCandle resolution
--split
offSplit 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.

测试多种参数组合,按收益排序:
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)默认值说明
--levels <csv>
3,5,8,10,15待测试的网格层数列表
--ranges <csv>
3,5,7,10,12,15,20待测试的网格范围百分比列表
--top <n>
10显示的最优结果数量
--investment <amount>
1000投入资金(计价货币)
--days <n>
3历史数据周期
--interval <res>
1mK线分辨率
--split
关闭在买入和卖出层之间拆分资金(对高于起始价格的层级进行市价买入基础货币)
最多支持200种参数组合。非长期运行——执行完成后返回结果。
执行前务必确认以下关键参数:交易对投入资金拆分模式。这些参数会影响资金和策略表现——切勿默认使用参数值。其他参数(层数列表、范围列表、天数、分辨率、最优结果数量)除非用户指定,否则可使用默认值。

Run (Live Trading)

运行(实盘交易)

Human Confirmation Required

需要人工确认

NEVER execute
revx strategy grid run
(without
--dry-run
) 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.
--dry-run
does not require confirmation (no real orders).
未经用户明确确认,绝不要执行不带
--dry-run
revx strategy grid run
命令
。该命令会下达真实订单,动用真实资金。
启动实盘网格机器人前,向用户展示确认摘要:
即将启动的网格机器人:
  • 交易对:BTC-USD
  • 投入资金:500美元
  • 网格层数:每侧10层
  • 网格范围:±5%
  • 模式:实盘(LIVE)(真实订单)
这将下达真实的买入和卖出订单。是否继续?
仅在用户明确批准后执行。
--dry-run
无需确认(不会下达真实订单)。

Always Suggest Dry Run First

建议先进行模拟运行

When the user asks to run a live grid bot, always suggest starting with
--dry-run
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.
当用户请求运行实盘网格机器人时,除非用户在当前会话中已完成模拟运行或明确表示要跳过,否则始终建议先执行
--dry-run
示例回复:
在启动实盘前,我建议先进行模拟运行以验证网格设置:
bash
revx strategy grid run BTC-USD --investment 500 --levels 10 --range 5 --dry-run
这会模拟机器人运行,但不会下达真实订单。要不要先进行模拟运行?
如果用户确认要跳过模拟运行,则进入上述实盘确认流程。

Missing Parameters — Always Ask, Never Guess

参数缺失——务必询问,切勿猜测

The
--investment
flag is required by the CLI, but also confirm the user's intent for all key parameters:
  1. Symbol — which pair?
  2. Investment — how much capital?
  3. Levels — how many grid levels per side? (default 5 if user says "use defaults")
  4. 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
FlagDefaultDescription
--investment <amount>
requiredCapital in quote currency
--levels <n>
5Grid levels per side (2-25)
--range <pct>
5Grid range +/- % from mid
--split
offSplit investment across buy and sell levels (market-buy base for levels above current price)
--interval <sec>
10Polling interval in seconds
--dry-run
offSimulate without real orders
--reset
offDiscard 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
revx-telegram
skill), notifications are sent on startup, shutdown, fills, and P&L changes.
CLI要求必须提供
--investment
标识,但同时也要确认用户对所有关键参数的意向:
  1. 交易对——哪一个交易对?
  2. 投入资金——投入多少资金?
  3. 网格层数——每侧设置多少层网格?(如果用户说“使用默认值”,则默认5层)
  4. 网格范围——设置多少百分比范围?(如果用户说“使用默认值”,则默认5%)
如果用户说“在BTC上运行网格机器人”,至少要询问投入资金金额。
运行带实时仪表盘的实盘网格机器人:
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)默认值说明
--investment <amount>
必填投入资金(计价货币)
--levels <n>
5每侧的网格层数(2-25)
--range <pct>
5网格范围:相对于中间价的±百分比
--split
关闭在买入和卖出层之间拆分资金(对高于当前价格的层级进行市价买入基础货币)
--interval <sec>
10轮询间隔(秒)
--dry-run
关闭模拟运行,不下达真实订单
--reset
关闭丢弃已保存的状态,重新开始
按下Ctrl+C可优雅关闭(取消未成交订单,打印摘要)。
持久性: 状态会自动保存以实现崩溃恢复。优雅关闭会删除状态。崩溃的会话在重启时会自动对账。
如果已配置Telegram连接器(参见
revx-telegram
技能),则会在启动、关闭、成交和盈亏变化时发送通知。

Long-Running Command — Behavioral Instructions for Claude

长期运行命令——Claude的行为说明

revx strategy grid run
(including
--dry-run
) runs indefinitely as a continuous polling loop.
How to handle:
  1. Run the command using the
    Bash
    tool with
    run_in_background: true
    — this frees Claude immediately while the process runs asynchronously
  2. Periodically read the background task output file with the
    Read
    tool to monitor status and report key events to the user (orders placed, fills, errors)
  3. If the user asks to stop, use the
    TaskStop
    tool with the task ID
  4. 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).

revx strategy grid run
(包括
--dry-run
)会作为持续轮询循环无限运行
处理方式:
  1. 使用
    Bash
    工具并设置
    run_in_background: true
    来执行命令——这会立即释放Claude,同时进程在后台异步运行
  2. 定期使用
    Read
    工具读取后台任务输出文件,监控状态并向用户报告关键事件(订单下达、成交、错误)
  3. 如果用户要求停止,使用
    TaskStop
    工具并传入任务ID
  4. 同时向用户打印命令,以便他们可以选择在单独终端中运行以获得完整的实时仪表盘体验(带颜色、实时表格,按下Ctrl+C停止)
示例——启动网格机器人:
Bash工具调用:
json
{ "command": "revx strategy grid run BTC-USD --investment 500 --levels 10 --range 5", "run_in_background": true }
给用户的回复:
已在后台启动BTC-USD的网格机器人。我会定期检查更新。
如果你想查看实时仪表盘,请在单独终端中运行以下命令:
bash
revx strategy grid run BTC-USD --investment 500 --levels 10 --range 5
按下Ctrl+C可停止(会优雅取消未成交订单)。

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
--split
. Present it as a simple choice with context:
Would you like to use split mode (
--split
)?
  • 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
--split
consistently across backtest, optimize, dry-run, and live when the user has chosen split mode.

当用户设置网格策略(回测、优化或运行)时,如果他们未指定
--split
询问他们是否要使用拆分模式。以简单选择的方式呈现并说明背景:
你是否要使用拆分模式(
--split
)?
  • 不使用拆分——所有资金投入当前价格下方的买入订单。最适合上涨趋势市场,此时你预期价格会回落到买入区间后反弹。
  • 使用拆分——资金分配到买入和卖出层。在起始价格进行市价买入,为上方的卖出仓位提供资金。最适合震荡/横盘市场,此时价格在当前水平附近波动。
如果用户不确定,建议在回测/优化中运行两种模式以比较结果。
当用户选择拆分模式后,在回测、优化、模拟运行和实盘运行中均需一致使用
--split

P&L Metrics

盈亏指标(P&L)

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
--split
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
--split
:
only buy levels (below start price) are funded. In uptrending markets all grid cycles may complete, making Realized and Total P&L equal.
With
--split
:
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.

Realized P&L = 每笔完成卖出的利润总和(卖出收入 − 每层成本)。衡量纯粹的网格交易利润。初始拆分买入(如果使用
--split
)不会影响该指标。
Total P&L =(最终计价货币余额 + 最终基础货币数量 × 最终价格)− 初始投入资金。按市值计算的投资组合价值变化。不会在结束时强制卖出资产。
不使用
--split
时:
仅为起始价格下方的买入层提供资金。在上涨趋势市场中,所有网格周期可能完成,此时已实现盈亏和总盈亏相等。
使用
--split
时:
资金分配到所有层级。起始价格上方的层级通过在起始价格进行模拟市价买入获得仓位。这会导致已实现盈亏和总盈亏出现差异,并允许在网格范围内的上下波动中获利。

Common Workflow: Backtest Then Run

常见流程:先回测再运行

bash
undefined
bash
undefined

1. Optimize to find best parameters

1. 优化以找到最佳参数

revx strategy grid optimize BTC-USD --investment 1000 --days 30
revx strategy grid optimize BTC-USD --investment 1000 --days 30

2. Backtest the top result

2. 回测最优结果

revx strategy grid backtest BTC-USD --levels 10 --range 7 --investment 1000
revx strategy grid backtest BTC-USD --levels 10 --range 7 --investment 1000

3. Dry run first

3. 先进行模拟运行

revx strategy grid run BTC-USD --investment 1000 --levels 10 --range 7 --dry-run
revx strategy grid run BTC-USD --investment 1000 --levels 10 --range 7 --dry-run

4. Go live

4. 启动实盘

revx strategy grid run BTC-USD --investment 1000 --levels 10 --range 7

Use `--split` consistently across all steps if you want to test and run with split investment.

---
revx strategy grid run BTC-USD --investment 1000 --levels 10 --range 7

如果你想测试并运行拆分资金模式,请在所有步骤中一致使用`--split`。

---

Related Skills

相关技能

SkillPurpose
revx-telegram
Get Telegram notifications for grid bot events
revx-market
Check prices and pair data before configuring a grid
revx-account
Check balances and order status
revx-trading
Manual order placement (grid bot places orders automatically)
revx-auth
API key setup and configuration
技能用途
revx-telegram
获取网格机器人事件的Telegram通知
revx-market
配置网格前查看价格和交易对数据
revx-account
查看余额和订单状态
revx-trading
手动下单(网格机器人自动下单)
revx-auth
API密钥设置和配置