Class TaLibRTIndicatorAdapter

java.lang.Object
com.wualabs.qtsurfer.engine.indicators.talib.TaLibRTIndicatorAdapter
All Implemented Interfaces:
Resettable, RTIndicator

public final class TaLibRTIndicatorAdapter extends Object implements RTIndicator
Adapts a TA-Lib batch function to the RTIndicator streaming interface.

TA-Lib operates on full arrays (batch API). This adapter maintains a rolling double[] buffer and re-invokes the TA-Lib function on each update(double) call, returning the most recent computed value.

Usage example:

Core core = new Core();
RTIndicator ema = TaLibRTIndicatorAdapter.of(
    (prices, endIdx, outBeg, outNb, outReal) -> {
        core.ema(0, endIdx, prices, 14, outBeg, outNb, outReal);
        return outReal[Math.max(0, outNb.value - 1)];
    }, 10_000);
  • Method Details

    • of

      public static TaLibRTIndicatorAdapter of(TaLibRTIndicatorAdapter.TaLibFunction function, int maxSize)
      Creates an adapter wrapping a TA-Lib batch function.
      Parameters:
      function - the TA-Lib computation to invoke on each update
      maxSize - the maximum number of price values to buffer
      Returns:
      a new RTIndicator backed by TA-Lib
    • update

      public double update(double newValue)
      Specified by:
      update in interface RTIndicator
    • getValue

      public double getValue()
      Specified by:
      getValue in interface RTIndicator
    • reset

      public void reset()
      Specified by:
      reset in interface Resettable