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

Cancel orders on Hyperliquid by order ID.

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

Summary

Functions

Cancel a single order by order ID.

Cancel multiple orders by order ID.

Types

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

Functions

Link to this function

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

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

Cancel a single order by order ID.

Parameters

  • asset: Asset index
  • oid: Order ID to cancel
  • opts: Optional parameters

Options

  • :private_key - Private key for signing (falls back to config)
  • :vault_address - Cancel on behalf of a vault

Returns

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

Examples

{:ok, result} = Cancel.cancel(0, 12345)

Breaking Change (v0.2.0)

private_key was previously the first positional argument. It is now an option in the opts keyword list (:private_key).

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 order ID.

Parameters

  • cancels: List of cancel requests [%{asset: 0, oid: 123}, ...]
  • opts: Optional parameters

Options

  • :private_key - Private key for signing (falls back to config)
  • :vault_address - Cancel on behalf of a vault

Returns

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

Examples

cancels = [
  %{asset: 0, oid: 12345},
  %{asset: 0, oid: 12346}
]
{:ok, result} = Cancel.cancel_batch(cancels)

Breaking Change (v0.2.0)

private_key was previously the first positional argument. It is now an option in the opts keyword list (:private_key).