-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscanner.py
More file actions
55 lines (41 loc) · 2 KB
/
Copy pathscanner.py
File metadata and controls
55 lines (41 loc) · 2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
"""
Multi-Platform Scanner.
Fetches soccer markets from all enabled prediction market platforms,
groups them by match using fuzzy team name matching, and produces
CrossPlatformMatch objects ready for the detector.
"""
from concurrent.futures import ThreadPoolExecutor, as_completed
from platform_base import PlatformClient, NormalizedMatch, CrossPlatformMatch
from matching import group_matches_by_event
class Scanner:
"""Scans all enabled platforms and groups matches across platforms."""
def __init__(self, platforms: list[PlatformClient]):
self.platforms = platforms
def scan(self) -> list[CrossPlatformMatch]:
"""
Fetch soccer markets from all platforms and group by match.
Returns only matches found on 2+ platforms (cross-platform arb
requires prices from different sources).
"""
all_matches: list[NormalizedMatch] = []
def fetch(platform: PlatformClient) -> list[NormalizedMatch]:
print(f"[Scanner] Fetching from {platform.name}...")
result = platform.fetch_soccer_markets()
print(f"[Scanner] {platform.name}: {len(result)} markets")
return result
with ThreadPoolExecutor(max_workers=len(self.platforms)) as ex:
futures = {ex.submit(fetch, p): p for p in self.platforms}
for future in as_completed(futures):
try:
all_matches.extend(future.result())
except Exception as e:
print(f"[Scanner] Error fetching from {futures[future].name}: {e}")
if not all_matches:
print("[Scanner] No matches found from any platform")
return []
# Group by real-world match across platforms
grouped = group_matches_by_event(all_matches)
cross_platform_count = sum(1 for g in grouped if len(g.platform_data) >= 2)
print(f"[Scanner] {len(all_matches)} total markets -> "
f"{cross_platform_count} cross-platform matches")
return grouped