Class TaLibRTIndicatorAdapter
java.lang.Object
com.wualabs.qtsurfer.engine.indicators.talib.TaLibRTIndicatorAdapter
- All Implemented Interfaces:
Resettable, 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);
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic interfaceFunctional interface wrapping a TA-Lib batch computation. -
Method Summary
Modifier and TypeMethodDescriptiondoublegetValue()static TaLibRTIndicatorAdapterof(TaLibRTIndicatorAdapter.TaLibFunction function, int maxSize) Creates an adapter wrapping a TA-Lib batch function.voidreset()doubleupdate(double newValue) Methods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface RTIndicator
getDisplayHint, getId, getMeta, isHidden, isReady, ro, update, update
-
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 updatemaxSize- the maximum number of price values to buffer- Returns:
- a new RTIndicator backed by TA-Lib
-
update
public double update(double newValue) - Specified by:
updatein interfaceRTIndicator
-
getValue
public double getValue()- Specified by:
getValuein interfaceRTIndicator
-
reset
public void reset()- Specified by:
resetin interfaceResettable
-