mirror of
https://github.com/discountry/ritmex-bot.git
synced 2026-09-11 17:28:08 +00:00
i18n(core): route order-coordinator and token/margin guards through t()
These files bypassed the i18n table entirely, so a user running LANG=en still got Chinese order logs. Migrating them surfaced structural duplication too: the five order paths each spelled out their own 'quantity invalid' string, now one key parameterised by an order-kind label. Also fixes a type that carried display text as its domain: TrendLabel was '做多' | '做空' | '无信号', so the engine's snapshot value *was* the Chinese string and English rendering depended on matching it. Now 'long' | 'short' | 'none', translated at the edge. Order-coordinator tests asserted the Chinese literals, which is exactly what made the gap invisible; they now assert the resolved key so they hold in either language. 39 new translation keys. 271 pass; tsc and oxlint clean.
This commit is contained in:
@@ -32,6 +32,7 @@ import { createTradeLog, type TradeLogEntry } from "../logging/trade-log";
|
||||
import { decryptCopyright } from "../utils/copyright";
|
||||
import { isRateLimitError } from "../utils/errors";
|
||||
import { RateLimitController } from "../core/lib/rate-limit";
|
||||
import type { TrendLabel } from "../utils/format";
|
||||
import { StrategyEventEmitter } from "./common/event-emitter";
|
||||
import { createPrecisionSyncer, type PrecisionSyncer } from "./common/precision-syncer";
|
||||
import { safeSubscribe, type LogHandler } from "./common/subscriptions";
|
||||
@@ -44,7 +45,7 @@ export interface TrendEngineSnapshot {
|
||||
lastPrice: number | null;
|
||||
sma30: number | null;
|
||||
bollingerBandwidth: number | null;
|
||||
trend: "做多" | "做空" | "无信号";
|
||||
trend: TrendLabel;
|
||||
position: PositionSnapshot;
|
||||
pnl: number;
|
||||
unrealized: number;
|
||||
@@ -978,13 +979,14 @@ export class TrendEngine {
|
||||
const position = getPosition(this.accountSnapshot, this.config.symbol);
|
||||
const price = this.tickerSnapshot ? Number(this.tickerSnapshot.lastPrice) : null;
|
||||
const sma30 = this.lastSma30;
|
||||
const trend = price == null || sma30 == null
|
||||
? "无信号"
|
||||
: price > sma30
|
||||
? "做多"
|
||||
: price < sma30
|
||||
? "做空"
|
||||
: "无信号";
|
||||
const trend: TrendLabel =
|
||||
price == null || sma30 == null
|
||||
? "none"
|
||||
: price > sma30
|
||||
? "long"
|
||||
: price < sma30
|
||||
? "short"
|
||||
: "none";
|
||||
const pnl = price != null ? computePositionPnl(position, price, price) : 0;
|
||||
return {
|
||||
ready: this.isReady(),
|
||||
|
||||
Reference in New Issue
Block a user