import type { ChargeSchedule, Contract } from '../accounting/index.js'; import type { Diagnostic } from '../diagnostics/index.js'; import type { Value } from '../engine/index.js'; import type { RunDeclaration } from './declaration.js'; /** The window of the supplied bars a report is about. */ export interface DateRange { /** Inclusive, UTC ms; null means the first bar supplied. */ readonly from: number | null; /** Inclusive; null means the last. */ readonly to: number | null; } /** How a resting order is decided against a bar, and who holds a level. */ export interface FillPolicy { /** A limit fills only when the bar traded through it. */ readonly limitNeedsThrough: boolean; readonly stopFillsAtOpenOnGap: boolean; /** Who holds a bracket's levels; 'destination' until 17.9 exists. */ readonly levels: 'destination' | 'engine'; /** This policy's own revision, so an old record replays as it ran. */ readonly version: number; } /** * How closely two numbers have to agree, and why they are allowed not to. * * Exact by default. A bound that is not zero without a reason beside it is * refused, because a tolerance with no reason is a failed comparison somebody * turned off. The reason a tolerance exists at all is a second implementation, * never this one's own re-run: a rerun of the same record on this engine is * bit-identical or it is a defect. */ export interface Tolerance { readonly abs: number; readonly rel: number; /** Required whenever either bound is non-zero. */ readonly reason: string | null; } /** Everything the host decided about one run. */ export interface BacktestSettings { readonly range: DateRange; readonly contract: Contract; /** Null derives one from the declaration. */ readonly costs: ChargeSchedule | null; readonly fill: FillPolicy; readonly inputs: Readonly>; readonly now: number | null; readonly tolerance: Tolerance; } /** * How a resting order is decided when the host states nothing. * * Conservative on both counts, because a backtest that is wrong is wrong in the * strategy's favour by default: a limit is only filled where the bar traded * through it, so an order resting exactly at the extreme of a bar is not * credited with a fill nobody can prove happened, and a stop that gapped is * filled at the open rather than at its trigger, which is the price a trader * would actually have been given. * * `levels` is `destination` because there is nowhere else for it to be: a * bracket reaches a destination as a protective instruction attached to a tag * and the engine holds no level of its own. The other spelling exists so that a * record made today says which of the two it ran under. * * `version` is this policy's own revision. It travels in the record so that a * run stored before the rules changed replays as it ran rather than being * quietly re-decided under today's. */ export declare const DEFAULT_FILL: FillPolicy; /** Exact, which is what a comparison is until somebody writes down why it is not. */ export declare const EXACT: Tolerance; /** The whole window of whatever bars were supplied. */ export declare const WHOLE_RANGE: DateRange; /** * The settings a run takes when the host states only the contract. * * Every default here is the absence of a choice rather than a choice made on * the host's behalf: the whole of the bars supplied, no schedule, exact * comparison, no inputs overridden and no clock. A host that wants any of it * different says so, and what it said is what the record stores. * * **The contract is the first argument and cannot be in the second.** The * second was `Partial`, which names a `contract` field that * this function then ignored in favour of the positional one: a caller passing * a contract there silently got the other, and a test written that way passed * while proving nothing. Excluding the field makes it a compiler error at the * call rather than a wrong answer at the end of a run. */ export declare function settingsFor(contract: Contract, chosen?: Omit, 'contract'>): BacktestSettings; /** * What a run cannot be carried out under, before its first bar. * * Four questions, and every one of them is a figure nobody could explain * afterwards rather than a tidiness rule: * * - **Two cost models at once**, OS6023. A supplied schedule and a declared * commission describe the same money. Applied together they charge it twice * and applied one at a time they charge whichever an engine preferred, which * is a rule nobody wrote down. * - **A schedule that cannot be evaluated**, OS6021, which `scheduleProblem` * decides, because the schedule is the money layer's and the rule for it is * written once, there. **Whichever schedule the run will be charged under**, * which is the declaration's own when the host supplied none: asking only * about a supplied one left every refusal in the money layer unreachable on * the path almost every run takes. * - **A quantity in a unit this destination cannot fill**, OS6021. A backtest * fills in units and works out no running equity, so a quantity in cash or in * a percentage of equity is one it cannot convert, and a lot needs a lot size * the instrument may not state. * - **A tolerance with a bound and no reason**, OS6021. A comparison allowed to * pass by a margin nobody justified is a failed comparison somebody switched * off, and the reason a tolerance exists at all is a second implementation: * a rerun of one record on this engine is bit-identical or it is a defect. * * Nothing has been computed when this is asked, so a refusal costs one run * rather than a report a reader has to be told to distrust. */ export declare function checkSettings(settings: BacktestSettings, declared: RunDeclaration): Diagnostic | null; //# sourceMappingURL=settings.d.ts.map