• Interval token to seconds. Case matters where it disambiguates: lowercase The instant a bar starting at barStartSec closes, or null when that cannot be known from the interval alone.

    This asks the interval registry rather than parsing the token itself. A second parser here was the bug: it matched a fixed set of letter codes and returned 60 seconds for anything else, so a host that registered its own code got a cache that believed a new bar closed every minute. A tick-count series keyed that way is served stale for up to a minute at a time, and a registered calendar code was approximated at 30 days.

    Null means "no fixed close", and it is returned for three genuinely different situations that all demand the same conservative answer:

    • tick and volume bars, which close on trade flow. A 500-tick bar may run for a second or an hour, so nothing about elapsed time says whether the last bar is complete.
    • an unregistered code. Guessing 60 seconds is how the old parser turned a typo into a silently wrong cache.

    The caller must treat null as "cannot cache and cannot serve past coverage", which is the safe direction: it refetches rather than serving something stale.

    Parameters

    • interval: string
    • barStartSec: number
    • Optionalzone: string

    Returns number | null