diff --git a/app/static/futures_analysis.js b/app/static/futures_analysis.js index 1f3ebf0..447b229 100644 --- a/app/static/futures_analysis.js +++ b/app/static/futures_analysis.js @@ -1426,6 +1426,17 @@ function trRenderDetailKline(data, pair) { } }); + // 计算全局价格范围,用于确定标记偏移量 + let globalLow = Infinity, globalHigh = -Infinity; + candles.forEach(c => { + const lo = parseFloat(c[3]); + const hi = parseFloat(c[4]); + if (lo < globalLow) globalLow = lo; + if (hi > globalHigh) globalHigh = hi; + }); + const priceRange = globalHigh - globalLow; + const markerOffset = priceRange * 0.06; // 标记偏移量:价格范围的6% + // 生成标记数据 let minMarkerIdx = Infinity; let maxMarkerIdx = -Infinity; @@ -1435,8 +1446,8 @@ function trRenderDetailKline(data, pair) { const candle = candles[dateIdx]; const price = parseFloat(m.price); const low = parseFloat(candle[3]); - const high = parseFloat(candle[4]); - const markerPrice = Math.max(low, Math.min(high, price)); + // 买标记放在K线下方,远离柱体 + const markerPrice = low - markerOffset; buyMarkers.push({ name: `买${m.offset || ''}`, @@ -1453,9 +1464,9 @@ function trRenderDetailKline(data, pair) { const dateIdx = parseInt(idx); const candle = candles[dateIdx]; const price = parseFloat(m.price); - const low = parseFloat(candle[3]); const high = parseFloat(candle[4]); - const markerPrice = Math.max(low, Math.min(high, price)); + // 卖标记放在K线上方,远离柱体 + const markerPrice = high + markerOffset; sellMarkers.push({ name: `卖${m.offset || ''}`, @@ -1564,7 +1575,7 @@ function trRenderDetailKline(data, pair) { symbol: 'triangle', symbolSize: 12, data: buyMarkers, - label: { show: true, formatter: '{b}', fontSize: 10, color: '#10b981' }, + label: { show: true, formatter: '{b}', fontSize: 10, color: '#10b981', position: 'bottom', distance: 5 }, }, }, { @@ -1581,7 +1592,7 @@ function trRenderDetailKline(data, pair) { symbolSize: 12, symbolRotate: 180, data: sellMarkers, - label: { show: true, formatter: '{b}', fontSize: 10, color: '#ef4444' }, + label: { show: true, formatter: '{b}', fontSize: 10, color: '#ef4444', position: 'top', distance: 5 }, }, }, { diff --git a/data/futures_analysis.db b/data/futures_analysis.db index d1edf2f..5c2482b 100644 Binary files a/data/futures_analysis.db and b/data/futures_analysis.db differ