xtraderClient/docs/api/priceHistory.md
2026-03-15 21:08:51 +08:00

2.2 KiB
Raw Blame History

priceHistory.ts

路径src/api/priceHistory.ts

功能用途

价格历史公开接口,用于 TradeDetail 页面的 Yes/No 折线图。对接 GET /pmPriceHistory/getPmPriceHistoryPublic(无需鉴权)。

核心能力

  • getPmPriceHistoryPublic:按市场 ID 分页获取价格历史
  • priceHistoryToChartData:将接口返回的 list 转为 ECharts 使用的 [timestamp_ms, value_0_100][]

GET /pmPriceHistory/getPmPriceHistoryPublic

请求参数Query

参数 类型 必填 说明
market string 传 YES 对应的 clobTokenId即当前市场 clobTokenIds[0]
page number 页码,默认 1
pageSize number 每页条数,默认 500
interval string 数据间隔
time number 时间筛选
createdAtRange string[] 创建时间范围
fidelity number 数据精度
keyword string 关键字
order string 排序
sort string 排序字段
price number 价格筛选

响应

{ code, data, msg }dataPageResult<PmPriceHistoryItem>listpagepageSizetotal)。

PmPriceHistoryItemlist 单项)

字段 类型 说明
ID number 主键
market string 市场标识
price number 价格01 小数或 0100由 priceHistoryToChartData 统一为 0100
time number Unix 秒时间戳
interval string 数据间隔
fidelity number 数据精度
createdAt string 创建时间
updatedAt string 更新时间

使用方式

import {
  getPmPriceHistoryPublic,
  priceHistoryToChartData,
  type PmPriceHistoryItem,
} from '@/api/priceHistory'

const res = await getPmPriceHistoryPublic({
  market: marketId,
  page: 1,
  pageSize: 500,
})
const chartData = priceHistoryToChartData(res.data?.list ?? [])

扩展方式

  • 按时间范围1H/6H/1D 等)传 intervalcreatedAtRange 需与后端约定取值
  • 若后端返回的 price 固定为 0100priceHistoryToChartData 已兼容≤1 时乘 100