Skip to content

Options OS documentation

Define a crypto-options trading engine, translate it into specifications, build it with Claude Code or Codex, and verify the implementation. This page documents the construction model, repository structure, commands, libraries, controls and verification procedures included in the private Options OS repository.

Repository setup

Options OS is distributed through a private GitHub repository. Configure GitHub SSH access, then clone the repository:

shell
$git clone git@github.com:LeanOS-Technologies/options-os.git && cd options-os

Start Claude or Codex from the repository root. The coding agent will automatically load the relevant repository instructions from CLAUDE.md or AGENTS.md.

Understand the system

Ask the coding agent to explain how Options OS works:

coding agent prompt
Explain the Options OS system, its architecture, construction model, libraries and development workflow

Or run the /explain-component skill for a structured explanation. In Codex, replace the leading / with $.

Trading engine intent

Options OS supplies four coordinated templates that turn a trading idea into accepted engineering specifications. The trading engine intent captures the trading and operating decisions. The engine, operations and scenario specifications translate that accepted intent into engineering authority.

The engine definition stage is complete only when the trading engine intent and all three engineering specifications have been reviewed and accepted. Implementation begins only after this definition stage closes.

StageSupplied TemplateCompleted artifact
Capture intentTrading engine intentAccepted trading and operating definition
Define meaningEngine specificationAccepted strategy, financial and risk semantics
Define operationOperations specificationAccepted lifecycle, execution, persistence and recovery behaviour
Define evidenceScenario specificationAccepted behavioural cases and verification requirements

The trading engine intent is the upstream source. The three engineering specifications are peer outputs of its translation, and each owns a different part of the engine.

Before starting repository implementation, use a capable web-based reasoning model to work through the supplied template. Attach it together with your trading idea, known strategy rules, operating constraints, existing research or calculations, and any decisions that must remain open.

As of August 2026, the recommended models are:

  • ChatGPT GPT-5.6 Sol - preferred for precision, structured reasoning and consistency across the complete definition
  • Claude web - usable, but currently tends to be more verbose and less precise for this task

This recommendation reflects observed model behaviour and may change as the models change.

Provide the model with the trading engine intent, the trading idea, known strategy rules, known operating constraints, existing research or calculations, and decisions that must remain open. Example:

web agent
Use the attached trading engine intent to define the following
crypto-options trading engine.

Work through every section of the document. Identify missing, ambiguous
or conflicting decisions. Do not invent trading policy to make the
definition appear complete. Mark unresolved decisions explicitly.

Trading idea:
Sell an ETH strangle when implied volatility is high. Keep the position
delta-neutral and exit at 50% profit.

Work iteratively until the template contains the accepted trading and operating decisions. The completed document becomes the authoritative trading engine intent for your engine. Add it to the repository before starting the coding-agent workflow.

Trading engine intent scope

The trading engine intent covers:

  • Trading universe
  • Engine and strategy identity
  • Market idea
  • Observable market behaviour
  • Market, venue and derived inputs
  • Data freshness and quality
  • Setups and signals
  • Candidate selection
  • Option structures
  • Entry and placement policy
  • Position sizing
  • Portfolio allocation
  • Risk and mandates
  • Hedging
  • Exit and settlement
  • Orders and partial fills
  • Engine-instance state
  • Restart and recovery
  • Reconciliation
  • Operator commands
  • Runtime modes
  • Monitoring and evidence

A definition is incomplete when two independent engineers could implement different behaviour from it.

Required separations

The trading engine intent separates the following responsibilities:

LayerResponsibility
StrategySetups, signals, invalidation, candidate selection and strategy state
RiskApprove, reject, clip, halt, defend or reduce
ExecutionConvert accepted intent into deterministic order commands
AdapterTranslate between canonical and venue-native behaviour
BookOwn positions, portfolio state and reconciliation results
RuntimeSchedule and interpret declared behaviour

Risk may override strategy and execution.

Execution may determine how to place an accepted intent. It may not invent strategy logic.

Runtime may schedule declared behaviour. It may not create new business rules.

Venue adapters may translate canonical instructions. They may not redefine the strategy, risk policy or financial meaning of the engine.

Translate intent into engineering specifications

