Skip to main content

orderwave

Compact aggregate order-book simulation for Python, with readable built-in heatmaps.

orderwave keeps the runtime model small: a sparse bid/ask book, bounded mean-reverting fair value, and a dynamic distribution-synthesis engine where multiple latent depth distributions change their mass, location, and variance before aggregate liquidity is revealed, canceled, and swept.

Overview

Install

pip install orderwave

Quick Start

from orderwave import Market

market = Market(seed=7, capture="visual")
result = market.run(steps=1_000)

snapshot = result.snapshot
history = result.history
overview = market.plot()
heatmap = market.plot_heatmap()
book = market.plot_book()

Public API

  • Market(...): create a simulator with an initial price, tick size, visible depth, seed, optional MarketConfig, and capture="summary" | "visual".
  • step(): advance one step and return the latest snapshot.
  • gen(steps): run multiple steps and return the latest snapshot.
  • run(steps): return SimulationResult(snapshot=..., history=...).
  • get(): return the current snapshot as a dict.
  • get_history(): return the summary history as a pandas.DataFrame.
  • plot(): render the price path with a stable level-ranked signed-depth heatmap. Requires capture="visual".
  • plot_heatmap(anchor="mid" | "price"): render a standalone heatmap on stable level coordinates. Requires capture="visual".
  • plot_book(): render the current order book.

capture="summary" keeps the fast path lean. capture="visual" stores a fixed signed-depth window around the moving market center so the heatmap can show sweep, void, and refill structure clearly. Heatmap rows are always fixed visible ranks, laid out as ask N ... ask 1 | bid 1 ... bid N, so they do not drift vertically with price.

Snapshot and History

Snapshot fields:

  • step
  • last_price
  • mid_price
  • best_bid
  • best_ask
  • spread
  • bids
  • asks
  • bid_depth
  • ask_depth
  • depth_imbalance
  • buy_aggr_volume
  • sell_aggr_volume
  • fair_price

History columns:

  • step
  • last_price
  • mid_price
  • best_bid
  • best_ask
  • spread
  • bid_depth
  • ask_depth
  • depth_imbalance
  • buy_aggr_volume
  • sell_aggr_volume
  • fair_price

Model

  • Fair price follows a bounded mean-reverting Gaussian process with weak flow coupling.
  • Hidden liquidity evolves as stochastic distributions rather than a hand-written rule tree. Total liquidity, side skew, and side-specific depth components move first, then visible limit/cancel/market flow is sampled from the synthesized distributions through Cox-Poisson style intensities.
  • Visible depth is not rebuilt with symptom-specific rules. Thin-side recovery comes from dynamically synthesized shortage and near-touch distributions rather than hard visible-level floors.
  • Repair is safety-only: it prevents one-sided or crossed books and enforces the spread cap, but it does not cosmetically repad every visible rank.

Realism Profiling

Profile generic microstructure behavior with:

python -m scripts.profile_realism --steps 5000

The profiler reports path balance, spread/impact persistence, flow/return sign agreement, top-rank gap frequency, per-rank depth shape, visible/full-book one-sidedness, near-touch connectivity, and pair-distribution entropy.

Documentation Assets

Book

Diagnostics

Variants

Regenerate the documentation images with:

python -m scripts.render_doc_images

The image renderer now searches for representative seeds that satisfy drift and path-balance acceptance instead of hard-coding one path.

Render the standalone heatmap example with:

python -m examples.plot_market_heatmap --output artifacts/orderwave_heatmap.png

More docs:

Metadata

Release files for orderwave 0.6.8

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for orderwave 0.6.8
File Size Uploaded
orderwave-0.6.8.tar.gz 26.1 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for orderwave 0.6.8
File Interpreter ABI Platform
orderwave-0.6.8-py3-none-any.whl Python 3 none any Details

Total release size: 49.0 kB

Release files / orderwave-0.6.8.tar.gz

Download URL orderwave-0.6.8.tar.gz
Size 26.1 kB
Tags Source
SHA-256 checksum
How to use checksums
841cc3525dd77d0a41cd7949ba02bc8dc4ae558506a2d950b8bc55add1703abd
BLAKE2b-256 checksum
How to use checksums
f39f36200b7fe28c80ed793f66b6ded1d2523bde73291d21f3f572d9ec9c7c1e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.7

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Mar 12, 2026.

Transparency log

Release files / orderwave-0.6.8-py3-none-any.whl

Download URL orderwave-0.6.8-py3-none-any.whl
Size 22.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
5d36244ca8feb05ae999c7ade0f5517600a3f78499f0273c644fa5daa9ac325f
BLAKE2b-256 checksum
How to use checksums
b1c10313bd82e243453b5acbd78d21649c2a2b9c15ce2abcafe29f19495352fe
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.7

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Mar 12, 2026.

Transparency log

Release history Release notifications | RSS feed

This release

0.6.8 This release

2 release files

0.6.7

2 release files

0.6.6

2 release files

0.6.5

2 release files

0.6.4

2 release files

0.6.3

2 release files

0.6.2

2 release files

0.6.1

2 release files

0.6.0

2 release files

0.5.1

2 release files

0.4.16

2 release files

0.4.14

2 release files

0.4.7

2 release files

0.4.4

2 release files

0.4.3

2 release files

0.4.2

2 release files

0.4.1

2 release files

0.4.0

2 release files

0.3.0

2 release files

0.2.0

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page