View Source Hyperliquid.Api.Info.RecentTrades (hyperliquid v0.2.2)
Recent trades for a coin.
Returns a list of recent trades with price, size, side, and timestamp.
See: https://hyperliquid.gitbook.io/hyperliquid-docs/for-developers/api/info-endpoint
Usage
{:ok, trades} = RecentTrades.request("BTC")
{:ok, vwap} = RecentTrades.vwap(trades)
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.
Get buy trades only.
Returns true if cache storage is enabled.
Returns the cache TTL if configured.
Creates a changeset for recent trades data.
Fetch data and persist to configured storage backends.
Fetch data and persist. Raises on error.
Get trades within a time range.
Get the latest trade.
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.
Get sell trades only.
Returns true if any storage backend is enabled.
Calculate total volume.
Calculate VWAP (Volume Weighted Average Price).
Types
@type t() :: %Hyperliquid.Api.Info.RecentTrades{coin: String.t(), trades: [Trade.t()]}
Functions
Returns metadata about this endpoint.
Example
iex> Hyperliquid.Api.Info.RecentTrades.__endpoint_info__()
%{
endpoint: "recentTrades",
type: :info,
rate_limit_cost: 1,
params: [:coin],
optional_params: [],
doc: "Retrieve recent trades for a coin",
returns: "List of recent trades with price, size, side, and timestamp"
}
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.
Get buy trades only.
Parameters
recent: The recent trades struct
Returns
- List of buy trades
Returns true if cache storage is enabled.
Returns the cache TTL if configured.
@spec changeset(t(), map()) :: Ecto.Changeset.t()
Creates a changeset for recent trades data.
Parameters
recent: The recent trades structattrs: Map with trades key
Returns
Ecto.Changeset.t()
Fetch data and persist to configured storage backends.
This calls request/N and then stores the result using Storage.Writer.
Request params are merged into stored data for cache key generation.
Fetch data and persist. Raises on error.
@spec in_range(t(), non_neg_integer(), non_neg_integer()) :: [map()]
Get trades within a time range.
Parameters
recent: The recent trades structstart_time: Start timestamp in msend_time: End timestamp in ms
Returns
- List of trades within range
Get the latest trade.
Parameters
recent: The recent trades struct
Returns
{:ok, Trade.t()}if trades exist{:error, :empty}if no trades
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).
@spec rate_limit_cost() :: non_neg_integer()
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.
Get sell trades only.
Parameters
recent: The recent trades struct
Returns
- List of sell trades
Returns true if any storage backend is enabled.
Calculate total volume.
Parameters
recent: The recent trades struct
Returns
{:ok, float()}- Total volume{:error, :empty}- No trades
Calculate VWAP (Volume Weighted Average Price).
Parameters
recent: The recent trades struct
Returns
{:ok, float()}- VWAP{:error, :empty}- No trades