feat: stabilize Xingtu market data sync

This commit is contained in:
2026-04-21 14:16:29 +08:00
parent 85e835a96a
commit 55324a5bb7
19 changed files with 2150 additions and 1366 deletions
+14
View File
@@ -17,6 +17,16 @@ export function normalizeRateDisplay(value: string): string {
return trimmedValue.replace(/\s+/g, "");
}
export function normalizeFractionRateDisplay(value: string): string | null {
const numericValue = Number(value);
if (!Number.isFinite(numericValue)) {
return null;
}
const percentageValue = numericValue * 100;
return `${trimTrailingZeros(percentageValue.toFixed(6))}%`;
}
export function parseRateLowerBound(value: string | null | undefined): number | null {
const comparableRate = toComparableRate(value);
return comparableRate?.numeric ?? null;
@@ -86,3 +96,7 @@ function toComparableRate(value: string | null | undefined): ComparableRate | nu
return null;
}
function trimTrailingZeros(value: string): string {
return value.replace(/\.?0+$/, "");
}