实时挂单比例显示

This commit is contained in:
dongzp 2026-07-21 15:34:58 +08:00
parent 5708ab2b14
commit bc1cd1297a
2 changed files with 10 additions and 5 deletions

View File

@ -67,9 +67,6 @@ export function mapBaiduQuotationToQuote(result: BaiduQuotationResult): QuoteDat
const outside = toNum(op?.outside) const outside = toNum(op?.outside)
const inside = toNum(op?.inside) const inside = toNum(op?.inside)
const total = outside + inside
const buyRatio = total > 0 ? Math.round((outside / total) * 100) : 50
const sellRatio = 100 - buyRatio
const asksRaw = result.askinfos ?? [] const asksRaw = result.askinfos ?? []
const bidsRaw = result.buyinfos ?? [] const bidsRaw = result.buyinfos ?? []
@ -87,6 +84,13 @@ export function mapBaiduQuotationToQuote(result: BaiduQuotationResult): QuoteDat
volume: toNum(b.bidvolume), volume: toNum(b.bidvolume),
})) }))
// 买卖力度条按五档挂单量汇总,而非外盘/内盘
const bidVol = bids.reduce((sum, b) => sum + b.volume, 0)
const askVol = asks.reduce((sum, a) => sum + a.volume, 0)
const bookTotal = bidVol + askVol
const buyRatio = bookTotal > 0 ? Math.round((bidVol / bookTotal) * 100) : 50
const sellRatio = 100 - buyRatio
const amountYi = parseAmountYi( const amountYi = parseAmountYi(
result.pankouinfos?.list?.find((i) => i.ename === 'amount')?.value, result.pankouinfos?.list?.find((i) => i.ename === 'amount')?.value,
op?.amount, op?.amount,

View File

@ -71,8 +71,9 @@ export const quoteMock: QuoteData = {
outerVol: 412331, outerVol: 412331,
innerVol: 413312, innerVol: 413312,
updatedAt: '11:30:00', updatedAt: '11:30:00',
buyRatio: 48, // 买档量 1503 / 卖档量 1365 → 约 52% / 48%
sellRatio: 52, buyRatio: 52,
sellRatio: 48,
intraday: buildIntraday(), intraday: buildIntraday(),
candles: { candles: {
day: buildCandles(60), day: buildCandles(60),