Skip to content

v0.15.0

Choose a tag to compare

@joaquinbejar joaquinbejar released this 30 Sep 11:43
· 58 commits to main since this release
2aca8c9

orderbook-rs v0.15.0

The stop-protection release: elected trailing stops can be bounded by a per-book protection collar (#302). Without a collar, behaviour is unchanged from 0.14.0. It is a breaking release (new public fields, a new CancelReason variant, snapshot format 6); see the migration table in the "What's New in Version 0.15.0" section of src/lib.rs (docs.rs).

[0.15.0] - 2026-09-30

The stop-protection release. Elected trailing stops (#286) can be bounded
by a per-book protection collar (#302): with a collar configured, an
elected stop's child is an immediate-or-cancel limit order at the trailed
stop price minus (sell) or plus (buy) the collar, instead of an unpriced
market order. Without a collar, behaviour is unchanged from 0.14.0.
Breaking: new public fields on OrderBookSnapshotPackage,
ReplayBookConfig and OrderStatus::Triggered, a new
CancelReason::StopProtectionBand variant, and snapshot format 6.

Added

  • Protection collar for elected stop orders (#302). StopProtection
    (try_new(collar), new(NonZeroU128), collar(), limit_price(side, stop), check_tick_size) and OrderBook::set_stop_protection /
    stop_protection. With a collar, an elected trailing stop
    (special_orders) executes as an immediate-or-cancel limit order at
    stop - collar (sell) or stop + collar (buy), stop being its trailed
    stop price at election and the collar an absolute offset in price units
    (like CME protection points, except that the remainder is cancelled,
    not rested: a stop whose band is exhausted leaves its position
    unprotected); nothing rests. A remainder the collar cut (liquidity left
    beyond the limit, including an empty band) ends Cancelled { reason: StopProtectionBand }; one left because the side ran out within the band
    keeps InsufficientLiquidity. OrderStatus::Triggered records the
    child's limit_price. StopProtection is re-exported from the prelude.
    The collar must be a multiple of the
    tick size (InvalidTickSize; a later set_tick_size does not
    re-validate it) and cannot be zero (new
    OrderBookError::InvalidStopProtection, reject code Other(0): a
    configuration error). A band that reaches or passes the representable
    bound (sell collar >= stop, buy stop + collar >= u128::MAX) has the
    bound, 0 / u128::MAX, as its limit. Unset (the default) keeps the 0.14.0 unpriced IOC
    market child. The type is available without special_orders, so
    snapshots and replay configurations are identical in every build.
    ReplayBookConfig::with_stop_protection carries it into replay. The
    pending_stops_hdr bench gains *_collar_* elect and cascade
    scenarios; special_orders_demo shows a collar.

Changed (breaking)

  • Snapshot format 6 (#302). ORDERBOOK_SNAPSHOT_FORMAT_VERSION is 6
    and OrderBookSnapshotPackage::validate reads 2..=6. Packages carry
    stop_protection: Option<StopProtection> (#[serde(default)]),
    written by create_snapshot_package and installed by
    restore_from_snapshot_package (as captured, without the tick-size
    check). The snapshot payload and its checksum are unchanged from
    version 5; config fields are not checksummed, as before.
    • Migration: version-5 packages (0.14.0) keep verifying and restore with
      no collar (covered by a verbatim 0.14.0 fixture); a package below
      version 6 that carries a collar is rejected. A 0.14 reader rejects
      every version-6 package ("Unsupported snapshot version") instead of
      silently dropping the collar, so upgrade readers before writers. A
      zero collar does not deserialize.
  • ReplayBookConfig::stop_protection (#302). New public field; code
    building the struct with an exhaustive literal must set it (or use
    ..Default::default()). ReplayBookConfig::new leaves it None.
  • OrderBookSnapshotPackage::stop_protection (#302). New public
    field; exhaustive literals must set it.
  • CancelReason::StopProtectionBand (#302). New variant, appended
    (bincode index 10, JSON "StopProtectionBand"); exhaustive matches need
    the arm. The collared child's terminal reason when the collar cut its
    sweep; InsufficientLiquidity otherwise.
  • OrderStatus::Triggered::limit_price (#302). New field
    (Option<u128>, #[serde(default)]): the child's collar limit, None
    for a market child. 0.14 JSON decodes with None; bincode Triggered
    payloads do not decode across 0.14 / 0.15. Patterns and literals naming
    every field must add it. Display appends , limit=<price> when set.
    Nothing journaled or on the wire carries OrderStatus (ExecReport
    keeps status code 5).

Known limitations

  • Stop protection collar (#302). A gap of more than one collar through
    a stop's price always consumes the stop with zero fill
    (StopProtectionBand), leaving the position unprotected. The collar
    bounds each child, not the cascade: a ladder of stops spaced one collar
    apart still walks the book k × collar in one call (no cascade depth
    limit or velocity pause). A sell collar that reaches or exceeds the stop
    price (limit 0), or a buy stop + collar that reaches or exceeds
    u128::MAX, does not protect that stop. Replay needs the
    source book's collar, constant over the replayed range. A mismatch is
    not an OutcomeMismatch, and snapshots_match catches it only when it
    changed an outcome (the snapshot does not carry the collar; with no
    election in the range, or coinciding fills, the snapshots match while
    future elections differ): compare the replayed book's
    stop_protection() with the source book's (or the snapshot package's
    stop_protection).