Skip to content

add order history cleanup utility#134

Open
kirito201922 wants to merge 1 commit intoPolymarket:mainfrom
kirito201922:scripts/clean-order-history
Open

add order history cleanup utility#134
kirito201922 wants to merge 1 commit intoPolymarket:mainfrom
kirito201922:scripts/clean-order-history

Conversation

@kirito201922
Copy link

@kirito201922 kirito201922 commented Jan 5, 2026

Adds a script that prunes closed orders from a local order history JSON, reducing file size and improving performance.


Note

Introduces a Python utility to prune closed orders from data/order_history.json to keep history size manageable.

  • Adds scripts/python/clean_order_history.py that filters out orders with status == "closed" and rewrites the JSON (pretty-printed)
  • Handles missing history file gracefully and prints a summary of removed vs remaining orders

Written by Cursor Bugbot for commit 5d9270f. This will update automatically on new commits. Configure here.

Adds a script that prunes closed orders from a local order history JSON, reducing file size and improving performance.
return
data = json.loads(HISTORY_PATH.read_text())
original_len = len(data.get("orders", []))
data["orders"] = [o for o in data.get("orders", []) if o.get("status") != "closed"]
Copy link

Choose a reason for hiding this comment

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

Script adds "orders" key to files lacking it

The code unconditionally assigns data["orders"] even when the original JSON file doesn't contain an "orders" key. If run on a file without this key, the script will add "orders": [] to the file structure rather than leaving it unchanged. A cleanup utility probably shouldn't modify files that have no matching data to clean. The logic uses data.get("orders", []) to safely read, but then always writes back via assignment.

Fix in Cursor Fix in Web

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant