Class HftOrderGateway
java.lang.Object
com.quantfinlib.trading.HftOrderGateway
- All Implemented Interfaces:
AutoCloseable
Ultra-low-latency order gateway — the fast lane from signal to venue. The
hot path (
submit(int, com.quantfinlib.orderbook.Side, long, double, long)) performs zero allocation, zero locking, zero
map lookups: an inline HftRiskGate check over primitive arrays,
then a release-store publish into a preallocated OrderRingBuffer.
A dedicated venue thread (busy-spin optional) drains orders to the
registered OrderListeners — the venue adapter (exchange session,
simulator, ...) lives on that side.
Return convention of submit(int, com.quantfinlib.orderbook.Side, long, double, long): positive = accepted order id;
negative = risk-rejected, with -returnValue the
HftRiskGate reason code; 0 = ring full (backpressure — the
caller chooses spin, drop, or kill-switch).
Single producer (the trading thread), single consumer (the venue
thread) — the same threading model as HftMarketDataBus.
-
Constructor Summary
ConstructorsConstructorDescriptionHftOrderGateway(int ringCapacity, HftRiskGate riskGate, boolean busySpin) HftOrderGateway(HftRiskGate riskGate) Parked venue thread, 8K ring. -
Method Summary
Modifier and TypeMethodDescriptionvoidaddOrderListener(OrderListener listener) voidclose()longOrders handed to the venue thread so far.longriskGate()voidstart()voidstop()Stops the venue thread after draining queued orders.longRisk-checks and submits one order.long
-
Constructor Details
-
HftOrderGateway
-
HftOrderGateway
Parked venue thread, 8K ring.
-
-
Method Details
-
addOrderListener
-
start
public void start() -
stop
public void stop()Stops the venue thread after draining queued orders. -
close
public void close()- Specified by:
closein interfaceAutoCloseable
-
submit
Risk-checks and submits one order. Zero allocation.- Returns:
- positive order id if accepted; negative
HftRiskGatereason code if rejected; 0 if the ring is full
-
riskGate
-
submittedCount
public long submittedCount() -
deliveredCount
public long deliveredCount()Orders handed to the venue thread so far. -
ringFullCount
public long ringFullCount()
-