Skip to main content

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, Poisson limit/market/cancel flow, bounded mean-reverting fair value, and a light liquidity-state kernel that creates sweep and refill structure without the older heuristic stack.

Overview

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, 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 mid-anchored signed-depth heatmap. Requires capture="visual".
  • plot_heatmap(anchor="mid" | "price"): render a standalone heatmap on 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 y-axes stay in level space rather than real prices.

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.
  • Limit, market, and cancel counts are sampled from Poisson distributions.
  • Event side is driven by fair-value gap, depth imbalance, and recent signed flow.
  • Limit placement mixes inside join/improve, best-level refill, and deeper wall placement.
  • Aggressive flow raises side-specific stress and refill pressure so the heatmap shows asymmetric withdrawal and recovery.

Documentation Assets

Book

Diagnostics

Variants

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:

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

orderwave-0.6.2.tar.gz (18.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

orderwave-0.6.2-py3-none-any.whl (16.9 kB view details)

Uploaded Python 3

File details

Details for the file orderwave-0.6.2.tar.gz.

File metadata

  • Download URL: orderwave-0.6.2.tar.gz
  • Upload date:
  • Size: 18.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for orderwave-0.6.2.tar.gz
Algorithm Hash digest
SHA256 58448561128a7edbe6c47987b5a139fcbc8bbdb1d941810e62bee3d877335138
MD5 2cf5562467a10975b1a5b1d2f86bdad4
BLAKE2b-256 a104d661df84fa3cc850b315ac6dcde1e4de6a00dfa8f7bdd68377394d825dee

See more details on using hashes here.

Provenance

The following attestation bundles were made for orderwave-0.6.2.tar.gz:

Publisher: workflow.yml on smturtle2/quoteflow

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file orderwave-0.6.2-py3-none-any.whl.

File metadata

  • Download URL: orderwave-0.6.2-py3-none-any.whl
  • Upload date:
  • Size: 16.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for orderwave-0.6.2-py3-none-any.whl
Algorithm Hash digest
SHA256 5a663d2ca049e6eb384cdce97299bb1ed7fcff92dfc33f4ab6f356a17b39a826
MD5 34707c3e0d7af615fcb79f851485138a
BLAKE2b-256 0796091e8b9f9fe82f3ab054089a483e60f5b5547d22a474a6d7dc80ada90b27

See more details on using hashes here.

Provenance

The following attestation bundles were made for orderwave-0.6.2-py3-none-any.whl:

Publisher: workflow.yml on smturtle2/quoteflow

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page