feat: stabilize Xingtu market data sync
This commit is contained in:
@@ -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+$/, "");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user