Query editor
WITH params AS (SELECT 4500 AS max_offset),markets AS (SELECT lower(condition_id) AS condition_idFROM query_8038637),excluded_traders AS (SELECT '0xa5ef39c3d3e10d0b270233af41cac69796b12966' AS trader),directions AS (SELECT sort_directionFROM (VALUES ('DESC'), ('ASC')) AS t(sort_direction)),offsets AS (SELECT page_offsetFROM paramsCROSS JOIN UNNEST(sequence(0, max_offset, 500)) AS t(page_offset)),pages AS (SELECTm.condition_id,d.sort_direction,o.page_offset,try(CAST(json_parse(http_get(concat('https://data-api.polymarket.com/v1/market-positions?market=',m.condition_id,chr(38), 'status=ALL',chr(38), 'sortBy=TOTAL_PNL',chr(38), 'sortDirection=', d.sort_direction,chr(38), 'limit=500',chr(38), 'offset=', CAST(o.page_offset AS VARCHAR)))) AS ARRAY(ROW(token VARCHAR,positions ARRAY(ROW(proxyWallet VARCHAR,name VARCHAR,asset VARCHAR,conditionId VARCHAR,avgPrice DOUBLE,size DOUBLE,currPrice DOUBLE,currentValue DOUBLE,cashPnl DOUBLE,totalBought DOUBLE,realizedPnl DOUBLE,totalPnl DOUBLE,outcome VARCHAR,outcomeIndex INTEGER)))))) AS response_pageFROM markets mCROSS JOIN directions dCROSS JOIN offsets o),page_stats AS (SELECTcondition_id,sort_direction,page_offset,