跳到主要内容

账户历史

本页是成交 / 委托 / 资金流水 / 持仓历史 相关接口:JSON-RPC 读方法(getUserFills 等)与历史 REST(/api/v1/fills/api/v1/orders/api/v1/fund-flows 等)。

getUserFills

用户成交历史(含 gross 扣款 fee;不含 Layer ⑥.2 返佣拆分,返佣见 [getBlockEvents../history/blocks.md#getblockevents 的 Core::RebatePaid)。读 fill archive(权威源)并与 index 内存 merge;client_order_id 由 open 簿 / closed archive 补全。启动时若 archive 落后 journal,由 backfill_fill_history_store 从 journal 回补。

参数类型必填说明
addressAddress20账户地址
symbolString按市场过滤
market_idu32精确市场过滤(重名/跨代际历史);携带时优先于 symbol,可查已下市市场历史
start_time_msu64起始时间(毫秒)
end_time_msu64结束时间(毫秒)
offsetusize默认 0
limitusize默认 100,最大 1000

响应 data · UserFillResponse[]: 同 TradeResponse + 以下字段:

字段类型说明
order_idu64用户侧订单 ID(成交↔订单对账键)
client_order_idString?客户端订单 ID(open 簿 / closed archive 补全)
feeString该用户在本笔成交中支付的 gross fee(SCALE_6,≥ 0;Layer ⑥.1 扣款,返佣池拆分不在此字段)
is_takerbool是否吃单方
aggressor_sideSide吃单方向

响应示例:

{
"jsonrpc": "2.0", "id": 1,
"result": {
"height": 12345,
"data": [{
"block_height": 12345,
"event_seq": 3,
"timestamp_ms": 1717200001000,
"market_id": 1,
"symbol": "BTC-USDT",
"order_id": 1001,
"client_order_id": "my-cloid-1",
"price": "97234.50",
"qty": "0.50000",
"notional": "48617.250000",
"fee": "24.308625",
"is_taker": true,
"aggressor_side": "Bid"
}],
"page": { "offset": 0, "limit": 100, "total": null }
}
}

getOrderFills

单笔订单成交明细(做市对账点查)。读 fill archive 并与 index 内存 merge;响应字段同 [getUserFills#getuserfills 的 UserFillResponse[]。全量历史永久存储,不截断。

参数类型必填说明
order_idu64二选一订单 ID
client_order_idString二选一客户端订单 ID(需同时给 address + symbol,同 [getOrderStatus../trading/account.md#getorderstatus)
addressAddress20cloid 时必填账户地址
symbolStringcloid 时必填市场 symbol
offsetusize默认 0
limitusize默认 100,最大 1000

响应示例:

{
"jsonrpc": "2.0", "id": 1,
"result": {
"height": 12345,
"data": [{
"block_height": 12345,
"event_seq": 3,
"timestamp_ms": 1717200001000,
"market_id": 1,
"symbol": "BTC-USDT",
"order_id": 1001,
"client_order_id": "my-cloid-1",
"price": "97234.50",
"qty": "0.50000",
"notional": "48617.250000",
"fee": "24.308625",
"is_taker": false,
"aggressor_side": "Bid"
}],
"page": { "offset": 0, "limit": 100, "total": null }
}
}

账户历史(REST)

以下接口均为分页列表 { data, page },按区块高度新→旧排序。

事件类记录公共字段(fills / fund-flows / bridge-flows / positions / account/events):

FieldTypeDescription
heightnumber区块高度
seqnumber区块内 event 序号
timestamp_msnumber区块时间戳(ms)
envelope_idxnumber | null源 event 的 envelope 索引
tx_hashstring | null源 event 的 L2 交易 hash(见 [事件溯源../system/index.md#事件溯源event-provenance)

GET /api/v1/fills

账户成交历史。每笔 fill 产生 taker / maker 两行。

Query

ParamTypeRequiredDefaultMaxDescription
accountstringyes账户地址
market_idnumberno市场过滤
from_blocknumberno最小区块高度(含)
to_blocknumberno最大区块高度(含)
offsetnumberno0分页偏移
limitnumberno50200页大小

Response 200

{
"data": [
{
"height": 12345,
"seq": 3,
"is_taker": true,
"timestamp_ms": 1717000000000,
"market_id": 1,
"order_id": 42,
"account": "0xabcd…",
"counterparty": "0x1234…",
"price": "50000.00",
"qty": "1.5",
"notional": "75000.000000",
"fee": "3.750000",
"position_action": "close_long",
"realized_pnl": "100.000000",
"realized_pnl_pct": "1.64",
"symbol": "BTC-USDT",
"envelope_idx": 2,
"tx_hash": "0x…"
}
],
"page": { "offset": 0, "limit": 50, "total": 150 }
}
FieldTypeDescription
is_takerboolean是否为 taker 侧
notionalstringprice × qty(SCALE_6)
feestring该参与者手续费(SCALE_6)
position_actionstring | null开/平仓效果:open_long / open_short / close_long / close_short;无法判定时省略
realized_pnlstring | null本笔成交 attributed 已实现盈亏(SCALE_6);derive 自同 envelope 内匹配的 PositionUpdated 或强平 Liquidated
realized_pnl_pctstring | null盈利率(百分比,两位小数);开仓/加仓为 "0.00"
envelope_idxnumber | null源 event 的 envelope 索引
tx_hashstring | null源 event 的 L2 交易 hash

开/平仓判定与 PnL 关联规则见 FillRecord


GET /api/v1/orders

账户历史委托(按 order_id 聚合,一行一单,仅已关闭订单)。

与当前委托的分工

场景数据来源
当前委托(挂单中,实时)Chain getAccountOrders 或 WS orderUpdates;亦可本服务 GET /api/v1/chain/open-orders(链 proxy)
历史委托(已成交/已撤/已过期)本接口

默认不传 status 时,服务端附加 status != open,不返回挂单。索引层 derive worker 仍会物化 open 行(供内部聚合),但对外历史列表不包含。

derive worker 从链事件物化:OrderAccepted → 建单;OrderResting → 更新挂簿快照(改价/改量,price / qty / filled_qty);Filled → 累计成交量/均价;OrderDone / 特殊撤单 event → 终态。

Query

ParamTypeRequiredDefaultMaxDescription
ownerstringyes订单 owner 地址
market_idnumberno市场过滤
statusstringno排除 open终态过滤:filled | partial_cancelled | cancelled | expired;显式 open 可单独查挂单(读侧索引,非历史主路径)
offsetnumberno0分页偏移
limitnumberno50200页大小

Response 200

{
"data": [
{
"order_id": 100,
"owner": "0xabcd…",
"market_id": 1,
"symbol": "BTC-USDT",
"side": "Bid",
"price": "50000.00",
"qty": "1.5",
"filled_qty": "1.2",
"avg_fill_price": "49980.50",
"status": "partial_cancelled",
"close_reason": "Cancelled",
"placed_height": 12345,
"placed_at_ms": 1717000000000,
"closed_height": 12350,
"closed_at_ms": 1717000005000,
"placed_tx_hash": "0x…",
"closed_tx_hash": "0x…"
}
],
"page": { "offset": 0, "limit": 50, "total": 42 }
}
FieldTypeDescription
statusstring聚合终态。默认列表仅含 filled / partial_cancelled / cancelled / expiredopen 仅当显式 status=open 时出现
filled_qtystring已成交量(size 精度)
avg_fill_pricestring | null成交均价(price 精度)
close_reasonstring | null链上 DoneReason 或特殊撤单原因(如 CancelledByPositionFlat
qtystring原始委托数量
placed_tx_hashstring | null下单(OrderAccepted)所在 L2 交易 hash
closed_tx_hashstring | null终态 event 所在 L2 交易 hash(撤单/过期/完全成交)

排序closed_at_ms 新→旧;相同时 order_id 大→小。列表时间轴与 closed_at_ms 一致(非 placed_at_ms)。

分页total 为匹配过滤后的已关闭订单总数(默认不含 open)。


GET /api/v1/fund-flows

账户资金流水(Core::BalanceChanged 余额变更)。

Query

ParamTypeRequiredDefaultMaxDescription
accountstringyes账户地址
reasonstringno变更原因过滤,如 TakerFeeBridgeDepositRealizedPnlRebateToInviterRebateToInvitee
market_idnumberno市场过滤(部分原因带 market_id
from_blocknumberno最小区块高度(含)
to_blocknumberno最大区块高度(含)
offsetnumberno0分页偏移
limitnumberno50200页大小

Response 200

{
"data": [
{
"height": 12345,
"seq": 8,
"timestamp_ms": 1717000000000,
"account": "0xabcd…",
"delta": "-3.750000",
"new_balance": "996.250000",
"reason": "TakerFee",
"market_id": 1,
"envelope_idx": 2,
"tx_hash": "0x…"
}
],
"page": { "offset": 0, "limit": 50, "total": 200 }
}
FieldTypeDescription
deltastring余额变动量(可为负)
new_balancestring变动后余额
reasonstring变更原因,见链层 BalanceReason
envelope_idxnumber | null源 event 的 envelope 索引
tx_hashstring | null源 event 的 L2 交易 hash

常见 reason 值:TakerFeeMakerFeeRealizedPnlBridgeDepositBridgeWithdrawDebitBridgeWithdrawRefundLiquidationImReleaseImAutoAllocateImManualAllocateMakerFeeRefundFeeRecipientCreditOracleTradeWithdrawalBankruptcyFloorRebateToInviterRebateToInvitee

返佣入账(RebateToInviter / RebateToInvitee)与 [GET /api/v1/rebate/events../history/referral.md#get-apiv1rebateevents 的 Core::RebatePaid 成对出现;汇总明细见返佣接口,流水侧按 reason 过滤即可。


GET /api/v1/bridge-flows

充提生命周期事件(Bridge::*)。

Query

ParamTypeRequiredDefaultMaxDescription
accountstringyes账户地址
event_typestringno事件类型:DepositRecordedDepositCreditedWithdrawRequestedWithdrawSettledWithdrawRefunded
from_blocknumberno最小区块高度(含)
to_blocknumberno最大区块高度(含)
offsetnumberno0分页偏移
limitnumberno50200页大小

Response 200

{
"data": [
{
"height": 12345,
"seq": 2,
"timestamp_ms": 1717000000000,
"event_type": "DepositCredited",
"account": "0xabcd…",
"amount": "1000.000000",
"new_balance": "1000.000000",
"deposit_seq": 5,
"request_id": null,
"chain_id": null,
"reason_code": null,
"envelope_idx": 0,
"tx_hash": "0x…",
"external_tx_hash": null
}
],
"page": { "offset": 0, "limit": 50, "total": 12 }
}
FieldTypeDescription
envelope_idxnumber | null源 event 的 envelope 索引
tx_hashstring | nullL2 envelope 交易 hash
external_tx_hashstring | nullL1 链上交易 hash(如 DepositRecorded / WithdrawSettled body 内)
event_typestringDepositRecorded | DepositCredited | WithdrawRequested | WithdrawSettled | WithdrawRefunded
amountstring金额(SCALE_6)
new_balancestring | null变更后余额(部分事件有)
deposit_seqnumber | null充值序号
request_idnumber | null提现 request ID
chain_idnumber | null外链 chain ID
reason_codenumber | null退款原因码(WithdrawRefunded

GET /api/v1/positions

账户持仓变动历史(Exec::Position*)。

Query

ParamTypeRequiredDefaultMaxDescription
ownerstringyes账户地址
market_idnumberno市场过滤
event_typestringnoUpdatedFlattenedForceClosedAtMark
from_blocknumberno最小区块高度(含)
to_blocknumberno最大区块高度(含)
offsetnumberno0分页偏移
limitnumberno50200页大小

Response 200

{
"data": [
{
"height": 12345,
"seq": 4,
"timestamp_ms": 1717000000000,
"owner": "0xabcd…",
"market_id": 1,
"event_type": "Updated",
"old_size": "0",
"new_size": "1.5",
"new_entry_vwap": "50000.00",
"realized_pnl": "0",
"mark_price": null,
"symbol": "BTC-USDT",
"envelope_idx": 2,
"tx_hash": "0x…"
}
],
"page": { "offset": 0, "limit": 50, "total": 30 }
}
FieldTypeDescription
envelope_idxnumber | null源 event 的 envelope 索引
tx_hashstring | null源 event 的 L2 交易 hash

GET /api/v1/account/events

按账户过滤的链上事件(通用分类查询,数据来自 event 表)。

Query

ParamTypeRequiredDefaultMaxDescription
accountstringyes账户地址
kindstringno事件大类:ExecCoreBridgeTriggerLiquidationOps
sub_kindstringno子类型,如 FilledBalanceChanged
market_idnumberno市场过滤
from_blocknumberno最小区块高度(含)
to_blocknumberno最大区块高度(含)
offsetnumberno0分页偏移
limitnumberno50200页大小

Response 200

{
"data": [
{
"height": 12345,
"seq": 3,
"envelope_idx": 0,
"kind": "Exec",
"sub_kind": "Filled",
"market_id": 1,
"symbol": "BTC-USDT",
"tx_hash": "0x…",
"account": "0xabcd…",
"timestamp_ms": 1717000000000,
"body": { "price": "50000.00", "qty": "1.5" }
}
],
"page": { "offset": 0, "limit": 50, "total": 500 }
}
FieldTypeDescription
envelope_idxnumber事件所在 envelope 索引
tx_hashstring | null产生该 event 的 L2 交易 hash
timestamp_msnumber区块时间戳(ms)
kind / sub_kindstring事件大类 / 子类型
bodyobject原始事件 JSON