Skip to main content
DELETE
/
api
/
v1
/
trading
/
orders
Cancel All Orders
curl --request DELETE \
  --url https://api.example.com/api/v1/trading/orders
{
  "message": "<string>",
  "cancelled": 123,
  "total": 123,
  "total_refund": 123,
  "errors": [
    {}
  ]
}

Usage

result = client.cancel_all_orders()

Response

message
string
Result message.
cancelled
integer
Number of orders successfully cancelled.
total
integer
Total number of open orders found.
total_refund
number
Total USDC refunded to available balance.
errors
array
List of any errors encountered during cancellation.

Example

from polyhush import PolyhushClient

client = PolyhushClient(api_key="your-api-key")

result = client.cancel_all_orders()

print(f"Cancelled: {result['cancelled']}/{result['total']} orders")
print(f"Total refund: ${result['total_refund']:.2f}")

if result.get('errors'):
    print(f"\n⚠️ Errors:")
    for error in result['errors']:
        print(f"  - {error}")

Response

{
  "message": "Cancelled 5 orders",
  "cancelled": 5,
  "total": 5,
  "total_refund": 275.50,
  "errors": []
}

Use Cases

Emergency Exit

Quickly cancel all orders before a major market event

Strategy Reset

Clear all orders to implement a new trading strategy

End of Day

Cancel all open orders at the end of your trading session

API Key Rotation

Clean up before rotating API keys
This method is atomic - it will attempt to cancel all orders even if some fail. Check the errors array to see if any cancellations failed.