feat: 增强 Lighter 适配器的账户更新逻辑,支持市场账户的实时更新和合并处理

This commit is contained in:
discountry
2025-10-03 15:52:18 +08:00
parent d328758074
commit 263cbd7c21
2 changed files with 58 additions and 4 deletions
+2 -1
View File
@@ -172,7 +172,8 @@ function lighterPositionToAster(symbol: string, position: LighterPosition): Aste
const sign = position.sign ?? 0;
const positionSide = sign > 0 ? "LONG" : sign < 0 ? "SHORT" : "BOTH";
const magnitude = Number(position.position ?? 0);
const signed = sign < 0 ? -Math.abs(magnitude) : Math.abs(magnitude);
// Normalize: when sign is 0, treat as flat regardless of reported magnitude
const signed = sign === 0 ? 0 : sign < 0 ? -Math.abs(magnitude) : Math.abs(magnitude);
return {
symbol,
positionAmt: Number.isFinite(signed) ? signed.toString() : position.position ?? "0",