Skip to content

feat(candles): support 1d interval in aggregator#454

Open
Nuwe10 wants to merge 1 commit into
Vatix-Protocol:mainfrom
Nuwe10:feature/420-support-1d-interval-in-aggregator
Open

feat(candles): support 1d interval in aggregator#454
Nuwe10 wants to merge 1 commit into
Vatix-Protocol:mainfrom
Nuwe10:feature/420-support-1d-interval-in-aggregator

Conversation

@Nuwe10

@Nuwe10 Nuwe10 commented Jun 28, 2026

Copy link
Copy Markdown
Contributor

Summary

Formalises and tests the 1d candle interval in the aggregator pipeline.

What was already in place

Location Status
CandleInterval type '1d' present
INTERVAL_MS['1d'] 86_400_000
SCHEDULES cron '0 0 * * *' ✅ present
VALID_INTERVALS in price controller '1d' included
getIntervalSeconds / getDefaultIntervalSeconds ✅ handled

What this PR adds

  • JSDoc comment on the '1d' entry in INTERVAL_MS documenting the UTC midnight-boundary semantics and the relationship between the cron fire time and the period-window calculation.
  • candles.service.spec.ts — unit tests covering:
    • No-op when no swaps exist in the period
    • Correct OHLCV values (open/high/low/close/volumeUsd) computed from a set of swaps
    • Separate candle rows written per distinct pool
    • The query window for 1d is exactly 86_400_000 ms
    • All four intervals (1m, 5m, 1h, 1d) resolve without error

Validation

  • TypeScript: no diagnostics on changed files
  • Tests require Jest (not installed in CI yet); test runner is the standard NestJS/Jest config already present in package.json

Closes #420

The 1d CandleInterval was already wired into INTERVAL_MS, the BullMQ
SCHEDULES (cron '0 0 * * *'), VALID_INTERVALS in the price controller,
and getIntervalSeconds in the price service.

This commit makes the 1d support explicit and verified:

- Adds a JSDoc comment on the '1d' entry in INTERVAL_MS explaining the
  UTC midnight-boundary semantics and how the cron firing time aligns
  with the period calculation.
- Adds candles.service.spec.ts with unit tests covering:
    • no-op when no swaps exist for the period
    • correct OHLCV computation for a single pool over a 1d window
    • separate candles written per distinct pool
    • correct 86_400_000 ms query window for the '1d' interval
    • all four intervals (1m, 5m, 1h, 1d) resolve without error

Closes Vatix-Protocol#420
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Support 1d interval in aggregator

1 participant