View Source Hyperliquid.Api.Info.ActiveAssetData (hyperliquid v0.2.2)

Active trading data for a specific asset and user.

Returns leverage, max trade sizes, available balance, and mark price for a specific coin and user combination.

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

Usage

{:ok, data} = ActiveAssetData.request("0x1234...", "BTC")
ActiveAssetData.cross_margin?(data)

Summary

Functions

Returns metadata about this endpoint.

Returns postgres table configurations (multi-table support).

Returns storage configuration for this endpoint.

Build a cache key from response data using the configured pattern. Returns nil if cache is not enabled or no pattern configured.

Build the request payload.

Returns true if cache storage is enabled.

Returns the cache TTL if configured.

Creates a changeset for active asset data.

Check if using cross margin.

Fetch is an alias for request when no storage is configured.

Check if using isolated margin.

Get the leverage value.

Get the max buy size.

Get the max sell size.

Parse and validate the API response.

Returns true if postgres storage is enabled.

Returns the postgres table name if configured (primary table for legacy support).

Returns the upsert config for postgres (primary table for legacy support).

Get the rate limit cost for this endpoint.

Make the API request and parse the response.

Make the API request, raising on error.

Make the API request and return the raw response map (no key transformation).

Make the API request returning raw map, raising on error.

Returns true if any storage backend is enabled.

Types

@type t() :: %Hyperliquid.Api.Info.ActiveAssetData{
  available_to_trade: [String.t()],
  leverage: Leverage.t(),
  mark_px: String.t(),
  max_trade_szs: [String.t()]
}

Functions

Returns metadata about this endpoint.

Example

iex> Hyperliquid.Api.Info.ActiveAssetData.__endpoint_info__()
%{
  endpoint: "activeAssetData",
  type: :info,
  rate_limit_cost: 2,
  params: [:user, :coin],
  optional_params: [],
  doc: "Retrieve active trading data for a specific asset and user",
  returns: "Leverage, max trade sizes, available balance, and mark price"
}

Returns postgres table configurations (multi-table support).

Returns storage configuration for this endpoint.

Build a cache key from response data using the configured pattern. Returns nil if cache is not enabled or no pattern configured.

Link to this function

build_request(user, coin)

View Source
@spec build_request(term(), term()) :: map()

Build the request payload.

Returns true if cache storage is enabled.

Returns the cache TTL if configured.

Link to this function

changeset(data \\ %__MODULE__{}, attrs)

View Source
@spec changeset(t(), map()) :: Ecto.Changeset.t()

Creates a changeset for active asset data.

Parameters

  • data: The active asset data struct
  • attrs: Map of attributes to validate

Returns

  • Ecto.Changeset.t()
Link to this function

cross_margin?(active_asset_data)

View Source
@spec cross_margin?(t()) :: boolean()

Check if using cross margin.

Parameters

  • data: The active asset data struct

Returns

  • boolean()

Fetch is an alias for request when no storage is configured.

Link to this function

isolated_margin?(active_asset_data)

View Source
@spec isolated_margin?(t()) :: boolean()

Check if using isolated margin.

Parameters

  • data: The active asset data struct

Returns

  • boolean()
Link to this function

leverage_value(active_asset_data)

View Source
@spec leverage_value(t()) :: integer()

Get the leverage value.

Parameters

  • data: The active asset data struct

Returns

  • Integer leverage value
@spec max_buy_size(t()) :: {:ok, String.t()} | {:error, :not_available}

Get the max buy size.

Parameters

  • data: The active asset data struct

Returns

  • {:ok, String.t()} if available
  • {:error, :not_available} if not available
@spec max_sell_size(t()) :: {:ok, String.t()} | {:error, :not_available}

Get the max sell size.

Parameters

  • data: The active asset data struct

Returns

  • {:ok, String.t()} if available
  • {:error, :not_available} if not available
@spec parse_response(map()) :: {:ok, t()} | {:error, term()}

Parse and validate the API response.

Returns true if postgres storage is enabled.

Returns the postgres table name if configured (primary table for legacy support).

Link to this function

postgres_upsert_config()

View Source

Returns the upsert config for postgres (primary table for legacy support).

@spec rate_limit_cost() :: non_neg_integer()

Get the rate limit cost for this endpoint.

@spec request(term(), term()) :: {:ok, t()} | {:error, term()}

Make the API request and parse the response.

@spec request!(term(), term()) :: t()

Make the API request, raising on error.

@spec request_raw(term(), term()) :: {:ok, map()} | {:error, term()}

Make the API request and return the raw response map (no key transformation).

Link to this function

request_raw!(user, coin)

View Source
@spec request_raw!(term(), term()) :: map()

Make the API request returning raw map, raising on error.

Returns true if any storage backend is enabled.