Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 25 additions & 0 deletions scripts/python/download_order_history.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#!/usr/bin/env python3

"""
Download and save your complete order history from the Polymarket API.

Requires API credentials set in environment.
"""

import json
import os
from pathlib import Path
from agents.polymarket.polymarket import Polymarket # type: ignore

OUTPUT_FILE = Path("data/order_history_download.json")

def main() -> None:
client = Polymarket()
orders = client.get_all_orders() # type: ignore
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Script calls nonexistent get_all_orders method

The script calls client.get_all_orders() on the Polymarket instance, but this method does not exist in the Polymarket class. The Polymarket class has methods like get_all_markets() and get_all_events(), but no get_all_orders() method was ever implemented. The # type: ignore comment suppresses the type checker warning that would have caught this, so the script will crash at runtime with an AttributeError.

Fix in Cursor Fix in Web

OUTPUT_FILE.parent.mkdir(parents=True, exist_ok=True)
with open(OUTPUT_FILE, "w") as f:
json.dump([o.as_dict() for o in orders], f, indent=2) # type: ignore
print(f"Downloaded {len(orders)} orders to {OUTPUT_FILE}")

if __name__ == "__main__":
main()