diff --git a/manual_trading_hub/static/chart.js b/manual_trading_hub/static/chart.js index 053c077..5614b41 100644 --- a/manual_trading_hub/static/chart.js +++ b/manual_trading_hub/static/chart.js @@ -46,6 +46,7 @@ let priceTick = null; let priceAutoScale = true; let rangeMarkers = []; + let currentPriceLine = null; let lastCandles = []; let candleByTime = {}; let chartMeta = null; @@ -159,9 +160,35 @@ function showLatestOhlcv() { paintOhlcv(latestCandle()); + updateCurrentPriceLine(); updatePriceTag(); } + function clearCurrentPriceLine() { + if (currentPriceLine && candleSeries) { + try { + candleSeries.removePriceLine(currentPriceLine); + } catch (e) {} + } + currentPriceLine = null; + } + + function updateCurrentPriceLine() { + clearCurrentPriceLine(); + if (!candleSeries) return; + const bar = latestCandle(); + if (!bar || bar.close == null) return; + const up = Number(bar.close) >= Number(bar.open); + currentPriceLine = candleSeries.createPriceLine({ + price: Number(bar.close), + color: up ? "#00ff9d" : "#ff4d6d", + lineWidth: 1, + lineStyle: 2, + axisLabelVisible: true, + title: "现价", + }); + } + function tickLiveClock() { const cd = fmtBarCountdown(barRemainMs(currentTf)); if (elPriceTagTime && elPriceTag && !elPriceTag.classList.contains("hidden")) { diff --git a/manual_trading_hub/static/index.html b/manual_trading_hub/static/index.html index 617e001..f3db086 100644 --- a/manual_trading_hub/static/index.html +++ b/manual_trading_hub/static/index.html @@ -192,7 +192,7 @@
- - + +