UNPKG

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.

39 lines 2.85 kB
/** * # session/sizing — the cockpit's bounded-risk sizing + budget envelopes * * The two pure projections the Simulate driver ({@link import("./simulate.ts")}) layers onto the wake * kernel so a model sizes WITHIN the bounded-risk envelope instead of into a silent fire-time clamp: * - {@link sizingHeadroomOf} — the MAX fillable size the remaining-R budget admits for the exec * instrument, charged at the FULL COST BASIS (ADR-0017: equity `spot × mult`, option `premium × mult`); * - {@link budgetEnvelopeOf} — the remaining-R fraction + the nested plan ⊆ book ⊆ owner envelopes, * carrying the optional {@link SizingHeadroom} when the caller can source the exec price. * * PURE: derivations of the injected budget + price, no wall clock / RNG. Both fail closed — an * unbuildable basis (no live price, a non-finite premium) yields a `null` cap + a note of the cost-basis * rule, never a fabricated per-leg number. */ import type { Budget, BudgetEnvelope, SizingHeadroom } from "../frame/types.ts"; /** The **sizing headroom** (kestrel-m9i.32) — the MAX fillable size the remaining-R budget admits for * the exec instrument, so a model sizes WITHIN the bounded-risk envelope instead of into a SILENT * fire-time clamp. Bounded risk is the FULL COST BASIS (ADR-0017): equity charges `qty × spot × mult` * (mult 1), an option `qty × premium × mult` — so `maxUnits = floor(remainingUsd / basisPerUnit)`. * * Equity/spot (`multiplier === 1`): the per-share basis IS the spot; when spot is a live finite price * the cue is concrete. Option (`multiplier !== 1`): the basis is `premium × mult`; when a near-money * `optionPremium` is supplied the cue is concrete, otherwise the basis is unbuildable — the model * still gets the remaining-$ ceiling + a note of the cost-basis rule (never a fabricated per-leg cap). * PURE: a derivation of the injected budget + price, no wall clock / RNG. */ export declare function sizingHeadroomOf(args: { readonly instrument: string; readonly remainingUsd: number | null; readonly spot: number | null; readonly multiplier: number; readonly optionPremium?: number | null; }): SizingHeadroom; /** The cockpit risk-envelope budget (remaining-R + the nested plan ⊆ book ⊆ owner envelopes) from * the plan-lifecycle {@link Budget}. `remainingR` is the fraction of the session's 1R still uncommitted * (`remaining / total`); the three envelopes are the session's 1R (rUsd IS 1R — a structural config * fact, not an invented value). Carries the optional {@link SizingHeadroom} (the max fillable size the * remaining-R budget admits) when the caller can source the exec price. Pure. */ export declare function budgetEnvelopeOf(budget: Budget | null | undefined, sizing?: SizingHeadroom | null): BudgetEnvelope; //# sourceMappingURL=sizing.d.ts.map