Show the recent trade window, not just the last print - #23
Merged
Conversation
The market rail vetoes an order by comparing it to a reference built from the book, the feed, and the last print. On a thin book the last print can be days old and far from where the property actually changes hands, so a single stale outlier silently dominates two healthy live quotes — and nothing in the output let the operator tell an outlier from a genuine repricing. Observed live: a bid was refused as "6.3% above the market reference" where that reference was one print from three days earlier. The orderbook and the feed both quoted materially higher, and the median of recent prints sat between them. The rail was arguably right to ask, but it showed only the number that made it object. Adds to the diagnostic block: * median of the recent window, and its low/high range * the AGE of the last print The window is selected by timestamp rather than array order; the payload is not guaranteed sorted, and taking the first N would summarise arbitrary prints. Trigger semantics are unchanged — this is about giving a human enough to judge, not about loosening the check.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The gap
The market rail builds a reference from the orderbook, the trades feed, and the
last print, then objects if the order is materially worse than it. On a thin book
the last print can be days old and far from where the property actually
changes hands — so one stale outlier silently dominates two healthy live quotes.
Observed live: a bid was refused as "6.3% above the market reference", where that
reference was a single print from three days earlier. The orderbook and the
feed both quoted materially higher, and the median of recent prints sat between
them. The rail was arguably right to ask — but it displayed only the number that
made it object, so there was no way to distinguish a stale outlier from a genuine
repricing without leaving the tool and querying the tape by hand.
The change
The diagnostic block now also shows:
That's enough to tell at a glance that the objection rests on a stale tail rather
than on current pricing.
Trigger semantics are unchanged. This is about giving a human enough context to
judge an override, not about loosening the check — overriding a rail by habit is
how it stops protecting you.
Note on window selection
The window is chosen by timestamp, not array order. The payload is not
guaranteed sorted, so taking the first N would summarise arbitrary prints and
quietly mislead. There's a test pinning this: newest prints appended last must
still be what the median reflects.
Tests
medianover odd / even / empty samplesdescribesurfaces the median and range, reproducing the live case above