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

Historical funding rates for an asset.

Returns historical funding rate records for a perpetual asset.

See: https://hyperliquid.gitbook.io/hyperliquid-docs/for-developers/api/info-endpoint/perpetuals#retrieve-historical-funding-rates

Usage

{:ok, history} = FundingHistory.request("BTC", 1700000000000)
{:ok, rates} = FundingHistory.rates(history)

Summary

Functions

Returns metadata about this endpoint.

Returns postgres table configurations (multi-table support).

Returns storage configuration for this endpoint.

Get average funding rate.

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 funding history data.

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

Get records within a time range.

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.

Get all funding rate records.

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.FundingHistory{records: [Record.t()]}

Functions

Returns metadata about this endpoint.

Example

iex> Hyperliquid.Api.Info.FundingHistory.__endpoint_info__()
%{
  endpoint: "fundingHistory",
  type: :info,
  rate_limit_cost: 2,
  params: [:coin, :start_time],
  optional_params: [:end_time],
  doc: "Retrieve historical funding rates for an asset",
  returns: "Historical funding rate records for a perpetual asset"
}

Returns postgres table configurations (multi-table support).

Returns storage configuration for this endpoint.

Link to this function

average_rate(funding_history)

View Source
@spec average_rate(t()) :: {:ok, float()} | {:error, :no_records | :parse_error}

Get average funding rate.

Parameters

  • history: The funding history struct

Returns

  • {:ok, float()} - Average funding rate
  • {:error, :no_records} - If no records
  • {:error, :parse_error} - If parsing fails

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(coin, start_time, opts)

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

Build the request payload.

Returns true if cache storage is enabled.

Returns the cache TTL if configured.

Link to this function

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

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

Creates a changeset for funding history data.

Parameters

  • history: The funding history struct
  • attrs: Map with payments data

Returns

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

fetch(coin, start_time, opts \\ [])

View Source

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

Link to this function

fetch!(coin, start_time, opts \\ [])

View Source
Link to this function

in_range(funding_history, start_time, end_time)

View Source
@spec in_range(t(), non_neg_integer(), non_neg_integer()) :: [map()]

Get records within a time range.

Parameters

  • history: The funding history struct
  • start_time: Start timestamp in ms
  • end_time: End timestamp in ms

Returns

  • List of records in range
@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 rates(t()) :: [map()]

Get all funding rate records.

Parameters

  • history: The funding history struct

Returns

  • List of funding rate records
Link to this function

request(coin, start_time, opts \\ [])

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

Make the API request and parse the response.

Link to this function

request!(coin, start_time, opts \\ [])

View Source
@spec request!(term(), term(), keyword()) :: t()

Make the API request, raising on error.

Link to this function

request_raw(coin, start_time, opts \\ [])

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

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

Link to this function

request_raw!(coin, start_time, opts \\ [])

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

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

Returns true if any storage backend is enabled.