Skip to content

feat: post resting limit orders instead of only taking asks#31

Merged
adamewozniak merged 1 commit into
mainfrom
feat/post-limit-orders
Mar 3, 2026
Merged

feat: post resting limit orders instead of only taking asks#31
adamewozniak merged 1 commit into
mainfrom
feat/post-limit-orders

Conversation

@ten-nex
Copy link
Copy Markdown
Contributor

@ten-nex ten-nex commented Mar 3, 2026

Problem

All bots currently only take from the orderbook — they check for existing asks, and if there are none, they do nothing:

if not orderbook.asks:
    print(f'No asks available')
    return

This creates a deadlock: every bot waits for someone else to post first. The only liquidity comes from the MM, so every trade has the MM as counterparty. No bot-vs-bot crossing happens.

Solution

Change the default price_action_bot to post resting limit orders based on its price signal:

  • Confidence → Price: Bot converts its signal confidence into a limit price (e.g., 60% confidence → bid at 58%, leaving 2% edge)
  • Maker-first: If no matching ask exists, the order rests on the book for other bots to fill against
  • Still takes when profitable: If there's an ask at or below the bot's price, it fills immediately (like before)
  • 10-min expiry: Orders stay on the book for most of the market's life
  • Signal management: Cancels stale orders on signal flip or HOLD, skips re-posting if already has a resting order

Impact

This is the structural fix for bot-vs-bot crossing. When multiple bots post resting orders with different views:

  • Bot A posts YES bid at 58% (thinks BTC goes up)
  • Bot B posts NO bid at 55% (thinks BTC goes down) → equivalent to YES ask at 45%
  • They can cross each other — pure fee revenue, zero MM risk

The MM becomes a backstop, not the primary counterparty for every trade.

Changes the default price_action_bot behavior from taker-only to maker-first:

- Bots now post resting limit orders at prices derived from their confidence signal
- If a matching ask exists at/below the bot's price, it fills immediately (same as before)
- If no matching ask, the order rests on the book for other bots to fill against
- Orders expire after 10 min (most of a 15-min market's life)
- Signal flip detection: cancels stale orders when direction changes
- HOLD signal cancels resting orders (not confident enough to leave on book)
- Skips re-posting if already has a resting order in the same direction

This addresses the empty orderbook deadlock where all bots wait for asks
that never appear. Now bots populate the book, enabling bot-vs-bot crossing
which generates fee revenue without MM exposure.
@adamewozniak adamewozniak merged commit fec8fac into main Mar 3, 2026
5 checks passed
@adamewozniak adamewozniak deleted the feat/post-limit-orders branch March 3, 2026 21:21
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.

2 participants