back to Trade Master
The proof behind the pitch

Research & methodology

reproduce it · run it on the same seam · read the risk

No black box. Every model in Trade Master is a piece of published quant research, re-implemented from scratch in the Paganini quant library and run through the same tick → strategy → RISK → fill loop your live orders ride. This page names the algorithm, shows the actual output, and is explicit about what is reproduced versus simplified — because a desk that can't read its engine shouldn't trust it.

The gallery — one command, every lineage

vivaldi gallery runs them all on one synthetic tape (calm → turbulent, 800 ticks, canonical fill model, one risk gate). On this liquid, fee-heavy tape most lose — and the demo says so rather than cherry-picking. The point is that each model runs on the same seam and behaves as its theory predicts; real validation is vivaldi prove on real data.

vivaldi gallery
800 ticks (a calm → turbulent synthetic tape), one risk gate in the path:

  regime-aware-optimal-quoting — HMM/HJB regime quoting (Paganini)
    regime_aware_quoter   400 fills (400 maker)   net PnL -34.63   final pos -0.08
  deephedging — RL hedging under frictions (no-trade band)
    friction_hedger       113 fills (113 taker)   net PnL -678.45  final pos 0.62
  optimaltradingml — regime-switching intraday trading
    mean_reversion_taker    4 fills               net PnL -209.58  final pos -0.50
  MT5 "Moving Average" expert advisor
    ma_crossover           10 fills               net PnL +647.45  final pos 0.50
  MT5 "RSI" expert advisor (Wilder)
    rsi_reversion           4 fills               net PnL +112.80  final pos 0.50

1 · Regime-aware optimal quoting (HMM + HJB)

The research

Regime-switching market making that extends Avellaneda–Stoikov: a Gaussian HMM (sticky self-transition priors, EM) labels K = 2–4 regimes from LOB features; a system of coupled HJB equations — one per regime, quadratic value function V_i(q,t) = a_i + b_i·q + c_i·q² solved backward under CARA utility — gives the optimal bid/ask half-spreads; an online Bayesian filter tracks the regime belief in real time. The dissertation's headline: the regime-aware HJB policy beats static A-S out-of-sample.

What Paganini implements

The full stack — GaussianHmm::fit, a QuadraticHjb solver, a RegimeQuoter composing filter + HJB, plus BOCPD change-point, Viterbi, and a vol/drift Kalman. The quoter runs live on the CLI (vivaldi paper --strategy regime) and is authorable as an .aria file that binds the native quantlib.

Read the risk, not the P&L

On a single tape the naive fixed maker shows the highest P&L — a trap: it ends pinned at the position limit, so its P&L is just which way price drifted. Run the same four quoters across 8 random tapes and the truth is in the spread, not the mean:

strategy (8 tapes)mean PnLPnL rangestdevavg |end pos|
fixed (maker)+57.9−113 … +248119.00.97
avellaneda–stoikov−26.8−120 … +5354.60.41
glft−111.3−290 … +78121.71.00
regime HMM+HJB−49.6−51 … −481.20.01

The regime quoter ends flat on every tape (|pos| ≈ 0.01) with a P&L stdev of 1.2 — roughly 100× tighter inventory and risk than the fixed maker. It earns the (here, honestly fee-negative) spread with almost no directional risk, instead of betting the book. That is the risk-controlled spread engine a market-making / clearing desk is paid to run.

Reproduced vs simplified. AS, GLFT and the regime HMM+HJB quoter are all reproduced and run live through the engine. The regime quoter's HJB is solved in a price-normalised frame for numerical stability and the regime-switch rate is capped (the realistic "persistent regimes" case).

2 · Strategies as fast binary plugins

A strategy can be authored three ways — pure .aria DSL (which now reads its own position), a Rust plugin, or a C++ plugin — all on the same seam, all inventory-aware, all running in backtest and live. The same host loader runs Rust and C++ plugins identically.

authoring routefillsnet PnLfinal pos
.aria (pure DSL, reads position)3088+117.80.50 (band)
Rust plugin [inv_skew_as_alpha]1698+70.70.04
C++ plugin [cpp_inv_skew]2243+108.00.01
fixed maker (no inventory)3138−68.71.00 (pins the limit)

A plugin is a decision function: it gets a read-only context (market data + inventory / greeks / P&L) and returns intents — no venue or risk handle, so it cannot bypass risk. Proven by test: a plugin asking for size 1e9 is clamped to the position limit exactly like a native strategy, and a kill-switch halt zeroes its quotes. It's a stable C ABI, zero-alloc and fast — FFI + intent-mapping overhead ≈ 20 ns/tick. The locked demo refuses external plugins by design (loading arbitrary native code would defeat the lockdown — a security property, not a gap).

3 · Portfolio margin — SPAN & SIMM

vivaldi margin --demo prices a cross-margined crypto book two independent ways — CME SPAN (1988, 16-scenario risk array) and ISDA SIMM (2016 framework, δ + vega + curvature) — and checks both cover a parametric 99% 1-day VaR. The methodology doc names every place the implementation simplifies the official spec, because for a margin engine the simplifications are the interesting part.

vivaldi margin --demo
# cross-margined book: 2 linear + 2 option legs (BTC/ETH)

SPAN — CME Standard Portfolio Analysis of Risk (1988), 16-scenario array
    TOTAL SPAN margin:  16224.04

SIMM — ISDA Standard Initial Margin Model (2016, simplified single-class)
    delta 24619.02  +  vega 11834.38  +  curvature 1775.16
    TOTAL SIMM margin:  38228.56

VaR check — parametric 99% 1-day (σ 4.0%/day):  5654.65
    SPAN COVERS VaR   |   SIMM COVERS VaR

What Paganini actually implements

The examples are thin; the library behind them is not. Paganini ships, from scratch and unit-tested:

Market making

Avellaneda–Stoikov, Guéant–Lehalle–Fernández-Tapia (GLFT), Cartea–Jaimungal (alpha-aware), vega-aware options MM, inventory / OFI skew.

Regime

Gaussian HMM (EM, sticky prior, log-space forward–backward), quadratic-ansatz HJB solver, online Bayesian regime filter, BOCPD change-point, Viterbi, vol/drift Kalman.

Hedging

Whalley–Wilmott no-trade band, HJB warm-start hedge policy, backtest_hedge_path, CVaR objective (the deep-hedging training loss).

Execution

Almgren–Chriss, Obizhaeva–Wang (transient impact), VWAP/TWAP, Cartea–Jaimungal optimal-VWAP, Perold implementation-shortfall, cross-impact propagator.

The two market-making quoters are wired all the way to the live CLI (vivaldi paper --strategy as|glft); the regime/HJB, hedging and execution families live in the library and are reproduced in spirit by the small gallery strategies. Where a piece is library-only, the docs say so.