mirror of
https://github.com/discountry/ritmex-bot.git
synced 2026-09-12 01:38:07 +00:00
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:
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user