Skip to content

trade_aggregation: support 14, nanosecond timestamps and size units, … - #25

Merged
MathisWellmann merged 1 commit into
mainfrom
trade_aggregation-14
Nov 12, 2026
Merged

MathisWellmann merged 1 commit into
mainfrom
trade_aggregation-14

Conversation

@MathisWellmann

Copy link
Copy Markdown
Owner

…0.139.0

trade_aggregation 14 takes the timestamp resolution and the currency of the trade size from the trade type. The old impl left the resolution at its default of milliseconds although the timestamps are in nanoseconds, so the parts of trade_aggregation that read it from the trade (Adaptive, MinDuration, MaxDuration, TimeVelocity) were off by a factor of 10^6.

Trade now implements Timestamped with TimestampResolution::Nanosecond, and TakerTrade with SIZE_UNIT from the currency of its quantity, so By::Base and By::Quote sum base volumes and notionals for linear and inverse contracts. For that, Currency gets a KIND constant (CurrencyKind::Base or ::Quote), which generic code can also use elsewhere.

The From for trade_aggregation::Trade conversion is removed: that type now has millisecond timestamps and quote sizes, so the conversion would lose precision, and a Trade can be aggregated directly.

Breaking (new required Currency constant, removed conversion), so the version is 0.139.0.

…0.139.0

trade_aggregation 14 takes the timestamp resolution and the currency of
the trade size from the trade type. The old impl left the resolution at
its default of milliseconds although the timestamps are in nanoseconds, so
the parts of trade_aggregation that read it from the trade (Adaptive,
MinDuration, MaxDuration, TimeVelocity) were off by a factor of 10^6.

Trade now implements Timestamped with TimestampResolution::Nanosecond, and
TakerTrade with SIZE_UNIT from the currency of its quantity, so By::Base
and By::Quote sum base volumes and notionals for linear and inverse
contracts. For that, Currency gets a KIND constant (CurrencyKind::Base or
::Quote), which generic code can also use elsewhere.

The From<Trade> for trade_aggregation::Trade conversion is removed: that
type now has millisecond timestamps and quote sizes, so the conversion
would lose precision, and a Trade can be aggregated directly.

Breaking (new required Currency constant, removed conversion), so the
version is 0.139.0.
@github-actions

Copy link
Copy Markdown

Summary

PR bumps trade_aggregation 13 → 14, splitting the old TakerTrade into Timestamped (ns resolution) plus TakerTrade with a SIZE_UNIT const derived from a new CurrencyKind::KIND on the Currency trait, and drops the From<Trade> for trade_aggregation::Trade impl.

Issues

  • Blocker — src/trade_aggregation.rs (tests, lines 62–67 and 82–84): the new tests call trade.base_size() and trade.quote_size(), but no definition of either method exists anywhere in the tree (grep for fn base_size|fn quote_size across all .rs files returns no matches, and the diff adds no such impls), so the test module cannot compile. Add base_size()/quote_size() to Trade (side-signed, converting between base and quote via price) or drop those assertions.
  • Major — src/trade_aggregation.rs:34–37: SIZE_UNIT is resolved from CurrencyKind through crate::prelude::* only; CurrencyKind is re-exported from types/mod.rs, and any crate that implements Currency outside this repo (e.g. test doubles or downstream crates) now fails to build because KIND is a new required associated constant. Verify no external Currency impls exist, or give KIND a default to keep the trait extensible.

@MathisWellmann
MathisWellmann merged commit f4ab458 into main Nov 12, 2026
2 checks passed
@MathisWellmann
MathisWellmann deleted the trade_aggregation-14 branch November 12, 2026 15:38
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