# `ZenQuant.Helpers.Funding`
[🔗](https://github.com/ZenHive/zen_quant/blob/v0.8.1/lib/zen_quant/helpers/funding.ex#L1)

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]

# `next_funding`

```elixir
@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)

# `next_funding_at`

```elixir
@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]

# `next_funding_at_from`

```elixir
@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]

# `next_funding_from`

```elixir
@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)

---

*Consult [api-reference.md](api-reference.md) for complete listing*