After the trading engine intent has been accepted and added to the repository, use the coding agent to translate it into the three supplied engineering specification templates.

The examples below use Claude Code syntax. In Codex, replace the leading / with $.

coding agent prompt
/translate-trading-intent

Provide the accepted trading engine intent as the source document.

The skill produces:

SpecificationOwns
Engine specificationStrategy meaning, facts, state, decisions, risk, attribution and allowed variation
Operations specificationLifecycles, book state, execution, persistence, recovery, reconciliation, replay and degraded operation
Scenario specificationDecision cases, lifecycle episodes, failures, restart, isolation, performance and runtime evidence

Together, the three specifications define the engine. They are peers and must not duplicate one another’s responsibility.

Related authority remains separate:

  • Venue behaviour is defined in venue specifications.
  • Reusable financial behaviour is defined in library specifications.
  • Infrastructure and provider selection are resolved during architecture and assembly.
  • Generated artifacts represent accepted specifications. They do not redefine them.

The translation must expose missing, ambiguous or contradictory decisions. The coding agent must report implementation-critical gaps and return the trading engine intent for correction. It must not invent trading policy or reinterpret accepted decisions.

Review and accept all three engineering specifications before the build begins.

Building an engine

Building starts only after the trading intent has been translated into accepted engineering specifications. Use the architecture, implementation-contract, planning and execution skills in order.

The examples below use Claude Code syntax. In Codex, replace the leading / with $:

accepted engineering specification
    ↓
/architect-system
    ↓
accepted architecture and assembly decisions
    ↓
/write-buildable-specification
    ↓
implementation-ready specifications
    ↓
/create-implementation-plan
    ↓
dependency-closed execution plan
    ↓
/execute-implementation-plan
    ↓
implementation and verification evidence

Do not skip directly from trading intent to implementation.

1. Define the architecture - /architect-system

Takes the accepted specifications and defines engine boundaries, components and responsibilities, dependency direction, state ownership, effect boundaries, persistence, messaging, runtime topology, venue integration, library selection and assembly bindings. Must preserve the specifications’ meaning rather than reinterpret the strategy.

2. Produce implementation contracts - /write-buildable-specification

Converts accepted engine and architecture decisions into implementation-ready specifications defining required behaviour, inputs/outputs, types and schemas, state transitions, dependencies, failure behaviour, persistence requirements, consumer obligations and acceptance evidence - enough for a coding agent to implement without reconstructing meaning from conversation history.

3. Create the implementation plan - /create-implementation-plan

Divides accepted specifications into dependency-closed execution packets, each identifying specification rules implemented, existing libraries/components to use, files and boundaries that may change, producers and consumers affected, tests and evidence required, completion conditions and dependencies on earlier packets. Organize around complete behaviour, not files or generic phases.

4. Execute the implementation plan - /execute-implementation-plan

Implements accepted packets in dependency order. Each packet must close with implementation, required tests, architecture/invariant checks, specification conformance, recorded command output and remaining blockers. A packet is not complete because expected modules exist - its required behaviour, integration and evidence must exist.

Authority model

Repository authority flows in one direction:

trading engine intent
    ↓
accepted specifications
    ↓
INVARIANTS.md
    ↓
mechanical enforcement policy
    ↓
CLAUDE.md and AGENTS.md
    ↓
hooks, tests and CI
    ↓
implementation and generated evidence

Read authority in this order before changing behaviour:

  1. INVARIANTS.md
  2. PROFILE.md
  3. The applicable specification
  4. The current implementation
  5. Generated code maps and verification evidence

Code is implementation evidence. It is not the source of financial or operational meaning.

When code conflicts with an accepted specification, correct the code.

When a generated artifact conflicts with its source, correct the generator or regenerate the artifact.

When an enforcement rule conflicts with its owning invariant, correct the rule at its source.

Repository map

