/** * Which bars a report is about, and which merely got it there. * * **Every bar supplied executes, and only some of them are reported.** That is * the whole of this file and it is the fact a driver written without it gets * wrong. A study of the last year needs the indicators warm before the year * starts, so bars before the window are handed to the engine exactly as the * reported ones are: they execute, their orders are real, and a position opened * on one of them is carried into the window rather than appearing from nowhere * at its first bar. What they are not is reported: no equity point, and no * calendar month of their own. * * **A window holding no bar at all is refused**, OS6020, rather than reported * as a flat curve. A flat curve is what a strategy that did nothing also * produces, and only this can tell the two apart. * * **Both bounds are inclusive and are compared against the times of the bars * supplied**, never against a calendar. A window that falls inside a gap in the * data is empty however wide it looks, which is the truthful answer: there are * no bars in it. * * The other fact a driver gets wrong is not a window at all and is written here * because this is where a driver looks: the bar count handed to the engine is * the total it will be given, not the number given so far. An engine told that * each bar is the only bar reports `bar.isLast` true on every one of them, and * a strategy that flattens on the last bar flattens on all of them. */ import type { BarMark } from '../accounting/index.js'; import type { Diagnostic } from '../diagnostics/index.js'; import type { DateRange } from './settings.js'; import type { RecordedBar } from './record.js'; /** Which of the bars supplied the report is about. */ export interface ReportWindow { /** The first reported bar, by index into the bars supplied. */ readonly first: number; /** The last reported bar, inclusive. */ readonly last: number; /** How many bars run before the first reported one. */ readonly warmup: number; /** Every bar supplied, which is what the engine is told a run holds. */ readonly total: number; } export type WindowResult = { readonly ok: true; readonly covered: ReportWindow; } | { readonly ok: false; readonly diagnostic: Diagnostic; }; /** * The window a range names over the bars supplied. * * A bar with no time is inside an unstated bound and outside a stated one, * because a bound is a comparison and there is nothing to compare it with. A * run over bars none of which carry a time is therefore reported whole when the * host named no range, which is what a host handing over a bare series means, * and refused the moment it names one, which is what a host asking for a window * it cannot be given deserves to be told. */ export declare function windowFor(bars: readonly RecordedBar[], range: DateRange): WindowResult; /** Whether one bar's own time is inside the window, both bounds inclusive. */ export declare function inside(time: number | null, range: DateRange): boolean; /** * Whether a bar is reported, which is the question the marks are built from. * * Asked of an index rather than of a time, because the window is decided once * and a bar asked twice has to be answered the same way both times. */ export declare function inReport(index: number, covered: ReportWindow): boolean; /** * The bars as the report marks against them: the close, and whether it counts. * * One mark per bar supplied, warmup included, because the money layer sweeps * the warmup rather than being handed a shortened list: a trade opened before * the window is already in the fold at the window's first point, with its * charges paid and its position marked. A mark says which of the two it is and * the fold decides what to do about it. * * Built here rather than in the driver because a replay marks the same bars the * same way, and two places deciding what a warmup bar is would be two reports * of one run. */ export declare function marksFor(bars: readonly RecordedBar[], covered: ReportWindow): readonly BarMark[]; //# sourceMappingURL=range.d.ts.map