A compact aggregate order-book market simulator.
Project description
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 regime-aware queue-reactive liquidity kernel that drives buy/sell flow clustering, side-specific cancel pressure, refill lag, execution episodes, and gap recovery without reintroducing the older heuristic stack.
Install
pip install orderwave
Quick Start
from orderwave import Market
market = Market(seed=42, capture="visual")
result = market.run(steps=1_000)
snapshot = result.snapshot
history = result.history
overview = market.plot()
heatmap = market.plot_heatmap(anchor="price")
book = market.plot_book()
Public API
Market(...): create a simulator with an initial price, tick size, visible depth, seed, optionalMarketConfig, andcapture="summary" | "visual".step(): advance one step and return the latest snapshot.gen(steps): run multiple steps and return the latest snapshot.run(steps): returnSimulationResult(snapshot=..., history=...).get(): return the current snapshot as adict.get_history(): return the summary history as apandas.DataFrame.plot(): render the price path with a stable level-ranked signed-depth heatmap. Requirescapture="visual".plot_heatmap(anchor="mid" | "price"): render a standalone heatmap on stable level coordinates. Requirescapture="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:
steplast_pricemid_pricebest_bidbest_askspreadbidsasksbid_depthask_depthdepth_imbalancebuy_aggr_volumesell_aggr_volumefair_price
History columns:
steplast_pricemid_pricebest_bidbest_askspreadbid_depthask_depthdepth_imbalancebuy_aggr_volumesell_aggr_volumefair_price
Model
- Fair price follows a bounded mean-reverting Gaussian process with short-memory flow feedback.
- Buy/sell market flow, bid/ask cancel flow, and bid/ask limit flow all use state-dependent Poisson intensities rather than one shared shuffled event pool.
- The internal kernel tracks buy/sell flow impulse, side-specific cancel pressure, side-specific refill lag, gap pressure, hidden liquidity regime, and persistent execution pressure.
- Limit placement is split into join, touch refill, gap fill, connected shelf, and isolated wall families so the book can hold holes and recover instead of being perfectly refilled every step.
- Repair is safety-only: it prevents one-sided or crossed books, but it no longer backfills every visible level.
Realism Profiling
Profile generic microstructure behavior with:
python -m scripts.profile_realism --steps 5000
The profiler reports spread/impact persistence, trade-sign autocorrelation, top-rank gap frequency, per-rank depth shape, shock-side cancel/refill skew, hidden regime occupancy, and connected-vs-isolated deep liquidity structure.
Documentation Assets
Regenerate the documentation images with:
python -m scripts.render_doc_images
Render the standalone heatmap example with:
python -m examples.plot_market_heatmap --output artifacts/orderwave_heatmap.png
More docs:
- English: docs/en/README.md
- Korean: README.ko.md
- Release process: docs/en/releasing.md
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file orderwave-0.6.5.tar.gz.
File metadata
- Download URL: orderwave-0.6.5.tar.gz
- Upload date:
- Size: 28.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9ae12e70f443020fcf050506a908889233121c2f8fecad0f12da57484f5d701f
|
|
| MD5 |
f187e36fb9cedb43a965f351d14f737c
|
|
| BLAKE2b-256 |
90c7e5c809fb43c8e1f50fd49d81502e6d0518fae97d577fd8385355e4dfbbec
|
Provenance
The following attestation bundles were made for orderwave-0.6.5.tar.gz:
Publisher:
workflow.yml on smturtle2/quoteflow
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
orderwave-0.6.5.tar.gz -
Subject digest:
9ae12e70f443020fcf050506a908889233121c2f8fecad0f12da57484f5d701f - Sigstore transparency entry: 1090302833
- Sigstore integration time:
-
Permalink:
smturtle2/quoteflow@a09b156919cc80de3c3de49b8c046bb7216c40bb -
Branch / Tag:
refs/tags/v0.6.5 - Owner: https://github.com/smturtle2
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
workflow.yml@a09b156919cc80de3c3de49b8c046bb7216c40bb -
Trigger Event:
release
-
Statement type:
File details
Details for the file orderwave-0.6.5-py3-none-any.whl.
File metadata
- Download URL: orderwave-0.6.5-py3-none-any.whl
- Upload date:
- Size: 25.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
33f45f4244c70f83e41f1858d3d68dd74a71a9fb26c5694ab06e62c1b240d161
|
|
| MD5 |
fe49be430ead6a8bab7823eebe50a8da
|
|
| BLAKE2b-256 |
3612ba79326284822145e469c0bf63666b06ccd14aeb55486fedded7e0f851ad
|
Provenance
The following attestation bundles were made for orderwave-0.6.5-py3-none-any.whl:
Publisher:
workflow.yml on smturtle2/quoteflow
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
orderwave-0.6.5-py3-none-any.whl -
Subject digest:
33f45f4244c70f83e41f1858d3d68dd74a71a9fb26c5694ab06e62c1b240d161 - Sigstore transparency entry: 1090302857
- Sigstore integration time:
-
Permalink:
smturtle2/quoteflow@a09b156919cc80de3c3de49b8c046bb7216c40bb -
Branch / Tag:
refs/tags/v0.6.5 - Owner: https://github.com/smturtle2
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
workflow.yml@a09b156919cc80de3c3de49b8c046bb7216c40bb -
Trigger Event:
release
-
Statement type: