FlowLab
Market data simulator · Implementation risk

Know what it costs to move, before the capital moves.

FlowLab is an agent-based limit order book simulator. It builds a synthetic market that reacts to your order — so the cost of executing a decision can be measured before the decision is committed.

Method Event-driven, agent-based simulation
Output Order-level synthetic LOB data
Origin MSc thesis, University of Copenhagen
The implementation gap A flat navy line showing the portfolio value assumed at the moment of decision, and a brass line falling away from it showing realized value once the trade is executed into the market. The widening area between them is the implementation gap. Implementation gap Decision value — what the mandate assumed Realized value — after the market absorbed the order Execution horizon Value
Fig. 1 — The implementation gap. Every large decision is priced at a book that no longer exists once the order starts working. FlowLab measures that distance in advance, across many plausible markets rather than the one that happened to occur.
The problem

Existing tools measure value, or measure cost afterwards.
None of them let the market fight back.

Replayed history is a single fixed path: it cannot respond to the order being tested, so any strategy large enough to matter is evaluated against a market that ignores it. Transaction cost analysis is accurate and late. Portfolio risk platforms answer what a book is worth under stress, not whether it can be moved under stress. The unmeasured quantity sits between those three.

ToolWhat it tells youReacts to your order
Historical replay How a strategy would have performed along one path that already happened. No
Post-trade TCA What execution actually cost, once the capital has already moved. After the fact
Portfolio risk platforms What the portfolio is worth under a stressed scenario. Not applicable
FlowLab What it would cost to move the position — across many plausible markets, under conditions you specify. Yes — endogenously

Table 1. FlowLab is complementary to the tools above, not a replacement for them. It occupies the pre-trade, liquidity-facing question the others were not built to answer.

Architecture

A simulated venue, built in layers.

FlowLab is modular by construction: the kernel knows nothing about finance, the exchange knows nothing about strategy, and the agents know nothing about each other except through the book. Every layer can be replaced or extended without touching the rest, and a run is reproducible given a fixed configuration and seed.

Analysis & data pipeline

Reconstructs the full visible book from order-level data, extracts features, and passes simulated and empirical output through identical logic so the two are directly comparable.

LOB reconstructionFeature extractionGymnasium RL environment

Heterogeneous agent layer

Four agent families generate the order flow. Liquidity, trend, and valuation pressure all emerge from their interaction rather than being imposed on the price path.

NoiseMarket makerMomentumFundamental value

Exchange layer

A Nasdaq-like venue with price–time priority matching, order-level event logging, market-data dissemination, and session gating through a market calendar.

Matching engineMBO-style loggingMarket calendar

Simulation kernel

A deterministic discrete-event engine handling time, event scheduling, and message delivery. It contains no financial logic of its own — which is what makes runs reproducible and the layers above interchangeable.

Fig. 2 — Layer structure. Arrows run one way: the kernel schedules, the exchange matches, the agents decide. Supporting machinery feeds the agent layer without privileged access to the book.

The agent layer

Order flow with reasons behind it.

Realistic book dynamics do not come from fitting a price process. They come from participants with different objectives, horizons, and constraints acting on the same venue at once.

Noise

Background flow

Stochastic order submission that keeps the book populated and supplies the uninformed component of trading against which other agents operate.

Market maker

Liquidity provision

Inventory-aware two-sided quoting following an Avellaneda–Stoikov formulation. Quotes widen and skew as inventory accumulates — the mechanism behind depth thinning under stress.

Momentum

Trend following

Reads a shared signal layer — moving averages, RSI, order-flow imbalance — and trades the direction of it, amplifying moves the way real short-horizon flow does.

The novel contribution

Fundamental value agents with path-dependent behaviour

Most agent-based models let a valuation agent trade the same way regardless of what it has already lived through. FlowLab's does not. Each agent carries an internal stress state that updates as the run unfolds, and routes its intentions through an execution desk that paces orders into the book rather than dumping them.