options-os/
├── .agents/                    shared agent skills
├── .claude/                    Claude Code integration
├── .codex/                     Codex integration
├── .docs/                      operational documentation
├── .legal/                     licence and notices
├── execution/
│   ├── backlog/
│   ├── queued/
│   ├── in-work/
│   ├── done/
│   ├── support/
│   ├── EXECUTION_PROTOCOL.md
│   └── README.md
├── packages/
│   ├── libs/                   reusable libraries
│   ├── adapter-deribit/        Deribit implementation
│   └── ruff.toml
├── specifications/
│   ├── framework/              engine and assembly framework
│   ├── libs/                   library specifications
│   └── README.md
├── tools/
│   ├── codemap/
│   ├── controls/
│   ├── flatten/
│   ├── lint/
│   ├── probes/
│   ├── scraper/
│   └── tree/
├── AGENTS.md
├── CLAUDE.md
├── INVARIANTS.md
├── PROFILE.md
├── Makefile
└── README.md
AreaPurpose
.agents/Shared agent skills
.claude/Claude Code skills, hooks, workflows and configuration
.codex/Codex integration and configuration
.docs/Repository operating instructions
packages/libs/Reusable financial and operational implementations
packages/adapter-deribit/Concrete Deribit adapter
execution/Work registry, execution protocol, directives and verification records
specifications/Authoritative engine, venue, assembly and library contracts
tools/controls/Generated agent controls
tools/lint/Architecture and invariant enforcement
tools/probes/Live venue observations
tools/scraper/Venue-documentation capture
tools/codemap/Generated structural indexes

Software construction model

Reusable code follows the framework construction model:

primitives ← enums ← objects ← algebra ← morphisms ← pipelines ← programs
     ↑          ↑         ↑         ↑          ↑           ↑
     └──────────┴─────────┴─────────┴──────────┴───────────┤
                                                        interpreter → effects
                                                             ↑           ↑
                                                             └── runtime ┘
LayerOwns
PrimitivesConstrained scalar values and identifiers
EnumsClosed alternatives
ObjectsImmutable domain products and sums
AlgebraPure calculations and laws
MorphismsPure transformations
PipelinesNamed compositions of transformations
ProgramsInstructions represented as data
InterpretersExecution of programs through declared capabilities
EffectsNetwork, database, filesystem, clock and mutable state
RuntimeDependency selection, scheduling, supervision and resources

Effects begin at the interpreter boundary.

Financial calculations must remain testable without connecting to a venue, database, clock or filesystem.

Not every package requires every layer. Empty pass-through layers are not permitted.

Agentic layer

The repository supplies four mechanisms for coding-agent work:

ComponentPurpose
SkillsProcedures for one engineering task
WorkflowsCoordinated sequences of skills
HooksControls applied before, during and after agent actions
ToolsPrograms for enforcement, inspection, testing and evidence generation

Skills

Skills cover:

  • Trading-intent translation
  • Buildable specification writing
  • Architecture
  • Implementation planning
  • Plan execution
  • Venue adapters and probes
  • Unit and end-to-end test design
  • Test verification
  • Implementation and financial audits
  • Defect tracing and repair
  • Runtime evidence evaluation

Invoke the skill required by the current task. Do not combine unrelated lifecycle stages into one prompt.

Workflows

Repository workflows coordinate complete engineering activities:

  • build-system
  • change-system
  • correct-defect
  • certify-trading-build
  • release-readiness

Use a workflow when the task crosses several specifications, libraries, adapters or verification stages.

Workflow identifiers retain their repository names even when their target is an engine.

Hooks

Hooks enforce repository rules at session, prompt, tool, edit, configuration-change and stop boundaries.

They reject operations such as:

  • Destructive repository changes
  • Test weakening
  • Failure suppression
  • Unauthorized changes to semantic authority
  • Invalid database access
  • Incomplete work reported as complete

Hooks enforce declared rules. They do not decide which feature or correction should be built.

Assembly and library selection

Assembly requires explicit direction.

Tell the coding agent which existing libraries satisfy each required capability. Point it to their specifications and implementations.

Example:

coding agent prompt
Use the existing quant-greeks library for Greek meaning and exposure
calculation. Do not introduce engine-local Greek types or calculations.

Use quant-cost for fees, spread, slippage, funding and hedge-cost
representation. Do not create another cost model inside the engine.

Use adapter-core as the exchange-integration substrate and
adapter-deribit as the concrete Deribit implementation.

Do not ask the agent to “use the repository where appropriate.” That leaves library selection open to interpretation.

