mirror of
https://github.com/discountry/ritmex-bot.git
synced 2026-09-11 17:28:08 +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";
|
} from "./types";
|
||||||
import { coerceBooleanFlag, normalizeBooleanFlag } from "./flags";
|
import { coerceBooleanFlag, normalizeBooleanFlag } from "./flags";
|
||||||
import { normalizeOrderIdentity } from "./order-identity";
|
import { normalizeOrderIdentity } from "./order-identity";
|
||||||
|
import { normalizeOrderStatus } from "./status";
|
||||||
|
|
||||||
export function toDepth(symbol: string, snapshot: LighterOrderBookSnapshot): AsterDepth {
|
export function toDepth(symbol: string, snapshot: LighterOrderBookSnapshot): AsterDepth {
|
||||||
const toLevels = (levels: LighterOrderBookLevel[]): AsterDepthLevel[] =>
|
const toLevels = (levels: LighterOrderBookLevel[]): AsterDepthLevel[] =>
|
||||||
@@ -104,7 +105,7 @@ export function lighterOrderToAster(symbol: string, order: LighterOrder): AsterO
|
|||||||
symbol,
|
symbol,
|
||||||
side,
|
side,
|
||||||
type: mapOrderType(order.type),
|
type: mapOrderType(order.type),
|
||||||
status: order.status ?? order.trigger_status ?? "UNKNOWN",
|
status: normalizeOrderStatus(order.status ?? order.trigger_status ?? "UNKNOWN"),
|
||||||
price: order.price ?? "0",
|
price: order.price ?? "0",
|
||||||
origQty: order.initial_base_amount ?? "0",
|
origQty: order.initial_base_amount ?? "0",
|
||||||
executedQty: computeExecutedQty(order),
|
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;
|
priceChange?: string;
|
||||||
priceChangePercent?: string;
|
priceChangePercent?: string;
|
||||||
weightedAvgPrice?: string;
|
weightedAvgPrice?: string;
|
||||||
|
bidPrice?: string;
|
||||||
|
askPrice?: string;
|
||||||
|
markPrice?: string;
|
||||||
lastQty?: string;
|
lastQty?: string;
|
||||||
openTime?: number;
|
openTime?: number;
|
||||||
closeTime?: number;
|
closeTime?: number;
|
||||||
|
|||||||
Reference in New Issue
Block a user