MCPcopy Index your code
hub / github.com/pmxt-dev/pmxt / main

Function main

sdks/python/demo-real-usage.py:20–110  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

18from pmxt import Polymarket, MarketList
19
20def main():
21 print("=== Real PMXT MarketList.match() Demo ===\n")
22
23 # Initialize Polymarket client (will auto-start server if needed)
24 polymarket = Polymarket()
25
26 print("Fetching markets from Polymarket...")
27 try:
28 markets = polymarket.fetch_markets(limit=100)
29 except Exception as e:
30 print(f"Error fetching markets: {e}")
31 print("\nNote: Make sure PMXT server is running:")
32 print(" pmxt-server")
33 print("\nOr use the demo with mocked data:")
34 print(" python demo-usage.py")
35 sys.exit(1)
36
37 print(f"Fetched {len(markets)} markets\n")
38
39 # Search for Oscars-related markets
40 print("--- Filtering for Oscars 2026 markets ---\n")
41 oscars_markets = [
42 m for m in markets
43 if ("oscars" in m.title.lower() or "best picture" in m.title.lower())
44 and ("2026" in m.title.lower() or m.title.lower().count("20") > 0)
45 ]
46
47 if not oscars_markets:
48 # Fall back to any markets mentioning Best Picture
49 oscars_markets = [m for m in markets if "best picture" in m.title.lower()]
50
51 if not oscars_markets:
52 print("No Oscars markets found. Using first 20 markets instead...\n")
53 oscars_markets = markets[:20]
54
55 # Convert to MarketList to enable match() method
56 market_list = MarketList(oscars_markets)
57
58 print(f"Found {len(market_list)} relevant markets\n")
59
60 # Show first 10 markets
61 print("Sample markets:")
62 for i, market in enumerate(market_list[:10], 1):
63 print(f" {i}. {market.title[:70]}")
64
65 if len(market_list) > 10:
66 print(f" ... and {len(market_list) - 10} more")
67
68 # Try to find "One Battle"
69 print("\n--- Using market_list.match('One Battle') ---\n")
70 try:
71 market = market_list.match("One Battle")
72 print(f"✓ Found: {market.title}")
73 print(f" Market ID: {market.market_id}")
74 print(f" Volume 24h: ${market.volume_24h:,.0f}")
75 print(f" Liquidity: ${market.liquidity:,.0f}")
76 if market.yes:
77 print(f" Yes price: {market.yes.price:.4f}")

Callers 1

demo-real-usage.pyFile · 0.70

Calls 4

matchMethod · 0.95
PolymarketClass · 0.90
MarketListClass · 0.90
fetch_marketsMethod · 0.80

Tested by

no test coverage detected