Skip to content

14.1: aggregator improvements - #25

Merged
MathisWellmann merged 5 commits into
mainfrom
improvements
Nov 12, 2026
Merged

MathisWellmann merged 5 commits into
mainfrom
improvements

Conversation

@MathisWellmann

Copy link
Copy Markdown
Owner
  • components: bipower variation and quarticity act on market events
  • aggregator: start the seq of the candles at a given number
  • aggregator: report events out of time order as an error
  • tests: save and restore the aggregator with bincode and real prices

BipowerVariation and RealizedQuarticity took any TakerTrade, while every
other trade component takes AsTrade events. So a candle over
MarketEvent<T, Q> with them did not compile, and a fused trade and quote
candle could not hold the jump-robust volatility estimates. They now skip
quotes like RealizedVariance does. Every TakerTrade is AsTrade, so plain
trade candles keep working.
seq counts the candles from the start of an aggregator. A process that
continues a series without the saved aggregator, e.g. after the loss of
its checkpoint, restarted the numbers at 0. A store that removes
duplicates by (series, rule, seq) would then replace old candles with new
ones. with_next_seq continues the numbers. It must be called before the
first event, so the numbers cannot skip or repeat. The docs say that only
a restored aggregator also keeps the rule state, and that a fresh one
matches the old candles only from a point that does not depend on the
past, e.g. the start of an aligned period.
update and advance_to panic on an event or a watermark earlier than the
latest time. In a live process that serves many symbols, one late event
then stops all of them, and after a restart the same event can stop the
process again. try_update and try_advance_to return OutOfOrder instead
and change nothing, so the caller can drop or log the event.
latest_timestamp lets the caller check the order itself. OutOfOrder is a
type of its own, because Error is not non_exhaustive and a new variant
would break exhaustive matches.
The restart test saved the aggregator as JSON and used prices such as
117.0. serde_json without float_roundtrip parses some prices 1 ulp off,
and the restored aggregator then closes other candles. Short decimal
prices hid this; a probe with a random walk price showed it. The test now
saves with bincode, which stores every f64 exactly, compares the bars
byte for byte, uses a random walk price with varied sizes, and covers
more components with f64 state, also a candle of trades and quotes.
With plain JSON both restart tests now fail. The README says to save
the state in an exact format.
@MathisWellmann MathisWellmann changed the title aggregator improvements 14.1: aggregator improvements Nov 12, 2026
@MathisWellmann
MathisWellmann merged commit 01121e8 into main Nov 12, 2026
1 check passed
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.

1 participant