Package com.quantfinlib.trading


package com.quantfinlib.trading
Order entry, two lanes (mirroring marketdata):

HFT fast laneHftRiskGate (zero-allocation pre-trade checks over int ids, ≈3 ns, cross-thread safe via VarHandle acquire/release), OrderRingBuffer (SPSC primitive ring) and HftOrderGateway (submit = risk check + release-store publish; measured tick-to-order p50 ≈ 504 ns). On top of the lane: HftQuoter (streaming two-sided market maker with inventory skew, tick-grid snap and conflation — measured tick-to-two-sided-quote p50 ≈ 592 ns) with AvellanedaStoikov (the principled quoting model behind the quoter's heuristic skew: closed-form reservation price and optimal spread from risk aversion, variance and fill intensity), AutoHedger (live position-band hedging with in-flight cooldown), OrderThrottle (venue message-rate token bucket) and LastLookGate (maker-side symmetric last-look price check per the FX Global Code). Venue adapters implement OrderListener — see sbe.BinaryOrderPublisher and the FIX engine. Scale-out: ShardedTradingEngine (shared-nothing shards) under GlobalRiskAggregator (firm-wide gross-notional circuit breaker).

Simulation lanePaperTradingGateway (quote-driven fills, average-cost accounting, pre-trade risk gate; fully synchronized with atomic snapshot()) observed live through TradingDashboard (zero-dep embedded HTTP).

  • Class
    Description
    Live position-band auto-hedger on the fast lane — the streaming counterpart to the batch hedging.DeltaHedger: while the batch hedger rebalances on a schedule against a model delta, this one watches the risk gate's live position on every tick and fires a flattening order through the HftOrderGateway the moment the band is breached.
    Avellaneda-Stoikov (2008) optimal market-making quotes — the principled version of the inventory skew HftQuoter applies heuristically.
    Firm-wide risk across shards — the piece sharding deliberately doesn't solve: each shard's HftRiskGate sees only its own symbols, so a "total gross notional across the firm" cap needs someone who can see all of them.
    Ultra-low-latency order gateway — the fast lane from signal to venue.
    Streaming two-sided quoter on the fast lane — the market-making loop: tick in → mid → inventory skew → tick-grid snap → two orders out through the HftRiskGate and HftOrderGateway, with zero allocation per tick.
    Quoting parameters.
    Zero-allocation pre-trade risk gate for the HFT order path — the fast-lane counterpart of PreTradeLimitChecker.
    Maker-side symmetric last-look price check — the mechanism FX liquidity providers apply to incoming deal requests, implemented the way the FX Global Code (Principle 17) says it must be: symmetric.
    Order entry abstraction — the seam between strategy code and the venue.
     
    All-primitive order callback on the venue side of the fast lane: no order object, no boxing, no allocation.
    Zero-allocation single-producer / single-consumer ring buffer for order messages — the order-entry mirror of the market-data TickRingBuffer: preallocated primitive slots, cache-line-padded sequences, acquire/release publication, and producer/consumer sequence caching.
    Lifecycle state of a gateway order.
    Order-rate throttle: a nanosecond token bucket for exchange message-rate limits (every real venue enforces one; exceeding it earns disconnects or fines, so the gateway must self-limit).
    Quote-driven paper trading venue: closes the research-to-production loop by running real strategy + risk-gate code against simulated fills.
    One internally consistent view of the whole account (single lock acquisition).
    Horizontal scaling as shipped machinery, not a recipe: N independent bus → risk gate → order gateway stacks (one consumer core and one venue core per shard) behind a single symbol-routing facade.
    Zero-dependency live trading dashboard (JDK com.sun.net.httpserver): serves a self-refreshing HTML page and a JSON status endpoint with the paper-trading account (cash, equity, realized Pinvalid input: '&L', positions, rejections) and any attached latency histograms — the whole live loop, observable in a browser.