kestrel.markets
Version:
A typed, token-efficient language + runtime for agentic trading: agents author bounded plans, the runtime fires them at the tick. CLI + typed library + MCP server.
45 lines • 3.29 kB
TypeScript
/**
* # frame/format — the shared token-cheap formatting primitives (invents no value)
*
* The tiny, PURE display primitives shared by the non-configurable cockpit kernel
* ({@link ./render.ts}) and the catalog body panes ({@link ./pane-catalog.ts}). Extracted here so
* BOTH the kernel and the pane catalog format numbers identically — one definition, never a second
* one that could drift a `—` here from a `—` there.
*
* ## The invariant these live inside (ADR-0009)
* **Invents no value.** An absent/`null`/non-finite value renders as the explicit unknown glyph
* {@link DASH} (`—`), never a guessed default. Layout (padding widths, fixed precision) is computed;
* a *value* never is. No wall clock, no RNG — a byte-stable function of the input.
*/
/** The explicit unknown glyph — an absent/`null` value is shown as unknown, never filled in. */
export declare const DASH = "\u2014";
/** A price/level: integer stays integer, else 2dp. `null`/`undefined` ⇒ `—`. Small numbers by
* construction (prices, strikes) — never epoch-shaped, keeping the date-blind grep clean. */
export declare function px(x: number | null | undefined): string;
/** A fixed-precision number (`prec` dp). Non-finite ⇒ `—` (an unknown is shown as unknown). */
export declare function num(x: number | null | undefined, prec?: number): string;
/** Signed dollars, 2dp (`+120.00`, `-45.00`). `null`/`undefined` ⇒ `—`. */
export declare function money(x: number | null | undefined): string;
/** Signed dollars carrying an EXPLICIT `$` (`-$25.97`, `+$392.00`) — the unmistakable-DOLLARS glyph
* for a running P&L, so a reader can never mistake it for cents (the kestrel-c11 100× mis-scale).
* `null`/`undefined`/non-finite ⇒ `—` (an unknown P&L is shown as unknown, never a fabricated 0). */
export declare function usd(x: number | null | undefined): string;
/** Signed integer with an explicit sign (a signed position qty: `+2`, `-1`). */
export declare function signedInt(n: number): string;
/** A position/order/fill leg is EQUITY/SPOT iff it carries NEITHER a strike NOR a right — the ADR-0017
* spot instrument has neither (an option carries BOTH; a fictional zero-strike is never written). The
* shared predicate the percept branches on so a spot leg renders as `<instrument> shares` WITHOUT any
* option chrome (no `<right>@<strike>`, no `fair` column) — a phantom zero-strike CALL (`0C`, `—null`,
* `—undefined`) is not a real contract and confused a live model (kestrel-orx). One definition, shared
* by the kernel ({@link ./render.ts}) and the pane catalog ({@link ./pane-catalog.ts}), so the spot/option
* boundary can never drift between the two surfaces. Mirrors the engine convention (`orgfacts.legKey`,
* `kernelOf`): BOTH absent ⇒ spot. Invents no value — a pure function of the leg's presence bits. */
export declare function isSpotLeg(leg: {
readonly strike?: number | null;
readonly right?: string | null;
}): boolean;
/** `T-92m to close` — minutes-to-close, relative only. `null` ⇒ `T-— to close`. */
export declare function toClose(min: number | null): string;
/** Right-pad to width (left-aligned text column). */
export declare function pad(s: string, w: number): string;
//# sourceMappingURL=format.d.ts.map