Function alignToInterval

Aligns timestamp down to the nearest interval boundary. For example, for 15m interval: 00:17 -> 00:15, 00:44 -> 00:30

Candle timestamp convention:

  • Candle timestamp = openTime (when candle opens)
  • Candle with timestamp 00:00 covers period [00:00, 00:15) for 15m interval

Adapter contract:

  • Adapter must return candles with timestamp = openTime
  • First returned candle.timestamp must equal aligned since
  • Adapter must return exactly limit candles
  • Parameters

    • date: Date

      Date to align

    • interval: CandleInterval

      Candle interval (e.g., "1m", "15m", "1h")

    Returns Date

    New Date aligned down to interval boundary