/** * One resting order against one bar: did it trade, and at what price. * * **A bar is four prices and no path.** Whether the high came before the low is * not in the data, so every rule here is one that does not need to know, and * the places where knowing would matter are decided against the strategy rather * than guessed in its favour. That is the whole discipline of this file: a * backtest that is generous about fills is a backtest that reports money the * market never offered. * * Three rules, each with the case it exists for: * * - **Touched is not traded through.** A limit resting exactly at the low of a * bar may or may not have been filled: the print happened, somebody was * filled at that price, and whether it was this order depends on a queue no * bar records. The default is that it was not (`limitNeedsThrough`), and a * host that has decided otherwise for its own market says so in the policy. * - **A gap fills at the open, not at the level.** A stop triggered by a bar * that opened beyond it was not filled at its trigger, and a backtest that * says it was is reporting the one price that was never available. The open * is the first price there was. * - **A limit fills at its own price or better, and never worse.** Where the * bar opened already through a limit, the open is the better price and the * fill is there; a limit is never worsened by slippage, because a limit that * is worsened is not a limit. * * A stop limit is both, in one bar and in that order: the trigger has to be * reached and the limit has to be traded through, and where only the trigger is * reached the order becomes a resting limit and waits. */ import type { OrderSide, OrderType } from '../engine/index.js'; import type { FillPolicy } from './settings.js'; import type { RecordedBar } from './record.js'; /** A resting order, as the venue holds one. */ export interface RestingOrder { readonly side: OrderSide; readonly type: OrderType; /** The price a limit may not be worse than, absent on a plain stop. */ readonly limit: number | null; /** The price a stop is triggered at, absent on a plain limit. */ readonly trigger: number | null; } /** What one bar did to one resting order. */ export type RestOutcome = { readonly filled: false; readonly triggered: boolean; } | { readonly filled: true; readonly price: number; /** Whether the price is the bar's open, which is a gap through the level. */ readonly atOpen: boolean; /** Whether slippage applies, which a limit never takes. */ readonly slips: boolean; }; /** * One order against one bar. * * A bar missing any of the four prices decides nothing: an incomplete bar is * not evidence that a level was reached and it is not evidence that it was not. */ export declare function testResting(order: RestingOrder, bar: RecordedBar, policy: FillPolicy): RestOutcome; //# sourceMappingURL=resting.d.ts.map