Valuation itself can be driven either by an Ornstein–Uhlenbeck process, for a controlled statistical anchor, or by a point-in-time DCF model, when the question is how a specific real-world input propagates into market behaviour.

  • 01
    Revision shock — the size and direction of a change in the agent's own fair value.
  • 02
    Unrealized loss — pressure accumulated from positions currently underwater.
  • 03
    Portfolio performance — the state of the agent's book as a whole, not position by position.
  • 04
    Market barometer — a market-wide stress reading shared across agents, allowing collective behaviour to tighten.

Fig. 3. Four stress sources feed one internal state, which conditions both willingness to trade and how aggressively the execution desk works an order.

Scenario range

The same trade, across many markets that could have happened.

Because conditions are produced by the agent population rather than drawn from a fixed tape, a single order can be examined against a distribution of market states — including states that have no historical precedent at the venue in question.

Liquidity withdrawal

Market makers pull back and depth thins, so the same order meets a materially different book.

Volatility & spread regimes

Calm, stressed, and crisis-like conditions, configured through agent parameters rather than scripted price paths.

Execution styles

Immediate, VWAP-style, gradual participation, and delayed schedules, compared against identical market conditions.

Order-flow shocks

Sudden shifts in buy or sell intensity, to test how a schedule behaves when flow turns against it mid-execution.

Counterfactual paths

One trade repeated across many independent runs, producing a distribution of outcomes instead of a single realized number.

Note. Scenario construction is configuration, not prediction. FlowLab produces internally consistent markets under stated assumptions; it does not forecast which of them will occur.

Validation

What has been demonstrated, and what has not.

Benchmarked against ABIDES

FlowLab's baseline was compared against the rmsc03 reference configuration of ABIDES, a widely used agent-based market simulator developed within a JPMorgan-affiliated research group. Under comparable settings the simulator reproduces:

  • A continuous, two-sided limit order book
  • An endogenous mid-price driven by agent interaction
  • Near-zero mean returns over the simulation horizon
  • A plausible bid–ask spread

Stated limitations

The current baseline does not yet reproduce volatility clustering — a well-documented feature of real return series. This is expected at this stage of development and is stated plainly rather than worked around.

FlowLab should be read as an extensible foundation for implementation-risk work, not as a finished, fully calibrated model of any particular market. Calibration to a specific venue, asset, and period is engagement work, and the RCGA layer exists to do it.

Nothing here is investment advice, and no simulated result is a forecast.

Where it is used

Questions the simulator is built to answer.

Asset owners & risk functions

  • Pre-trade rebalance and transition stress-testing. Expected cost, stressed cost, and sensitivity to a thinner book — before the mandate is approved.
  • External manager due diligence. Whether a manager's backtest assumes liquidity the market would not have provided, and where capacity breaks down.
  • Liquidity-crisis scenario labs. Governance-facing exercises on whether positions can be exited, not only what they are worth.
  • Post-trade attribution. Separating what the market did from what the execution did, using counterfactual runs.

Quant & execution teams

  • Model validation across many paths. Synthetic order-level data for testing internal models where history offers a single sample.
  • Execution algorithm development. Schedules tested against a book that responds to them, through a Gymnasium-compatible environment.
  • Alpha capacity analysis. The point at which a signal's edge is consumed by the cost of acting on it.
  • Macro-to-microstructure tracing. Using the DCF layer to follow an external input, such as a rate change, into book behaviour.
Provenance & contact

Built as research. Documented like research.

FlowLab began as a master's thesis in mathematical finance and retains that standard of documentation: assumptions stated, methods described, limitations named. We work with institutions on scoped implementation-risk studies, calibration to a specific venue and asset, and evaluation of execution approaches under conditions that have not yet occurred.

If the question in front of you is whether a position can actually be moved — and at what cost — we are glad to discuss it.

contact@flowlab.io
Thesis
FlowLab: A Market Data Simulator
Authors
Benjamin BaadsagerChristian Clasen
Supervisor
Johannes Wiesel
Institution
University of CopenhagenMathematical finance
Data
Nasdaq TotalView-ITCHMSFT, via Databento