/** * Rounding, and the one rule that decides every case. * * **Halves go away from zero, never to even.** `stdlib.md` section 8.1 fixes it * there and the reason is legibility: a price rounded for display should agree * with what a trader would write down, and round-half-to-even surprises people * at exactly the values that matter. Fixing it also means two engines cannot * differ by one tick. * * The implementation does not add a half and take the floor. That is the usual * shortcut and it is wrong for the value just below a half, where adding 0.5 * rounds up to the next representable number before the floor ever runs. The * fractional part is compared instead, which has no such case. */ import type { Value } from '../values/index.js'; /** The nearest whole number, halves away from zero. */ export declare function roundHalfAway(x: number): number; /** `round(x)`: to the nearest whole number, halves away from zero. */ export declare function round(x: Value): Value; /** * The scale for a digit count: the nearest binary64 to ten to that power, and * past the last finite power the infinity the power would have been. */ export declare function scaleOf(decimals: number): number; /** * `round(x, decimals)`: to a fixed number of decimals, halves away from zero. * * A digit count is a whole number of zero or more; anything else is OS3004 or * OS4003 before the call reaches here, and absence is the backstop. */ export declare function roundTo(x: Value, decimals: number): Value; /** `floor(x)`: toward negative infinity. */ export declare function floor(x: Value): Value; /** `ceil(x)`: toward positive infinity. */ export declare function ceil(x: Value): Value; /** `trunc(x)`: toward zero. */ export declare function trunc(x: Value): Value; /** `roundToStep(x, step)`: to the nearest multiple of `step`. */ export declare function roundToStep(x: Value, step: Value): Value; /** * `roundToTick(price)`: to the instrument's tick. * * Absent when the host supplied no tick size, rather than the price unrounded. * Returning the input would produce an order price that looks rounded and is * not, which is a defect nothing downstream can see. */ export declare function roundToTick(price: Value, tickSize: Value): Value; //# sourceMappingURL=rounding.d.ts.map