Skip to content

Bound retry loop in Trader.one_best_trade#217

Open
Soth912 wants to merge 1 commit intoPolymarket:mainfrom
Soth912:codex/repo-audit-agents
Open

Bound retry loop in Trader.one_best_trade#217
Soth912 wants to merge 1 commit intoPolymarket:mainfrom
Soth912:codex/repo-audit-agents

Conversation

@Soth912
Copy link

@Soth912 Soth912 commented Mar 15, 2026

Summary

  • replace the recursive retry path in Trader.one_best_trade() with a bounded loop
  • re-raise the original exception once retries are exhausted instead of recursing indefinitely
  • add a regression test covering repeated failure and bounded retries

Why

During repo-audit, Trader.one_best_trade() was found to call itself from the except block. If the underlying failure persists, the method keeps recursing until Python hits the recursion limit, which hides the original operational error behind a secondary RecursionError.

Testing

  • /Users/soth/工作空间/githubfix/.venv/bin/python -m unittest discover -s tests

Note

Medium Risk
Touches the main trading execution path by changing retry/error propagation semantics; mistakes could alter how failures are surfaced or how many times trade selection runs.

Overview
Bounds retry behavior in Trader.one_best_trade(). The method now accepts max_retries, retries via a loop instead of self-recursion, and re-raises the original exception once the retry budget is exhausted.

Adds a unit test (tests/test_trade.py) that simulates repeated failure and asserts the function attempts max_retries + 1 times and ultimately raises the original error.

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

Copy link

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

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

Welcome to Polymarket Agents. Thank you for creating your first PR. Cheers!

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