This repository was archived by the owner on May 25, 2026. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 385
fix: tick size cache stale — force refresh on order create, better er… #282
Open
kingo233
wants to merge
5
commits into
Polymarket:main
Choose a base branch
from
kingo233:fix/tick-size-cache-stale
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
3ab67c9
fix: tick size cache stale — force refresh on order create, better er…
kingo233 368f2c2
fix: make TickSizeRejectedError inherit from PolyApiException
kingo233 dff0ba8
fix: remove dead 'minimum_tick' check in _is_tick_size_related_error
kingo233 40a4d7f
fix: add keyword detection to _is_tick_size_related_error
kingo233 b077da8
fix: handle dict/nested error_msg in tick size detection
kingo233 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,55 @@ | ||
| """Tests for ClobClient error message handling (tick size detection).""" | ||
| from unittest import TestCase | ||
|
|
||
| from py_clob_client.client import ClobClient | ||
|
|
||
|
|
||
| class TestClientTickSizeErrorDetection(TestCase): | ||
| """Test _is_tick_size_related_error and _flatten_error_message with dict/string payloads.""" | ||
|
|
||
| def test_is_tick_size_related_error_string_plain(self): | ||
| self.assertTrue(ClobClient._is_tick_size_related_error("invalid tick size")) | ||
| self.assertTrue(ClobClient._is_tick_size_related_error("Price precision error")) | ||
| self.assertTrue(ClobClient._is_tick_size_related_error("minimum_tick violated")) | ||
| self.assertFalse(ClobClient._is_tick_size_related_error("insufficient balance")) | ||
| self.assertFalse(ClobClient._is_tick_size_related_error("")) | ||
|
|
||
| def test_is_tick_size_related_error_string_none(self): | ||
| self.assertFalse(ClobClient._is_tick_size_related_error(None)) | ||
|
|
||
| def test_is_tick_size_related_error_dict_nested_message(self): | ||
| # API returns resp.json() e.g. {"error": {"message": "invalid tick size"}} | ||
| payload = {"error": {"message": "invalid tick size"}} | ||
| self.assertTrue(ClobClient._is_tick_size_related_error(payload)) | ||
|
|
||
| def test_is_tick_size_related_error_dict_precision_deep(self): | ||
| payload = {"detail": {"reason": "Price precision does not match"}} | ||
| self.assertTrue(ClobClient._is_tick_size_related_error(payload)) | ||
|
|
||
| def test_is_tick_size_related_error_dict_minimum_tick(self): | ||
| payload = {"message": "Order violates minimum_tick"} | ||
| self.assertTrue(ClobClient._is_tick_size_related_error(payload)) | ||
|
|
||
| def test_is_tick_size_related_error_dict_unrelated(self): | ||
| payload = {"error": {"message": "insufficient balance"}} | ||
| self.assertFalse(ClobClient._is_tick_size_related_error(payload)) | ||
|
|
||
| def test_flatten_error_message_string(self): | ||
| self.assertEqual(ClobClient._flatten_error_message("hello"), "hello") | ||
|
|
||
| def test_flatten_error_message_dict_nested(self): | ||
| payload = {"error": {"message": "invalid tick size"}} | ||
| self.assertEqual( | ||
| ClobClient._flatten_error_message(payload), "invalid tick size" | ||
| ) | ||
|
|
||
| def test_flatten_error_message_dict_multiple_keys(self): | ||
| payload = {"msg": "precision", "code": 400} | ||
| self.assertIn("precision", ClobClient._flatten_error_message(payload)) | ||
|
|
||
| def test_flatten_error_message_list(self): | ||
| payload = ["first", "minimum_tick error"] | ||
| self.assertIn("minimum_tick", ClobClient._flatten_error_message(payload)) | ||
|
|
||
| def test_flatten_error_message_none(self): | ||
| self.assertEqual(ClobClient._flatten_error_message(None), "") |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.