Class CrossRateEngine
Two compositions cover every triangulation:
CrossRateEngine.Op.MULTIPLY— legs share the middle currency on opposite sides: A/B × B/C = A/C (EURUSD × USDJPY = EURJPY);CrossRateEngine.Op.DIVIDE— legs share the quote currency: A/C ÷ B/C = A/B (EURUSD ÷ GBPUSD = EURGBP).
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.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic enumHow the two leg prices compose into the cross. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionintaddCross(String legA, String legB, String crossSymbol, CrossRateEngine.Op op, TickListener listener) Registers a synthetic cross.Symbols of all registered crosses, in registration order.
-
Constructor Details
-
CrossRateEngine
-
-
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 inlistenercallbacks. Call beforebus.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
-