07 นักวิเคราะห์ตลาด AI
มอบตารางข้อมูลตลาดสดให้ ClickHouse Agent ให้มันตรวจจับและสืบสวนการเคลื่อนไหวด้วยตัวเอง แล้วตัดสินคำตอบของมันด้วย SQL แบบ deterministic
จุดเริ่มต้น
collector อยู่ในสถานะ healthy ในโหมด live, degraded หรือ fixture คิวรีของโมดูล 05
คืนผลลัพธ์ได้ และคุณลงชื่อเข้าใช้องค์กรที่เป็นเจ้าของ polymarket-workshop แล้ว ไม่ต้องมี
API key ใหม่หรือโปรเซสบนเครื่อง: ClickHouse Agents รันบน Cloud ภายใต้ identity ที่คุณ
สร้างไว้ในโมดูล 00
ทำไป
โมดูล 05 ตอบคำถามสี่ข้อที่คุณเขียนไว้ล่วงหน้าแล้ว แต่ตลาดไม่รอ รายการคำถามของคุณ รูปแบบที่มีประโยชน์คือนักวิเคราะห์แบบ on-call: สังเกตการเคลื่อนไหว ตั้ง สมมติฐาน เขียนคิวรีที่ทดสอบสมมติฐานนั้น แล้วรายงานคำตัดสินพร้อมหลักฐาน ลูปนั้นก็ล้มเหลวแบบเงียบ ๆ ได้เช่นกัน ดังนั้นสองขั้นสุดท้ายจะตัดสิน agent แทนที่จะเชื่อมันไปเลย
ขั้นที่ 1 — เปิด ClickHouse Agents และเชื่อมต่อบริการนี้
open 'https://ai.clickhouse.cloud'คอนโซล Cloud ก็ไปที่เดียวกันได้: เข้าบริการของคุณ แล้วเลือก ClickHouse agents
สร้าง agent ชื่อ Polymarket analyst เพิ่มเครื่องมือ ClickHouse ชี้ไปที่
polymarket-workshop และยืนยันว่ามันรายงานว่า Connected หากไม่มีเครื่องมือที่เชื่อมต่ออยู่
agent จะเดา schema ของคุณ วางข้อความนี้เป็นคำสั่งของมัน ทุกบรรทัดมีอยู่เพราะ
agent มักทำผิดเมื่อไม่มีมัน:
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.ขั้นที่ 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.ผลที่ควรได้: ผลลัพธ์ที่ระบุชื่อหนึ่งรายการ ค่าการเคลื่อนไหวแบบมีเครื่องหมายเป็นหน่วย point และ SQL ที่ merge ค่า aggregate state แทนการ select คอลัมน์ state ดิบ
ขั้นที่ 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.คุณไม่เคยบอกว่าสัญญาณสามอย่างนั้นต้องรวมกันอย่างไร การที่มันต้องเลือกเองคือสิ่งที่ทำให้นี่เป็น agent ไม่ใช่กล่อง text-to-SQL
ขั้นที่ 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.คำตอบที่มีประโยชน์จะระบุนาทีล่าสุดที่ยังไม่ครบ อายุของ quote และจำนวนการอัปเดตที่น้อยนิด ซึ่งอยู่เบื้องหลังนาทีที่ข้อมูลบาง บันทึกไว้ว่าคำตัดสินนั้นรอดหรือไม่
ขั้นที่ 5 — ตัดสิน agent ด้วย SQL แบบ deterministic
รันคำสั่งนี้ในคอนโซล SQL ของ Cloud มันตอบขั้นที่ 2 โดยไม่ใช้ agent ดังนั้นแถวบนสุดของมันคือ ค่าอ้างอิงของคุณ:
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;ช่วงเวลาต่างกันโดยเจตนา: คิวรีนี้ครอบคลุมนาทีที่สมบูรณ์ที่เก่าสุดถึงใหม่สุดที่มีอยู่
ขณะที่ agent ถูกขอให้ใช้ก้าวห้านาที เทียบ token_id เครื่องหมายของ
move_points และขนาดของค่า ไม่ใช่ทศนิยม จากนั้นตรวจตัวเลขการยืนยันของ agent
เทียบกับคิวรี Spread and freshness และ Volume velocity ที่บันทึกไว้ใน
โมดูล 06
ขั้นที่ 6 — จดสิ่งที่ agent ทำผิดไว้
อย่างน้อยหนึ่งข้อต่อไปนี้มักโผล่ขึ้นมา หาข้อของคุณในบันทึกการสนทนา:
- select
closeหรือhighจากmarket_midpoints_1mโดยไม่ใช้ฟังก์ชันMergeแล้ว อธิบายค่าที่ได้กลับมาอย่างมั่นใจเต็มที่ - ถือว่านาทีล่าสุดที่ยังเก็บข้อมูลไม่ครบเป็นนาทีที่สมบูรณ์ ซึ่งทำให้ช่วงท้ายดูเกินจริง
- รายงาน token ของ Yes และ token No ของมันเป็นตัวที่ขยับสองรายการที่เป็นอิสระกัน
- ตัด
FINALออกจากpolymarket.marketsทำให้ตลาดที่ถูกค้นพบใหม่ join เข้ามาสองครั้ง - เรียก midpoint ว่าเป็นราคาที่เทรดได้ หรืออ้างการเคลื่อนไหวโดยไม่บอกอายุของข้อมูล
หากตัวเลขของมันตรงกับตัวตัดสินเป๊ะ ให้ทดสอบเรื่องนาทีที่ไม่ครบโดยตรง: ถามว่า
นาทีล่าสุดของมันสมบูรณ์หรือไม่ แล้วเทียบ max(minute) ใน
polymarket.market_midpoints_1m กับ toStartOfMinute(now()) ค่าที่เท่ากันหมายความว่ามันไม่
สมบูรณ์ และ agent ที่บอกเป็นอย่างอื่นได้กล่าวข้อความเท็จเกี่ยวกับข้อมูลสด
ถือว่าเสร็จเมื่อ
- SQL ตรวจจับของ agent อ่าน
market_midpoints_1mผ่านฟังก์ชันMerge - คำตัดสินของมันอ้าง spread อายุของ quote และวอลุ่มการเทรด ไม่ใช่ราคาเพียงอย่างเดียว
- แถวบนสุดของคิวรีตัวตัดสินตรงกับ agent ในเรื่อง token และทิศทาง หรือคุณอธิบาย ความต่างได้ และ
- คุณได้จดสิ่งที่ agent ทำผิดหรือพูดเกินจริงไว้อย่างน้อยหนึ่งข้อ
ต่อไป: สรุปปิดท้ายและล้างของ