PolymarketClickHouse Workshops

07 AI market analyst

ClickHouse Agent에 실시간 시장 테이블을 주고 스스로 움직임을 감지하고 조사하게 만든 뒤, 결정적 SQL로 그 답을 심판합니다.

Your computer
macOS terminal: Run workshop commands in Terminal using zsh or bash.

시작 지점

collector가 live, degraded, 또는 fixture 모드에서 healthy 상태이고, Module 05 쿼리들이 반환되며, polymarket-workshop을 소유한 조직에 로그인되어 있습니다. 새 API 키나 로컬 프로세스는 필요하지 않습니다. ClickHouse Agents는 Module 00에서 만든 신원으로 Cloud에서 실행됩니다.

왜

Module 05는 이미 적어 두었던 네 가지 질문에 답했습니다. 시장은 당신의 질문 목록을 기다려주지 않습니다. 유용한 형태는 온콜 분석가입니다. 움직임을 알아차리고, 가설을 세우고, 그것을 검증할 쿼리를 작성하고, 근거와 함께 판정을 보고합니다. 그 루프도 조용히 실패하기 때문에, 마지막 두 단계는 에이전트를 신뢰하는 대신 심판합니다.

Step 1 — ClickHouse Agents 열고 이 서비스 연결

open 'https://ai.clickhouse.cloud'

Cloud 콘솔에서도 같은 곳에 도달합니다. 서비스로 들어간 뒤 ClickHouse agents입니다.

Polymarket analyst라는 이름의 에이전트를 만들고, ClickHouse 도구를 추가해 polymarket-workshop을 가리키게 한 뒤, Connected로 보고되는지 확인하세요. 연결된 도구가 없으면 에이전트는 스키마를 추측합니다. 다음 내용을 지침으로 붙여 넣으세요. 모든 줄은 그것이 없으면 에이전트가 틀리기 때문에 들어 있습니다:

You answer questions about live public prediction-market data in the polymarket database
of this service. Rules:
- Probability is the quote midpoint: polymarket.price_ticks where midpoint > 0, or the
  merged close of polymarket.market_midpoints_1m. A last_trade_price tick is not one.
- market_midpoints_1m holds AggregateFunction states. Read them only through
  argMinMerge(open), maxMerge(high), minMerge(low), argMaxMerge(close) and
  countMerge(updates), grouped by minute, token_id.
- Metadata comes from polymarket.markets FINAL, trades from polymarket.trades_clean.
- One condition_id per market, one token_id per outcome. A Yes move and its No
  counterpart are one event, not two findings.
- Timestamps are UTC and the newest minute is usually still filling.
- Show the SQL you ran and the age of the data behind every number.
- Public-data analysis only. Never give trading advice.

Step 2 — 첫 번째 턴: 움직임을 직접 찾게 하기

Using the ClickHouse tool, find the largest midpoint move in the last 30 minutes of
polymarket.market_midpoints_1m. For each token_id compare the merged close of the most
recent complete minute with the merged close five minutes earlier. Report the question,
the outcome, the token_id, both probabilities in percent, the move in percentage points,
and the two minutes you compared. Show the SQL.

예상 결과: 이름이 지정된 결과 하나, 부호가 있는 포인트 단위 움직임, 그리고 원시 상태 열을 그대로 선택하는 대신 집계 상태를 병합하는 SQL.

Step 3 — 두 번째 턴: 자기 발견을 스스로 조사하게 하기

Investigate that move before you believe it. From polymarket.price_ticks report the
latest best_bid, best_ask, spread in percentage points, and quote age in seconds for that
token_id. From polymarket.trades_clean compare matched volume as price * size over the
five minutes covering the move against the previous five minutes. Then give a verdict of
corroborated, weakly corroborated, or likely artifact, and name the evidence behind it.

그 세 신호를 어떻게 조합하라고 말한 적이 없습니다. 그 선택을 스스로 하는 것이 이것을 text-to-SQL 박스가 아니라 에이전트로 만듭니다.

Step 4 — 세 번째 턴: 자기 판정을 공격하게 하기

