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.
50 lines • 3.41 kB
TypeScript
/**
* # session/vehicle-health — the cockpit routing gate's per-vehicle liquidity read
*
* A vehicle's book at a wake vantage → its {@link VehicleHealth} fingerprint (the MM-pull signal the
* acting agent routes on). Extracted from the Simulate driver ({@link import("./simulate.ts")}) so the
* projection lives beside its own small, testable interface: the driver freezes market time, hands each
* exec vehicle's book in ({@link VehicleBook}), and reads back the date-blind health line the enriched
* cockpit kernel renders.
*
* PURE + injected-time: no wall clock, no RNG. `staleS` is a RELATIVE seconds count (`nowTs − asof_ts`),
* never an absolute time, so the same book + same vantage projects a byte-identical health line — the
* determinism the tracer's replay rides on. FAIL-CLOSED: a dark / one-sided / crossed book projects no
* liquidity (never fabricated), and an equity instrument with no chain book sources its NBBO from the
* SAME spot quote the fill floor executes against ({@link vehicleBookFromSpot}), so HEALTH and PRICING
* can never disagree.
*/
import type { BookState } from "../bus/index.ts";
import type { VehicleHealth } from "../frame/types.ts";
/** One vehicle's book at the wake vantage — the input {@link vehicleHealthOf} projects into a
* {@link VehicleHealth}. `book` is `undefined` when no BOOK has been observed for the vehicle yet
* (a dark vehicle, named-not-hidden). */
export interface VehicleBook {
readonly instrument: string;
readonly book: BookState | undefined;
}
/** Project one vehicle's book into its cockpit {@link VehicleHealth} (the routing gate). A vehicle
* with no observed book is DARK-and-named (never blank); otherwise the MM-pull fingerprint is the
* bid-present rate + two-sidedness, and `staleS` is a RELATIVE duration (a date-blind seconds count,
* `nowTs − asof_ts`), never an absolute time. Pure. */
export declare function vehicleHealthOf(v: VehicleBook, nowTs: number): VehicleHealth;
/** Source an exec vehicle's health book, closing the equity false-dark gap (kestrel-710). `core.books`
* only ever holds the OPTION-CHAIN book; a plain EQUITY instrument has no chain book, so its
* {@link VehicleBook} would be `book:undefined` ⇒ {@link vehicleHealthOf} hard-returns DARK even while
* the SPOT NBBO the fill floor + `exec-fair-quote-v1` execute against is genuinely two-sided.
*
* When a real option book exists it is passed through untouched (the options path is byte-identical).
* Otherwise, when `core.spotFill.currentQuote(instrument)` reports a live NBBO, project a synthetic
* ONE-LEG book from it so HEALTH and PRICING read the SAME source. **Fail-closed**, using the exact
* predicate of {@link import("../fair/index.ts").executionFairSpot}: an absent, one-sided (a `null`
* side), non-finite, or crossed (`ask < bid`) quote projects NO book ⇒ the vehicle stays DARK — never
* fabricate liquidity. Only a genuine two-sided uncrossed quote reports live. Pure + injected-time:
* `asof_ts` is the quote's own event ts (so `staleS = nowTs − asof_ts`), never a wall clock. */
export declare function vehicleBookFromSpot(instrument: string, optionBook: BookState | undefined, spot: {
readonly quote: {
readonly bid: number | null;
readonly ask: number | null;
};
readonly ts: number;
} | undefined): VehicleBook;
//# sourceMappingURL=vehicle-health.d.ts.map