Without explicit bindings, coding agents commonly rebuild capabilities that already exist. This wastes context and implementation time, creates conflicting semantics and produces an engine that is more difficult to verify.

Correcting a duplicated or incorrectly integrated implementation is usually more difficult than building the correct path from the start. Coding agents are weaker at semantic correction across an existing engine than at bounded construction from accepted specifications.

Resolve library, venue and infrastructure bindings before creating the implementation plan.

Working with libraries

The reusable implementation is divided into independently specified Python packages:

CapabilityLibraries
Shared vocabularycanonical, instrument, trading-model, message-bus
Options mathematicsquant-volatility, quant-pricing, quant-greeks, quant-surface
Portfolio economicsquant-portfolio, quant-cost, pnl-algebra
Trading factsprice-facts, market-quality, order-algebra
Decisionsmandate, risk-kernel, hedging
Infrastructureconfig, logger, notification, adapter-core

Each package owns:

  • pyproject.toml
  • Source code
  • Tests
  • A library specification
  • A lifecycle record
  • A generated code map

Run a library test suite from its package directory:

shell
$cd packages/libs/<library> && .venv/bin/python -m pytest tests -q

A library defines reusable facts, calculations, plans or verdicts. It does not define an engine’s trading strategy.

For example, the hedging library may produce a hedge plan. The engine decides when that plan is required and whether it may be executed.

Venue integration

adapter-core defines the shared structure used to integrate an exchange.

The repository includes adapter-deribit, a concrete Deribit implementation.

The adapter boundary covers:

  • Instruments
  • Market data
  • Account state
  • Orders
  • Fills
  • Positions
  • Errors
  • Rate limits
  • Persistence
  • Reconciliation

Venue-native meaning must remain inside the venue specification and adapter.

Engine code consumes canonical facts and commands. It must not depend directly on Deribit payloads or client types.

Venue probes

A probe answers one specific question about a live venue and records the response as JSON.

Run a Deribit probe with:

shell
$python3 -m tools.probes.deribit.code.account --testnet

Probes may require credentials. Mainnet access is blocked unless explicitly confirmed.

Probe results are observations. Interpret them against the venue specification before changing adapter behaviour.

Verification

Run the complete repository gate with:

shell
$pre-commit run --all-files

The gate includes:

  • Ruff
  • Mypy
  • Package test suites
  • Architecture and invariant enforcement
  • Generated-policy validation
  • Claude Code control tests
  • Codex control tests

Run enforcement tests directly:

shell
$python3 -m pytest -q tools/lint/tests

Run control-plane tests directly:

shell
$python3 -m pytest -q tools/controls/tests

A command that did not run is not passing evidence.

A pre-existing failure may be reported as unchanged only when identical baseline and final evidence exists. It must not be reported as passing.

Verification ladder

specifications
    ↓
types and schemas
    ↓
invariants and architecture rules
    ↓
unit and property tests
    ↓
integration and contract tests
    ↓
lifecycle and acceptance scenarios
    ↓
static analysis and quality gates
    ↓
runtime evidence
    ↓
conformance

Different evidence answers different questions:

ArtifactQuestion
Blueprint manifestWhich contracts, providers, bindings and topology were selected?
Contract mapWhich accepted rules must the implementation satisfy?
Readiness resultWhich decisions or capabilities still block implementation?
Code mapWhere is each rule represented in code and tests?
Conformance resultWhich rules are covered, missing, contradictory or unverifiable?

A similarly named module is not proof that a requirement was implemented.

Evidence must preserve the required inputs, units, calculations, state transitions, failure behaviour and invariants.

Context tools

Generate a repository tree:

shell
$make tree DIR=<path>

Generate structural code maps:

shell
$make codemap

Flatten a subsystem into one reviewable document:

shell
$make flatten-libs || make flatten-adapter-core || make flatten-skills || make flatten-hooks || make flatten-lint

Generated trees, flattened views and code maps allow coding artifacts to be transported to a web-based reasoning model for evaluation and audit.

They provide current codebase evidence without requiring the reviewer to infer the repository from conversation history.

Model selection

Use different model capabilities for different stages:

