Polymarket Bot Tutorial · Chapter 15 of 32
Polymarket پر sports microstructure bots: in-game edge، scoreline-driven mispricing، NBA tag (745) اور Tennis tag (864)، live data sources، اور high-frequency sports markets کے لیے execution patterns۔
یہ chapter کس بارے میں ہے
Sports markets Polymarket پر سب سے زیادہ مسلسل active non-political segment ہیں۔ جو bots واقعی کام کرتے ہیں وہ دو صاف buckets میں آتے ہیں: pre-game line-catchers جو line set ہونے کے بعد trade کرتے ہیں، اور in-game microstructure bots جو کھیل کے دوران order-book movement پر react کرتے ہیں۔ یہ chapter دونوں کو cover کرتا ہے، خاص tag IDs، data sources، اور latency budgets کے ساتھ جو ہر ایک پر apply ہوتے ہیں۔
Sports markets Polymarket پر سب سے مصروف non-political segment ہیں۔ جو execution pattern کام کرتا ہے وہ live-score feed (ESPN، PandaScore) کو order-book microstructure signals کے ساتھ combine کرتا ہے۔ یہ chapter خاص طور پر NFL، NBA، soccer، اور tennis کے لیے کیا کام کرتا ہے، اور esports کیسے مختلف ہے، یہ cover کرتا ہے۔
- Sports markets tradeable کیوں ہیں
- Pre-game بمقابلہ in-game (مختلف bots)
- Verified tag IDs (745 NBA، 864 Tennis)
- Data sources: ESPN، official APIs، on-screen
- In-game کے لیے latency budget
- 0.99 / 0.01 trap
- Code: games book کو subscribe کریں اور react کریں
Sports markets tradeable کیوں ہیں
Sports markets defined timeframes (hours سے days) میں clear ہوتے ہیں، public live data رکھتے ہیں، اور games کے دوران مسلسل order flow attract کرتے ہیں۔ یہ تینوں tradeable market کے لیے ضروری ہیں - political markets میں "defined timeframe" نہیں ہوتا، weather markets میں "continuous flow" کمزور ہوتا ہے، اور obscure tournaments میں "public live data" نہیں ہوتا۔
Sports markets پر trader population بھی election markets کے مقابلے میں زیادہ diverse ہوتی ہے۔ casual sports bettors emotional pricing کرتے ہیں؛ informed traders game کے دوران fair value کی طرف correction کرتے ہیں۔ ان دونوں کے درمیان gap ہی bot edge ہے۔
Volume distribution uneven ہوتی ہے: ایک NFL Sunday Polymarket sports markets میں hundreds of millions of dollars rotate کر سکتی ہے؛ Tuesday-night Saudi Pro League fixture شاید $50k سے کم کرے۔ اپنی strategy کو اس کے مطابق size کریں جہاں action واقعی ہے۔
Pre-game بمقابلہ in-game (مختلف bots)
دو بنیادی طور پر مختلف bot designs۔
Pre-game line-catcher: نئے کھلے ہوئے markets scan کریں، اپنی model یا کسی sharper venue کے number کے مقابل mis-priced lines identify کریں، FOK buy place کریں۔ In-play تک hold کریں، کبھی کبھی resolution تک بھی۔ Speed: minutes-not-seconds۔ Edge: model + line-shopping۔
In-game microstructure: live game's order book WebSocket subscribe کریں، imbalance signals + score events پر seconds کے اندر react کریں۔ Speed: seconds-not-minutes۔ Edge: latency + order flow پڑھنا۔
دونوں کا code تقریباً ایک جیسا نہیں ہوتا۔ ان کے risk profiles مختلف ہیں، data sources مختلف ہیں، exit strategies مختلف ہیں۔ ایک bot اگر دونوں کرنے کی کوشش کرے تو آخرکار دونوں میں اچھا نہیں رہتا؛ ایک ہی منتخب کریں۔
Verified tag IDs (745 NBA, 864 Tennis)
Major sports categories کے لیے production tag IDs May 2026 میں verify کیے گئے۔ انہیں /events calls کو efficiently filter کرنے کے لیے استعمال کریں۔
| Sport / League | Tag ID | Tag slug | Notes |
|---|---|---|---|
| NBA | 745 | nba | Oct-Jun میں highest volume |
| NFL | 450 | nfl | Sep-Feb میں Sun/Mon peak |
| Tennis (all) | 864 | tennis | year-round، tournament cadence |
| Soccer (general) | 1059 | soccer | نیچے والے sub-tags کے ساتھ combine کریں |
| EPL | 739 | epl | |
| UCL | 2186 | uefa-champions-league | |
| Esports (all) | 702 | esports | LoL+CS2+Valorant+Dota |
| MLB | 1245 | mlb | Apr-Oct میں peak |
| NHL | 823 | nhl | Oct-Jun میں peak |
Tag IDs سالوں کے ساتھ stable رہتے ہیں۔ نئے tags add ہوتے ہیں (Saudi Pro League، IPL) لیکن پرانے tags کو renumber نہیں کیا جاتا۔
Data sources: ESPN، official APIs، on-screen
Traditional sports کے لیے free ESPN scoreboard API وہ سب کچھ cover کرتی ہے جس کی آپ کو ضرورت ہے: scores، period/clock، win-probability، کبھی کبھی shot location۔ Key کی ضرورت نہیں؛ rate-limit صرف IP level پر ہوتا ہے۔ Endpoint pattern: https://site.api.espn.com/apis/site/v2/sports/<sport>/<league>/scoreboard۔
Esports کے لیے ESPN میں coverage نہیں ہے۔ Options: PandaScore ($30-60/mo، industry standard)، HLTV (صرف CS2، scrapeable، API نہیں)، Liquipedia (community-maintained، scrapeable، update cadence سست)۔
On-screen feeds (TV stream کے لیے pay کرنا اور OCR کے ذریعے scorebug پڑھنا) کام تو کرتے ہیں مگر operationally heavy ہیں۔ صرف اسی صورت recommend کیے جاتے ہیں جب آپ کے پاس ایسی strategy ہو جسے sub-3-second updates کی ضرورت ہو، اور جس sport کے لیے کوئی API real time میں cover نہ کرتی ہو۔
In-game کے لیے latency budget
In-game reactive bot کے لیے end-to-end latency budget۔
- Score event ہوتا ہے: t=0
- Source feed reflect کرتی ہے: t+3-15s (ESPN: ~10s; PandaScore: ~3s)
- آپ کا bot feed پڑھتا ہے: t+10-16s
- Bot action decide کرتا ہے: +50ms
- FOK order place ہوتا ہے: +200-500ms
- CLOB پر matched ہوتا ہے: +300-1000ms (network + matching)
Total: 11-17 seconds۔ سب سے تیز professional firms paid premium feeds اور co-located VPS کے ساتھ end-to-end 3-5 seconds achieve کرتی ہیں۔ Standard hosts اور free ESPN پر چلنے والے retail bots زیادہ سست end پر ہوتے ہیں۔
جن strategies کو sub-5s چاہیے، وہ retail کے لیے viable نہیں ہیں۔ جو strategies 10-17s window میں کام کرتی ہیں وہ یہ ہیں: score کے بعد line-catching، overreactions کو fade کرنا، late-game certainty plays۔
0.99 / 0.01 trap
سب سے common in-play sports bot failure: one minute left پر heavy favorite کو 0.99 پر buy کرنا، اور آسان +1¢ کی امید رکھنا۔ یہ تین reasons سے fail ہوتا ہے۔
First, underdog کی 1% implied probability صفر نہیں ہوتی - late comebacks غیر معمولی frequency کے ساتھ ہوتے ہیں۔ 99.5% certain win، اگر 200 بار کھیلا جائے، تو full position size کے لیے ایک loss پیدا کرتا ہے۔
Second, 0.99/0.01 پر spread کا مطلب ہے کہ آپ share کے لیے 99c pay کرتے ہیں، success پر 1c جیتتے ہیں، اور rare reversal پر 99c ہارتے ہیں۔ Risk-reward انتہائی brutal ہے۔
Third, GTC sell at 0.999 استعمال کرنے والا bot شاذ و نادر ہی fill ہوگا - اس price پر buyers نہیں ہوتے۔ Position resolution تک ride کرتی ہے۔ اگر جیت ہو جائے تو آپ نے 1c کمایا۔ اگر reversal ہو جائے تو آپ 99c ہار گئے۔
یہ trap builders کے حقیقی پیسے کا نقصان ہے جنہوں نے math نہیں چلائی۔ 0.95+ priced markets سے باہر رہیں جب تک کہ آپ کی strategy خاص طور پر redemption-arbitrage profile کے لیے نہ بنائی گئی ہو۔
Code: games book کو subscribe کریں اور react کریں
Reference: ایک مخصوص NBA game کے WebSocket کو subscribe کریں، book updates log کریں، imbalance signal پر FOK fire کریں۔
import websocket, json
THRESHOLD = 0.5 # imbalance level to trigger
def on_message(ws, message):
msg = json.loads(message)
if msg.get("event_type") != "book": return
bids = msg.get("bids", [])
asks = msg.get("asks", [])
bid_depth = sum(float(b["price"]) * float(b["size"]) for b in bids[:5])
ask_depth = sum(float(a["price"]) * float(a["size"]) for a in asks[:5])
total = bid_depth + ask_depth
if total < 100: return # too illiquid
imb = (bid_depth - ask_depth) / total
if abs(imb) > THRESHOLD:
print(f"signal imb={imb:.2f} bid={bid_depth:.0f} ask={ask_depth:.0f}")
# fire FOK here
ws = websocket.WebSocketApp(
"wss://ws-subscriptions-clob.polymarket.com/ws/market",
on_open=lambda ws: ws.send(json.dumps({"type":"Market","markets":["<CONDITION_ID>"]})),
on_message=on_message
)
ws.run_forever()
Production additions: fires کے درمیان cooldown، per-token inventory cap، stale book پر kill (30s تک کوئی message نہ آئے)۔





