import os, requests
BASE = "https://api.0xinsider.com/api/v1"
H = {"Authorization": f"Bearer {os.environ['OXINSIDER_API_KEY']}"}
wallets = ["0x204f...", "0x863...", "0x885..."]
batch = requests.post(
f"{BASE}/traders/batch",
json={"traders": wallets, "expand": ["trust"]},
headers=H,
).json()
book = []
for item in batch["data"]:
if item["status"] == "ok":
t = item["data"]
book.append({
"wallet": t["address"],
"name": t["username"],
"grade": t["grade"],
"total_pnl": t["pnl"]["total"],
"unrealized": t["pnl"]["unrealized"],
"last_30d": t["pnl"]["last_30d"],
})
else:
print("failed:", item["input"], item["error"]["message"])
print("portfolio P&L:", sum(b["total_pnl"] for b in book))