import type { BarState, HostBar } from './bars.js'; import type { EngineLimits } from './budget.js'; import type { ResolvedInput } from './inputs.js'; import type { LoadOptions } from './load.js'; import type { Grid } from './grids.js'; import type { LedgerRow, OrderFrame } from './ledger/index.js'; import type { CompiledProgram } from './types.js'; import type { RequestPlan } from './request-plan.js'; import type { BarColumns } from './bar-source.js'; import type { Value } from './values/index.js'; import type { Drawing } from './drawings.js'; import type { BarResult, RunResult } from './results.js'; export declare class Engine { private readonly registers; private readonly memory; private readonly channels; private readonly heap; private readonly budget; private readonly machine; private readonly library; private readonly grids; private readonly onUnconfirmed; private readonly alerting; private readonly requests; /** * What this strategy sent and what became of it, `stdlib.md` 17.7. Held by * the run rather than asked of the host, because a host's position row is per * contract and shared: reading it is reading somebody else's trade. */ private readonly ledger; /** * The instrument's session, read once from the record it belongs to. * * Once because the record is read once, at load, and is constant for the * whole run (`host-interface.md` 4.4). A session that changed between bar ten * and bar eleven would anchor the first ten bars of a study to one schedule * and the rest of the same chart to another. */ private readonly sessions; /** * The bars the engine has been given, which a read folds. * * A read of the chart's own instrument at a coarser interval is folded from * these, so the fold needs the bars themselves and not only the registers * derived from them. `run` seeds the whole dataset before bar 0 and `append` * adds one at a time, which is the difference a `"lookahead"` read shows and * the other two modes do not: lookahead reads to the end of the bucket the * chart bar is inside, and on a live feed there is nothing there yet. That is * the mode repainting on history, permanently and by design. */ private readonly known; private supplied; private index; private updates; private started; private previousClose; private lastClose; private facts; private view; private failure; readonly program: CompiledProgram; private readonly inputs; private readonly options; constructor(program: CompiledProgram, inputs: readonly ResolvedInput[], options: LoadOptions, limits: EngineLimits, plans?: readonly RequestPlan[]); /** Whether a failure has stopped this script. A stopped script stays stopped. */ get failed(): boolean; /** How many bars the engine has been given. */ get barCount(): number; /** * A new bar arrives. * * Step 11 of the previous bar happens here rather than at the end of it, * because a checkpoint is taken only if the engine is moving on to the next * bar, and until one arrives the previous bar may still be re-executed. */ append(bar: HostBar, state?: BarState, supplied?: number): BarResult; /** * The newest bar changed, so it runs again. * * Step 1: the checkpoint from the end of the previous bar is restored, except * that `"live"` cells keep their current values, which is the whole of * `live var`. Everything else rolls back, so executing a moving bar ten times * gives the same answer as executing it once. */ update(bar: HostBar, state?: BarState): BarResult; /** * A whole dataset, appended in order. Stops at the first bar that fails. * * The whole set is handed to the fold before bar 0 rather than discovered one * bar at a time. Nothing about a confirmed or a developing read changes: both * stop at the bar being executed, so running a dataset and appending it bar by * bar give the same numbers. A `"lookahead"` read is the one that differs, and * that difference is the mode: it reads to the end of the bucket the chart bar * is inside, which exists in a dataset and does not exist on a live feed. * * A dataset with nothing in it is OS6010 and not an empty result, because a * pane with nothing drawn on it is what a study that computed nothing also * produces and only the engine can tell the two apart. */ run(bars: readonly HostBar[] | BarColumns, states?: readonly BarState[]): RunResult; /** * The dataset a driver appends one bar at a time, handed to the fold before * bar 0 as `run` hands it, so a `"lookahead"` read reads it as history. */ history(bars: readonly HostBar[] | BarColumns): void; /** * A frame from the destination, `host-interface.md` 7.2. Held until the next * bar begins rather than folded where it lands: nothing reaches a running * execution, so every position fact is constant for the length of one and a * moving bar sees what its first execution saw. */ deliver(frame: OrderFrame): void; /** The strategy's own ledger, `stdlib.md` 17.7, oldest row first. */ orders(): readonly LedgerRow[]; private execute; /** * A hand-over the engine refuses, before any of it has been executed. * * Nothing is rolled back because nothing has run: the bar was never begun, * the previous bar's checkpoint still stands, and the columns already * published stay as they are. The script is stopped for the same reason a * failed bar stops it, which is that the next bar would be computed on a * state nobody can account for. */ private refuse; /** A bar that failed: steps 7 to 11 do not run, the journal rolls back, the script stops. */ private stopped; /** Step 11, and the sweep that pays for the objects the bar left behind. */ private checkpoint; private rollback; /** One channel's column over every bar executed so far. */ column(channel: number): readonly Value[]; /** The drawing objects a host should render, in creation order. */ drawings(): readonly Drawing[]; /** The grids and the cells the last executed bar wrote into them. */ tables(): readonly Grid[]; } //# sourceMappingURL=engine.d.ts.map