View Source Hyperliquid.Api.Subscription.FastAssetCtxs (hyperliquid v0.4.1)

WebSocket subscription for low-latency mark and mid price updates.

A trimmed-down counterpart to assetCtxs: each event is a map of coin to a context carrying only markPx and midPx, either of which may be absent, and midPx may be explicitly null when there is no two-sided market.

See: https://hyperliquid.gitbook.io/hyperliquid-docs/for-developers/api/websocket/subscriptions

Usage

{:ok, request} = FastAssetCtxs.build_request()
# => {:ok, %{type: "fastAssetCtxs"}}

Summary

Functions

Returns postgres table configurations (multi-table support).

Returns storage configuration for this subscription.

Returns metadata about this subscription endpoint.

Build a cache key from event data using the configured pattern.

Build a subscription request.

Returns true if cache storage is enabled.

Returns the configured cache fields for partial storage, or nil for all fields.

Returns the cache TTL if configured.

Coins present in this event.

Generate a unique subscription key for this parameter set.

Mark price for a coin.

Mid price for a coin.

Returns true if postgres storage is enabled.

Returns the configured postgres fields for partial storage, or nil for all fields.

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

Returns true if any storage backend is enabled.

Types

@type request_params() :: %{}
@type t() :: %Hyperliquid.Api.Subscription.FastAssetCtxs{ctxs: map()}

Functions

Returns postgres table configurations (multi-table support).

Returns storage configuration for this subscription.

Returns metadata about this subscription endpoint.

Link to this function

build_cache_key(event_data)

View Source

Build a cache key from event data using the configured pattern.

Returns nil if cache is not enabled or no pattern is configured.

Link to this function

build_request(params \\ %{})

View Source
@spec build_request(map()) :: {:ok, map()}

Build a subscription request.

Returns

  • {:ok, request_map} - Subscription request

Returns true if cache storage is enabled.

Returns the configured cache fields for partial storage, or nil for all fields.

Returns the cache TTL if configured.

Link to this function

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

View Source
@spec changeset(t(), map()) :: Ecto.Changeset.t()
@spec coins(t() | map()) :: [String.t()]

Coins present in this event.

Parameters

  • event: The subscription event

Returns

  • List of coin names
Link to this function

generate_subscription_key(params)

View Source
@spec generate_subscription_key(map()) :: String.t()

Generate a unique subscription key for this parameter set.

Parameters

  • params - Map of subscription parameters

Returns

String key that uniquely identifies this subscription variant.

@spec mark_px(t() | map(), String.t()) :: {:ok, String.t()} | {:error, :not_found}

Mark price for a coin.

Parameters

  • event: The subscription event
  • coin: Coin name

Returns

  • {:ok, String.t()} if present
  • {:error, :not_found} otherwise
@spec mid_px(t() | map(), String.t()) :: {:ok, String.t()} | {:error, :not_found}

Mid price for a coin.

Returns {:error, :not_found} when the coin has no mid price, which includes the case where the API sent an explicit null.

Parameters

  • event: The subscription event
  • coin: Coin name

Returns

  • {:ok, String.t()} if present
  • {:error, :not_found} otherwise

Returns true if postgres storage is enabled.

Returns the configured postgres fields for partial storage, or nil for all fields.

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

Returns true if any storage backend is enabled.