初步完成项目,可以监控给出入场信号
This commit is contained in:
@@ -0,0 +1,42 @@
|
||||
"""Test API directly to check rate limiting."""
|
||||
import os
|
||||
import httpx
|
||||
|
||||
proxy = os.environ.get('HTTP_PROXY', '').strip() or None
|
||||
client = httpx.Client(timeout=10.0, proxy=proxy)
|
||||
|
||||
print('=== Gamma API test ===')
|
||||
r = client.get(
|
||||
'https://gamma-api.polymarket.com/events',
|
||||
params={'active': 'true', 'closed': 'false', 'order': 'volume24hr', 'ascending': 'false', 'limit': 3},
|
||||
)
|
||||
print(f'Status={r.status_code} events={len(r.json())}')
|
||||
if r.json():
|
||||
print(f'first title: {r.json()[0].get("title", "?")[:50]}')
|
||||
|
||||
print()
|
||||
print('=== Data API: top 3 events → 1 market each ===')
|
||||
events_resp = client.get(
|
||||
'https://gamma-api.polymarket.com/events',
|
||||
params={'active': 'true', 'closed': 'false', 'limit': 3},
|
||||
).json()
|
||||
|
||||
for ev in events_resp[:3]:
|
||||
title = ev.get('title', '?')[:40]
|
||||
markets = ev.get('markets', []) or []
|
||||
if not markets:
|
||||
continue
|
||||
cid = markets[0].get('conditionId')
|
||||
if not cid:
|
||||
continue
|
||||
r2 = client.get(
|
||||
'https://data-api.polymarket.com/v1/market-positions',
|
||||
params={'market': cid, 'status': 'ALL', 'sortBy': 'TOTAL_PNL', 'limit': 5},
|
||||
)
|
||||
try:
|
||||
data = r2.json()
|
||||
n = len(data) if isinstance(data, list) else -1
|
||||
pos_count = sum(len(d.get('positions', [])) for d in data) if isinstance(data, list) else 0
|
||||
print(f' tokens={n} positions={pos_count} | {title}')
|
||||
except Exception as e:
|
||||
print(f' parse_err={e} body[:80]={r2.text[:80]}')
|
||||
Reference in New Issue
Block a user