From dbe5cea9ae5c4c850069ed5d0cea3904100df205 Mon Sep 17 00:00:00 2001 From: Dominik Roth Date: Sat, 17 Oct 2026 19:03:35 +0200 Subject: [PATCH] sell.py: fix off-by-one in queue-ahead depth A resting order at the same price was posted first and has time priority, so it should count as ahead too (p <= r["price"], not p <). Co-Authored-By: Claude Sonnet 5 --- tools/sell.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/tools/sell.py b/tools/sell.py index a459d10..046b1b9 100755 --- a/tools/sell.py +++ b/tools/sell.py @@ -132,7 +132,9 @@ def main(): cutoff_price = max(recent_prices + [best_ask or 0]) * 1.1 if recent_prices else float("inf") med_vol = med or 1 for r in rows: - ahead = sum(u for p, u in asks if p < r["price"]) + # p <= (not <): a resting order AT the same price was posted first and has time + # priority over yours - it's ahead of you too, not a free pass to the front of the queue. + ahead = sum(u for p, u in asks if p <= r["price"]) # Outside the recent-traded range the queue mechanism doesn't meaningfully apply (no # real evidence that cumulative ahead-quantity, much of it itself unreachable junk # asks, clears at the normal rate) - that means "not a binding constraint" (0), NOT