@@ -138,6 +138,7 @@ cdef class TopstepClient:
138138 order_data[" accountId" ] = account_id
139139
140140 async with httpx.AsyncClient() as client:
141+ print (f" DEBUG: Placing Order Payload: {json.dumps(order_data)}" )
141142 response = await client.post(url, json = order_data, headers = headers)
142143
143144 if response.is_success:
@@ -210,7 +211,7 @@ cdef class TopstepClient:
210211 """ Async REST search accounts"""
211212 url = f" {self.base_url}/api/Account/search"
212213 headers = self ._get_headers()
213- payload = {" active " : only_active} # Check API spec, usually paging too but simplifying
214+ payload = {" onlyActiveAccounts " : only_active} # Check API spec, usually paging too but simplifying
214215 # Legacy accounts.py used: {"page": 1, "pageSize": 100} maybe?
215216 # Let's check legacy implementation below or assume standard search
216217 # Re-checking legacy accounts.py logic would be safer but let's assume basic search for now
@@ -242,5 +243,13 @@ cdef class TopstepClient:
242243
243244 def _handle_response (self , response ):
244245 if response.is_success:
245- return {" success" : True , ** response.json()}
246+ data = response.json()
247+ # DEBUG LOGGING for Soft Failures
248+ if not data.get(" success" , True ): # If API explicitly says false
249+ print (f" DEBUG: Soft Failure (HTTP 200). Response: {data}" )
250+ # print(f"DEBUG: HTTP {response.status_code} from {response.url}. Body: {data}")
251+ return {" success" : True , ** data}
252+ # DEBUG LOGGING
253+ print (f" DEBUG: API Error. Status: {response.status_code}, URL: {response.url}" )
254+ print (f" DEBUG: Response Text: {response.text}" )
246255 return {" success" : False , " error" : response.text}
0 commit comments