auto: hourly snapshot 2026-06-07 13:34
This commit is contained in:
@@ -0,0 +1,24 @@
|
||||
import urllib.request, json, time, pandas as pd
|
||||
URL="https://api.hyperliquid.xyz/info"
|
||||
start_ms = int(pd.Timestamp("2026-04-01", tz="UTC").timestamp()*1000)
|
||||
end_ms = int(pd.Timestamp("2026-05-01", tz="UTC").timestamp()*1000)
|
||||
rows=[]; cursor=start_ms
|
||||
while cursor < end_ms:
|
||||
body=json.dumps({"type":"fundingHistory","coin":"BTC","startTime":cursor,"endTime":end_ms}).encode()
|
||||
req=urllib.request.Request(URL,data=body,headers={"Content-Type":"application/json"})
|
||||
with urllib.request.urlopen(req,timeout=30) as r:
|
||||
chunk=json.loads(r.read().decode())
|
||||
if not chunk: break
|
||||
rows.extend(chunk)
|
||||
last=int(chunk[-1].get("time",0))
|
||||
if last<=cursor: break
|
||||
cursor=last+1
|
||||
time.sleep(0.15)
|
||||
df=pd.DataFrame(rows)
|
||||
df["ts"]=pd.to_datetime(df["time"].astype("int64"),unit="ms",utc=True)
|
||||
df["fbps_ann"]=df["fundingRate"].astype(float)*8760*10000
|
||||
print(f"rows: {len(df)} expected: 720")
|
||||
print(f"span: {df.ts.min()} -> {df.ts.max()}")
|
||||
print(f"fbps_ann: mean={df.fbps_ann.mean():+.1f} std={df.fbps_ann.std():.1f} min={df.fbps_ann.min():+.1f} max={df.fbps_ann.max():+.1f}")
|
||||
df.to_parquet("/tmp/april_funding_verify.parquet")
|
||||
print("OK: API returns full April funding cleanly.")
|
||||
Reference in New Issue
Block a user