feat: 实现订单推送服务和 WebSocket 重连机制

- 实现订单推送服务,支持多账户订单实时推送
- 添加 WebSocket 自动重连机制,支持指数退避策略
- 修复订单详情接口 L2 认证问题,通过 PolymarketClobService 获取
- 配置 Gson lenient 模式,支持解析格式不严格的 JSON
- 添加响应日志拦截器,便于调试 API 响应问题
- 使用 Gamma API 获取市场信息,支持通过 condition_ids 查询
- 修复字段映射问题,使用 @SerializedName 替代 @JsonProperty
- 订单推送消息包含订单详情和市场信息
This commit is contained in:
WrBug
2025-11-27 14:51:46 +08:00
parent 47357995af
commit 5b458b9b0c
21 changed files with 1765 additions and 66 deletions
+48
View File
@@ -210,3 +210,51 @@ export function getPositionKey(position: AccountPosition): string {
return `${position.accountId}-${position.marketId}-${position.side}`
}
/**
* Polymarket 订单消息(来自 WebSocket User Channel
*/
export interface OrderMessage {
asset_id: string
associate_trades?: string[]
event_type: string // "order"
id: string // order id
market: string // condition ID of market
order_owner: string // owner of order
original_size: string // original order size
outcome: string // outcome
owner: string // owner of orders
price: string // price of order
side: string // BUY/SELL
size_matched: string // size of order that has been matched
timestamp: string // time of event
type: string // PLACEMENT/UPDATE/CANCELLATION
}
/**
* 订单详情(通过 API 获取)
*/
export interface OrderDetail {
id: string // 订单 ID
market: string // 市场 ID (condition ID)
side: string // BUY/SELL
price: string // 价格
size: string // 订单大小
filled: string // 已成交数量
status: string // 订单状态
createdAt: string // 创建时间(ISO 8601 格式)
marketName?: string // 市场名称
marketSlug?: string // 市场 slug
marketIcon?: string // 市场图标
}
/**
* 订单推送消息
*/
export interface OrderPushMessage {
accountId: number
accountName: string
order: OrderMessage // 订单信息(来自 WebSocket
orderDetail?: OrderDetail // 订单详情(通过 API 获取)
timestamp?: number // 推送时间戳
}