/** * Higher timeframe and other instrument reads, folded onto the chart's bars. * * A read is an expression evaluated over a **different set of bars** than the * chart's, whose value is then folded back onto the chart's. Two halves, and * they are in two files: `request-body.ts` runs the expression once per * requested bar, and this decides which requested bar each chart bar is allowed * to see. The second half is where the off-by-one lives, so it is written as * one comparison repeated three times rather than as three rules. * * **Bars in, buckets out.** Source bars are grouped by the bucket key of their * open instant (`timeframe.ts`); a bucket becomes one requested bar. The source * is the chart's own bars for a read of the chart's instrument, which is the * read `host-interface.md` 5.1 says an engine can satisfy from what it already * holds, and the host's answer for a read of another instrument, which it never * can. One fold serves both, so the two kinds of read cannot drift apart. * * **The three modes differ in one thing: how far past the chart bar the fold is * allowed to look.** Everything else about them is the same code. * * | Mode | Source bars it may consume | Value the chart bar takes | * |---|---|---| * | `"confirmed"` | Those opening at or before this chart bar | The last bucket that closed | * | `"developing"` | Those opening at or before this chart bar | The bucket this bar is inside, so far | * | `"lookahead"` | Those belonging to this bar's bucket or earlier | The bucket this bar is inside, in full | * * Read the middle column, because it is the repainting question written out. * Confirmed and developing stop at the chart bar and can be computed live; * lookahead reads past it, which is why it repaints on history permanently and * by design, and why on the newest bucket, where there is nothing past the bar * to read, it is the bucket so far and nothing better exists. * * **The boundary.** A bucket has begun on the first chart bar whose key is the * new one, because a bar's open instant is what dates it. So a confirmed read * steps to the closed bucket's value on the first chart bar of the next bucket, * holds it across every bar inside that bucket including the last, and steps * again on the first bar of the one after. The bar a bucket closes on still * reads the bucket before it: at that bar's open, the bucket it is inside had * not closed. * * **Warmup translates by arithmetic and not by a rule.** The expression runs on * requested bars, so its own warmup is counted in requested bars and its absence * folds onto the chart like any other value: a twenty period average of daily * closes is absent until twenty daily bars exist, which on a five minute chart * is about a month in. The `warmup` field of the compiled program is what a host * extends the fetch range backwards by, a floor and not a promise, and an engine * given less gets a read that is absent for longer rather than a wrong number. */ import type { Span } from '../span/index.js'; import type { BarSource } from './bar-source.js'; import type { Clock, EngineLimits } from './budget.js'; import type { EngineHost } from './host.js'; import type { ResolvedInput } from './inputs.js'; import type { HostFacts, ManifestEntry, PositionFacts } from './library/index.js'; import type { Registers } from './registers.js'; import type { RequestPlan } from './request-plan.js'; import type { CompiledProgram, Request } from './types.js'; import type { Heap, Value } from './values/index.js'; export interface RequestParts { readonly program: CompiledProgram; /** Every read in the program, nested ones included, keyed by its own id. */ readonly plans: ReadonlyMap; readonly host: EngineHost; readonly limits: EngineLimits; readonly clock: Clock | undefined; readonly library: readonly ManifestEntry[]; readonly inputs: readonly ResolvedInput[]; /** The facts a body inherits, with its own identity written over three of them. */ readonly facts: HostFacts; /** The strategy's own position, which a body reads as the chart's bars do. */ readonly position: PositionFacts; /** * The heap of the machine these reads land in, read when a bar asks for it. * * A function rather than the heap, because a read written inside another lands * in the enclosing body's heap and that body does not exist until its own * reads have been built. */ heapOf(): Heap; spanAt(line: number, column: number): Span; } export declare class RequestSet { private readonly reads; private readonly byId; private readonly parts; constructor(parts: RequestParts, requests: readonly Request[]); get empty(): boolean; /** * Step 4: each read's value for this bar, written into its `"request"` * register. * * `fresh` says whether this is the first execution of this bar. A bar that is * executing again restores the fold to where it stood when the bar began and * rebuilds the bucket now forming from the source as it now stands, which is * what makes a moving bar idempotent one level down: the newest chart bar may * have been revised since the last execution, and the bucket it is inside has * to be rebuilt from the revision rather than from the reading it replaced. */ fill(registers: Registers, bars: BarSource, index: number, fresh: boolean): void; /** `req.isReady(read)`: whether the host has answered this one yet. */ answered(id: Value): Value; /** `req.error(read)`: the reason it failed, or the empty string when none has. */ failure(id: Value): Value; } //# sourceMappingURL=requests.d.ts.map