Enhance CLI command mode for ritmex-bot (#23)

- Introduced a new command mode for `ritmex-bot`, allowing agent-friendly structured trading operations without entering the Ink interactive menu.
- Updated `package.json` to include versioning and set the project as public with a new CLI entry point.
- Enhanced documentation in both English and Chinese to provide comprehensive usage instructions for the new command mode.
- Added a new executable script for `ritmex-bot` to facilitate command execution.
- Improved error handling and command parsing for better user experience and clarity in command execution.
This commit is contained in:
Disney
2026-02-27 12:42:20 +08:00
committed by GitHub
parent d6399b92aa
commit 4014a86223
22 changed files with 3319 additions and 53 deletions
+4 -2
View File
@@ -474,18 +474,20 @@ export class BackpackGateway {
if (!quantity) continue;
const sideRaw = String(raw?.side ?? info.side ?? this.deriveSideFromExposure(info)).toLowerCase();
const isShort = sideRaw.includes("short") || quantity < 0;
const isLong = sideRaw.includes("long") || (!sideRaw.includes("short") && quantity > 0);
const positionAmt = isShort ? -Math.abs(quantity) : Math.abs(quantity);
const entryPrice = this.toStringAmount(raw?.entryPrice ?? info.entryPrice ?? "0");
const unrealized = this.toStringAmount(raw?.unrealizedPnl ?? info.pnlUnrealized ?? "0");
const markPrice = this.toOptionalString(raw?.markPrice ?? info.markPrice);
const liquidationPrice = this.toOptionalString(raw?.liquidationPrice ?? info.estLiquidationPrice);
const leverage = this.toOptionalString(raw?.leverage ?? info.leverage);
const symbol = String(raw?.symbol ?? info.symbol ?? this.marketSymbol ?? this.symbol);
positions.push({
symbol: this.symbol,
symbol,
positionAmt: positionAmt.toString(),
entryPrice,
unrealizedProfit: unrealized,
positionSide: "BOTH",
positionSide: isLong ? "LONG" : isShort ? "SHORT" : "BOTH",
updateTime: now,
markPrice,
liquidationPrice,