Skip to content

Add single-file market maker bot example#15

Open
WGB5445 wants to merge 8 commits intomainfrom
logan/market-maker-bot-example
Open

Add single-file market maker bot example#15
WGB5445 wants to merge 8 commits intomainfrom
logan/market-maker-bot-example

Conversation

@WGB5445
Copy link
Copy Markdown
Collaborator

@WGB5445 WGB5445 commented Apr 14, 2026

Summary

Add a new single-file market maker bot example under examples/write/market_maker_bot.py.

What is included

  • Inventory-skew quote computation around mid price
  • Basic risk guards (max_inventory, max_margin_usage)
  • Cancel-and-replace quoting cycle
  • Dry-run mode for safe validation
  • CLI flags for market, network, timing, and risk parameters

Why

This keeps the market-maker example self-contained and easy to run with the current Python SDK API surface.

Validation

  • Script compiles and --help runs successfully
  • Formatting and lint adjustments were applied on this branch

Copilot AI review requested due to automatic review settings April 14, 2026 07:31
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds a self-contained, single-file example market maker bot script to demonstrate basic cancel/replace quoting with inventory skew and risk guards using the current Decibel Python SDK APIs.

Changes:

  • Introduces examples/write/market_maker_bot.py implementing a periodic quoting loop (fetch state → cancel existing orders → place post-only bid/ask).
  • Adds CLI/env configuration for market/network/timing and basic risk limits (inventory and margin usage).
  • Implements quote rounding to market tick/lot sizes via SDK utilities.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@WGB5445
Copy link
Copy Markdown
Collaborator Author

WGB5445 commented Apr 14, 2026

Addressed all three review points in commit d52a4f4:

  1. Dry-run cancel path
  • _cancel_market_orders now accepts write: DecibelWriteDex | None.
  • _run_cycle now executes cancel handling when (settings.dry_run or write is not None) and open_order_ids, so dry-run can simulate cancel logs.
  1. Distinguishable quote outcomes
  • Added QuoteStatus and QuoteDecision.
  • _compute_quotes now returns explicit statuses (OK, PAUSE_NO_PRICE, PAUSE_INVENTORY_LIMIT, PAUSE_SIZE_INVALID) instead of overloading None.
  • _run_cycle branches by status, avoiding misleading inventory-limit messages for size/config issues.
  1. Fatal handling for configuration errors
  • Main loop now treats ValueError as fatal config errors, prints fatal config error: ..., and exits with non-zero status (2).

Also added focused tests in tests/test_market_maker_bot.py for:

  • dry-run cancel simulation without write client
  • quote status behavior for size-invalid and inventory-limit cases
  • spread-too-tight ValueError
  • fatal exit path on config ValueError

Validation run locally:

  • ruff check (targeted files)
  • ruff format --check
  • pytest tests/test_market_maker_bot.py tests/abi/test_registry.py

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 2 out of 2 changed files in this pull request and generated no new comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@WGB5445 WGB5445 requested a review from gregnazario April 14, 2026 10:53
Copy link
Copy Markdown
Collaborator

@gregnazario gregnazario left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems fine, let's add documentation (saying what it does, since it is an example)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants