fix(python): resolve HTTP client and trade message bugs#2
Open
manassehnnad1 wants to merge 1 commit into
Open
Conversation
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
this PR fixes four bugs in the Python HTTP client that collectively prevent
any order from being placed successfully using the SDK as shipped.
Bug 1 —
public_keycalled as a function (http_client.py)TransactionSigner.public_keyis a plain string attribute, not a callable.Calling it with
()raisesTypeError: 'str' object is not callableimmediately, making
place_orders()completely unusable.Bug 2 — Nonce sent as string with wrong source (
http_client.py)Two problems on the same line:
"1778724349688225000"instead of the integer
1778724349688225000.order_objects[0].noncereferences.nonceon a plain dict returned bytx.to_api(). Dicts have no.nonceattribute, raisingAttributeError: 'dict' object has no attribute 'nonce'.The
noncevariable is already correctly defined earlier in the functionand should be used directly.
Bug 3 —
pxandszsent as strings inLimitOrder.to_api()(trade.py)Price and size are wrapped in f-strings, sending them as JSON strings
(
"79.6") instead of JSON numbers (79.6). The API requires numericvalues and rejects string values with a 422 error.
The same issue affects
szinMarketOrder,Stop,TakeProfit, andTrailingStopand has been fixed in all locations.Bug 4 — Wrong response parsing path in
OrderResponse.from_api()(trade.py)The method navigates
data.payload.response.data.statuseswhich does notexist in the actual API response. The real structure is
response.data.statuses. This causesfrom_api()to always return anempty list
[]regardless of the actual server response, making itimpossible to know if an order succeeded, failed, or what its order ID is.
Impact
Bugs 1–3 together mean no order can ever be placed using the Python SDK
as shipped. Bug 4 means even if an order did go through, the caller would
never know because responses always parse as empty.
These bugs were discovered while building a Claude-powered autonomous
trading agent on BULK testnet using the Python SDK.
Testing
All fixes have been verified against the staging environment
(
staging-api.bulk.trade). Orders now place successfully and responsesparse correctly, returning the expected
restingstatus and order IDs.