Skip to content

Architecture

Crate structure

crates/
├── cli/           # bin crate - the matchstick binary
├── core-types/    # foundation types, no external deps beyond serde/chrono
├── indicators/    # technical analysis calculations
├── orders/        # order lifecycle management
├── risk/          # position sizing and risk limits
├── strategy/      # strategy configuration and metrics
├── watchlist/     # watchlist types + formula DSL (pest)
└── render/        # table rendering (ASCII + JSON)

Dependency graph

core-types  (standalone)
├── indicators
├── orders
├── risk
├── strategy

watchlist  (standalone, contains formula DSL)
└── render

cli  (depends on all above + clap + colored + tokio)

Library crates depend only on core-types or watchlist. They do not depend on each other (except render -> watchlist). The cli crate assembles everything.

Key types

core-types

TypePurpose
MarketTickSingle price update with bid/ask
OhlcvBarCandlestick bar with VWAP
PositionOpen position with P&L tracking
TimeframeBar duration (Tick through Month)
TradingError13 error variants

indicators

TypePurpose
IndicatorEngineCalculation engine with 5-minute cache
IndicatorRequestWhat to calculate (type, symbol, period)
IndicatorResultComputed values with metadata

orders

TypePurpose
OrderManagerMulti-order tracking
OrderFull order with fills and state machine
OrderFillExecution details

risk

TypePurpose
RiskManagerPortfolio-level validation
PositionSizer4 sizing methods
RiskLimitsConfigurable constraints

strategy

TypePurpose
StrategyManagerMulti-strategy orchestration
StrategyConfigName, symbols, timeframe, capital
StrategyMetricsWin rate, Sharpe, drawdown

watchlist

TypePurpose
WatchlistContainer for symbols and columns
CustomColumnFormula-driven computed column
ExprFormula AST node

Design patterns

  • Epsilon comparisons: Floating-point safety throughout (1e-8)
  • State machines: Order and strategy lifecycle validation
  • Builder patterns: OrderRequest, StrategyConfig, RiskLimits
  • Capability tokens: OrderRef with UUID-based access control

Built for traders who value data provenance.