Repository navigation
Releases: quantmind/troy
Releases · quantmind/troy
Release list
v0.1.3
Square roots, and a rounding strategy on the operations that round.
Added
Dec::sqrt,Dec::checked_sqrtandDec::sqrt_approx.sqrtrounds half
away from zero atDec::SCALEand is the one operation here that cannot
overflow: the largest root the range holds is about1.3e10, so a negative
value and NaN are its only failures, which is whatchecked_sqrtreports as
None.sqrt_approxgoes throughf64for 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 byDec::round_dp_withand
Dec::round_to_step_with:MidpointAwayFromZero,MidpointNearestEven,
ToZero,AwayFromZero,ToNegativeInfinityandToPositiveInfinity. Pass
one where the direction is the exchange's rather than yours:ToZerofor a
quantity filter, the infinity pair for a bid or ask pinned to a tick,
MidpointNearestEvenwhere many rounded values are summed. It derives
DefaultasMidpointAwayFromZeroand serialises under theserdefeature,
so a per-instrument policy stores and restores with the instrument.
Changed
round_dpandround_to_stepare unchanged, and are now defined as the
MidpointAwayFromZerocase of their_withcounterparts.floor,ceil
andtruncare thedp0 cases of the three directed strategies, and say so
in their docs.- The
arithmeticbenchmark is nowdecand carries the roots alongside the
arithmetic, socargo bench --bench arithmeticiscargo bench --bench dec.
make benchis unchanged.docs/bench-data.jsonis re-measured, and the
site's front page hands off to aDecpage 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.
v0.1.2
Added
- The market types serialise under the
serdefeature:PriceAmount,
OrderBookSide,OrderBook,OrderBookTopandOrderBookDiff. A book
snapshot now round trips whole, where before onlyDecdid. OrderBook::is_consistent— every level valid, each side ordered the way its
slot requires, no price held twice, and a spread above zero. A book built
throughsetholds this by construction, so check it on one that arrived
another way: deserialised from a snapshot, or assembled by hand.Displayhonours the format spec. A precision rounds to exactly that many
places, halves away from zero, padded with zeros pastDec::SCALE; width,
fill, alignment,0and+behave as they do on the built-in numeric types.
Bare{}is unchanged, and still compiles to what it did before. The
rounding runs on the digits rather than through aDec, so a carry out of
the range still renders:format!("{:.0}", Dec::MAX)is
170141183460469231732, a numberDeccannot hold andround_dpanswers
withDec::NAN.- A benchmark and docs site at https://troy.quantmind.com, carrying the full
benchmark set, the order book numbers, the digit and depth sweeps and the
design docs.make sitebuilds it,make site-devserves it locally.
Removed
make bench-page, which rendered a single page from the snapshot.make sitebuilds the whole site instead.
v0.1.1
Fixed
- Parser reported
Overflowfor text carrying more significant digits than a
u128holds, even for values well inside the range:1.0written with 43
decimal places, or a float printed as its exact expansion. Surplus digits now
round the last one kept instead of failing the parse.
Added
OrderBook::imbalance—(bid - ask) / (bid + ask)at the touch, in[-1, 1].OrderBook::range_imbalance(from, to)— the same over a half open band of
levels. An empty or inverted band readsNone, not zero.tests/fuzz.rs— proptest properties overDec;make rs-fuzzsweeps wider.tests/fuzz_book.rs— capped-book invariants at 10, 50, 100 and 200 levels.benches/orderbook.rs— book operations by depth;make benchruns it.
Changed
OrderBookSidedrops its runningtotal_amount.amount_meanand
amount_std_devsum on demand,trimbecomes atruncate, and a non-finite
amount can no longer poison a side for good.
v0.1.0
First release: Dec, a fixed-scale decimal backed by an i128 with
Dec::SCALE decimal places, with parsing, formatting, arithmetic, rounding,
and optional serde and rust_decimal support.
Arithmetic is exact over a symmetric finite range of roughly +/-1.7e20.
Anything leaving it becomes Dec::NAN, which propagates through every later
operation so the fault reaches the boundary where Dec::is_finite is checked,
rather than being clamped to a plausible number or raised as a panic on a hot
path. The ordering stays total, so Dec remains usable as a map key and in a
sorted book. See the design module for the reasoning.