验证 Polymarket 与 Kalshi 的只读目录及盘口 #4
@@ -63,7 +63,7 @@ sequenceDiagram
|
||||
|
||||
## 核对生产买卖报价
|
||||
|
||||
`venue-probe --compare-prices` 在常规输出上增加每个结果的 price_check。它把报价响应、HTTP 状态、前后盘口和哈希放在同一条记录中。前后盘口稳定时,BUY 与买一、SELL 与卖一一致就标为 resting_side。缺失买或卖的一侧分别按生产样本的 0 或 1 对照;双侧均空时结论待定。
|
||||
`venue-probe --compare-prices` 在常规输出上增加每个结果的 price_check。它把报价响应、HTTP 状态、前后盘口和哈希放在同一条记录中。前后盘口稳定时,BUY 与买一、SELL 与卖一一致就标为 resting_side。缺失买或卖的一侧分别按生产样本的 0 或 1 对照;前后两侧均明确为空且报价为 0 和 1 时标为 empty_book_defaults,缺失深度字段的样本保持待定。
|
||||
|
||||
[市场 559651 的目录字段摘录](fixtures/gamma-559651.json)来自公开 Gamma JSON 的网页读取,记录自身的更新时间为 2026-12-02 21:08:08 UTC。该 v1 市场同时返回两套 ID,盘口请求使用 clobTokenIds。目录买一为 0.012、卖一为 0.013、最小价格步长为 0.001。测试以这些真实目录值构造模拟的 CLOB 响应;本次工作站直连 Gamma 超时,网页读取该资产的 CLOB book 和 price 也未取得响应。目录观测与模拟样例均不能确认线上 BUY 和 SELL 返回了什么。[Gamma 公开市场目录](https://gamma-api.polymarket.com/markets?limit=1)
|
||||
|
||||
@@ -121,3 +121,5 @@ sequenceDiagram
|
||||
| [Kalshi 空盘口](fixtures/live-kalshi-book.json) | KXPLATINUMH-26DEC0303-T1377.49 返回 HTTP 200,yes_dollars 和 no_dollars 均为空数组。此时没有可从该快照读出的买一或卖一。 |
|
||||
|
||||
2026-12-03 06:55 UTC 采集的[同侧报价快照](fixtures/live-side-prices.json)按请求保存前后盘口、报价、时间、方法及响应。双侧盘口最优价为 0.039 和 0.04。缺买盘的结果返回 BUY 字符串 0,缺卖盘的结果返回 SELL 字符串 1。批量 POST 返回相同字符串。文档列出的逗号分隔 GET 在这次生产取样返回 400。三个资产的前后盘口哈希各自一致。[官方单价接口](https://docs.polymarket.com/api-reference/market-data/get-market-price)
|
||||
|
||||
[电竞盘双空样本](fixtures/live-empty-prices.json)保留前后盘口和两次价格请求。两个深度数组均为空,公开 BUY 返回 "0",SELL 返回 "1"。探针把该结果计为已验证的空盘报价,实际可成交数量仍为零。
|
||||
|
||||
@@ -0,0 +1,61 @@
|
||||
{
|
||||
"market": "cs2-bb3-lgc-2026-12-03-game1-round-total-27pt5",
|
||||
"before": {
|
||||
"method": "GET",
|
||||
"url": "https://clob.polymarket.com/book?token_id=64069535502365350520464017439278800338614209934309608490621606944970108681676",
|
||||
"payload": null,
|
||||
"status": 200,
|
||||
"date": "Thu, 03 Dec 2026 07:55:53 GMT",
|
||||
"body": {
|
||||
"market": "0xe5febd2f236a15ef7c1cc70a481e081bb64223d3e67aa3870677cccd72530853",
|
||||
"asset_id": "64069535502365350520464017439278800338614209934309608490621606944970108681676",
|
||||
"timestamp": "1796284481649",
|
||||
"hash": "575e315a02461b9280427591ba1fe7e48b3b70ce",
|
||||
"bids": [],
|
||||
"asks": [],
|
||||
"min_order_size": "5",
|
||||
"tick_size": "0.01",
|
||||
"neg_risk": false,
|
||||
"last_trade_price": ""
|
||||
}
|
||||
},
|
||||
"buy": {
|
||||
"method": "GET",
|
||||
"url": "https://clob.polymarket.com/price?token_id=64069535502365350520464017439278800338614209934309608490621606944970108681676&side=BUY",
|
||||
"payload": null,
|
||||
"status": 200,
|
||||
"date": "Thu, 03 Dec 2026 07:55:55 GMT",
|
||||
"body": {
|
||||
"price": "0"
|
||||
}
|
||||
},
|
||||
"sell": {
|
||||
"method": "GET",
|
||||
"url": "https://clob.polymarket.com/price?token_id=64069535502365350520464017439278800338614209934309608490621606944970108681676&side=SELL",
|
||||
"payload": null,
|
||||
"status": 200,
|
||||
"date": "Thu, 03 Dec 2026 07:55:55 GMT",
|
||||
"body": {
|
||||
"price": "1"
|
||||
}
|
||||
},
|
||||
"after": {
|
||||
"method": "GET",
|
||||
"url": "https://clob.polymarket.com/book?token_id=64069535502365350520464017439278800338614209934309608490621606944970108681676",
|
||||
"payload": null,
|
||||
"status": 200,
|
||||
"date": "Thu, 03 Dec 2026 07:55:56 GMT",
|
||||
"body": {
|
||||
"market": "0xe5febd2f236a15ef7c1cc70a481e081bb64223d3e67aa3870677cccd72530853",
|
||||
"asset_id": "64069535502365350520464017439278800338614209934309608490621606944970108681676",
|
||||
"timestamp": "1796284481649",
|
||||
"hash": "575e315a02461b9280427591ba1fe7e48b3b70ce",
|
||||
"bids": [],
|
||||
"asks": [],
|
||||
"min_order_size": "5",
|
||||
"tick_size": "0.01",
|
||||
"neg_risk": false,
|
||||
"last_trade_price": ""
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -58,7 +58,20 @@ fn classify(before: &Value, after: &Value, buy: &Value, sell: &Value) -> &'stati
|
||||
return "inconclusive";
|
||||
};
|
||||
match (bid, ask) {
|
||||
(None, None) => "inconclusive",
|
||||
(None, None) => {
|
||||
let empty = [before, after].iter().all(|book| {
|
||||
["best_bid", "best_ask"]
|
||||
.iter()
|
||||
.all(|key| book.get(*key) == Some(&Value::Null))
|
||||
});
|
||||
if !empty {
|
||||
"inconclusive"
|
||||
} else if (buy, sell) == (0, 1_000_000) {
|
||||
"empty_book_defaults"
|
||||
} else {
|
||||
"different_prices"
|
||||
}
|
||||
}
|
||||
(Some(b), Some(a)) if b >= a => "inconclusive",
|
||||
_ if (buy, sell) == (bid.unwrap_or(0), ask.unwrap_or(1_000_000)) => "resting_side",
|
||||
(Some(b), Some(a)) if (buy, sell) == (a, b) => "opposing_side",
|
||||
@@ -70,6 +83,31 @@ fn classify(before: &Value, after: &Value, buy: &Value, sell: &Value) -> &'stati
|
||||
mod tests {
|
||||
use super::*;
|
||||
|
||||
#[test]
|
||||
fn observed_empty_book_defaults_require_two_explicitly_empty_sides() {
|
||||
let observation: Value =
|
||||
serde_json::from_str(include_str!("../fixtures/live-empty-prices.json")).unwrap();
|
||||
let raw = &observation["before"]["body"];
|
||||
let market = json!({"conditionId":raw["market"]});
|
||||
let token = raw["asset_id"].as_str().unwrap();
|
||||
let before = books::poly_book(&market, token, raw).unwrap();
|
||||
let after = books::poly_book(&market, token, &observation["after"]["body"]).unwrap();
|
||||
let price = |key: &str| json!({"price_micros":books::price(&observation[key]["body"]["price"]).unwrap()});
|
||||
assert_eq!(
|
||||
classify(&before, &after, &price("buy"), &price("sell")),
|
||||
"empty_book_defaults"
|
||||
);
|
||||
assert_eq!(
|
||||
classify(&before, &after, &price("sell"), &price("buy")),
|
||||
"different_prices"
|
||||
);
|
||||
let incomplete = json!({"hash":before["hash"]});
|
||||
assert_eq!(
|
||||
classify(&incomplete, &incomplete, &price("buy"), &price("sell")),
|
||||
"inconclusive"
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn public_side_prices_replay_against_bracketing_books() {
|
||||
let raw: Value =
|
||||
|
||||
@@ -63,9 +63,12 @@ fn polymarket_report(
|
||||
}
|
||||
let complete = outcomes.iter().all(|s| s.get("book_error").is_none());
|
||||
let passed = compare
|
||||
&& outcomes
|
||||
.iter()
|
||||
.all(|s| s["price_check"]["status"] == "resting_side");
|
||||
&& outcomes.iter().all(|s| {
|
||||
matches!(
|
||||
s["price_check"]["status"].as_str(),
|
||||
Some("resting_side" | "empty_book_defaults")
|
||||
)
|
||||
});
|
||||
result["orderbooks_complete"] = json!(complete);
|
||||
if compare {
|
||||
result["price_check_passed"] = json!(passed);
|
||||
|
||||
Reference in New Issue
Block a user