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.

1,148 lines (1,147 loc) 35.7 kB
{ "$generated": { "checkedBy": "tests/docs.card.test.ts", "note": "GENERATED FILE — do not edit by hand.", "regenerate": "bun scripts/gen-card.ts", "renderer": "tests/support/card.ts", "sourceOfTruth": "tests/support/catalog.ts" }, "capabilities": [ { "access": { "surfaces": { "sdk": "available", "text": "available" } }, "evidence": { "tier": "none" }, "examples": [ "doc-buy-the-flush", "doc-comments-roundtrip", "plan-fade-flush", "plan-headline-chase" ], "id": "comments", "receipts": { "source": [ "src/lang/lex.ts", "src/lang/parse.ts", "src/lang/print.ts" ], "test": [ "tests/docs.fences.test.ts", "tests/lang.comments.test.ts" ] }, "runtime": { "note": "Comments carry no executable behavior, but they round-trip byte-identically through parse→print (own-line at the statement's indent; trailing after a single canonical space) — the authored 'why' is never lost (ADR-0033).", "status": "implemented" }, "summary": "`#` to end of line carries the author's thinking so the WHY travels with the strategy. Comments are PRESERVED byte-stably (ADR-0004 / ADR-0033): the lexer captures them as trivia, the printer re-emits them verbatim in canonical position. No runtime semantics by design — reasoning, not behavior.", "syntax": { "status": "supported" }, "title": "Comments (# reasoning)" }, { "access": { "note": "MCP: kestrel.validate returns the refusal as an ok:false ValidateOutcome — the reserved keyword never arms.", "surfaces": { "mcp": "available", "sdk": "available", "text": "available" } }, "evidence": { "tier": "none" }, "examples": [ "doc-reject-atomic" ], "id": "fail-closed-atomic", "receipts": { "source": [ "src/lang/parse.ts" ], "test": [ "tests/docs.fences.test.ts", "tests/lang.parse.test.ts" ] }, "runtime": { "note": "The refusal is enforced at parse time — no unguaranteeable all-or-none ticket reaches the engine.", "status": "implemented" }, "summary": "The atomic keyword is reserved and refused in v1 — a multi-leg ticket may not claim all-or-none fills the runtime cannot guarantee.", "syntax": { "note": "The parser raises KestrelParseError (\"reserved and refused\") on the atomic keyword.", "status": "rejected" }, "title": "Fail closed: atomic is reserved and refused" }, { "access": { "note": "MCP: kestrel.validate returns the refusal as an ok:false ValidateOutcome — the non-positive budget never arms.", "surfaces": { "mcp": "available", "sdk": "available", "text": "available" } }, "evidence": { "tier": "none" }, "examples": [ "doc-reject-budget" ], "id": "fail-closed-budget", "receipts": { "source": [ "src/lang/parse.ts" ], "test": [ "tests/docs.fences.test.ts", "tests/lang.parse.test.ts" ] }, "runtime": { "note": "The refusal is enforced at parse time — bounded risk holds before the engine ever arms.", "status": "implemented" }, "summary": "Bounded risk is a type: a budget must be a positive risk fraction so the position is always defined-risk. A non-positive budget is refused.", "syntax": { "note": "The parser raises KestrelParseError (\"positive risk fraction\") on a non-positive budget.", "status": "rejected" }, "title": "Fail closed: budget is a positive risk fraction" }, { "access": { "note": "MCP: kestrel.validate parses the document and returns the refusal as an ok:false ValidateOutcome — the illegal EXIT never arms.", "surfaces": { "mcp": "available", "sdk": "available", "text": "available" } }, "evidence": { "tier": "none" }, "examples": [ "doc-reject-exit-on-mark" ], "id": "fail-closed-exit-on-mark", "receipts": { "source": [ "src/lang/parse.ts" ], "test": [ "tests/docs.fences.test.ts", "tests/lang.parse.test.ts" ] }, "runtime": { "note": "The refusal is enforced at parse time — the illegal statement never reaches the engine.", "status": "implemented" }, "summary": "A quote is a health signal, never a value: an active EXIT may not condition on the mark (ADR-0005) — spelled as jargon (mid/bid/ask/last) or as the words a written playbook uses (mark/premium). The parser refuses all of them.", "syntax": { "note": "The parser raises KestrelParseError (\"marks lie\") on an EXIT conditioned on a mark — mid/bid/ask/last and their plain-English synonyms mark/premium alike.", "status": "rejected" }, "title": "Fail closed: no EXIT on a mark" }, { "access": { "note": "MCP: kestrel.grade grades finalized Blotter artifacts and returns the Gated<GradeOutcome> verbatim.", "surfaces": { "cli": "available", "mcp": "available", "sdk": "available", "text": "available" } }, "evidence": { "note": "The agent-day-1 practice-tier run was graded mechanically under maker-fair-v1.", "tier": "mechanical" }, "examples": [ "core-grade", "grade-headline-chase", "grade-open-drive", "grammar-skeleton" ], "id": "grade", "receipts": { "source": [ "src/fill/model.ts", "src/grade/index.ts", "src/lang/parse.ts" ], "test": [ "tests/docs.fences.test.ts", "tests/fill.test.ts", "tests/lang.parse.test.ts" ] }, "runtime": { "note": "The fill model and the support-guard contract (bankableEv refuses extrapolated E[$]) exist; the full typed replay grader lands with kestrel-a57.1.", "status": "partial" }, "summary": "An imperative replay of authored statements over recorded sessions under a named, versioned fill model, reporting honest EV.", "syntax": { "status": "supported" }, "title": "Grade statement" }, { "access": { "surfaces": { "sdk": "available", "text": "available" } }, "evidence": { "note": "The frozen-armory VS-null counterfactual was computed in the agent-day-1 practice-tier run.", "tier": "mechanical" }, "examples": [ "core-grade", "grade-headline-chase", "grade-open-drive" ], "id": "grade-counterfactuals", "receipts": { "source": [ "src/grade/index.ts", "src/lang/parse.ts" ], "test": [ "tests/lang.parse.test.ts" ] }, "runtime": { "note": "Counterfactual clauses parse; the frozen-armory (VS null) counterfactual ran mechanically in agent-day-1; full stratified grading lands with kestrel-a57.1.", "status": "partial" }, "summary": "Counterfactuals as syntax — VS ungated (did the gate earn its keep?), VS null (any edge at all?) — and stratified BY dimensions.", "syntax": { "status": "supported" }, "title": "Grade counterfactuals" }, { "access": { "surfaces": { "sdk": "available", "text": "available" } }, "evidence": { "tier": "none" }, "examples": [ "grammar-skeleton" ], "id": "module-imports", "receipts": { "source": [ "src/lang/ast.ts", "src/lang/parse.ts" ], "test": [ "tests/lang.parse.test.ts" ] }, "runtime": { "note": "Cross-document import linking (resolving IMPORT to another document's exports) is not yet implemented; parse/print only.", "status": "none" }, "summary": "Every document is a module; its named statements are importable by other documents (import what you reuse).", "syntax": { "note": "IMPORT / module documents parse and round-trip; the public example is proposed skeleton notation.", "status": "supported" }, "title": "Modules & IMPORT" }, { "access": { "note": "MCP: authored + fired/managed through the incremental Session lifecycle (kestrel.session.open → advance/revise a Plan document → finalize).", "surfaces": { "cli": "available", "mcp": "available", "sdk": "available", "text": "available" } }, "evidence": { "note": "Exercised end-to-end in the agent-day-1 practice-tier run.", "tier": "mechanical" }, "examples": [ "core-plan-fade", "doc-breakout-ladder", "doc-buy-the-flush", "doc-clause-skeleton", "grammar-skeleton", "overview-plan", "plan-fade-flush", "plan-headline-chase", "plan-open-drive" ], "id": "plan", "receipts": { "source": [ "src/engine/plans.ts", "src/lang/ast.ts", "src/lang/parse.ts" ], "test": [ "tests/docs.fences.test.ts", "tests/engine.plans.test.ts", "tests/lang.parse.test.ts" ] }, "runtime": { "note": "PlanEngine drives authored → armed → fired → managing → done with fire-then-inform (RUNTIME §5).", "status": "implemented" }, "summary": "A standing, bounded-risk contingent program: trigger → actions → bracket → invalidation → TTL, fired by the runtime at machine speed while the author is informed in parallel.", "syntax": { "status": "supported" }, "title": "Plan statement" }, { "access": { "note": "MCP: the ARM inventory handshake is applied by the runtime during a kestrel.session lifecycle (across a supersede).", "surfaces": { "cli": "available", "mcp": "available", "sdk": "available", "text": "available" } }, "evidence": { "tier": "none" }, "examples": [ "plan-acquire-open", "plan-manage-adopt" ], "id": "plan-arm", "receipts": { "source": [ "src/engine/plans.ts", "src/lang/parse.ts" ], "test": [ "tests/plan.inventory.test.ts", "tests/session.day-adoption.test.ts", "tests/session.day-arm-footgun.test.ts" ] }, "runtime": { "note": "At the supersede→arm handshake the binding transfers management authority for each genuinely-held leg from the acquisition-halted source to the bound replacement, then promotes a pure adopter (an ARM binding with no fireable entry) armed→managing so its EXIT/TP actually run (RUNTIME §5, kestrel-22j.14/r866).", "status": "implemented" }, "summary": "A replacement plan adopts a superseded plan's held leg with `ARM [basis <px>] foreach held leg`, so it can manage and covered-exit inventory it did not open itself — never naked, never inferred from a matching strike.", "syntax": { "status": "supported" }, "title": "ARM (inventory adoption — the exit escape hatch)" }, { "access": { "note": "MCP: EXIT is evaluated by the runtime during a kestrel.session lifecycle.", "surfaces": { "cli": "available", "mcp": "available", "sdk": "available", "text": "available" } }, "evidence": { "note": "EXIT clauses armed in the agent-day-1 practice-tier run.", "tier": "mechanical" }, "examples": [ "doc-breakout-ladder", "plan-headline-chase", "plan-open-drive" ], "id": "plan-exit", "receipts": { "source": [ "src/engine/plans.ts" ], "test": [ "tests/engine.plans.test.ts" ] }, "runtime": { "note": "EXIT (with esc/STAND retry ordering) runs in the manage phase (RUNTIME §5).", "status": "implemented" }, "summary": "An active out on an underlying trigger (never on option marks) — giveback means the thesis is dead, get out.", "syntax": { "status": "supported" }, "title": "EXIT (active out)" }, { "access": { "note": "MCP: INVALIDATE is enforced by the runtime during a kestrel.session lifecycle.", "surfaces": { "cli": "available", "mcp": "available", "sdk": "available", "text": "available" } }, "evidence": { "tier": "none" }, "examples": [ "core-plan-fade", "plan-fade-flush" ], "id": "plan-invalidate", "receipts": { "source": [ "src/engine/plans.ts" ], "test": [ "tests/engine.plans.test.ts" ] }, "runtime": { "note": "INVALIDATE halts acquisition while filled inventory persists (RUNTIME §5).", "status": "implemented" }, "summary": "Thesis broken: stop adding, ride the bounded remainder — distinct from EXIT, which flattens.", "syntax": { "status": "supported" }, "title": "INVALIDATE (thesis dead)" }, { "access": { "note": "MCP: RELOAD rungs are managed by the runtime during a kestrel.session lifecycle.", "surfaces": { "cli": "available", "mcp": "available", "sdk": "available", "text": "available" } }, "evidence": { "note": "Reload rungs armed in the agent-day-1 practice-tier run.", "tier": "mechanical" }, "examples": [ "doc-breakout-ladder", "plan-fade-flush", "plan-headline-chase" ], "id": "plan-reload", "receipts": { "source": [ "src/engine/plans.ts" ], "test": [ "tests/engine.plans.test.ts" ] }, "runtime": { "note": "Reload rungs re-checked against cumulative budget at every placement (RUNTIME §5).", "status": "implemented" }, "summary": "Add rungs into the thesis on further confirmation — worse price = better entry for a fade; the ladder IS the thesis.", "syntax": { "status": "supported" }, "title": "RELOAD ladder" }, { "access": { "note": "MCP: TP tiers are maintained by the runtime during a kestrel.session lifecycle.", "surfaces": { "cli": "available", "mcp": "available", "sdk": "available", "text": "available" } }, "evidence": { "note": "TP tiers rested in the agent-day-1 practice-tier run.", "tier": "mechanical" }, "examples": [ "doc-breakout-ladder", "doc-buy-the-flush", "plan-fade-flush", "plan-headline-chase", "plan-open-drive" ], "id": "plan-tp", "receipts": { "source": [ "src/engine/plans.ts" ], "test": [ "tests/engine.plans.test.ts" ] }, "runtime": { "note": "TP maintenance runs in the manage phase of every fired plan (RUNTIME §5). The tier threshold is evaluated on fair (the value anchor, kestrel-lic3): with an `@` the sell arms once fair crosses the threshold and rests at the `@` exec anchor; without one it rests at the target-derived price immediately and fills on market crossing.", "status": "implemented" }, "summary": "Take-profit tiers on the position — bank a fraction at a multiple, resting at a value anchor.", "syntax": { "status": "supported" }, "title": "TP (take-profit tiers)" }, { "access": { "surfaces": { "cli": "available", "sdk": "available", "text": "available" } }, "evidence": { "tier": "none" }, "examples": [ "grammar-skeleton" ], "id": "pod-book", "receipts": { "source": [ "src/engine/plans.ts", "src/lang/parse.ts", "src/org/index.ts" ], "test": [ "tests/engine.plans.test.ts", "tests/lang.parse.test.ts" ] }, "runtime": { "note": "Book envelope arbitration and org-tree budget nesting are enforced by the engine; deeper Pod recursion is still narrow.", "status": "implemented" }, "summary": "The recursive org tree — an allocating Pod (PM + envelope) over Books (the only place positions live); budgets nest, authority only narrows.", "syntax": { "note": "Concrete POD/BOOK/RISK statements parse and round-trip; the public example is proposed skeleton notation.", "status": "supported" }, "title": "Pod / Book / Risk org" }, { "access": { "note": "MCP: BOOK anchors parse via kestrel.validate and price orders the runtime places across the kestrel.session lifecycle.", "surfaces": { "cli": "available", "mcp": "available", "sdk": "available", "text": "available" } }, "evidence": { "tier": "none" }, "examples": [ "core-plan-fade", "doc-breakout-ladder", "doc-buy-the-flush", "overview-plan", "plan-fade-flush", "plan-headline-chase", "plan-open-drive" ], "id": "price-book-anchors", "receipts": { "source": [ "src/engine/pricing.ts" ], "test": [ "tests/engine.pricing.test.ts" ] }, "runtime": { "note": "Read off the leg quote; a needed dark side makes the whole line unresolvable (fail-closed, RUNTIME §4).", "status": "implemented" }, "summary": "bid · ask · mid · last · join · improve — queue position, not value; a dark side fails the line closed.", "syntax": { "status": "supported" }, "title": "BOOK price anchors" }, { "access": { "note": "MCP: combinators parse via kestrel.validate and bound the runtime's resting orders across the kestrel.session lifecycle.", "surfaces": { "cli": "available", "mcp": "available", "sdk": "available", "text": "available" } }, "evidence": { "note": "peg/cap bounded the resting orders in the agent-day-1 practice-tier run.", "tier": "mechanical" }, "examples": [ "core-plan-fade", "doc-breakout-ladder", "doc-buy-the-flush", "overview-plan", "plan-fade-flush", "plan-headline-chase", "plan-open-drive" ], "id": "price-combinators", "receipts": { "source": [ "src/engine/pricing.ts" ], "test": [ "tests/engine.pricing.test.ts" ] }, "runtime": { "note": "BUY caps compose tightest, SELL floors compose highest and always include intrinsic; peg reprices on ≥1-tick drift (RUNTIME §4).", "status": "implemented" }, "summary": "Combinators on any anchor: interpolation lean(a,b,x), guards min/max, offsets (fair-3c), tracking peg, bounds cap (buys) / floor (sells ≥ intrinsic), and time escalation esc.", "syntax": { "status": "supported" }, "title": "Price combinators" }, { "access": { "note": "MCP: the runtime resolves VALUE anchors while pricing fills across the kestrel.session lifecycle (kestrel.validate parses them).", "surfaces": { "cli": "available", "mcp": "available", "sdk": "available", "text": "available" } }, "evidence": { "note": "Priced the fills graded in the agent-day-1 practice-tier run.", "tier": "mechanical" }, "examples": [ "core-plan-fade", "doc-breakout-ladder", "doc-buy-the-flush", "overview-plan", "plan-fade-flush", "plan-headline-chase", "plan-open-drive" ], "id": "price-value-anchors", "receipts": { "source": [ "src/engine/pricing.ts", "src/fair/index.ts" ], "test": [ "tests/engine.pricing.test.ts", "tests/fair.test.ts" ] }, "runtime": { "note": "fair = ExecutionFair with receipts; a silent mid is forbidden and every fallback is annotated (RUNTIME §4).", "status": "implemented" }, "summary": "fair · intrinsic · basis — model worth, settle floor, and your own cost; a quote is never a value.", "syntax": { "status": "supported" }, "title": "VALUE price anchors" }, { "access": { "surfaces": { "sdk": "available", "text": "available" } }, "evidence": { "tier": "none" }, "examples": [ "doc-breakout-ladder", "doc-comments-roundtrip" ], "id": "roundtrip", "receipts": { "source": [ "src/lang/parse.ts", "src/lang/print.ts" ], "test": [ "tests/docs.fences.test.ts", "tests/lang.comments.test.ts", "tests/lang.golden.test.ts" ] }, "runtime": { "note": "print ∘ parse is idempotent and canonical; golden fixtures pin the contract.", "status": "implemented" }, "summary": "print(parse(text)) is a byte-stable fixed point; the typed object model is canonical and text is a projection of it (ADR-0004).", "syntax": { "status": "supported" }, "title": "Byte-stable round-trip" }, { "access": { "note": "MCP: WHEN parses via kestrel.validate and the runtime evaluates it across the kestrel.session lifecycle.", "surfaces": { "cli": "available", "mcp": "available", "sdk": "available", "text": "available" } }, "evidence": { "note": "Triggers gated the plans in the agent-day-1 practice-tier run.", "tier": "mechanical" }, "examples": [ "core-plan-fade", "core-wake", "doc-breakout-ladder", "doc-buy-the-flush", "overview-plan", "plan-fade-flush", "plan-headline-chase", "plan-open-drive", "wake-fast-move" ], "id": "trigger-algebra", "receipts": { "source": [ "src/lang/parse.ts", "src/series/trigger.ts" ], "test": [ "tests/engine.plans.test.ts", "tests/series.test.ts" ] }, "runtime": { "note": "Tri-state, causal evaluation with per-trigger edge memory over the series provider (RUNTIME §3).", "status": "implemented" }, "summary": "The shared WHEN expression language — named series × predicates (compare, cross, held, within, velocity) × AND/OR/NOT — used by Wake, Plan, and Grade alike.", "syntax": { "status": "supported" }, "title": "Trigger algebra (WHEN)" }, { "access": { "note": "MCP: USING resolves into each leg at arm through the kestrel.session lifecycle (kestrel.validate parses it).", "surfaces": { "cli": "available", "mcp": "available", "sdk": "available", "text": "available" } }, "evidence": { "note": "USING scoped the plans in the agent-day-1 practice-tier run.", "tier": "mechanical" }, "examples": [ "doc-breakout-ladder", "grammar-skeleton", "plan-headline-chase", "plan-open-drive" ], "id": "using-defaults", "receipts": { "source": [ "src/engine/plans.ts", "src/lang/parse.ts" ], "test": [ "tests/engine.plans.test.ts", "tests/lang.parse.test.ts" ] }, "runtime": { "note": "Defaults resolve into each leg at build/arm; per-leg overrides win.", "status": "implemented" }, "summary": "Scoped signal/exec defaults for a document; any leg may override — composition over repetition.", "syntax": { "status": "supported" }, "title": "USING scoped defaults" }, { "access": { "note": "MCP: the OPEN Frame is delivered by kestrel.session.start (the typed SessionFrame struct verbatim — a Rendering of it is the caller's); a VIEW document is authorable across the session.", "surfaces": { "mcp": "available", "sdk": "available", "text": "available" } }, "evidence": { "tier": "none" }, "examples": [ "frame-view", "grammar-skeleton" ], "id": "view", "receipts": { "source": [ "src/frame/index.ts", "src/lang/parse.ts" ], "test": [ "tests/frame.test.ts", "tests/lang.parse.test.ts" ] }, "runtime": { "note": "The Frame renderer (keyframe + delta) is implemented; wiring a VIEW statement's pane selection into it is not complete.", "status": "partial" }, "summary": "The standing definition of what should be seen — which panes, at what token budget — materialized as a Frame.", "syntax": { "note": "Concrete VIEW statements parse and round-trip (lang.parse; see the frame-view example); the grammar skeleton is proposed notation.", "status": "supported" }, "title": "View statement" }, { "access": { "note": "MCP: a WAKE document is authored via the kestrel.session lifecycle (advance/revise supersede); the runtime emits WAKE informs for fired plans across the session.", "surfaces": { "mcp": "available", "sdk": "available", "text": "available" } }, "evidence": { "tier": "none" }, "examples": [ "core-wake", "grammar-skeleton", "wake-fast-move" ], "id": "wake", "receipts": { "source": [ "src/lang/ast.ts", "src/lang/parse.ts" ], "test": [ "tests/lang.parse.test.ts" ] }, "runtime": { "note": "The runtime emits WAKE informs for fired plans (fire-then-inform); a standalone WAKE subscription scheduler is not yet wired.", "status": "partial" }, "summary": "A standing subscription over the trigger algebra that spends attention (tokens, wakes), never risk; it delivers a View.", "syntax": { "note": "Concrete WAKE statements parse and round-trip (lang.parse; see the core-wake example); the grammar skeleton is proposed notation.", "status": "supported" }, "title": "Wake statement" } ], "catalogHash": "sha256:a3bb213498d602194d155331ae2b5503c14f56416e08bf5648ae70d9ca0e2fa4", "certifiedCohort": 0, "evidenceSource": "docs/results/agent-day-1.md", "languageVersion": "0.4.20", "markdownTokens": 3473, "nonNegotiables": [ { "detail": "a parse escape stands down; an unknown series de-arms with a logged reason — never a silent default.", "rule": "Fail closed" }, { "detail": "a budget is a positive risk fraction (a type); a SELL is floored at intrinsic.", "rule": "Never naked / bounded risk" }, { "detail": "a quote is a health signal, never a value: no active EXIT conditions on the mark — mid/bid/ask/last or the human words mark/premium — and mid is never a price anchor.", "rule": "Marks lie" }, { "detail": "the certified honest-tier cohort is 0; a mechanical (practice) run is never labeled certified.", "rule": "Evidence honesty" }, { "detail": "the typed object model is canonical; `print(parse(text))` is a byte-stable fixed point (ADR-0004).", "rule": "Text is a projection" } ], "objectText": [ { "note": "A Wake spends attention, never risk. Its `when` is the shared trigger algebra as a typed node.", "object": { "kind": "wake", "name": "momentum", "when": { "kind": "cross", "dir": "above", "left": { "kind": "series", "segments": [ { "name": "spot" } ] }, "right": { "kind": "series", "segments": [ { "name": "hod" } ] } } }, "text": "WAKE momentum\n WHEN spot crosses above hod", "title": "Wake — a standing subscription over the trigger algebra" }, { "note": "`VS` counterfactuals and `BY` dimensions are syntax, not config; the object mirrors the text one-for-one.", "object": { "kind": "grade", "by": [ { "kind": "dim-vehicle" } ], "fill": "maker-fair-v1", "over": { "kind": "corpus-range", "from": "2024-01-01", "to": "2024-03-31" }, "subject": { "kind": "grade-subject", "name": "fade", "what": "plan" }, "versus": [ { "kind": "cf-ungated" }, { "kind": "cf-null" } ] }, "text": "GRADE plan fade OVER 2024-01-01..2024-03-31 FILL maker-fair-v1\n VS ungated null\n BY vehicle", "title": "Grade — an imperative replay with counterfactuals" }, { "note": "The printer elides USING-covered qualifiers and normalizes spacing; the object carries the full structure (see card.json).", "object": { "kind": "plan", "budget": { "kind": "budget", "unit": "R", "value": 0.3 }, "clauses": [ { "kind": "do", "legs": [ { "kind": "leg", "qty": 1, "right": "P", "side": "buy", "strike": { "kind": "strike-rel", "steps": -1 } } ], "policy": { "kind": "order-policy", "pricing": "peg" }, "price": { "kind": "lean", "a": { "kind": "anchor", "name": "bid" }, "b": { "kind": "anchor", "name": "fair" }, "x": 0.5 } }, { "kind": "tp", "frac": 0.5, "price": { "kind": "anchor", "name": "fair" }, "target": { "kind": "tp-mult", "mult": 2 } } ], "name": "fade", "ttl": { "kind": "ttl-rel", "dur": { "kind": "duration", "unit": "m", "value": 30 } }, "when": { "kind": "cross", "dir": "below", "left": { "kind": "series", "segments": [ { "name": "spot" } ] }, "right": { "kind": "series", "segments": [ { "name": "vwap" } ] } } }, "text": "PLAN fade budget 0.3R ttl +30m\n WHEN spot crosses below vwap\n DO buy 1 -1 P @ lean(bid, fair, 0.5) peg\n TP 2x frac 0.5 @ fair", "title": "Plan — bounded-risk contingent program (trigger → action → take-profit)" }, { "note": "An equity/spot leg is `buy N shares` — the `shares` marker replaces the strike+right an option leg carries (ADR-0017); the ambient `exec` symbol is the instrument. Omit `shares` and the parser refuses `buy N @ …`, naming both continuations.", "object": { "kind": "plan", "budget": { "kind": "budget", "unit": "R", "value": 0.5 }, "clauses": [ { "kind": "do", "legs": [ { "kind": "equity-leg", "qty": 100, "side": "buy" } ], "price": { "kind": "anchor", "name": "spot" } } ], "name": "accumulate", "ttl": { "kind": "ttl-rel", "dur": { "kind": "duration", "unit": "m", "value": 30 } }, "when": { "kind": "cross", "dir": "above", "left": { "kind": "series", "segments": [ { "name": "spot" } ] }, "right": { "kind": "series", "segments": [ { "name": "vwap" } ] } } }, "text": "PLAN accumulate budget 0.5R ttl +30m\n WHEN spot crosses above vwap\n DO buy 100 shares @ spot", "title": "Plan — an equity ticket (shares, not option strikes)" } ], "rejects": [ { "doctrine": "The parser raises KestrelParseError (\"reserved and refused\") on the atomic keyword.", "id": "fail-closed-atomic" }, { "doctrine": "The parser raises KestrelParseError (\"positive risk fraction\") on a non-positive budget.", "id": "fail-closed-budget" }, { "doctrine": "The parser raises KestrelParseError (\"marks lie\") on an EXIT conditioned on a mark — mid/bid/ask/last and their plain-English synonyms mark/premium alike.", "id": "fail-closed-exit-on-mark" } ], "statementKinds": [ { "kind": "VIEW", "answers": "what should I see? — panes at a token budget, materialized as a Frame" }, { "kind": "WAKE", "answers": "when should I look? — a standing subscription that spends attention, not risk" }, { "kind": "PLAN", "answers": "what may execute? — a bounded-risk contingent program the runtime fires" }, { "kind": "GRADE", "answers": "did it actually work? — an imperative replay reporting honest EV" } ], "surfaces": [ "text", "sdk", "cli", "mcp" ], "tokenBudget": 6000, "tokenizer": "kestrel-card/word-punct-v1" }