Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 37 additions & 0 deletions tests/test_cash_financing.js
Original file line number Diff line number Diff line change
Expand Up @@ -1165,6 +1165,43 @@ console.log("\n=== 11. currentEntryForAccount 映射健壮性 ===\n");
assert(entry && entry.runtime_target_enabled === true, "11g: separator variants should fallback-match");
}

// 11h: 避免平台前缀歧义导致误匹配(longbridge/ibkr 多账号)
{
const state = {
currentStrategies: {
longbridge: {
"longbridge-hk": { runtime_target_enabled: false, reserved_cash_ratio: "0.11" },
"longbridge-sg": { runtime_target_enabled: true, reserved_cash_ratio: "0.03" },
},
ibkr: {
"ibkr-primary": { runtime_target_enabled: false, reserved_cash_ratio: "0.20" },
"ibkr-soxl": { runtime_target_enabled: true, reserved_cash_ratio: "0.05" },
},
},
};
const longbridgeSg = { key: "longbridge-sg", label: "LB|SG", target_name: "longbridge-sg" };
const longbridgeEntry = currentEntryForAccount(state, "longbridge", longbridgeSg);
assert(
longbridgeEntry && longbridgeEntry.runtime_target_enabled === true,
"11h-a: longbridge-sg should match longbridge-sg entry instead of longbridge-hk",
);
assert(
longbridgeEntry && longbridgeEntry.reserved_cash_ratio === "0.03",
"11h-b: longbridge-sg should use its own reserved_cash_ratio",
);

const ibkrSoxl = { key: "ibkr-soxl", label: "IBKR-SOXL", target_name: "ibkr-soxl" };
const ibkrEntry = currentEntryForAccount(state, "ibkr", ibkrSoxl);
assert(
ibkrEntry && ibkrEntry.runtime_target_enabled === true,
"11h-c: ibkr-soxl should match ibkr-soxl entry instead of ibkr-primary",
);
assert(
ibkrEntry && ibkrEntry.reserved_cash_ratio === "0.05",
"11h-d: ibkr-soxl should use its own reserved_cash_ratio",
);
}

// ============================================================
// 12. syncOptionOverlayForAccount (解析为具体值)
// ============================================================
Expand Down
5 changes: 1 addition & 4 deletions web/strategy-switch-console/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -1248,10 +1248,7 @@
if (compact) candidates.add(compact);

const parts = key.split(/[^a-z0-9]+/).filter(Boolean);
for (const part of parts) candidates.add(part);
if (parts.length > 1) {
candidates.add(parts[parts.length - 1]);
}
if (parts.length > 1) candidates.add(parts[parts.length - 1]);
}
return [...candidates];
}
Expand Down
2 changes: 1 addition & 1 deletion web/strategy-switch-console/app_js.js

Large diffs are not rendered by default.

Loading