Compare commits
1 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| e6a914b381 |
@@ -221,7 +221,7 @@ sequenceDiagram
|
|||||||
participant E as prices_history/legacy.rs
|
participant E as prices_history/legacy.rs
|
||||||
C->>H: GET /prices-history,market 与 interval 或 startTs、endTs
|
C->>H: GET /prices-history,market 与 interval 或 startTs、endTs
|
||||||
H->>E: clob_price_history,fidelity 以分钟计
|
H->>E: clob_price_history,fidelity 以分钟计
|
||||||
E-->>H: 返回窗口内盘口中点样本,末尾追加最近可用点
|
E-->>H: 返回窗口内盘口中点样本,未封盘时追加最近可用点
|
||||||
H-->>C: history 数组,每点包含 t 和 p
|
H-->>C: history 数组,每点包含 t 和 p
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|||||||
@@ -1133,7 +1133,7 @@ flowchart LR
|
|||||||
L --> A["assets.rs"]
|
L --> A["assets.rs"]
|
||||||
L --> Q["prices_history/legacy.sql"]
|
L --> Q["prices_history/legacy.sql"]
|
||||||
Q --> T["quote_schema.sql 中的 quote_events"]
|
Q --> T["quote_schema.sql 中的 quote_events"]
|
||||||
Q --> O["prices_history/chart_schema.sql 中的采样起点和时间索引"]
|
Q --> O["prices_history/chart_schema.sql 中的采样起点、封盘时间和时间索引"]
|
||||||
API["lib.rs"] --> O
|
API["lib.rs"] --> O
|
||||||
Q --> S["schema.sql 中的 price_settlements"]
|
Q --> S["schema.sql 中的 price_settlements"]
|
||||||
```
|
```
|
||||||
@@ -1145,7 +1145,7 @@ sequenceDiagram
|
|||||||
participant D as SQLite
|
participant D as SQLite
|
||||||
C->>E: clob_price_history
|
C->>E: clob_price_history
|
||||||
E->>D: 清理到期委托并取得读快照与数据库时钟
|
E->>D: 清理到期委托并取得读快照与数据库时钟
|
||||||
E->>D: 按 UTC 分钟网格重放各采样点当时的盘口,再读取最近可用点
|
E->>D: 按 UTC 分钟网格重放盘口,封盘后只取窗口内的封盘前样本
|
||||||
D-->>E: 观测时间和定点价格
|
D-->>E: 观测时间和定点价格
|
||||||
E-->>C: t 为 Unix 秒,p 为十进制数
|
E-->>C: t 为 Unix 秒,p 为十进制数
|
||||||
```
|
```
|
||||||
|
|||||||
@@ -121,7 +121,7 @@ impl Exchange {
|
|||||||
db.execute_batch(include_str!("quote_schema.sql"))?;
|
db.execute_batch(include_str!("quote_schema.sql"))?;
|
||||||
}
|
}
|
||||||
let history_ready: bool = db.query_row(
|
let history_ready: bool = db.query_row(
|
||||||
"SELECT EXISTS(SELECT 1 FROM sqlite_schema WHERE type='trigger' AND name='chart_market_listed')",
|
"SELECT EXISTS(SELECT 1 FROM sqlite_schema WHERE type='trigger' AND name='chart_market_closed')",
|
||||||
[], |r| r.get(0),
|
[], |r| r.get(0),
|
||||||
)?;
|
)?;
|
||||||
if !history_ready {
|
if !history_ready {
|
||||||
|
|||||||
@@ -12,4 +12,12 @@ END;
|
|||||||
INSERT OR IGNORE INTO chart_origins
|
INSERT OR IGNORE INTO chart_origins
|
||||||
SELECT id,COALESCE((SELECT MIN(at_ms) FROM quote_events WHERE market=m.id),
|
SELECT id,COALESCE((SELECT MIN(at_ms) FROM quote_events WHERE market=m.id),
|
||||||
CAST(unixepoch('subsec')*1000 AS INTEGER)) FROM markets m;
|
CAST(unixepoch('subsec')*1000 AS INTEGER)) FROM markets m;
|
||||||
|
CREATE TABLE IF NOT EXISTS chart_closures (
|
||||||
|
market TEXT PRIMARY KEY REFERENCES markets,
|
||||||
|
at_ms INTEGER NOT NULL
|
||||||
|
);
|
||||||
|
CREATE TRIGGER IF NOT EXISTS chart_market_closed AFTER UPDATE OF phase ON markets
|
||||||
|
WHEN NEW.phase='closed' AND OLD.phase<>'closed' BEGIN
|
||||||
|
INSERT INTO chart_closures VALUES(NEW.id,CAST(unixepoch('subsec')*1000 AS INTEGER));
|
||||||
|
END;
|
||||||
COMMIT;
|
COMMIT;
|
||||||
|
|||||||
@@ -2,14 +2,16 @@
|
|||||||
-- The local sampler uses a UTC minute grid. The venue's collector has clock jitter.
|
-- The local sampler uses a UTC minute grid. The venue's collector has clock jitter.
|
||||||
WITH RECURSIVE horizon AS (
|
WITH RECURSIVE horizon AS (
|
||||||
SELECT (SELECT at_ms FROM chart_origins WHERE market=?1) AS first_ms,
|
SELECT (SELECT at_ms FROM chart_origins WHERE market=?1) AS first_ms,
|
||||||
(SELECT at_ms FROM price_settlements WHERE market=?1) AS resolved_ms,
|
(SELECT at_ms FROM chart_closures WHERE market=?1) AS closed_ms,
|
||||||
(SELECT winner FROM price_settlements WHERE market=?1) AS winner,
|
(SELECT phase IN ('closed','resolved') FROM markets WHERE id=?1) AS closed
|
||||||
(SELECT phase FROM markets WHERE id=?1) AS phase
|
|
||||||
), bounds AS (
|
), bounds AS (
|
||||||
SELECT first_ms, resolved_ms, winner,
|
SELECT first_ms, closed,
|
||||||
CASE WHEN phase='resolved' THEN COALESCE(resolved_ms,
|
CASE WHEN NOT closed THEN ?6/60000*60000
|
||||||
(SELECT MAX(at_ms) FROM quote_events WHERE market=?1))
|
WHEN closed_ms IS NOT NULL THEN closed_ms-1
|
||||||
ELSE ?6/60000*60000 END AS last_ms
|
-- Old closed markets lack the close time. Use the last
|
||||||
|
-- recorded nonempty quote and exclude the closing clear.
|
||||||
|
ELSE (SELECT MAX(at_ms) FROM quote_events WHERE market=?1
|
||||||
|
AND (yes_bid IS NOT NULL OR yes_ask IS NOT NULL)) END AS last_ms
|
||||||
FROM horizon
|
FROM horizon
|
||||||
), grid(ms) AS (
|
), grid(ms) AS (
|
||||||
SELECT ((MAX(?3,first_ms)+?5-1)/?5)*?5 FROM bounds
|
SELECT ((MAX(?3,first_ms)+?5-1)/?5)*?5 FROM bounds
|
||||||
@@ -19,14 +21,12 @@ WITH RECURSIVE horizon AS (
|
|||||||
), points(ms,tail) AS (
|
), points(ms,tail) AS (
|
||||||
SELECT ms,0 FROM grid
|
SELECT ms,0 FROM grid
|
||||||
UNION ALL
|
UNION ALL
|
||||||
SELECT last_ms,1 FROM bounds WHERE resolved_ms IS NOT NULL OR first_ms<=last_ms
|
SELECT last_ms,1 FROM bounds WHERE NOT closed AND first_ms<=last_ms
|
||||||
)
|
)
|
||||||
SELECT points.ms/1000,
|
SELECT points.ms/1000,
|
||||||
CASE WHEN points.ms=b.resolved_ms THEN
|
CASE WHEN ?2='YES' THEN (COALESCE(q.yes_bid,0)+COALESCE(q.yes_ask,10000))*50
|
||||||
CASE WHEN b.winner='VOID' THEN 500000 WHEN b.winner=?2 THEN 1000000 ELSE 0 END
|
|
||||||
WHEN ?2='YES' THEN (COALESCE(q.yes_bid,0)+COALESCE(q.yes_ask,10000))*50
|
|
||||||
ELSE 1000000-(COALESCE(q.yes_bid,0)+COALESCE(q.yes_ask,10000))*50 END
|
ELSE 1000000-(COALESCE(q.yes_bid,0)+COALESCE(q.yes_ask,10000))*50 END
|
||||||
FROM points CROSS JOIN bounds b
|
FROM points
|
||||||
LEFT JOIN quote_events q ON q.seq=(
|
LEFT JOIN quote_events q ON q.seq=(
|
||||||
SELECT seq FROM quote_events WHERE market=?1 AND at_ms<=points.ms
|
SELECT seq FROM quote_events WHERE market=?1 AND at_ms<=points.ms
|
||||||
ORDER BY at_ms DESC,seq DESC LIMIT 1
|
ORDER BY at_ms DESC,seq DESC LIMIT 1
|
||||||
|
|||||||
@@ -1553,21 +1553,23 @@ fn legacy_history_samples_the_book_without_fills_and_appends_the_latest_mark() {
|
|||||||
exchange
|
exchange
|
||||||
.execute(json!({"op":"close","id":"close","market":"mid-example"}))
|
.execute(json!({"op":"close","id":"close","market":"mid-example"}))
|
||||||
.unwrap();
|
.unwrap();
|
||||||
|
db.execute("UPDATE chart_closures SET at_ms=273000", [])
|
||||||
|
.unwrap();
|
||||||
|
db.execute(
|
||||||
|
"UPDATE quote_events SET at_ms=273000 WHERE yes_bid IS NULL AND yes_ask IS NULL",
|
||||||
|
[],
|
||||||
|
)
|
||||||
|
.unwrap();
|
||||||
|
let before_close = vec![json!({"t":240,"p":0.915})];
|
||||||
|
assert_eq!(read(&exchange, "NO", 180.001, 400.0), before_close);
|
||||||
exchange
|
exchange
|
||||||
.execute(json!({"op":"finalize","id":"verdict","market":"mid-example","winner":"NO"}))
|
.execute(json!({"op":"finalize","id":"verdict","market":"mid-example","winner":"NO"}))
|
||||||
.unwrap();
|
.unwrap();
|
||||||
db.execute("UPDATE price_settlements SET at_ms=273000", [])
|
|
||||||
.unwrap();
|
|
||||||
drop(exchange);
|
drop(exchange);
|
||||||
let reopened = Exchange::open(path).unwrap();
|
let reopened = Exchange::open(path).unwrap();
|
||||||
assert_eq!(
|
assert_eq!(read(&reopened, "NO", 180.001, 400.0), before_close);
|
||||||
read(&reopened, "NO", 180.001, 240.0),
|
assert!(read(&reopened, "YES", 273.0, 400.0).is_empty());
|
||||||
vec![json!({"t":240,"p":0.915}), json!({"t":273,"p":1})]
|
assert!(read(&reopened, "YES", 5.0, 5.0).is_empty());
|
||||||
);
|
|
||||||
assert_eq!(
|
|
||||||
read(&reopened, "YES", 5.0, 5.0),
|
|
||||||
vec![json!({"t":273,"p":0})]
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
|||||||
@@ -123,28 +123,3 @@ sequenceDiagram
|
|||||||
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)
|
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"。探针把该结果计为已验证的空盘报价,实际可成交数量仍为零。
|
[电竞盘双空样本](fixtures/live-empty-prices.json)保留前后盘口和两次价格请求。两个深度数组均为空,公开 BUY 返回 "0",SELL 返回 "1"。探针把该结果计为已验证的空盘报价,实际可成交数量仍为零。
|
||||||
|
|
||||||
## 外场资产协议对应关系
|
|
||||||
|
|
||||||
`--inspect-condition ID` 查询市场条件、V2 结构条件或互斥组。用 `--inspect-tokens IDS` 查询逗号分隔的资产 ID。两者输出请求来源、完整响应及按协议整理的结果。保存输出后可用 `--replay-tokens FILE` 离线核对。单资产查询只展示返回的一侧,complete 为 false。
|
|
||||||
|
|
||||||
迁移市场样本中,市场条件返回 CTF 与 V2 两对资产,结构条件只返回 V2 的一对。互斥组样本覆盖三道题,各有 CTF 与 V2 两对。探针核对同对互补链接,以及 binary 和 neg_risk 的 V2 资产高位条件和低位结果索引。目录结果用于识别资产协议,实际可交易资产仍由场所盘口确认。[生产样本](fixtures/live-token-families.json) · [官方 Data API](https://data-api.polymarket.com/v2/openapi.json)
|
|
||||||
|
|
||||||
```mermaid
|
|
||||||
flowchart LR
|
|
||||||
main["main.rs"] --> lookup["token_families.rs"]
|
|
||||||
lookup --> id["catalog.rs 的 uint256 解码"]
|
|
||||||
lookup --> api["Polymarket Data API /v2/tokens"]
|
|
||||||
```
|
|
||||||
|
|
||||||
```mermaid
|
|
||||||
sequenceDiagram
|
|
||||||
participant C as 操作员
|
|
||||||
participant P as venue-probe
|
|
||||||
participant D as Data API
|
|
||||||
C->>P: 查询条件、互斥组或结果资产
|
|
||||||
P->>D: GET /v2/tokens
|
|
||||||
D-->>P: 各协议的资产与互补链接
|
|
||||||
P->>P: 按市场和协议配对,核对 V2 编码
|
|
||||||
P-->>C: 原始响应与协议分组
|
|
||||||
```
|
|
||||||
|
|||||||
File diff suppressed because one or more lines are too long
@@ -9,7 +9,7 @@ fn pair(value: &Value) -> Result<[String; 2]> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Polymarket serializes token IDs as decimal strings. Decode without f64 or u128 truncation.
|
// Polymarket serializes token IDs as decimal strings. Decode without f64 or u128 truncation.
|
||||||
pub(crate) fn uint256(raw: &str) -> Result<[u8; 32]> {
|
fn uint256(raw: &str) -> Result<[u8; 32]> {
|
||||||
ensure!(
|
ensure!(
|
||||||
!raw.is_empty() && raw.len() <= 78 && raw.bytes().all(|b| b.is_ascii_digit()),
|
!raw.is_empty() && raw.len() <= 78 && raw.bytes().all(|b| b.is_ascii_digit()),
|
||||||
"invalid decimal token ID"
|
"invalid decimal token ID"
|
||||||
|
|||||||
@@ -3,7 +3,6 @@ mod books;
|
|||||||
mod catalog;
|
mod catalog;
|
||||||
mod price_check;
|
mod price_check;
|
||||||
mod probes;
|
mod probes;
|
||||||
mod token_families;
|
|
||||||
use anyhow::{ensure, Result};
|
use anyhow::{ensure, Result};
|
||||||
use reqwest::blocking::Client;
|
use reqwest::blocking::Client;
|
||||||
use serde_json::{json, Value};
|
use serde_json::{json, Value};
|
||||||
@@ -34,22 +33,8 @@ fn observe_book(client: &Client, url: reqwest::Url, token: &str) -> Result<()> {
|
|||||||
fn main() -> Result<()> {
|
fn main() -> Result<()> {
|
||||||
let args: Vec<_> = std::env::args().skip(1).collect();
|
let args: Vec<_> = std::env::args().skip(1).collect();
|
||||||
let usage =
|
let usage =
|
||||||
"usage: venue-probe [--compare-prices | --inspect-book TOKEN | --replay-book TOKEN FILE | --replay-market FILE | --inspect-condition ID | --inspect-tokens IDS | --replay-tokens FILE]";
|
"usage: venue-probe [--compare-prices | --inspect-book TOKEN | --replay-book TOKEN FILE | --replay-market FILE]";
|
||||||
if let [mode, file] = args.as_slice() {
|
if let [mode, file] = args.as_slice() {
|
||||||
if mode == "--replay-tokens" {
|
|
||||||
let input: Value = serde_json::from_reader(std::fs::File::open(file)?)?;
|
|
||||||
if let Some(status) = input.get("status") {
|
|
||||||
ensure!(
|
|
||||||
status.as_u64().is_some_and(|n| (200..300).contains(&n)),
|
|
||||||
"saved request failed"
|
|
||||||
);
|
|
||||||
}
|
|
||||||
println!(
|
|
||||||
"{}",
|
|
||||||
token_families::inspect(input.get("body").unwrap_or(&input))?
|
|
||||||
);
|
|
||||||
return Ok(());
|
|
||||||
}
|
|
||||||
if mode == "--replay-market" {
|
if mode == "--replay-market" {
|
||||||
let raw = serde_json::from_reader(std::fs::File::open(file)?)?;
|
let raw = serde_json::from_reader(std::fs::File::open(file)?)?;
|
||||||
println!("{}", catalog::Market::parse(&raw)?.report);
|
println!("{}", catalog::Market::parse(&raw)?.report);
|
||||||
@@ -73,14 +58,7 @@ fn main() -> Result<()> {
|
|||||||
let compare = match args.as_slice() {
|
let compare = match args.as_slice() {
|
||||||
[] => false,
|
[] => false,
|
||||||
[flag] if flag == "--compare-prices" => true,
|
[flag] if flag == "--compare-prices" => true,
|
||||||
[flag, _]
|
[flag, _] if flag == "--inspect-book" => false,
|
||||||
if matches!(
|
|
||||||
flag.as_str(),
|
|
||||||
"--inspect-book" | "--inspect-condition" | "--inspect-tokens"
|
|
||||||
) =>
|
|
||||||
{
|
|
||||||
false
|
|
||||||
}
|
|
||||||
_ => anyhow::bail!(usage),
|
_ => anyhow::bail!(usage),
|
||||||
};
|
};
|
||||||
let client = Client::builder()
|
let client = Client::builder()
|
||||||
@@ -88,16 +66,7 @@ fn main() -> Result<()> {
|
|||||||
.timeout(Duration::from_secs(15))
|
.timeout(Duration::from_secs(15))
|
||||||
.user_agent("eventbook-readonly-probe/0.1")
|
.user_agent("eventbook-readonly-probe/0.1")
|
||||||
.build()?;
|
.build()?;
|
||||||
if let [flag, token] = args.as_slice() {
|
if let [_, token] = args.as_slice() {
|
||||||
if matches!(flag.as_str(), "--inspect-condition" | "--inspect-tokens") {
|
|
||||||
let selector = if flag == "--inspect-condition" {
|
|
||||||
"condition"
|
|
||||||
} else {
|
|
||||||
"token_id"
|
|
||||||
};
|
|
||||||
println!("{}", token_families::observe(&client, selector, token)?);
|
|
||||||
return Ok(());
|
|
||||||
}
|
|
||||||
let url = reqwest::Url::parse_with_params(
|
let url = reqwest::Url::parse_with_params(
|
||||||
"https://clob.polymarket.com/book",
|
"https://clob.polymarket.com/book",
|
||||||
&[("token_id", token)],
|
&[("token_id", token)],
|
||||||
|
|||||||
@@ -1,143 +0,0 @@
|
|||||||
use crate::catalog::uint256;
|
|
||||||
use anyhow::{ensure, Context, Result};
|
|
||||||
use reqwest::{blocking::Client, Url};
|
|
||||||
use serde::Deserialize;
|
|
||||||
use serde_json::{json, Value};
|
|
||||||
use std::collections::{HashMap, HashSet};
|
|
||||||
|
|
||||||
#[derive(Deserialize)]
|
|
||||||
struct Token<'a> {
|
|
||||||
token_id: &'a str,
|
|
||||||
condition_id: &'a str,
|
|
||||||
structural_condition_id: Option<&'a str>,
|
|
||||||
module: &'a str,
|
|
||||||
outcome_index: u8,
|
|
||||||
opposite_token_id: &'a str,
|
|
||||||
question_index: Option<u64>,
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Eq, Hash, PartialEq)]
|
|
||||||
struct Family<'a> {
|
|
||||||
condition: &'a str,
|
|
||||||
structure: Option<&'a str>,
|
|
||||||
module: &'a str,
|
|
||||||
}
|
|
||||||
|
|
||||||
pub(crate) fn inspect(body: &Value) -> Result<Value> {
|
|
||||||
let data = body["data"].as_array().context("missing token rows")?;
|
|
||||||
let mut families = Vec::<[Option<&Value>; 2]>::new();
|
|
||||||
let mut indexes = HashMap::new();
|
|
||||||
let mut seen = HashSet::new();
|
|
||||||
for row in data {
|
|
||||||
let token = Token::deserialize(row)?;
|
|
||||||
let token_id = uint256(token.token_id)?;
|
|
||||||
let opposite = uint256(token.opposite_token_id)?;
|
|
||||||
ensure!(seen.insert(token_id), "duplicate token ID");
|
|
||||||
ensure!(
|
|
||||||
token_id != opposite && token.outcome_index <= 1,
|
|
||||||
"invalid binary pair"
|
|
||||||
);
|
|
||||||
if matches!(token.module, "binary" | "neg_risk") {
|
|
||||||
let mut structural = String::from("0x");
|
|
||||||
use std::fmt::Write;
|
|
||||||
for byte in &token_id[..31] {
|
|
||||||
write!(structural, "{byte:02x}")?;
|
|
||||||
}
|
|
||||||
structural.push_str("00");
|
|
||||||
ensure!(
|
|
||||||
token.structural_condition_id == Some(structural.as_str())
|
|
||||||
&& token_id[31] == token.outcome_index
|
|
||||||
&& opposite[..31] == token_id[..31]
|
|
||||||
&& opposite[31] == 1 - token.outcome_index,
|
|
||||||
"V2 position ID contradicts structural condition or outcome"
|
|
||||||
);
|
|
||||||
}
|
|
||||||
let key = Family {
|
|
||||||
condition: token.condition_id,
|
|
||||||
structure: token.structural_condition_id,
|
|
||||||
module: token.module,
|
|
||||||
};
|
|
||||||
let family = *indexes.entry(key).or_insert_with(|| {
|
|
||||||
families.push([None, None]);
|
|
||||||
families.len() - 1
|
|
||||||
});
|
|
||||||
let slots = &mut families[family];
|
|
||||||
if let Some(other) = slots[usize::from(1 - token.outcome_index)] {
|
|
||||||
let other = Token::deserialize(other)?;
|
|
||||||
ensure!(
|
|
||||||
other.token_id == token.opposite_token_id
|
|
||||||
&& other.opposite_token_id == token.token_id
|
|
||||||
&& other.question_index == token.question_index,
|
|
||||||
"outcome links point outside the protocol pair"
|
|
||||||
);
|
|
||||||
}
|
|
||||||
ensure!(
|
|
||||||
slots[usize::from(token.outcome_index)]
|
|
||||||
.replace(row)
|
|
||||||
.is_none(),
|
|
||||||
"duplicate outcome slot"
|
|
||||||
);
|
|
||||||
}
|
|
||||||
let groups: Vec<_> = families.into_iter().map(|slots| {
|
|
||||||
let row = slots[0].or(slots[1]).expect("each family has a known token");
|
|
||||||
json!({
|
|
||||||
"condition_id":row["condition_id"], "structural_condition_id":row["structural_condition_id"],
|
|
||||||
"module":row["module"],"question_index":row["question_index"],
|
|
||||||
"complete":slots.iter().all(Option::is_some),"outcomes":slots
|
|
||||||
})
|
|
||||||
}).collect();
|
|
||||||
Ok(json!({"families":groups,"token_count":data.len()}))
|
|
||||||
}
|
|
||||||
|
|
||||||
pub(crate) fn observe(client: &Client, selector: &str, value: &str) -> Result<Value> {
|
|
||||||
let url = Url::parse_with_params(
|
|
||||||
"https://data-api.polymarket.com/v2/tokens",
|
|
||||||
&[(selector, value)],
|
|
||||||
)?;
|
|
||||||
let response = client.get(url.clone()).send()?.error_for_status()?;
|
|
||||||
let status = response.status().as_u16();
|
|
||||||
let observed = response
|
|
||||||
.headers()
|
|
||||||
.get(reqwest::header::DATE)
|
|
||||||
.and_then(|v| v.to_str().ok())
|
|
||||||
.map(str::to_owned);
|
|
||||||
let body: Value = response.json()?;
|
|
||||||
let report = inspect(&body)?;
|
|
||||||
Ok(json!({"source":url.as_str(),"status":status,"date":observed,"body":body,"report":report}))
|
|
||||||
}
|
|
||||||
|
|
||||||
#[cfg(test)]
|
|
||||||
mod tests {
|
|
||||||
use super::*;
|
|
||||||
|
|
||||||
#[test]
|
|
||||||
fn production_rows_separate_both_protocols_and_partial_lookup() {
|
|
||||||
let sample: Value =
|
|
||||||
serde_json::from_str(include_str!("../fixtures/live-token-families.json")).unwrap();
|
|
||||||
let migrated = &sample["neg_risk_migrated"];
|
|
||||||
let body = &migrated["responses"][0]["body"];
|
|
||||||
let groups = inspect(body).unwrap();
|
|
||||||
assert_eq!(groups["token_count"], 4);
|
|
||||||
assert_eq!(groups["families"][0]["module"], "v1_ctf");
|
|
||||||
assert_eq!(groups["families"][1]["module"], "neg_risk");
|
|
||||||
assert_eq!(groups["families"][1]["complete"], true);
|
|
||||||
assert_eq!(
|
|
||||||
inspect(&migrated["structural"]["body"]).unwrap()["token_count"],
|
|
||||||
2
|
|
||||||
);
|
|
||||||
assert_eq!(
|
|
||||||
inspect(&sample["group"]["body"]).unwrap()["families"]
|
|
||||||
.as_array()
|
|
||||||
.unwrap()
|
|
||||||
.len(),
|
|
||||||
6
|
|
||||||
);
|
|
||||||
assert_eq!(
|
|
||||||
inspect(&sample["one"]["body"]).unwrap()["families"][0]["complete"],
|
|
||||||
false
|
|
||||||
);
|
|
||||||
let mut mismatch = body.clone();
|
|
||||||
mismatch["data"][0]["opposite_token_id"] = mismatch["data"][3]["token_id"].clone();
|
|
||||||
assert!(inspect(&mismatch).is_err());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -0,0 +1,597 @@
|
|||||||
|
[
|
||||||
|
{
|
||||||
|
"catalog_url": "https://gamma-api.polymarket.com/markets?closed=true&limit=100&order=closedTime&ascending=false",
|
||||||
|
"catalog": {
|
||||||
|
"id": "7554899",
|
||||||
|
"slug": "cs2-bb3-lgc-2026-12-03-game1-round-total-30pt5",
|
||||||
|
"version": "v1",
|
||||||
|
"conditionId": "0xdf04a0495b0a16dbce386acdc16d9aed19784db9888be53d150354b83b7c18b1",
|
||||||
|
"closed": true,
|
||||||
|
"closedTime": "2026-12-03 08:32:03.519799+00",
|
||||||
|
"acceptingOrders": false,
|
||||||
|
"umaResolutionStatus": "resolved",
|
||||||
|
"outcomePrices": "[\"0\", \"1\"]",
|
||||||
|
"outcomes": "[\"Over\", \"Under\"]",
|
||||||
|
"positionIds": null,
|
||||||
|
"clobTokenIds": "[\"73979342585906843441145134109923710004884703083095161594360108477170435492453\", \"78188826358032258311424545486331333398838521699262460256542567713692269401385\"]"
|
||||||
|
},
|
||||||
|
"sides": [
|
||||||
|
{
|
||||||
|
"asset": "73979342585906843441145134109923710004884703083095161594360108477170435492453",
|
||||||
|
"around": {
|
||||||
|
"method": "GET",
|
||||||
|
"url": "https://clob.polymarket.com/prices-history?market=73979342585906843441145134109923710004884703083095161594360108477170435492453&startTs=1796284923&endTs=1796288523&fidelity=2",
|
||||||
|
"payload": null,
|
||||||
|
"status": 200,
|
||||||
|
"date": "Thu, 03 Dec 2026 08:34:56 GMT",
|
||||||
|
"body": {
|
||||||
|
"history": [
|
||||||
|
{
|
||||||
|
"t": 1796285541,
|
||||||
|
"p": 0.1
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"t": 1796285655,
|
||||||
|
"p": 0.1
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"t": 1796285780,
|
||||||
|
"p": 0.1
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"t": 1796285889,
|
||||||
|
"p": 0.1
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"t": 1796286038,
|
||||||
|
"p": 0.1
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"t": 1796286155,
|
||||||
|
"p": 0.1
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"t": 1796286252,
|
||||||
|
"p": 0.005
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"t": 1796286383,
|
||||||
|
"p": 0.0005
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"t": 1796286495,
|
||||||
|
"p": 0.0005
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"t": 1796286646,
|
||||||
|
"p": 0.0005
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"after": {
|
||||||
|
"method": "GET",
|
||||||
|
"url": "https://clob.polymarket.com/prices-history?market=73979342585906843441145134109923710004884703083095161594360108477170435492453&startTs=1796290323&endTs=1796290623&fidelity=2",
|
||||||
|
"payload": null,
|
||||||
|
"status": 200,
|
||||||
|
"date": "Thu, 03 Dec 2026 08:34:56 GMT",
|
||||||
|
"body": {
|
||||||
|
"history": []
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"ancient": {
|
||||||
|
"method": "GET",
|
||||||
|
"url": "https://clob.polymarket.com/prices-history?market=73979342585906843441145134109923710004884703083095161594360108477170435492453&startTs=120&endTs=245",
|
||||||
|
"payload": null,
|
||||||
|
"status": 200,
|
||||||
|
"date": "Thu, 03 Dec 2026 08:34:56 GMT",
|
||||||
|
"body": {
|
||||||
|
"history": []
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"asset": "78188826358032258311424545486331333398838521699262460256542567713692269401385",
|
||||||
|
"around": {
|
||||||
|
"method": "GET",
|
||||||
|
"url": "https://clob.polymarket.com/prices-history?market=78188826358032258311424545486331333398838521699262460256542567713692269401385&startTs=1796284923&endTs=1796288523&fidelity=2",
|
||||||
|
"payload": null,
|
||||||
|
"status": 200,
|
||||||
|
"date": "Thu, 03 Dec 2026 08:34:58 GMT",
|
||||||
|
"body": {
|
||||||
|
"history": [
|
||||||
|
{
|
||||||
|
"t": 1796285540,
|
||||||
|
"p": 0.9
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"t": 1796285654,
|
||||||
|
"p": 0.9
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"t": 1796285780,
|
||||||
|
"p": 0.9
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"t": 1796285889,
|
||||||
|
"p": 0.9
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"t": 1796286037,
|
||||||
|
"p": 0.9
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"t": 1796286155,
|
||||||
|
"p": 0.9
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"t": 1796286252,
|
||||||
|
"p": 0.995
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"t": 1796286383,
|
||||||
|
"p": 0.9995
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"t": 1796286495,
|
||||||
|
"p": 0.9995
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"t": 1796286646,
|
||||||
|
"p": 0.9995
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"after": {
|
||||||
|
"method": "GET",
|
||||||
|
"url": "https://clob.polymarket.com/prices-history?market=78188826358032258311424545486331333398838521699262460256542567713692269401385&startTs=1796290323&endTs=1796290623&fidelity=2",
|
||||||
|
"payload": null,
|
||||||
|
"status": 200,
|
||||||
|
"date": "Thu, 03 Dec 2026 08:34:58 GMT",
|
||||||
|
"body": {
|
||||||
|
"history": []
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"ancient": {
|
||||||
|
"method": "GET",
|
||||||
|
"url": "https://clob.polymarket.com/prices-history?market=78188826358032258311424545486331333398838521699262460256542567713692269401385&startTs=120&endTs=245",
|
||||||
|
"payload": null,
|
||||||
|
"status": 200,
|
||||||
|
"date": "Thu, 03 Dec 2026 08:34:58 GMT",
|
||||||
|
"body": {
|
||||||
|
"history": []
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"catalog_url": "https://gamma-api.polymarket.com/markets?closed=true&limit=100&order=closedTime&ascending=false",
|
||||||
|
"catalog": {
|
||||||
|
"id": "7543472",
|
||||||
|
"slug": "setkameua-anat-illia-2026-12-03",
|
||||||
|
"version": "v2",
|
||||||
|
"conditionId": "0x01ae18f1c798f53d0efe0903889e57483c000000000000000000000000000000",
|
||||||
|
"closed": true,
|
||||||
|
"closedTime": "2026-12-03 08:31:00.370625+00",
|
||||||
|
"acceptingOrders": false,
|
||||||
|
"umaResolutionStatus": null,
|
||||||
|
"outcomePrices": "[\"1\", \"0\"]",
|
||||||
|
"outcomes": "[\"Nikolenko Anatolii\", \"Fokin Illia\"]",
|
||||||
|
"positionIds": [
|
||||||
|
"759916398134244316868652908232832573045153963965173623897622651599218278400",
|
||||||
|
"759916398134244316868652908232832573045153963965173623897622651599218278401"
|
||||||
|
],
|
||||||
|
"clobTokenIds": "[\"759916398134244316868652908232832573045153963965173623897622651599218278400\", \"759916398134244316868652908232832573045153963965173623897622651599218278401\"]"
|
||||||
|
},
|
||||||
|
"sides": [
|
||||||
|
{
|
||||||
|
"asset": "759916398134244316868652908232832573045153963965173623897622651599218278400",
|
||||||
|
"around": {
|
||||||
|
"method": "GET",
|
||||||
|
"url": "https://clob.polymarket.com/prices-history?market=759916398134244316868652908232832573045153963965173623897622651599218278400&startTs=1796284860&endTs=1796288460&fidelity=2",
|
||||||
|
"payload": null,
|
||||||
|
"status": 200,
|
||||||
|
"date": "Thu, 03 Dec 2026 08:34:59 GMT",
|
||||||
|
"body": {
|
||||||
|
"history": [
|
||||||
|
{
|
||||||
|
"t": 1796284969,
|
||||||
|
"p": 0.999
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"t": 1796285059,
|
||||||
|
"p": 0.999
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"t": 1796285176,
|
||||||
|
"p": 0.999
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"t": 1796285310,
|
||||||
|
"p": 0.999
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"t": 1796285335,
|
||||||
|
"p": 0.999
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"t": 1796285416,
|
||||||
|
"p": 0.999
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"t": 1796285540,
|
||||||
|
"p": 0.999
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"t": 1796285654,
|
||||||
|
"p": 0.999
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"t": 1796285779,
|
||||||
|
"p": 0.999
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"t": 1796285889,
|
||||||
|
"p": 0.999
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"t": 1796286037,
|
||||||
|
"p": 0.999
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"t": 1796286154,
|
||||||
|
"p": 0.999
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"t": 1796286252,
|
||||||
|
"p": 0.999
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"t": 1796286382,
|
||||||
|
"p": 0.999
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"t": 1796286494,
|
||||||
|
"p": 0.999
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"t": 1796286645,
|
||||||
|
"p": 0.999
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"after": {
|
||||||
|
"method": "GET",
|
||||||
|
"url": "https://clob.polymarket.com/prices-history?market=759916398134244316868652908232832573045153963965173623897622651599218278400&startTs=1796290260&endTs=1796290560&fidelity=2",
|
||||||
|
"payload": null,
|
||||||
|
"status": 200,
|
||||||
|
"date": "Thu, 03 Dec 2026 08:34:59 GMT",
|
||||||
|
"body": {
|
||||||
|
"history": []
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"ancient": {
|
||||||
|
"method": "GET",
|
||||||
|
"url": "https://clob.polymarket.com/prices-history?market=759916398134244316868652908232832573045153963965173623897622651599218278400&startTs=120&endTs=245",
|
||||||
|
"payload": null,
|
||||||
|
"status": 200,
|
||||||
|
"date": "Thu, 03 Dec 2026 08:34:59 GMT",
|
||||||
|
"body": {
|
||||||
|
"history": []
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"asset": "759916398134244316868652908232832573045153963965173623897622651599218278401",
|
||||||
|
"around": {
|
||||||
|
"method": "GET",
|
||||||
|
"url": "https://clob.polymarket.com/prices-history?market=759916398134244316868652908232832573045153963965173623897622651599218278401&startTs=1796284860&endTs=1796288460&fidelity=2",
|
||||||
|
"payload": null,
|
||||||
|
"status": 200,
|
||||||
|
"date": "Thu, 03 Dec 2026 08:35:00 GMT",
|
||||||
|
"body": {
|
||||||
|
"history": [
|
||||||
|
{
|
||||||
|
"t": 1796284969,
|
||||||
|
"p": 0.001
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"t": 1796285059,
|
||||||
|
"p": 0.001
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"t": 1796285176,
|
||||||
|
"p": 0.001
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"t": 1796285310,
|
||||||
|
"p": 0.001
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"t": 1796285335,
|
||||||
|
"p": 0.001
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"t": 1796285416,
|
||||||
|
"p": 0.001
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"t": 1796285540,
|
||||||
|
"p": 0.001
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"t": 1796285654,
|
||||||
|
"p": 0.001
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"t": 1796285779,
|
||||||
|
"p": 0.001
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"t": 1796285889,
|
||||||
|
"p": 0.001
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"t": 1796286037,
|
||||||
|
"p": 0.001
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"t": 1796286154,
|
||||||
|
"p": 0.001
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"t": 1796286252,
|
||||||
|
"p": 0.001
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"t": 1796286382,
|
||||||
|
"p": 0.001
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"t": 1796286494,
|
||||||
|
"p": 0.001
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"t": 1796286645,
|
||||||
|
"p": 0.001
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"after": {
|
||||||
|
"method": "GET",
|
||||||
|
"url": "https://clob.polymarket.com/prices-history?market=759916398134244316868652908232832573045153963965173623897622651599218278401&startTs=1796290260&endTs=1796290560&fidelity=2",
|
||||||
|
"payload": null,
|
||||||
|
"status": 200,
|
||||||
|
"date": "Thu, 03 Dec 2026 08:35:00 GMT",
|
||||||
|
"body": {
|
||||||
|
"history": []
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"ancient": {
|
||||||
|
"method": "GET",
|
||||||
|
"url": "https://clob.polymarket.com/prices-history?market=759916398134244316868652908232832573045153963965173623897622651599218278401&startTs=120&endTs=245",
|
||||||
|
"payload": null,
|
||||||
|
"status": 200,
|
||||||
|
"date": "Thu, 03 Dec 2026 08:35:01 GMT",
|
||||||
|
"body": {
|
||||||
|
"history": []
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"catalog_url": "https://gamma-api.polymarket.com/markets?closed=true&limit=100&order=closedTime&ascending=false",
|
||||||
|
"catalog": {
|
||||||
|
"id": "7528433",
|
||||||
|
"slug": "sol-updown-15m-1796285700",
|
||||||
|
"version": "v2",
|
||||||
|
"conditionId": "0x0190f69570a8ebb0d5608f8f773ffc068b000000000000000000000000000000",
|
||||||
|
"closed": true,
|
||||||
|
"closedTime": "2026-12-03 08:30:28.231292+00",
|
||||||
|
"acceptingOrders": false,
|
||||||
|
"umaResolutionStatus": null,
|
||||||
|
"outcomePrices": "[\"1\", \"0\"]",
|
||||||
|
"outcomes": "[\"Up\", \"Down\"]",
|
||||||
|
"positionIds": [
|
||||||
|
"708440684409184214698552699176045036593002385654320616860038876849074339840",
|
||||||
|
"708440684409184214698552699176045036593002385654320616860038876849074339841"
|
||||||
|
],
|
||||||
|
"clobTokenIds": "[\"708440684409184214698552699176045036593002385654320616860038876849074339840\", \"708440684409184214698552699176045036593002385654320616860038876849074339841\"]"
|
||||||
|
},
|
||||||
|
"sides": [
|
||||||
|
{
|
||||||
|
"asset": "708440684409184214698552699176045036593002385654320616860038876849074339840",
|
||||||
|
"around": {
|
||||||
|
"method": "GET",
|
||||||
|
"url": "https://clob.polymarket.com/prices-history?market=708440684409184214698552699176045036593002385654320616860038876849074339840&startTs=1796284828&endTs=1796288428&fidelity=2",
|
||||||
|
"payload": null,
|
||||||
|
"status": 200,
|
||||||
|
"date": "Thu, 03 Dec 2026 08:35:02 GMT",
|
||||||
|
"body": {
|
||||||
|
"history": [
|
||||||
|
{
|
||||||
|
"t": 1796284968,
|
||||||
|
"p": 0.5
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"t": 1796285058,
|
||||||
|
"p": 0.5
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"t": 1796285173,
|
||||||
|
"p": 0.5
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"t": 1796285310,
|
||||||
|
"p": 0.5
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"t": 1796285334,
|
||||||
|
"p": 0.5
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"t": 1796285414,
|
||||||
|
"p": 0.505
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"t": 1796285539,
|
||||||
|
"p": 0.505
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"t": 1796285653,
|
||||||
|
"p": 0.5
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"t": 1796285778,
|
||||||
|
"p": 0.395
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"t": 1796285888,
|
||||||
|
"p": 0.55
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"t": 1796286036,
|
||||||
|
"p": 0.675
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"t": 1796286153,
|
||||||
|
"p": 0.8
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"t": 1796286251,
|
||||||
|
"p": 0.83
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"t": 1796286382,
|
||||||
|
"p": 0.83
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"t": 1796286494,
|
||||||
|
"p": 0.96
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"after": {
|
||||||
|
"method": "GET",
|
||||||
|
"url": "https://clob.polymarket.com/prices-history?market=708440684409184214698552699176045036593002385654320616860038876849074339840&startTs=1796290228&endTs=1796290528&fidelity=2",
|
||||||
|
"payload": null,
|
||||||
|
"status": 200,
|
||||||
|
"date": "Thu, 03 Dec 2026 08:35:02 GMT",
|
||||||
|
"body": {
|
||||||
|
"history": []
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"ancient": {
|
||||||
|
"method": "GET",
|
||||||
|
"url": "https://clob.polymarket.com/prices-history?market=708440684409184214698552699176045036593002385654320616860038876849074339840&startTs=120&endTs=245",
|
||||||
|
"payload": null,
|
||||||
|
"status": 200,
|
||||||
|
"date": "Thu, 03 Dec 2026 08:35:02 GMT",
|
||||||
|
"body": {
|
||||||
|
"history": []
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"asset": "708440684409184214698552699176045036593002385654320616860038876849074339841",
|
||||||
|
"around": {
|
||||||
|
"method": "GET",
|
||||||
|
"url": "https://clob.polymarket.com/prices-history?market=708440684409184214698552699176045036593002385654320616860038876849074339841&startTs=1796284828&endTs=1796288428&fidelity=2",
|
||||||
|
"payload": null,
|
||||||
|
"status": 200,
|
||||||
|
"date": "Thu, 03 Dec 2026 08:35:03 GMT",
|
||||||
|
"body": {
|
||||||
|
"history": [
|
||||||
|
{
|
||||||
|
"t": 1796284969,
|
||||||
|
"p": 0.5
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"t": 1796285059,
|
||||||
|
"p": 0.5
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"t": 1796285176,
|
||||||
|
"p": 0.5
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"t": 1796285310,
|
||||||
|
"p": 0.5
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"t": 1796285335,
|
||||||
|
"p": 0.5
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"t": 1796285416,
|
||||||
|
"p": 0.495
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"t": 1796285540,
|
||||||
|
"p": 0.495
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"t": 1796285654,
|
||||||
|
"p": 0.5
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"t": 1796285779,
|
||||||
|
"p": 0.605
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"t": 1796285888,
|
||||||
|
"p": 0.455
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"t": 1796286036,
|
||||||
|
"p": 0.335
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"t": 1796286154,
|
||||||
|
"p": 0.205
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"t": 1796286252,
|
||||||
|
"p": 0.17
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"t": 1796286382,
|
||||||
|
"p": 0.175
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"t": 1796286494,
|
||||||
|
"p": 0.08
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"after": {
|
||||||
|
"method": "GET",
|
||||||
|
"url": "https://clob.polymarket.com/prices-history?market=708440684409184214698552699176045036593002385654320616860038876849074339841&startTs=1796290228&endTs=1796290528&fidelity=2",
|
||||||
|
"payload": null,
|
||||||
|
"status": 200,
|
||||||
|
"date": "Thu, 03 Dec 2026 08:35:03 GMT",
|
||||||
|
"body": {
|
||||||
|
"history": []
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"ancient": {
|
||||||
|
"method": "GET",
|
||||||
|
"url": "https://clob.polymarket.com/prices-history?market=708440684409184214698552699176045036593002385654320616860038876849074339841&startTs=120&endTs=245",
|
||||||
|
"payload": null,
|
||||||
|
"status": 200,
|
||||||
|
"date": "Thu, 03 Dec 2026 08:35:04 GMT",
|
||||||
|
"body": {
|
||||||
|
"history": []
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
||||||
@@ -376,7 +376,7 @@ Polymarket 的单资产最近成交接口规定,无成交时返回价格字符
|
|||||||
|
|
||||||
旧版 CLOB 客户端用 market 指定结果资产。单侧盘口的生产曲线末点为 0.0005,同批中点为 0.0005、最近成交为 0.001。一个近端成交记录为空的资产也有连续的 0.5 历史点。取早于上市的绝对区间时,有历史的资产仍返回最近可用点;新资产在中点已经可查时也可能返回空曲线。[生产请求和对照样本](examples/public-clob-history.json) · [CLOB OpenAPI](https://docs.polymarket.com/api-reference/markets/get-prices-history)
|
旧版 CLOB 客户端用 market 指定结果资产。单侧盘口的生产曲线末点为 0.0005,同批中点为 0.0005、最近成交为 0.001。一个近端成交记录为空的资产也有连续的 0.5 历史点。取早于上市的绝对区间时,有历史的资产仍返回最近可用点;新资产在中点已经可查时也可能返回空曲线。[生产请求和对照样本](examples/public-clob-history.json) · [CLOB OpenAPI](https://docs.polymarket.com/api-reference/markets/get-prices-history)
|
||||||
|
|
||||||
本地用已经提交的盘口变更重建历史中点。到每个 UTC 采样边界,取该时刻之前(含该时刻)最近一次盘口;缺买侧用 0,缺卖侧用 1。没有挂单变化时延续上次观测。窗口之外也追加最近一分钟的可用点;若与窗口最后一点重合,可出现重复时间戳。模拟裁决后在裁决时刻以兑付值收尾。已裁决的旧盘若缺少裁决时间,只使用最后有时间记录的报价。升级旧库时从第一条可信报价开始,没有报价记录的资产从迁移时刻开始。生产采集存在秒级抖动,新盘首个采样的延迟、长期历史保留和裁决后取点尚未逐点验证。V2 的成交与兑付历史保留其独立数据源。
|
本地用已经提交的盘口变更重建历史中点。到每个 UTC 采样边界,取该时刻之前(含该时刻)最近一次盘口;缺买侧用 0,缺卖侧用 1。没有挂单变化时延续上次观测。窗口之外也追加最近一分钟的可用点;若与窗口最后一点重合,可出现重复时间戳。封盘后,曲线只返回请求窗口内、封盘之前的采样点。电竞、乒乓球和 SOL 涨跌盘的六个生产结果均符合这一规则。电竞负侧、胜侧的末点分别为 0.0005 和 0.9995,目录最终兑付为 0 和 1。旧库没有封盘记录时,最多采样到最后一笔非空盘口记录。生产采样时钟有秒级偏移,新盘首个采样延迟和长期保留仍待核验。V2 曲线使用成交与兑付数据。[已裁决生产样本](examples/public-closed-chart-history.json)
|
||||||
|
|
||||||
fidelity 以分钟为单位;省略或不大于零时按 1 分钟处理。相对窗口 1w 至少需要 5 分钟、1m 至少需要 10 分钟。显式起止时间最多相隔 15 天,多一秒即拒绝。单给 startTs 时读到当前;两个时间相等时仍可返回末点。合法但未上市的本地资产返回空数组。[HTTP 样例](examples/clob-http.http)
|
fidelity 以分钟为单位;省略或不大于零时按 1 分钟处理。相对窗口 1w 至少需要 5 分钟、1m 至少需要 10 分钟。显式起止时间最多相隔 15 天,多一秒即拒绝。单给 startTs 时读到当前;两个时间相等时仍可返回末点。合法但未上市的本地资产返回空数组。[HTTP 样例](examples/clob-http.http)
|
||||||
|
|
||||||
@@ -466,6 +466,3 @@ SDK 使用 `GET /neg-risk?token_id=…`,也可以从已缓存的 CLOB 市场
|
|||||||
用空数据库重放[原单状态样例](examples/order-status.jsonl)。卖方以 0.60 挂 5 份 post-only 卖单,买方按金额吃掉 2 份。卖方撤回余单后,按原订单号查询,累计成交仍为 2,可成交余量为 0,`order_type` 为 GTC。买方的原单类型为 FAK。按卖方订单号查询 `trades`,这笔执行的份额也是 2。重启和重发相同命令沿用原回执与受理时间。
|
用空数据库重放[原单状态样例](examples/order-status.jsonl)。卖方以 0.60 挂 5 份 post-only 卖单,买方按金额吃掉 2 份。卖方撤回余单后,按原订单号查询,累计成交仍为 2,可成交余量为 0,`order_type` 为 GTC。买方的原单类型为 FAK。按卖方订单号查询 `trades`,这笔执行的份额也是 2。重启和重发相同命令沿用原回执与受理时间。
|
||||||
|
|
||||||
`open_orders` 的列表和精确查询均返回 `created_at`(Unix 秒)、`order_type` 和本地扩展 `post_only`。升级已有数据库时,用已受理的命令回执和 GTD 截止记录恢复提交指令;没有原始时钟记录的受理时间为 null。缺少原始回执的历史行仍可查询,未知字段保留为 null。官方当前将累计成交和逐笔对账分别放在订单的 size_matched 和账户成交记录;其单笔订单 HTTP 接口需要账户认证。本地验证使用可信操作员的 JSONL 接口,订单号与账户是模拟环境的标识。生产私有接口尚未实测。[官方订单查询](https://docs.polymarket.com/trading/manage-orders)
|
`open_orders` 的列表和精确查询均返回 `created_at`(Unix 秒)、`order_type` 和本地扩展 `post_only`。升级已有数据库时,用已受理的命令回执和 GTD 截止记录恢复提交指令;没有原始时钟记录的受理时间为 null。缺少原始回执的历史行仍可查询,未知字段保留为 null。官方当前将累计成交和逐笔对账分别放在订单的 size_matched 和账户成交记录;其单笔订单 HTTP 接口需要账户认证。本地验证使用可信操作员的 JSONL 接口,订单号与账户是模拟环境的标识。生产私有接口尚未实测。[官方订单查询](https://docs.polymarket.com/trading/manage-orders)
|
||||||
|
|
||||||
|
|
||||||
连接器通过只读 /v2/tokens 核对迁移市场。实测原市场条件返回 CTF 与 V2 各一对,结构条件只返回 V2。一个三题互斥组返回十二项。结果按市场条件、结构条件和协议分组,并保留原始结果与互补标识。外场目录映射尚未写入本地账本。[连接器取样](../crates/venue-probe/fixtures/live-token-families.json)
|
|
||||||
|
|||||||
Reference in New Issue
Block a user