View Source Hyperliquid.Interval (hyperliquid v0.1.1)
Provides helper functions for handling time intervals supported by Hyperliquid.
This module offers utilities for working with various time intervals, from 1 minute to 1 month. It includes functions to list supported intervals, convert intervals to milliseconds, and calculate the next interval start time.
Supported Intervals
The following intervals are supported: 1m, 3m, 5m, 15m, 30m, 1h, 2h, 4h, 8h, 12h, 1d, 3d, 1w, 1M
Usage
You can use this module to:
- Get a list of supported intervals
- Convert intervals to milliseconds
- Calculate the next start time for a given interval
Example:
iex> Hyperliquid.Interval.list()
["1m", "3m", "5m", "15m", "30m", "1h", "2h", "4h", "8h", "12h", "1d", "3d", "1w", "1M"]
iex> Hyperliquid.Interval.to_milliseconds("1h")
3600000
iex> current_time = :os.system_time(:millisecond)
iex> Hyperliquid.Interval.next_start(current_time, "15m")
# Returns the next 15-minute interval start time
Summary
Functions
Rounds the current time up to the nearest interval period specified in milliseconds.
Converts interval to milliseconds.
Functions
Rounds the current time up to the nearest interval period specified in milliseconds.
Converts interval to milliseconds.