Usage
result = client.cancel_order(order_id="ord_abc123")
Parameters
Response
Cancellation result message.
Amount refunded to available balance (for buy orders).
Example
from polyhush import PolyhushClient, PolyhushAPIError
client = PolyhushClient(api_key="your-api-key")
try:
result = client.cancel_order(order_id="ord_abc123")
print(f"✅ {result['message']}")
if result.get('refund_amount'):
print(f" Refunded: ${result['refund_amount']:.2f}")
except PolyhushAPIError as e:
if "already" in e.message.lower():
print("Order was already cancelled or filled")
else:
print(f"Cancel failed: {e.message}")
Response
{
"message": "Order cancelled successfully",
"refund_amount": 55.00
}
Refund Behavior
| Order Type | Refund |
|---|
| Buy order | Reserved USDC is refunded to available balance |
| Sell order | Reserved shares are released back to position |
| Partially filled | Only unfilled portion is refunded |
Cancellation requests are processed asynchronously. In rare cases, an order may fill between your cancel request and processing. Always check the response to confirm cancellation.