Fix hub market chart live K-line updates in manual follow mode.
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -2486,6 +2486,7 @@
|
||||
const aligned = alignCandlesToTick(incoming);
|
||||
const prevLen = lastCandles.length;
|
||||
const oldestTime = prevLen ? lastCandles[0].time : null;
|
||||
const prevLastTime = prevLen ? lastCandles[prevLen - 1].time : null;
|
||||
const merged = mergeCandles(lastCandles, aligned, { prepend: false });
|
||||
if (
|
||||
prevLen > 0 &&
|
||||
@@ -2495,16 +2496,21 @@
|
||||
) {
|
||||
return false;
|
||||
}
|
||||
aligned.forEach(function (bar) {
|
||||
candleSeries.update(bar);
|
||||
volumeSeries.update(buildVolumeBar(bar));
|
||||
});
|
||||
if (merged.length > prevLen) {
|
||||
for (let i = prevLen; i < merged.length; i++) {
|
||||
let patchStart = 0;
|
||||
if (prevLastTime != null) {
|
||||
patchStart = merged.findIndex(function (b) {
|
||||
return b.time >= prevLastTime;
|
||||
});
|
||||
if (patchStart < 0) return false;
|
||||
}
|
||||
try {
|
||||
for (let i = patchStart; i < merged.length; i++) {
|
||||
const bar = merged[i];
|
||||
candleSeries.update(bar);
|
||||
volumeSeries.update(buildVolumeBar(bar));
|
||||
}
|
||||
} catch (_) {
|
||||
return false;
|
||||
}
|
||||
lastCandles = merged;
|
||||
indexCandles(lastCandles);
|
||||
@@ -2639,7 +2645,15 @@
|
||||
}
|
||||
}
|
||||
const aligned = alignCandlesToTick(incoming);
|
||||
if (!autoFollow && applyTailCandlePatch(aligned)) {
|
||||
let tailPatched = false;
|
||||
if (!autoFollow) {
|
||||
try {
|
||||
tailPatched = applyTailCandlePatch(aligned);
|
||||
} catch (_) {
|
||||
tailPatched = false;
|
||||
}
|
||||
}
|
||||
if (!autoFollow && tailPatched) {
|
||||
/* 手动模式:增量 update,不触碰时间轴 */
|
||||
} else {
|
||||
const merged = mergeCandles(lastCandles, aligned, { prepend: false });
|
||||
@@ -2862,7 +2876,12 @@
|
||||
}
|
||||
if (posContext) updateLivePosPnl();
|
||||
const ver = Number(st.chart_version) || 0;
|
||||
if (ver && ver !== localChartVersion) localChartVersion = ver;
|
||||
if (ver && ver !== localChartVersion) {
|
||||
localChartVersion = ver;
|
||||
if (lastCandles.length && vKey === lastViewKey && !chartDataLoading) {
|
||||
void refreshChartTail();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function connectChartStream() {
|
||||
|
||||
@@ -1046,7 +1046,7 @@
|
||||
<div id="toast"></div>
|
||||
<script src="https://unpkg.com/lightweight-charts@4.2.0/dist/lightweight-charts.standalone.production.js"></script>
|
||||
<script src="/assets/chart_draw.js?v=20260609-market-day-split"></script>
|
||||
<script src="/assets/chart.js?v=20260614-market-live"></script>
|
||||
<script src="/assets/chart.js?v=20260626-market-tail-patch"></script>
|
||||
<script src="/assets/plan.js?v=20260614-plan-refresh"></script>
|
||||
<script src="/assets/calculator.js?v=3"></script>
|
||||
<script src="/assets/archive.js?v=20260612-archive-ai-chat"></script>
|
||||
|
||||
Reference in New Issue
Block a user