Add weekend open skip, expiry force-close, and Chinese trade labels.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
dekun
2026-07-25 10:28:33 +08:00
parent 826362b556
commit b50c134f5b
19 changed files with 525 additions and 52 deletions
+68
View File
@@ -0,0 +1,68 @@
/** 交易相关英文码 → 中文展示(库内仍存英文)。 */
const STATUS_ZH: Record<string, string> = {
open: "持仓中",
closed: "已平仓",
};
const SIDE_ZH: Record<string, string> = {
long: "多",
short: "空",
call: "看涨",
put: "看跌",
};
const LEG_ZH: Record<string, string> = {
perp: "永续",
option: "期权",
};
const ACTION_ZH: Record<string, string> = {
open: "开仓",
close: "平仓",
};
const CLOSE_REASON_ZH: Record<string, string> = {
fixed_usdt: "固定净盈利达标",
premium_multiple: "权利金倍数达标",
expiry: "到期自动全平",
emergency: "紧急全平",
manual: "手动平仓",
liquidity_retry: "流动性等待后续平仓",
unknown: "未知",
};
export function statusZh(v: string | null | undefined): string {
if (!v) return "—";
return STATUS_ZH[v] || v;
}
export function sideZh(v: string | null | undefined): string {
if (!v) return "—";
return SIDE_ZH[v] || v;
}
/** 永续方向 / 期权方向,如「多/看跌」 */
export function positionSidesZh(
perp: string | null | undefined,
option: string | null | undefined,
): string {
return `${sideZh(perp)}/${sideZh(option)}`;
}
export function fillDescZh(leg: string, action: string, side: string): string {
const l = LEG_ZH[leg] || leg;
const a = ACTION_ZH[action] || action;
const s = SIDE_ZH[side] || side;
// 期权买入开仓:「期权开多」;永续:「永续开多/开空」
if (leg === "option" && action === "open") return "期权开多";
if (leg === "option" && action === "close") return "期权平多";
if (leg === "perp" && action === "open") return s === "多" ? "永续开多" : "永续开空";
if (leg === "perp" && action === "close") return s === "多" ? "永续平多" : "永续平空";
return `${l}${a}${s}`;
}
export function closeReasonZh(v: string | null | undefined): string {
if (!v) return "—";
return CLOSE_REASON_ZH[v] || v;
}