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.
105 lines (98 loc) • 4.32 kB
text/typescript
/**
* # fill — the FillModel seam + SimFillEngine (RUNTIME §6–7)
*
* The judge of the runtime. One seam ({@link FillModel}) returns a calibrated per-assessment
* `pFill`, an expected fill price, and a definite floor `fill?` — never a bare boolean — and
* every plan *and the structural null* cross the same model, so strategies are compared on
* fills, not on fill assumptions (ARCHITECTURE §4). Two implementations bracket the truth:
*
* - {@link StrictCrossV1} — the **floor judge**: fills only on a strict tape cross, at the
* resting price. Conservative by construction (`pFill ∈ {0,1}`).
* - {@link MakerFairV1} — the **ceiling judge**: strict-cross ∪ a hazard of being filled
* while resting at/near `fair`, with hazard **parameters injected as versioned data**
* ({@link MakerFairHazardParams}); the shipped {@link MAKER_FAIR_DEFAULT_HAZARD} is clearly
* labelled uncalibrated.
*
* {@link SimFillEngine} is the pure, time-injected state machine that rests orders, reassesses
* them on book updates, and cash-settles at intrinsic — reporting both the floor outcome and
* the E[$] under `pFill`. Same event sequence ⇒ same outcomes (RUNTIME §0).
*/
export type {
FillModel,
FillOrderView,
FillAssessCtx,
FillAssessment,
FillCalibration,
FillLimit,
FillSupport,
Moneyness,
MakerFairHazardParams,
EpisodeSigmoidParams,
EpisodeSigmoidSide,
} from "./model.ts";
export {
StrictCrossV1,
MakerFairV1,
MakerFairCalV1,
STRICT_CROSS_LIMITS,
MAKER_FAIR_LIMITS,
loadEpisodeSigmoidParams,
MAKER_FAIR_DEFAULT_HAZARD,
makerFairHazard,
strictCross,
isCalibratedSupport,
directionalPfill,
classifyMoneyness,
MONEYNESS_ATM_BAND,
MONEYNESS_DEEP_OTM_FRAC,
SELL_FAR_OTM_CAP,
BUY_FAR_OTM_CROSSING,
} from "./model.ts";
/** The **GuardedIntent** owner (kestrel-vav2, arch-review C1b): the ONE interface concentrating leg
* classification, decision-time spot resolution, and the far-OTM cap decision that the fill model
* consumes — so the BOUNDED-RISK / never-naked property is testable through the enforcing seam. */
export type { GuardedIntent, GuardIntentInput } from "./guarded-intent.ts";
export { guardIntent, guardedIntentOf, guardedPfill } from "./guarded-intent.ts";
/** Per-contract option intrinsic — the single canonical `intrinsic(spot, strike, right)` from
* `src/fair` (pure). The fill seam and settlement read the same function fair prices against
* (RUNTIME §4/§6); it is re-exported here so fill consumers keep one import surface. */
export { intrinsic } from "../fair/index.ts";
export type {
CarriedLot,
FillOrder,
OrderOutcome,
SampledOutcome,
SettleMark,
SettleMarkProvenance,
SettleMarkResolution,
SettleReport,
SimFillEngineOptions,
} from "./engine.ts";
export { SimFillEngine, SETTLE_MARK_STALE_AFTER_MS, EPISODE_REMINT_DT_REF_MS } from "./engine.ts";
/** The instrument-general spot engine (ADR-0017): the equity/crypto sibling of
* {@link SimFillEngine} — matches strict-cross on `instrument` alone and settles
* **mark-to-final-spot** (no strike, no intrinsic-at-expiry). */
export type {
SpotQuote,
SpotFillOrder,
SpotOrderOutcome,
SpotSettleReport,
SpotFillEngineOptions,
} from "./spot.ts";
export { SpotFillEngine, spotStrictCross } from "./spot.ts";
/** The PER-WAKE mark-to-model of held option legs (theta-cell seam b): re-marks a held straddle
* against the tape's own option book at each wake, so standing pat on a bleeding position is
* natively costly. Gated; byte-identical when off. */
export type {
HeldOptionLeg,
WakeMark,
MarkToModelInput,
MarkToModelResult,
} from "./mark-to-model.ts";
export { markHeldLegsPerWake, OPTION_CONTRACT_MULTIPLIER } from "./mark-to-model.ts";
/** The HELD POSITION AS OF THE GRADED BUS (theta-floor owner): concentrates reconstruction + blended
* basis + per-wake marking behind ONE surface whose result decides the theta floor the sim driver folds
* into the graded Blotter — the tested surface decides, not driver glue below an untested private step
* (kestrel-pta5). Gated; `thetaBleed = null` (byte-identical) when off. */
export type { HeldPositionInput, HeldPositionResult } from "./held-position.ts";
export { heldPositionAsOfGradedBus, reconstructHeldOptionLegs } from "./held-position.ts";