Class HftSor

java.lang.Object
com.quantfinlib.execution.HftSor

public final class HftSor extends Object
Hot-lane smart order router: the zero-allocation sibling of SmartOrderRouter, for when the routing decision sits on the tick-to-order path. Venue state lives in parallel primitive arrays (updated in place from your per-venue feeds — plug in marketdata.Nbbo venue quotes directly); a route decision is a greedy sweep by all-in price with no sorting, no lists, no boxing.

Fees are expressed in ticks (venue taker fee converted at the instrument's tick size, once, at configuration time), so the comparison stays in integer-friendly arithmetic. Negative fee ticks model rebates. With the handful of venues real equities routing faces, the O(V²) selection sweep is faster than any heap — and allocates nothing.

Single-writer; reuse one router per routing thread.

  • Constructor Summary

    Constructors
    Constructor
    Description
    HftSor(int venueCount)
     
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    fee(int venue, double takerFeeTicks)
    Per-venue taker fee in ticks (negative = rebate).
    long
    route(Side side, long quantity, int limitTick, long[] outQty)
    Routes a marketable order across venues by best all-in price (quote ± fee), splitting at displayed size.
    long
     
    int
     
    void
    venueDown(int venue)
    Removes a venue from routing (feed loss / venue halt) — the symmetric call to Nbbo.onVenueDown, so a dead venue's stale quote can never keep receiving child orders.
    void
    venueQuote(int venue, int bid, long bidSz, int ask, long askSz)
    One venue's displayed top of book (zero size = side unavailable).

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • HftSor

      public HftSor(int venueCount)
  • Method Details

    • fee

      public void fee(int venue, double takerFeeTicks)
      Per-venue taker fee in ticks (negative = rebate). Configure once.
    • venueQuote

      public void venueQuote(int venue, int bid, long bidSz, int ask, long askSz)
      One venue's displayed top of book (zero size = side unavailable).
    • venueDown

      public void venueDown(int venue)
      Removes a venue from routing (feed loss / venue halt) — the symmetric call to Nbbo.onVenueDown, so a dead venue's stale quote can never keep receiving child orders.
    • route

      public long route(Side side, long quantity, int limitTick, long[] outQty)
      Routes a marketable order across venues by best all-in price (quote ± fee), splitting at displayed size. Child quantities are written into outQty[venue]: the array must be at least venueCount() long and indices [0, venueCount) are fully overwritten (entries beyond that are untouched). The return value is the total routed quantity — anything short of quantity found no displayed liquidity. Zero allocation.
      Parameters:
      limitTick - worst acceptable raw price in ticks (before fees); pass Integer.MAX_VALUE (buy) / Integer.MIN_VALUE (sell) for pure market
    • venueCount

      public int venueCount()
    • routeCount

      public long routeCount()