mirror of
https://github.com/discountry/ritmex-bot.git
synced 2026-09-09 08:18:07 +00:00
feat: add bid, ask, and mark price to AsterTicker and normalize order status in LighterGateway
This commit is contained in:
@@ -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),
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user