fix(hub): green open arrows for long, red for short on archive chart

Explicit open marker colors and broader direction parsing (short/空/sell).

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
dekun
2026-06-07 23:43:21 +08:00
parent 69f554214c
commit 41bdee2416
2 changed files with 19 additions and 3 deletions
+18 -2
View File
@@ -255,9 +255,25 @@
return best; return best;
} }
const OPEN_ARROW_LONG = "#22c55e";
const OPEN_ARROW_SHORT = "#ef4444";
const OPEN_ARROW_LONG_HI = "#4ade80";
const OPEN_ARROW_SHORT_HI = "#f87171";
function isLongDirection(dir) { function isLongDirection(dir) {
const d = String(dir || "").trim().toLowerCase(); const d = String(dir || "").trim().toLowerCase();
return d === "long" || d === "" || d === "buy"; if (d === "short" || d === "空" || d === "sell" || d === "做空" || d === "shorts") {
return false;
}
if (d === "long" || d === "多" || d === "buy" || d === "做多" || d === "longs") {
return true;
}
return true;
}
function openArrowColor(long, highlight) {
if (long) return highlight ? OPEN_ARROW_LONG_HI : OPEN_ARROW_LONG;
return highlight ? OPEN_ARROW_SHORT_HI : OPEN_ARROW_SHORT;
} }
function buildTradeMarkers(tr, candles, tf, opts) { function buildTradeMarkers(tr, candles, tf, opts) {
@@ -268,7 +284,7 @@
const long = isLongDirection(tr.direction); const long = isLongDirection(tr.direction);
const openMs = tradeOpenMs(tr); const openMs = tradeOpenMs(tr);
const closeMs = tradeCloseMs(tr); const closeMs = tradeCloseMs(tr);
const openColor = highlight ? (long ? "#4ade80" : "#f87171") : long ? "#22c55e" : "#ef4444"; const openColor = openArrowColor(long, highlight);
let closeColor = highlight ? "#fbbf24" : "#f59e0b"; let closeColor = highlight ? "#fbbf24" : "#f59e0b";
const pnl = Number(tr.pnl_amount); const pnl = Number(tr.pnl_amount);
if (!highlight && Number.isFinite(pnl) && pnl < -0.0001) { if (!highlight && Number.isFinite(pnl) && pnl < -0.0001) {
+1 -1
View File
@@ -352,7 +352,7 @@
<div id="toast"></div> <div id="toast"></div>
<script src="https://unpkg.com/lightweight-charts@4.2.0/dist/lightweight-charts.standalone.production.js"></script> <script src="https://unpkg.com/lightweight-charts@4.2.0/dist/lightweight-charts.standalone.production.js"></script>
<script src="/assets/chart.js?v=20260604-upnl-contracts"></script> <script src="/assets/chart.js?v=20260604-upnl-contracts"></script>
<script src="/assets/archive.js?v=20260607-hub-archive-v5"></script> <script src="/assets/archive.js?v=20260607-hub-archive-v6"></script>
<script src="/assets/ai_review_render.js?v=2"></script> <script src="/assets/ai_review_render.js?v=2"></script>
<script src="/assets/app.js?v=20260607-hub-archive-v1"></script> <script src="/assets/app.js?v=20260607-hub-archive-v1"></script>
</body> </body>