Skip to content

v0.1.3

Latest

Choose a tag to compare

@github-actions github-actions released this 06 Sep 08:00
v0.1.3
973ef15

Square roots, and a rounding strategy on the operations that round.

Added

  • Dec::sqrt, Dec::checked_sqrt and Dec::sqrt_approx. sqrt rounds half
    away from zero at Dec::SCALE and is the one operation here that cannot
    overflow: the largest root the range holds is about 1.3e10, so a negative
    value and NaN are its only failures, which is what checked_sqrt reports as
    None. sqrt_approx goes through f64 for about three times the speed,
    accurate to the double's sixteen significant digits rather than to the last
    place; take it where a root feeds a comparison, not where two of them are
    tested equal.
  • RoundingStrategy, taken by Dec::round_dp_with and
    Dec::round_to_step_with: MidpointAwayFromZero, MidpointNearestEven,
    ToZero, AwayFromZero, ToNegativeInfinity and ToPositiveInfinity. Pass
    one where the direction is the exchange's rather than yours: ToZero for a
    quantity filter, the infinity pair for a bid or ask pinned to a tick,
    MidpointNearestEven where many rounded values are summed. It derives
    Default as MidpointAwayFromZero and serialises under the serde feature,
    so a per-instrument policy stores and restores with the instrument.

Changed

  • round_dp and round_to_step are unchanged, and are now defined as the
    MidpointAwayFromZero case of their _with counterparts. floor, ceil
    and trunc are the dp 0 cases of the three directed strategies, and say so
    in their docs.
  • The arithmetic benchmark is now dec and carries the roots alongside the
    arithmetic, so cargo bench --bench arithmetic is cargo bench --bench dec.
    make bench is unchanged. docs/bench-data.json is re-measured, and the
    site's front page hands off to a Dec page for the per-operation numbers.
  • The readme says who writes this crate: every line generated by an AI agent
    under the review of high frequency trading practitioners, and what a
    contribution has to clear before it lands.