Serve side-specific execution quotes over the public market HTTP API

This commit is contained in:
2026-12-03 10:07:23 +08:00
parent b47058d75e
commit 1b2376ccb4
7 changed files with 220 additions and 37 deletions
+12
View File
@@ -60,3 +60,15 @@ POST http://127.0.0.1:9002/midpoints
Content-Type: application/json
[{"token_id":"eb:YES:mid-example"},{"token_id":"eb:NO:mid-example"}]
### Read the best ask to buy YES in the midpoint.jsonl fixture ("0.09")
GET http://127.0.0.1:9002/price?token_id=eb%3AYES%3Amid-example&side=BUY
### Read BUY and SELL for the same outcome (0.09 and 0.08)
GET http://127.0.0.1:9002/prices?token_ids=eb%3AYES%3Amid-example%2Ceb%3AYES%3Amid-example&sides=BUY%2CSELL
### Include both outcomes with a JSON body
POST http://127.0.0.1:9002/prices
Content-Type: application/json
[{"token_id":"eb:YES:mid-example","side":"BUY"},{"token_id":"eb:NO:mid-example","side":"BUY"}]
+6
View File
@@ -363,3 +363,9 @@ Polymarket 的单资产最近成交接口规定,无成交时返回价格字符
加载[中点订单样例](examples/midpoint.jsonl)后,YES 的买一为 0.08,NO 买一 0.91 对应 YES 卖一 0.09。单查 YES 得到 {"mid":"0.085"},批查两边得到 0.085 和 0.915。结果保留半个报价步长。即使价差很宽,中点查询也始终取两边的算术平均。缺边处理与上文价差查询相同,仍待生产样本验证。[官方行情指南](https://docs.polymarket.com/market-data/prices-order-books#fetch-a-midpoint)
单查字段有两种公开描述。行情指南的原始 HTTP 样例和官方 Rust SDK 的模拟服务均使用 `mid`,OpenAPI 定义的是 `mid_price`。本地返回前者,批量 GET 和 POST 均返回以资产 ID 为键的十进制字符串。这里引用的是文档与 SDK 测试,尚未取得同一时刻的生产回执。[Rust SDK 测试](https://github.com/Polymarket/rs-clob-client-v2/blob/main/tests/clob.rs#L89-L135) · [单资产 OpenAPI](https://docs.polymarket.com/api-reference/data/get-midpoint-price) · [批量 GET](https://docs.polymarket.com/api-reference/market-data/get-midpoint-prices-query-parameters)
### HTTP 买卖报价的方向
用[同一份本地盘口](examples/midpoint.jsonl)重放:YES 买一 0.08、卖一 0.09。单查 BUY 返回 {"price":"0.09"},单查 SELL 返回 {"price":"0.08"}。批量查询同一结果的两个方向会保留两个键,价格为 JSON 数字。GET 的 token_ids、sides 两列按位置配对,POST 接收含 token_id 和 side 的对象数组。[HTTP 请求](examples/clob-http.http) · [批量 GET 规范](https://docs.polymarket.com/api-reference/market-data/get-market-prices-query-parameters) · [批量 POST 规范](https://docs.polymarket.com/api-reference/market-data/get-market-prices-request-body)
官方行情指南从交易者角度描述 BUY 取卖一,OpenAPI 的单查文字则把 BUY 对应到买一。本地沿用行情指南与既有交易命令的口径。官方 Rust SDK 的模拟回执可以确认单查字符串、批查数字,无法据此判定生产方向。已上市资产缺少所需一侧时,本地 HTTP 单查返回 422,批查省略该方向。请求中出现未上市资产时整批返回 404。上述边界和交易方向仍待稳定盘口实测。[行情指南](https://docs.polymarket.com/market-data/prices-order-books#best-market-price) · [单查规范](https://docs.polymarket.com/api-reference/market-data/get-market-price) · [官方 SDK 用例](https://github.com/Polymarket/rs-clob-client-v2/blob/main/tests/clob.rs#L139-L216)