Skip to main content

An order-flow-driven synthetic market simulator.

Project description

orderwave

PyPI version Python versions Release workflow

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 | 한국어 문서

orderwave overview

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()
figure = market.plot()

print(snapshot["mid_price"], snapshot["best_bid"], snapshot["best_ask"])
print(history.tail())

figure.savefig("orderwave-overview.png")

Public API

from orderwave import Market

market = Market(
    init_price=100.0,
    tick_size=0.01,
    levels=5,
    seed=42,
    config={"preset": "balanced"},
)
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
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

Market.plot() is the default overview figure. It combines the quote-driven path, last-trade path, trade strength, and a signed visible-depth heatmap.

market = Market(seed=42)
market.gen(steps=1_000)

overview = market.plot()
book = market.plot_book()
diagnostics = market.plot_diagnostics()

Overview

orderwave overview

Current Book Snapshot

orderwave current book

Diagnostics

orderwave 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

orderwave presets

balanced, trend, and volatile reuse the same public API while shifting spread behavior, flow pressure, cancellation pressure, and hidden fair-price dynamics.

Snapshot Semantics

Market.get() returns a compact dictionary with prices, spread, visible depth, aggressive volume, trade strength, depth imbalance, and regime.

Important distinction:

  • mid_price can move when quotes improve, cancel, or get depleted
  • last_price only changes when a trade actually executes

Docs

Design 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 == 0 with the seeded initial book
  • Aggregate depth is modeled without exposing per-order FIFO complexity in v1

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.2.0.tar.gz (23.9 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.2.0-py3-none-any.whl (22.3 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for orderwave-0.2.0.tar.gz
Algorithm Hash digest
SHA256 1ae9f22954c582ecaa06a19b464a90ccd01f898c39a4dcc99236379ff97e7567
MD5 2aadd757de2bef729135ea4409fab4e8
BLAKE2b-256 49fc8f1f2815687d0dd023822230e195bb8b1d1fe77566fa664198d34b69ad1a

See more details on using hashes here.

Provenance

The following attestation bundles were made for orderwave-0.2.0.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.2.0-py3-none-any.whl.

File metadata

  • Download URL: orderwave-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 22.3 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.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 5eba69eb75b68ef7e31758d78e34a9d629a8dcf8ab54a7817345dd1704abb014
MD5 c81b76ab3ca48d7d262ae85dae206974
BLAKE2b-256 6114ae9a106ad13fdac7a82bb95ba5debd174236c8fde37fad5fb8a60f9ce46b

See more details on using hashes here.

Provenance

The following attestation bundles were made for orderwave-0.2.0-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