How vishaalchandrasekar0203/theory-trade works
Theory Trade is a local operations console for a deterministic high-frequency limit-order execution simulator. The principal workflow is to configure a tagged order and queue/market parameters, optionally calibrate those parameters from public Coinbase L1 data, then start and control a seeded discrete-event episode. The console presents queue position, fills, inventory, event tape, and a deterministic action recommendation with an equation-based explanation. Live calibration is optional and freezes at Start; the market feed does not drive the matching engine. Evidence for unsampled UI and live details is limited to README statements and SOURCE INDEX references.
Main entry points: use-simulation.ts Simulation controller · console.tsx Console shell · policy.ts Action policy · engine.ts Discrete-event engine
Components 23
Operations console
- App entry
app/page.tsx - Console shell
components/console.tsx - Parameter controls
components/controls-panel.tsx - Simulation controller
hooks/use-simulation.ts
Execution model
- Action policy
lib/sim/policy.ts - Closed-form model
lib/sim/formulas.ts - Discrete-event engine
lib/sim/engine.ts - Seeded randomness
lib/sim/rng.ts - Simulation state
lib/sim/types.ts - Recommendation explanation
lib/sim/explain.ts
Live calibration
- Market stream endpoint
app/api/market/route.ts - Feed hub
lib/live/hub.ts - Window estimator
lib/live/estimate.ts - EWMA smoothing
lib/live/ewma.ts - Estimate mapping
lib/live/map.ts
Episode views
- Queue and inventory
components/book-panel.tsx - Directive and equations
components/directive-panel.tsx - Event tape
components/event-tape.tsx - Episode metrics
components/metrics-bar.tsx - Status and controls
components/status-strip.tsx - Model card
components/model-card.tsx
Other components
- Operator
- Coinbase Exchange
Connections 32
- Operator → Parameter controls: sets parameters
components/controls-panel.tsx - App entry → Console shell: renders
app/page.tsx - Console shell → Parameter controls: renders
components/console.tsx - Console shell → Simulation controller: uses state
components/console.tsx - Parameter controls → Simulation controller: updates parameters
components/controls-panel.tsx - Simulation controller → Discrete-event engine: runs episodes
hooks/use-simulation.ts - Simulation controller → Action policy: requests recommendation
hooks/use-simulation.ts - Action policy → Discrete-event engine: checks legal actions
lib/sim/policy.ts - Action policy → Closed-form model: scores actions
lib/sim/policy.ts - Discrete-event engine → Seeded randomness: samples clocks
lib/sim/engine.ts - Discrete-event engine → Simulation state: reads and updates state
lib/sim/engine.ts - Action policy → Simulation state: scores typed state
lib/sim/policy.ts - Recommendation explanation → Action policy: uses policy terms
lib/sim/explain.ts - Simulation controller → Recommendation explanation: builds explanation
- Console shell → Queue and inventory: renders
components/console.tsx - Console shell → Directive and equations: renders
components/console.tsx - Console shell → Event tape: renders
components/console.tsx - Console shell → Episode metrics: renders
components/console.tsx - Console shell → Status and controls: renders
components/console.tsx - Queue and inventory → Simulation controller: reads episode state
components/book-panel.tsx - Directive and equations → Simulation controller: shows recommendation
components/directive-panel.tsx - Directive and equations → Model card: renders model card
components/directive-panel.tsx - Event tape → Simulation controller: reads event tape
components/event-tape.tsx - Operator → Market stream endpoint: enables feed
README.md - Simulation controller → Market stream endpoint: opens event stream
hooks/use-simulation.ts - Market stream endpoint → Feed hub: requests market data
app/api/market/route.ts - Feed hub → Coinbase Exchange: subscribes to L1
README.md - Feed hub → Window estimator: estimates window
lib/live/hub.ts - Feed hub → EWMA smoothing: smooths estimates
lib/live/hub.ts - Simulation controller → Estimate mapping: maps live estimates
- Estimate mapping → Simulation state: creates parameter patch
lib/live/map.ts - Simulation controller → Discrete-event engine: freezes estimates at start
README.md