Class CrossRateEngine

java.lang.Object
com.quantfinlib.fx.CrossRateEngine

public final class CrossRateEngine extends Object
Streaming cross-rate derivation on the HFT tick path: maintains synthetic crosses (EURJPY from EURUSD × USDJPY, EURGBP from EURUSD ÷ GBPUSD) live from their leg ticks, with zero allocation per tick.

Two compositions cover every triangulation:

Threading. Cross updates are delivered synchronously on the bus consumer thread through a caller-supplied TickListener — they are deliberately not re-published onto the bus, whose ring is single-producer (the feed thread); publishing from the consumer thread would break that contract. Chain downstream logic (streaming indicators, a quoter) off the listener exactly as off a native symbol. The cross symbol is still registered on the bus so it owns a dense id, usable with SymbolRegistry lookups and the order gateway.

Setup (addCross(java.lang.String, java.lang.String, java.lang.String, com.quantfinlib.fx.CrossRateEngine.Op, com.quantfinlib.marketdata.TickListener)) allocates; the per-tick path touches only primitive arrays captured at setup. Static one-shot math (mid from two leg quotes) lives in pricing.TriangularArbitrage; this class is its streaming counterpart.

  • Constructor Details

  • Method Details

    • addCross

      public int addCross(String legA, String legB, String crossSymbol, CrossRateEngine.Op op, TickListener listener)
      Registers a synthetic cross. Both legs and the cross symbol are registered on the bus; the returned dense id identifies the cross in listener callbacks. Call before bus.start().
      Parameters:
      listener - receives the derived cross tick (cross id, price, the triggering leg's size, the triggering leg's timestamp) on the bus consumer thread — must not block
    • crossSymbols

      public List<String> crossSymbols()
      Symbols of all registered crosses, in registration order.