Compare commits

..
Author SHA1 Message Date
codex-bot 95b3e50f47 Align Gamma clarification filters and pagination 2026-12-05 16:58:38 +08:00
30 changed files with 292 additions and 2499 deletions

No files matched your search

+4 -29
View File
@@ -183,8 +183,6 @@ sequenceDiagram
路径参数使用百分号编码。即使查询从 NO 开始,primary_token_id 仍对应 YES。可重放请求见[行情 HTTP 示例](../../docs/examples/clob-http.http)。
已裁决资产的公开盘口、买卖报价、中点和价差单查返回 404,批查跳过该资产。
### 查询盘口价差与中点
```mermaid
@@ -223,7 +221,7 @@ sequenceDiagram
participant E as prices_history/legacy.rs
C->>H: GET /prices-history,market 与 interval 或 startTs、endTs
H->>E: clob_price_history,fidelity 以分钟计
E-->>H: 返回窗口内盘口中点样本,未封盘时追加最近可用点
E-->>H: 返回窗口内盘口中点样本,末尾追加最近可用点
H-->>C: history 数组,每点包含 t 和 p
```
@@ -239,13 +237,13 @@ sequenceDiagram
participant C as 客户端
participant H as market_http
participant E as Exchange
C->>H: GET /market-clarifications?event_id=1&market_id=3
H->>E: 按事件和市场目录 ID 筛选,再排序和翻页
C->>H: GET /market-clarifications?event_id=1&question_id=...
H->>E: 按事件、市场、问题和可选交易哈希求交集,再排序和翻页
E-->>H: 规则说明、清盘标记和本地发布时间
H-->>C: 已发布的公告数组
```
event_id 取自本地 events 或 catalog 查询,market_id 取自 assets 查询。两个参数均可重复,同类 ID 取并集,同时指定事件与市场时取交集。独立市场的公告也能通过 market_id 查询。默认按公告 ID 降序,每页 20 条;支持 order=id、ascending、offset 和 0 到 100 的 limit。当前查询对其他筛选参数返回 400。
event_id 取自本地 events 或 catalog 查询,market_id 取自 assets 查询。question_id 匹配市场登记的裁决问题,忽略字母大小写。三种 ID 均可重复,同类取并集,跨条件取交集。tx_hash 按已保存的发布交易哈希精确筛选。默认每页 50 条,limit 超过 100 时取 100,非正值恢复默认。offset 小于 0 时按 0 处理。order 支持逗号分隔的 Gamma 字段,例如 createdAt,id。默认按 ID 升序,未知排序字段返回 422。
### 从事件页进入订单簿
@@ -338,23 +336,6 @@ sequenceDiagram
H-->>C: 200 data 数组,未找到返回空数组
```
### 查询公开持仓榜
`GET /v2/holders?condition=cup&limit=10` 按每个结果资产返回净持仓排名。传入 include_pnl=true 改查毛持仓,并返回可计算的持仓成本和盈亏。该模式限单个市场、每侧最多 100 行。续页要重新传 condition 及需要的筛选条件,并使用 pagination.next_cursor。按 token_id 合并翻页结果。 榜单的平均价包含剩余入场费,账户持仓的平均价按本金计算。两处共用入场本金和盈亏。
```mermaid
sequenceDiagram
participant C as 客户端
participant H as market_http.rs
participant E as Exchange
C->>H: GET /v2/holders,指定 condition 和可选 include_pnl
H->>E: 查各结果资产的排名
opt 毛持仓模式
E->>E: 重放本页账户的账本流水,补充成本和盈亏
end
E-->>C: data 按 token_id 分组,pagination 提供续页游标
```
### 查询持仓价值
`GET /v2/value?user=alice&condition=e` 返回该账户在市场 e 的持仓价值,单位为模拟美元。使用已登记的本地账户名或 20 字节钱包地址。省略 condition 查询所有已持有市场。无持仓的钱包返回零,仅有现金的账户也返回零。
@@ -442,9 +423,3 @@ sequenceDiagram
E-->>H: true
H-->>C: 200,neg_risk 为真
```
GET /v2/positions 查询钱包或单一市场的当前持仓、待赎回份额、互补仓位及已退出记录。用 pagination.next_cursor 续读时沿用原钱包或市场与筛选条件。
持仓页支持按标题、事件或最低份额与金额筛选。使用下一页游标时重发这三个筛选参数。
持仓页支持 sort_by=TIMESTAMP。start 和 end 按 Unix 秒包含两端,翻页时需重发。
+44 -88
View File
@@ -293,49 +293,35 @@ fn directory_lookup(engine: &Mutex<Exchange>, route: (&str, bool, &str), params:
.ok_or((404, "Not found"))
}
fn clarifications(engine: &Mutex<Exchange>, query: &str) -> Reply {
let invalid = (400, "Invalid clarification query");
let fields: Vec<(String, String)> = serde_urlencoded::from_str(query).map_err(|_| invalid)?;
let mut ids = Vec::new();
let mut events = Vec::new();
let mut limit = 20;
let mut offset = 0;
let mut ascending = false;
for (key, value) in fields {
match key.as_str() {
"event_id" => events.push(value.parse().map_err(|_| invalid)?),
"market_id" => ids.push(value.parse().map_err(|_| invalid)?),
"limit" => limit = value.parse().map_err(|_| invalid)?,
"offset" => offset = value.parse().map_err(|_| invalid)?,
"ascending" => ascending = value.parse().map_err(|_| invalid)?,
"order" if value == "id" => {}
_ => return Err(invalid),
}
}
fn clarifications(engine: &Mutex<Exchange>, query: &str) -> (u16, Value) {
let query = serde_urlencoded::from_str::<Vec<(String, String)>>(query)
.map_err(|_| "invalid query")
.and_then(|fields| exchange::ClarificationQuery::parse(&fields));
let query = match query {
Ok(query) => query,
Err(error) => return (422, json!({"type":"validation error","error":error})),
};
let rows = engine
.lock()
.map_err(|_| (500, "Internal server error"))?
.filtered_market_clarifications(&ids, &events, limit, offset, ascending)
.map_err(|e| match e {
exchange::MarketDataError::Invalid(_) => invalid,
exchange::MarketDataError::Unavailable => (500, "Internal server error"),
})?;
Ok(Value::Array(rows))
.ok()
.and_then(|exchange| exchange.gamma_clarifications(&query).ok());
match rows {
Some(rows) => (200, Value::Array(rows)),
None => (500, json!({"error":"Internal server error"})),
}
}
fn respond(mut req: Request, engine: &Mutex<Exchange>) -> std::io::Result<()> {
let (path, params) = req.url().split_once('?').unwrap_or((req.url(), ""));
let mut allow = None;
if req.method() == &Method::Get && path == "/market-clarifications" {
let (status, body) = clarifications(engine, params);
return send(req, status, body, None);
}
if req.method() == &Method::Get
&& matches!(
path,
"/v2/prices-history"
| "/v2/trades"
| "/v2/resolutions"
| "/v2/value"
| "/v2/oi"
| "/v2/positions"
| "/v2/holders"
"/v2/prices-history" | "/v2/trades" | "/v2/resolutions" | "/v2/value" | "/v2/oi"
)
{
let (status, body) = data_page(path, params, engine);
@@ -392,7 +378,6 @@ fn respond(mut req: Request, engine: &Mutex<Exchange>) -> std::io::Result<()> {
Err(exchange::MarketDataError::Unavailable) => Err((500, "Directory unavailable")),
}
}
(&Method::Get, "/market-clarifications") => clarifications(engine, params),
(&Method::Get, "/prices-history") => {
let result = serde_urlencoded::from_str::<exchange::ClobHistoryQuery>(params)
.map_err(|_| HistoryError::Invalid("invalid query parameters".into()))
@@ -479,9 +464,7 @@ fn respond(mut req: Request, engine: &Mutex<Exchange>) -> std::io::Result<()> {
| "/market-clarifications"
| "/v2/oi"
| "/v2/value"
| "/v2/positions"
| "/v2/trades"
| "/v2/holders"
| "/v2/resolutions"
| "/v2/prices-history",
) => {
@@ -522,39 +505,21 @@ fn read_page<Q: serde::de::DeserializeOwned>(
fn data_page(path: &str, params: &str, engine: &Mutex<Exchange>) -> (u16, Value) {
let page = match path {
"/v2/oi" => read_page(params, engine, Exchange::public_open_interest),
"/v2/positions" => read_page(params, engine, Exchange::public_positions),
"/v2/value" => read_page(params, engine, Exchange::public_portfolio_value),
"/v2/trades" => read_page(params, engine, Exchange::public_trade_feed),
"/v2/holders" => read_page(params, engine, Exchange::public_holders),
"/v2/resolutions" => read_page(params, engine, Exchange::public_resolutions),
_ => read_page(params, engine, Exchange::public_price_history),
};
match page {
Ok(data) => (200, data),
Err(HistoryError::Invalid(message)) => {
let mut error = json!({"code":"invalid_request","error":message,"retryable":false});
if path == "/v2/holders" {
let parameter = match message.as_str() {
"required query param 'condition' not provided"
| "include_pnl accepts exactly one 'condition' per call" => Some("condition"),
"limit must be at most 100 with include_pnl" => Some("limit"),
msg if msg.starts_with("invalid condition id:") => Some("condition"),
_ => None,
};
if let Some(parameter) = parameter {
error["parameter"] = json!(parameter);
}
}
(400, error)
}
Err(HistoryError::Invalid(message)) => (
400,
json!({"code":"invalid_request","error":message,"retryable":false}),
),
Err(HistoryError::Unavailable) if path == "/v2/oi" => (
503,
json!({"code":"unavailable","error":"open interest unavailable","retryable":true}),
),
Err(HistoryError::Unavailable) if path == "/v2/positions" => (
503,
json!({"code":"unavailable","error":"positions unavailable","retryable":true}),
),
Err(HistoryError::Unavailable) if path == "/v2/value" => (
503,
json!({"code":"unavailable","error":"portfolio valuation unavailable","retryable":true}),
@@ -563,10 +528,6 @@ fn data_page(path: &str, params: &str, engine: &Mutex<Exchange>) -> (u16, Value)
500,
json!({"code":"internal","error":"resolution state unavailable","retryable":true}),
),
Err(HistoryError::Unavailable) if path == "/v2/holders" => (
500,
json!({"code":"internal","error":"holders unavailable","retryable":true}),
),
Err(HistoryError::Unavailable) if path == "/v2/trades" => (
500,
json!({"code":"internal","error":"trade feed unavailable","retryable":true}),
@@ -617,8 +578,11 @@ mod tests {
fn socket_serves_single_and_batch_books_and_rejects_invalid_requests() {
let mut db = Exchange::open(":memory:").unwrap();
let market = "map 2:胜者";
let question = format!("0x{}", "ab".repeat(32));
let transaction = format!("0x{}", "cd".repeat(32));
db.execute(
json!({"op":"list","id":"list","market":market,"rules":"simulated","tick_size":"0.01"}),
json!({"op":"list","id":"list","market":market,"rules":"simulated","tick_size":"0.01",
"resolution":{"kind":"optimistic","eligible_at":0,"question_id":question}}),
)
.unwrap();
db.execute(json!({"op":"list","id":"path-market","market":"map+2/1","rules":"simulation","tick_size":"0.0025","base_fees":{"maker_bps":0,"taker_bps":30},"taker_fee_rate_ppm":50000})).unwrap();
@@ -647,9 +611,6 @@ mod tests {
let lookup_info = json!({"mbf":0,"tbf":30,"fd":{"r":0.05,"e":1,"to":true},"gst":null,"nr":false,"rfqe":false,"ibce":false,"oas":0,"mos":0.01,"mts":0.0025,
"t":[{"o":"YES","t":"eb:YES:map+2/1"},{"o":"NO","t":"eb:NO:map+2/1"}]});
for command in [
json!({"op":"list","id":"resolved-list","market":"resolved-test","rules":"resolved fixture"}),
json!({"op":"close","id":"resolved-close","market":"resolved-test"}),
json!({"op":"finalize","id":"resolved-final","market":"resolved-test","winner":"YES"}),
json!({"op":"fund","id":"v-fund","account":"unpriced-owner","cents":100}),
json!({"op":"list","id":"v-list","market":"unpriced","rules":"valuation fixture"}),
json!({"op":"split","id":"v-split","account":"unpriced-owner","market":"unpriced","qty":1}),
@@ -671,15 +632,24 @@ mod tests {
let sample = json!({"eb:YES:mid-example":"0.085","eb:NO:mid-example":"0.915"});
let pair = json!({"eb:YES:s":"0.4","eb:NO:s":"0.6","eb:YES:one":"0.6"});
let price_batch = json!({"eb:YES:mid-example":{"BUY":"0.08","SELL":"0.09"},"eb:NO:mid-example":{"BUY":"0.91"},"eb:YES:one":{"BUY":"0.2"}});
db.execute(json!({"op":"publish_clarification","id":"note","market":market,"content":"Map one includes overtime.","clear_book":false})).unwrap();
db.execute(json!({"op":"publish_clarification","id":"note","market":market,"content":"Map one includes overtime.","clear_book":false,"tx_hash":transaction})).unwrap();
let note = db
.execute(json!({"op":"resolution","market":market}))
.unwrap()["clarifications"]
.clone();
assert_eq!(note[0]["questionId"], question);
assert_eq!(note[0]["txHash"], transaction);
assert_eq!(note[0]["state"], "success");
let note_id = note[0]["marketId"].as_i64().unwrap();
let note_query = format!(
"/market-clarifications?market_id=9999&market_id={note_id}&order=id&ascending=true"
);
let note_by_question = format!(
"/market-clarifications?question_id=unknown&question_id=0x{}&tx_hash={transaction}&order=createdAt,id",
question[2..].to_ascii_uppercase()
);
let note_wrong_hash =
format!("/market-clarifications?question_id={question}&tx_hash=unknown");
for command in include_str!("../../../docs/examples/topic.jsonl")
.lines()
.take(3)
@@ -728,10 +698,6 @@ mod tests {
("GET","/v2/oi",String::new(),503,None),
("POST","/v2/oi",String::new(),405,None),
("GET","/v2/value?user=0x0000000000000000000000000000000000000001",String::new(),200,Some(json!({"data":{"proxy_wallet":"0x0000000000000000000000000000000000000001","value":0}}))),
("GET","/v2/positions?user=0x0000000000000000000000000000000000000001",String::new(),200,Some(json!({"data":[],"pagination":{"limit":100,"offset":0,"has_more":false,"next_cursor":null}}))),
("GET","/v2/positions",String::new(),400,None),
("GET","/v2/positions?user=unpriced-owner&cursor=invalid",String::new(),400,None),
("POST","/v2/positions",String::new(),405,None),
("GET","/v2/value",String::new(),400,None),
("GET","/v2/value?user=unpriced-owner",String::new(),503,None),
("GET","/v2/value?user=a&condition=",String::new(),400,None),
@@ -740,11 +706,6 @@ mod tests {
("GET","/v2/trades?user=unknown&conditionId=unknown&takerOnly=false",String::new(),200,Some(empty_trades)),
("GET","/v2/trades?offset=2",String::new(),400,None),
("GET","/v2/trades?cursor=invalid",String::new(),400,None),
("GET","/v2/holders",String::new(),400,Some(json!({"code":"invalid_request","error":"required query param 'condition' not provided","parameter":"condition","retryable":false}))),
("GET","/v2/holders?condition=s&limit=0",String::new(),200,Some(json!({"data":[],"pagination":{"limit":0,"offset":0,"has_more":false,"next_cursor":null}}))),
("GET","/v2/holders?condition=s&includePnl=true&limit=101",String::new(),400,Some(json!({"code":"invalid_request","error":"limit must be at most 100 with include_pnl","parameter":"limit","retryable":false}))),
("GET","/v2/holders?condition=s&offset=0",String::new(),400,None),
("POST","/v2/holders","{}".into(),405,None),
("GET","/v2/resolutions?condition=unknown",String::new(),200,Some(json!({"data":[]}))),
("GET","/v2/resolutions?condition=m&eventId=1",String::new(),400,None),
("GET","/v2/resolutions?questionId=invalid",String::new(),400,None),
@@ -769,11 +730,14 @@ mod tests {
("GET","/events/999999",String::new(),404,None),
("POST","/events/slug/test","{}".into(),405,None),
("GET","/market-clarifications?event_id=1&event_id=2",String::new(),200,Some(json!([]))),
("GET","/market-clarifications?event_id=0",String::new(),400,None),
("GET",note_query.as_str(),String::new(),200,Some(note)),
("GET","/market-clarifications?limit=0",String::new(),200,Some(json!([]))),
("GET","/market-clarifications?event_id=0",String::new(),422,Some(json!({"type":"validation error","error":"error validating query argument \"event_id\": invalid integer value"}))),
("GET","/market-clarifications?order=created_at",String::new(),422,Some(json!({"type":"validation error","error":"order fields are not valid"}))),
("GET",note_by_question.as_str(),String::new(),200,Some(note.clone())),
("GET",note_wrong_hash.as_str(),String::new(),200,Some(json!([]))),
("GET",note_query.as_str(),String::new(),200,Some(note.clone())),
("GET","/market-clarifications?limit=0",String::new(),200,Some(note.clone())),
("GET","/market-clarifications?offset=1",String::new(),200,Some(json!([]))),
("GET","/market-clarifications?limit=101",String::new(),400,None),
("GET","/market-clarifications?limit=101",String::new(),200,Some(note)),
("POST","/market-clarifications","{}".into(),405,None),
("GET","/prices-history?market=eb:YES:missing&interval=1h&fidelity=10",String::new(),200,Some(json!({"history":[]}))),
("GET","/prices-history?market=eb:NO:missing&startTs=1000&endTs=2000",String::new(),200,Some(json!({"history":[]}))),
@@ -797,14 +761,6 @@ mod tests {
("POST","/prices",json!([{"token_id":"eb:YES:s"}]).to_string(),200,Some(json!({"eb:YES:s":{"SELL":"0.41"}}))),
("POST","/prices",json!(vec![json!({"token_id":"eb:YES:s","side":"BUY"}); MAX_BOOKS+1]).to_string(),400,None),
("DELETE","/prices",String::new(),405,None),
("GET","/book?token_id=eb:YES:resolved-test",String::new(),404,Some(json!({"error":MISSING}))),
("GET","/price?token_id=eb:YES:resolved-test&side=BUY",String::new(),404,Some(json!({"error":MISSING}))),
("GET","/midpoint?token_id=eb:NO:resolved-test",String::new(),404,Some(json!({"error":MISSING}))),
("GET","/spread?token_id=eb:NO:resolved-test",String::new(),404,Some(json!({"error":MISSING}))),
("POST","/books",json!([{"token_id":"eb:YES:resolved-test"},{"token_id":yes}]).to_string(),200,Some(json!([expected_yes.clone()]))),
("POST","/prices",json!([{"token_id":"eb:YES:resolved-test","side":"BUY"},{"token_id":"eb:YES:s","side":"BUY"}]).to_string(),200,Some(json!({"eb:YES:s":{"BUY":"0.39"}}))),
("POST","/midpoints",json!([{"token_id":"eb:YES:resolved-test"},{"token_id":"eb:YES:s"}]).to_string(),200,Some(json!({"eb:YES:s":"0.4"}))),
("POST","/spreads",json!([{"token_id":"eb:YES:resolved-test"}]).to_string(),200,Some(json!({}))),
("GET","/midpoint?token_id=eb:YES:mid-example",String::new(),200,Some(json!({"mid":"0.085"}))),
("POST","/midpoints",json!([{"token_id":"eb:YES:mid-example"},{"token_id":"eb:NO:mid-example"}]).to_string(),200,Some(sample)),
("GET","/midpoint?token_id=eb:YES:s",String::new(),200,Some(json!({"mid":"0.4"}))),
+6 -43
View File
@@ -716,18 +716,6 @@ sequenceDiagram
E-->>C: 返回该结果资产的旧步长、新步长、时间和游标
```
公开榜单经 `holders/http.rs` 复用同一排名与估值。毛持仓模式中,`portfolio/economics.sql` 回读本页账户的成交与钱包操作,`portfolio/economics.rs` 计算成本和盈亏。账本顺序由 `portfolio/economics_schema.sql` 的触发器记录。同一毫秒发生的成交和持仓操作也能按写入顺序重放。账户持仓和毛持仓榜使用同一份成本。部分卖出按份额摊销剩余本金和入场费用,费用在对应份额卖出或赎回时计入已实现盈亏。旧数据缺少明确顺序或转换成本时,相关经济字段返回 null。
```mermaid
flowchart LR
H["holders/http.rs"] --> L["holders.rs / holders.sql"]
P["portfolio/positions.rs"] --> E["portfolio/economics.rs"]
H --> E
E --> Q["portfolio/economics.sql"]
Q --> S["portfolio/economics_schema.sql"]
I["lib.rs · Exchange::open"] --> S
```
### 体育赛事开赛撤单
```mermaid
@@ -1119,7 +1107,7 @@ sequenceDiagram
E->>D: 先处理到期订单,再从同一快照读取各市场最新 quote_events
D-->>E: 返回 YES 的买一和卖一
E->>E: 换算结果方向,缺买盘取 0、缺卖盘取 1,计算价差或中点
E-->>C: 按结果资产索引,跳过未上市和已裁决资产
E-->>C: 按结果资产索引,未上市资产无条目
```
HTTP 盘口查询由 public_book_prices 读取 quote_events,先清理到期任务,再在同一快照中读取各市场。BUY 取买一,SELL 取卖一。下单面板的 JSONL 命令继续查询最优对手价。
@@ -1145,7 +1133,7 @@ flowchart LR
L --> A["assets.rs"]
L --> Q["prices_history/legacy.sql"]
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
Q --> S["schema.sql 中的 price_settlements"]
```
@@ -1157,7 +1145,7 @@ sequenceDiagram
participant D as SQLite
C->>E: clob_price_history
E->>D: 清理到期委托并取得读快照与数据库时钟
E->>D: 按 UTC 分钟网格重放盘口,封盘后只取窗口内的封盘前样本
E->>D: 按 UTC 分钟网格重放各采样点当时的盘口,再读取最近可用点
D-->>E: 观测时间和定点价格
E-->>C: t 为 Unix 秒,p 为十进制数
```
@@ -1169,7 +1157,7 @@ flowchart LR
C["command.rs"] --> M["market.rs"]
M --> N["clarifications.rs"]
N --> B["market.rs · clear_orders"] --> L["book.rs · release"]
N --> S["schema.sql · market_clarifications"]
N --> S["schema.sql · market_clarifications / clarification_transactions / resolution_questions"]
R["resolution.rs"] --> N
I["lib.rs · open"] --> D["event_directory_schema.sql"]
A["catalog.rs · event / events / catalog"] --> D
@@ -1183,14 +1171,14 @@ sequenceDiagram
participant D as SQLite
participant B as 常驻盘口
O->>E: publish_clarification,携带请求 ID
E->>D: 同一事务中保存原文和 clear_book
E->>D: 同一事务中保存原文、clear_book 和可选 tx_hash
opt 清盘
E->>D: 撤销本市场所有存续委托,返还剩余现金或份额
end
E->>D: 保存回执并提交
E->>B: 应用已提交的订单变更
O->>E: 按事件目录 ID 查询公告
E->>D: 匹配体育盘或主题盘口,取市场过滤交集后翻页
E->>D: 关联事件目录、市场裁决问题和公告交易哈希,求交集后翻页
D-->>E: 已筛选的公告
E-->>O: 该页公告
O->>E: resolution
@@ -1446,28 +1434,3 @@ sequenceDiagram
E-->>C: 返回本次两侧销毁量和实付金额
end
```
### 公开持仓生命周期
```mermaid
flowchart LR
cli["cli/market_http.rs"] --> positions["portfolio/positions.rs"]
positions --> sql["portfolio/positions.sql"]
sql --> activity["成交、钱包流水及分侧赎回时间"]
positions --> mark["portfolio.rs 中的估值"]
positions --> cost["portfolio/economics.rs"]
cost --> fills["portfolio/economics.sql"]
```
```mermaid
sequenceDiagram
participant H as HTTP
participant P as public_positions
participant D as SQLite
H->>P: 钱包或市场、持仓状态和游标
P->>D: 清理到期任务并读取同一快照中的仓位与市场
D-->>P: 持仓、配对份额、裁决、目录及活动时间
P->>P: 按有效排序键保留一页、签署下一页游标
P-->>H: data 和 pagination
```
+4 -6
View File
@@ -45,7 +45,7 @@ impl Snapshot {
fn build(tx: &Transaction, books: &Books, token: &str) -> Result<Snapshot> {
let (outcome, market) = assets::parse_id(token)?;
find(tx, books, token, outcome, market, false)?
find(tx, books, token, outcome, market)?
.context("No orderbook exists for the requested token id")
}
@@ -55,14 +55,12 @@ fn find(
token: &str,
outcome: &str,
market: &str,
public_only: bool,
) -> Result<Option<Snapshot>> {
let row: Option<(i64, bool)> = tx
.query_row(
"SELECT at_ms,EXISTS(SELECT 1 FROM neg_risk_members WHERE market=?1)
FROM book_snapshot_times b JOIN markets m ON m.id=b.market
WHERE b.market=?1 AND (NOT ?2 OR m.phase<>'resolved')",
rusqlite::params![market, public_only],
FROM book_snapshot_times WHERE market=?1",
[market],
|r| Ok((r.get(0)?, r.get(1)?)),
)
.optional()?;
@@ -116,7 +114,7 @@ pub(crate) fn read_many(
let mut result = Vec::with_capacity(tokens.len());
for token in tokens {
if let Ok((outcome, market)) = assets::parse_id(token) {
if let Some(book) = find(tx, books, token, outcome, market, true)? {
if let Some(book) = find(tx, books, token, outcome, market)? {
result.push(serde_json::to_value(book)?);
}
}
+184 -23
View File
@@ -8,6 +8,7 @@ pub(crate) fn publish(
market: &str,
content: &str,
clear_book: bool,
tx_hash: Option<&str>,
) -> Result<Value> {
phase(tx, market, &["preopen", "continuous", "closed"])?;
ensure!(!content.trim().is_empty(), "clarification text required");
@@ -16,6 +17,16 @@ pub(crate) fn publish(
params![market, content, clear_book],
)?;
let id = tx.last_insert_rowid();
if let Some(hash) = tx_hash {
ensure!(
crate::validation::hex_id(hash, 64),
"invalid clarification tx_hash"
);
tx.execute(
"INSERT INTO clarification_transactions(clarification,tx_hash) VALUES(?1,?2)",
params![id, hash],
)?;
}
let canceled = if clear_book {
market::clear_orders(tx, market)?
} else {
@@ -24,46 +35,198 @@ pub(crate) fn publish(
Ok(json!({"id":id,"market":market,"clearBook":clear_book,"canceled_count":canceled}))
}
fn read(
db: &Connection,
market: Option<&str>,
ids: &[i64],
event_ids: &[i64],
pub struct ClarificationQuery {
market_ids: Vec<i64>,
event_ids: Vec<i64>,
question_ids: Vec<String>,
tx_hash: Option<String>,
sort_columns: Vec<&'static str>,
limit: i64,
offset: i64,
ascending: bool,
}
impl ClarificationQuery {
pub fn parse(fields: &[(String, String)]) -> Result<Self, &'static str> {
let values = |key: &'static str| {
fields
.iter()
.filter(move |(name, _)| name == key)
.map(|(_, value)| value.as_str())
};
let integer = |key, default| {
values(key).next().map_or(Ok(default), |value| {
value.parse::<i64>().map_err(|_| "invalid integer")
})
};
let ids = |key, invalid| {
values(key)
.map(|value| {
let id = value.parse::<i64>().map_err(|_| "invalid integer")?;
if id <= 0 {
return Err(invalid);
}
Ok(id)
})
.collect::<Result<Vec<_>, _>>()
};
let sort_columns = values("order")
.next()
.unwrap_or_default()
.split(',')
.map(str::trim)
.filter(|key| !key.is_empty())
.map(order_column)
.collect::<Result<Vec<_>, _>>()?;
let ascending = match values("ascending").next() {
None | Some("1" | "t" | "T" | "true" | "TRUE" | "True") => true,
Some("0" | "f" | "F" | "false" | "FALSE" | "False") => false,
Some(_) => return Err("invalid boolean"),
};
let limit = integer("limit", 50)?;
Ok(Self {
market_ids: ids(
"market_id",
"error validating query argument \"market_id\": invalid integer value",
)?,
event_ids: ids(
"event_id",
"error validating query argument \"event_id\": invalid integer value",
)?,
question_ids: values("question_id")
.filter(|id| !id.is_empty())
.map(str::to_ascii_lowercase)
.collect(),
tx_hash: values("tx_hash")
.next()
.filter(|hash| !hash.is_empty())
.map(str::to_owned),
sort_columns,
limit: if limit <= 0 { 50 } else { limit.min(100) },
offset: integer("offset", 0)?.max(0),
ascending,
})
}
fn by_id(
market_ids: &[i64],
event_ids: &[i64],
limit: i64,
offset: i64,
ascending: bool,
) -> Self {
Self {
market_ids: market_ids.to_vec(),
event_ids: event_ids.to_vec(),
question_ids: Vec::new(),
tx_hash: None,
sort_columns: vec!["n.id"],
limit,
offset,
ascending,
}
}
}
fn order_column(key: &str) -> Result<&'static str, &'static str> {
match key {
"id" => Ok("n.id"),
"marketId" => Ok("d.id"),
"eventId" => Ok("e.id"),
"questionId" => Ok("q.question_id"),
"content" => Ok("n.content"),
"clearBook" => Ok("n.clear_book"),
"createdAt" => Ok("n.created_at"),
"txHash" => Ok("x.tx_hash"),
"state" | "notifyDiscord" | "showInFrontend" | "adapterAddress" | "negRiskRequestId"
| "queuedAt" | "scheduledFor" | "txTimestamp" => Ok("NULL"),
_ => Err("order fields are not valid"),
}
}
fn read(
db: &Connection,
market: Option<&str>,
query: &ClarificationQuery,
) -> rusqlite::Result<Vec<Value>> {
let ids_json = json!(ids).to_string();
let events_json = json!(event_ids).to_string();
let order = if ascending { "ASC" } else { "DESC" };
let ids_json = json!(query.market_ids).to_string();
let events_json = json!(query.event_ids).to_string();
let questions_json = json!(query.question_ids).to_string();
let (order, nulls) = if query.ascending {
("ASC", "LAST")
} else {
("DESC", "FIRST")
};
let ordering = query
.sort_columns
.iter()
.copied()
.chain(["n.id"])
.map(|column| format!("{column} {order} NULLS {nulls}"))
.collect::<Vec<_>>()
.join(", ");
let sql = format!(
"SELECT n.id,d.id,n.content,n.clear_book,n.created_at
"SELECT n.id,d.id,n.content,n.clear_book,n.created_at,e.id,q.question_id,x.tx_hash
FROM market_clarifications n JOIN market_directory_ids d ON d.market=n.market
LEFT JOIN sports_markets s ON s.market=n.market
LEFT JOIN topic_markets t ON t.market=n.market
LEFT JOIN event_directory_ids e ON e.event=COALESCE(s.event,t.event)
LEFT JOIN resolution_questions q ON q.market=n.market
LEFT JOIN clarification_transactions x ON x.clarification=n.id
WHERE (?1 IS NULL OR n.market=?1)
AND (?2='[]' OR d.id IN (SELECT value FROM json_each(?2)))
AND (?3='[]' OR e.id IN (SELECT value FROM json_each(?3)))
ORDER BY n.id {order} LIMIT ?4 OFFSET ?5"
AND (?4='[]' OR q.question_id IN (SELECT value FROM json_each(?4)))
AND (?5 IS NULL OR x.tx_hash=?5)
ORDER BY {ordering} LIMIT ?6 OFFSET ?7"
);
let mut stmt = db.prepare_cached(&sql)?;
let rows = stmt.query_map(params![market, ids_json, events_json, limit, offset], |r| {
Ok(
json!({"id":r.get::<_,i64>(0)?,"marketId":r.get::<_,i64>(1)?,
"content":r.get::<_,String>(2)?,"clearBook":r.get::<_,bool>(3)?,
"createdAt":r.get::<_,String>(4)?,"showInFrontend":true,
"txTimestamp":null,"txHash":null}),
)
})?;
let rows = stmt.query_map(
params![
market,
ids_json,
events_json,
questions_json,
query.tx_hash,
query.limit,
query.offset
],
|r| {
let mut row = json!({
"id":r.get::<_,i64>(0)?, "marketId":r.get::<_,i64>(1)?,
"content":r.get::<_,String>(2)?, "clearBook":r.get::<_,bool>(3)?,
"createdAt":r.get::<_,String>(4)?, "showInFrontend":true, "state":"success",
"notifyDiscord":false,
"txTimestamp":null, "txHash":r.get::<_,Option<String>>(7)?
});
if let Some(event) = r.get::<_, Option<i64>>(5)? {
row["eventId"] = json!(event);
}
if let Some(question) = r.get::<_, Option<String>>(6)? {
row["questionId"] = json!(question);
}
Ok(row)
},
)?;
rows.collect()
}
pub(crate) fn for_resolution(db: &Connection, market: &str) -> rusqlite::Result<Vec<Value>> {
read(db, Some(market), &[], &[], -1, 0, true)
read(
db,
Some(market),
&ClarificationQuery::by_id(&[], &[], -1, 0, true),
)
}
impl Exchange {
pub fn gamma_clarifications(
&self,
query: &ClarificationQuery,
) -> Result<Vec<Value>, MarketDataError> {
Ok(read(&self.db, None, query)?)
}
pub fn market_clarifications(
&self,
ids: &[i64],
@@ -87,14 +250,12 @@ impl Exchange {
"invalid clarification filter".into(),
));
}
Ok(read(
&self.db,
None,
self.gamma_clarifications(&ClarificationQuery::by_id(
ids,
event_ids,
i64::from(limit),
offset,
ascending,
)?)
))
}
}
+1
View File
@@ -49,6 +49,7 @@ pub(crate) enum Command {
market: String,
content: String,
clear_book: bool,
tx_hash: Option<String>,
},
Clarify {
market: String,
+8 -17
View File
@@ -1,5 +1,3 @@
pub(crate) mod http;
use crate::{assets, portfolio, validation::identifier};
use anyhow::{ensure, Context, Result};
use rusqlite::{params, Connection};
@@ -129,22 +127,9 @@ impl Request {
pub fn read(self, db: &Connection) -> Result<Value> {
let mut page = self.page()?;
let (data, more) = page.read(db)?;
page.offset = page
.offset
.checked_add(i64::from(page.limit))
.context("holders offset overflow")?;
let cursor = more.then(|| serde_json::to_string(&page)).transpose()?;
Ok(json!({"basis":page.basis,"data":data,"next_cursor":cursor}))
}
}
impl Page {
fn read(&self, db: &Connection) -> Result<(Vec<Value>, bool)> {
let page = self;
let minimum = minimum_units(&page.min_balance)?;
if page.limit == 0 || minimum.is_none() {
return Ok((Vec::new(), false));
return Ok(json!({"basis":page.basis,"data":[],"next_cursor":null}));
}
let end = page
.offset
@@ -201,6 +186,12 @@ impl Page {
data.push(json!({"market":market,"asset_id":assets::id(market,outcome),"outcome":outcome,"holders":holders}));
}
}
Ok((data, more))
page.offset = end;
let cursor = if more {
Some(serde_json::to_string(&page)?)
} else {
None
};
Ok(json!({"basis":page.basis,"data":data,"next_cursor":cursor}))
}
}
-235
View File
@@ -1,235 +0,0 @@
use super::{minimum_units, Basis, Page};
use crate::{
inventory::{decimal, UNIT},
portfolio::economics::{round_money, Economics, HOLDER_FIELDS},
validation::{condition_filter, hex_id},
Exchange, MarketDataError,
};
use anyhow::{ensure, Context, Result};
use data_encoding::BASE64URL_NOPAD;
use hmac::{Hmac, Mac};
use rusqlite::{Connection, OptionalExtension};
use serde::{Deserialize, Serialize};
use serde_json::{json, Number, Value};
use sha2::Sha256;
#[derive(Deserialize)]
pub struct HoldersQuery {
#[serde(alias = "condition_id", alias = "conditionId")]
condition: Option<String>,
limit: Option<u32>,
cursor: Option<String>,
#[serde(alias = "minBalance")]
min_balance: Option<String>,
#[serde(alias = "includePnl")]
include_pnl: Option<bool>,
offset: Option<String>,
#[serde(alias = "market_id", alias = "marketId")]
market: Option<String>,
}
#[derive(Serialize, Deserialize)]
struct Window {
limit: u32,
offset: i64,
}
fn cursor_mac(db: &Connection) -> Result<Hmac<Sha256>> {
let secret: Vec<u8> = db.query_row(
"SELECT secret FROM trade_cursor_key WHERE singleton=1",
[],
|r| r.get(0),
)?;
let mut mac = Hmac::<Sha256>::new_from_slice(&secret).expect("HMAC accepts any key length");
mac.update(b"eventbook:/v2/holders:v1\0");
Ok(mac)
}
impl Window {
fn decode(db: &Connection, token: &str) -> Result<Self> {
ensure!(token.len() <= 256, "invalid cursor");
let bytes = BASE64URL_NOPAD
.decode(token.as_bytes())
.context("invalid cursor")?;
let split = bytes.len().checked_sub(32).context("invalid cursor")?;
let (payload, signature) = bytes.split_at(split);
let mut mac = cursor_mac(db)?;
mac.update(payload);
mac.verify_slice(signature)
.map_err(|_| anyhow::anyhow!("invalid cursor"))?;
Ok(serde_json::from_slice(payload).context("invalid cursor")?)
}
fn encode(&self, db: &Connection) -> Result<String> {
let mut bytes = serde_json::to_vec(self)?;
let mut mac = cursor_mac(db)?;
mac.update(&bytes);
bytes.extend_from_slice(&mac.finalize().into_bytes());
Ok(BASE64URL_NOPAD.encode(&bytes))
}
}
fn wire_group(group: &Value, economics: Option<&Economics>) -> Result<Value> {
let outcome = group["outcome"]
.as_str()
.context("missing holder outcome")?;
let token = group["asset_id"].as_str().context("missing holder token")?;
let index = if outcome == "YES" { 0 } else { 1 };
let holders = group["holders"].as_array().context("missing holder rows")?;
let holders = holders
.iter()
.map(|holder| -> Result<Value> {
let account = holder["account"]
.as_str()
.context("missing holder wallet")?;
let amount = holder["amount"]
.as_number()
.context("missing holder amount")?;
let mut row = json!({
"proxy_wallet":account,"amount":amount,"token_id":token,"outcome_index":index,
"bio":"","name":"","pseudonym":"","profile_image":"","profile_image_optimized":"",
"display_username_public":false,"verified":false
});
if let Some(economics) = economics {
let mark = holder["current_price_micros"].as_i64().map(i128::from);
let value = holder["current_value_micros"].as_i64().map(i128::from);
let units = minimum_units(amount)?.context("holder amount overflow")?;
row["current_price"] = json!(mark.map(|p| decimal(p, UNIT)));
row["current_value"] = json!(value.map(|p| decimal(round_money(p), UNIT)));
let fields = economics
.cost(account, outcome, units)
.map(|cost| cost.fields(value, true));
for field in HOLDER_FIELDS {
row[field] = fields
.as_ref()
.map_or(Value::Null, |values| values[field].clone());
}
}
Ok(row)
})
.collect::<Result<Vec<_>>>()?;
Ok(json!({"token_id":token,"holders":holders}))
}
impl HoldersQuery {
fn read(self, db: &Connection) -> Result<Value> {
ensure!(self.offset.is_none(), "'offset' is not a query param on this API: pages are cursor-only, pass 'cursor' from a prior response's next_cursor");
ensure!(self.market.is_none(), "'market' is not a query param on this API: filter by condition id with 'condition' (aliases 'condition_id', 'conditionId')");
let conditions = self
.condition
.as_deref()
.filter(|s| !s.trim().is_empty())
.context("required query param 'condition' not provided")?;
let ids = condition_filter(Some(conditions), db)
.map_err(|error| match error {
MarketDataError::Invalid(message) => anyhow::anyhow!(
"{}",
message.replacen("invalid condition:", "invalid condition id:", 1)
),
MarketDataError::Unavailable => anyhow::Error::new(rusqlite::Error::InvalidQuery),
})?
.context("required query param 'condition' not provided")?;
let mut markets: Vec<String> = serde_json::from_str(&ids)?;
let gross = self.include_pnl.unwrap_or(false);
ensure!(
!gross || markets.len() == 1,
"include_pnl accepts exactly one 'condition' per call"
);
for market in &mut markets {
if hex_id(market, 64) {
let canonical = db
.query_row(
"SELECT id FROM markets WHERE id=? COLLATE NOCASE ORDER BY id LIMIT 1",
[&*market],
|r| r.get(0),
)
.optional()?;
if let Some(id) = canonical {
*market = id;
}
}
}
let raw_limit = self.limit.unwrap_or(100);
ensure!(
raw_limit <= 1000,
"Failed to deserialize query string: limit: limit must be between 0 and 1000"
);
let window = self
.cursor
.as_deref()
.map(|cursor| Window::decode(db, cursor))
.transpose()?
.unwrap_or(Window {
limit: raw_limit,
offset: 0,
});
ensure!(
!gross || window.limit <= 100,
"limit must be at most 100 with include_pnl"
);
let min_balance = self
.min_balance
.as_deref()
.filter(|raw| !raw.trim().is_empty())
.map(|raw| raw.trim().parse::<Number>().context("invalid min_balance"))
.transpose()?
.filter(|number| !number.to_string().starts_with('-'))
.unwrap_or_else(|| 0.into());
let page = Page {
markets,
basis: if gross { Basis::Gross } else { Basis::Net },
min_balance,
limit: window.limit,
offset: window.offset,
};
let (groups, more) = page.read(db)?;
let economics = if gross && !groups.is_empty() {
let accounts: Vec<_> = groups
.iter()
.filter_map(|g| g["holders"].as_array())
.flatten()
.filter_map(|h| h["account"].as_str())
.collect();
Some(Economics::read(db, &page.markets[0], &accounts)?)
} else {
None
};
let data = groups
.iter()
.map(|group| wire_group(group, economics.as_ref()))
.collect::<Result<Vec<_>>>()?;
let next = if more {
let offset = window
.offset
.checked_add(i64::from(window.limit))
.context("holders offset overflow")?;
Some(
Window {
limit: window.limit,
offset,
}
.encode(db)?,
)
} else {
None
};
Ok(json!({"data":data,"pagination":{
"limit":window.limit,"offset":window.offset,"has_more":more,"next_cursor":next
}}))
}
}
impl Exchange {
pub fn public_holders(&self, query: HoldersQuery) -> Result<Value, MarketDataError> {
let tx = self.db.unchecked_transaction()?;
let result = query.read(&tx).map_err(|error| {
if error.downcast_ref::<rusqlite::Error>().is_some() {
MarketDataError::Unavailable
} else {
MarketDataError::Invalid(error.to_string())
}
})?;
tx.commit()?;
Ok(result)
}
}
+2 -10
View File
@@ -49,13 +49,12 @@ use serde_json::{json, Map, Value};
use std::{path::Path, time::Duration};
pub use assets::parse_id as parse_asset_id;
pub use clarifications::ClarificationQuery;
pub use depth_feed::MarketPage;
pub use gamma_directory::DirectoryKey;
pub use gamma_list::DirectoryResource;
pub use holders::http::HoldersQuery;
pub use open_interest::InterestQuery;
pub use portfolio::http::ValueQuery;
pub use portfolio::positions::PositionQuery;
pub use prices_history::http::HistoryQuery;
pub use prices_history::legacy::ClobHistoryQuery;
pub use public_trades::http::TradeQuery;
@@ -123,7 +122,7 @@ impl Exchange {
db.execute_batch(include_str!("quote_schema.sql"))?;
}
let history_ready: bool = db.query_row(
"SELECT EXISTS(SELECT 1 FROM sqlite_schema WHERE type='trigger' AND name='chart_market_closed')",
"SELECT EXISTS(SELECT 1 FROM sqlite_schema WHERE type='trigger' AND name='chart_market_listed')",
[], |r| r.get(0),
)?;
if !history_ready {
@@ -137,13 +136,6 @@ impl Exchange {
db.execute_batch(include_str!("valuation_schema.sql"))?;
}
lots::migrate(&mut db)?;
let economics_order_ready: bool = db.query_row(
"SELECT EXISTS(SELECT 1 FROM sqlite_schema WHERE type='trigger' AND name='cost_order_wallet')",
[], |r| r.get(0),
)?;
if !economics_order_ready {
db.execute_batch(include_str!("portfolio/economics_schema.sql"))?;
}
let snapshot_ready: bool = db.query_row(
"SELECT EXISTS(SELECT 1 FROM sqlite_schema WHERE type='table' AND name='book_snapshot_times')", [], |r| r.get(0))?;
if !snapshot_ready {
+2 -14
View File
@@ -131,7 +131,8 @@ pub(crate) fn apply(
market,
content,
clear_book,
} => crate::clarifications::publish(tx, &market, &content, clear_book),
tx_hash,
} => crate::clarifications::publish(tx, &market, &content, clear_book, tx_hash.as_deref()),
Command::Clarify {
market,
name,
@@ -479,19 +480,6 @@ fn redeem(
request_id: &str,
amounts: Option<[i64; 2]>,
) -> Result<i64> {
tx.execute(
"INSERT INTO position_redemption_times(account,market,outcome,at_ms)
SELECT account,market,outcome,CAST(unixepoch('subsec')*1000 AS INTEGER)
FROM position_units WHERE account=?1 AND market=?2 AND available>0
AND (?3 IS NULL OR CASE outcome WHEN 'YES' THEN ?3 ELSE ?4 END>0)
ON CONFLICT(account,market,outcome) DO UPDATE SET at_ms=excluded.at_ms",
params![
account,
market,
amounts.map(|a| a[0]),
amounts.map(|a| a[1])
],
)?;
let (shares, paid) = match amounts {
Some(amounts) => crate::neg_risk::burn_for_redemption(tx, market, account, amounts)?,
None => burn_full_balance(tx, market, account)?,
-2
View File
@@ -1,6 +1,4 @@
pub(crate) mod economics;
pub(crate) mod http;
pub(crate) mod positions;
mod protocol;
use crate::{
-283
View File
@@ -1,283 +0,0 @@
use crate::inventory::{decimal, UNIT};
use rusqlite::{params, Connection, Row};
use serde_json::{json, Value};
use std::collections::HashMap;
#[derive(Clone, Default)]
pub(crate) struct Cost {
units: i128,
cost: i128,
realized: i128,
acquired: i128,
lifetime_principal: i128,
bought: i128,
entry_fees: i128,
}
impl Cost {
fn acquire(&mut self, units: i128, cost: i128, fee: i128, from_trade: bool) -> bool {
if units <= 0
|| !(0..=units).contains(&cost)
|| fee < 0
|| self.units + units > i128::from(i64::MAX)
|| self.entry_fees + fee > i128::from(i64::MAX)
{
return false;
}
self.units += units;
self.cost += cost;
self.acquired += units;
self.lifetime_principal += cost;
self.entry_fees += fee;
if from_trade {
self.bought += units;
}
true
}
fn dispose(&mut self, units: i128, proceeds: i128) -> bool {
if units < 0 || units > self.units {
return false;
}
if units > 0 {
let removed = self.cost * units / self.units;
self.cost -= removed;
let fees = self.entry_fees * units / self.units;
self.entry_fees -= fees;
self.units -= units;
self.realized += proceeds - removed - fees;
}
true
}
}
pub(super) const POSITION_FIELDS: [&str; 10] = [
"avg_price",
"total_size",
"entry_cost_usdc",
"entry_fees_usdc",
"total_cost_usdc",
"realized_pnl",
"unrealized_pnl",
"total_pnl",
"percent_pnl",
"percent_realized_pnl",
];
pub(crate) const HOLDER_FIELDS: [&str; 5] = [
"avg_price",
"entry_cost_usdc",
"realized_pnl",
"unrealized_pnl",
"total_pnl",
];
pub(crate) fn round_money(micros: i128) -> i128 {
micros.signum() * ((micros.abs() + 50) / 100) * 100
}
fn percentage(delta: i128, basis: i128) -> Option<serde_json::Number> {
(basis > 0).then_some(())?;
Some(decimal(delta.checked_mul(i128::from(UNIT))? / basis, 10000))
}
impl Cost {
fn avg_price(&self, include_fees: bool) -> Option<i128> {
let (principal, units) = if self.units > 0 {
(
self.cost + if include_fees { self.entry_fees } else { 0 },
self.units,
)
} else {
(self.lifetime_principal, self.acquired)
};
(units > 0).then_some(())?;
Some(principal.checked_mul(i128::from(UNIT))? / units / 100 * 100)
}
fn realized_pnl(&self) -> i128 {
round_money(self.realized)
}
fn unrealized_pnl(&self, value: Option<i128>) -> Option<i128> {
value.map(|mark| round_money(mark - self.cost))
}
fn total_pnl(&self, value: Option<i128>) -> Option<i128> {
self.unrealized_pnl(value).map(|p| p + self.realized_pnl())
}
fn historical_basis(&self) -> Option<i128> {
if self.units > 0 {
Some(self.cost.checked_mul(self.bought)? / self.units)
} else {
Some(self.lifetime_principal.checked_mul(self.bought)? / self.acquired)
}
}
pub(crate) fn fields(&self, value: Option<i128>, holder: bool) -> Value {
let basis = round_money(self.cost);
let mut fields = json!({
"avg_price": self.avg_price(holder).map(|v| decimal(v,UNIT)),
"entry_cost_usdc": decimal(basis,UNIT),
"realized_pnl": decimal(self.realized_pnl(),UNIT),
"unrealized_pnl": self.unrealized_pnl(value).map(|v| decimal(v,UNIT)),
"total_pnl": self.total_pnl(value).map(|v| decimal(v,UNIT))
});
if !holder {
fields["total_size"] = json!(decimal(self.bought, UNIT));
fields["entry_fees_usdc"] = json!(decimal(self.entry_fees, UNIT));
fields["total_cost_usdc"] = json!(decimal(basis + self.entry_fees, UNIT));
fields["percent_pnl"] = json!(value.and_then(|v| percentage(v - self.cost, self.cost)));
fields["percent_realized_pnl"] = json!(value
.zip(self.historical_basis())
.and_then(|(v, b)| percentage(v - b, b)));
}
fields
}
}
#[derive(Clone, Copy)]
pub(super) enum Metric {
Average,
Realized,
Unrealized,
Total,
}
impl Metric {
pub(super) fn parse(sort: &str) -> Option<Self> {
match sort {
"AVG_PRICE" => Some(Self::Average),
"REALIZED_PNL" => Some(Self::Realized),
"UNREALIZED_PNL" => Some(Self::Unrealized),
"TOTAL_PNL" => Some(Self::Total),
_ => None,
}
}
pub(super) fn rank(self, cost: &Cost, value: Option<i128>) -> Option<i128> {
match self {
Self::Average => cost.avg_price(false),
Self::Realized => Some(cost.realized_pnl()),
Self::Unrealized => cost.unrealized_pnl(value),
Self::Total => cost.total_pnl(value),
}
}
}
#[derive(Default)]
struct Account {
sides: [Cost; 2],
incomplete: bool,
last_legacy: Option<(i64, i64)>,
}
fn side_index(outcome: &str) -> Option<usize> {
match outcome {
"YES" => Some(0),
"NO" => Some(1),
_ => None,
}
}
impl Account {
fn apply(&mut self, row: &Row<'_>, payout: [i128; 2]) -> rusqlite::Result<bool> {
let operation: String = row.get(4)?;
let shares = row.get::<_, Option<i64>>(6)?.map(i128::from);
let cash = i128::from(row.get::<_, i64>(7)?);
let fee = i128::from(row.get::<_, i64>(8)?);
let units = match shares {
Some(shares) if shares >= 0 => shares,
_ => return Ok(false),
};
Ok(match operation.as_str() {
"buy" | "sell" => {
let outcome: String = row.get(5)?;
let Some(idx) = side_index(&outcome) else {
return Ok(false);
};
if operation == "buy" {
self.sides[idx].acquire(units, cash, fee, true)
} else {
self.sides[idx].dispose(units, cash - fee)
}
}
"SPLIT" => {
let first = -cash / 2;
self.sides[0].acquire(units, first, 0, false)
&& self.sides[1].acquire(units, -cash - first, 0, false)
}
"MERGE" => {
let first = cash / 2;
self.sides[0].dispose(units, first) && self.sides[1].dispose(units, cash - first)
}
"REDEEM" => {
let raw: Option<String> = row.get(9)?;
let amounts: [i128; 2] = if let Some(raw) = raw {
let Ok(values) = serde_json::from_str::<[i64; 2]>(&raw) else {
return Ok(false);
};
values.map(i128::from)
} else {
[self.sides[0].units, self.sides[1].units]
};
let settled = [amounts[0] * payout[0] / 100, amounts[1] * payout[1] / 100];
amounts.iter().sum::<i128>() == units
&& settled.iter().sum::<i128>() == cash
&& self.sides[0].dispose(amounts[0], settled[0])
&& self.sides[1].dispose(amounts[1], settled[1])
}
// The conversion journal has group totals but no per-leg cost allocation.
_ => false,
})
}
}
pub(crate) struct Economics(HashMap<String, Account>);
impl Economics {
pub fn read(db: &Connection, market: &str, accounts: &[&str]) -> rusqlite::Result<Self> {
let winner: Option<String> =
db.query_row("SELECT winner FROM markets WHERE id=?", [market], |r| {
r.get(0)
})?;
let payout = match winner.as_deref() {
Some("YES") => [100, 0],
Some("NO") => [0, 100],
Some("VOID") => [50, 50],
_ => [0, 0],
};
let mut out: HashMap<String, Account> = HashMap::new();
let mut stmt = db.prepare_cached(include_str!("economics.sql"))?;
let mut rows = stmt.query(params![market, json!(accounts).to_string()])?;
while let Some(row) = rows.next()? {
let account = out.entry(row.get(0)?).or_default();
if account.incomplete {
continue;
}
if row.get::<_, Option<i64>>(3)?.is_none() && row.get::<_, bool>(10)? {
let source: i64 = row.get(1)?;
let Some(at) = row.get::<_, Option<i64>>(2)? else {
account.incomplete = true;
continue;
};
if account
.last_legacy
.is_some_and(|(time, old_source)| time == at && source != old_source)
{
account.incomplete = true;
continue;
}
account.last_legacy = Some((at, source));
}
account.incomplete = !account.apply(row, payout)?;
}
Ok(Self(out))
}
pub fn cost(&self, account: &str, outcome: &str, units: i64) -> Option<&Cost> {
let account = self.0.get(account).filter(|a| !a.incomplete)?;
let side = &account.sides[side_index(outcome)?];
(side.units == i128::from(units) && side.acquired > 0).then_some(side)
}
}
@@ -1,39 +0,0 @@
WITH requested(account) AS MATERIALIZED (
SELECT DISTINCT value FROM json_each(?2)
), legs AS (
SELECT t.account,1 AS source,t.execution AS record,t.order_seq AS leg,t.at_ms,
t.side AS operation,t.outcome,
t.quantity*10000 AS shares,t.quantity*t.price AS cash,
COALESCE(f.fee_micros,0) AS fee,NULL AS redemption_amounts
FROM wallet_trade_legs t JOIN requested a USING(account)
LEFT JOIN execution_fees f ON f.execution=t.execution AND f.taker_order=t.order_seq
WHERE t.market=?1
UNION ALL
SELECT w.account,0,w.id,0,w.at_ms,w.kind,NULL,
COALESCE(p.shares_micros,w.shares*1000000),
COALESCE(p.cash_micros,w.cash_delta*10000),0,
CASE WHEN w.kind='REDEEM' THEN json_extract(r.response,'$.amounts_micros') END
FROM wallet_movements w JOIN requested a USING(account)
LEFT JOIN precise_movements p ON p.request_id=w.request_id AND p.account=w.account
LEFT JOIN requests r ON r.id=w.request_id
WHERE (w.market=?1 AND w.kind IN ('SPLIT','MERGE','REDEEM'))
OR (w.kind='CONVERSION' AND EXISTS (
SELECT 1 FROM neg_risk_members n WHERE n.market=?1 AND n.group_id=w.group_id
))
UNION ALL
SELECT v.vault,0,0,0,NULL,'CONVERSION',NULL,NULL,0,0,NULL
FROM neg_risk_members n
JOIN neg_risk_conversion_fees v USING(group_id) JOIN requested a ON a.account=v.vault
WHERE n.market=?1 AND v.bps>0 AND EXISTS (
SELECT 1 FROM wallet_movements w WHERE w.group_id=n.group_id AND w.kind='CONVERSION'
)
), ordered AS (
SELECT l.*,o.seq AS write_seq,
MAX(o.seq IS NULL AND l.source=0) OVER (PARTITION BY l.account)
AND MAX(o.seq IS NULL AND l.source=1) OVER (PARTITION BY l.account) AS mixed_legacy
FROM legs l LEFT JOIN position_economics_order o ON o.source=l.source AND o.record=l.record
)
SELECT account,source,at_ms,write_seq,operation,outcome,shares,cash,fee,redemption_amounts,mixed_legacy
FROM ordered
ORDER BY account,write_seq IS NOT NULL,
CASE WHEN write_seq IS NULL AND mixed_legacy THEN at_ms END,write_seq,source,record,leg
@@ -1,21 +0,0 @@
BEGIN IMMEDIATE;
-- Trade executions and wallet movements have independent ID sequences.
-- Record their shared write order so a sale and a split in the same
-- millisecond can be replayed in the order in which they committed.
CREATE TABLE IF NOT EXISTS position_economics_order (
seq INTEGER PRIMARY KEY,
source INTEGER NOT NULL,
record INTEGER NOT NULL,
UNIQUE(source,record)
);
CREATE TRIGGER IF NOT EXISTS cost_order_fill AFTER INSERT ON fills BEGIN
INSERT INTO position_economics_order(source,record) VALUES(1,NEW.seq);
END;
CREATE TRIGGER IF NOT EXISTS cost_order_paired AFTER INSERT ON paired_fills BEGIN
INSERT INTO position_economics_order(source,record) VALUES(1,NEW.seq);
END;
CREATE TRIGGER IF NOT EXISTS cost_order_wallet AFTER INSERT ON wallet_movements
WHEN NEW.kind IN ('SPLIT','MERGE','REDEEM','CONVERSION') BEGIN
INSERT INTO position_economics_order(source,record) VALUES(0,NEW.id);
END;
COMMIT;
-427
View File
@@ -1,427 +0,0 @@
use super::economics::{round_money, Economics, Metric, POSITION_FIELDS};
use crate::{
assets, expiry,
inventory::{decimal, UNIT},
validation::{condition_filter, hex_id, identifier},
Exchange, MarketDataError,
};
use data_encoding::BASE64URL_NOPAD;
use hmac::{Hmac, Mac};
use rusqlite::{params, Connection, TransactionBehavior};
use serde::{Deserialize, Serialize};
use serde_json::{json, Value};
use sha2::Sha256;
use std::collections::BTreeMap;
#[derive(Deserialize)]
#[serde(deny_unknown_fields)]
pub struct PositionQuery {
user: Option<String>,
#[serde(alias = "condition_id", alias = "conditionId")]
condition: Option<String>,
status: Option<String>,
#[serde(alias = "eventId")]
event_id: Option<String>,
title: Option<String>,
#[serde(alias = "filterType")]
filter_type: Option<String>,
#[serde(alias = "filterAmount")]
filter_amount: Option<f64>,
#[serde(alias = "sortBy")]
sort_by: Option<String>,
#[serde(alias = "sortDirection")]
sort_direction: Option<String>,
#[serde(alias = "includeArchived")]
include_archived: Option<bool>,
start: Option<i64>,
end: Option<i64>,
limit: Option<u32>,
cursor: Option<String>,
}
#[derive(Serialize, Deserialize, PartialEq, Eq)]
struct Selection {
user: Option<String>,
conditions: Option<String>,
status: String,
sort: String,
direction: String,
archived: bool,
}
#[derive(Serialize, Deserialize)]
struct Cursor {
selection: Selection,
limit: u32,
offset: u64,
last: Key,
}
// Negate only the numeric rank for descending order. Identity is a stable
// tie-breaker regardless of direction or changes elsewhere in the portfolio.
type Key = (bool, i128, String, String, String);
fn invalid(message: &str) -> MarketDataError {
MarketDataError::Invalid(message.to_owned())
}
impl Cursor {
fn mac(db: &Connection) -> Result<Hmac<Sha256>, MarketDataError> {
let secret: Vec<u8> = db.query_row(
"SELECT secret FROM trade_cursor_key WHERE singleton=1",
[],
|row| row.get(0),
)?;
let mut mac =
Hmac::<Sha256>::new_from_slice(&secret).map_err(|_| MarketDataError::Unavailable)?;
mac.update(b"eventbook:/v2/positions:v1\0");
Ok(mac)
}
fn decode(db: &Connection, encoded: &str) -> Result<Self, MarketDataError> {
let bad = || invalid("invalid position cursor");
if encoded.len() > 8192 {
return Err(bad());
}
let bytes = BASE64URL_NOPAD
.decode(encoded.as_bytes())
.map_err(|_| bad())?;
let split = bytes.len().checked_sub(32).ok_or_else(bad)?;
let (payload, signature) = bytes.split_at(split);
let mut mac = Self::mac(db)?;
mac.update(payload);
mac.verify_slice(signature).map_err(|_| bad())?;
serde_json::from_slice(payload).map_err(|_| bad())
}
fn encode(&self, db: &Connection) -> Result<String, MarketDataError> {
let mut bytes = serde_json::to_vec(self).map_err(|_| MarketDataError::Unavailable)?;
let mut mac = Self::mac(db)?;
mac.update(&bytes);
bytes.extend_from_slice(&mac.finalize().into_bytes());
Ok(BASE64URL_NOPAD.encode(&bytes))
}
}
impl Exchange {
pub fn public_positions(&self, query: PositionQuery) -> Result<Value, MarketDataError> {
let tx = expiry::transaction(&self.db, TransactionBehavior::Deferred)
.map_err(|_| MarketDataError::Unavailable)?;
let mut user = query.user;
let wallet = user.as_deref().is_some_and(|id| hex_id(id, 40));
if let Some(id) = &mut user {
if wallet {
id.make_ascii_lowercase();
if super::protocol::CONTRACTS
.iter()
.any(|c| c.eq_ignore_ascii_case(id))
{
return Err(invalid("protocol contract is not a user"));
}
} else {
identifier(id).map_err(|_| invalid("invalid user"))?;
if !tx.query_row(
"SELECT EXISTS(SELECT 1 FROM accounts WHERE id=?1)",
[&*id],
|r| r.get::<_, bool>(0),
)? {
return Err(invalid("invalid user"));
}
}
}
if query.event_id.is_some() && (query.condition.is_some() || user.is_none()) {
return Err(invalid(if query.condition.is_some() {
"must provide either eventId or condition, not both"
} else {
"event_id requires a user"
}));
}
let events = query
.event_id
.as_deref()
.map(|raw| {
let ids: std::collections::BTreeSet<_> = raw
.split(',')
.map(str::trim)
.filter(|s| !s.is_empty())
.collect();
if ids.len() > 20 {
return Err(invalid("expected at most 20 event ids"));
}
let numeric: Vec<i64> = ids.into_iter().filter_map(|id| id.parse().ok()).collect();
serde_json::to_string(&numeric).map_err(|_| MarketDataError::Unavailable)
})
.transpose()?;
let title = query
.title
.as_deref()
.map(str::trim)
.filter(|s| !s.is_empty());
if title.is_some_and(|s| s.chars().count() > 200) {
return Err(invalid("title exceeds 200 characters"));
}
let title = title.map(|s| format!("%{s}%"));
let cash = match query.filter_type.as_deref() {
None => false,
Some(name) if name.eq_ignore_ascii_case("TOKENS") => false,
Some(name) if name.eq_ignore_ascii_case("CASH") => true,
Some(_) => return Err(invalid("filterType must be CASH or TOKENS")),
};
let floor = query
.filter_amount
.filter(|v| v.is_finite() && *v >= 0.0)
.map_or(0, |v| (v * UNIT as f64).ceil() as i64);
let shares_floor = if cash { 100_000 } else { floor.max(100_000) };
let conditions = condition_filter(query.condition.as_deref(), &tx)?;
if user.is_none() {
let count = conditions
.as_ref()
.map(|s| serde_json::from_str::<Vec<String>>(s))
.transpose()
.map_err(|_| MarketDataError::Unavailable)?
.map_or(0, |ids| ids.len());
if count != 1 {
return Err(invalid("expected a user or exactly one condition"));
}
}
let start = query.start.filter(|n| *n > 0);
let end = query.end.filter(|n| *n > 0);
if matches!((start, end), (Some(a), Some(b)) if b < a) {
return Err(invalid("end must not be before start"));
}
let cursor = query
.cursor
.as_deref()
.map(|encoded| Cursor::decode(&tx, encoded))
.transpose()?;
let prior = cursor.as_ref().map(|p| &p.selection);
let mut status = query
.status
.or_else(|| prior.map(|s| s.status.clone()))
.unwrap_or_else(|| "OPEN".into());
if !matches!(
status.as_str(),
"OPEN" | "CLOSED" | "REDEEMABLE" | "REDEEMABLE_LOST" | "MERGEABLE"
) || (user.is_none() && status == "REDEEMABLE_LOST")
{
return Err(invalid("invalid position status"));
}
if user.is_none() && status == "MERGEABLE" {
status = "OPEN".into();
}
if status == "CLOSED" && query.include_archived.is_some() {
return Err(invalid("include_archived is unavailable for CLOSED"));
}
let mut sort = query
.sort_by
.or_else(|| prior.map(|s| s.sort.clone()))
.unwrap_or_else(|| {
match status.as_str() {
"MERGEABLE" => "TOKENS",
"CLOSED" if user.is_some() => "REALIZED_PNL",
_ => "CURRENT_VALUE",
}
.into()
});
if user.is_some()
&& matches!(status.as_str(), "CLOSED" | "REDEEMABLE_LOST")
&& sort == "AVG_PRICE"
{
return Err(invalid(
"sortBy=AVG_PRICE is not supported on a user's CLOSED or REDEEMABLE_LOST positions",
));
}
if user.is_some()
&& status == "CLOSED"
&& matches!(
sort.as_str(),
"TOKENS" | "CURRENT_VALUE" | "PRICE" | "UNREALIZED_PNL"
)
{
sort = "REALIZED_PNL".into();
}
let metric = Metric::parse(&sort);
let direction = query
.sort_direction
.or_else(|| prior.map(|s| s.direction.clone()))
.unwrap_or_else(|| "DESC".into());
if (metric.is_none()
&& !matches!(
sort.as_str(),
"CURRENT_VALUE" | "PRICE" | "TOKENS" | "TIMESTAMP"
))
|| !matches!(direction.as_str(), "ASC" | "DESC")
{
return Err(invalid("invalid or unsupported position sort"));
}
let selection = Selection {
user,
conditions,
status,
sort,
direction,
archived: query
.include_archived
.or_else(|| prior.map(|s| s.archived))
.unwrap_or(false),
};
let limit = cursor
.as_ref()
.map_or(query.limit.unwrap_or(100), |p| p.limit);
if limit > 1000 || cursor.as_ref().is_some_and(|p| p.selection != selection) {
return Err(invalid("invalid position limit or cursor filters"));
}
let offset = cursor.as_ref().map_or(0, |p| p.offset);
let mut page = BTreeMap::new();
if limit != 0 {
let mut cost_snapshot: Option<(String, String, Economics)> = None;
let mut stmt = tx.prepare_cached(include_str!("positions.sql"))?;
let mut rows = stmt.query(params![
selection.user,
wallet,
selection.conditions,
selection.status,
selection.archived,
events,
title,
shares_floor,
start,
end
])?;
while let Some(row) = rows.next()? {
let account: String = row.get(0)?;
let market: String = row.get(1)?;
let outcome: String = row.get(2)?;
let size: i64 = row.get(3)?;
let phase: String = row.get(4)?;
let payout: Option<i64> = row.get(5)?;
let mark = super::price(&tx, &market, &outcome, &phase, payout)
.map_err(|_| MarketDataError::Unavailable)?
.map(|(price, _)| price);
let value = super::holding_value(size, mark);
if cash && floor > 0 && value.is_none_or(|v| v < i128::from(floor)) {
continue;
}
let last_event_at: Option<i64> = row.get(13)?;
let first_entry_at: Option<i64> = row.get(14)?;
let (rank, cost) = if let Some(metric) = metric {
if cost_snapshot
.as_ref()
.is_none_or(|(a, m, _)| a != &account || m != &market)
{
let history = Economics::read(&tx, &market, &[account.as_str()])?;
cost_snapshot = Some((account.clone(), market.clone(), history));
}
let cost = cost_snapshot.as_ref().and_then(|(_, _, history)| {
history.cost(&account, &outcome, size).cloned()
});
(
cost.as_ref().and_then(|cost| metric.rank(cost, value)),
cost,
)
} else {
let rank = match selection.sort.as_str() {
"TIMESTAMP" => last_event_at.map(i128::from),
"TOKENS" => Some(i128::from(size)),
"PRICE" => Some(i128::from(mark.unwrap_or(0))),
_ => Some(value.unwrap_or(0)),
};
(rank, None)
};
let rank = rank.map_or(i128::MAX, |n| {
if selection.direction == "DESC" {
-n
} else {
n
}
});
let losing = selection.status == "REDEEMABLE" && payout == Some(0);
let key = (
losing,
rank,
account.clone(),
market.clone(),
outcome.clone(),
);
if cursor.as_ref().is_some_and(|p| key <= p.last) {
continue;
}
let yes = outcome == "YES";
let opposite = if yes { "NO" } else { "YES" };
let redeemable = size > 0 && phase == "resolved";
let status = if selection.status == "CLOSED" {
"CLOSED"
} else if redeemable {
"REDEEMABLE"
} else {
"OPEN"
};
page.insert(key, (json!({
"proxy_wallet": account, "condition_id": market,
"token_id": assets::id(&market,&outcome), "opposite_token_id": assets::id(&market,opposite),
"current_size": decimal(size.into(),UNIT),
"last_event_at":last_event_at, "first_entry_at":first_entry_at,
"current_price": mark.map(|p| decimal(p.into(),UNIT)),
"current_value": value.map(|v| decimal(round_money(v),UNIT)),
"status": status, "redeemable": redeemable, "mergeable": row.get::<_, bool>(7)?,
"archived": row.get::<_, bool>(6)?, "negative_risk": row.get::<_, bool>(12)?,
"title": row.get::<_, String>(8)?, "slug": row.get::<_, String>(9)?,
"outcome": row.get::<_, String>(if yes {10} else {11})?,
"opposite_outcome": row.get::<_, String>(if yes {11} else {10})?,
"outcome_index": if yes {0} else {1}
}), size, value, cost));
if page.len() > limit as usize + 1 {
page.pop_last();
}
}
}
let has_more = page.len() > limit as usize;
let next = if has_more {
page.pop_last();
let token = Cursor {
selection,
limit,
offset: offset.saturating_add(u64::from(limit)),
last: page.last_key_value().expect("nonempty page").0.clone(),
}
.encode(&tx)?;
Some(token)
} else {
None
};
let mut page_costs = BTreeMap::new();
if metric.is_none() {
let mut accounts_by_market: BTreeMap<&str, Vec<&str>> = BTreeMap::new();
for (_, _, account, market, _) in page.keys() {
accounts_by_market.entry(market).or_default().push(account);
}
for (market, accounts) in accounts_by_market {
page_costs.insert(market.to_owned(), Economics::read(&tx, market, &accounts)?);
}
}
let mut data = Vec::with_capacity(page.len());
for ((_, _, account, market, outcome), (mut row, size, value, cost)) in page {
let cost = if metric.is_some() {
cost.as_ref()
} else {
page_costs
.get(&market)
.and_then(|history| history.cost(&account, &outcome, size))
};
let fields = cost.map(|cost| cost.fields(value, false));
for key in POSITION_FIELDS {
row[key] = fields
.as_ref()
.map_or(Value::Null, |values| values[key].clone());
}
data.push(row);
}
tx.commit()?;
Ok(
json!({"data":data,"pagination":{"limit":limit,"offset":offset,"has_more":has_more,"next_cursor":next}}),
)
}
}
@@ -1,64 +0,0 @@
WITH held AS (
SELECT p.*,p.available+p.reserved AS size,
COALESCE(v.active,1) AS active, COALESCE(v.archived,0) AS archived
FROM position_units p LEFT JOIN market_visibility v USING(market)
WHERE (?1 IS NULL OR CASE WHEN ?2 THEN p.account COLLATE NOCASE=?1 ELSE p.account=?1 END)
AND (?3 IS NULL OR p.market IN (SELECT value FROM json_each(?3)))
AND (?6 IS NULL OR p.market IN (
SELECT l.market FROM listed_markets l JOIN event_directory_ids e ON e.event=l.event
WHERE e.id IN (SELECT value FROM json_each(?6))
))
), selected AS (
SELECT p.account,p.market,p.outcome,p.size,p.phase,p.payout_per_share,p.archived,
p.phase<>'resolved' AND p.size>=100000 AND COALESCE(other.size,0)>=100000 AS mergeable,
w.question,w.slug,w.yes_label,w.no_label,n.market IS NOT NULL AS negative_risk
FROM held p
JOIN market_wire_metadata w ON w.market=p.market
LEFT JOIN held other ON other.account=p.account AND other.market=p.market AND other.outcome<>p.outcome
LEFT JOIN neg_risk_members n ON n.market=p.market
WHERE (?7 IS NULL OR w.question LIKE ?7) AND CASE ?4
WHEN 'CLOSED' THEN p.size<CASE WHEN ?1 IS NULL THEN ?8 ELSE 100000 END
ELSE p.active AND (?5 OR NOT p.archived) AND p.size>=?8 AND CASE ?4
WHEN 'OPEN' THEN 1
WHEN 'REDEEMABLE' THEN p.phase='resolved'
WHEN 'REDEEMABLE_LOST' THEN p.phase='resolved' AND p.payout_per_share=0
WHEN 'MERGEABLE' THEN mergeable
END
END
), observations AS (
SELECT s.account,s.market,s.outcome,t.at_ms,t.side='buy' AS entry
FROM selected s JOIN wallet_trade_legs t
ON t.account=s.account AND t.market=s.market AND t.outcome=s.outcome
UNION ALL
SELECT s.account,s.market,s.outcome,w.at_ms,w.kind='SPLIT'
FROM selected s JOIN wallet_movements w ON w.account=s.account AND w.market=s.market
WHERE w.kind IN ('SPLIT','MERGE')
UNION ALL
SELECT s.account,s.market,s.outcome,w.at_ms,0
FROM selected s
JOIN wallet_movements w ON w.account=s.account AND w.market=s.market AND w.kind='REDEEM'
JOIN requests r ON r.id=w.request_id
WHERE json_extract(r.response,CASE s.outcome WHEN 'YES' THEN '$.amounts_micros[0]' ELSE '$.amounts_micros[1]' END)>0
UNION ALL
SELECT s.account,s.market,s.outcome,w.at_ms,s.outcome='YES'
FROM selected s
JOIN neg_risk_members n ON n.market=s.market
JOIN wallet_movements w ON w.account=s.account AND w.group_id=n.group_id AND w.kind='CONVERSION'
JOIN requests r ON r.id=w.request_id
WHERE s.market IN (
SELECT value FROM json_each(r.response,CASE s.outcome WHEN 'YES' THEN '$.yes_markets' ELSE '$.no_markets' END)
)
AND (s.outcome='NO' OR COALESCE(json_extract(r.response,'$.conversion_fee.bps'),0)<10000)
UNION ALL
SELECT s.account,s.market,s.outcome,r.at_ms,0
FROM selected s JOIN position_redemption_times r USING(account,market,outcome)
), clocks AS (
SELECT account,market,outcome,MAX(at_ms)/1000 AS last_event_at,
MIN(CASE WHEN entry THEN at_ms END)/1000 AS first_entry_at
FROM observations GROUP BY account,market,outcome
)
SELECT s.*,c.last_event_at,c.first_entry_at
FROM selected s LEFT JOIN clocks c USING(account,market,outcome)
WHERE (?9 IS NULL OR c.last_event_at>=?9)
AND (?10 IS NULL OR c.last_event_at<=?10)
ORDER BY s.account,s.market,s.outcome
@@ -12,12 +12,4 @@ END;
INSERT OR IGNORE INTO chart_origins
SELECT id,COALESCE((SELECT MIN(at_ms) FROM quote_events WHERE market=m.id),
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;
+12 -12
View File
@@ -2,16 +2,14 @@
-- The local sampler uses a UTC minute grid. The venue's collector has clock jitter.
WITH RECURSIVE horizon AS (
SELECT (SELECT at_ms FROM chart_origins WHERE market=?1) AS first_ms,
(SELECT at_ms FROM chart_closures WHERE market=?1) AS closed_ms,
(SELECT phase IN ('closed','resolved') FROM markets WHERE id=?1) AS closed
(SELECT at_ms FROM price_settlements WHERE market=?1) AS resolved_ms,
(SELECT winner FROM price_settlements WHERE market=?1) AS winner,
(SELECT phase FROM markets WHERE id=?1) AS phase
), bounds AS (
SELECT first_ms, closed,
CASE WHEN NOT closed THEN ?6/60000*60000
WHEN closed_ms IS NOT NULL THEN closed_ms-1
-- 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
SELECT first_ms, resolved_ms, winner,
CASE WHEN phase='resolved' THEN COALESCE(resolved_ms,
(SELECT MAX(at_ms) FROM quote_events WHERE market=?1))
ELSE ?6/60000*60000 END AS last_ms
FROM horizon
), grid(ms) AS (
SELECT ((MAX(?3,first_ms)+?5-1)/?5)*?5 FROM bounds
@@ -21,12 +19,14 @@ WITH RECURSIVE horizon AS (
), points(ms,tail) AS (
SELECT ms,0 FROM grid
UNION ALL
SELECT last_ms,1 FROM bounds WHERE NOT closed AND first_ms<=last_ms
SELECT last_ms,1 FROM bounds WHERE resolved_ms IS NOT NULL OR first_ms<=last_ms
)
SELECT points.ms/1000,
CASE WHEN ?2='YES' THEN (COALESCE(q.yes_bid,0)+COALESCE(q.yes_ask,10000))*50
CASE WHEN points.ms=b.resolved_ms THEN
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
FROM points
FROM points CROSS JOIN bounds b
LEFT JOIN quote_events q ON q.seq=(
SELECT seq FROM quote_events WHERE market=?1 AND at_ms<=points.ms
ORDER BY at_ms DESC,seq DESC LIMIT 1
+6 -10
View File
@@ -200,7 +200,7 @@ impl PriceRequest {
// Use the last committed top of book, even when only one side has liquidity.
// All requested markets share the caller's read snapshot.
fn price_rows(db: &Connection, requests: &[PriceRequest]) -> Result<Vec<Option<String>>> {
quote_rows(db, requests, false)?
quote_rows(db, requests)?
.into_iter()
.zip(requests)
.map(|(quote, request)| {
@@ -220,11 +220,7 @@ fn price_rows(db: &Connection, requests: &[PriceRequest]) -> Result<Vec<Option<S
.collect()
}
fn quote_rows(
db: &Connection,
requests: &[PriceRequest],
public_only: bool,
) -> Result<Vec<Option<Quote>>> {
fn quote_rows(db: &Connection, requests: &[PriceRequest]) -> Result<Vec<Option<Quote>>> {
if !(1..=500).contains(&requests.len()) {
return Err(PriceQueryError::RequestCount.into());
}
@@ -238,11 +234,11 @@ fn quote_rows(
}
let mut stmt = db.prepare_cached(
"SELECT COALESCE(q.seq,0),q.yes_bid,q.yes_ask,q.at_ms,m.id,j.key
FROM json_each(?1) j LEFT JOIN markets m ON m.id=j.value AND (NOT ?2 OR m.phase<>'resolved')
FROM json_each(?1) j LEFT JOIN markets m ON m.id=j.value
LEFT JOIN quote_events q ON q.seq=(SELECT MAX(seq) FROM quote_events WHERE market=m.id)
ORDER BY j.key",
)?;
let mut rows = stmt.query(params![serde_json::to_string(&markets)?, public_only])?;
let mut rows = stmt.query([serde_json::to_string(&markets)?])?;
let mut quotes = Vec::with_capacity(requests.len());
while let Some(row) = rows.next()? {
let index: usize = row.get(5)?;
@@ -288,7 +284,7 @@ impl crate::Exchange {
pub fn public_book_prices(&self, requests: &[PriceRequest]) -> Result<Value> {
let tx = crate::expiry::transaction(&self.db, rusqlite::TransactionBehavior::Deferred)?;
let mut result = json!({});
for (request, quote) in requests.iter().zip(quote_rows(&tx, requests, true)?) {
for (request, quote) in requests.iter().zip(quote_rows(&tx, requests)?) {
if let Some(quote) = quote {
let (bid, ask) = quote.public_sides();
let ticks = match request.side {
@@ -337,7 +333,7 @@ impl crate::Exchange {
.map_err(|_| crate::MarketDataError::Unavailable)?;
let mut stmt = tx.prepare_cached(
"SELECT COALESCE(q.seq,0),q.yes_bid,q.yes_ask,q.at_ms,j.key FROM json_each(?1) j
JOIN markets m ON m.id=json_extract(j.value,'$[1]') AND m.phase<>'resolved'
JOIN markets m ON m.id=json_extract(j.value,'$[1]')
LEFT JOIN quote_events q ON q.seq=(SELECT MAX(seq) FROM quote_events WHERE market=m.id)"
)?;
let mut rows = stmt.query([input])?;
+5 -9
View File
@@ -18,6 +18,11 @@ CREATE TABLE IF NOT EXISTS market_clarifications (
created_at TEXT NOT NULL DEFAULT (strftime('%Y-%m-%dT%H:%M:%fZ','now'))
);
CREATE INDEX IF NOT EXISTS clarifications_by_market ON market_clarifications(market,id);
CREATE TABLE IF NOT EXISTS clarification_transactions (
clarification INTEGER PRIMARY KEY REFERENCES market_clarifications(id),
tx_hash TEXT NOT NULL
);
CREATE INDEX IF NOT EXISTS clarifications_by_transaction ON clarification_transactions(tx_hash);
CREATE TABLE IF NOT EXISTS positions (
account TEXT REFERENCES accounts, market TEXT REFERENCES markets, outcome TEXT,
quantity INTEGER NOT NULL CHECK(quantity >= 0), PRIMARY KEY(account,market,outcome)
@@ -322,15 +327,6 @@ CREATE TABLE IF NOT EXISTS budget_spend_micros (
);
-- Keep issued public trade cursors valid after a restart, scoped to this database.
-- Preserve which outcome was actually burned by a full redemption.
CREATE TABLE IF NOT EXISTS position_redemption_times (
account TEXT NOT NULL REFERENCES accounts,
market TEXT NOT NULL REFERENCES markets,
outcome TEXT NOT NULL,
at_ms INTEGER NOT NULL,
PRIMARY KEY(account,market,outcome)
);
CREATE TABLE IF NOT EXISTS trade_cursor_key (
singleton INTEGER PRIMARY KEY CHECK(singleton=1), secret BLOB NOT NULL CHECK(length(secret)=32)
);
+10 -287
View File
@@ -1553,23 +1553,21 @@ fn legacy_history_samples_the_book_without_fills_and_appends_the_latest_mark() {
exchange
.execute(json!({"op":"close","id":"close","market":"mid-example"}))
.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
.execute(json!({"op":"finalize","id":"verdict","market":"mid-example","winner":"NO"}))
.unwrap();
db.execute("UPDATE price_settlements SET at_ms=273000", [])
.unwrap();
drop(exchange);
let reopened = Exchange::open(path).unwrap();
assert_eq!(read(&reopened, "NO", 180.001, 400.0), before_close);
assert!(read(&reopened, "YES", 273.0, 400.0).is_empty());
assert!(read(&reopened, "YES", 5.0, 5.0).is_empty());
assert_eq!(
read(&reopened, "NO", 180.001, 240.0),
vec![json!({"t":240,"p":0.915}), json!({"t":273,"p":1})]
);
assert_eq!(
read(&reopened, "YES", 5.0, 5.0),
vec![json!({"t":273,"p":0})]
);
}
#[test]
@@ -1881,52 +1879,6 @@ fn holders_net_reserved_and_hedged_balances_and_page_each_token() {
assert!(e
.execute(json!({"op":"holders","cursor":first["next_cursor"],"market":"different"}))
.is_err());
let request = |value| serde_json::from_value::<exchange::HoldersQuery>(value).unwrap();
let first_public = e
.public_holders(request(json!({"condition":"cup","limit":1})))
.unwrap();
assert_eq!(
first_public["data"][0]["holders"][0]["proxy_wallet"],
"alice"
);
assert_eq!(first_public["data"][0]["holders"][0]["amount"], 3);
assert!(first_public["data"][0]["holders"][0]
.get("entry_cost_usdc")
.is_none());
let cursor = first_public["pagination"]["next_cursor"].as_str().unwrap();
let next_public = e
.public_holders(request(
json!({"condition":"cup","cursor":cursor,"limit":9}),
))
.unwrap();
assert_eq!(next_public["pagination"]["limit"], 1);
assert_eq!(next_public["pagination"]["offset"], 1);
assert_eq!(next_public["data"].as_array().unwrap().len(), 1);
assert_eq!(
next_public["data"][0]["holders"][0]["proxy_wallet"],
"carol"
);
assert_eq!(next_public["data"][0]["holders"][0]["amount"], 0);
let pnl = e
.public_holders(request(json!({"condition":"cup","includePnl":true})))
.unwrap();
let alice_yes = &pnl["data"][0]["holders"][0];
let alice_no = &pnl["data"][1]["holders"][0];
let bob_no = &pnl["data"][1]["holders"][1];
assert_eq!(alice_yes["amount"], 10);
assert_eq!(alice_yes["entry_cost_usdc"], 5);
assert_eq!(alice_no["amount"], 7);
assert_eq!(alice_no["entry_cost_usdc"], json!(3.5));
assert_eq!(alice_no["realized_pnl"], json!(-0.3));
assert_eq!(bob_no["proxy_wallet"], "bob");
assert_eq!(bob_no["entry_cost_usdc"], json!(3.2));
assert!(
(bob_no["unrealized_pnl"].as_f64().unwrap() + bob_no["realized_pnl"].as_f64().unwrap()
- bob_no["total_pnl"].as_f64().unwrap())
.abs()
< 1e-9
);
assert_eq!(gross["data"][0]["holders"][0]["amount"], 10);
assert_eq!(gross["data"][1]["holders"][0]["amount"], 7);
assert_eq!(
@@ -4224,232 +4176,3 @@ fn order_submission_terms_survive_fills_cancel_retries_and_legacy_upgrade() {
assert_eq!(e.execute(cmd.clone()).unwrap()["orders"][0], expected);
}
}
#[test]
fn public_positions_walk_a_mergeable_pair_and_held_settlement() {
let dir = tempdir().unwrap();
let path = dir.path().join("positions.db");
let mut e = Exchange::open(&path).unwrap();
setup(&mut e);
let read =
|engine: &Exchange, query| engine.public_positions(serde_json::from_value(query).unwrap());
for cmd in [
json!({"op":"list","id":"dust-list","market":"dust","rules":"dust"}),
json!({"op":"split","id":"dust-split","market":"dust","account":"bob","qty_micros":8800}),
json!({"op":"close","id":"dust-close","market":"dust"}),
json!({"op":"finalize","id":"dust-win","market":"dust","winner":"YES"}),
] {
e.execute(cmd).unwrap();
}
assert_eq!(
read(&e, json!({"user":"bob","condition":"dust"})).unwrap()["data"],
json!([])
);
let dust = read(
&e,
json!({"user":"bob","condition":"dust","status":"CLOSED"}),
)
.unwrap();
let winning_dust = dust["data"]
.as_array()
.unwrap()
.iter()
.find(|row| row["token_id"] == "eb:YES:dust")
.unwrap();
assert_eq!(winning_dust["current_size"], 0.0088);
assert_eq!(winning_dust["redeemable"], true);
assert_eq!(
read(
&e,
json!({"user":"alice","title":"%e%","filter_type":"tokens","filter_amount":10})
)
.unwrap()["data"]
.as_array()
.unwrap()
.len(),
2
);
assert_eq!(
read(&e, json!({"user":"alice","filter_amount":10.001})).unwrap()["data"],
json!([])
);
assert_eq!(
read(&e, json!({"user":"alice","title":"unmatched title"})).unwrap()["data"],
json!([])
);
assert_eq!(
read(&e, json!({"user":"alice","event_id":"unmatched"})).unwrap()["data"],
json!([])
);
assert!(read(&e, json!({"user":"alice","event_id":"1","condition":"e"})).is_err());
let db = rusqlite::Connection::open(&path).unwrap();
db.execute(
"UPDATE wallet_movements SET at_ms=123999 WHERE request_id='s'",
[],
)
.unwrap();
let instant = read(
&e,
json!({"user":"alice","start":123,"end":123,"sort_by":"TIMESTAMP"}),
)
.unwrap();
assert_eq!(instant["data"].as_array().unwrap().len(), 2);
assert_eq!(instant["data"][0]["first_entry_at"], 123);
assert_eq!(instant["data"][0]["last_event_at"], 123);
assert_eq!(
read(&e, json!({"user":"alice","start":124})).unwrap()["data"],
json!([])
);
assert!(read(&e, json!({"user":"alice","start":124,"end":123})).is_err());
drop(db);
let first = read(&e, json!({"user":"alice","status":"MERGEABLE","limit":1})).unwrap();
assert_eq!(first["data"][0]["mergeable"], true);
let cursor = first["pagination"]["next_cursor"].as_str().unwrap();
assert!(read(&e, json!({"user":"bob","cursor":cursor})).is_err());
assert!(read(&e, json!({"user":"alice","status":"OPEN","cursor":cursor})).is_err());
drop(e);
let mut e = Exchange::open(path).unwrap();
let next = read(&e, json!({"user":"alice","cursor":cursor,"limit":5})).unwrap();
assert_eq!(next["pagination"]["limit"], 1);
assert_eq!(next["pagination"]["offset"], 1);
assert_eq!(next["pagination"]["has_more"], false);
assert_ne!(next["data"][0]["token_id"], first["data"][0]["token_id"]);
e.execute(json!({"op":"close","id":"close","market":"e"}))
.unwrap();
e.execute(json!({"op":"finalize","id":"win","market":"e","winner":"YES"}))
.unwrap();
let held = read(&e, json!({"user":"alice","condition":"e","status":"OPEN"})).unwrap();
assert_eq!(held["data"][0]["status"], "REDEEMABLE");
assert_eq!(held["data"][0]["current_value"], 10);
assert_eq!(held["data"][0]["mergeable"], false);
let cash = read(
&e,
json!({"user":"alice","filterType":"cash","filterAmount":10}),
)
.unwrap();
assert_eq!(cash["data"].as_array().unwrap().len(), 1);
assert_eq!(cash["data"][0]["token_id"], "eb:YES:e");
let lost = read(&e, json!({"user":"alice","status":"REDEEMABLE_LOST"})).unwrap();
assert_eq!(lost["data"].as_array().unwrap().len(), 1);
assert_eq!(lost["data"][0]["token_id"], "eb:NO:e");
e.execute(json!({"op":"redeem","id":"claim","market":"e","account":"alice"}))
.unwrap();
assert_eq!(
read(&e, json!({"user":"alice"})).unwrap()["data"],
json!([])
);
let closed = read(&e, json!({"user":"alice","status":"CLOSED"})).unwrap();
assert_eq!(closed["data"].as_array().unwrap().len(), 2);
assert_eq!(closed["data"][0]["realized_pnl"], 5);
assert_eq!(closed["data"][1]["realized_pnl"], -5);
}
#[test]
fn public_positions_reconstructs_trade_basis_after_a_partial_sale() {
let mut e = Exchange::open(":memory:").unwrap();
setup(&mut e);
for cmd in [
json!({"op":"fund","id":"fund-trader","account":"trader","cents":2000}),
json!({"op":"open","id":"open","market":"e"}),
order("ask", "alice", "sell", 40, 10),
order("entry", "trader", "buy", 40, 10),
order("exit", "trader", "sell", 80, 3),
order("buyer", "bob", "buy", 80, 3),
] {
e.execute(cmd).unwrap();
}
for command in [
json!({"op":"list","id":"other-list","market":"other","rules":"other result"}),
json!({"op":"split","id":"other-split","market":"other","account":"alice","qty":5}),
json!({"op":"open","id":"other-open","market":"other"}),
] {
e.execute(command).unwrap();
}
for (id, account, side, price, qty) in [
("other-ask", "alice", "sell", 60, 5),
("other-buy", "trader", "buy", 60, 5),
("other-exit", "trader", "sell", 40, 5),
("other-take", "bob", "buy", 40, 5),
] {
let mut command = order(id, account, side, price, qty);
command["market"] = json!("other");
e.execute(command).unwrap();
}
let read = |user| {
e.public_positions(serde_json::from_value(json!({"user":user})).unwrap())
.unwrap()
};
let page = read("trader");
let row = &page["data"][0];
assert_eq!(row["current_size"], 7);
assert_eq!(row["total_size"], 10);
assert_eq!(row["entry_cost_usdc"], 2.8);
assert_eq!(row["realized_pnl"], 1.2);
assert_eq!(row["unrealized_pnl"], 2.8);
assert_eq!(row["total_pnl"], 4);
let sorted = |params| e.public_positions(serde_json::from_value(params).unwrap());
let closed = sorted(json!({"user":"trader","status":"CLOSED","sort_by":"PRICE"})).unwrap();
assert_eq!(closed["data"][0]["realized_pnl"], -1);
assert_eq!(closed["data"][0]["avg_price"], 0.6);
assert!(sorted(json!({"user":"trader","status":"CLOSED","sort_by":"AVG_PRICE"})).is_err());
let market = sorted(json!({"condition":"e","sort_by":"AVG_PRICE","limit":1})).unwrap();
assert_eq!(market["data"][0]["proxy_wallet"], "bob");
let cursor = market["pagination"]["next_cursor"].as_str().unwrap();
let next = sorted(json!({"condition":"e","cursor":cursor})).unwrap();
assert_eq!(next["data"][0]["proxy_wallet"], "alice");
assert_eq!(next["data"][0]["entry_cost_usdc"], 5);
assert_eq!(next["data"][0]["total_size"], 0);
let cursor = next["pagination"]["next_cursor"].as_str().unwrap();
let last = sorted(json!({"condition":"e","cursor":cursor})).unwrap();
assert_eq!(last["data"][0]["proxy_wallet"], "trader");
assert_eq!(row["percent_pnl"], 100);
assert_eq!(row["percent_realized_pnl"], 40);
}
#[test]
fn positions_and_holders_share_costs_but_use_different_average_prices() {
let dir = tempdir().unwrap();
let path = dir.path().join("position-fees.sqlite");
let mut db = Exchange::open(&path).unwrap();
let position = |db: &Exchange| {
db.public_positions(
serde_json::from_value(json!({"user":"bob","condition":"cup"})).unwrap(),
)
.unwrap()["data"][0]
.clone()
};
for line in include_str!("../../../docs/examples/fees.jsonl").lines() {
let cmd: Value = serde_json::from_str(line).unwrap();
if cmd["op"] == "market_sell" {
let open = position(&db);
assert_eq!(open["entry_fees_usdc"], json!(1.25));
assert_eq!(open["realized_pnl"], 0);
}
db.execute(cmd).unwrap();
}
drop(db);
let db = Exchange::open(path).unwrap();
let open = position(&db);
assert_eq!(open["current_size"], 99);
assert_eq!(open["entry_cost_usdc"], json!(49.5));
assert_eq!(open["entry_fees_usdc"], json!(1.2375));
assert_eq!(open["realized_pnl"], json!(-0.223));
let holders = db
.public_holders(
serde_json::from_value(json!({"condition":"cup","include_pnl":true})).unwrap(),
)
.unwrap();
let holder = &holders["data"][0]["holders"][0];
assert_eq!(holder["proxy_wallet"], "bob");
assert_eq!(holder["avg_price"], json!(0.5125));
assert_eq!(open["avg_price"], json!(0.5));
for field in [
"entry_cost_usdc",
"realized_pnl",
"current_value",
"unrealized_pnl",
"total_pnl",
] {
assert_eq!(holder[field], open[field]);
}
}
@@ -1,597 +0,0 @@
[
{
"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": []
}
}
}
]
}
]
@@ -1,12 +0,0 @@
{
"AVG_PRICE": {"url":"https://data-api.polymarket.com/v2/positions?user=0xbc79e27f2c94124aeefb08d74b4e4fd3ac834e4d&limit=7&sort_by=AVG_PRICE","status":200,"date":"Fri, 04 Dec 2026 20:56:44 GMT","body":{"data":[{"token_id":"60488319664307907808238843684363128940030194181923783216789526080413999461490","status":"REDEEMABLE","avg_price":0.8899,"current_price":0.0,"current_value":0.0,"realized_pnl":-2.354,"unrealized_pnl":-10.0025,"total_pnl":-12.3565,"current_size":11.239},{"token_id":"98073668715220604074158446612974804298018754563117252335606186300079136804004","status":"REDEEMABLE","avg_price":0.8399,"current_price":0.0,"current_value":0.0,"realized_pnl":-0.04,"unrealized_pnl":-4.9999,"total_pnl":-5.0399,"current_size":5.9523},{"token_id":"47077648217971757308720798158325917219531658951054235799631815254380459178462","status":"REDEEMABLE","avg_price":0.8299,"current_price":0.0,"current_value":0.0,"realized_pnl":-0.0175,"unrealized_pnl":-2.0499,"total_pnl":-2.0674,"current_size":2.4698},{"token_id":"70856206809794487052236221713547822530745876986932371021154800731989645923129","status":"REDEEMABLE","avg_price":0.792,"current_price":0.0,"current_value":0.0,"realized_pnl":-0.052,"unrealized_pnl":-4.9999,"total_pnl":-5.0519,"current_size":6.3125},{"token_id":"108440305255097343955145320114677386272816360228724390087556347183639101640370","status":"REDEEMABLE","avg_price":0.7899,"current_price":0.0,"current_value":0.0,"realized_pnl":-0.0525,"unrealized_pnl":-4.9999,"total_pnl":-5.0524,"current_size":6.3291},{"token_id":"63234107892075973252894556579763050283535055859503091414443970074757771467750","status":"REDEEMABLE","avg_price":0.7899,"current_price":0.0,"current_value":0.0,"realized_pnl":-0.0436,"unrealized_pnl":-4.1499,"total_pnl":-4.1935,"current_size":5.2531},{"token_id":"74071744813515333849424646391280658530446865984842804791705239676919358527019","status":"REDEEMABLE","avg_price":0.7898,"current_price":0.0,"current_value":0.0,"realized_pnl":2.7632,"unrealized_pnl":-10.0053,"total_pnl":-7.2421,"current_size":12.6673}],"pagination":{"limit":7,"offset":0,"has_more":true}}},
"REALIZED_PNL": {"url":"https://data-api.polymarket.com/v2/positions?user=0xbc79e27f2c94124aeefb08d74b4e4fd3ac834e4d&limit=7&sort_by=REALIZED_PNL","status":200,"date":"Fri, 04 Dec 2026 20:56:43 GMT","body":{"data":[{"token_id":"85950283731933994682282061396049926478670817100428423549552644750092884541497","status":"REDEEMABLE","avg_price":0.3021,"current_price":0.0,"current_value":0.0,"realized_pnl":9.075,"unrealized_pnl":-5.0007,"total_pnl":4.0743,"current_size":16.552},{"token_id":"74071744813515333849424646391280658530446865984842804791705239676919358527019","status":"REDEEMABLE","avg_price":0.7898,"current_price":0.0,"current_value":0.0,"realized_pnl":2.7632,"unrealized_pnl":-10.0053,"total_pnl":-7.2421,"current_size":12.6673},{"token_id":"63086340633867374166296916716767345159121388286341018941116828465599669741959","status":"REDEEMABLE","avg_price":0.5897,"current_price":0.0,"current_value":0.0,"realized_pnl":1.1111,"unrealized_pnl":-3.0007,"total_pnl":-1.8896,"current_size":5.0882},{"token_id":"548462943067324124336689254204000269948663684506167200680384187254947446784","status":"OPEN","avg_price":0.5799,"current_price":0.0005,"current_value":0.0043,"realized_pnl":0.0,"unrealized_pnl":-4.9957,"total_pnl":-4.9957,"current_size":8.6206},{"token_id":"874402096953853186496076533822258356735156175384049251327656694874617413633","status":"OPEN","avg_price":0.4599,"current_price":0.0005,"current_value":0.0054,"realized_pnl":0.0,"unrealized_pnl":-4.9946,"total_pnl":-4.9946,"current_size":10.8695},{"token_id":"49458764017597659514573234731940998982339359646087074270291874830372572595732","status":"REDEEMABLE","avg_price":0.0199,"current_price":0.0,"current_value":0.0,"realized_pnl":-0.01,"unrealized_pnl":-0.2039,"total_pnl":-0.2139,"current_size":10.2},{"token_id":"2618591573832738162913679271927267207972968872239887962293396886053858554649","status":"REDEEMABLE","avg_price":0.7299,"current_price":0.0,"current_value":0.0,"realized_pnl":-0.0149,"unrealized_pnl":-1.0999,"total_pnl":-1.1148,"current_size":1.5068}],"pagination":{"limit":7,"offset":0,"has_more":true}}},
"UNREALIZED_PNL": {"url":"https://data-api.polymarket.com/v2/positions?user=0xbc79e27f2c94124aeefb08d74b4e4fd3ac834e4d&limit=7&sort_by=UNREALIZED_PNL","status":200,"date":"Fri, 04 Dec 2026 20:56:43 GMT","body":{"data":[{"token_id":"49932611791842248277648635261891267637049151266001723816279042019553905945029","status":"OPEN","avg_price":0.0767,"current_price":0.0845,"current_value":1.5914,"realized_pnl":-2.7801,"unrealized_pnl":0.1462,"total_pnl":-2.6339,"current_size":18.8333},{"token_id":"49458764017597659514573234731940998982339359646087074270291874830372572595732","status":"REDEEMABLE","avg_price":0.0199,"current_price":0.0,"current_value":0.0,"realized_pnl":-0.01,"unrealized_pnl":-0.2039,"total_pnl":-0.2139,"current_size":10.2},{"token_id":"2618591573832738162913679271927267207972968872239887962293396886053858554649","status":"REDEEMABLE","avg_price":0.7299,"current_price":0.0,"current_value":0.0,"realized_pnl":-0.0149,"unrealized_pnl":-1.0999,"total_pnl":-1.1148,"current_size":1.5068},{"token_id":"54065802348264340781180366286468940160774623409772296945681445781417976930148","status":"REDEEMABLE","avg_price":0.4199,"current_price":0.0,"current_value":0.0,"realized_pnl":-0.0412,"unrealized_pnl":-1.4199,"total_pnl":-1.4611,"current_size":3.3809},{"token_id":"41330338653304219709555029188568269032082472789433655579873196372491063819991","status":"REDEEMABLE","avg_price":0.5299,"current_price":0.0,"current_value":0.0,"realized_pnl":-0.0452,"unrealized_pnl":-1.9199,"total_pnl":-1.9651,"current_size":3.6226},{"token_id":"110628429202387177247865174708140645662223783382160894070566377074936174195944","status":"REDEEMABLE","avg_price":0.01,"current_price":0.0,"current_value":0.0,"realized_pnl":-0.099,"unrealized_pnl":-2.0,"total_pnl":-2.099,"current_size":200.0},{"token_id":"17081582571570121060773872712824914681371082713110525237465736969237633904493","status":"REDEEMABLE","avg_price":0.01,"current_price":0.0,"current_value":0.0,"realized_pnl":-0.099,"unrealized_pnl":-2.0,"total_pnl":-2.099,"current_size":200.0}],"pagination":{"limit":7,"offset":0,"has_more":true}}},
"TOTAL_PNL": {"url":"https://data-api.polymarket.com/v2/positions?user=0xbc79e27f2c94124aeefb08d74b4e4fd3ac834e4d&limit=7&sort_by=TOTAL_PNL","status":200,"date":"Fri, 04 Dec 2026 20:56:43 GMT","body":{"data":[{"token_id":"85950283731933994682282061396049926478670817100428423549552644750092884541497","status":"REDEEMABLE","avg_price":0.3021,"current_price":0.0,"current_value":0.0,"realized_pnl":9.075,"unrealized_pnl":-5.0007,"total_pnl":4.0743,"current_size":16.552},{"token_id":"49458764017597659514573234731940998982339359646087074270291874830372572595732","status":"REDEEMABLE","avg_price":0.0199,"current_price":0.0,"current_value":0.0,"realized_pnl":-0.01,"unrealized_pnl":-0.2039,"total_pnl":-0.2139,"current_size":10.2},{"token_id":"2618591573832738162913679271927267207972968872239887962293396886053858554649","status":"REDEEMABLE","avg_price":0.7299,"current_price":0.0,"current_value":0.0,"realized_pnl":-0.0149,"unrealized_pnl":-1.0999,"total_pnl":-1.1148,"current_size":1.5068},{"token_id":"54065802348264340781180366286468940160774623409772296945681445781417976930148","status":"REDEEMABLE","avg_price":0.4199,"current_price":0.0,"current_value":0.0,"realized_pnl":-0.0412,"unrealized_pnl":-1.4199,"total_pnl":-1.4611,"current_size":3.3809},{"token_id":"63086340633867374166296916716767345159121388286341018941116828465599669741959","status":"REDEEMABLE","avg_price":0.5897,"current_price":0.0,"current_value":0.0,"realized_pnl":1.1111,"unrealized_pnl":-3.0007,"total_pnl":-1.8896,"current_size":5.0882},{"token_id":"41330338653304219709555029188568269032082472789433655579873196372491063819991","status":"REDEEMABLE","avg_price":0.5299,"current_price":0.0,"current_value":0.0,"realized_pnl":-0.0452,"unrealized_pnl":-1.9199,"total_pnl":-1.9651,"current_size":3.6226},{"token_id":"47077648217971757308720798158325917219531658951054235799631815254380459178462","status":"REDEEMABLE","avg_price":0.8299,"current_price":0.0,"current_value":0.0,"realized_pnl":-0.0175,"unrealized_pnl":-2.0499,"total_pnl":-2.0674,"current_size":2.4698}],"pagination":{"limit":7,"offset":0,"has_more":true}}},
"closed_default": {"url":"https://data-api.polymarket.com/v2/positions?user=0xbc79e27f2c94124aeefb08d74b4e4fd3ac834e4d&limit=7&status=CLOSED","status":200,"date":"Fri, 04 Dec 2026 20:56:44 GMT","body":{"data":[{"token_id":"64620987201699714450904116765860966371545498125118736828680924169103742549403","status":"CLOSED","avg_price":0.2563,"current_price":1.0,"current_value":0.0,"realized_pnl":140.2894,"unrealized_pnl":0.0,"total_pnl":140.2894,"current_size":0.0},{"token_id":"75330054133399519852942415648680462506229215995803834711708101333223557605575","status":"CLOSED","avg_price":0.1397,"current_price":1.0,"current_value":0.0,"realized_pnl":109.1872,"unrealized_pnl":0.0,"total_pnl":109.1872,"current_size":0.0},{"token_id":"72888742932028991999466800216526896647951096092660478043802178498251332433741","status":"CLOSED","avg_price":0.487,"current_price":1.0,"current_value":0.0,"realized_pnl":90.3027,"unrealized_pnl":0.0,"total_pnl":90.3027,"current_size":0.0},{"token_id":"86843952992160665672559618028215743820638930427178683578703356678040675334819","status":"CLOSED","avg_price":0.4409,"current_price":1.0,"current_value":0.0,"realized_pnl":76.3429,"unrealized_pnl":0.0,"total_pnl":76.3429,"current_size":0.0},{"token_id":"55777510390318665492467086761401190607530819299865696880260617846434456780822","status":"CLOSED","avg_price":0.3715,"current_price":1.0,"current_value":0.0088,"realized_pnl":69.8901,"unrealized_pnl":0.0,"total_pnl":69.8901,"current_size":0.0088},{"token_id":"44996766623670111163185478315686536955427082108927675029181126638545537017422","status":"CLOSED","avg_price":0.1583,"current_price":1.0,"current_value":0.0,"realized_pnl":66.0998,"unrealized_pnl":0.0,"total_pnl":66.0998,"current_size":0.0},{"token_id":"651293246995138689769147052202072185438268329505895120511651147642598064129","status":"CLOSED","avg_price":0.1734,"current_price":1.0,"current_value":0.0,"realized_pnl":59.5228,"unrealized_pnl":0.0,"total_pnl":59.5228,"current_size":0.0}],"pagination":{"limit":7,"offset":0,"has_more":true}}},
"closed_price": {"url":"https://data-api.polymarket.com/v2/positions?user=0xbc79e27f2c94124aeefb08d74b4e4fd3ac834e4d&limit=7&status=CLOSED&sort_by=PRICE","status":200,"date":"Fri, 04 Dec 2026 20:56:44 GMT","body":{"data":[{"token_id":"64620987201699714450904116765860966371545498125118736828680924169103742549403","status":"CLOSED","avg_price":0.2563,"current_price":1.0,"current_value":0.0,"realized_pnl":140.2894,"unrealized_pnl":0.0,"total_pnl":140.2894,"current_size":0.0},{"token_id":"75330054133399519852942415648680462506229215995803834711708101333223557605575","status":"CLOSED","avg_price":0.1397,"current_price":1.0,"current_value":0.0,"realized_pnl":109.1872,"unrealized_pnl":0.0,"total_pnl":109.1872,"current_size":0.0},{"token_id":"72888742932028991999466800216526896647951096092660478043802178498251332433741","status":"CLOSED","avg_price":0.487,"current_price":1.0,"current_value":0.0,"realized_pnl":90.3027,"unrealized_pnl":0.0,"total_pnl":90.3027,"current_size":0.0},{"token_id":"86843952992160665672559618028215743820638930427178683578703356678040675334819","status":"CLOSED","avg_price":0.4409,"current_price":1.0,"current_value":0.0,"realized_pnl":76.3429,"unrealized_pnl":0.0,"total_pnl":76.3429,"current_size":0.0},{"token_id":"55777510390318665492467086761401190607530819299865696880260617846434456780822","status":"CLOSED","avg_price":0.3715,"current_price":1.0,"current_value":0.0088,"realized_pnl":69.8901,"unrealized_pnl":0.0,"total_pnl":69.8901,"current_size":0.0088},{"token_id":"44996766623670111163185478315686536955427082108927675029181126638545537017422","status":"CLOSED","avg_price":0.1583,"current_price":1.0,"current_value":0.0,"realized_pnl":66.0998,"unrealized_pnl":0.0,"total_pnl":66.0998,"current_size":0.0},{"token_id":"651293246995138689769147052202072185438268329505895120511651147642598064129","status":"CLOSED","avg_price":0.1734,"current_price":1.0,"current_value":0.0,"realized_pnl":59.5228,"unrealized_pnl":0.0,"total_pnl":59.5228,"current_size":0.0}],"pagination":{"limit":7,"offset":0,"has_more":true}}},
"closed_value": {"url":"https://data-api.polymarket.com/v2/positions?user=0xbc79e27f2c94124aeefb08d74b4e4fd3ac834e4d&limit=7&status=CLOSED&sort_by=CURRENT_VALUE","status":200,"date":"Fri, 04 Dec 2026 20:56:44 GMT","body":{"data":[{"token_id":"64620987201699714450904116765860966371545498125118736828680924169103742549403","status":"CLOSED","avg_price":0.2563,"current_price":1.0,"current_value":0.0,"realized_pnl":140.2894,"unrealized_pnl":0.0,"total_pnl":140.2894,"current_size":0.0},{"token_id":"75330054133399519852942415648680462506229215995803834711708101333223557605575","status":"CLOSED","avg_price":0.1397,"current_price":1.0,"current_value":0.0,"realized_pnl":109.1872,"unrealized_pnl":0.0,"total_pnl":109.1872,"current_size":0.0},{"token_id":"72888742932028991999466800216526896647951096092660478043802178498251332433741","status":"CLOSED","avg_price":0.487,"current_price":1.0,"current_value":0.0,"realized_pnl":90.3027,"unrealized_pnl":0.0,"total_pnl":90.3027,"current_size":0.0},{"token_id":"86843952992160665672559618028215743820638930427178683578703356678040675334819","status":"CLOSED","avg_price":0.4409,"current_price":1.0,"current_value":0.0,"realized_pnl":76.3429,"unrealized_pnl":0.0,"total_pnl":76.3429,"current_size":0.0},{"token_id":"55777510390318665492467086761401190607530819299865696880260617846434456780822","status":"CLOSED","avg_price":0.3715,"current_price":1.0,"current_value":0.0088,"realized_pnl":69.8901,"unrealized_pnl":0.0,"total_pnl":69.8901,"current_size":0.0088},{"token_id":"44996766623670111163185478315686536955427082108927675029181126638545537017422","status":"CLOSED","avg_price":0.1583,"current_price":1.0,"current_value":0.0,"realized_pnl":66.0998,"unrealized_pnl":0.0,"total_pnl":66.0998,"current_size":0.0},{"token_id":"651293246995138689769147052202072185438268329505895120511651147642598064129","status":"CLOSED","avg_price":0.1734,"current_price":1.0,"current_value":0.0,"realized_pnl":59.5228,"unrealized_pnl":0.0,"total_pnl":59.5228,"current_size":0.0}],"pagination":{"limit":7,"offset":0,"has_more":true}}},
"closed_avg": {"url":"https://data-api.polymarket.com/v2/positions?user=0xbc79e27f2c94124aeefb08d74b4e4fd3ac834e4d&limit=7&status=CLOSED&sort_by=AVG_PRICE","status":400,"date":"Fri, 04 Dec 2026 20:56:44 GMT","body":{"error":"sortBy=AVG_PRICE is not supported on a user's CLOSED or REDEEMABLE_LOST positions","code":"invalid_request","parameter":"sort_by","retryable":false}},
"lost_avg": {"url":"https://data-api.polymarket.com/v2/positions?user=0xbc79e27f2c94124aeefb08d74b4e4fd3ac834e4d&limit=7&status=REDEEMABLE_LOST&sort_by=AVG_PRICE","status":400,"date":"Fri, 04 Dec 2026 20:56:44 GMT","body":{"error":"sortBy=AVG_PRICE is not supported on a user's CLOSED or REDEEMABLE_LOST positions","code":"invalid_request","parameter":"sort_by","retryable":false}},
"realized_asc": {"url":"https://data-api.polymarket.com/v2/positions?user=0xbc79e27f2c94124aeefb08d74b4e4fd3ac834e4d&limit=7&sort_by=REALIZED_PNL&sort_direction=ASC","status":200,"date":"Fri, 04 Dec 2026 20:56:45 GMT","body":{"data":[{"token_id":"49932611791842248277648635261891267637049151266001723816279042019553905945029","status":"OPEN","avg_price":0.0767,"current_price":0.0845,"current_value":1.5914,"realized_pnl":-2.7801,"unrealized_pnl":0.1462,"total_pnl":-2.6339,"current_size":18.8333},{"token_id":"1188548547445269520707219060348990378779441344231931183199848184706112898196","status":"REDEEMABLE","avg_price":0.4867,"current_price":0.0,"current_value":0.0,"realized_pnl":-2.5321,"unrealized_pnl":-4.2565,"total_pnl":-6.7886,"current_size":8.745},{"token_id":"60488319664307907808238843684363128940030194181923783216789526080413999461490","status":"REDEEMABLE","avg_price":0.8899,"current_price":0.0,"current_value":0.0,"realized_pnl":-2.354,"unrealized_pnl":-10.0025,"total_pnl":-12.3565,"current_size":11.239},{"token_id":"892410193561107172609378383902568085199971906757190112078441271767169236993","status":"REDEEMABLE","avg_price":0.2521,"current_price":0.0,"current_value":0.0,"realized_pnl":-0.5598,"unrealized_pnl":-15.0,"total_pnl":-15.5598,"current_size":59.4884},{"token_id":"95229129827670087220727100480106541228024373756540169057303133111627214417806","status":"REDEEMABLE","avg_price":0.4514,"current_price":0.0,"current_value":0.0,"realized_pnl":-0.5483,"unrealized_pnl":-19.9999,"total_pnl":-20.5482,"current_size":44.3002},{"token_id":"93415544680886777702827441791006010294818009048547752679075414774317684068568","status":"REDEEMABLE","avg_price":0.4265,"current_price":0.0,"current_value":0.0,"realized_pnl":-0.5375,"unrealized_pnl":-18.9999,"total_pnl":-19.5374,"current_size":44.5414},{"token_id":"62981699707887980466392119482265940477346988633684735288536223089899860523618","status":"REDEEMABLE","avg_price":0.7096,"current_price":0.0,"current_value":0.0,"realized_pnl":-0.43,"unrealized_pnl":-29.9998,"total_pnl":-30.4298,"current_size":42.2733}],"pagination":{"limit":7,"offset":0,"has_more":true}}}
}
@@ -1,47 +0,0 @@
{
"position": {
"condition_id": "0xdc8c47c5b5d38a0da237b5a82f500ebc5cf5150de902962ac6ff76051ffe9159",
"token_id": "49932611791842248277648635261891267637049151266001723816279042019553905945029",
"proxy_wallet": "0xbc79e27f2c94124aeefb08d74b4e4fd3ac834e4d",
"current_size": 18.8333,
"total_size": 63.8333,
"avg_price": 0.0767,
"current_value": 0.9322,
"entry_cost_usdc": 1.4451,
"entry_fees_usdc": 0.066709,
"total_cost_usdc": 1.511809,
"realized_pnl": -2.7801,
"unrealized_pnl": -0.5129,
"total_pnl": -3.293
},
"trades": {
"url": "https://data-api.polymarket.com/v2/trades?user=0xbc79e27f2c94124aeefb08d74b4e4fd3ac834e4d&condition=0xdc8c47c5b5d38a0da237b5a82f500ebc5cf5150de902962ac6ff76051ffe9159&limit=50",
"status": 200,
"date": "Fri, 04 Dec 2026 20:53:08 GMT",
"body": {
"data": [
{
"token_id": "49932611791842248277648635261891267637049151266001723816279042019553905945029",
"side": "SELL",
"price": 0.0194444444,
"size": 45.0,
"timestamp": 1796380585
},
{
"token_id": "49932611791842248277648635261891267637049151266001723816279042019553905945029",
"side": "BUY",
"price": 0.077,
"size": 24.65,
"timestamp": 1796319905
},
{
"token_id": "49932611791842248277648635261891267637049151266001723816279042019553905945029",
"side": "BUY",
"price": 0.0765630793,
"size": 39.183377,
"timestamp": 1796319905
}
]
}
}
}
@@ -1,17 +0,0 @@
{
"baseline": {"url":"https://data-api.polymarket.com/v2/positions?user=0x0000000000000000000000000000000000000001&condition=0x87822b3d4ccba1835d698354b01c050b55f20c5f34b14908bff4ea5a6d58af4c&status=OPEN&limit=5","status":200,"date":"Fri, 04 Dec 2026 20:46:44 GMT","body":{"data":[{"token_id":"29677413448356631423250052573262008356913370083986817030510370064664558041792","condition_id":"0x87822b3d4ccba1835d698354b01c050b55f20c5f34b14908bff4ea5a6d58af4c","event_id":"16125","title":"Will Mark Carney be the next Canadian Prime Minister?","current_size":10.0,"current_value":10.0,"status":"REDEEMABLE"}]}},
"title": {"url":"https://data-api.polymarket.com/v2/positions?user=0x0000000000000000000000000000000000000001&condition=0x87822b3d4ccba1835d698354b01c050b55f20c5f34b14908bff4ea5a6d58af4c&status=OPEN&limit=5&title=wILL+mARK+cARNEY+BE+THE+NEXT+cANADIAN+pRIME+mINISTER%3F","status":200,"date":"Fri, 04 Dec 2026 20:46:44 GMT","body":{"data":[{"token_id":"29677413448356631423250052573262008356913370083986817030510370064664558041792","condition_id":"0x87822b3d4ccba1835d698354b01c050b55f20c5f34b14908bff4ea5a6d58af4c","event_id":"16125","title":"Will Mark Carney be the next Canadian Prime Minister?","current_size":10.0,"current_value":10.0,"status":"REDEEMABLE"}]}},
"wildcard": {"url":"https://data-api.polymarket.com/v2/positions?user=0x0000000000000000000000000000000000000001&condition=0x87822b3d4ccba1835d698354b01c050b55f20c5f34b14908bff4ea5a6d58af4c&status=OPEN&limit=5&title=%25","status":200,"date":"Fri, 04 Dec 2026 20:46:44 GMT","body":{"data":[{"token_id":"29677413448356631423250052573262008356913370083986817030510370064664558041792","condition_id":"0x87822b3d4ccba1835d698354b01c050b55f20c5f34b14908bff4ea5a6d58af4c","event_id":"16125","title":"Will Mark Carney be the next Canadian Prime Minister?","current_size":10.0,"current_value":10.0,"status":"REDEEMABLE"}]}},
"missing_title": {"url":"https://data-api.polymarket.com/v2/positions?user=0x0000000000000000000000000000000000000001&condition=0x87822b3d4ccba1835d698354b01c050b55f20c5f34b14908bff4ea5a6d58af4c&status=OPEN&limit=5&title=unmatched-xzyz","status":200,"date":"Fri, 04 Dec 2026 20:46:44 GMT","body":{"data":[]}},
"event_id": {"url":"https://data-api.polymarket.com/v2/positions?user=0x0000000000000000000000000000000000000001&status=OPEN&limit=5&event_id=16125","status":200,"date":"Fri, 04 Dec 2026 20:46:45 GMT","body":{"data":[{"token_id":"29677413448356631423250052573262008356913370083986817030510370064664558041792","condition_id":"0x87822b3d4ccba1835d698354b01c050b55f20c5f34b14908bff4ea5a6d58af4c","event_id":"16125","title":"Will Mark Carney be the next Canadian Prime Minister?","current_size":10.0,"current_value":10.0,"status":"REDEEMABLE"}]}},
"eventId": {"url":"https://data-api.polymarket.com/v2/positions?user=0x0000000000000000000000000000000000000001&status=OPEN&limit=5&eventId=16125","status":200,"date":"Fri, 04 Dec 2026 20:46:44 GMT","body":{"data":[{"token_id":"29677413448356631423250052573262008356913370083986817030510370064664558041792","condition_id":"0x87822b3d4ccba1835d698354b01c050b55f20c5f34b14908bff4ea5a6d58af4c","event_id":"16125","title":"Will Mark Carney be the next Canadian Prime Minister?","current_size":10.0,"current_value":10.0,"status":"REDEEMABLE"}]}},
"conflict": {"url":"https://data-api.polymarket.com/v2/positions?user=0x0000000000000000000000000000000000000001&condition=0x87822b3d4ccba1835d698354b01c050b55f20c5f34b14908bff4ea5a6d58af4c&status=OPEN&limit=5&event_id=16125","status":400,"date":"Fri, 04 Dec 2026 20:46:45 GMT","body":{"error":"must provide either eventId or condition, not both","code":"invalid_request","retryable":false}},
"wrong_event": {"url":"https://data-api.polymarket.com/v2/positions?user=0x0000000000000000000000000000000000000001&status=OPEN&limit=5&event_id=1","status":200,"date":"Fri, 04 Dec 2026 20:46:45 GMT","body":{"data":[]}},
"invalid_event": {"url":"https://data-api.polymarket.com/v2/positions?user=0x0000000000000000000000000000000000000001&status=OPEN&limit=5&event_id=bad","status":200,"date":"Fri, 04 Dec 2026 20:46:45 GMT","body":{"data":[]}},
"threshold": {"url":"https://data-api.polymarket.com/v2/positions?user=0x0000000000000000000000000000000000000001&condition=0x87822b3d4ccba1835d698354b01c050b55f20c5f34b14908bff4ea5a6d58af4c&status=OPEN&limit=5&filter_type=TOKENS&filter_amount=10.0","status":200,"date":"Fri, 04 Dec 2026 20:46:45 GMT","body":{"data":[{"token_id":"29677413448356631423250052573262008356913370083986817030510370064664558041792","condition_id":"0x87822b3d4ccba1835d698354b01c050b55f20c5f34b14908bff4ea5a6d58af4c","event_id":"16125","title":"Will Mark Carney be the next Canadian Prime Minister?","current_size":10.0,"current_value":10.0,"status":"REDEEMABLE"}]}},
"above_threshold": {"url":"https://data-api.polymarket.com/v2/positions?user=0x0000000000000000000000000000000000000001&condition=0x87822b3d4ccba1835d698354b01c050b55f20c5f34b14908bff4ea5a6d58af4c&status=OPEN&limit=5&filter_type=TOKENS&filter_amount=11.0","status":200,"date":"Fri, 04 Dec 2026 20:46:45 GMT","body":{"data":[]}},
"cash": {"url":"https://data-api.polymarket.com/v2/positions?user=0x0000000000000000000000000000000000000001&condition=0x87822b3d4ccba1835d698354b01c050b55f20c5f34b14908bff4ea5a6d58af4c&status=OPEN&limit=5&filter_type=CASH&filter_amount=11.0","status":200,"date":"Fri, 04 Dec 2026 20:46:45 GMT","body":{"data":[]}},
"lowercase_type": {"url":"https://data-api.polymarket.com/v2/positions?user=0x0000000000000000000000000000000000000001&condition=0x87822b3d4ccba1835d698354b01c050b55f20c5f34b14908bff4ea5a6d58af4c&status=OPEN&limit=5&filter_type=cash&filter_amount=11.0","status":200,"date":"Fri, 04 Dec 2026 20:46:45 GMT","body":{"data":[]}},
"invalid_type": {"url":"https://data-api.polymarket.com/v2/positions?user=0x0000000000000000000000000000000000000001&condition=0x87822b3d4ccba1835d698354b01c050b55f20c5f34b14908bff4ea5a6d58af4c&status=OPEN&limit=5&filter_type=weird&filter_amount=11.0","status":400,"date":"Fri, 04 Dec 2026 20:46:45 GMT","body":{"error":"filterType must be CASH or TOKENS","code":"invalid_request","parameter":"filter_type","retryable":false}},
"negative_amount": {"url":"https://data-api.polymarket.com/v2/positions?user=0x0000000000000000000000000000000000000001&condition=0x87822b3d4ccba1835d698354b01c050b55f20c5f34b14908bff4ea5a6d58af4c&status=OPEN&limit=5&filter_type=TOKENS&filter_amount=-1","status":200,"date":"Fri, 04 Dec 2026 20:46:46 GMT","body":{"data":[{"token_id":"29677413448356631423250052573262008356913370083986817030510370064664558041792","condition_id":"0x87822b3d4ccba1835d698354b01c050b55f20c5f34b14908bff4ea5a6d58af4c","event_id":"16125","title":"Will Mark Carney be the next Canadian Prime Minister?","current_size":10.0,"current_value":10.0,"status":"REDEEMABLE"}]}}
}
@@ -1,27 +0,0 @@
[
{"status":"OPEN","request":"https://data-api.polymarket.com/v2/positions?user=0xbc79e27f2c94124aeefb08d74b4e4fd3ac834e4d&status=OPEN&limit=5","observed_at":"Fri, 04 Dec 2026 20:39:57 GMT","http_status":200,"data":[{"proxy_wallet":"0xbc79e27f2c94124aeefb08d74b4e4fd3ac834e4d","condition_id":"0x016124720ad566f88bc302b21b492db296000000000000000000000000000000","token_id":"623948551310085686003807523523823512265834388288292452103061352323364159488","current_size":15.1515,"current_value":15.0757,"current_price":0.995,"status":"OPEN","mergeable":false,"redeemable":false,"archived":false},{"proxy_wallet":"0xbc79e27f2c94124aeefb08d74b4e4fd3ac834e4d","condition_id":"0x016bf4066e82571228813b876d04127934000000000000000000000000000000","token_id":"643049684020821311351796507355633171121115944121291300545830924465303715840","current_size":8.9285,"current_value":4.5982,"current_price":0.515,"status":"OPEN","mergeable":false,"redeemable":false,"archived":false},{"proxy_wallet":"0xbc79e27f2c94124aeefb08d74b4e4fd3ac834e4d","condition_id":"0xdc8c47c5b5d38a0da237b5a82f500ebc5cf5150de902962ac6ff76051ffe9159","token_id":"49932611791842248277648635261891267637049151266001723816279042019553905945029","current_size":18.8333,"current_value":0.9322,"current_price":0.0495,"status":"OPEN","mergeable":false,"redeemable":false,"archived":false},{"proxy_wallet":"0xbc79e27f2c94124aeefb08d74b4e4fd3ac834e4d","condition_id":"0x01f91615c9f752dc4e9138a6d1c9ded081000000000000000000000000000000","token_id":"892410193561107172609378383902568085199971906757190112078441271767169236993","current_size":59.4884,"current_value":0.0297,"current_price":0.0005,"status":"OPEN","mergeable":false,"redeemable":false,"archived":false},{"proxy_wallet":"0xbc79e27f2c94124aeefb08d74b4e4fd3ac834e4d","condition_id":"0x01eee4e05ca8e4c40c00966bddccf9acb1000000000000000000000000000000","token_id":"874402096953853186496076533822258356735156175384049251327656694874617413633","current_size":10.8695,"current_value":0.0054,"current_price":0.0005,"status":"OPEN","mergeable":false,"redeemable":false,"archived":false}],"has_more":true},
{"status":"REDEEMABLE","request":"https://data-api.polymarket.com/v2/positions?user=0xbc79e27f2c94124aeefb08d74b4e4fd3ac834e4d&status=REDEEMABLE&limit=5","observed_at":"Fri, 04 Dec 2026 20:39:57 GMT","http_status":200,"data":[{"proxy_wallet":"0xbc79e27f2c94124aeefb08d74b4e4fd3ac834e4d","condition_id":"0x73cbafa706ecd442f1d425760bf6990956d02f80a05218e2572ed8ff7d86600b","token_id":"100763846727527357412896243147875965206285074082132692057261517775218157995567","current_size":6.0,"current_value":0.0,"current_price":0.0,"status":"REDEEMABLE","mergeable":false,"redeemable":true,"archived":false},{"proxy_wallet":"0xbc79e27f2c94124aeefb08d74b4e4fd3ac834e4d","condition_id":"0x4b447aa24c5102be629d34e69972b4b8e9dad5692fb254627a66872add7ba02d","token_id":"103877075039694027145965660409462575325733871480609040594710427223250156456853","current_size":5.0847,"current_value":0.0,"current_price":0.0,"status":"REDEEMABLE","mergeable":false,"redeemable":true,"archived":false},{"proxy_wallet":"0xbc79e27f2c94124aeefb08d74b4e4fd3ac834e4d","condition_id":"0x7a7f7d7dcf69d3da887bf3732e7b4b2e8027ddad31395723d59ff759fe9bde56","token_id":"104746504118717300110262411640865393647451671620802814999140848418915045458343","current_size":4.8873,"current_value":0.0,"current_price":0.0,"status":"REDEEMABLE","mergeable":false,"redeemable":true,"archived":false},{"proxy_wallet":"0xbc79e27f2c94124aeefb08d74b4e4fd3ac834e4d","condition_id":"0x1737056c8ea1cc123713358625034c7bfa7cd5774ef640be9b8b199b9ace1552","token_id":"105214925774848454231506621805852425090385120703591449046381705680407825366975","current_size":11.6279,"current_value":0.0,"current_price":0.0,"status":"REDEEMABLE","mergeable":false,"redeemable":true,"archived":false},{"proxy_wallet":"0xbc79e27f2c94124aeefb08d74b4e4fd3ac834e4d","condition_id":"0xe1ae15398ca106ac2e444ba2258b108889b532e0990f89b1e7822b4ffb799eaf","token_id":"105426785463374522069343252785158212507372409184321993521191917200251587638020","current_size":30.9246,"current_value":0.0,"current_price":0.0,"status":"REDEEMABLE","mergeable":false,"redeemable":true,"archived":false}],"has_more":true},
{"status":"REDEEMABLE_LOST","request":"https://data-api.polymarket.com/v2/positions?user=0xbc79e27f2c94124aeefb08d74b4e4fd3ac834e4d&status=REDEEMABLE_LOST&limit=5","observed_at":"Fri, 04 Dec 2026 20:39:57 GMT","http_status":200,"data":[{"proxy_wallet":"0xbc79e27f2c94124aeefb08d74b4e4fd3ac834e4d","condition_id":"0x73cbafa706ecd442f1d425760bf6990956d02f80a05218e2572ed8ff7d86600b","token_id":"100763846727527357412896243147875965206285074082132692057261517775218157995567","current_size":6.0,"current_value":0.0,"current_price":0.0,"status":"REDEEMABLE","mergeable":false,"redeemable":true,"archived":false},{"proxy_wallet":"0xbc79e27f2c94124aeefb08d74b4e4fd3ac834e4d","condition_id":"0x4b447aa24c5102be629d34e69972b4b8e9dad5692fb254627a66872add7ba02d","token_id":"103877075039694027145965660409462575325733871480609040594710427223250156456853","current_size":5.0847,"current_value":0.0,"current_price":0.0,"status":"REDEEMABLE","mergeable":false,"redeemable":true,"archived":false},{"proxy_wallet":"0xbc79e27f2c94124aeefb08d74b4e4fd3ac834e4d","condition_id":"0x7a7f7d7dcf69d3da887bf3732e7b4b2e8027ddad31395723d59ff759fe9bde56","token_id":"104746504118717300110262411640865393647451671620802814999140848418915045458343","current_size":4.8873,"current_value":0.0,"current_price":0.0,"status":"REDEEMABLE","mergeable":false,"redeemable":true,"archived":false},{"proxy_wallet":"0xbc79e27f2c94124aeefb08d74b4e4fd3ac834e4d","condition_id":"0x1737056c8ea1cc123713358625034c7bfa7cd5774ef640be9b8b199b9ace1552","token_id":"105214925774848454231506621805852425090385120703591449046381705680407825366975","current_size":11.6279,"current_value":0.0,"current_price":0.0,"status":"REDEEMABLE","mergeable":false,"redeemable":true,"archived":false},{"proxy_wallet":"0xbc79e27f2c94124aeefb08d74b4e4fd3ac834e4d","condition_id":"0xe1ae15398ca106ac2e444ba2258b108889b532e0990f89b1e7822b4ffb799eaf","token_id":"105426785463374522069343252785158212507372409184321993521191917200251587638020","current_size":30.9246,"current_value":0.0,"current_price":0.0,"status":"REDEEMABLE","mergeable":false,"redeemable":true,"archived":false}],"has_more":true},
{"status":"MERGEABLE","request":"https://data-api.polymarket.com/v2/positions?user=0xbc79e27f2c94124aeefb08d74b4e4fd3ac834e4d&status=MERGEABLE&limit=5","observed_at":"Fri, 04 Dec 2026 20:39:57 GMT","http_status":200,"data":[],"has_more":false},
{"status":"CLOSED","request":"https://data-api.polymarket.com/v2/positions?user=0xbc79e27f2c94124aeefb08d74b4e4fd3ac834e4d&status=CLOSED&limit=5","observed_at":"Fri, 04 Dec 2026 20:39:57 GMT","http_status":200,"data":[{"proxy_wallet":"0xbc79e27f2c94124aeefb08d74b4e4fd3ac834e4d","condition_id":"0x738bf8bbf91b9dfd7e7d17e361ecfea7176ef33d383b6028ce9668fd69c4467d","token_id":"64620987201699714450904116765860966371545498125118736828680924169103742549403","current_size":0.0,"current_value":0.0,"current_price":1.0,"status":"CLOSED","mergeable":false,"redeemable":false,"archived":false},{"proxy_wallet":"0xbc79e27f2c94124aeefb08d74b4e4fd3ac834e4d","condition_id":"0x6dec4720e43ba8dd413f37760e97af043c54926dfbae4ffccd732cca308068ed","token_id":"75330054133399519852942415648680462506229215995803834711708101333223557605575","current_size":0.0,"current_value":0.0,"current_price":1.0,"status":"CLOSED","mergeable":false,"redeemable":false,"archived":false},{"proxy_wallet":"0xbc79e27f2c94124aeefb08d74b4e4fd3ac834e4d","condition_id":"0x0b0e47715d9901114b4c59b2908251b15a315207f7ab9b9799de81c831828b1a","token_id":"72888742932028991999466800216526896647951096092660478043802178498251332433741","current_size":0.0,"current_value":0.0,"current_price":1.0,"status":"CLOSED","mergeable":false,"redeemable":false,"archived":false},{"proxy_wallet":"0xbc79e27f2c94124aeefb08d74b4e4fd3ac834e4d","condition_id":"0x6fa1a21ce8cb9f6aa46edf5cf83e854afa2f7c96c535f06f0621d5f2016f3a89","token_id":"86843952992160665672559618028215743820638930427178683578703356678040675334819","current_size":0.0,"current_value":0.0,"current_price":1.0,"status":"CLOSED","mergeable":false,"redeemable":false,"archived":false},{"proxy_wallet":"0xbc79e27f2c94124aeefb08d74b4e4fd3ac834e4d","condition_id":"0x584f4cbc22ad93f05c1bde730a3b0c90a0ca3aee5d645d7641d4603b43ee305e","token_id":"55777510390318665492467086761401190607530819299865696880260617846434456780822","current_size":0.0088,"current_value":0.0088,"current_price":1.0,"status":"CLOSED","mergeable":false,"redeemable":true,"archived":false}],"has_more":true},
{"status":"OPEN","request":"https://data-api.polymarket.com/v2/positions?user=0xf7ca80f9a8f7c060a95392779210f74f2c356c84&status=OPEN&limit=5","observed_at":"Fri, 04 Dec 2026 20:39:57 GMT","http_status":200,"data":[{"proxy_wallet":"0xf7ca80f9a8f7c060a95392779210f74f2c356c84","condition_id":"0x01c1a020b58e05a3009ee507a3ff4f0729000000000000000000000000000000","token_id":"794419493339223664676140421620832224698646438653725751911329865844933001216","current_size":124.78,"current_value":123.8441,"current_price":0.9925,"status":"OPEN","mergeable":true,"redeemable":false,"archived":false},{"proxy_wallet":"0xf7ca80f9a8f7c060a95392779210f74f2c356c84","condition_id":"0x01c1a020b58e05a3009ee507a3ff4f0729000000000000000000000000000000","token_id":"794419493339223664676140421620832224698646438653725751911329865844933001217","current_size":125.41,"current_value":0.9405,"current_price":0.0075,"status":"OPEN","mergeable":true,"redeemable":false,"archived":false},{"proxy_wallet":"0xf7ca80f9a8f7c060a95392779210f74f2c356c84","condition_id":"0x637c9bdf7f8890c61c2d9488f8257575d8dfbc8e5708dae5f9aeaf47eb732959","token_id":"7802863854525654123138575151927839237553910654992019912159611729274188962237","current_size":0.29,"current_value":0.29,"current_price":1.0,"status":"REDEEMABLE","mergeable":false,"redeemable":true,"archived":false},{"proxy_wallet":"0xf7ca80f9a8f7c060a95392779210f74f2c356c84","condition_id":"0x2354b05ead4943bd86185e11fde68d4211e96cdc17a5d5c73f1116f21768fb70","token_id":"41775945706322230419100317170276564072148810772947737407607911013106626106551","current_size":0.27,"current_value":0.27,"current_price":1.0,"status":"REDEEMABLE","mergeable":false,"redeemable":true,"archived":false},{"proxy_wallet":"0xf7ca80f9a8f7c060a95392779210f74f2c356c84","condition_id":"0x6cddabbdd2162d82cbc45f20bbabf25cffa07f82da3fa981881d924701b79dbb","token_id":"100039973924308094011065672661860176642793653560164320857887841908176930183682","current_size":80.726,"current_value":0.0,"current_price":0.0,"status":"REDEEMABLE","mergeable":false,"redeemable":true,"archived":false}],"has_more":true},
{"status":"REDEEMABLE","request":"https://data-api.polymarket.com/v2/positions?user=0xf7ca80f9a8f7c060a95392779210f74f2c356c84&status=REDEEMABLE&limit=5","observed_at":"Fri, 04 Dec 2026 20:39:57 GMT","http_status":200,"data":[{"proxy_wallet":"0xf7ca80f9a8f7c060a95392779210f74f2c356c84","condition_id":"0x637c9bdf7f8890c61c2d9488f8257575d8dfbc8e5708dae5f9aeaf47eb732959","token_id":"7802863854525654123138575151927839237553910654992019912159611729274188962237","current_size":0.29,"current_value":0.29,"current_price":1.0,"status":"REDEEMABLE","mergeable":false,"redeemable":true,"archived":false},{"proxy_wallet":"0xf7ca80f9a8f7c060a95392779210f74f2c356c84","condition_id":"0x2354b05ead4943bd86185e11fde68d4211e96cdc17a5d5c73f1116f21768fb70","token_id":"41775945706322230419100317170276564072148810772947737407607911013106626106551","current_size":0.27,"current_value":0.27,"current_price":1.0,"status":"REDEEMABLE","mergeable":false,"redeemable":true,"archived":false},{"proxy_wallet":"0xf7ca80f9a8f7c060a95392779210f74f2c356c84","condition_id":"0x6cddabbdd2162d82cbc45f20bbabf25cffa07f82da3fa981881d924701b79dbb","token_id":"100039973924308094011065672661860176642793653560164320857887841908176930183682","current_size":80.726,"current_value":0.0,"current_price":0.0,"status":"REDEEMABLE","mergeable":false,"redeemable":true,"archived":false},{"proxy_wallet":"0xf7ca80f9a8f7c060a95392779210f74f2c356c84","condition_id":"0x1d02405b049b76beba2320c827e9bc7024ce076d5f690aaafaddb37ef4618312","token_id":"100116739742939922754784677284710427936553332398602782242024802232507374504067","current_size":526.5287,"current_value":0.0,"current_price":0.0,"status":"REDEEMABLE","mergeable":false,"redeemable":true,"archived":false},{"proxy_wallet":"0xf7ca80f9a8f7c060a95392779210f74f2c356c84","condition_id":"0x15e6b013a3543a0383f89abb8830afd2e8be0c842849170aaa600ae3dfbaaa6c","token_id":"100393779853577963580513954385583070858358777009499003882127685996315097055067","current_size":200.0,"current_value":0.0,"current_price":0.0,"status":"REDEEMABLE","mergeable":false,"redeemable":true,"archived":false}],"has_more":true},
{"status":"REDEEMABLE_LOST","request":"https://data-api.polymarket.com/v2/positions?user=0xf7ca80f9a8f7c060a95392779210f74f2c356c84&status=REDEEMABLE_LOST&limit=5","observed_at":"Fri, 04 Dec 2026 20:39:57 GMT","http_status":200,"data":[{"proxy_wallet":"0xf7ca80f9a8f7c060a95392779210f74f2c356c84","condition_id":"0x6cddabbdd2162d82cbc45f20bbabf25cffa07f82da3fa981881d924701b79dbb","token_id":"100039973924308094011065672661860176642793653560164320857887841908176930183682","current_size":80.726,"current_value":0.0,"current_price":0.0,"status":"REDEEMABLE","mergeable":false,"redeemable":true,"archived":false},{"proxy_wallet":"0xf7ca80f9a8f7c060a95392779210f74f2c356c84","condition_id":"0x1d02405b049b76beba2320c827e9bc7024ce076d5f690aaafaddb37ef4618312","token_id":"100116739742939922754784677284710427936553332398602782242024802232507374504067","current_size":526.5287,"current_value":0.0,"current_price":0.0,"status":"REDEEMABLE","mergeable":false,"redeemable":true,"archived":false},{"proxy_wallet":"0xf7ca80f9a8f7c060a95392779210f74f2c356c84","condition_id":"0x15e6b013a3543a0383f89abb8830afd2e8be0c842849170aaa600ae3dfbaaa6c","token_id":"100393779853577963580513954385583070858358777009499003882127685996315097055067","current_size":200.0,"current_value":0.0,"current_price":0.0,"status":"REDEEMABLE","mergeable":false,"redeemable":true,"archived":false},{"proxy_wallet":"0xf7ca80f9a8f7c060a95392779210f74f2c356c84","condition_id":"0xab1b6f5658808737521e83c0967158c1982116c46283ecece415375eb34ac7c7","token_id":"101285568154310971208307776855119673478596477267029240818545990219942975297335","current_size":100.0,"current_value":0.0,"current_price":0.0,"status":"REDEEMABLE","mergeable":false,"redeemable":true,"archived":false},{"proxy_wallet":"0xf7ca80f9a8f7c060a95392779210f74f2c356c84","condition_id":"0xb0e7e2a75362969bf6a6a12cfeda88080fca19cf83fb5e07ada602fba135c993","token_id":"101529303986380227797820995397675670838146600395802452608313597769581050384853","current_size":80.0,"current_value":0.0,"current_price":0.0,"status":"REDEEMABLE","mergeable":false,"redeemable":true,"archived":false}],"has_more":true},
{"status":"MERGEABLE","request":"https://data-api.polymarket.com/v2/positions?user=0xf7ca80f9a8f7c060a95392779210f74f2c356c84&status=MERGEABLE&limit=5","observed_at":"Fri, 04 Dec 2026 20:39:58 GMT","http_status":200,"data":[{"proxy_wallet":"0xf7ca80f9a8f7c060a95392779210f74f2c356c84","condition_id":"0x01c1a020b58e05a3009ee507a3ff4f0729000000000000000000000000000000","token_id":"794419493339223664676140421620832224698646438653725751911329865844933001217","current_size":125.41,"current_value":0.9405,"current_price":0.0075,"status":"OPEN","mergeable":true,"redeemable":false,"archived":false},{"proxy_wallet":"0xf7ca80f9a8f7c060a95392779210f74f2c356c84","condition_id":"0x01c1a020b58e05a3009ee507a3ff4f0729000000000000000000000000000000","token_id":"794419493339223664676140421620832224698646438653725751911329865844933001216","current_size":124.78,"current_value":123.8441,"current_price":0.9925,"status":"OPEN","mergeable":true,"redeemable":false,"archived":false}],"has_more":false},
{"status":"CLOSED","request":"https://data-api.polymarket.com/v2/positions?user=0xf7ca80f9a8f7c060a95392779210f74f2c356c84&status=CLOSED&limit=5","observed_at":"Fri, 04 Dec 2026 20:39:58 GMT","http_status":200,"data":[{"proxy_wallet":"0xf7ca80f9a8f7c060a95392779210f74f2c356c84","condition_id":"0xe9981200d697d4729963dada67485373d8b79a53eb255939a7069e42d46d4f6c","token_id":"99975885905088265651270566134319140793798341996806903249122353498509388749063","current_size":0.0,"current_value":0.0,"current_price":1.0,"status":"CLOSED","mergeable":false,"redeemable":false,"archived":false},{"proxy_wallet":"0xf7ca80f9a8f7c060a95392779210f74f2c356c84","condition_id":"0xd8f6e1a887b882f35b3bbf7fb85b9d826870a9a1920c00caaa53bd949cffa949","token_id":"105306919281568750525162884908349813267467919393753767766216631616424696605401","current_size":0.0,"current_value":0.0,"current_price":1.0,"status":"CLOSED","mergeable":false,"redeemable":false,"archived":false},{"proxy_wallet":"0xf7ca80f9a8f7c060a95392779210f74f2c356c84","condition_id":"0xb8dc298e91d22304a5cbff5742ff1aaff244a65abf3c9996bc4a280b43b0c0b9","token_id":"88695616369657695855103828387547750759012457957971788345643843623803550935910","current_size":0.0,"current_value":0.0,"current_price":1.0,"status":"CLOSED","mergeable":false,"redeemable":false,"archived":false},{"proxy_wallet":"0xf7ca80f9a8f7c060a95392779210f74f2c356c84","condition_id":"0xfdce02fefc76b251a487dc9c98d37f78827e40eb70d6d255b2286c003bf7484c","token_id":"7013566801704553053137262927590994113649140483746153978660013661321438752729","current_size":0.0,"current_value":0.0,"current_price":1.0,"status":"CLOSED","mergeable":false,"redeemable":false,"archived":false},{"proxy_wallet":"0xf7ca80f9a8f7c060a95392779210f74f2c356c84","condition_id":"0x392bf5a52839711126181d97eb499caaac15fdecd0e56d44042f958c54a59220","token_id":"31995302506920258679115983355300175302934302898810308908401438376519603649683","current_size":0.0,"current_value":0.0,"current_price":1.0,"status":"CLOSED","mergeable":false,"redeemable":false,"archived":false}],"has_more":true},
{"status":"OPEN","request":"https://data-api.polymarket.com/v2/positions?user=0x234d32aa641177b3b6f7f646c5ef2d4c884d5898&status=OPEN&limit=5","observed_at":"Fri, 04 Dec 2026 20:39:58 GMT","http_status":200,"data":[{"proxy_wallet":"0x234d32aa641177b3b6f7f646c5ef2d4c884d5898","condition_id":"0x016bf4066e82571228813b876d04127934000000000000000000000000000000","token_id":"643049684020821311351796507355633171121115944121291300545830924465303715841","current_size":4.4444,"current_value":2.2444,"current_price":0.505,"status":"OPEN","mergeable":false,"redeemable":false,"archived":false},{"proxy_wallet":"0x234d32aa641177b3b6f7f646c5ef2d4c884d5898","condition_id":"0x016124720ad566f88bc302b21b492db296000000000000000000000000000000","token_id":"623948551310085686003807523523823512265834388288292452103061352323364159489","current_size":7.1428,"current_value":0.0357,"current_price":0.005,"status":"OPEN","mergeable":false,"redeemable":false,"archived":false},{"proxy_wallet":"0x234d32aa641177b3b6f7f646c5ef2d4c884d5898","condition_id":"0xf5351030d387eb7c021652d6f891f772cff8b0063ceb03e58f8c0b6c4d71f04f","token_id":"100068124601642237151788915119212498183404504460402310236684671438891194396112","current_size":2.8571,"current_value":0.0,"current_price":0.0,"status":"REDEEMABLE","mergeable":false,"redeemable":true,"archived":false},{"proxy_wallet":"0x234d32aa641177b3b6f7f646c5ef2d4c884d5898","condition_id":"0xeaadc51d3e5083118368ddde5c2b66654223707abf104d035fd7de9461c793a7","token_id":"100150378208475896629216696395655000392920954575626044733969466382236387653470","current_size":15.8871,"current_value":0.0,"current_price":0.0,"status":"REDEEMABLE","mergeable":false,"redeemable":true,"archived":false},{"proxy_wallet":"0x234d32aa641177b3b6f7f646c5ef2d4c884d5898","condition_id":"0xbe22ebd236997b54936b94f0b4a310c003732eb50dc78a93821b71a130d9178f","token_id":"100163301955613618223861608386405333660480045417003308533532425336949272565405","current_size":6.6666,"current_value":0.0,"current_price":0.0,"status":"REDEEMABLE","mergeable":false,"redeemable":true,"archived":false}],"has_more":true},
{"status":"REDEEMABLE","request":"https://data-api.polymarket.com/v2/positions?user=0x234d32aa641177b3b6f7f646c5ef2d4c884d5898&status=REDEEMABLE&limit=5","observed_at":"Fri, 04 Dec 2026 20:39:58 GMT","http_status":200,"data":[{"proxy_wallet":"0x234d32aa641177b3b6f7f646c5ef2d4c884d5898","condition_id":"0xf5351030d387eb7c021652d6f891f772cff8b0063ceb03e58f8c0b6c4d71f04f","token_id":"100068124601642237151788915119212498183404504460402310236684671438891194396112","current_size":2.8571,"current_value":0.0,"current_price":0.0,"status":"REDEEMABLE","mergeable":false,"redeemable":true,"archived":false},{"proxy_wallet":"0x234d32aa641177b3b6f7f646c5ef2d4c884d5898","condition_id":"0xeaadc51d3e5083118368ddde5c2b66654223707abf104d035fd7de9461c793a7","token_id":"100150378208475896629216696395655000392920954575626044733969466382236387653470","current_size":15.8871,"current_value":0.0,"current_price":0.0,"status":"REDEEMABLE","mergeable":false,"redeemable":true,"archived":false},{"proxy_wallet":"0x234d32aa641177b3b6f7f646c5ef2d4c884d5898","condition_id":"0xbe22ebd236997b54936b94f0b4a310c003732eb50dc78a93821b71a130d9178f","token_id":"100163301955613618223861608386405333660480045417003308533532425336949272565405","current_size":6.6666,"current_value":0.0,"current_price":0.0,"status":"REDEEMABLE","mergeable":false,"redeemable":true,"archived":false},{"proxy_wallet":"0x234d32aa641177b3b6f7f646c5ef2d4c884d5898","condition_id":"0x50eed781c1dd0a60b90ad26c1663a866de2ba07768651b51b7ec8c5789c95d5a","token_id":"100367409921233883296261093339211137996368453206234319171305571116788301736111","current_size":4.1666,"current_value":0.0,"current_price":0.0,"status":"REDEEMABLE","mergeable":false,"redeemable":true,"archived":false},{"proxy_wallet":"0x234d32aa641177b3b6f7f646c5ef2d4c884d5898","condition_id":"0x2d899daacd8b355a453ac10932b8fc8f24b20afabdaa7ff57604faf2814194ee","token_id":"100418145250952185995386017588754248391407603189163355707143814476900315526896","current_size":3.3333,"current_value":0.0,"current_price":0.0,"status":"REDEEMABLE","mergeable":false,"redeemable":true,"archived":false}],"has_more":true},
{"status":"REDEEMABLE_LOST","request":"https://data-api.polymarket.com/v2/positions?user=0x234d32aa641177b3b6f7f646c5ef2d4c884d5898&status=REDEEMABLE_LOST&limit=5","observed_at":"Fri, 04 Dec 2026 20:39:58 GMT","http_status":200,"data":[{"proxy_wallet":"0x234d32aa641177b3b6f7f646c5ef2d4c884d5898","condition_id":"0xf5351030d387eb7c021652d6f891f772cff8b0063ceb03e58f8c0b6c4d71f04f","token_id":"100068124601642237151788915119212498183404504460402310236684671438891194396112","current_size":2.8571,"current_value":0.0,"current_price":0.0,"status":"REDEEMABLE","mergeable":false,"redeemable":true,"archived":false},{"proxy_wallet":"0x234d32aa641177b3b6f7f646c5ef2d4c884d5898","condition_id":"0xeaadc51d3e5083118368ddde5c2b66654223707abf104d035fd7de9461c793a7","token_id":"100150378208475896629216696395655000392920954575626044733969466382236387653470","current_size":15.8871,"current_value":0.0,"current_price":0.0,"status":"REDEEMABLE","mergeable":false,"redeemable":true,"archived":false},{"proxy_wallet":"0x234d32aa641177b3b6f7f646c5ef2d4c884d5898","condition_id":"0xbe22ebd236997b54936b94f0b4a310c003732eb50dc78a93821b71a130d9178f","token_id":"100163301955613618223861608386405333660480045417003308533532425336949272565405","current_size":6.6666,"current_value":0.0,"current_price":0.0,"status":"REDEEMABLE","mergeable":false,"redeemable":true,"archived":false},{"proxy_wallet":"0x234d32aa641177b3b6f7f646c5ef2d4c884d5898","condition_id":"0x50eed781c1dd0a60b90ad26c1663a866de2ba07768651b51b7ec8c5789c95d5a","token_id":"100367409921233883296261093339211137996368453206234319171305571116788301736111","current_size":4.1666,"current_value":0.0,"current_price":0.0,"status":"REDEEMABLE","mergeable":false,"redeemable":true,"archived":false},{"proxy_wallet":"0x234d32aa641177b3b6f7f646c5ef2d4c884d5898","condition_id":"0x2d899daacd8b355a453ac10932b8fc8f24b20afabdaa7ff57604faf2814194ee","token_id":"100418145250952185995386017588754248391407603189163355707143814476900315526896","current_size":3.3333,"current_value":0.0,"current_price":0.0,"status":"REDEEMABLE","mergeable":false,"redeemable":true,"archived":false}],"has_more":true},
{"status":"MERGEABLE","request":"https://data-api.polymarket.com/v2/positions?user=0x234d32aa641177b3b6f7f646c5ef2d4c884d5898&status=MERGEABLE&limit=5","observed_at":"Fri, 04 Dec 2026 20:39:58 GMT","http_status":200,"data":[],"has_more":false},
{"status":"CLOSED","request":"https://data-api.polymarket.com/v2/positions?user=0x234d32aa641177b3b6f7f646c5ef2d4c884d5898&status=CLOSED&limit=5","observed_at":"Fri, 04 Dec 2026 20:39:58 GMT","http_status":200,"data":[{"proxy_wallet":"0x234d32aa641177b3b6f7f646c5ef2d4c884d5898","condition_id":"0x6bbb7ea04dc336e578662000c6929bebacf36ff47652aabb1b9a06d35a957b4d","token_id":"32250452259858625197208821141035109957279303585472265423681761943649363177306","current_size":0.0,"current_value":0.0,"current_price":1.0,"status":"CLOSED","mergeable":false,"redeemable":false,"archived":false},{"proxy_wallet":"0x234d32aa641177b3b6f7f646c5ef2d4c884d5898","condition_id":"0xc7a02400f015eff5bd1b43d96a27ddd3831b83370d1592e1ac3f432ef5c83ec9","token_id":"36368021161523860163338053935989864202333714982664338848644977086573258801930","current_size":0.0,"current_value":0.0,"current_price":1.0,"status":"CLOSED","mergeable":false,"redeemable":false,"archived":false},{"proxy_wallet":"0x234d32aa641177b3b6f7f646c5ef2d4c884d5898","condition_id":"0x35cfa37bab442283afa3b0f722c2057c0aad24a4473c2f8b0007ceec1adf25f6","token_id":"57962399175893558324976286608643798416417838125923251650067757839664970395717","current_size":0.0,"current_value":0.0,"current_price":1.0,"status":"CLOSED","mergeable":false,"redeemable":false,"archived":false},{"proxy_wallet":"0x234d32aa641177b3b6f7f646c5ef2d4c884d5898","condition_id":"0xdd228d32d0f3b15ad1768a78a317bc51456f5b2f57917567239e1fd67983cb90","token_id":"38346828385519716434059560916428795367702672794427008722087251895584250368963","current_size":0.0,"current_value":0.0,"current_price":1.0,"status":"CLOSED","mergeable":false,"redeemable":false,"archived":false},{"proxy_wallet":"0x234d32aa641177b3b6f7f646c5ef2d4c884d5898","condition_id":"0xa1f529ba68ee418003297582f04b5b8fe99081551c34779cc4b8356deec548ef","token_id":"93031934626579772395730415777505121846594645275192433981225161762801687539627","current_size":0.0,"current_value":0.0,"current_price":1.0,"status":"CLOSED","mergeable":false,"redeemable":false,"archived":false}],"has_more":true},
{"status":"OPEN","request":"https://data-api.polymarket.com/v2/positions?user=0xb6c9344216d8139ebda93f9648bcbe1240936e57&status=OPEN&limit=5","observed_at":"Fri, 04 Dec 2026 20:39:58 GMT","http_status":200,"data":[{"proxy_wallet":"0xb6c9344216d8139ebda93f9648bcbe1240936e57","condition_id":"0x9ca22f7af33ec67d48965de02eadfe5d6523f712e973f4b3519139973c4bec29","token_id":"90489244946727857927478579210986058033850864162778431818016847041565184722190","current_size":33.3333,"current_value":29.8333,"current_price":0.895,"status":"OPEN","mergeable":false,"redeemable":false,"archived":false},{"proxy_wallet":"0xb6c9344216d8139ebda93f9648bcbe1240936e57","condition_id":"0x7586a96520578acaaaa4ea84a2582f197f84255da1f3392a7aa300386c187b37","token_id":"20006732765674855733524007935991362439352594042415161039767275461950712817548","current_size":44.453,"current_value":4.3119,"current_price":0.097,"status":"OPEN","mergeable":false,"redeemable":false,"archived":false},{"proxy_wallet":"0xb6c9344216d8139ebda93f9648bcbe1240936e57","condition_id":"0x684e5b72d4e407695397a79ed75ef37273c2655ca2548791a4153233d3744696","token_id":"11876606915924142133615854761923277060697657209957870741155164849437788272266","current_size":154.1538,"current_value":3.7767,"current_price":0.0245,"status":"OPEN","mergeable":false,"redeemable":false,"archived":false},{"proxy_wallet":"0xb6c9344216d8139ebda93f9648bcbe1240936e57","condition_id":"0x63da7b2d523ba263304447b6f0ef4a6ea180b89ae91f8f256bbd8397b0c03888","token_id":"54142434400360599628100949386530479498068835619855720955715377508216403661205","current_size":1.9607,"current_value":1.9607,"current_price":1.0,"status":"REDEEMABLE","mergeable":false,"redeemable":true,"archived":false},{"proxy_wallet":"0xb6c9344216d8139ebda93f9648bcbe1240936e57","condition_id":"0x75743159df076ee110ede9e386bf9cad91df081c8bd04f3f05e5d7c141a51f33","token_id":"12288525947764397960021713424576849007970406950510265136663237558531782770669","current_size":79.06,"current_value":1.8974,"current_price":0.024,"status":"OPEN","mergeable":false,"redeemable":false,"archived":false}],"has_more":true},
{"status":"REDEEMABLE","request":"https://data-api.polymarket.com/v2/positions?user=0xb6c9344216d8139ebda93f9648bcbe1240936e57&status=REDEEMABLE&limit=5","observed_at":"Fri, 04 Dec 2026 20:39:59 GMT","http_status":200,"data":[{"proxy_wallet":"0xb6c9344216d8139ebda93f9648bcbe1240936e57","condition_id":"0x63da7b2d523ba263304447b6f0ef4a6ea180b89ae91f8f256bbd8397b0c03888","token_id":"54142434400360599628100949386530479498068835619855720955715377508216403661205","current_size":1.9607,"current_value":1.9607,"current_price":1.0,"status":"REDEEMABLE","mergeable":false,"redeemable":true,"archived":false},{"proxy_wallet":"0xb6c9344216d8139ebda93f9648bcbe1240936e57","condition_id":"0x89e9eec16f900a6b24f54d0287d8fcae2cb033d2aff7f7e70b76ff39d2096746","token_id":"6190838905626139275138287078725780734402030701897525505916200372078494079316","current_size":1.8181,"current_value":1.8181,"current_price":1.0,"status":"REDEEMABLE","mergeable":false,"redeemable":true,"archived":false},{"proxy_wallet":"0xb6c9344216d8139ebda93f9648bcbe1240936e57","condition_id":"0xb67a10d8e7aa0ecefdec67617bfe7de13a5e4450a6366babdc11a0be61095fec","token_id":"105220676801298290597520454980520144355742641714821188587322329229931781495341","current_size":41.6666,"current_value":0.0,"current_price":0.0,"status":"REDEEMABLE","mergeable":false,"redeemable":true,"archived":false},{"proxy_wallet":"0xb6c9344216d8139ebda93f9648bcbe1240936e57","condition_id":"0x3e518a48b72535b40c6aec922930a2ca4c3a84374b1fd3a755309bccc4edc9d8","token_id":"106675605315891515362400993057244154389996801258820216339420752929151210370605","current_size":25.641,"current_value":0.0,"current_price":0.0,"status":"REDEEMABLE","mergeable":false,"redeemable":true,"archived":false},{"proxy_wallet":"0xb6c9344216d8139ebda93f9648bcbe1240936e57","condition_id":"0x69aeb202063d522a2138eea4af2b246ded0b5f0a369e3533844d3c3a91126b7a","token_id":"106777711314668536375213333774224943218460456889313536158654065973760832135255","current_size":13.3333,"current_value":0.0,"current_price":0.0,"status":"REDEEMABLE","mergeable":false,"redeemable":true,"archived":false}],"has_more":true},
{"status":"REDEEMABLE_LOST","request":"https://data-api.polymarket.com/v2/positions?user=0xb6c9344216d8139ebda93f9648bcbe1240936e57&status=REDEEMABLE_LOST&limit=5","observed_at":"Fri, 04 Dec 2026 20:39:59 GMT","http_status":200,"data":[{"proxy_wallet":"0xb6c9344216d8139ebda93f9648bcbe1240936e57","condition_id":"0xb67a10d8e7aa0ecefdec67617bfe7de13a5e4450a6366babdc11a0be61095fec","token_id":"105220676801298290597520454980520144355742641714821188587322329229931781495341","current_size":41.6666,"current_value":0.0,"current_price":0.0,"status":"REDEEMABLE","mergeable":false,"redeemable":true,"archived":false},{"proxy_wallet":"0xb6c9344216d8139ebda93f9648bcbe1240936e57","condition_id":"0x3e518a48b72535b40c6aec922930a2ca4c3a84374b1fd3a755309bccc4edc9d8","token_id":"106675605315891515362400993057244154389996801258820216339420752929151210370605","current_size":25.641,"current_value":0.0,"current_price":0.0,"status":"REDEEMABLE","mergeable":false,"redeemable":true,"archived":false},{"proxy_wallet":"0xb6c9344216d8139ebda93f9648bcbe1240936e57","condition_id":"0x69aeb202063d522a2138eea4af2b246ded0b5f0a369e3533844d3c3a91126b7a","token_id":"106777711314668536375213333774224943218460456889313536158654065973760832135255","current_size":13.3333,"current_value":0.0,"current_price":0.0,"status":"REDEEMABLE","mergeable":false,"redeemable":true,"archived":false},{"proxy_wallet":"0xb6c9344216d8139ebda93f9648bcbe1240936e57","condition_id":"0xcd231ad5fb3feb95c4f270e5f5445ba739a0d62413b4fcd449bbfacc0e2fb0d0","token_id":"111167256144913771457317512438671267306129441178434599434929288584618561589335","current_size":6.7567,"current_value":0.0,"current_price":0.0,"status":"REDEEMABLE","mergeable":false,"redeemable":true,"archived":false},{"proxy_wallet":"0xb6c9344216d8139ebda93f9648bcbe1240936e57","condition_id":"0x0fd33cd06a60ca6445ca184deda2da5751d090eca6f50835392edfa667d6ba5a","token_id":"111378315534273870693607410636433225023407397602928550105530263480212651559012","current_size":14.4927,"current_value":0.0,"current_price":0.0,"status":"REDEEMABLE","mergeable":false,"redeemable":true,"archived":false}],"has_more":true},
{"status":"MERGEABLE","request":"https://data-api.polymarket.com/v2/positions?user=0xb6c9344216d8139ebda93f9648bcbe1240936e57&status=MERGEABLE&limit=5","observed_at":"Fri, 04 Dec 2026 20:39:59 GMT","http_status":200,"data":[],"has_more":false},
{"status":"CLOSED","request":"https://data-api.polymarket.com/v2/positions?user=0xb6c9344216d8139ebda93f9648bcbe1240936e57&status=CLOSED&limit=5","observed_at":"Fri, 04 Dec 2026 20:39:59 GMT","http_status":200,"data":[{"proxy_wallet":"0xb6c9344216d8139ebda93f9648bcbe1240936e57","condition_id":"0x258ff19b4baff0ed24bc28f58e83c8be6f2f91d9134700703e0aa51810c51a63","token_id":"1689950543806317773337530280926430142670579667870391801780343754845480907767","current_size":0.0,"current_value":0.0,"current_price":1.0,"status":"CLOSED","mergeable":false,"redeemable":false,"archived":false},{"proxy_wallet":"0xb6c9344216d8139ebda93f9648bcbe1240936e57","condition_id":"0xcceae66d81c60f90c9679ab531b865bd7e9f95cc54f7b0634a24095519b10d65","token_id":"107409796822153809778143872196236532785178617102787858261374110829112218839748","current_size":0.0,"current_value":0.0,"current_price":1.0,"status":"CLOSED","mergeable":false,"redeemable":false,"archived":false},{"proxy_wallet":"0xb6c9344216d8139ebda93f9648bcbe1240936e57","condition_id":"0x72bee1e573407d221b7fe3a8b5494fa159118cef5b4fc1155df8b62a1891e22f","token_id":"67769739493433108294547688091351634385240379761911714880507494310949784810747","current_size":0.0,"current_value":0.0,"current_price":1.0,"status":"CLOSED","mergeable":false,"redeemable":false,"archived":false},{"proxy_wallet":"0xb6c9344216d8139ebda93f9648bcbe1240936e57","condition_id":"0x09685805d0cf45bac3bdcabfc78866b2ca98aa45561ade9e73ec234366d12fbe","token_id":"50502754578080065229596734683657247352680854573482409167312994130978096359720","current_size":0.0,"current_value":0.0,"current_price":1.0,"status":"CLOSED","mergeable":false,"redeemable":false,"archived":false},{"proxy_wallet":"0xb6c9344216d8139ebda93f9648bcbe1240936e57","condition_id":"0xb24de8e22e871ba3bbedb6c6c8ee70b1ac54875efd9e61981075b0b4ba6f8293","token_id":"102466397314063543880416078637408206323333520330416790306498580370424355602908","current_size":0.0,"current_value":0.0,"current_price":1.0,"status":"CLOSED","mergeable":false,"redeemable":false,"archived":false}],"has_more":true},
{"status":"OPEN","request":"https://data-api.polymarket.com/v2/positions?user=0x0000000000000000000000000000000000000001&status=OPEN&limit=5","observed_at":"Fri, 04 Dec 2026 20:39:59 GMT","http_status":200,"data":[{"proxy_wallet":"0x0000000000000000000000000000000000000001","condition_id":"0x87822b3d4ccba1835d698354b01c050b55f20c5f34b14908bff4ea5a6d58af4c","token_id":"29677413448356631423250052573262008356913370083986817030510370064664558041792","current_size":10.0,"current_value":10.0,"current_price":1.0,"status":"REDEEMABLE","mergeable":false,"redeemable":true,"archived":false},{"proxy_wallet":"0x0000000000000000000000000000000000000001","condition_id":"0xc587bda904f031a973ad3cb57128ca011bfab0f45e6cb3734ed2227c4d4be419","token_id":"69119940120690198080427862456277899176151352667092917892731174838615809844766","current_size":5000.0,"current_value":0.0,"current_price":0.0,"status":"REDEEMABLE","mergeable":false,"redeemable":true,"archived":false}],"has_more":false},
{"status":"REDEEMABLE","request":"https://data-api.polymarket.com/v2/positions?user=0x0000000000000000000000000000000000000001&status=REDEEMABLE&limit=5","observed_at":"Fri, 04 Dec 2026 20:39:59 GMT","http_status":200,"data":[{"proxy_wallet":"0x0000000000000000000000000000000000000001","condition_id":"0x87822b3d4ccba1835d698354b01c050b55f20c5f34b14908bff4ea5a6d58af4c","token_id":"29677413448356631423250052573262008356913370083986817030510370064664558041792","current_size":10.0,"current_value":10.0,"current_price":1.0,"status":"REDEEMABLE","mergeable":false,"redeemable":true,"archived":false},{"proxy_wallet":"0x0000000000000000000000000000000000000001","condition_id":"0xc587bda904f031a973ad3cb57128ca011bfab0f45e6cb3734ed2227c4d4be419","token_id":"69119940120690198080427862456277899176151352667092917892731174838615809844766","current_size":5000.0,"current_value":0.0,"current_price":0.0,"status":"REDEEMABLE","mergeable":false,"redeemable":true,"archived":false}],"has_more":false},
{"status":"REDEEMABLE_LOST","request":"https://data-api.polymarket.com/v2/positions?user=0x0000000000000000000000000000000000000001&status=REDEEMABLE_LOST&limit=5","observed_at":"Fri, 04 Dec 2026 20:39:59 GMT","http_status":200,"data":[{"proxy_wallet":"0x0000000000000000000000000000000000000001","condition_id":"0xc587bda904f031a973ad3cb57128ca011bfab0f45e6cb3734ed2227c4d4be419","token_id":"69119940120690198080427862456277899176151352667092917892731174838615809844766","current_size":5000.0,"current_value":0.0,"current_price":0.0,"status":"REDEEMABLE","mergeable":false,"redeemable":true,"archived":false}],"has_more":false},
{"status":"MERGEABLE","request":"https://data-api.polymarket.com/v2/positions?user=0x0000000000000000000000000000000000000001&status=MERGEABLE&limit=5","observed_at":"Fri, 04 Dec 2026 20:39:59 GMT","http_status":200,"data":[],"has_more":false},
{"status":"CLOSED","request":"https://data-api.polymarket.com/v2/positions?user=0x0000000000000000000000000000000000000001&status=CLOSED&limit=5","observed_at":"Fri, 04 Dec 2026 20:40:00 GMT","http_status":200,"data":[{"proxy_wallet":"0x0000000000000000000000000000000000000001","condition_id":"0x94aa22f01a34a4b127130126790bd0d81c04fff5f838a985e57fe1d9b0ffd9d8","token_id":"27425216295922979944979664970690470308097061041637644521425228902515084341296","current_size":0.0,"current_value":0.0,"current_price":0.0,"status":"CLOSED","mergeable":false,"redeemable":true,"archived":false}],"has_more":false}
]
-10
View File
@@ -1,10 +0,0 @@
{
"sort_desc": {"url":"https://data-api.polymarket.com/v2/positions?user=0x19b3823092892c026517fd0ff58df4889abe0b9b&status=OPEN&sort_by=TIMESTAMP&limit=5","status":200,"date":"Fri, 04 Dec 2026 20:49:44 GMT","body":{"data":[{"token_id":"720714510152246054130276515843293825241395125263705983303209818949486116865","condition_id":"0x0197e8f2f080b39c8703e35e54c228192b000000000000000000000000000000","status":"OPEN","last_event_at":1796417320,"first_entry_at":1796417119},{"token_id":"720714510152246054130276515843293825241395125263705983303209818949486116864","condition_id":"0x0197e8f2f080b39c8703e35e54c228192b000000000000000000000000000000","status":"OPEN","last_event_at":1796417318,"first_entry_at":1796417101},{"token_id":"643049684020821311351796507355633171121115944121291300545830924465303715840","condition_id":"0x016bf4066e82571228813b876d04127934000000000000000000000000000000","status":"REDEEMABLE","last_event_at":1796417123,"first_entry_at":1796416804},{"token_id":"623948551310085686003807523523823512265834388288292452103061352323364159489","condition_id":"0x016124720ad566f88bc302b21b492db296000000000000000000000000000000","status":"REDEEMABLE","last_event_at":1796416819,"first_entry_at":1796416496},{"token_id":"595598232364135711271605858900428478751902694056243533045033760895327535105","condition_id":"0x015118be44ab1eaf0539263c3943a4c95f000000000000000000000000000000","status":"REDEEMABLE","last_event_at":1796416525,"first_entry_at":1796416165}]}},
"sort_asc": {"url":"https://data-api.polymarket.com/v2/positions?user=0x19b3823092892c026517fd0ff58df4889abe0b9b&status=OPEN&sort_by=TIMESTAMP&sort_direction=ASC&limit=5","status":200,"date":"Fri, 04 Dec 2026 20:49:47 GMT","body":{"data":[{"token_id":"108211118887905827198085240321612246840377385685588945381741674294231397172455","condition_id":"0xbe5219d1c82daaa110a20c0b50dae77f681f05eb43094e05ea24fe833c5ec47f","status":"REDEEMABLE","last_event_at":1744791574,"first_entry_at":1744779538},{"token_id":"44939317539819072767368114561139572498853620329975668979095413555067370578574","condition_id":"0xb12a219f75d35ad91ee9428d22e47f1ee6de61f5d79466b1749c8b66aed2f2d9","status":"REDEEMABLE","last_event_at":1748760251,"first_entry_at":1747881352},{"token_id":"77444435762420711044339640645792265526010696615911175439180482698545420366139","condition_id":"0xa4f51ae09144ebedb1e4329a28597dcb25217be1050fb76b86335837943bf519","status":"REDEEMABLE","last_event_at":1748986412,"first_entry_at":1748847554},{"token_id":"46741667374359006482611348910695433711657619345444561736608864383253626406210","condition_id":"0x461bc99cf3a7d76bd9fd52ab850d62d1d985cee88b940c80ae9888a94176e83b","status":"REDEEMABLE","last_event_at":1749879384,"first_entry_at":1749701035},{"token_id":"57190891280800009123681638917785245658930686322518532172325806346323335059331","condition_id":"0x6edc6c77c16ef3ba1bcd646159f12f8b8a39528e500dcff95b9220ccfbb75141","status":"REDEEMABLE","last_event_at":1750663953,"first_entry_at":1747628175}]}},
"instant": {"url":"https://data-api.polymarket.com/v2/positions?user=0x19b3823092892c026517fd0ff58df4889abe0b9b&condition=0x0197e8f2f080b39c8703e35e54c228192b000000000000000000000000000000&start=1796417320&end=1796417320","status":200,"date":"Fri, 04 Dec 2026 20:49:44 GMT","body":{"data":[{"token_id":"720714510152246054130276515843293825241395125263705983303209818949486116865","condition_id":"0x0197e8f2f080b39c8703e35e54c228192b000000000000000000000000000000","status":"OPEN","last_event_at":1796417320,"first_entry_at":1796417119}]}},
"after": {"url":"https://data-api.polymarket.com/v2/positions?user=0x19b3823092892c026517fd0ff58df4889abe0b9b&condition=0x0197e8f2f080b39c8703e35e54c228192b000000000000000000000000000000&start=1796417321","status":200,"date":"Fri, 04 Dec 2026 20:49:44 GMT","body":{"data":[]}},
"before": {"url":"https://data-api.polymarket.com/v2/positions?user=0x19b3823092892c026517fd0ff58df4889abe0b9b&condition=0x0197e8f2f080b39c8703e35e54c228192b000000000000000000000000000000&end=1796417319","status":200,"date":"Fri, 04 Dec 2026 20:49:44 GMT","body":{"data":[{"token_id":"720714510152246054130276515843293825241395125263705983303209818949486116864","condition_id":"0x0197e8f2f080b39c8703e35e54c228192b000000000000000000000000000000","status":"OPEN","last_event_at":1796417318,"first_entry_at":1796417101}]}},
"inversion": {"url":"https://data-api.polymarket.com/v2/positions?user=0x19b3823092892c026517fd0ff58df4889abe0b9b&condition=0x0197e8f2f080b39c8703e35e54c228192b000000000000000000000000000000&start=1796417321&end=1796417320","status":400,"date":"Fri, 04 Dec 2026 20:49:44 GMT","body":{"error":"end must not be before start","code":"invalid_request","retryable":false}},
"negative": {"url":"https://data-api.polymarket.com/v2/positions?user=0x19b3823092892c026517fd0ff58df4889abe0b9b&condition=0x0197e8f2f080b39c8703e35e54c228192b000000000000000000000000000000&start=-1","status":200,"date":"Fri, 04 Dec 2026 20:49:44 GMT","body":{"data":[{"token_id":"720714510152246054130276515843293825241395125263705983303209818949486116864","condition_id":"0x0197e8f2f080b39c8703e35e54c228192b000000000000000000000000000000","status":"OPEN","last_event_at":1796417318,"first_entry_at":1796417101},{"token_id":"720714510152246054130276515843293825241395125263705983303209818949486116865","condition_id":"0x0197e8f2f080b39c8703e35e54c228192b000000000000000000000000000000","status":"OPEN","last_event_at":1796417320,"first_entry_at":1796417119}]}},
"market_instant": {"url":"https://data-api.polymarket.com/v2/positions?condition=0x0197e8f2f080b39c8703e35e54c228192b000000000000000000000000000000&start=1796417320&end=1796417320&limit=3","status":200,"date":"Fri, 04 Dec 2026 20:49:45 GMT","body":{"data":[{"token_id":"720714510152246054130276515843293825241395125263705983303209818949486116864","condition_id":"0x0197e8f2f080b39c8703e35e54c228192b000000000000000000000000000000","status":"OPEN","last_event_at":1796417320,"first_entry_at":1796417122},{"token_id":"720714510152246054130276515843293825241395125263705983303209818949486116864","condition_id":"0x0197e8f2f080b39c8703e35e54c228192b000000000000000000000000000000","status":"OPEN","last_event_at":1796417320,"first_entry_at":1796417128},{"token_id":"720714510152246054130276515843293825241395125263705983303209818949486116864","condition_id":"0x0197e8f2f080b39c8703e35e54c228192b000000000000000000000000000000","status":"OPEN","last_event_at":1796417320,"first_entry_at":1796417129}]}}
}
-10
View File
@@ -1,10 +0,0 @@
{"markets":[
{"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\"]"},"book_responses":[{"method":"GET","url":"https://clob.polymarket.com/midpoint?token_id=73979342585906843441145134109923710004884703083095161594360108477170435492453","payload":null,"status":404,"date":"Thu, 03 Dec 2026 08:37:31 GMT","body":{"error":"No orderbook exists for the requested token id"}},{"method":"GET","url":"https://clob.polymarket.com/spread?token_id=73979342585906843441145134109923710004884703083095161594360108477170435492453","payload":null,"status":404,"date":"Thu, 03 Dec 2026 08:37:31 GMT","body":{"error":"No orderbook exists for the requested token id"}},{"method":"GET","url":"https://clob.polymarket.com/book?token_id=73979342585906843441145134109923710004884703083095161594360108477170435492453","payload":null,"status":404,"date":"Thu, 03 Dec 2026 08:37:31 GMT","body":{"error":"No orderbook exists for the requested token id"}},{"method":"GET","url":"https://clob.polymarket.com/midpoint?token_id=78188826358032258311424545486331333398838521699262460256542567713692269401385","payload":null,"status":404,"date":"Thu, 03 Dec 2026 08:37:32 GMT","body":{"error":"No orderbook exists for the requested token id"}},{"method":"GET","url":"https://clob.polymarket.com/spread?token_id=78188826358032258311424545486331333398838521699262460256542567713692269401385","payload":null,"status":404,"date":"Thu, 03 Dec 2026 08:37:32 GMT","body":{"error":"No orderbook exists for the requested token id"}},{"method":"GET","url":"https://clob.polymarket.com/book?token_id=78188826358032258311424545486331333398838521699262460256542567713692269401385","payload":null,"status":404,"date":"Thu, 03 Dec 2026 08:37:32 GMT","body":{"error":"No orderbook exists for the requested token id"}}],"quotes":[{"method":"GET","url":"https://clob.polymarket.com/midpoint?token_id=73979342585906843441145134109923710004884703083095161594360108477170435492453","payload":null,"status":404,"date":"Thu, 03 Dec 2026 08:36:26 GMT","body":{"error":"No orderbook exists for the requested token id"}},{"method":"GET","url":"https://clob.polymarket.com/spread?token_id=73979342585906843441145134109923710004884703083095161594360108477170435492453","payload":null,"status":404,"date":"Thu, 03 Dec 2026 08:36:26 GMT","body":{"error":"No orderbook exists for the requested token id"}},{"method":"GET","url":"https://clob.polymarket.com/price?token_id=73979342585906843441145134109923710004884703083095161594360108477170435492453&side=BUY","payload":null,"status":404,"date":"Thu, 03 Dec 2026 08:36:26 GMT","body":{"error":"No orderbook exists for the requested token id"}},{"method":"POST","url":"https://clob.polymarket.com/books","payload":[{"token_id":"73979342585906843441145134109923710004884703083095161594360108477170435492453","side":"BUY"},{"token_id":"78188826358032258311424545486331333398838521699262460256542567713692269401385","side":"BUY"}],"status":200,"date":"Thu, 03 Dec 2026 08:36:26 GMT","body":[]},{"method":"POST","url":"https://clob.polymarket.com/midpoints","payload":[{"token_id":"73979342585906843441145134109923710004884703083095161594360108477170435492453","side":"BUY"},{"token_id":"78188826358032258311424545486331333398838521699262460256542567713692269401385","side":"BUY"}],"status":200,"date":"Thu, 03 Dec 2026 08:36:26 GMT","body":{}},{"method":"POST","url":"https://clob.polymarket.com/spreads","payload":[{"token_id":"73979342585906843441145134109923710004884703083095161594360108477170435492453","side":"BUY"},{"token_id":"78188826358032258311424545486331333398838521699262460256542567713692269401385","side":"BUY"}],"status":200,"date":"Thu, 03 Dec 2026 08:36:26 GMT","body":{}},{"method":"POST","url":"https://clob.polymarket.com/prices","payload":[{"token_id":"73979342585906843441145134109923710004884703083095161594360108477170435492453","side":"BUY"},{"token_id":"78188826358032258311424545486331333398838521699262460256542567713692269401385","side":"BUY"}],"status":200,"date":"Thu, 03 Dec 2026 08:36:26 GMT","body":{}}]},
{"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\"]"},"book_responses":[{"method":"GET","url":"https://clob.polymarket.com/midpoint?token_id=759916398134244316868652908232832573045153963965173623897622651599218278400","payload":null,"status":404,"date":"Thu, 03 Dec 2026 08:37:32 GMT","body":{"error":"No orderbook exists for the requested token id"}},{"method":"GET","url":"https://clob.polymarket.com/spread?token_id=759916398134244316868652908232832573045153963965173623897622651599218278400","payload":null,"status":200,"date":"Thu, 03 Dec 2026 08:37:32 GMT","body":{"spread":"1"}},{"method":"GET","url":"https://clob.polymarket.com/book?token_id=759916398134244316868652908232832573045153963965173623897622651599218278400","payload":null,"status":404,"date":"Thu, 03 Dec 2026 08:37:32 GMT","body":{"error":"No orderbook exists for the requested token id"}},{"method":"GET","url":"https://clob.polymarket.com/midpoint?token_id=759916398134244316868652908232832573045153963965173623897622651599218278401","payload":null,"status":200,"date":"Thu, 03 Dec 2026 08:37:32 GMT","body":{"mid":"0.5"}},{"method":"GET","url":"https://clob.polymarket.com/spread?token_id=759916398134244316868652908232832573045153963965173623897622651599218278401","payload":null,"status":404,"date":"Thu, 03 Dec 2026 08:37:33 GMT","body":{"error":"No orderbook exists for the requested token id"}},{"method":"GET","url":"https://clob.polymarket.com/book?token_id=759916398134244316868652908232832573045153963965173623897622651599218278401","payload":null,"status":404,"date":"Thu, 03 Dec 2026 08:37:32 GMT","body":{"error":"No orderbook exists for the requested token id"}}],"quotes":[{"method":"GET","url":"https://clob.polymarket.com/midpoint?token_id=759916398134244316868652908232832573045153963965173623897622651599218278400","payload":null,"status":404,"date":"Thu, 03 Dec 2026 08:36:27 GMT","body":{"error":"No orderbook exists for the requested token id"}},{"method":"GET","url":"https://clob.polymarket.com/spread?token_id=759916398134244316868652908232832573045153963965173623897622651599218278400","payload":null,"status":200,"date":"Thu, 03 Dec 2026 08:36:27 GMT","body":{"spread":"1"}},{"method":"GET","url":"https://clob.polymarket.com/price?token_id=759916398134244316868652908232832573045153963965173623897622651599218278400&side=BUY","payload":null,"status":404,"date":"Thu, 03 Dec 2026 08:36:27 GMT","body":{"error":"No orderbook exists for the requested token id"}},{"method":"POST","url":"https://clob.polymarket.com/books","payload":[{"token_id":"759916398134244316868652908232832573045153963965173623897622651599218278400","side":"BUY"},{"token_id":"759916398134244316868652908232832573045153963965173623897622651599218278401","side":"BUY"}],"status":200,"date":"Thu, 03 Dec 2026 08:36:27 GMT","body":[]},{"method":"POST","url":"https://clob.polymarket.com/midpoints","payload":[{"token_id":"759916398134244316868652908232832573045153963965173623897622651599218278400","side":"BUY"},{"token_id":"759916398134244316868652908232832573045153963965173623897622651599218278401","side":"BUY"}],"status":200,"date":"Thu, 03 Dec 2026 08:36:27 GMT","body":{"759916398134244316868652908232832573045153963965173623897622651599218278401":"0.5"}},{"method":"POST","url":"https://clob.polymarket.com/spreads","payload":[{"token_id":"759916398134244316868652908232832573045153963965173623897622651599218278400","side":"BUY"},{"token_id":"759916398134244316868652908232832573045153963965173623897622651599218278401","side":"BUY"}],"status":200,"date":"Thu, 03 Dec 2026 08:36:27 GMT","body":{"759916398134244316868652908232832573045153963965173623897622651599218278400":"1"}},{"method":"POST","url":"https://clob.polymarket.com/prices","payload":[{"token_id":"759916398134244316868652908232832573045153963965173623897622651599218278400","side":"BUY"},{"token_id":"759916398134244316868652908232832573045153963965173623897622651599218278401","side":"BUY"}],"status":200,"date":"Thu, 03 Dec 2026 08:36:28 GMT","body":{}}]},
{"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\"]"},"book_responses":[{"method":"GET","url":"https://clob.polymarket.com/midpoint?token_id=708440684409184214698552699176045036593002385654320616860038876849074339840","payload":null,"status":404,"date":"Thu, 03 Dec 2026 08:37:35 GMT","body":{"error":"No orderbook exists for the requested token id"}},{"method":"GET","url":"https://clob.polymarket.com/spread?token_id=708440684409184214698552699176045036593002385654320616860038876849074339840","payload":null,"status":404,"date":"Thu, 03 Dec 2026 08:37:33 GMT","body":{"error":"No orderbook exists for the requested token id"}},{"method":"GET","url":"https://clob.polymarket.com/book?token_id=708440684409184214698552699176045036593002385654320616860038876849074339840","payload":null,"status":404,"date":"Thu, 03 Dec 2026 08:37:33 GMT","body":{"error":"No orderbook exists for the requested token id"}},{"method":"GET","url":"https://clob.polymarket.com/midpoint?token_id=708440684409184214698552699176045036593002385654320616860038876849074339841","payload":null,"status":404,"date":"Thu, 03 Dec 2026 08:37:34 GMT","body":{"error":"No orderbook exists for the requested token id"}},{"method":"GET","url":"https://clob.polymarket.com/spread?token_id=708440684409184214698552699176045036593002385654320616860038876849074339841","payload":null,"status":404,"date":"Thu, 03 Dec 2026 08:37:33 GMT","body":{"error":"No orderbook exists for the requested token id"}},{"method":"GET","url":"https://clob.polymarket.com/book?token_id=708440684409184214698552699176045036593002385654320616860038876849074339841","payload":null,"status":404,"date":"Thu, 03 Dec 2026 08:37:34 GMT","body":{"error":"No orderbook exists for the requested token id"}}],"quotes":[{"method":"GET","url":"https://clob.polymarket.com/midpoint?token_id=708440684409184214698552699176045036593002385654320616860038876849074339840","payload":null,"status":404,"date":"Thu, 03 Dec 2026 08:36:28 GMT","body":{"error":"No orderbook exists for the requested token id"}},{"method":"GET","url":"https://clob.polymarket.com/spread?token_id=708440684409184214698552699176045036593002385654320616860038876849074339840","payload":null,"status":404,"date":"Thu, 03 Dec 2026 08:36:28 GMT","body":{"error":"No orderbook exists for the requested token id"}},{"method":"GET","url":"https://clob.polymarket.com/price?token_id=708440684409184214698552699176045036593002385654320616860038876849074339840&side=BUY","payload":null,"status":404,"date":"Thu, 03 Dec 2026 08:36:28 GMT","body":{"error":"No orderbook exists for the requested token id"}},{"method":"POST","url":"https://clob.polymarket.com/books","payload":[{"token_id":"708440684409184214698552699176045036593002385654320616860038876849074339840","side":"BUY"},{"token_id":"708440684409184214698552699176045036593002385654320616860038876849074339841","side":"BUY"}],"status":200,"date":"Thu, 03 Dec 2026 08:36:28 GMT","body":[]},{"method":"POST","url":"https://clob.polymarket.com/midpoints","payload":[{"token_id":"708440684409184214698552699176045036593002385654320616860038876849074339840","side":"BUY"},{"token_id":"708440684409184214698552699176045036593002385654320616860038876849074339841","side":"BUY"}],"status":200,"date":"Thu, 03 Dec 2026 08:36:28 GMT","body":{}},{"method":"POST","url":"https://clob.polymarket.com/spreads","payload":[{"token_id":"708440684409184214698552699176045036593002385654320616860038876849074339840","side":"BUY"},{"token_id":"708440684409184214698552699176045036593002385654320616860038876849074339841","side":"BUY"}],"status":200,"date":"Thu, 03 Dec 2026 08:36:29 GMT","body":{}},{"method":"POST","url":"https://clob.polymarket.com/prices","payload":[{"token_id":"708440684409184214698552699176045036593002385654320616860038876849074339840","side":"BUY"},{"token_id":"708440684409184214698552699176045036593002385654320616860038876849074339841","side":"BUY"}],"status":200,"date":"Thu, 03 Dec 2026 08:36:29 GMT","body":{}}]}
],"mixed_batch":[
{"method":"POST","url":"https://clob.polymarket.com/books","payload":[{"token_id":"73979342585906843441145134109923710004884703083095161594360108477170435492453","side":"BUY"},{"token_id":"35090254409399344650860070211816464534198960801264823587796928404808383727584","side":"BUY"}],"status":200,"date":"Thu, 03 Dec 2026 08:36:29 GMT","body":[{"market":"0xa5f8a44504de30fa36fff2406b2b27b3d15476ed50448e4fc3ead4861d8a5e3e","asset_id":"35090254409399344650860070211816464534198960801264823587796928404808383727584","hash":"a4e1311a77002cac23f8be77c8e355df22551c4f"}]},
{"method":"POST","url":"https://clob.polymarket.com/midpoints","payload":[{"token_id":"73979342585906843441145134109923710004884703083095161594360108477170435492453","side":"BUY"},{"token_id":"35090254409399344650860070211816464534198960801264823587796928404808383727584","side":"BUY"}],"status":200,"date":"Thu, 03 Dec 2026 08:36:29 GMT","body":{"35090254409399344650860070211816464534198960801264823587796928404808383727584":"0.0375"}},
{"method":"POST","url":"https://clob.polymarket.com/spreads","payload":[{"token_id":"73979342585906843441145134109923710004884703083095161594360108477170435492453","side":"BUY"},{"token_id":"35090254409399344650860070211816464534198960801264823587796928404808383727584","side":"BUY"}],"status":200,"date":"Thu, 03 Dec 2026 08:36:29 GMT","body":{"35090254409399344650860070211816464534198960801264823587796928404808383727584":"0.001"}},
{"method":"POST","url":"https://clob.polymarket.com/prices","payload":[{"token_id":"73979342585906843441145134109923710004884703083095161594360108477170435492453","side":"BUY"},{"token_id":"35090254409399344650860070211816464534198960801264823587796928404808383727584","side":"BUY"}],"status":200,"date":"Thu, 03 Dec 2026 08:36:29 GMT","body":{"35090254409399344650860070211816464534198960801264823587796928404808383727584":{"BUY":"0.037"}}}
]}
@@ -1,123 +0,0 @@
{
"comparison": [
{
"holder_request": {
"url": "https://data-api.polymarket.com/v2/holders?condition=0xd429e8d7062eea25e3b8a4b668075fdcabc874ed7d7f2d8e27a10897f2d9e7e1&include_pnl=true&limit=3",
"date": "Sat, 05 Dec 2026 10:02:14 GMT",
"status": 200
},
"position_request": {
"url": "https://data-api.polymarket.com/v2/positions?condition=0xd429e8d7062eea25e3b8a4b668075fdcabc874ed7d7f2d8e27a10897f2d9e7e1&user=0x94e4c271a84d72f9efc8326606cee80b6e7c87e0&limit=10",
"date": "Sat, 05 Dec 2026 10:02:15 GMT",
"status": 200
},
"holder": {
"token_id": "66212785991181043242385918842184346061589075164444484655588738697632121784428",
"amount": 10000.0,
"avg_price": 0.2578,
"entry_cost_usdc": 2536.2415,
"current_price": 0.245,
"current_value": 2450.0,
"realized_pnl": 0.0,
"unrealized_pnl": -86.2415,
"total_pnl": -86.2415
},
"position": {
"token_id": "66212785991181043242385918842184346061589075164444484655588738697632121784428",
"current_size": 10000.0,
"total_size": 10000.0,
"avg_price": 0.2536,
"entry_cost_usdc": 2536.2415,
"entry_fees_usdc": 42.41846,
"total_cost_usdc": 2578.65996,
"current_price": 0.245,
"current_value": 2450.0,
"realized_pnl": 0.0,
"unrealized_pnl": -86.2415,
"total_pnl": -86.2415,
"percent_pnl": -3.4003,
"percent_realized_pnl": -3.4003
}
},
{
"holder_request": {
"url": "https://data-api.polymarket.com/v2/holders?condition=0xd429e8d7062eea25e3b8a4b668075fdcabc874ed7d7f2d8e27a10897f2d9e7e1&include_pnl=true&limit=3",
"date": "Sat, 05 Dec 2026 10:02:14 GMT",
"status": 200
},
"position_request": {
"url": "https://data-api.polymarket.com/v2/positions?condition=0xd429e8d7062eea25e3b8a4b668075fdcabc874ed7d7f2d8e27a10897f2d9e7e1&user=0x0346afae2603313d2bbee96b628536c8cbe352a5&limit=10",
"date": "Sat, 05 Dec 2026 10:02:15 GMT",
"status": 200
},
"holder": {
"token_id": "29727007796287549821138814586181906366437913673914222647744463655310236602624",
"amount": 2808.0,
"avg_price": 0.7551,
"entry_cost_usdc": 2105.9966,
"current_price": 0.755,
"current_value": 2120.04,
"realized_pnl": 0.0,
"unrealized_pnl": 14.0433,
"total_pnl": 14.0433
},
"position": {
"token_id": "29727007796287549821138814586181906366437913673914222647744463655310236602624",
"current_size": 2808.0,
"total_size": 2808.0,
"avg_price": 0.7499,
"entry_cost_usdc": 2105.9966,
"entry_fees_usdc": 14.4,
"total_cost_usdc": 2120.3966,
"current_price": 0.755,
"current_value": 2120.04,
"realized_pnl": 0.0,
"unrealized_pnl": 14.0433,
"total_pnl": 14.0433,
"percent_pnl": 0.6668,
"percent_realized_pnl": 0.6668
}
}
],
"trade_activity": {
"request": {
"url": "https://data-api.polymarket.com/v2/activity?condition=0xdc8c47c5b5d38a0da237b5a82f500ebc5cf5150de902962ac6ff76051ffe9159&user=0xbc79e27f2c94124aeefb08d74b4e4fd3ac834e4d&type=TRADE&limit=20",
"date": "Sat, 05 Dec 2026 10:02:16 GMT",
"status": 200
},
"fields": [
{
"side": "SELL",
"price": 0.024,
"size": 18.83,
"usdc_size": 0.42987,
"timestamp": 1796425000,
"token_id": "49932611791842248277648635261891267637049151266001723816279042019553905945029"
},
{
"side": "SELL",
"price": 0.0194444444,
"size": 45.0,
"usdc_size": 0.83211,
"timestamp": 1796380585,
"token_id": "49932611791842248277648635261891267637049151266001723816279042019553905945029"
},
{
"side": "BUY",
"price": 0.077,
"size": 24.65,
"usdc_size": 1.98564,
"timestamp": 1796319905,
"token_id": "49932611791842248277648635261891267637049151266001723816279042019553905945029"
},
{
"side": "BUY",
"price": 0.0765630793,
"size": 39.183377,
"usdc_size": 3.13851,
"timestamp": 1796319905,
"token_id": "49932611791842248277648635261891267637049151266001723816279042019553905945029"
}
]
}
}
+4 -29
View File
@@ -306,10 +306,6 @@ order、market_sell 和卖出 estimate 可用 size_micros 输入数量,也可
本地覆盖盘口快照、档位变化、最优报价和文本心跳。最近成交、步长调整和启用扩展功能后的市场生命周期事件也可经同一连接订阅。初始快照使用数组发送;生产端帧分组、延迟和断线时机尚待实测。Rust 回环测试入口为 `market_socket_sends_snapshots_deltas_and_application_pongs`。
#### V2 公开持仓榜
2026-12-05 的生产对照中,limit=1 分别返回两个结果各一位,负数 min_balance 与零门槛一致。恰好一位达标时下一页为空指针。续页必须重送 condition,页宽和偏移由游标保留,min_balance 与 include_pnl 可在请求中重传。Eventbook 的 `/v2/holders` 对齐这些边界,并复用实际份额、冻结卖单和盘口估值。新账本保存成交与钱包操作的共同写入顺序。已知历史按移动平均成本重放,买入成本排除手续费,卖出用实收额计算已实现盈亏,拆分和合并按等额分摊。旧流水缺时钟、同毫秒顺序有歧义、转换缺少分腿成本或账本与持仓不符时,成本及盈亏留空。公开钱包资料和生产成本算法仍待逐户对照。一次生产样本中同一资产的榜单 avg_price 为 0.2578,持仓接口为 0.2536,两者的 entry_cost_usdc 相同。本地榜单按剩余本金加买入费用后除以持有份额,持仓页按剩余本金计算平均价。两种平均价均截到四位小数。[官方持仓榜接口](https://docs.polymarket.com/api-reference/markets/list-a-markets-top-holders)
### 最近成交和步长变化
[回放样例](examples/market-stream-trades.jsonl)先将空盘步长由 0.01 调到 0.001,再以 0.40 美元成交 2 份 YES,最后通过互补买单以 0.35 美元成交 1 份 YES。订阅 YES 的客户端收到新的步长、两笔最近成交和相应的档位变化;订阅 NO 的客户端也收到该结果的步长变化,以及互补成交对应的 0.65 美元成交价。[官方原始报文字段](https://docs.polymarket.com/market-data/realtime-data.md)
@@ -380,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)
本地用已经提交的盘口变更重建历史中点。到每个 UTC 采样边界,取该时刻之前(含该时刻)最近一次盘口;缺买侧用 0,缺卖侧用 1。没有挂单变化时延续上次观测。窗口之外也追加最近一分钟的可用点;若与窗口最后一点重合,可出现重复时间戳。封盘后,曲线只返回请求窗口内、封盘之前的采样点。电竞、乒乓球和 SOL 涨跌盘的六个生产结果均符合这一规则。电竞负侧、胜侧的末点分别为 0.0005 和 0.9995,目录最终兑付为 0 和 1。旧库没有封盘记录时,最多采样到最后一笔非空盘口记录。生产采样时钟有秒级偏移,新盘首个采样延迟和长期保留仍待核验。V2 曲线使用成交与兑付数据。[已裁决生产样本](examples/public-closed-chart-history.json)
本地用已经提交的盘口变更重建历史中点。到每个 UTC 采样边界,取该时刻之前(含该时刻)最近一次盘口;缺买侧用 0,缺卖侧用 1。没有挂单变化时延续上次观测。窗口之外也追加最近一分钟的可用点;若与窗口最后一点重合,可出现重复时间戳。模拟裁决后在裁决时刻以兑付值收尾。已裁决的旧盘若缺少裁决时间,只使用最后有时间记录的报价。升级旧库时从第一条可信报价开始,没有报价记录的资产从迁移时刻开始。生产采集存在秒级抖动,新盘首个采样的延迟、长期历史保留和裁决后取点尚未逐点验证。V2 的成交与兑付历史保留其独立数据源。
fidelity 以分钟为单位;省略或不大于零时按 1 分钟处理。相对窗口 1w 至少需要 5 分钟、1m 至少需要 10 分钟。显式起止时间最多相隔 15 天,多一秒即拒绝。单给 startTs 时读到当前;两个时间相等时仍可返回末点。合法但未上市的本地资产返回空数组。[HTTP 样例](examples/clob-http.http)
@@ -390,7 +386,9 @@ fidelity 以分钟为单位;省略或不大于零时按 1 分钟处理。相
[本地样例](examples/clarifications.jsonl)先挂出 0.40 的 YES 买单。第一条说明保留挂单,第二条要求清盘,账户收回预留的 0.40。两条说明都按发布时间保留,初始规则仍可查看。模拟操作员可在盘前、连续交易或封盘待裁决期间发布公告。重复的请求 ID 返回原回执;之后新挂的订单不会因重放旧公告被撤。[官方规则澄清说明](https://docs.polymarket.com/concepts/resolution#clarifications)
`GET /market-clarifications` 支持按数字事件 ID、市场 ID 筛选、翻页和按公告 ID 排序。clearBook 表示发布时是否要求清盘。createdAt 是本地发布时间,txTimestamp 和 txHash 留空。官方另外支持按 UMA 问题 ID、交易哈希及其他排序字段查询,这些筛选项尚待实现。[官方公告列表](https://docs.polymarket.com/api-reference/markets/list-market-clarifications) · [官方返回示例](https://docs.polymarket.com/market-data/market-details#market-clarifications)
`GET /market-clarifications` 支持按数字事件 ID、市场 ID、已登记的 UMA 问题 ID 及发布交易哈希查询。同类 ID 可重复,跨条件取交集。publish_clarification 可附带可信操作者提供的 tx_hash,和公告及清盘同事务写入。带事件或裁决问题的公告公开 eventId、questionId,本地已发布公告的 state 为 success。txTimestamp 暂无链上证据,保留 null。
2026-12-05 的 Gamma 生产样本中,无参数与 limit=0 均返回 50 条,limit=101 返回 100 条,offset=-1 等同于首屏。order=createdAt,id 接受逗号分隔的字段,order=created_at 返回 422。用公告 23029 的 questionId 查询命中同一公告,大写十六进制仍命中。其交易哈希精确筛选返回六条公告,大写哈希返回空数组。本地采用同样的查询口径。Gamma 未指定无排序参数时的稳定顺序,本地使用公告 ID 稳定翻页,默认升序;预约、排队和链上确认时间仍待接入。[官方公告列表](https://docs.polymarket.com/api-reference/markets/list-market-clarifications) · [生产查询样例](https://gamma-api.polymarket.com/market-clarifications?limit=2&order=id&ascending=true)
本地 resolution 查询在获胜结果确定后同时返回已持久化的 resolved_at_ms 和 payouts;旧市场缺少时间记录时返回 null。兑付权重顺序为 YES、NO:YES 胜为 [1,0],NO 胜为 [0,1],作废为 [1,1],分母为两项之和。挑战期内的提案不会生成兑付权重。链上区块、UMA 仲裁回执及生产 Data API 的状态枚举尚待对照。[Polymarket UMA 适配器](https://github.com/Polymarket/uma-ctf-adapter/blob/main/src/UmaCtfAdapter.sol) · [生产裁决状态接口](https://docs.polymarket.com/api-reference/markets/get-resolution-state)
@@ -470,26 +468,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。重启和重发相同命令沿用原回执与受理时间。
`open_orders` 的列表和精确查询均返回 `created_at`(Unix 秒)、`order_type` 和本地扩展 `post_only`。升级已有数据库时,用已受理的命令回执和 GTD 截止记录恢复提交指令;没有原始时钟记录的受理时间为 null。缺少原始回执的历史行仍可查询,未知字段保留为 null。官方当前将累计成交和逐笔对账分别放在订单的 size_matched 和账户成交记录;其单笔订单 HTTP 接口需要账户认证。本地验证使用可信操作员的 JSONL 接口,订单号与账户是模拟环境的标识。生产私有接口尚未实测。[官方订单查询](https://docs.polymarket.com/trading/manage-orders)
### 已裁决市场的公开盘口
对电竞、乒乓球和 SOL 涨跌盘的六个已裁决结果单查 /book,全部返回 404。批量 /books 和 /prices 忽略已裁决资产,混合批次保留可用资产。中点和价差多数同样返回 404,但一个 V2 市场的两侧分别仍能读到价差 1 或中点 0.5。Eventbook 对已裁决结果统一省略四种公开行情,保留内部快照供交易状态和回放。封盘待裁决阶段、外场淘汰时延和例外是否由服务缓存触发仍待验证。[生产响应](examples/public-resolved-books.json)
### Data API 持仓生命周期
公开 GET /v2/positions 已接入本地账本。可按钱包查询,或用一个市场查持有人,也可对钱包附加市场条件。OPEN 包含仍持有的已裁决资产,REDEEMABLE 保留待兑付的胜负两侧,REDEEMABLE_LOST 选出尚未核销的零兑付资产。MERGEABLE 返回持有互补份额的两侧,CLOSED 查询已经退出或低于 0.1 份的仓位。当前持仓使用 0.1 份下限。游标由本地签名,绑定查询、页大小及最后一行的排序键。逐页使用各自的已提交快照,仓位变动可能改变后续排序。
这一版返回数量、估值、配对与赎回标记、结果身份和目录标题。本地支持份额、价格和当前价值排序。跨钱包关闭记录仍待接入。实测 0.0088 份已裁决余额出现在 CLOSED,仍标记 redeemable。用相同条件查询 OPEN 和 REDEEMABLE 均为空,即使传入 filter_amount=0。生产响应中的姓名和签名游标未保存在样本里。[公开生产响应摘要](examples/public-position-lifecycle.json) · [官方持仓规范](https://data-api.polymarket.com/v2/openapi.json)
持仓列表支持 title(不区分 ASCII 大小写、保留 SQL LIKE 通配符)、event_id(最多 20 个事件、仅钱包查询、与 condition 互斥)和 filter_type / filter_amount。TOKENS 按当前份额过滤,CASH 按当前估值过滤,门槛包含等值。无效筛选类型返回 400,负门槛采用默认行为。翻页时继续发送标题、事件和金额参数。钱包 CLOSED 维持 0.1 份的边界,市场维度的份额门槛会移动 OPEN 与 CLOSED 分界。标题非 ASCII 大小写及市场维度边界仍待生产对照。[生产筛选样本](examples/public-position-filters.json)
持仓活动时间按结果资产从成交、拆分、合并、互斥转换及赎回推导。start/end 按 Unix 秒包含两端,非正数表示无界。有界查询排除没有可信时间的行。可用 TIMESTAMP 排序,翻页时重发窗口。本地 first_entry_at 是最早有记录的取得时间。历史全额赎回缺少分侧数据,转换费用金库的入账时间及在平仓后重新入场的时间口径仍待核验。新赎回按实际烧掉的结果记录时间。裁决、挂单或撤单本身不增加持仓活动。[生产时间窗口样本](examples/public-position-time.json)
账户持仓和毛持仓榜共用一套账本。买入手续费单列并随卖出、合并或赎回按份额摊销。未实现盈亏沿用扣除剩余本金的口径。可重建的拆分和合并按两侧等额分摊本地抵押,已完成的赎回按真实兑付入账。混用多个日志来源且缺时钟或同毫秒无法判断顺序时,或互斥转换缺失分腿成本时,经济字段留空。百分比采用官方的剩余本金和累计买入份额口径,分母为零时留空。生产样本中 10,000 份的榜单平均价为 0.2578,账户持仓为 0.2536,两处的剩余本金、估值和盈亏一致。另一个部分卖出的样本,可由公开成交净额和按份额摊销的买入费重建出接近的已实现盈亏。生产扣费舍入和跨市场转换仍待逐笔验证。[生产对照](examples/public-shared-position-economics.json) · [官方持仓字段](https://data-api.polymarket.com/v2/openapi.json)
持仓页可按 AVG_PRICE、REALIZED_PNL、UNREALIZED_PNL 和 TOTAL_PNL 排序,已知值按返回精度比较,缺少可重建成本的仓位排列在末尾。钱包 CLOSED 默认按已实现盈亏排序,给它 TOKENS、CURRENT_VALUE、PRICE 或 UNREALIZED_PNL 时也采用已实现盈亏。钱包 CLOSED 和 REDEEMABLE_LOST 拒绝 AVG_PRICE。游标绑定实际采用的排序。旧 CLOSED 游标使用被替代的排序键时要从第一页重新获取。生产未核验缺成本行的相对位置。[生产排序样本](examples/public-position-economics-sorts.json)