List every assumption in that verdict that could be wrong, and for each one the single
query that would falsify it. Run the two you consider most likely to be wrong, then tell
me whether the verdict survives.

유용한 답은 아직 채워지는 중인 최신 분(minute), 호가 나이, 그리고 얇은 구간 뒤에 업데이트가 얼마나 적게 있는지를 짚습니다. 판정이 살아남았는지 기록하세요.

Step 5 — 결정적 SQL로 에이전트 심판하기

이것을 Cloud SQL 콘솔에서 실행하세요. 에이전트 없이 Step 2에 답하므로, 그 최상단 행이 당신의 기준값입니다:

WITH per_minute AS
(
    SELECT
        token_id,
        minute,
        argMaxMerge(close) AS close_midpoint
    FROM polymarket.market_midpoints_1m
    WHERE minute >= now() - INTERVAL 30 MINUTE
      AND minute < toStartOfMinute(now())
    GROUP BY token_id, minute
)
SELECT
    m.question,
    m.outcome,
    p.token_id,
    round(argMax(p.close_midpoint, p.minute) * 100, 2) AS latest_percent,
    round(argMin(p.close_midpoint, p.minute) * 100, 2) AS oldest_percent,
    round(latest_percent - oldest_percent, 2) AS move_points,
    min(p.minute) AS window_start,
    max(p.minute) AS window_end
FROM per_minute AS p
INNER JOIN
(
    SELECT token_id, question, outcome
    FROM polymarket.markets FINAL
) AS m ON m.token_id = p.token_id
GROUP BY m.question, m.outcome, p.token_id
ORDER BY abs(move_points) DESC
LIMIT 5;

구간이 다른 것은 의도된 것입니다. 이 쿼리는 존재하는 가장 오래된 완결 분과 가장 최신 완결 분을 아우르고, 에이전트에게는 5분 간격을 요구했습니다. 소수점이 아니라 token_id, move_points의 부호, 그리고 크기를 비교하세요. 그다음 Module 06에서 저장한 Spread and freshness와 Volume velocity 쿼리로 에이전트의 보강 근거 수치를 확인하세요.

Step 6 — 에이전트가 틀린 것을 적어 두기

보통 이 중 최소 하나가 나타납니다. 기록(transcript)에서 당신의 사례를 찾으세요:

  • market_midpoints_1m에서 Merge 함수 없이 close나 high를 선택하고, 돌아온 값을 무엇이든 완전한 확신으로 설명하기;
  • 아직 채워지는 중인 최신 분을 완결된 것으로 취급해 마지막 구간을 과장하기;
  • Yes 토큰과 그 No 토큰을 서로 독립적인 두 급변동 종목으로 보고하기;
  • polymarket.markets에서 FINAL을 빼서, 재탐색된 시장이 두 번 조인되게 하기;
  • 중간값을 거래 가능한 가격이라고 부르거나, 움직임을 그 나이 없이 인용하기.

에이전트의 숫자가 심판 쿼리와 정확히 일치했다면, 부분 분(minute)을 직접 시험하세요. 최신 분이 완결되었는지 물어본 뒤, polymarket.market_midpoints_1m의 max(minute)를 toStartOfMinute(now())와 비교하세요. 값이 같다면 완결되지 않았다는 뜻이고, 그렇지 않다고 말한 에이전트는 실시간 데이터에 대해 거짓을 말한 것입니다.

완료 조건

  • 에이전트의 감지 SQL이 Merge 함수를 통해 market_midpoints_1m을 읽는다;
  • 그 판정이 가격만이 아니라 스프레드, 호가 나이, 거래량을 근거로 인용한다;
  • 심판 쿼리의 최상단 행이 토큰과 방향에서 에이전트와 일치하거나, 그 차이를 설명할 수 있다; 그리고
  • 에이전트가 틀렸거나 과장한 것 하나를 적어 두었다.

다음: 마무리하고 정리합니다.

이 페이지의 내용

Track your progress?

Optional. We email a link to confirm your address; progress records once you open it.

Please use your work email address, not a personal one.

Progress tracking also requires accepting the current Terms of Service in Privacy settings.

KO