View Source Hyperliquid.Api.Exchange.CancelByCloid (hyperliquid v0.2.2)

Cancel orders on Hyperliquid by client order ID.

See: https://hyperliquid.gitbook.io/hyperliquid-docs/for-developers/api/exchange-endpoint

Summary

Functions

Cancel a single order by client order ID.

Cancel multiple orders by client order ID.

Types

@type cancel_opts() :: [{:vault_address, String.t()}]
@type cancel_request() :: %{asset: non_neg_integer(), cloid: String.t()}
@type cancel_response() :: %{
  status: String.t(),
  response: %{type: String.t(), data: %{statuses: list()}}
}

Functions

Link to this function

cancel(asset, cloid, opts \\ [])

View Source
@spec cancel(non_neg_integer(), String.t(), cancel_opts()) ::
  {:ok, cancel_response()} | {:error, term()}

Cancel a single order by client order ID.

Parameters

  • private_key: Private key for signing (hex string)
  • asset: Asset index
  • cloid: Client order ID to cancel
  • opts: Optional parameters

Options

  • :vault_address - Cancel on behalf of a vault

Returns

  • {:ok, response} - Cancel result
  • {:error, term()} - Error details

Examples

{:ok, result} = CancelByCloid.cancel(private_key, 0, "my-order-1")
Link to this function

cancel_batch(cancels, opts \\ [])

View Source
@spec cancel_batch([cancel_request()], cancel_opts()) ::
  {:ok, cancel_response()} | {:error, term()}

Cancel multiple orders by client order ID.

Parameters

  • private_key: Private key for signing (hex string)
  • cancels: List of cancel requests [%{asset: 0, cloid: "id"}, ...]
  • opts: Optional parameters

Options

  • :vault_address - Cancel on behalf of a vault

Returns

  • {:ok, response} - Batch cancel result
  • {:error, term()} - Error details

Examples

cancels = [
  %{asset: 0, cloid: "my-order-1"},
  %{asset: 0, cloid: "my-order-2"}
]
{:ok, result} = CancelByCloid.cancel_batch(private_key, cancels)