An order-flow-driven synthetic market simulator.
Project description
orderwave
Order-flow-driven synthetic market simulation for Python, with built-in visualization.
orderwave does not random-walk price directly. It simulates a sparse limit order book, stochastic limit arrivals, marketable flow, cancellations, and inside-spread quote improvement, then lets price emerge from those book changes. The same Market object can also render the path, the current book snapshot, and microstructure diagnostics without extra plotting glue.
English Docs | 한국어 README | 한국어 문서
Why orderwave
- Minimal public entry point:
from orderwave import Market - Price changes only as a consequence of book mechanics
- Hidden fair value biases order flow without directly overwriting price
- Same seed, same path
- Built-in figures for overview, current book, and diagnostics
Installation
pip install orderwave
For local development:
pip install -e .[dev]
Quick Start
from orderwave import Market
market = Market(seed=42, config={"preset": "trend"})
market.gen(steps=1_000)
snapshot = market.get()
history = market.get_history()
events = market.get_event_history()
overview = market.plot()
book = market.plot_book()
diagnostics = market.plot_diagnostics()
print(snapshot["mid_price"], snapshot["best_bid"], snapshot["best_ask"])
print(history.tail())
print(events.tail())
overview.savefig("orderwave-overview.png")
API Surface
| API | Purpose |
|---|---|
step() |
Run one micro-batch and return the latest snapshot |
gen(steps=n) |
Run n micro-batches and return the latest snapshot |
get() |
Return the current snapshot |
get_history() |
Return compact pandas.DataFrame history |
get_event_history() |
Return the applied event log as a pandas.DataFrame |
plot() |
Render price, spread, trade strength, and visible-book heatmap |
plot_book() |
Render the current order book on a real price axis |
plot_diagnostics() |
Render spread, imbalance, volatility, and regime diagnostics |
Advanced configuration is available through orderwave.config.MarketConfig.
Built-in Visualization
All plotting methods return matplotlib.figure.Figure and leave save/show control to the caller.
plot()renders the main overview: price, spread, execution-only trade strength, and signed visible-depth heatmapplot_book()renders the current order book on a real price axisplot_diagnostics()renders spread, imbalance, non-zero absolute-return autocorrelation, and regime diagnostics
The overview heatmap keeps signed depth. Ask liquidity is red, bid liquidity is blue, 0 maps to a light gray midpoint, and missing levels render as blank background instead of black cells.
Presets At A Glance
balanced, trend, and volatile reuse the same public API while shifting spread behavior, flow pressure, cancellation pressure, and hidden fair-price dynamics.
Core Semantics
Market.get() returns a compact dictionary with prices, spread, visible depth, aggressive volume, trade strength, depth imbalance, and regime.
trade_strength is an execution-only signed imbalance. It is computed from an EWMA of realized aggressor buy and sell volume, so quote-only book changes do not move it.
Important distinction:
mid_pricecan move when quotes improve, cancel, or get depletedlast_priceonly changes when a trade actually executes
Core guarantees:
- Price is never random-walked directly
- Quote improvement, best-quote depletion, and market execution are the only price-moving mechanisms
- Visible history starts at
step == 0with the seeded initial book - Applied limit, market, and cancel events are available through
get_event_history() - Aggregate depth is modeled without exposing per-order FIFO complexity in v1
Docs
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.3.0.tar.gz.
File metadata
- Download URL: orderwave-0.3.0.tar.gz
- Upload date:
- Size: 26.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
101592434b7488ec2e4cec0723be349419f196c0723ccf3959fd065268a5e209
|
|
| MD5 |
ed67558219af0d55b8ca3ae9403a18a3
|
|
| BLAKE2b-256 |
08b1dc84abeea6750d34b82fc802c1446d2447b0649fd4944d0333553495a414
|
Provenance
The following attestation bundles were made for orderwave-0.3.0.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.3.0.tar.gz -
Subject digest:
101592434b7488ec2e4cec0723be349419f196c0723ccf3959fd065268a5e209 - Sigstore transparency entry: 1050689176
- Sigstore integration time:
-
Permalink:
smturtle2/quoteflow@e1da8677b99b3ef70af660f4161307f6fff6b51b -
Branch / Tag:
refs/tags/v0.3.0 - Owner: https://github.com/smturtle2
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
workflow.yml@e1da8677b99b3ef70af660f4161307f6fff6b51b -
Trigger Event:
release
-
Statement type:
File details
Details for the file orderwave-0.3.0-py3-none-any.whl.
File metadata
- Download URL: orderwave-0.3.0-py3-none-any.whl
- Upload date:
- Size: 23.6 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 |
cca20ed12b6d1922fed9f24073ba0aefb6145c21c2f94bcc9cf6a1a1cdb00430
|
|
| MD5 |
055f2bdb533229eebc3cd873f1cc8ab5
|
|
| BLAKE2b-256 |
b4770d69fd04a144d17e40a7455620c731e7044a77ae04c35abc22adb2f9ae23
|
Provenance
The following attestation bundles were made for orderwave-0.3.0-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.3.0-py3-none-any.whl -
Subject digest:
cca20ed12b6d1922fed9f24073ba0aefb6145c21c2f94bcc9cf6a1a1cdb00430 - Sigstore transparency entry: 1050689185
- Sigstore integration time:
-
Permalink:
smturtle2/quoteflow@e1da8677b99b3ef70af660f4161307f6fff6b51b -
Branch / Tag:
refs/tags/v0.3.0 - Owner: https://github.com/smturtle2
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
workflow.yml@e1da8677b99b3ef70af660f4161307f6fff6b51b -
Trigger Event:
release
-
Statement type: