mirror of
https://ghfast.top/https://github.com/aeroxw/easy-tdx.git
synced 2026-09-12 15:44:15 +08:00
fix(web-ui): 翻页拼接后按时间排序,修复>800根数据图表/成交记录错乱
翻页拼接 concat 后页间时间逆序(page1=最新段,page2=更旧段), 导致 index 800 处时间从 2026 倒退到 2019。引擎/图表只正确处理前 800 根, 成交记录在 800 根后出现 2019 年数据。 修复:concat 后加 sort((a,b) => datetime.localeCompare)。 实测 1600 根排序后整体时间正序,index 799→800 连续递增。
This commit is contained in:
+9
-5
@@ -86,11 +86,15 @@ export async function fetchBars(
|
||||
if (pageBars.length < 800) break
|
||||
}
|
||||
|
||||
// 按日期范围过滤(闭区间)
|
||||
let bars = allBars
|
||||
if (startDate) bars = bars.filter((b) => b.datetime.slice(0, 10) >= startDate)
|
||||
if (endDate) bars = bars.filter((b) => b.datetime.slice(0, 10) <= endDate)
|
||||
return bars
|
||||
// 按日期范围过滤(闭区间)
|
||||
let bars = allBars
|
||||
if (startDate) bars = bars.filter((b) => b.datetime.slice(0, 10) >= startDate)
|
||||
if (endDate) bars = bars.filter((b) => b.datetime.slice(0, 10) <= endDate)
|
||||
// 翻页拼接后按时间正序排序:每页内部是正序,但页间是逆序
|
||||
// (page1=最新段,page2=更旧段),concat 后需排序保证整体正序,
|
||||
// 否则引擎/图表只正确处理第一页的数据。
|
||||
bars.sort((a, b) => a.datetime.localeCompare(b.datetime))
|
||||
return bars
|
||||
}
|
||||
|
||||
/** 把后端 bars 的单条记录归一化为统一 Bar(datetime 字段)。 */
|
||||
|
||||
Reference in New Issue
Block a user