From d6533733c954ab0c6573024c597589c97939251b Mon Sep 17 00:00:00 2001 From: discountry Date: Sun, 28 Sep 2025 01:39:49 +0800 Subject: [PATCH] =?UTF-8?q?docs:=20=E6=9B=B4=E6=96=B0=20README=20=E6=96=87?= =?UTF-8?q?=E4=BB=B6=EF=BC=8C=E6=B7=BB=E5=8A=A0=E9=9D=99=E9=BB=98=E5=90=AF?= =?UTF-8?q?=E5=8A=A8=E5=92=8C=E5=90=8E=E5=8F=B0=E8=BF=90=E8=A1=8C=E7=9A=84?= =?UTF-8?q?=E8=AF=B4=E6=98=8E=EF=BC=8C=E5=8C=85=E6=8B=AC=E5=91=BD=E4=BB=A4?= =?UTF-8?q?=E8=A1=8C=E7=94=A8=E6=B3=95=E5=92=8C=20pm2=20=E9=85=8D=E7=BD=AE?= =?UTF-8?q?=E7=A4=BA=E4=BE=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 36 ++++++++++++++++++++++++++++++++++++ README_en.md | 40 ++++++++++++++++++++++++++++++++++++++++ 2 files changed, 76 insertions(+) diff --git a/README.md b/README.md index d2af844..e28c05a 100644 --- a/README.md +++ b/README.md @@ -80,6 +80,42 @@ bun run dev # 调试模式,等价于运行 index.ts bun x vitest run # 执行单元测试 ``` +## 静默启动与后台运行 +### 直接静默启动 +无需进入 Ink 菜单,可用命令行直接拉起指定策略: + +```bash +bun run index.ts --strategy trend --silent # 启动趋势策略 +bun run index.ts --strategy maker --silent # 启动做市策略 +bun run index.ts --strategy offset-maker --silent # 启动偏移做市策略 +``` + +### 项目内置脚本 +`package.json` 提供了便捷脚本: + +```bash +bun run start:trend:silent +bun run start:maker:silent +bun run start:offset:silent +``` + +### 使用 pm2 守护并自动重启 +将 `pm2` 安装到项目中(示例:`bun add -d pm2`),之后即可在不安装全局 pm2 的情况下运行: + +```bash +bunx pm2 start bun --name ritmex-trend --cwd . --restart-delay 5000 -- run index.ts --strategy trend --silent +``` + +亦可直接调用脚本: + +```bash +bun run pm2:start:trend +bun run pm2:start:maker +bun run pm2:start:offset +``` + +根据需要调整 `--name`、`--cwd`、`--restart-delay` 等参数,完成后可执行 `pm2 save` 持久化进程列表。 + ## 测试 项目使用 Vitest: ```bash diff --git a/README_en.md b/README_en.md index e23bff0..56e6d35 100644 --- a/README_en.md +++ b/README_en.md @@ -77,6 +77,42 @@ bun run dev # Development entry point bun x vitest run # Execute the Vitest suite ``` +## Silent & Background Execution +### Direct silent launch +Skip the Ink menu and start a strategy straight from the CLI: + +```bash +bun run index.ts --strategy trend --silent # Trend engine +bun run index.ts --strategy maker --silent # Maker engine +bun run index.ts --strategy offset-maker --silent # Offset maker engine +``` + +### Package scripts +Convenience aliases are exposed in `package.json`: + +```bash +bun run start:trend:silent +bun run start:maker:silent +bun run start:offset:silent +``` + +### Daemonising with pm2 +Install `pm2` locally (e.g. `bun add -d pm2`) and launch without a global install: + +```bash +bunx pm2 start bun --name ritmex-trend --cwd . --restart-delay 5000 -- run index.ts --strategy trend --silent +``` + +You can also reuse the bundled scripts: + +```bash +bun run pm2:start:trend +bun run pm2:start:maker +bun run pm2:start:offset +``` + +Adjust `--name`, `--cwd`, or `--restart-delay` to suit your environment and run `pm2 save` if you want the process to auto-start after reboot. + ## Testing Vitest powers the unit tests: ```bash @@ -85,6 +121,10 @@ bun x vitest --watch ``` ## Troubleshooting +- You need at least 50–100 USDT of capital before deploying a live strategy. +- Set leverage on the exchange beforehand (around 50x is recommended); the bot does not change it for you. +- Keep server/desktop time in sync with real-world time to avoid signature errors. +- Make sure the exchange account is in one-way position mode. - **Env not loading**: ensure `.env` resides in the repository root and variable names are spelled correctly. - **Order rejected for precision**: align `PRICE_TICK`, `QTY_STEP`, and `TRADE_SYMBOL` with the exchange filters. - **Permission or auth errors**: double-check exchange API scopes.