Class InstrumentGroupRTIndicator
- All Implemented Interfaces:
ClockAware, Resettable, RTIndicator
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final StringBandwidth name suffix — a structural disambiguator (the band's own name), not a display hint.static final Stringstatic final String -
Constructor Summary
ConstructorsConstructorDescriptionInstrumentGroupRTIndicator(Instrument instrument) InstrumentGroupRTIndicator(@NonNull InstrumentMapRTIndicator indicators) -
Method Summary
Modifier and TypeMethodDescriptionadd(@NonNull String name, @NonNull MarketSnapshotValueSource valueSource) add(@NonNull String name, @NonNull MarketSnapshotValueSource valueSource, RTIndicator indicator) add(@NonNull String name, @NonNull RTIndicator indicator) add(@NonNull String name, @NonNull RTIndicator indicator, @NonNull DisplayHint displayHint) Registers an indicator under a clean name, carrying itsDisplayHintas descriptor metadata instead of smuggling it into the name.addPrice()voidaddWindow(WindowTimeRTIndicator window) backtestEnabled(boolean backtestEnabled) Enables or disables backtest mode for this group and its underlying indicator map.bollinger(int periods) Adds a Bollinger Bands indicator with its upper and lower bands as separate named entries.bollingerBandwidth(String bollingerIndicatorName) Adds a Bollinger BandWidth indicator derived from an existing Bollinger indicator.cci(int periods) CCI overperiods, registered as"cci" + periods.voidclear()conditional(String name, String indicator, @NonNull Predicate<RTIndicator> predicate, @NonNull RTIndicator thenIndicator) conditional(String name, String indicator, @NonNull Predicate<RTIndicator> predicate, @NonNull RTIndicator thenIndicator, RTIndicator elseIndicator) decorate(String name, String indicator, @NonNull UnaryOperator<RTIndicator> op) Wraps an existing indicator with a unary operator transformation and registers the result.distanceMa(String indicator) distanceMa(String name, String indicator) ema(int periods) equal(String name, String indicator, @NonNull Number coefficient, String thenIndicator, String elseIndicator) getExisting(String name) Wiring diagnostics raised about this group's indicators — e.g. one that needs per-bar OHLCV bound to a ticker stream.getReadOnly(String name) getReadOnlyExisting(String name) Returns this group's state store — the single store every window listener of this instrument shares — either the injected one or an in-memory store created on first access.doublegreatOrEqual(String name, String indicator, @NonNull Number coefficient) greatOrEqual(String name, String indicator, @NonNull Number coefficient, String thenIndicator) greatOrEqual(String name, String indicator, @NonNull Number coefficient, String thenIndicator, String elseIndicator) greatThan(String name, String indicator, @NonNull Number coefficient, String thenIndicator, String elseIndicator) indicatorBank(com.wualabs.qtsurfer.engine.indicators.cache.IndicatorBank.Session indicatorBankSession) Routes every indicator registered from here on through a memoization bank, so a batch of runs over one dataset computes each distinct indicator once.booleanlessOrEqual(String name, String indicator, @NonNull Number coefficient) lessOrEqual(String name, String indicator, @NonNull Number coefficient, String thenIndicator) lessOrEqual(String name, String indicator, @NonNull Number coefficient, String thenIndicator, String elseIndicator) lessThan(String name, String indicator, @NonNull Number coefficient, String thenIndicator, String elseIndicator) macd()MACD (12/26) of this group's default source, registered as"macd".MACD (12/26) of this group's default source.MACD of another registered indicator.notEqual(String name, String indicator, @NonNull Number coefficient, String thenIndicator, String elseIndicator) percentChange(String indicator) percentChange(String name, String indicator) periodCount(String name, String indicator, @NonNull Predicate<Double> predicate) rateChange(String indicator) rateChange(String name, String indicator, boolean percent) Unregisters an indicator and hands back the instance that was doing the work.voidreset()Resets every indicator in this group in place, mirroringsetClockSupplier(Supplier).voidrsi(int periods) rsi(int periods, boolean sma) voidsetClockSupplier(Supplier<Clock> clockSupplier) sma(int periods) stateStoreSupplier(@NonNull Supplier<StateStore> stateStoreSupplier) Replaces the store this group hands to its windows.stochRsi(int periods) Stochastic RSI overperiods, registered as"stochRsi" + periods.Stochastic RSI — output is [0, 100], henceDisplayHint.PERCENT.useTickerValue(@NonNull String indicatorName, @NonNull MarketSnapshotValueSource valueSource) Wraps an existing indicator with aTickerRTIndicatorso it receives values from a specific snapshot value source instead of raw numeric updates.window()Creates a new WindowTimeRTIndicatorBuilder wired to this group's indicator map.window(WindowTimeRTIndicator.WindowTime windowTime) window(@NonNull String indicatorName, int windowTimeSeconds, @NonNull OnChangeRTIndicator.OnChangeListener onChangeListener) window(@NonNull String indicatorName, @NonNull WindowTimeRTIndicator.WindowTime windowTime, @NonNull OnChangeRTIndicator.OnChangeListener onChangeListener) window(@NonNull String indicatorName, @NonNull Duration windowTime, @NonNull OnChangeRTIndicator.OnChangeListener onChangeListener) Methods inherited from class AbstractRTIndicator
equals, getDisplayHint, getMeta, getValue, hashCode, hide, isPoison, setValue, toString, toString, update, withDisplayHint, withMeta
-
Field Details
-
PREFIX_HIDDEN
- See Also:
-
RTINDICATOR_PRICE
- See Also:
-
PREFIX_SMA
- See Also:
-
PREFIX_EMA
- See Also:
-
PREFIX_RSI
- See Also:
-
PREFIX_MACD
- See Also:
-
PREFIX_CCI
- See Also:
-
PREFIX_STOCH_RSI
- See Also:
-
PREFIX_BOLLINGER
- See Also:
-
PREFIX_GAIN
- See Also:
-
PREFIX_LOSS
- See Also:
-
PREFIX_WINDOW
- See Also:
-
PREFIX_DIST
- See Also:
-
PREFIX_SUM
- See Also:
-
PREFIX_MAX
- See Also:
-
PREFIX_MIN
- See Also:
-
PREFIX_ADD
- See Also:
-
PREFIX_DIFF
- See Also:
-
PREFIX_MUL
- See Also:
-
PREFIX_RATE_CHANGE
- See Also:
-
PREFIX_CLAMP
- See Also:
-
PREFIX_ROUND
- See Also:
-
SUBFIX_BOLLINGER_UPPER
- See Also:
-
SUBFIX_BOLLINGER_LOWER
- See Also:
-
SUBFIX_BANDWIDTH
Bandwidth name suffix — a structural disambiguator (the band's own name), not a display hint.- See Also:
-
-
Constructor Details
-
InstrumentGroupRTIndicator
-
InstrumentGroupRTIndicator
-
-
Method Details
-
getNotices
Wiring diagnostics raised about this group's indicators — e.g. one that needs per-bar OHLCV bound to a ticker stream. Delegates to the underlying map, which is where the dispatch that detects them happens; exposed here because this is the object a strategy already holds.- Returns:
- the notices in the order they were first raised, empty for a correctly wired group
-
addPrice
-
sma
-
sma
-
sma
-
ema
-
ema
-
rsi
-
rsi
-
rsi
-
macd
MACD (12/26) of this group's default source, registered as"macd". -
macd
MACD (12/26) of this group's default source. -
macd
-
macd
public InstrumentGroupRTIndicator macd(String name, String indicator, int shortEmaPeriods, int longEmaPeriods) MACD of another registered indicator. -
cci
CCI overperiods, registered as"cci" + periods. -
cci
-
stochRsi
Stochastic RSI overperiods, registered as"stochRsi" + periods. -
stochRsi
Stochastic RSI — output is [0, 100], henceDisplayHint.PERCENT. -
bollinger
-
bollinger
-
bollinger
-
bollinger
Adds a Bollinger Bands indicator with its upper and lower bands as separate named entries. The middle band is registered undername, upper undername + "Upper", and lower undername + "Lower".- Parameters:
name- base name for the Bollinger indicator entriesperiods- number of periods for the SMA/standard deviation calculationk- multiplier for the standard deviation bands- Returns:
- this builder for chaining
-
bollingerBandwidth
Adds a Bollinger BandWidth indicator derived from an existing Bollinger indicator. If the named indicator is not found or is not a BollingerBandsRTIndicator, a new default Bollinger indicator is auto-created as a hidden (prefixed with "_") entry. The bandwidth indicator is registered asbollingerIndicatorName + "BW"and carries aDisplayHint.PERCENThint.- Parameters:
bollingerIndicatorName- name of the existing Bollinger indicator to derive from- Returns:
- this builder for chaining
-
gain
-
gain
-
gain
public InstrumentGroupRTIndicator gain(String name, String indicator, boolean resetPeriodsOnSustain) -
loss
-
loss
-
loss
public InstrumentGroupRTIndicator loss(String name, String indicator, boolean resetPeriodsOnSustain) -
max
-
max
-
min
-
min
-
sum
-
sum
-
distanceMa
-
distanceMa
-
distance
-
distance
-
percentChange
-
percentChange
-
rateChange
-
rateChange
-
window
public InstrumentGroupRTIndicator window(@NonNull @NonNull String indicatorName, int windowTimeSeconds, @NonNull @NonNull OnChangeRTIndicator.OnChangeListener onChangeListener) -
window
public InstrumentGroupRTIndicator window(@NonNull @NonNull String indicatorName, @NonNull @NonNull WindowTimeRTIndicator.WindowTime windowTime, @NonNull @NonNull OnChangeRTIndicator.OnChangeListener onChangeListener) -
window
public InstrumentGroupRTIndicator window(@NonNull @NonNull String indicatorName, @NonNull @NonNull Duration windowTime, @NonNull @NonNull OnChangeRTIndicator.OnChangeListener onChangeListener) -
sma
-
ema
-
decorate
public InstrumentGroupRTIndicator decorate(String name, String indicator, @NonNull @NonNull UnaryOperator<RTIndicator> op) Wraps an existing indicator with a unary operator transformation and registers the result. The source indicator is accessed as read-only, so the original is not mutated by updates.- Parameters:
name- name for the new decorated indicatorindicator- name of the existing indicator to wrapop- operator that receives the read-only indicator and returns a new one- Returns:
- this builder for chaining
-
equal
public InstrumentGroupRTIndicator equal(String name, String indicator, @NonNull @NonNull Number coefficient) -
notEqual
public InstrumentGroupRTIndicator notEqual(String name, String indicator, @NonNull @NonNull Number coefficient) -
greatOrEqual
public InstrumentGroupRTIndicator greatOrEqual(String name, String indicator, @NonNull @NonNull Number coefficient) -
greatThan
public InstrumentGroupRTIndicator greatThan(String name, String indicator, @NonNull @NonNull Number coefficient) -
lessOrEqual
public InstrumentGroupRTIndicator lessOrEqual(String name, String indicator, @NonNull @NonNull Number coefficient) -
lessThan
public InstrumentGroupRTIndicator lessThan(String name, String indicator, @NonNull @NonNull Number coefficient) -
predicate
public InstrumentGroupRTIndicator predicate(String name, String indicator, @NonNull @NonNull Predicate<Double> predicate) -
periodCount
public InstrumentGroupRTIndicator periodCount(String name, String indicator, @NonNull @NonNull Predicate<Double> predicate) -
equal
public InstrumentGroupRTIndicator equal(String name, String indicator, @NonNull @NonNull Number coefficient, String thenIndicator) -
equal
-
notEqual
public InstrumentGroupRTIndicator notEqual(String name, String indicator, @NonNull @NonNull Number coefficient, String thenIndicator) -
notEqual
-
greatOrEqual
public InstrumentGroupRTIndicator greatOrEqual(String name, String indicator, @NonNull @NonNull Number coefficient, String thenIndicator) -
greatOrEqual
-
greatThan
public InstrumentGroupRTIndicator greatThan(String name, String indicator, @NonNull @NonNull Number coefficient, String thenIndicator) -
greatThan
-
lessOrEqual
public InstrumentGroupRTIndicator lessOrEqual(String name, String indicator, @NonNull @NonNull Number coefficient, String thenIndicator) -
lessOrEqual
-
lessThan
public InstrumentGroupRTIndicator lessThan(String name, String indicator, @NonNull @NonNull Number coefficient, String thenIndicator) -
lessThan
-
conditional
public InstrumentGroupRTIndicator conditional(String name, String indicator, @NonNull @NonNull Predicate<RTIndicator> predicate, @NonNull @NonNull RTIndicator thenIndicator) -
conditional
public InstrumentGroupRTIndicator conditional(String name, String indicator, @NonNull @NonNull Predicate<RTIndicator> predicate, @NonNull @NonNull RTIndicator thenIndicator, RTIndicator elseIndicator) -
clamp
public InstrumentGroupRTIndicator clamp(String indicator, Predicate<Double> clampPredicate, Number clampValue) -
clamp
-
clamp
-
clamp
public InstrumentGroupRTIndicator clamp(String name, String indicator, Number minRange, Number maxRange) -
round
-
round
-
add
-
add
-
diff
-
diff
-
mul
-
mul
-
fun
public InstrumentGroupRTIndicator fun(String name, String indicatorA, String indicatorB, BiFunction<Double, Double, Double> bifunction) -
mul
-
mul
-
getStateStore
Returns this group's state store — the single store every window listener of this instrument shares — either the injected one or an in-memory store created on first access. A strategy overrides the whole topology by injecting its own supplier viastateStoreSupplier(Supplier), which is how state reaches a persistent backend .Because the store is shared, keys are a per-instrument namespace: two windows that use the same key see each other's value. Name keys accordingly.
Calling this materializes the store. Windows call it only when they have something to write , so a group nobody listens to never creates one.
- Returns:
- the state store for this instrument (never null)
-
stateStoreSupplier
public InstrumentGroupRTIndicator stateStoreSupplier(@NonNull @NonNull Supplier<StateStore> stateStoreSupplier) Replaces the store this group hands to its windows. Windows resolve through the group at event time rather than capturing a store when they are built, so this may be set before or aftersetupIndicators— what matters is that it lands before the first window boundary writes.- Parameters:
stateStoreSupplier- supplies the store for this instrument- Returns:
- this builder for chaining
-
indicatorBank
public InstrumentGroupRTIndicator indicatorBank(com.wualabs.qtsurfer.engine.indicators.cache.IndicatorBank.Session indicatorBankSession) Routes every indicator registered from here on through a memoization bank, so a batch of runs over one dataset computes each distinct indicator once.Must be set before the indicators are built. Interception happens as each one is registered, which is the only moment a replacement can still be picked up by the derived indicators that reference it — swapping afterwards would leave them reading an instance nothing updates any more.
- Parameters:
indicatorBankSession- this run's view of the bank, ornullto compute everything live (the default, and what every non-sweep caller gets)- Returns:
- this builder for chaining
-
add
public InstrumentGroupRTIndicator add(@NonNull @NonNull String name, @NonNull @NonNull RTIndicator indicator) -
add
public InstrumentGroupRTIndicator add(@NonNull @NonNull String name, @NonNull @NonNull RTIndicator indicator, @NonNull @NonNull DisplayHint displayHint) Registers an indicator under a clean name, carrying itsDisplayHintas descriptor metadata instead of smuggling it into the name. Replaces the oldadd(name + "%", indicator)convention: the registered name is now exactlyname, sogetExisting(name)finds it, and the charting layer reads the hint from the indicator.- Parameters:
name- the clean registration name (also the lookup name)indicator- the indicator to registerdisplayHint- how its value should be presented- Returns:
- this builder for chaining
-
add
public InstrumentGroupRTIndicator add(@NonNull @NonNull String name, @NonNull @NonNull MarketSnapshotValueSource valueSource) -
add
public InstrumentGroupRTIndicator add(@NonNull @NonNull String name, @NonNull @NonNull MarketSnapshotValueSource valueSource, RTIndicator indicator) -
useTickerValue
public InstrumentGroupRTIndicator useTickerValue(@NonNull @NonNull String indicatorName, @NonNull @NonNull MarketSnapshotValueSource valueSource) Wraps an existing indicator with aTickerRTIndicatorso it receives values from a specific snapshot value source instead of raw numeric updates. If the indicator already consumes a snapshot directly (implementsRichRTIndicator), the operation is skipped with a warning. The existing indicator is removed and re-added wrapped with the new value source.- Parameters:
indicatorName- name of the existing indicator to wrapvalueSource- the snapshot field to use as the value source- Returns:
- this builder for chaining
-
addWindow
-
getValue
-
getReadOnlyExisting
-
getReadOnly
-
getExisting
-
get
-
remove
Unregisters an indicator and hands back the instance that was doing the work.When memoization is active the registered object is a wrapper, and what comes back here is the indicator inside it, with any recording it had started dropped: a series that stops where the indicator left the group describes nothing a later run will replay.
- Parameters:
name- the registered name- Returns:
- the indicator, or
nullif nothing was registered under that name
-
reset
-
clear
public void clear() -
window
-
window
-
window
Creates a new WindowTimeRTIndicatorBuilder wired to this group's indicator map. Built windows are auto-registered: unnamed windows get an auto-generated hidden name viaaddWindow(WindowTimeRTIndicator), named windows are added under their own name. Every window inherits this group's state store, so listeners of one instrument share one state namespace.- Returns:
- a new builder for configuring and building a WindowTimeRTIndicator
-
setClockSupplier
- Specified by:
setClockSupplierin interfaceClockAware
-
reset
public void reset()Resets every indicator in this group in place, mirroringsetClockSupplier(Supplier). Distinct from the selectivereset(String...)overload: this no-arg override honors the baseResettable.reset()contract for the whole group. Instruments are kept (seeclear()); only rolling state is zeroed.- Specified by:
resetin interfaceResettable- Overrides:
resetin classAbstractRTIndicator
-
backtestEnabled
Enables or disables backtest mode for this group and its underlying indicator map. When enabled, ticker timestamps are used to set a fixed clock for time-aware indicators.- Parameters:
backtestEnabled- true to enable backtest mode- Returns:
- this builder for chaining
-
getInstrument
-
getIndicators
-
isBacktestEnabled
public boolean isBacktestEnabled()
-