feat: add bid, ask, and mark price to AsterTicker and normalize order status in LighterGateway

This commit is contained in:
discountry
2025-11-13 02:34:10 +08:00
parent 7529de334f
commit a9fa7f2e19
3 changed files with 19 additions and 1 deletions
+2 -1
View File
@@ -21,6 +21,7 @@ import type {
} from "./types";
import { coerceBooleanFlag, normalizeBooleanFlag } from "./flags";
import { normalizeOrderIdentity } from "./order-identity";
import { normalizeOrderStatus } from "./status";
export function toDepth(symbol: string, snapshot: LighterOrderBookSnapshot): AsterDepth {
const toLevels = (levels: LighterOrderBookLevel[]): AsterDepthLevel[] =>
@@ -104,7 +105,7 @@ export function lighterOrderToAster(symbol: string, order: LighterOrder): AsterO
symbol,
side,
type: mapOrderType(order.type),
status: order.status ?? order.trigger_status ?? "UNKNOWN",
status: normalizeOrderStatus(order.status ?? order.trigger_status ?? "UNKNOWN"),
price: order.price ?? "0",
origQty: order.initial_base_amount ?? "0",
executedQty: computeExecutedQty(order),
+14
View File
@@ -0,0 +1,14 @@
const TERMINAL_STATUS_MAP: Record<string, string> = {
filled: "FILLED",
canceled: "CANCELED",
cancelled: "CANCELED",
expired: "EXPIRED",
"canceled-post-only": "CANCELED",
"canceled-reduce-only": "CANCELED",
};
export function normalizeOrderStatus(raw: string): string {
if (!raw) return "UNKNOWN";
const normalized = raw.toLowerCase();
return TERMINAL_STATUS_MAP[normalized] ?? raw.toUpperCase();
}
+3
View File
@@ -316,6 +316,9 @@ export interface AsterTicker {
priceChange?: string;
priceChangePercent?: string;
weightedAvgPrice?: string;
bidPrice?: string;
askPrice?: string;
markPrice?: string;
lastQty?: string;
openTime?: number;
closeTime?: number;