Funding rate timing helpers for perpetual futures.
Pure functions for calculating time until next funding payment. Most perpetual futures exchanges use 8-hour funding cycles at 00:00, 08:00, and 16:00 UTC.
Example
ZenQuant.Helpers.Funding.next_funding()
# => 2.5 (hours until next funding)
ZenQuant.Helpers.Funding.next_funding_at()
# => ~U[2025-01-15 16:00:00Z]API Functions
| Function | Arity | Description | Param Kinds |
|---|---|---|---|
next_funding_at_from | 1 | Next fixed eight-hour funding DateTime after the supplied time. | from: value |
next_funding_from | 1 | Hours until the next fixed eight-hour funding time from a supplied DateTime. | from: value |
next_funding_at | 0 | Next 00:00, 08:00, or 16:00 UTC funding time, using the system clock. | - |
next_funding | 0 | Hours until the next 00:00, 08:00, or 16:00 UTC funding time, using the system clock. | - |
Summary
Functions
Returns hours until the next funding time.
Returns the DateTime of the next funding time.
Returns the DateTime of the next funding time from a given DateTime.
Returns hours until the next funding time from a given DateTime.
Functions
@spec next_funding() :: float()
Returns hours until the next funding time.
Standard funding cycles are at 00:00, 08:00, and 16:00 UTC.
Example
ZenQuant.Helpers.Funding.next_funding()
# => 2.5 (hours until next funding)
@spec next_funding_at() :: DateTime.t()
Returns the DateTime of the next funding time.
Standard funding cycles are at 00:00, 08:00, and 16:00 UTC.
Example
ZenQuant.Helpers.Funding.next_funding_at()
# => ~U[2025-01-15 16:00:00Z]
@spec next_funding_at_from(DateTime.t()) :: DateTime.t()
Returns the DateTime of the next funding time from a given DateTime.
Example
past_time = ~U[2025-01-15 07:30:00Z]
ZenQuant.Helpers.Funding.next_funding_at_from(past_time)
# => ~U[2025-01-15 08:00:00Z]
@spec next_funding_from(DateTime.t()) :: float()
Returns hours until the next funding time from a given DateTime.
Useful for backtesting or working with historical data.
Example
past_time = ~U[2025-01-15 07:30:00Z]
ZenQuant.Helpers.Funding.next_funding_from(past_time)
# => 0.5 (30 minutes until 08:00)