StageRecommended model
Trading engine intentChatGPT GPT-5.6 Sol through the ChatGPT web application
Specification translationStrong coding-agent model
Architecture and assemblyStrong coding-agent model
Buildable specificationsStrong coding-agent model
Implementation planningStrong coding-agent model
Bounded implementationClaude Sonnet or Codex Luna
Financial or semantic auditStrongest available reasoning model
Cross-boundary correctionStrongest available coding-agent model

Use the strongest available model for work that establishes meaning:

  • Trading-intent translation
  • Specification writing
  • Architecture
  • Assembly
  • Cross-engine decisions
  • Financial and semantic audits

Once the specifications, architecture and bindings are accepted, implementation packets can usually be assigned to less expensive models.

Do not move to a less capable implementation model while trading meaning, architecture or assembly decisions remain unresolved.

Implementation quality is bounded by the quality of the accepted definition. A coding agent cannot repair missing trading intent by generating more code.

Coding-agent operating notes

Claude Code and Codex behave differently during long implementation work.

These notes describe observed behaviour. They do not replace repository verification.

Claude Code

Claude Code may over-hedge and push authorized work backwards instead of completing the implementation.

When this happens, ask it to create a factual handoff containing:

  • Current repository state
  • Accepted authority
  • Completed work
  • Remaining work
  • Active blockers
  • Commands already run

End the current session. Start a clean session from the handoff and current repository state.

Use the implementation-directive template to define scope and completion evidence.

Do not continue carrying a long argumentative session. Once the agent develops a persistent incorrect framing, additional correction inside the same context often reinforces it.

If the behaviour continues across clean sessions, inspect the global agent memory and instructions. Remove stale or conflicting entries that push the agent toward obsolete decisions or workflows.

Codex

Codex usually delivers implementation faster, but it may underdeliver against broad instructions.

Keep control of:

  • Exact scope
  • Required existing libraries
  • Affected consumers
  • Required tests
  • Evidence commands
  • Completion criteria

Use bounded execution packets.

Inspect whether each packet implements the complete behaviour rather than only the most visible code path.

Do not accept:

  • A partial implementation reported as complete
  • Tests that cover only the new module
  • Missing consumer integration
  • Unverified persistence or restart behaviour
  • Claims that a command would pass
  • A renamed or wrapped legacy implementation presented as semantic integration

When Codex stops early, return it to the same packet with the missing acceptance rows.

Do not broaden the task or create a new plan unless the accepted specification has changed.

Session recovery

Use a clean session when:

  • The agent repeatedly reopens accepted decisions
  • The conversation is dominated by previous failed attempts
  • The agent argues against the authorized scope
  • Old implementation state is treated as current
  • The agent repeatedly stops before satisfying acceptance criteria
  • Corrections produce more interpretation instead of forward progress

A handoff must describe:

  • Current state
  • Desired state
  • Constraints
  • Remaining work
  • Verification evidence

It should not reproduce the narrative history of the session.

Implementation directive

Use the repository directive template when the next agent needs an exact implementation boundary:

execution/support/templates/_IMPLEMENTATION_DIRECTIVE.md

The directive must state:

  • Accepted specification
  • Baseline
  • Authorized scope
  • Required changes
  • Existing components that must be reused
  • Prohibited changes
  • Required verification
  • Completion conditions

Session cleanup corrects context. It does not authorize changing accepted specifications or bypassing unresolved blockers.

Common rules

  • Complete and accept the trading engine intent before running /translate-trading-intent.
  • Use a capable web-based reasoning model for the initial definition.
  • Run Claude Code or Codex from the repository root.
  • Start engine-definition work in the repository with /translate-trading-intent.
  • Accept the engine, operations and scenario specifications before architecture work.
  • Define architecture and assembly before implementation planning.
  • Point the agent to existing libraries explicitly.
  • Read the applicable specification before changing behaviour.
  • Do not infer financial meaning from implementation alone.
  • Do not add venue-native types to engine code.
  • Do not perform effects inside pure libraries.
  • Do not weaken tests to make a change pass.
  • Do not hand-edit generated policy files.
  • Do not report a verification command as passing unless it ran successfully.
  • Do not begin implementation while required engine decisions remain unresolved.
  • Keep strategy, risk, execution, adapter, book and runtime responsibilities separate.

Explore Options OS