盘口数据优化

This commit is contained in:
dongzp 2026-07-21 15:39:05 +08:00
parent bc1cd1297a
commit 671a6355da

View File

@ -71,18 +71,22 @@ export function mapBaiduQuotationToQuote(result: BaiduQuotationResult): QuoteDat
const asksRaw = result.askinfos ?? [] const asksRaw = result.askinfos ?? []
const bidsRaw = result.buyinfos ?? [] const bidsRaw = result.buyinfos ?? []
// 盘口:接口卖档为卖5→卖1,买档为买1→买5,与 UI 一致 // 盘口:接口卖档为卖5→卖1,买档为买1→买5;价格为 "0.0"/0 的空档不展示
const asks = asksRaw.map((a, i) => ({ const asks = asksRaw
level: asksRaw.length - i, .map((a, i) => ({
price: toNum(a.askprice), level: asksRaw.length - i,
volume: toNum(a.askvolume), price: toNum(a.askprice),
})) volume: toNum(a.askvolume),
}))
.filter((a) => a.price > 0)
const bids = bidsRaw.map((b, i) => ({ const bids = bidsRaw
level: i + 1, .map((b, i) => ({
price: toNum(b.bidprice), level: i + 1,
volume: toNum(b.bidvolume), price: toNum(b.bidprice),
})) volume: toNum(b.bidvolume),
}))
.filter((b) => b.price > 0)
// 买卖力度条按五档挂单量汇总,而非外盘/内盘 // 买卖力度条按五档挂单量汇总,而非外盘/内盘
const bidVol = bids.reduce((sum, b) => sum + b.volume, 0) const bidVol = bids.reduce((sum, b) => sum + b.volume, 0)