export type TimeframeUnit = 'm' | 'h' | 'D' | 'W' | 'M'; export interface Timeframe { readonly count: number; readonly unit: TimeframeUnit; /** The string as it was written, for a diagnostic that has to name it. */ readonly text: string; } export declare function parseTimeframe(text: string): Timeframe | undefined; /** Whether this timeframe is folded by counting rather than by the calendar. */ export declare function isIntraday(timeframe: Timeframe): boolean; /** Minutes one bar covers, for an intraday timeframe only. */ export declare function minutesOf(timeframe: Timeframe): number | undefined; /** * One timeframe's length in minutes, with a month treated as thirty days. * * Two uses and neither of them folds anything: ordering two timeframes, which * is "is the request finer than the chart" and therefore OS6002, and sizing the * range of history a host is asked to fetch, which is a floor. A month is not a * fixed number of minutes, and where a bucket actually begins is the calendar's * job below. */ export declare function nominalMinutes(timeframe: Timeframe): number; /** * Minutes one bar of a chart's own interval covers, or nothing where the host * stated no interval this engine can read. * * A month is counted at its nominal length here, which is the answer the * session facts need and not a claim about a calendar: any bar of a day or more * spans a whole session whatever the exact figure, so every number past the * length of a session gives those facts the same answer. */ export declare function barMinutesOf(interval: string | undefined): number | null; /** * The bucket an instant falls in, or nothing when no key can be worked out. * * Nothing comes back for a calendar unit with no zone, and for an instant that * is not a finite number. Both leave the read absent rather than folded into a * bucket the engine invented. */ export declare function bucketKeyOf(instant: number, timeframe: Timeframe, zone: string | null): number | undefined; /** Why a requested timeframe cannot be folded onto the chart's, if it cannot. */ export type FoldRefusal = { readonly code: 'OS6002'; } | { readonly code: 'OS6015'; readonly suggestion: string; }; /** * Whether the chart's bars can be folded into the requested ones. * * Two refusals and no third. A request finer than the chart is OS6002, because * folding cannot invent bars that were never loaded, and an intraday request * that is not a whole multiple of the chart's is OS6015, because an intraday * bucket is counted rather than dated and a bucket boundary that fell inside a * chart bar would put part of one bar in two requested bars. A day, week or * month request is dated, so the multiple rule does not apply to it. */ export declare function foldRefusal(requested: Timeframe, chart: Timeframe): FoldRefusal | undefined; //# sourceMappingURL=timeframe.d.ts.map