This commit is contained in:
discountry
2025-12-08 23:55:13 +08:00
parent a23eb91f04
commit 49b8f0bcf1
2 changed files with 46 additions and 1 deletions
+6 -1
View File
@@ -905,13 +905,18 @@ export class LighterGateway {
candidates = preferred;
}
const preferSpot = wantsSpot;
candidates.sort((a, b) => {
const aExact = normalizeSymbolForms(a.symbol).includes(desiredSymbol.toUpperCase()) ? 1 : 0;
const bExact = normalizeSymbolForms(b.symbol).includes(desiredSymbol.toUpperCase()) ? 1 : 0;
if (aExact !== bExact) return bExact - aExact;
const aSpot = normalizeMarketType(a.market_type) === "spot" ? 1 : 0;
const bSpot = normalizeMarketType(b.market_type) === "spot" ? 1 : 0;
if (aSpot !== bSpot) return bSpot - aSpot;
if (aSpot !== bSpot) {
const aScore = preferSpot ? aSpot : 1 - aSpot; // prefer perp when not explicitly spot
const bScore = preferSpot ? bSpot : 1 - bSpot;
return bScore - aScore;
}
return 0;
});