Signature
client.sync_orders(order_id: str = None) -> Dict
Parameters
| Parameter | Type | Description |
|---|
order_id | string | Specific order to sync. If None, syncs all pending orders |
Returns
Single order:
| Field | Type | Description |
|---|
status | string | Sync result: updated, no_change, already_complete, error |
order_id | string | The order ID that was synced |
filled_size | float | Total shares filled (cumulative) |
new_status | string | Current order status (PLACED, PARTIALLY_FILLED, FILLED, CANCELLED) |
new_fill_size | float | New shares filled in this sync (0 if no new fills) |
message | string | Error message (only present if status is “error”) |
All orders:
| Field | Type | Description |
|---|
synced | int | Orders whose status was updated |
total | int | Total orders processed |
Example
from polyhush import PolyhushClient
client = PolyhushClient(api_key="your-api-key")
# Sync all pending orders
result = client.sync_orders()
print(f"Synced {result['synced']} of {result['total']} orders")
# Sync a specific order
result = client.sync_orders(order_id="ord_abc123")
if result['status'] == 'updated':
print(f"Order synced: {result['new_fill_size']} new shares filled")
print(f"Total filled: {result['filled_size']}, Status: {result['new_status']}")
elif result['status'] == 'no_change':
print(f"Order unchanged: {result['filled_size']} filled, Status: {result['new_status']}")
elif result['status'] == 'error':
print(f"Sync failed: {result.get('message', 'Unknown error')}")
Order status is automatically kept in sync via WebSocket. Only call this manually after network interruptions or if an order seems stuck.