View Source Hyperliquid.Api.Info.CandleSnapshot (hyperliquid v0.2.2)
OHLCV candle data for a coin.
Returns historical candle data for charting and technical analysis.
Usage
{:ok, candles} = CandleSnapshot.request("BTC", "1h", start_time, end_time)
{:ok, vwap} = CandleSnapshot.vwap(candles)
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 candle snapshot data.
Fetch data and persist to configured storage backends.
Fetch data and persist. Raises on error.
Get candles within a time range.
Get the latest candle.
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.
Get valid candle intervals.
Calculate VWAP (Volume Weighted Average Price) for the snapshot.
Types
Functions
Returns metadata about this endpoint.
Example
iex> Hyperliquid.Api.Info.CandleSnapshot.__endpoint_info__()
%{
endpoint: "candleSnapshot",
type: :info,
rate_limit_cost: 2,
params: [:coin, :interval, :start_time, :end_time],
optional_params: [],
doc: "Retrieve OHLCV candle data for a coin",
returns: "Array of candles with OHLCV data and trade counts"
}
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.
@spec changeset(t(), map()) :: Ecto.Changeset.t()
Creates a changeset for candle snapshot data.
Parameters
snapshot: The snapshot structattrs: Map with candles 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 candles within a time range.
Parameters
snapshot: The candle snapshot structstart_time: Start timestamp in msend_time: End timestamp in ms
Returns
- List of candles within range
Get the latest candle.
Parameters
snapshot: The candle snapshot struct
Returns
{:ok, Candle.t()}if candles exist{:error, :empty}if no candles
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.
Returns true if any storage backend is enabled.
@spec valid_intervals() :: [String.t()]
Get valid candle intervals.
Returns
- List of valid interval strings
Calculate VWAP (Volume Weighted Average Price) for the snapshot.
Parameters
snapshot: The candle snapshot struct
Returns
{:ok, float()}- VWAP value{:error, :empty}- No candles